googlemaps-kit 0.1.3 → 0.2.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/README.md +146 -179
- package/dist/advanced/auth.d.ts +10 -0
- package/dist/advanced/auth.d.ts.map +1 -0
- package/dist/advanced/auth.js +8 -0
- package/dist/advanced/auth.js.map +1 -0
- package/dist/advanced/http.d.ts +10 -0
- package/dist/advanced/http.d.ts.map +1 -0
- package/dist/advanced/http.js +9 -0
- package/dist/advanced/http.js.map +1 -0
- package/dist/advanced/parsers.d.ts +28 -0
- package/dist/advanced/parsers.d.ts.map +1 -0
- package/dist/advanced/parsers.js +25 -0
- package/dist/advanced/parsers.js.map +1 -0
- package/dist/advanced/rpc.d.ts +29 -0
- package/dist/advanced/rpc.d.ts.map +1 -0
- package/dist/advanced/rpc.js +23 -0
- package/dist/advanced/rpc.js.map +1 -0
- package/dist/advanced/services.d.ts +34 -0
- package/dist/advanced/services.d.ts.map +1 -0
- package/dist/advanced/services.js +29 -0
- package/dist/advanced/services.js.map +1 -0
- package/dist/advanced/utils.d.ts +15 -0
- package/dist/advanced/utils.d.ts.map +1 -0
- package/dist/advanced/utils.js +13 -0
- package/dist/advanced/utils.js.map +1 -0
- package/dist/advanced.d.ts +43 -0
- package/dist/advanced.d.ts.map +1 -0
- package/dist/advanced.js +26 -0
- package/dist/advanced.js.map +1 -0
- package/dist/auth/session.d.ts +6 -1
- package/dist/auth/session.d.ts.map +1 -1
- package/dist/auth/session.js +23 -8
- package/dist/auth/session.js.map +1 -1
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +115 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/gmaps-client.d.ts +91 -52
- package/dist/client/gmaps-client.d.ts.map +1 -1
- package/dist/client/gmaps-client.js +209 -109
- package/dist/client/gmaps-client.js.map +1 -1
- package/dist/client/http-client.d.ts +28 -3
- package/dist/client/http-client.d.ts.map +1 -1
- package/dist/client/http-client.js +163 -14
- package/dist/client/http-client.js.map +1 -1
- package/dist/client/intent.d.ts +75 -0
- package/dist/client/intent.d.ts.map +1 -0
- package/dist/client/intent.js +546 -0
- package/dist/client/intent.js.map +1 -0
- package/dist/client/maps-tools.d.ts +80 -0
- package/dist/client/maps-tools.d.ts.map +1 -0
- package/dist/client/maps-tools.js +187 -0
- package/dist/client/maps-tools.js.map +1 -0
- package/dist/client/namespaces.d.ts +121 -0
- package/dist/client/namespaces.d.ts.map +1 -0
- package/dist/client/namespaces.js +169 -0
- package/dist/client/namespaces.js.map +1 -0
- package/dist/client/place-enrichment.d.ts +19 -0
- package/dist/client/place-enrichment.d.ts.map +1 -0
- package/dist/client/place-enrichment.js +71 -0
- package/dist/client/place-enrichment.js.map +1 -0
- package/dist/client/product-namespaces.d.ts +30 -0
- package/dist/client/product-namespaces.d.ts.map +1 -0
- package/dist/client/product-namespaces.js +47 -0
- package/dist/client/product-namespaces.js.map +1 -0
- package/dist/index.d.ts +31 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -28
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -137
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +3 -94
- package/dist/internal.js.map +1 -1
- package/dist/parsers/place.d.ts.map +1 -1
- package/dist/parsers/place.js +2 -0
- package/dist/parsers/place.js.map +1 -1
- package/dist/parsers/reviews.d.ts +0 -2
- package/dist/parsers/reviews.d.ts.map +1 -1
- package/dist/parsers/reviews.js +0 -2
- package/dist/parsers/reviews.js.map +1 -1
- package/dist/parsers/search.d.ts +13 -1
- package/dist/parsers/search.d.ts.map +1 -1
- package/dist/parsers/search.js +130 -71
- package/dist/parsers/search.js.map +1 -1
- package/dist/rpc/batch-execute.d.ts.map +1 -1
- package/dist/rpc/batch-execute.js +20 -3
- package/dist/rpc/batch-execute.js.map +1 -1
- package/dist/rpc/batch-rpc.d.ts.map +1 -1
- package/dist/rpc/batch-rpc.js +5 -6
- package/dist/rpc/batch-rpc.js.map +1 -1
- package/dist/rpc/batch-services.d.ts +2 -0
- package/dist/rpc/batch-services.d.ts.map +1 -1
- package/dist/rpc/batch-services.js +4 -0
- package/dist/rpc/batch-services.js.map +1 -1
- package/dist/rpc/pb-builders.d.ts +0 -2
- package/dist/rpc/pb-builders.d.ts.map +1 -1
- package/dist/rpc/pb-builders.js +2 -5
- package/dist/rpc/pb-builders.js.map +1 -1
- package/dist/rpc/rpc-client.d.ts +6 -2
- package/dist/rpc/rpc-client.d.ts.map +1 -1
- package/dist/rpc/rpc-client.js +26 -10
- package/dist/rpc/rpc-client.js.map +1 -1
- package/dist/rpc/rpc-methods.d.ts +0 -7
- package/dist/rpc/rpc-methods.d.ts.map +1 -1
- package/dist/rpc/rpc-methods.js +0 -7
- package/dist/rpc/rpc-methods.js.map +1 -1
- package/dist/services/ask-maps.js +1 -1
- package/dist/services/ask-maps.js.map +1 -1
- package/dist/services/directions.d.ts +3 -8
- package/dist/services/directions.d.ts.map +1 -1
- package/dist/services/directions.js +37 -13
- package/dist/services/directions.js.map +1 -1
- package/dist/services/geocode.js +1 -1
- package/dist/services/photos.d.ts.map +1 -1
- package/dist/services/photos.js +2 -5
- package/dist/services/photos.js.map +1 -1
- package/dist/services/places.d.ts.map +1 -1
- package/dist/services/places.js +13 -4
- package/dist/services/places.js.map +1 -1
- package/dist/services/reviews.d.ts +7 -0
- package/dist/services/reviews.d.ts.map +1 -1
- package/dist/services/reviews.js +10 -1
- package/dist/services/reviews.js.map +1 -1
- package/dist/services/search.d.ts +7 -5
- package/dist/services/search.d.ts.map +1 -1
- package/dist/services/search.js +46 -17
- package/dist/services/search.js.map +1 -1
- package/dist/services/ugc-aggregates.d.ts.map +1 -1
- package/dist/services/ugc-aggregates.js +1 -17
- package/dist/services/ugc-aggregates.js.map +1 -1
- package/dist/types/common.d.ts +92 -6
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +12 -0
- package/dist/types/common.js.map +1 -1
- package/dist/types/directions.d.ts +16 -2
- package/dist/types/directions.d.ts.map +1 -1
- package/dist/types/dx.d.ts +289 -0
- package/dist/types/dx.d.ts.map +1 -0
- package/dist/types/dx.js +7 -0
- package/dist/types/dx.js.map +1 -0
- package/dist/types/hooks.d.ts +48 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/hooks.js +5 -0
- package/dist/types/hooks.js.map +1 -0
- package/dist/utils/abort.d.ts +7 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +43 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/coords.d.ts +24 -0
- package/dist/utils/coords.d.ts.map +1 -0
- package/dist/utils/coords.js +37 -0
- package/dist/utils/coords.js.map +1 -0
- package/dist/utils/export-results.d.ts +24 -0
- package/dist/utils/export-results.d.ts.map +1 -0
- package/dist/utils/export-results.js +105 -0
- package/dist/utils/export-results.js.map +1 -0
- package/dist/utils/hooks.d.ts +10 -0
- package/dist/utils/hooks.d.ts.map +1 -0
- package/dist/utils/hooks.js +47 -0
- package/dist/utils/hooks.js.map +1 -0
- package/dist/utils/place-ref.d.ts +39 -0
- package/dist/utils/place-ref.d.ts.map +1 -0
- package/dist/utils/place-ref.js +109 -0
- package/dist/utils/place-ref.js.map +1 -0
- package/dist/utils/pooled.d.ts +2 -0
- package/dist/utils/pooled.d.ts.map +1 -1
- package/dist/utils/pooled.js +8 -0
- package/dist/utils/pooled.js.map +1 -1
- package/dist/utils/request-context.d.ts +9 -0
- package/dist/utils/request-context.d.ts.map +1 -0
- package/dist/utils/request-context.js +12 -0
- package/dist/utils/request-context.js.map +1 -0
- package/dist/utils/ttl-cache.d.ts +17 -0
- package/dist/utils/ttl-cache.d.ts.map +1 -0
- package/dist/utils/ttl-cache.js +43 -0
- package/dist/utils/ttl-cache.js.map +1 -0
- package/package.json +27 -12
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle hooks + progress events for Intent / HTTP.
|
|
3
|
+
*/
|
|
4
|
+
export type HookActionType = 'discover' | 'discoverPages' | 'resolve' | 'profile' | 'profileMany' | 'route' | 'opinions' | 'opinionsPages' | 'media' | 'mediaMany' | 'pipeline' | 'http.get' | 'http.getBytes' | 'batchexecute';
|
|
5
|
+
export interface HookActionEvent {
|
|
6
|
+
type: HookActionType | string;
|
|
7
|
+
status: 'ok' | 'error';
|
|
8
|
+
durationMs: number;
|
|
9
|
+
error?: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface HookRetryEvent {
|
|
12
|
+
type: HookActionType | string;
|
|
13
|
+
attempt: number;
|
|
14
|
+
delayMs?: number;
|
|
15
|
+
error?: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface HookErrorEvent {
|
|
18
|
+
type: HookActionType | string;
|
|
19
|
+
error: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** Wire once on `sdk({ hooks })` — fire-and-forget, never blocks the call. */
|
|
22
|
+
export interface GMapsHooks {
|
|
23
|
+
onAction?: (event: HookActionEvent) => void;
|
|
24
|
+
onRetry?: (event: HookRetryEvent) => void;
|
|
25
|
+
onError?: (event: HookErrorEvent) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface ProgressEvent {
|
|
28
|
+
/** Logical operation, e.g. `discover`, `opinions`, `profileMany`. */
|
|
29
|
+
type: string;
|
|
30
|
+
/** 1-based page / item index when known. */
|
|
31
|
+
index?: number;
|
|
32
|
+
/** Total pages / items when known. */
|
|
33
|
+
total?: number;
|
|
34
|
+
/** Items accumulated so far. */
|
|
35
|
+
loaded?: number;
|
|
36
|
+
/** Opaque key (place hexId, page offset, …). */
|
|
37
|
+
key?: string;
|
|
38
|
+
done?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export type ProgressCallback = (event: ProgressEvent) => void;
|
|
41
|
+
/** Optional in-memory TTL cache for Intent reads. */
|
|
42
|
+
export interface GMapsCacheOptions {
|
|
43
|
+
/** Entry lifetime in ms (default 60_000). */
|
|
44
|
+
ttlMs?: number;
|
|
45
|
+
/** Max entries before LRU eviction (default 256). */
|
|
46
|
+
maxEntries?: number;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,eAAe,GACf,SAAS,GACT,SAAS,GACT,aAAa,GACb,OAAO,GACP,UAAU,GACV,eAAe,GACf,OAAO,GACP,WAAW,GACX,UAAU,GACV,UAAU,GACV,eAAe,GACf,cAAc,CAAC;AAEnB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,cAAc,GAAG,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,cAAc,GAAG,MAAM,CAAC;IAC9B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAE9D,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abort helpers shared by HTTP, Intent, and CLI.
|
|
3
|
+
*/
|
|
4
|
+
export declare function throwIfAborted(signal?: AbortSignal): void;
|
|
5
|
+
/** Sleep that rejects when the signal aborts. */
|
|
6
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=abort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../src/utils/abort.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAOzD;AAED,iDAAiD;AACjD,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abort helpers shared by HTTP, Intent, and CLI.
|
|
3
|
+
*/
|
|
4
|
+
import { GMapsError } from '../types/common.js';
|
|
5
|
+
export function throwIfAborted(signal) {
|
|
6
|
+
if (!signal)
|
|
7
|
+
return;
|
|
8
|
+
if (signal.aborted) {
|
|
9
|
+
const reason = signal.reason;
|
|
10
|
+
if (reason instanceof Error)
|
|
11
|
+
throw reason;
|
|
12
|
+
throw new GMapsError(typeof reason === 'string' ? reason : 'Aborted', undefined, reason);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Sleep that rejects when the signal aborts. */
|
|
16
|
+
export function sleep(ms, signal) {
|
|
17
|
+
if (ms <= 0) {
|
|
18
|
+
throwIfAborted(signal);
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
if (signal?.aborted) {
|
|
23
|
+
reject(abortError(signal));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const timer = setTimeout(() => {
|
|
27
|
+
signal?.removeEventListener('abort', onAbort);
|
|
28
|
+
resolve();
|
|
29
|
+
}, ms);
|
|
30
|
+
const onAbort = () => {
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
reject(abortError(signal));
|
|
33
|
+
};
|
|
34
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function abortError(signal) {
|
|
38
|
+
const reason = signal?.reason;
|
|
39
|
+
if (reason instanceof Error)
|
|
40
|
+
return reason;
|
|
41
|
+
return new GMapsError(typeof reason === 'string' ? reason : 'Aborted', undefined, reason);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=abort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../src/utils/abort.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,UAAU,cAAc,CAAC,MAAoB;IACjD,IAAI,CAAC,MAAM;QAAE,OAAO;I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MAAM,YAAY,KAAK;QAAE,OAAO,MAAM,CAAC;IAC3C,OAAO,IAAI,UAAU,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared coordinate helpers — aliases between lat/lng and latitude/longitude.
|
|
3
|
+
*/
|
|
4
|
+
export interface CoordFields {
|
|
5
|
+
latitude?: number;
|
|
6
|
+
longitude?: number;
|
|
7
|
+
lat?: number;
|
|
8
|
+
lng?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface CoordinatesLike {
|
|
11
|
+
lat: number;
|
|
12
|
+
lng: number;
|
|
13
|
+
}
|
|
14
|
+
/** Copy latitude↔lat and longitude↔lng so both spellings are populated. */
|
|
15
|
+
export declare function applyCoordAliases<T extends CoordFields>(obj: T): T;
|
|
16
|
+
/**
|
|
17
|
+
* Normalize any coords-shaped object to `{ lat, lng }`.
|
|
18
|
+
* Accepts `lat`/`lng` or `latitude`/`longitude`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toCoordinates(value: CoordFields | {
|
|
21
|
+
lat: number;
|
|
22
|
+
lng: number;
|
|
23
|
+
} | null | undefined): CoordinatesLike | undefined;
|
|
24
|
+
//# sourceMappingURL=coords.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coords.d.ts","sourceRoot":"","sources":["../../src/utils/coords.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAYlE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GACnE,eAAe,GAAG,SAAS,CAa7B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared coordinate helpers — aliases between lat/lng and latitude/longitude.
|
|
3
|
+
*/
|
|
4
|
+
/** Copy latitude↔lat and longitude↔lng so both spellings are populated. */
|
|
5
|
+
export function applyCoordAliases(obj) {
|
|
6
|
+
const lat = obj.lat ?? obj.latitude;
|
|
7
|
+
const lng = obj.lng ?? obj.longitude;
|
|
8
|
+
if (lat != null) {
|
|
9
|
+
obj.lat = lat;
|
|
10
|
+
obj.latitude = lat;
|
|
11
|
+
}
|
|
12
|
+
if (lng != null) {
|
|
13
|
+
obj.lng = lng;
|
|
14
|
+
obj.longitude = lng;
|
|
15
|
+
}
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Normalize any coords-shaped object to `{ lat, lng }`.
|
|
20
|
+
* Accepts `lat`/`lng` or `latitude`/`longitude`.
|
|
21
|
+
*/
|
|
22
|
+
export function toCoordinates(value) {
|
|
23
|
+
if (!value || typeof value !== 'object')
|
|
24
|
+
return undefined;
|
|
25
|
+
const lat = 'lat' in value && typeof value.lat === 'number'
|
|
26
|
+
? value.lat
|
|
27
|
+
: value.latitude;
|
|
28
|
+
const lng = 'lng' in value && typeof value.lng === 'number'
|
|
29
|
+
? value.lng
|
|
30
|
+
: value.longitude;
|
|
31
|
+
if (typeof lat !== 'number' || typeof lng !== 'number')
|
|
32
|
+
return undefined;
|
|
33
|
+
if (!Number.isFinite(lat) || !Number.isFinite(lng))
|
|
34
|
+
return undefined;
|
|
35
|
+
return { lat, lng };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=coords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coords.js","sourceRoot":"","sources":["../../src/utils/coords.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAAwB,GAAM;IAC7D,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC;IACpC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC;IACrC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;QACd,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC;IACrB,CAAC;IACD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;QACd,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAoE;IAEpE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,MAAM,GAAG,GACP,KAAK,IAAI,KAAK,IAAI,OAAQ,KAA2B,CAAC,GAAG,KAAK,QAAQ;QACpE,CAAC,CAAE,KAAyB,CAAC,GAAG;QAChC,CAAC,CAAE,KAAqB,CAAC,QAAQ,CAAC;IACtC,MAAM,GAAG,GACP,KAAK,IAAI,KAAK,IAAI,OAAQ,KAA2B,CAAC,GAAG,KAAK,QAAQ;QACpE,CAAC,CAAE,KAAyB,CAAC,GAAG;QAChC,CAAC,CAAE,KAAqB,CAAC,SAAS,CAAC;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACzE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACrE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export helpers for discover / place results (CSV + GeoJSON).
|
|
3
|
+
*/
|
|
4
|
+
import type { PlaceDetails, SearchResult } from '../types/common.js';
|
|
5
|
+
import type { PlaceProfile } from '../types/dx.js';
|
|
6
|
+
export type ExportablePlace = SearchResult | PlaceDetails | PlaceProfile;
|
|
7
|
+
/** Flat CSV for spreadsheets / agents. */
|
|
8
|
+
export declare function toCsv(rows: ExportablePlace[]): string;
|
|
9
|
+
export interface GeoJsonFeatureCollection {
|
|
10
|
+
type: 'FeatureCollection';
|
|
11
|
+
features: Array<{
|
|
12
|
+
type: 'Feature';
|
|
13
|
+
geometry: {
|
|
14
|
+
type: 'Point';
|
|
15
|
+
coordinates: [number, number];
|
|
16
|
+
} | null;
|
|
17
|
+
properties: Record<string, unknown>;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/** GeoJSON FeatureCollection (skips rows without coords unless includeMissing). */
|
|
21
|
+
export declare function toGeoJSON(rows: ExportablePlace[], options?: {
|
|
22
|
+
includeMissing?: boolean;
|
|
23
|
+
}): GeoJsonFeatureCollection;
|
|
24
|
+
//# sourceMappingURL=export-results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-results.d.ts","sourceRoot":"","sources":["../../src/utils/export-results.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;AAoDzE,0CAA0C;AAC1C,wBAAgB,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,MAAM,CAoCrD;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,SAAS,CAAC;QAChB,QAAQ,EAAE;YAAE,IAAI,EAAE,OAAO,CAAC;YAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;SAAE,GAAG,IAAI,CAAC;QAClE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC,CAAC;CACJ;AAED,mFAAmF;AACnF,wBAAgB,SAAS,CACvB,IAAI,EAAE,eAAe,EAAE,EACvB,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAO,GACzC,wBAAwB,CAyB1B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export helpers for discover / place results (CSV + GeoJSON).
|
|
3
|
+
*/
|
|
4
|
+
function asPlaceFields(row) {
|
|
5
|
+
if ('place' in row && row.place) {
|
|
6
|
+
const p = row.place;
|
|
7
|
+
return {
|
|
8
|
+
name: p.name,
|
|
9
|
+
hexId: p.hexId,
|
|
10
|
+
placeId: p.placeId,
|
|
11
|
+
address: p.address,
|
|
12
|
+
lat: p.lat ?? p.latitude,
|
|
13
|
+
lng: p.lng ?? p.longitude,
|
|
14
|
+
rating: p.rating,
|
|
15
|
+
reviewCount: p.reviewCount,
|
|
16
|
+
phone: p.phone,
|
|
17
|
+
website: p.website,
|
|
18
|
+
category: p.categories?.[0],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const r = row;
|
|
22
|
+
return {
|
|
23
|
+
name: r.name,
|
|
24
|
+
hexId: r.hexId,
|
|
25
|
+
placeId: r.placeId,
|
|
26
|
+
address: r.address,
|
|
27
|
+
lat: r.lat ?? r.latitude,
|
|
28
|
+
lng: r.lng ?? r.longitude,
|
|
29
|
+
rating: r.rating,
|
|
30
|
+
reviewCount: r.reviewCount,
|
|
31
|
+
phone: r.phone,
|
|
32
|
+
website: r.website,
|
|
33
|
+
category: 'category' in r ? r.category : r.categories?.[0],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function csvEscape(value) {
|
|
37
|
+
if (/[",\n\r]/.test(value))
|
|
38
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
/** Flat CSV for spreadsheets / agents. */
|
|
42
|
+
export function toCsv(rows) {
|
|
43
|
+
const header = [
|
|
44
|
+
'name',
|
|
45
|
+
'hexId',
|
|
46
|
+
'placeId',
|
|
47
|
+
'address',
|
|
48
|
+
'lat',
|
|
49
|
+
'lng',
|
|
50
|
+
'rating',
|
|
51
|
+
'reviewCount',
|
|
52
|
+
'phone',
|
|
53
|
+
'website',
|
|
54
|
+
'category',
|
|
55
|
+
];
|
|
56
|
+
const lines = [header.join(',')];
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const f = asPlaceFields(row);
|
|
59
|
+
lines.push([
|
|
60
|
+
f.name ?? '',
|
|
61
|
+
f.hexId ?? '',
|
|
62
|
+
f.placeId ?? '',
|
|
63
|
+
f.address ?? '',
|
|
64
|
+
f.lat ?? '',
|
|
65
|
+
f.lng ?? '',
|
|
66
|
+
f.rating ?? '',
|
|
67
|
+
f.reviewCount ?? '',
|
|
68
|
+
f.phone ?? '',
|
|
69
|
+
f.website ?? '',
|
|
70
|
+
f.category ?? '',
|
|
71
|
+
]
|
|
72
|
+
.map((v) => csvEscape(String(v)))
|
|
73
|
+
.join(','));
|
|
74
|
+
}
|
|
75
|
+
return lines.join('\n');
|
|
76
|
+
}
|
|
77
|
+
/** GeoJSON FeatureCollection (skips rows without coords unless includeMissing). */
|
|
78
|
+
export function toGeoJSON(rows, options = {}) {
|
|
79
|
+
const features = [];
|
|
80
|
+
for (const row of rows) {
|
|
81
|
+
const f = asPlaceFields(row);
|
|
82
|
+
const hasCoords = f.lat != null && f.lng != null;
|
|
83
|
+
if (!hasCoords && !options.includeMissing)
|
|
84
|
+
continue;
|
|
85
|
+
features.push({
|
|
86
|
+
type: 'Feature',
|
|
87
|
+
geometry: hasCoords
|
|
88
|
+
? { type: 'Point', coordinates: [f.lng, f.lat] }
|
|
89
|
+
: null,
|
|
90
|
+
properties: {
|
|
91
|
+
name: f.name,
|
|
92
|
+
hexId: f.hexId,
|
|
93
|
+
placeId: f.placeId,
|
|
94
|
+
address: f.address,
|
|
95
|
+
rating: f.rating,
|
|
96
|
+
reviewCount: f.reviewCount,
|
|
97
|
+
phone: f.phone,
|
|
98
|
+
website: f.website,
|
|
99
|
+
category: f.category,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return { type: 'FeatureCollection', features };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=export-results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-results.js","sourceRoot":"","sources":["../../src/utils/export-results.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,SAAS,aAAa,CAAC,GAAoB;IAazC,IAAI,OAAO,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;QACpB,OAAO;YACL,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,QAAQ;YACxB,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,S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C,IAAI,CAAC;YACZ,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,SAAS;gBACjB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,GAAI,EAAE,CAAC,CAAC,GAAI,CAAC,EAAE;gBAClD,CAAC,CAAC,IAAI;YACR,UAAU,EAAE;gBACV,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,QAAQ,EAAE,CAAC,CAAC,QAAQ;aACrB;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fire lifecycle hooks without letting user callbacks break the call path.
|
|
3
|
+
*/
|
|
4
|
+
import type { GMapsHooks, HookActionEvent, HookErrorEvent, HookRetryEvent } from '../types/hooks.js';
|
|
5
|
+
export declare function fireAction(hooks: GMapsHooks | undefined, event: HookActionEvent): void;
|
|
6
|
+
export declare function fireRetry(hooks: GMapsHooks | undefined, event: HookRetryEvent): void;
|
|
7
|
+
export declare function fireError(hooks: GMapsHooks | undefined, event: HookErrorEvent): void;
|
|
8
|
+
/** Wrap an Intent call with onAction / onError timing. */
|
|
9
|
+
export declare function withActionHook<T>(hooks: GMapsHooks | undefined, type: string, fn: () => Promise<T>): Promise<T>;
|
|
10
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/utils/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAErG,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAMtF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAMpF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAMpF;AAED,0DAA0D;AAC1D,wBAAsB,cAAc,CAAC,CAAC,EACpC,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAgBZ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fire lifecycle hooks without letting user callbacks break the call path.
|
|
3
|
+
*/
|
|
4
|
+
export function fireAction(hooks, event) {
|
|
5
|
+
try {
|
|
6
|
+
hooks?.onAction?.(event);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
// ignore hook failures
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function fireRetry(hooks, event) {
|
|
13
|
+
try {
|
|
14
|
+
hooks?.onRetry?.(event);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// ignore
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function fireError(hooks, event) {
|
|
21
|
+
try {
|
|
22
|
+
hooks?.onError?.(event);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Wrap an Intent call with onAction / onError timing. */
|
|
29
|
+
export async function withActionHook(hooks, type, fn) {
|
|
30
|
+
const start = performance.now();
|
|
31
|
+
try {
|
|
32
|
+
const result = await fn();
|
|
33
|
+
fireAction(hooks, { type, status: 'ok', durationMs: performance.now() - start });
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
fireAction(hooks, {
|
|
38
|
+
type,
|
|
39
|
+
status: 'error',
|
|
40
|
+
durationMs: performance.now() - start,
|
|
41
|
+
error,
|
|
42
|
+
});
|
|
43
|
+
fireError(hooks, { type, error });
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/utils/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,UAAU,UAAU,CAAC,KAA6B,EAAE,KAAsB;IAC9E,IAAI,CAAC;QACH,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,uBAAuB;IACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAA6B,EAAE,KAAqB;IAC5E,IAAI,CAAC;QACH,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAA6B,EAAE,KAAqB;IAC5E,IAAI,CAAC;QACH,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC;AAED,0DAA0D;AAC1D,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAA6B,EAC7B,IAAY,EACZ,EAAoB;IAEpB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;QAC1B,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;QACjF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,EAAE;YAChB,IAAI;YACJ,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK;YACrC,KAAK;SACN,CAAC,CAAC;QACH,SAAS,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAClC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlaceRef + route endpoint normalization (shared by Intent API and services).
|
|
3
|
+
*/
|
|
4
|
+
import type { Coordinates } from '../types/common.js';
|
|
5
|
+
import type { NormalizedPlaceRef, PlaceRef } from '../types/dx.js';
|
|
6
|
+
/**
|
|
7
|
+
* Normalize a PlaceRef for service calls.
|
|
8
|
+
* Accepts: hexId string, ChIJ placeId string, or object with hexId and/or placeId.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizePlaceRef(ref: PlaceRef): NormalizedPlaceRef;
|
|
11
|
+
/** Resolve route endpoint: address string, coords, or PlaceRef with coords. */
|
|
12
|
+
export declare function resolveRouteEndpoint(value: string | Coordinates | PlaceRef | CoordLoose): string | Coordinates;
|
|
13
|
+
type CoordLoose = {
|
|
14
|
+
lat?: number;
|
|
15
|
+
lng?: number;
|
|
16
|
+
latitude?: number;
|
|
17
|
+
longitude?: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolve search bias center from Intent (`near`) or service (`location`) spelling.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveSearchCenter(options: {
|
|
23
|
+
near?: Coordinates | CoordLoose;
|
|
24
|
+
location?: Coordinates | CoordLoose;
|
|
25
|
+
}): Coordinates;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve directions endpoints from Intent (`from`/`to`) or service (`origin`/`destination`).
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveDirectionsEndpoints(options: {
|
|
30
|
+
from?: string | Coordinates | PlaceRef;
|
|
31
|
+
to?: string | Coordinates | PlaceRef;
|
|
32
|
+
origin?: string | Coordinates | PlaceRef;
|
|
33
|
+
destination?: string | Coordinates | PlaceRef;
|
|
34
|
+
}): {
|
|
35
|
+
origin: string | Coordinates;
|
|
36
|
+
destination: string | Coordinates;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=place-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-ref.d.ts","sourceRoot":"","sources":["../../src/utils/place-ref.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAenE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG,kBAAkB,CAiDnE;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAClD,MAAM,GAAG,WAAW,CAgCtB;AAED,KAAK,UAAU,GAAG;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC3C,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAChC,QAAQ,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACrC,GAAG,WAAW,CAQd;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACvC,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;CAC/C,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAYtE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlaceRef + route endpoint normalization (shared by Intent API and services).
|
|
3
|
+
*/
|
|
4
|
+
import { GMapsError } from '../types/common.js';
|
|
5
|
+
import { placeIdToFeatureId } from './ids.js';
|
|
6
|
+
import { toCoordinates } from './coords.js';
|
|
7
|
+
const HEX_ID_RE = /^0x[0-9a-f]+:0x[0-9a-f]+$/i;
|
|
8
|
+
const PLACE_ID_RE = /^ChIJ[\w-]+$/;
|
|
9
|
+
function tryPlaceIdToHex(placeId) {
|
|
10
|
+
try {
|
|
11
|
+
return placeIdToFeatureId(placeId);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Normalize a PlaceRef for service calls.
|
|
19
|
+
* Accepts: hexId string, ChIJ placeId string, or object with hexId and/or placeId.
|
|
20
|
+
*/
|
|
21
|
+
export function normalizePlaceRef(ref) {
|
|
22
|
+
if (typeof ref === 'string') {
|
|
23
|
+
const trimmed = ref.trim();
|
|
24
|
+
if (!trimmed) {
|
|
25
|
+
throw new GMapsError('PlaceRef string must be a non-empty hexId or placeId');
|
|
26
|
+
}
|
|
27
|
+
if (HEX_ID_RE.test(trimmed)) {
|
|
28
|
+
return { hexId: trimmed };
|
|
29
|
+
}
|
|
30
|
+
if (PLACE_ID_RE.test(trimmed)) {
|
|
31
|
+
const hexId = tryPlaceIdToHex(trimmed);
|
|
32
|
+
if (!hexId) {
|
|
33
|
+
throw new GMapsError(`Could not convert placeId to hexId: ${trimmed}`);
|
|
34
|
+
}
|
|
35
|
+
return { hexId, placeId: trimmed };
|
|
36
|
+
}
|
|
37
|
+
throw new GMapsError('PlaceRef string must be a hexId (0x…:0x…) or ChIJ placeId — got an unrecognized id');
|
|
38
|
+
}
|
|
39
|
+
let hexId = ref.hexId?.trim();
|
|
40
|
+
const placeId = ref.placeId?.trim();
|
|
41
|
+
if (!hexId && placeId) {
|
|
42
|
+
hexId = tryPlaceIdToHex(placeId);
|
|
43
|
+
if (!hexId) {
|
|
44
|
+
throw new GMapsError(`PlaceRef has placeId but could not convert to hexId: ${placeId}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!hexId) {
|
|
48
|
+
throw new GMapsError('PlaceRef requires hexId (0x…:0x…) or placeId (ChIJ…). ' +
|
|
49
|
+
'If you called resolve(), check that the result includes hexId before profile/media/opinions.');
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
hexId,
|
|
53
|
+
name: ref.name,
|
|
54
|
+
lat: ref.lat ?? ref.latitude,
|
|
55
|
+
lng: ref.lng ?? ref.longitude,
|
|
56
|
+
placeId: placeId ?? ref.placeId,
|
|
57
|
+
ftid: ref.ftid,
|
|
58
|
+
reviewCount: ref.reviewCount,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Resolve route endpoint: address string, coords, or PlaceRef with coords. */
|
|
62
|
+
export function resolveRouteEndpoint(value) {
|
|
63
|
+
if (typeof value === 'string') {
|
|
64
|
+
const trimmed = value.trim();
|
|
65
|
+
if (HEX_ID_RE.test(trimmed)) {
|
|
66
|
+
throw new GMapsError('Route endpoint cannot be a bare hexId — pass { lat, lng }, a PlaceRef with coords, or an address string');
|
|
67
|
+
}
|
|
68
|
+
if (PLACE_ID_RE.test(trimmed)) {
|
|
69
|
+
throw new GMapsError('Route endpoint cannot be a bare placeId — pass { lat, lng } or an address string');
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
if (typeof value === 'object' && value !== null && 'hexId' in value && value.hexId) {
|
|
74
|
+
const place = normalizePlaceRef(value);
|
|
75
|
+
if (place.lat == null || place.lng == null) {
|
|
76
|
+
throw new GMapsError('PlaceRef route endpoint requires lat/lng (or latitude/longitude). Profile the place first or pass an address.');
|
|
77
|
+
}
|
|
78
|
+
return { lat: place.lat, lng: place.lng };
|
|
79
|
+
}
|
|
80
|
+
const coords = toCoordinates(value);
|
|
81
|
+
if (coords)
|
|
82
|
+
return coords;
|
|
83
|
+
throw new GMapsError('Invalid route endpoint — expected address string, { lat, lng }, or PlaceRef with coordinates');
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolve search bias center from Intent (`near`) or service (`location`) spelling.
|
|
87
|
+
*/
|
|
88
|
+
export function resolveSearchCenter(options) {
|
|
89
|
+
const coords = toCoordinates(options.near) ?? toCoordinates(options.location);
|
|
90
|
+
if (!coords) {
|
|
91
|
+
throw new GMapsError('Search requires a bias center — pass near: { lat, lng } (Intent) or location: { lat, lng } (search service)');
|
|
92
|
+
}
|
|
93
|
+
return coords;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolve directions endpoints from Intent (`from`/`to`) or service (`origin`/`destination`).
|
|
97
|
+
*/
|
|
98
|
+
export function resolveDirectionsEndpoints(options) {
|
|
99
|
+
const originRaw = options.from ?? options.origin;
|
|
100
|
+
const destRaw = options.to ?? options.destination;
|
|
101
|
+
if (originRaw == null || destRaw == null) {
|
|
102
|
+
throw new GMapsError('Directions require from/to (Intent) or origin/destination (directions service)');
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
origin: resolveRouteEndpoint(originRaw),
|
|
106
|
+
destination: resolveRouteEndpoint(destRaw),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=place-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-ref.js","sourceRoot":"","sources":["../../src/utils/place-ref.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,SAAS,GAAG,4BAA4B,CAAC;AAC/C,MAAM,WAAW,GAAG,cAAc,CAAC;AAEnC,SAAS,eAAe,CAAC,OAAe;IACtC,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAa;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,UAAU,CAAC,sDAAsD,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC5B,CAAC;QACD,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAA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AI,OAAO,CAAC,MAAM,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,WAAW,CAAC;IAClD,IAAI,SAAS,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACzC,MAAM,IAAI,UAAU,CAClB,gFAAgF,CACjF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM,EAAE,oBAAoB,CAAC,SAAS,CAAC;QACvC,WAAW,EAAE,oBAAoB,CAAC,OAAO,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
package/dist/utils/pooled.d.ts
CHANGED
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
* Run async tasks with bounded concurrency (same pattern as scripts/capture-maps-all.ts).
|
|
3
3
|
*/
|
|
4
4
|
export declare function pooled<T>(items: T[], limit: number, worker: (item: T, index: number) => Promise<void>): Promise<void>;
|
|
5
|
+
/** Like {@link pooled} but collects return values in input order. */
|
|
6
|
+
export declare function pooledMap<T, R>(items: T[], limit: number, worker: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
5
7
|
export declare function sleep(ms: number): Promise<void>;
|
|
6
8
|
//# sourceMappingURL=pooled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pooled.d.ts","sourceRoot":"","sources":["../../src/utils/pooled.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAC5B,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
1
|
+
{"version":3,"file":"pooled.d.ts","sourceRoot":"","sources":["../../src/utils/pooled.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAC5B,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,qEAAqE;AACrE,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,EAClC,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,CAAC,EAAE,CAAC,CAMd;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
package/dist/utils/pooled.js
CHANGED
|
@@ -13,6 +13,14 @@ export async function pooled(items, limit, worker) {
|
|
|
13
13
|
});
|
|
14
14
|
await Promise.all(runners);
|
|
15
15
|
}
|
|
16
|
+
/** Like {@link pooled} but collects return values in input order. */
|
|
17
|
+
export async function pooledMap(items, limit, worker) {
|
|
18
|
+
const results = new Array(items.length);
|
|
19
|
+
await pooled(items, limit, async (item, index) => {
|
|
20
|
+
results[index] = await worker(item, index);
|
|
21
|
+
});
|
|
22
|
+
return results;
|
|
23
|
+
}
|
|
16
24
|
export function sleep(ms) {
|
|
17
25
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
18
26
|
}
|
package/dist/utils/pooled.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pooled.js","sourceRoot":"","sources":["../../src/utils/pooled.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,KAAU,EACV,KAAa,EACb,MAAiD;IAEjD,IAAI,KAAK,CAAC,MAAM,K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C,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED,qEAAqE;AACrE,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAU,EACV,KAAa,EACb,MAA8C;IAE9C,MAAM,OAAO,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/C,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-async-call request context (AbortSignal) without threading through every service.
|
|
3
|
+
*/
|
|
4
|
+
export interface RequestContext {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
export declare function runWithRequestContext<T>(ctx: RequestContext, fn: () => Promise<T>): Promise<T>;
|
|
8
|
+
export declare function getRequestSignal(): AbortSignal | undefined;
|
|
9
|
+
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/utils/request-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAID,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,GAAG,EAAE,cAAc,EACnB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,wBAAgB,gBAAgB,IAAI,WAAW,GAAG,SAAS,CAE1D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-async-call request context (AbortSignal) without threading through every service.
|
|
3
|
+
*/
|
|
4
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
|
+
const store = new AsyncLocalStorage();
|
|
6
|
+
export function runWithRequestContext(ctx, fn) {
|
|
7
|
+
return store.run(ctx, fn);
|
|
8
|
+
}
|
|
9
|
+
export function getRequestSignal() {
|
|
10
|
+
return store.getStore()?.signal;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/utils/request-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,MAAM,KAAK,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAEtD,MAAM,UAAU,qBAAqB,CACnC,GAAmB,EACnB,EAAoB;IAEpB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC;AAClC,CAAC"}
|