@pilot-status/sdk 0.21.0 → 0.23.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-agent.d.ts","sourceRoot":"","sources":["../src/user-agent.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,cAAc,6BAAqC,CAAC;AAEjE;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAKtD"}
@@ -0,0 +1,23 @@
1
+ import { SDK_VERSION } from "./version.js";
2
+ /**
3
+ * Product token sent on every request. The Pilot Status API buckets `/v1` callers
4
+ * by User-Agent and only recognises the SDK when the header STARTS with
5
+ * `pilot-status-node/<version>`.
6
+ */
7
+ export const SDK_USER_AGENT = `pilot-status-node/${SDK_VERSION}`;
8
+ /**
9
+ * The User-Agent actually sent. A caller-supplied value is kept, never replaced:
10
+ * - a third-party UA gets the SDK token in FRONT (`pilot-status-node/x.y.z my-app/1.0`),
11
+ * because the server parser is anchored at the start of the header;
12
+ * - a UA that already starts with `pilot-status-` is another Pilot Status product
13
+ * built on this SDK, so it stays first and the SDK token goes after it.
14
+ */
15
+ export function buildUserAgent(custom) {
16
+ const theirs = custom?.trim();
17
+ if (!theirs)
18
+ return SDK_USER_AGENT;
19
+ if (theirs.toLowerCase().startsWith("pilot-status-"))
20
+ return `${theirs} ${SDK_USER_AGENT}`;
21
+ return `${SDK_USER_AGENT} ${theirs}`;
22
+ }
23
+ //# sourceMappingURL=user-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../src/user-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,WAAW,EAAE,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe;IAC1C,MAAM,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,MAAM;QAAE,OAAO,cAAc,CAAC;IACnC,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;QAAE,OAAO,GAAG,MAAM,IAAI,cAAc,EAAE,CAAC;IAC3F,OAAO,GAAG,cAAc,IAAI,MAAM,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const SDK_VERSION = "0.23.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ // GENERATED by scripts/write-version.mjs from package.json — do not edit by hand.
2
+ export const SDK_VERSION = "0.23.0";
3
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pilot-status/sdk",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Official TypeScript SDK for the Pilot Status public API.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,6 +33,7 @@
33
33
  "typescript"
34
34
  ],
35
35
  "scripts": {
36
+ "prebuild": "node scripts/write-version.mjs",
36
37
  "build": "tsc -p tsconfig.json",
37
38
  "prepublishOnly": "npm run build",
38
39
  "test": "vitest run",