@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 59 lines 2.18 KB
Raw
1 import type * as geoRoutes from "@distilled.cloud/aws/geo-routes";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4
5 /**
6 * Runtime binding for `geo-routes:CalculateRouteMatrix` — compute travel time
7 * and distance for all pairs of origins to destinations in one call (an
8 * origin-destination cost matrix), e.g. rank the nearest store for each
9 * customer.
10 *
11 * geo-routes is a standalone, pay-per-call Amazon Location API with no
12 * resource to manage: the binding takes no arguments and grants the function
13 * `geo-routes:CalculateRouteMatrix`. Requests and responses are raw distilled
14 * types (positions are `[longitude, latitude]` pairs). The matrix requires a
15 * `RoutingBoundary` — a geometry that contains all origins and destinations,
16 * or `{ Unbounded: true }`.
17 *
18 * ### Calculating a Route Matrix
19 * Provide the `CalculateRouteMatrixHttp` implementation layer on the Function
20 * effect (`.pipe(Effect.provide(AWS.GeoRoutes.CalculateRouteMatrixHttp))`),
21 * bind in the init phase, then call the client at runtime.
22 *
23 * **Example:** Calculate a 2x2 origin-destination matrix
24 * ```typescript
25 * // init
26 * const calculateRouteMatrix = yield* AWS.GeoRoutes.CalculateRouteMatrix();
27 *
28 * // runtime — positions are [longitude, latitude]
29 * const result = yield* calculateRouteMatrix({
30 * Origins: [
31 * { Position: [-122.339, 47.61] },
32 * { Position: [-122.335, 47.608] },
33 * ],
34 * Destinations: [
35 * { Position: [-122.201, 47.61] },
36 * { Position: [-122.313, 47.62] },
37 * ],
38 * RoutingBoundary: {
39 * Geometry: { Circle: { Center: [-122.3, 47.61], Radius: 30_000 } },
40 * },
41 * });
42 * const secondsFromFirstOriginToFirstDestination =
43 * result.RouteMatrix[0]?.[0]?.Duration;
44 * ```
45 *
46 * @binding
47 */
48 export interface CalculateRouteMatrix extends Binding.Service<
49 CalculateRouteMatrix,
50 "AWS.GeoRoutes.CalculateRouteMatrix",
51 () => Effect.Effect<
52 (
53 request: geoRoutes.CalculateRouteMatrixRequest,
54 ) => Effect.Effect<geoRoutes.CalculateRouteMatrixResponse, geoRoutes.CalculateRouteMatrixError>
55 >
56 > {}
57 export const CalculateRouteMatrix = Binding.Service<CalculateRouteMatrix>(
58 "AWS.GeoRoutes.CalculateRouteMatrix",
59 );