hg-map-sdk 1.1.0 → 1.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 +11 -2
- package/index.d.ts +2 -0
- package/package.json +4 -4
- package/src/client.js +12 -0
- package/src/errors.js +2 -0
package/README.md
CHANGED
|
@@ -28,12 +28,15 @@ Node 18+, no dependencies, TypeScript types included.
|
|
|
28
28
|
3. Create the client as below. A key starting with `hk_` is sent as `X-Hoogaaa-Api-Key`: the gateway checks it,
|
|
29
29
|
counts the call in the console's Usage and strips it before map-service. Nothing else changes.
|
|
30
30
|
|
|
31
|
-
### With a map-service key (inside the cluster)
|
|
31
|
+
### With a map-service key (inside the cluster) — stops on 30 Nov 2026
|
|
32
|
+
|
|
33
|
+
> **`mk_` keys stop working on 30 Nov 2026 00:00 IST.** Move to a Hoogaaa Cloud key (above) before then. From
|
|
34
|
+
> 1.2.0 the SDK prints a `DeprecationWarning` (`HG_MAP_SDK_OLD_KEY`) once per process when it gets an `mk_` key.
|
|
32
35
|
|
|
33
36
|
1. Give your service its own key on map-service:
|
|
34
37
|
|
|
35
38
|
```bash
|
|
36
|
-
cd
|
|
39
|
+
cd map/map-osrm/map-service
|
|
37
40
|
npm run clients -- create user-backend # prints the key once
|
|
38
41
|
```
|
|
39
42
|
|
|
@@ -125,6 +128,12 @@ try {
|
|
|
125
128
|
| `INVALID_*` (400) | Bad input; `details` says which field |
|
|
126
129
|
| `PROVIDER_UNAVAILABLE` / `GEOCODING_UNAVAILABLE` (503) | Engine down / no geocoder configured |
|
|
127
130
|
| `NETWORK_ERROR`, `TIMEOUT` | map-service not reachable or too slow |
|
|
131
|
+
| `PAID_PROVIDERS_OFF` (503) | A **test** key, and this server has only paid providers (Ola, Mappls, Google) for that call. Not retried |
|
|
132
|
+
|
|
133
|
+
**Test keys use only free providers.** With a `hk_test_` key map-service answers from its own engines (OSRM,
|
|
134
|
+
Photon, Nominatim) and never from Ola, Mappls or Google, so testing never costs money. Live keys use the full
|
|
135
|
+
provider list. The Maps admin can let a project's next few test calls (default 10) use the paid ones too, to check
|
|
136
|
+
them; the response header `X-Map-Paid-Providers` says `off`, `on` or `test 3/10`.
|
|
128
137
|
|
|
129
138
|
With a Hoogaaa Cloud key the gateway may answer first:
|
|
130
139
|
|
package/index.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export type ErrorCode =
|
|
|
61
61
|
| "PINCODE_NOT_FOUND"
|
|
62
62
|
| "PINCODES_UNAVAILABLE"
|
|
63
63
|
| "GEOCODING_UNAVAILABLE"
|
|
64
|
+
// A Hoogaaa test key on a server whose providers are all paid ones (test keys use only free providers)
|
|
65
|
+
| "PAID_PROVIDERS_OFF"
|
|
64
66
|
| "PROVIDER_UNAVAILABLE"
|
|
65
67
|
| "PROVIDER_REJECTED"
|
|
66
68
|
| (string & {});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hg-map-sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Client for
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Client for Hoogaaa Maps (map-service): routing, ETA, trip optimization, geocoding and India PIN codes \u2014 provider-independent",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/satyamsonker1010/
|
|
21
|
+
"url": "git+https://github.com/satyamsonker1010/hoogaaa-map-service.git",
|
|
22
22
|
"directory": "sdk"
|
|
23
23
|
},
|
|
24
|
-
"homepage": "https://github.com/satyamsonker1010/
|
|
24
|
+
"homepage": "https://github.com/satyamsonker1010/hoogaaa-map-service/tree/development/sdk#readme",
|
|
25
25
|
"keywords": [
|
|
26
26
|
"maps",
|
|
27
27
|
"routing",
|
package/src/client.js
CHANGED
|
@@ -11,6 +11,17 @@ const DEFAULTS = {
|
|
|
11
11
|
|
|
12
12
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
13
|
|
|
14
|
+
// map-service keys (mk_…) stop on 30 Nov 2026 00:00 IST (owner, 19 Nov 2026). Said once per process.
|
|
15
|
+
let warnedOldKey = false;
|
|
16
|
+
const warnOldKey = () => {
|
|
17
|
+
if (warnedOldKey) return;
|
|
18
|
+
warnedOldKey = true;
|
|
19
|
+
process.emitWarning(
|
|
20
|
+
"map-service keys (mk_…) stop working on 30 Nov 2026 00:00 IST. Create a Hoogaaa Cloud key (hk_test_… / hk_live_…) at https://console.hoogaaa.com and call the gateway (https://apidev.hoogaaa.com/api/v1/maps or https://api.hoogaaa.com/api/v1/maps).",
|
|
21
|
+
{ type: "DeprecationWarning", code: "HG_MAP_SDK_OLD_KEY" },
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
14
25
|
/**
|
|
15
26
|
* Low-level HTTP: base URL + key, timeout, retries, and turning map-service's
|
|
16
27
|
* `{ success, message, data, code, errors }` envelope into data or a MapServiceError.
|
|
@@ -33,6 +44,7 @@ class HttpClient {
|
|
|
33
44
|
// A Hoogaaa Cloud key (from the console) goes to the gateway in its own header; the gateway checks it, counts the
|
|
34
45
|
// call in the console's Usage and strips it before map-service. A map-service key (mk_…) goes as before.
|
|
35
46
|
this.keyHeader = this.apiKey.startsWith("hk_") ? "X-Hoogaaa-Api-Key" : "X-Map-Service-Api-Key";
|
|
47
|
+
if (!this.apiKey.startsWith("hk_")) warnOldKey();
|
|
36
48
|
this.timeoutMs = options.timeoutMs ?? DEFAULTS.timeoutMs;
|
|
37
49
|
this.retries = Math.max(0, options.retries ?? DEFAULTS.retries);
|
|
38
50
|
this.retryDelayMs = options.retryDelayMs ?? DEFAULTS.retryDelayMs;
|
package/src/errors.js
CHANGED
|
@@ -22,6 +22,8 @@ class MapServiceError extends Error {
|
|
|
22
22
|
|
|
23
23
|
/** True for failures worth retrying later (map-service down/slow, or rate-limited). */
|
|
24
24
|
get retryable() {
|
|
25
|
+
// A test key on a server with only paid providers: asking again never helps.
|
|
26
|
+
if (this.code === "PAID_PROVIDERS_OFF") return false;
|
|
25
27
|
return (
|
|
26
28
|
this.code === "NETWORK_ERROR" ||
|
|
27
29
|
this.code === "TIMEOUT" ||
|