@apostra/sdk 0.0.0-stage → 0.37.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,58 @@
1
+ import { Apostra } from '@apostra/sdk'
2
+
3
+ function required(name: string): string {
4
+ const value = process.env[name]
5
+ if (!value) throw new Error(`${name} is required`)
6
+ return value
7
+ }
8
+
9
+ const api = new Apostra({
10
+ apiKey: required('APOSTRA_API_KEY'),
11
+ accountId: process.env.APOSTRA_ACCOUNT_ID,
12
+ baseUrl: process.env.APOSTRA_BASE_URL ?? 'https://api.apostra.com/api/v3',
13
+ })
14
+ const campaignId = required('APOSTRA_CAMPAIGN_ID')
15
+
16
+ // Verify the credential and discover the resolved account before any write.
17
+ const status = await api.getStatus({})
18
+ if (!status.account)
19
+ throw new Error('The credential did not resolve an account')
20
+
21
+ // A unique key belongs to this exact preview request. Reuse it only to retry
22
+ // the same request after an uncertain response.
23
+ const previewKey = crypto.randomUUID()
24
+ const preview = await api.saveCampaign(
25
+ {
26
+ campaignId,
27
+ desiredPhase: 'active',
28
+ idempotencyKey: previewKey,
29
+ },
30
+ { idempotencyKey: previewKey },
31
+ )
32
+
33
+ // Inspect `preview` before confirming. Confirmation is deliberately opt-in so
34
+ // running the sample against the synthetic seller remains a preview by default.
35
+ if (process.env.APOSTRA_CONFIRM_LAUNCH === 'true') {
36
+ const confirmKey = crypto.randomUUID()
37
+ await api.saveCampaign(
38
+ {
39
+ campaignId,
40
+ desiredPhase: 'active',
41
+ confirmLaunch: true,
42
+ idempotencyKey: confirmKey,
43
+ },
44
+ { idempotencyKey: confirmKey },
45
+ )
46
+ }
47
+
48
+ const delivery = await api.getDelivery({
49
+ report: 'campaign_delivery',
50
+ filters: { campaignId },
51
+ range: {
52
+ startDate: required('APOSTRA_START_DATE'),
53
+ endDate: required('APOSTRA_END_DATE'),
54
+ },
55
+ limit: 100,
56
+ })
57
+
58
+ void [preview, delivery]
package/llms.txt ADDED
@@ -0,0 +1,11 @@
1
+ # Apostra TypeScript SDK
2
+
3
+ Read `SKILL.md` in this package before implementing an Apostra task.
4
+
5
+ - SDK guide: https://docs.apostra.com/v2/sdk
6
+ - V3 HTTP contract: https://docs.apostra.com/v3/http-api
7
+ - Authentication: https://docs.apostra.com/v3/authentication
8
+ - Complete documentation corpus: https://docs.apostra.com/llms-full.txt
9
+
10
+ The public documentation is the source of truth for operation inputs, results,
11
+ permissions, and behaviour.
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@apostra/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.37.0",
4
+ "description": "The official Apostra V3 HTTP SDK",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/apostra-public/apostra.git",
10
+ "directory": "sdk/typescript"
11
+ },
12
+ "homepage": "https://docs.apostra.com/v2/sdk",
13
+ "engines": {
14
+ "node": ">=22.18.0"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./models": {
24
+ "types": "./dist/generated/types.gen.d.ts",
25
+ "import": "./dist/generated/types.gen.js"
26
+ },
27
+ "./metadata": {
28
+ "types": "./dist/generated/metadata.d.ts",
29
+ "import": "./dist/generated/metadata.js"
30
+ },
31
+ "./webhooks": {
32
+ "types": "./dist/webhooks.d.ts",
33
+ "import": "./dist/webhooks.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "SKILL.md",
40
+ "llms.txt",
41
+ "examples",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "publishConfig": {
46
+ "access": "public",
47
+ "registry": "https://registry.npmjs.org"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc6 -p tsconfig.build.json",
51
+ "type-check": "tsc6 --noEmit",
52
+ "test": "vitest run",
53
+ "lint": "biome check src/transport.ts src/webhooks.ts src/index.ts __tests__ examples --error-on-warnings",
54
+ "prepack": "npm run build"
55
+ },
56
+ "devDependencies": {
57
+ "@adcp/sdk": "15.8.1",
58
+ "@types/node": "^22.15.17",
59
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
60
+ "vitest": "^4.1.9"
61
+ }
62
+ }