@apostra/sdk 0.37.0 → 0.39.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/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export type { CliLoginEntry } from './cli-login.js';
2
+ export { cliLoginTokenProvider } from './cli-login.js';
1
3
  export * from './generated/client.js';
2
4
  export { operations, version } from './generated/metadata.js';
3
5
  export type { AdcpError, JsonValue } from './generated/types.gen.js';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { cliLoginTokenProvider } from './cli-login.js';
1
2
  export * from './generated/client.js';
2
3
  export { operations, version } from './generated/metadata.js';
3
4
  export * from './transport.js';
package/dist/transport.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { cliLoginTokenProvider, storedCliLogin } from './cli-login.js';
1
2
  import { baseUrl, m2mTokenUrl, operations, version, } from './generated/metadata.js';
2
3
  export class ApostraError extends Error {
3
4
  status;
@@ -297,6 +298,19 @@ export class Transport {
297
298
  accountId: options.accountId ?? environment?.APOSTRA_ACCOUNT_ID,
298
299
  baseUrl: options.baseUrl ?? environment?.APOSTRA_BASE_URL,
299
300
  };
301
+ if (!hasExplicitCredential && resolvedOptions.apiKey === undefined) {
302
+ // Last link of the default chain: `apostra login` for this base URL.
303
+ const login = storedCliLogin(resolvedOptions.baseUrl ?? baseUrl);
304
+ if (login) {
305
+ if (resolvedOptions.accountId !== undefined &&
306
+ resolvedOptions.accountId !== login.accountId)
307
+ throw new TypeError(`accountId ${resolvedOptions.accountId} does not match account ${login.accountId}, the one you signed in to with \`apostra login\`. Run \`apostra login --account ${resolvedOptions.accountId}\` or remove accountId.`);
308
+ resolvedOptions.tokenProvider = cliLoginTokenProvider({
309
+ baseUrl: resolvedOptions.baseUrl,
310
+ fetch: options.fetch,
311
+ });
312
+ }
313
+ }
300
314
  if ([
301
315
  resolvedOptions.apiKey,
302
316
  resolvedOptions.accessToken,
package/llms.txt CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Read `SKILL.md` in this package before implementing an Apostra task.
4
4
 
5
- - SDK guide: https://docs.apostra.com/v2/sdk
5
+ - SDK guide: https://docs.apostra.com/v3/sdk-guide
6
6
  - V3 HTTP contract: https://docs.apostra.com/v3/http-api
7
7
  - Authentication: https://docs.apostra.com/v3/authentication
8
8
  - Complete documentation corpus: https://docs.apostra.com/llms-full.txt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apostra/sdk",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "description": "The official Apostra V3 HTTP SDK",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/apostra-public/apostra.git",
10
10
  "directory": "sdk/typescript"
11
11
  },
12
- "homepage": "https://docs.apostra.com/v2/sdk",
12
+ "homepage": "https://docs.apostra.com/v3/sdk-guide",
13
13
  "engines": {
14
14
  "node": ">=22.18.0"
15
15
  },
@@ -28,6 +28,10 @@
28
28
  "types": "./dist/generated/metadata.d.ts",
29
29
  "import": "./dist/generated/metadata.js"
30
30
  },
31
+ "./cli-login": {
32
+ "types": "./dist/cli-login.d.ts",
33
+ "import": "./dist/cli-login.js"
34
+ },
31
35
  "./webhooks": {
32
36
  "types": "./dist/webhooks.d.ts",
33
37
  "import": "./dist/webhooks.js"
@@ -50,11 +54,11 @@
50
54
  "build": "tsc6 -p tsconfig.build.json",
51
55
  "type-check": "tsc6 --noEmit",
52
56
  "test": "vitest run",
53
- "lint": "biome check src/transport.ts src/webhooks.ts src/index.ts __tests__ examples --error-on-warnings",
57
+ "lint": "biome check src/transport.ts src/cli-login.ts src/webhooks.ts src/index.ts __tests__ examples --error-on-warnings",
54
58
  "prepack": "npm run build"
55
59
  },
56
60
  "devDependencies": {
57
- "@adcp/sdk": "15.8.1",
61
+ "@adcp/sdk": "16.2.0",
58
62
  "@types/node": "^22.15.17",
59
63
  "typescript": "npm:@typescript/typescript6@^6.0.2",
60
64
  "vitest": "^4.1.9"