@volter/twin-googlemaps 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +96 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +23 -0
- package/dist/src/googlemaps-auth.d.ts +31 -0
- package/dist/src/googlemaps-auth.js +37 -0
- package/dist/src/googlemaps-budget.d.ts +61 -0
- package/dist/src/googlemaps-budget.js +142 -0
- package/dist/src/googlemaps-capabilities.d.ts +3 -0
- package/dist/src/googlemaps-capabilities.js +648 -0
- package/dist/src/googlemaps-conformance.d.ts +8 -0
- package/dist/src/googlemaps-conformance.js +18 -0
- package/dist/src/googlemaps-connector.d.ts +94 -0
- package/dist/src/googlemaps-connector.js +243 -0
- package/dist/src/googlemaps-data.d.ts +87 -0
- package/dist/src/googlemaps-data.js +370 -0
- package/dist/src/googlemaps-perform-harness.d.ts +5 -0
- package/dist/src/googlemaps-perform-harness.js +17 -0
- package/dist/src/googlemaps-server.d.ts +14 -0
- package/dist/src/googlemaps-server.js +25 -0
- package/dist/src/googlemaps-twin.d.ts +2 -0
- package/dist/src/googlemaps-twin.js +1116 -0
- package/dist/src/googlemaps-types.d.ts +45 -0
- package/dist/src/googlemaps-types.js +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +65 -0
- package/package.json +52 -0
- package/src/cli.ts +22 -0
- package/src/googlemaps-auth.ts +52 -0
- package/src/googlemaps-budget.ts +168 -0
- package/src/googlemaps-capabilities.ts +766 -0
- package/src/googlemaps-conformance.ts +24 -0
- package/src/googlemaps-connector.ts +250 -0
- package/src/googlemaps-data.ts +399 -0
- package/src/googlemaps-perform-harness.ts +17 -0
- package/src/googlemaps-server.ts +33 -0
- package/src/googlemaps-twin.ts +1110 -0
- package/src/googlemaps-types.ts +47 -0
- package/src/index.ts +124 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// A MINIATURE OF THE HEAD, for this pack's own claims and suites (protocol 2). Not on the serve path.
|
|
2
|
+
import { confirmAction, deployableEntries, worldNow } from '@volter/world-core';
|
|
3
|
+
import { pushGoogleMapsAction, type GoogleMapsExecute } from './googlemaps-connector.ts';
|
|
4
|
+
|
|
5
|
+
export async function performPending(execute: GoogleMapsExecute, opts: { root?: string; occurredAt?: string } = {}): Promise<number> {
|
|
6
|
+
let pushed = 0;
|
|
7
|
+
for (const entry of deployableEntries('googlemaps', opts.root)) {
|
|
8
|
+
if (!(await pushGoogleMapsAction(entry, execute))) continue;
|
|
9
|
+
confirmAction({
|
|
10
|
+
service: 'googlemaps', actionId: entry.id, subject: entry.subject, fields: entry.fields ?? {},
|
|
11
|
+
occurredAt: opts.occurredAt ?? worldNow(), receipt: { status: 'deployed' },
|
|
12
|
+
...(opts.root !== undefined ? { root: opts.root } : {}),
|
|
13
|
+
});
|
|
14
|
+
pushed += 1;
|
|
15
|
+
}
|
|
16
|
+
return pushed;
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Google Maps twin HTTP server — serve the full Google Maps Platform twin handler over HTTP so
|
|
2
|
+
// the real clients (pointed at this base URL) work unmodified.
|
|
3
|
+
//
|
|
4
|
+
// FETCH-FIRST (runtime contract R12b): the pack's whole HTTP surface is the plain fetch below,
|
|
5
|
+
// built from the kernel's ONE adaptation (`createTwinFetchFromHandler` — manifest door, body
|
|
6
|
+
// read, header map, worldNow() stamp, JSON reply). This file contributes only VALUES. The
|
|
7
|
+
// server is one line of Bun.serve around that same closure, so the standalone (R1) and hosted
|
|
8
|
+
// lanes execute identical serving bytes.
|
|
9
|
+
import { serveHttp } from '@volter/world-core';
|
|
10
|
+
import { handleGoogleMapsTwinRequest } from './googlemaps-twin.ts';
|
|
11
|
+
import { createTwinFetchFromHandler, statefulTwinManifest } from '@volter/world-core';
|
|
12
|
+
|
|
13
|
+
/** Options every Google Maps-twin HTTP surface needs, independent of who owns the socket. */
|
|
14
|
+
export interface GoogleMapsTwinFetchOptions {
|
|
15
|
+
root?: string;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createGoogleMapsTwinFetch(options: GoogleMapsTwinFetchOptions = {}): (request: Request) => Promise<Response> {
|
|
20
|
+
return createTwinFetchFromHandler(handleGoogleMapsTwinRequest, {
|
|
21
|
+
...options,
|
|
22
|
+
manifest: statefulTwinManifest({ vendor: 'googlemaps', twinOf: 'the Google Maps Platform web services', stores: 'deterministic geocoding/places/roads answers derived from the request' }),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function createGoogleMapsTwinServer(options: { root?: string; port?: number; readOnly?: boolean } = {}): Promise<{ port: number; stop: () => void }> {
|
|
27
|
+
const server = await serveHttp({
|
|
28
|
+
port: options.port ?? 0,
|
|
29
|
+
idleTimeout: 60,
|
|
30
|
+
fetch: createGoogleMapsTwinFetch(options),
|
|
31
|
+
});
|
|
32
|
+
return { port: server.port ?? options.port ?? 0, stop: () => server.stop(true) };
|
|
33
|
+
}
|