@adcp/sdk 5.25.0 → 6.0.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 +45 -7
- package/dist/lib/compliance-fixtures/index.d.ts +1 -1
- package/dist/lib/compliance-fixtures/index.js +1 -1
- package/dist/lib/conformance/runners.d.ts.map +1 -1
- package/dist/lib/conformance/runners.js +13 -1
- package/dist/lib/conformance/runners.js.map +1 -1
- package/dist/lib/core/AgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.js +15 -0
- package/dist/lib/core/SingleAgentClient.js.map +1 -1
- package/dist/lib/core/TaskExecutor.d.ts +7 -0
- package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
- package/dist/lib/core/TaskExecutor.js +9 -2
- package/dist/lib/core/TaskExecutor.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +7 -8
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/protocols/index.d.ts +3 -1
- package/dist/lib/protocols/index.d.ts.map +1 -1
- package/dist/lib/protocols/index.js +23 -14
- package/dist/lib/protocols/index.js.map +1 -1
- package/dist/lib/schemas/index.d.ts +1 -1
- package/dist/lib/schemas/index.js +1 -1
- package/dist/lib/server/create-adcp-server.d.ts +142 -11
- package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
- package/dist/lib/server/create-adcp-server.js +211 -2
- package/dist/lib/server/create-adcp-server.js.map +1 -1
- package/dist/lib/server/ctx-metadata/backends/memory.d.ts +27 -0
- package/dist/lib/server/ctx-metadata/backends/memory.d.ts.map +1 -0
- package/dist/lib/server/ctx-metadata/backends/memory.js +72 -0
- package/dist/lib/server/ctx-metadata/backends/memory.js.map +1 -0
- package/dist/lib/server/ctx-metadata/backends/pg.d.ts +62 -0
- package/dist/lib/server/ctx-metadata/backends/pg.d.ts.map +1 -0
- package/dist/lib/server/ctx-metadata/backends/pg.js +145 -0
- package/dist/lib/server/ctx-metadata/backends/pg.js.map +1 -0
- package/dist/lib/server/ctx-metadata/index.d.ts +15 -0
- package/dist/lib/server/ctx-metadata/index.d.ts.map +1 -0
- package/dist/lib/server/ctx-metadata/index.js +28 -0
- package/dist/lib/server/ctx-metadata/index.js.map +1 -0
- package/dist/lib/server/ctx-metadata/store.d.ts +177 -0
- package/dist/lib/server/ctx-metadata/store.d.ts.map +1 -0
- package/dist/lib/server/ctx-metadata/store.js +327 -0
- package/dist/lib/server/ctx-metadata/store.js.map +1 -0
- package/dist/lib/server/ctx-metadata/wire-shape.d.ts +55 -0
- package/dist/lib/server/ctx-metadata/wire-shape.d.ts.map +1 -0
- package/dist/lib/server/ctx-metadata/wire-shape.js +121 -0
- package/dist/lib/server/ctx-metadata/wire-shape.js.map +1 -0
- package/dist/lib/server/decisioning/account.d.ts +309 -0
- package/dist/lib/server/decisioning/account.d.ts.map +1 -0
- package/dist/lib/server/decisioning/account.js +102 -0
- package/dist/lib/server/decisioning/account.js.map +1 -0
- package/dist/lib/server/decisioning/admin-router.d.ts +75 -0
- package/dist/lib/server/decisioning/admin-router.d.ts.map +1 -0
- package/dist/lib/server/decisioning/admin-router.js +120 -0
- package/dist/lib/server/decisioning/admin-router.js.map +1 -0
- package/dist/lib/server/decisioning/assembly-helpers.d.ts +204 -0
- package/dist/lib/server/decisioning/assembly-helpers.d.ts.map +1 -0
- package/dist/lib/server/decisioning/assembly-helpers.js +173 -0
- package/dist/lib/server/decisioning/assembly-helpers.js.map +1 -0
- package/dist/lib/server/decisioning/async-outcome.d.ts +154 -0
- package/dist/lib/server/decisioning/async-outcome.d.ts.map +1 -0
- package/dist/lib/server/decisioning/async-outcome.js +239 -0
- package/dist/lib/server/decisioning/async-outcome.js.map +1 -0
- package/dist/lib/server/decisioning/capabilities.d.ts +251 -0
- package/dist/lib/server/decisioning/capabilities.d.ts.map +1 -0
- package/dist/lib/server/decisioning/capabilities.js +16 -0
- package/dist/lib/server/decisioning/capabilities.js.map +1 -0
- package/dist/lib/server/decisioning/context.d.ts +212 -0
- package/dist/lib/server/decisioning/context.d.ts.map +1 -0
- package/dist/lib/server/decisioning/context.js +26 -0
- package/dist/lib/server/decisioning/context.js.map +1 -0
- package/dist/lib/server/decisioning/errors-typed.d.ts +104 -0
- package/dist/lib/server/decisioning/errors-typed.d.ts.map +1 -0
- package/dist/lib/server/decisioning/errors-typed.js +304 -0
- package/dist/lib/server/decisioning/errors-typed.js.map +1 -0
- package/dist/lib/server/decisioning/helpers.d.ts +131 -0
- package/dist/lib/server/decisioning/helpers.d.ts.map +1 -0
- package/dist/lib/server/decisioning/helpers.js +134 -0
- package/dist/lib/server/decisioning/helpers.js.map +1 -0
- package/dist/lib/server/decisioning/index.d.ts +46 -0
- package/dist/lib/server/decisioning/index.d.ts.map +1 -0
- package/dist/lib/server/decisioning/index.js +120 -0
- package/dist/lib/server/decisioning/index.js.map +1 -0
- package/dist/lib/server/decisioning/list-helpers.d.ts +53 -0
- package/dist/lib/server/decisioning/list-helpers.d.ts.map +1 -0
- package/dist/lib/server/decisioning/list-helpers.js +96 -0
- package/dist/lib/server/decisioning/list-helpers.js.map +1 -0
- package/dist/lib/server/decisioning/manifest-helpers.d.ts +56 -0
- package/dist/lib/server/decisioning/manifest-helpers.d.ts.map +1 -0
- package/dist/lib/server/decisioning/manifest-helpers.js +78 -0
- package/dist/lib/server/decisioning/manifest-helpers.js.map +1 -0
- package/dist/lib/server/decisioning/pagination.d.ts +21 -0
- package/dist/lib/server/decisioning/pagination.d.ts.map +1 -0
- package/dist/lib/server/decisioning/pagination.js +12 -0
- package/dist/lib/server/decisioning/pagination.js.map +1 -0
- package/dist/lib/server/decisioning/platform.d.ts +188 -0
- package/dist/lib/server/decisioning/platform.d.ts.map +1 -0
- package/dist/lib/server/decisioning/platform.js +19 -0
- package/dist/lib/server/decisioning/platform.js.map +1 -0
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts +510 -0
- package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +2196 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -0
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts +114 -0
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts.map +1 -0
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.js +247 -0
- package/dist/lib/server/decisioning/runtime/postgres-task-registry.js.map +1 -0
- package/dist/lib/server/decisioning/runtime/protocol-for-tool.d.ts +32 -0
- package/dist/lib/server/decisioning/runtime/protocol-for-tool.d.ts.map +1 -0
- package/dist/lib/server/decisioning/runtime/protocol-for-tool.js +127 -0
- package/dist/lib/server/decisioning/runtime/protocol-for-tool.js.map +1 -0
- package/dist/lib/server/decisioning/runtime/task-registry.d.ts +105 -0
- package/dist/lib/server/decisioning/runtime/task-registry.d.ts.map +1 -0
- package/dist/lib/server/decisioning/runtime/task-registry.js +96 -0
- package/dist/lib/server/decisioning/runtime/task-registry.js.map +1 -0
- package/dist/lib/server/decisioning/runtime/to-context.d.ts +54 -0
- package/dist/lib/server/decisioning/runtime/to-context.d.ts.map +1 -0
- package/dist/lib/server/decisioning/runtime/to-context.js +166 -0
- package/dist/lib/server/decisioning/runtime/to-context.js.map +1 -0
- package/dist/lib/server/decisioning/runtime/validate-platform.d.ts +20 -0
- package/dist/lib/server/decisioning/runtime/validate-platform.d.ts.map +1 -0
- package/dist/lib/server/decisioning/runtime/validate-platform.js +93 -0
- package/dist/lib/server/decisioning/runtime/validate-platform.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/audiences.d.ts +72 -0
- package/dist/lib/server/decisioning/specialisms/audiences.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/audiences.js +15 -0
- package/dist/lib/server/decisioning/specialisms/audiences.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts +92 -0
- package/dist/lib/server/decisioning/specialisms/brand-rights.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/brand-rights.js +28 -0
- package/dist/lib/server/decisioning/specialisms/brand-rights.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/campaign-governance.d.ts +67 -0
- package/dist/lib/server/decisioning/specialisms/campaign-governance.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/campaign-governance.js +31 -0
- package/dist/lib/server/decisioning/specialisms/campaign-governance.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/content-standards.d.ts +78 -0
- package/dist/lib/server/decisioning/specialisms/content-standards.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/content-standards.js +35 -0
- package/dist/lib/server/decisioning/specialisms/content-standards.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +81 -0
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.js +28 -0
- package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/creative.d.ts +144 -0
- package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/creative.js +19 -0
- package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/lists.d.ts +61 -0
- package/dist/lib/server/decisioning/specialisms/lists.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/lists.js +30 -0
- package/dist/lib/server/decisioning/specialisms/lists.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/sales.d.ts +163 -0
- package/dist/lib/server/decisioning/specialisms/sales.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/sales.js +64 -0
- package/dist/lib/server/decisioning/specialisms/sales.js.map +1 -0
- package/dist/lib/server/decisioning/specialisms/signals.d.ts +64 -0
- package/dist/lib/server/decisioning/specialisms/signals.d.ts.map +1 -0
- package/dist/lib/server/decisioning/specialisms/signals.js +28 -0
- package/dist/lib/server/decisioning/specialisms/signals.js.map +1 -0
- package/dist/lib/server/decisioning/start-time.d.ts +76 -0
- package/dist/lib/server/decisioning/start-time.d.ts.map +1 -0
- package/dist/lib/server/decisioning/start-time.js +81 -0
- package/dist/lib/server/decisioning/start-time.js.map +1 -0
- package/dist/lib/server/decisioning/status-changes.d.ts +165 -0
- package/dist/lib/server/decisioning/status-changes.d.ts.map +1 -0
- package/dist/lib/server/decisioning/status-changes.js +131 -0
- package/dist/lib/server/decisioning/status-changes.js.map +1 -0
- package/dist/lib/server/decisioning/status-mappers.d.ts +46 -0
- package/dist/lib/server/decisioning/status-mappers.d.ts.map +1 -0
- package/dist/lib/server/decisioning/status-mappers.js +46 -0
- package/dist/lib/server/decisioning/status-mappers.js.map +1 -0
- package/dist/lib/server/decisioning/tenant-registry.d.ts +289 -0
- package/dist/lib/server/decisioning/tenant-registry.d.ts.map +1 -0
- package/dist/lib/server/decisioning/tenant-registry.js +503 -0
- package/dist/lib/server/decisioning/tenant-registry.js.map +1 -0
- package/dist/lib/server/express-adapter.d.ts +1 -1
- package/dist/lib/server/express-adapter.js +1 -1
- package/dist/lib/server/governance.d.ts +1 -1
- package/dist/lib/server/governance.js +1 -1
- package/dist/lib/server/idempotency/store.d.ts +1 -1
- package/dist/lib/server/idempotency/store.js +1 -1
- package/dist/lib/server/index.d.ts +9 -2
- package/dist/lib/server/index.d.ts.map +1 -1
- package/dist/lib/server/index.js +79 -4
- package/dist/lib/server/index.js.map +1 -1
- package/dist/lib/server/legacy/v5/index.d.ts +38 -0
- package/dist/lib/server/legacy/v5/index.d.ts.map +1 -0
- package/dist/lib/server/legacy/v5/index.js +60 -0
- package/dist/lib/server/legacy/v5/index.js.map +1 -0
- package/dist/lib/server/normalize-errors.d.ts +88 -0
- package/dist/lib/server/normalize-errors.d.ts.map +1 -0
- package/dist/lib/server/normalize-errors.js +146 -0
- package/dist/lib/server/normalize-errors.js.map +1 -0
- package/dist/lib/server/pick-safe-details.d.ts +90 -0
- package/dist/lib/server/pick-safe-details.d.ts.map +1 -0
- package/dist/lib/server/pick-safe-details.js +148 -0
- package/dist/lib/server/pick-safe-details.js.map +1 -0
- package/dist/lib/server/postgres-state-store.d.ts +1 -1
- package/dist/lib/server/postgres-state-store.js +1 -1
- package/dist/lib/server/responses.d.ts +38 -0
- package/dist/lib/server/responses.d.ts.map +1 -1
- package/dist/lib/server/responses.js +38 -0
- package/dist/lib/server/responses.js.map +1 -1
- package/dist/lib/server/state-store.d.ts +1 -1
- package/dist/lib/server/state-store.js +1 -1
- package/dist/lib/server/test-controller.d.ts +10 -3
- package/dist/lib/server/test-controller.d.ts.map +1 -1
- package/dist/lib/server/test-controller.js +10 -3
- package/dist/lib/server/test-controller.js.map +1 -1
- package/dist/lib/testing/comply-controller.d.ts +47 -1
- package/dist/lib/testing/comply-controller.d.ts.map +1 -1
- package/dist/lib/testing/comply-controller.js +11 -4
- package/dist/lib/testing/comply-controller.js.map +1 -1
- package/dist/lib/testing/index.d.ts +1 -1
- package/dist/lib/testing/index.d.ts.map +1 -1
- package/dist/lib/testing/index.js.map +1 -1
- package/dist/lib/testing/personas/index.d.ts +143 -0
- package/dist/lib/testing/personas/index.d.ts.map +1 -0
- package/dist/lib/testing/personas/index.js +190 -0
- package/dist/lib/testing/personas/index.js.map +1 -0
- package/dist/lib/testing/storyboard/index.d.ts +1 -1
- package/dist/lib/testing/storyboard/index.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/index.js +3 -2
- package/dist/lib/testing/storyboard/index.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts +13 -0
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +179 -7
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/types/adcp.d.ts.map +1 -1
- package/dist/lib/types/adcp.js +1 -0
- package/dist/lib/types/adcp.js.map +1 -1
- package/dist/lib/types/asset-instances.d.ts +1 -0
- package/dist/lib/types/asset-instances.d.ts.map +1 -1
- package/dist/lib/types/core.generated.d.ts +203 -98
- package/dist/lib/types/core.generated.d.ts.map +1 -1
- package/dist/lib/types/core.generated.js +1 -1
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.d.ts.map +1 -1
- package/dist/lib/types/index.js.map +1 -1
- package/dist/lib/types/schemas.generated.d.ts +599 -159
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +175 -94
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/tools.generated.d.ts +315 -46
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/utils/capabilities.d.ts +1 -1
- package/dist/lib/utils/capabilities.d.ts.map +1 -1
- package/dist/lib/utils/capabilities.js +6 -0
- package/dist/lib/utils/capabilities.js.map +1 -1
- package/dist/lib/validation/schema-validator.d.ts +13 -0
- package/dist/lib/validation/schema-validator.d.ts.map +1 -1
- package/dist/lib/validation/schema-validator.js +240 -3
- package/dist/lib/validation/schema-validator.js.map +1 -1
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.js.map +1 -1
- package/docs/guides/BUILD-AN-AGENT.md +30 -5
- package/docs/llms.txt +28 -17
- package/examples/README.md +3 -1
- package/examples/decisioning-platform-broadcast-tv.ts +300 -0
- package/examples/decisioning-platform-identity-graph.ts +214 -0
- package/examples/decisioning-platform-mock-seller.ts +332 -0
- package/examples/decisioning-platform-multi-tenant.ts +128 -0
- package/examples/decisioning-platform-programmatic.ts +254 -0
- package/examples/signals-agent.ts +1 -1
- package/package.json +13 -2
- package/skills/build-brand-rights-agent/SKILL.md +10 -3
- package/skills/build-creative-agent/SKILL.md +94 -64
- package/skills/build-decisioning-creative-template/SKILL.md +554 -0
- package/skills/build-decisioning-platform/SKILL.md +304 -0
- package/skills/build-decisioning-platform/advanced/BRAND-RIGHTS.md +25 -0
- package/skills/build-decisioning-platform/advanced/COMPLIANCE.md +23 -0
- package/skills/build-decisioning-platform/advanced/GOVERNANCE.md +24 -0
- package/skills/build-decisioning-platform/advanced/HITL.md +34 -0
- package/skills/build-decisioning-platform/advanced/IDEMPOTENCY.md +52 -0
- package/skills/build-decisioning-platform/advanced/MULTI-TENANT.md +47 -0
- package/skills/build-decisioning-platform/advanced/OAUTH.md +22 -0
- package/skills/build-decisioning-platform/advanced/REFERENCE.md +991 -0
- package/skills/build-decisioning-platform/advanced/SANDBOX.md +24 -0
- package/skills/build-decisioning-platform/advanced/STATE-MACHINE.md +52 -0
- package/skills/build-decisioning-signal-marketplace/SKILL.md +269 -0
- package/skills/build-generative-seller-agent/SKILL.md +89 -53
- package/skills/build-governance-agent/SKILL.md +76 -45
- package/skills/build-retail-media-agent/SKILL.md +87 -62
- package/skills/build-seller-agent/SKILL.md +384 -255
- package/skills/build-seller-agent/deployment.md +5 -3
- package/skills/build-seller-agent/specialisms/audience-sync.md +0 -2
- package/skills/build-seller-agent/specialisms/sales-broadcast-tv.md +0 -2
- package/skills/build-seller-agent/specialisms/sales-guaranteed.md +0 -2
- package/skills/build-seller-agent/specialisms/sales-non-guaranteed.md +0 -2
- package/skills/build-seller-agent/specialisms/sales-proposal-mode.md +0 -2
- package/skills/build-seller-agent/specialisms/sales-social.md +0 -2
- package/skills/build-seller-agent/specialisms/signed-requests.md +0 -2
- package/skills/build-si-agent/SKILL.md +40 -32
- package/skills/build-signals-agent/SKILL.md +139 -92
- package/skills/call-adcp-agent.previous/SKILL.md +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-typed.js","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/errors-typed.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,mDAA4C;AAW5C,8EAA8E;AAC9E,yEAAyE;AACzE,+DAA+D;AAC/D,8EAA8E;AAE9E,MAAa,oBAAqB,SAAQ,yBAAS;I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,OAAO,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE;SAC7C,CAAC,CAAC;IACL,CAAC;CACF;AATD,oDASC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adopter utility helpers for DecisioningPlatform implementations.
|
|
3
|
+
*
|
|
4
|
+
* All exports are opt-in convenience — nothing in the framework calls
|
|
5
|
+
* these internally. They lift boilerplate that every adopter with the
|
|
6
|
+
* corresponding pattern would otherwise rewrite from scratch.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
import { AdcpError, type ErrorCode } from './async-outcome';
|
|
11
|
+
/**
|
|
12
|
+
* Project a per-id Result-returning lookup into the `pollAudienceStatuses`
|
|
13
|
+
* `Map<id, status>` shape.
|
|
14
|
+
*
|
|
15
|
+
* Runs all lookups in parallel. Drops entries where `result.isOk()` is
|
|
16
|
+
* false OR `result.value` is `undefined` — per the SDK contract, not-found
|
|
17
|
+
* entries are omitted from the map (callers handle missing keys via
|
|
18
|
+
* `Map.prototype.get`).
|
|
19
|
+
*
|
|
20
|
+
* Typical use in `AudiencePlatform.pollAudienceStatuses`:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { batchPoll } from '@adcp/sdk/server/decisioning';
|
|
24
|
+
*
|
|
25
|
+
* async pollAudienceStatuses(audienceIds, ctx) {
|
|
26
|
+
* return batchPoll(audienceIds, async (id) =>
|
|
27
|
+
* this.myPlatform.getAudienceStatus(id, ctx.account.ctx_metadata.token)
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* The `lookup` return type is structural — any object with `isOk(): boolean`
|
|
33
|
+
* and `value?: TValue` matches (`neverthrow`, `fp-ts`, or custom Result types
|
|
34
|
+
* all work without wrapping).
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare function batchPoll<TKey extends string, TValue>(ids: readonly TKey[], lookup: (id: TKey) => Promise<{
|
|
39
|
+
isOk(): boolean;
|
|
40
|
+
value?: TValue;
|
|
41
|
+
}>): Promise<Map<TKey, TValue>>;
|
|
42
|
+
/**
|
|
43
|
+
* Construct an `AdcpError` for a buyer-correctable validation failure.
|
|
44
|
+
* Shorthand for `new AdcpError('VALIDATION_ERROR', { recovery: 'correctable', ... })`.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { validationError } from '@adcp/sdk/server/decisioning';
|
|
48
|
+
*
|
|
49
|
+
* if (!req.targeting?.geos?.length) {
|
|
50
|
+
* throw validationError('At least one geo is required', {
|
|
51
|
+
* field: 'targeting.geos',
|
|
52
|
+
* });
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param message - Human-readable explanation of the validation failure.
|
|
57
|
+
* @param opts.field - Wire `field` path (e.g. `'targeting.geos'`).
|
|
58
|
+
* @param opts.code - Override the error code (default `'VALIDATION_ERROR'`).
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare function validationError(message: string, opts?: {
|
|
62
|
+
field?: string;
|
|
63
|
+
code?: ErrorCode | (string & {});
|
|
64
|
+
}): AdcpError;
|
|
65
|
+
/**
|
|
66
|
+
* Construct an `AdcpError` for an upstream-platform failure (5xx /
|
|
67
|
+
* rate-limited). `extraDetails` is run through {@link pickSafeDetails}
|
|
68
|
+
* internally — depth-capped and size-capped — so credentials or stack
|
|
69
|
+
* traces the caller accidentally included don't cross the wire boundary.
|
|
70
|
+
*
|
|
71
|
+
* HTTP 429 maps to `RATE_LIMITED` (with `retry_after: 60`). All other
|
|
72
|
+
* upstream failures map to `SERVICE_UNAVAILABLE`. Both use
|
|
73
|
+
* `recovery: 'transient'`.
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { upstreamError } from '@adcp/sdk/server/decisioning';
|
|
77
|
+
*
|
|
78
|
+
* try {
|
|
79
|
+
* return await this.gam.createOrder(req);
|
|
80
|
+
* } catch (e) {
|
|
81
|
+
* throw upstreamError('GAM order creation failed', e, {
|
|
82
|
+
* gam_error_code: e.errorCode,
|
|
83
|
+
* request_id: e.requestId,
|
|
84
|
+
* });
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @param prefix - Short description of the operation that failed
|
|
89
|
+
* (e.g. `'GAM order creation failed'`). Prepended to the upstream message.
|
|
90
|
+
* @param e - Upstream error. Only `message`, `code`, and `status` are read;
|
|
91
|
+
* all other fields are ignored.
|
|
92
|
+
* @param extraDetails - Optional pre-selected safe fields to surface to the
|
|
93
|
+
* buyer. Run through `pickSafeDetails` with depth/size caps before attaching
|
|
94
|
+
* to the wire envelope.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare function upstreamError(prefix: string, e: {
|
|
98
|
+
message?: string;
|
|
99
|
+
code?: number | string;
|
|
100
|
+
status?: number;
|
|
101
|
+
}, extraDetails?: Record<string, unknown>): AdcpError;
|
|
102
|
+
/**
|
|
103
|
+
* Strip index signatures from a wire request type for back-compat with
|
|
104
|
+
* v5-era task functions whose parameter types don't carry the spec's
|
|
105
|
+
* `additionalProperties: true` index signature (`[x: string]: unknown`).
|
|
106
|
+
*
|
|
107
|
+
* Without this, passing a v6 wire type directly to a v5 task fn produces:
|
|
108
|
+
*
|
|
109
|
+
* ```
|
|
110
|
+
* Type 'CreateMediaBuyRequest' is not assignable to type
|
|
111
|
+
* 'Parameters<typeof createMediaBuyTask>[1]'
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* because generated v6 types include `[x: string]: unknown` for
|
|
115
|
+
* forward-compat but v5 fn signatures were authored without it.
|
|
116
|
+
*
|
|
117
|
+
* ```ts
|
|
118
|
+
* import type { RequestShape } from '@adcp/sdk/server/decisioning';
|
|
119
|
+
*
|
|
120
|
+
* const result = await createMediaBuyTask(
|
|
121
|
+
* snapCtx(account),
|
|
122
|
+
* req as RequestShape<typeof req>, // drops index sig for v5 adapter compat
|
|
123
|
+
* );
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
export type RequestShape<T> = {
|
|
129
|
+
[K in keyof T]: T[K];
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAO5D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,SAAS,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,EACzD,GAAG,EAAE,SAAS,IAAI,EAAE,EACpB,MAAM,EAAE,CAAC,EAAE,EAAE,IAAI,KAAK,OAAO,CAAC;IAAE,IAAI,IAAI,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACjE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAc5B;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;CAAE,GAC1D,SAAS,CAMX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAChE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,SAAS,CAaX;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Adopter utility helpers for DecisioningPlatform implementations.
|
|
4
|
+
*
|
|
5
|
+
* All exports are opt-in convenience — nothing in the framework calls
|
|
6
|
+
* these internally. They lift boilerplate that every adopter with the
|
|
7
|
+
* corresponding pattern would otherwise rewrite from scratch.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.batchPoll = batchPoll;
|
|
13
|
+
exports.validationError = validationError;
|
|
14
|
+
exports.upstreamError = upstreamError;
|
|
15
|
+
const async_outcome_1 = require("./async-outcome");
|
|
16
|
+
const pick_safe_details_1 = require("../pick-safe-details");
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// batchPoll
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
/**
|
|
21
|
+
* Project a per-id Result-returning lookup into the `pollAudienceStatuses`
|
|
22
|
+
* `Map<id, status>` shape.
|
|
23
|
+
*
|
|
24
|
+
* Runs all lookups in parallel. Drops entries where `result.isOk()` is
|
|
25
|
+
* false OR `result.value` is `undefined` — per the SDK contract, not-found
|
|
26
|
+
* entries are omitted from the map (callers handle missing keys via
|
|
27
|
+
* `Map.prototype.get`).
|
|
28
|
+
*
|
|
29
|
+
* Typical use in `AudiencePlatform.pollAudienceStatuses`:
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { batchPoll } from '@adcp/sdk/server/decisioning';
|
|
33
|
+
*
|
|
34
|
+
* async pollAudienceStatuses(audienceIds, ctx) {
|
|
35
|
+
* return batchPoll(audienceIds, async (id) =>
|
|
36
|
+
* this.myPlatform.getAudienceStatus(id, ctx.account.ctx_metadata.token)
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* The `lookup` return type is structural — any object with `isOk(): boolean`
|
|
42
|
+
* and `value?: TValue` matches (`neverthrow`, `fp-ts`, or custom Result types
|
|
43
|
+
* all work without wrapping).
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
async function batchPoll(ids, lookup) {
|
|
48
|
+
const pairs = await Promise.all(ids.map(async (id) => {
|
|
49
|
+
const r = await lookup(id);
|
|
50
|
+
return [id, r];
|
|
51
|
+
}));
|
|
52
|
+
const result = new Map();
|
|
53
|
+
for (const [id, r] of pairs) {
|
|
54
|
+
if (r.isOk() && r.value !== undefined) {
|
|
55
|
+
result.set(id, r.value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Error factory helpers
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
/**
|
|
64
|
+
* Construct an `AdcpError` for a buyer-correctable validation failure.
|
|
65
|
+
* Shorthand for `new AdcpError('VALIDATION_ERROR', { recovery: 'correctable', ... })`.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { validationError } from '@adcp/sdk/server/decisioning';
|
|
69
|
+
*
|
|
70
|
+
* if (!req.targeting?.geos?.length) {
|
|
71
|
+
* throw validationError('At least one geo is required', {
|
|
72
|
+
* field: 'targeting.geos',
|
|
73
|
+
* });
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param message - Human-readable explanation of the validation failure.
|
|
78
|
+
* @param opts.field - Wire `field` path (e.g. `'targeting.geos'`).
|
|
79
|
+
* @param opts.code - Override the error code (default `'VALIDATION_ERROR'`).
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
function validationError(message, opts) {
|
|
83
|
+
return new async_outcome_1.AdcpError((opts?.code ?? 'VALIDATION_ERROR'), {
|
|
84
|
+
recovery: 'correctable',
|
|
85
|
+
message,
|
|
86
|
+
...(opts?.field !== undefined && { field: opts.field }),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Construct an `AdcpError` for an upstream-platform failure (5xx /
|
|
91
|
+
* rate-limited). `extraDetails` is run through {@link pickSafeDetails}
|
|
92
|
+
* internally — depth-capped and size-capped — so credentials or stack
|
|
93
|
+
* traces the caller accidentally included don't cross the wire boundary.
|
|
94
|
+
*
|
|
95
|
+
* HTTP 429 maps to `RATE_LIMITED` (with `retry_after: 60`). All other
|
|
96
|
+
* upstream failures map to `SERVICE_UNAVAILABLE`. Both use
|
|
97
|
+
* `recovery: 'transient'`.
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { upstreamError } from '@adcp/sdk/server/decisioning';
|
|
101
|
+
*
|
|
102
|
+
* try {
|
|
103
|
+
* return await this.gam.createOrder(req);
|
|
104
|
+
* } catch (e) {
|
|
105
|
+
* throw upstreamError('GAM order creation failed', e, {
|
|
106
|
+
* gam_error_code: e.errorCode,
|
|
107
|
+
* request_id: e.requestId,
|
|
108
|
+
* });
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @param prefix - Short description of the operation that failed
|
|
113
|
+
* (e.g. `'GAM order creation failed'`). Prepended to the upstream message.
|
|
114
|
+
* @param e - Upstream error. Only `message`, `code`, and `status` are read;
|
|
115
|
+
* all other fields are ignored.
|
|
116
|
+
* @param extraDetails - Optional pre-selected safe fields to surface to the
|
|
117
|
+
* buyer. Run through `pickSafeDetails` with depth/size caps before attaching
|
|
118
|
+
* to the wire envelope.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
function upstreamError(prefix, e, extraDetails) {
|
|
122
|
+
const statusCode = e.status ?? (typeof e.code === 'number' ? e.code : undefined);
|
|
123
|
+
const isRateLimited = statusCode === 429;
|
|
124
|
+
const errorCode = isRateLimited ? 'RATE_LIMITED' : 'SERVICE_UNAVAILABLE';
|
|
125
|
+
const upstreamMsg = typeof e.message === 'string' && e.message.length > 0 ? e.message : 'upstream error';
|
|
126
|
+
const details = extraDetails !== undefined ? (0, pick_safe_details_1.pickSafeDetails)(extraDetails, Object.keys(extraDetails)) : undefined;
|
|
127
|
+
return new async_outcome_1.AdcpError(errorCode, {
|
|
128
|
+
recovery: 'transient',
|
|
129
|
+
message: `${prefix}: ${upstreamMsg}`,
|
|
130
|
+
...(isRateLimited && { retry_after: 60 }),
|
|
131
|
+
...(details !== undefined && { details }),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAoCH,8BAiBC;AAyBD,0CASC;AAkCD,sCAiBC;AAxID,mDAA4D;AAC5D,4DAAuD;AAEvD,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACI,KAAK,UAAU,SAAS,CAC7B,GAAoB,EACpB,MAAkE;IAElE,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAC,EAAE,EAAC,EAAE;QACjB,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,EAAE,CAAC,CAAU,CAAC;IAC1B,CAAC,CAAC,CACH,CAAC;IACF,MAAM,MAA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CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACzG,MAAM,OAAO,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAA,mCAAe,EAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAElH,OAAO,IAAI,yBAAS,CAAC,SAAS,EAAE;QAC9B,QAAQ,EAAE,WAAW;QACrB,OAAO,EAAE,GAAG,MAAM,KAAK,WAAW,EAAE;QACpC,GAAG,CAAC,aAAa,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QACzC,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DecisioningPlatform v1.0 — preview surface for the v6.0 architecture.
|
|
3
|
+
*
|
|
4
|
+
* Status: PREVIEW. Types only; not yet wired into the framework. Subject
|
|
5
|
+
* to change before 6.0 ships. Don't build production adapters against this
|
|
6
|
+
* yet — the framework still routes through the v5.x handler-style API.
|
|
7
|
+
*
|
|
8
|
+
* Design proposal: `.context/proposals/specialism-platform-interfaces-v3.md`
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export { type AdcpStructuredError, type ErrorCode, AdcpError } from './async-outcome';
|
|
13
|
+
export { PackageNotFoundError, MediaBuyNotFoundError, ProductNotFoundError, CreativeNotFoundError, ProductUnavailableError, CreativeRejectedError, BudgetTooLowError, BudgetExhaustedError, IdempotencyConflictError, InvalidRequestError, InvalidStateError, BackwardsTimeRangeError, AuthRequiredError, PermissionDeniedError, RateLimitedError, ServiceUnavailableError, UnsupportedFeatureError, ComplianceUnsatisfiedError, GovernanceDeniedError, PolicyViolationError, } from './errors-typed';
|
|
14
|
+
export type { CursorPage, CursorRequest } from './pagination';
|
|
15
|
+
export { publishStatusChange, setStatusChangeBus, getStatusChangeBus, createInMemoryStatusChangeBus, type StatusChange, type StatusChangeBus, type StatusChangeResourceType, type StatusChangeListener, type PublishStatusChangeOpts, } from './status-changes';
|
|
16
|
+
export type { DecisioningCapabilities, CreativeAgentRef, TargetingCapabilities, ReportingCapabilities, } from './capabilities';
|
|
17
|
+
export type { Account, AuthPrincipal, AccountStore, AccountFilter, SyncAccountsResultRow, AdcpAccountStatus, ResolveContext, ResolvedAuthInfo, } from './account';
|
|
18
|
+
export { AccountNotFoundError, refAccountId } from './account';
|
|
19
|
+
export type { StatusMappers, AdcpMediaBuyStatus, AdcpCreativeStatus, AdcpPlanStatus } from './status-mappers';
|
|
20
|
+
export { identityStatusMappers } from './status-mappers';
|
|
21
|
+
export type { RequestContext, WorkflowStateReader, ResourceResolver, WorkflowObjectType, WorkflowStep, Proposal, GovernanceContextJWS, } from './context';
|
|
22
|
+
export type { DecisioningPlatform, RequiredPlatformsFor, RequiredCapabilitiesFor } from './platform';
|
|
23
|
+
export type { CreativeBuilderPlatform, BuildCreativeReturn, CreativeTemplatePlatform, CreativeGenerativePlatform, RefinementMessage, SyncCreativesRow, } from './specialisms/creative';
|
|
24
|
+
export type { CreativeAdServerPlatform } from './specialisms/creative-ad-server';
|
|
25
|
+
export type { CampaignGovernancePlatform } from './specialisms/campaign-governance';
|
|
26
|
+
export type { ContentStandardsPlatform } from './specialisms/content-standards';
|
|
27
|
+
export type { PropertyListsPlatform, CollectionListsPlatform } from './specialisms/lists';
|
|
28
|
+
export type { SalesPlatform } from './specialisms/sales';
|
|
29
|
+
export type { AudiencePlatform, Audience, SyncAudiencesRow, AudienceStatus } from './specialisms/audiences';
|
|
30
|
+
export type { SignalsPlatform } from './specialisms/signals';
|
|
31
|
+
export type { BrandRightsPlatform } from './specialisms/brand-rights';
|
|
32
|
+
export type { GetBrandIdentityRequest, GetBrandIdentitySuccess, GetRightsRequest, GetRightsSuccess, AcquireRightsRequest, AcquireRightsAcquired, AcquireRightsPendingApproval, AcquireRightsRejected, AcquireRightsError, RightUse, RightType, RightsConstraint, RightsTerms, RightsPricingOption, GenerationCredential, } from '../../types/core.generated';
|
|
33
|
+
export { createAdcpServerFromPlatform, getAllAdcpMigrations, type CreateAdcpServerFromPlatformOptions, type DecisioningAdcpServer, type DecisioningObservabilityHooks, } from './runtime/from-platform';
|
|
34
|
+
export { PlatformConfigError, validatePlatform } from './runtime/validate-platform';
|
|
35
|
+
export { createInMemoryTaskRegistry, type TaskRegistry, type TaskRecord, type TaskStatus, } from './runtime/task-registry';
|
|
36
|
+
export { createPostgresTaskRegistry, getDecisioningTaskRegistryMigration, type CreatePostgresTaskRegistryOptions, type PgQueryable, } from './runtime/postgres-task-registry';
|
|
37
|
+
export { createTenantRegistry, createDefaultJwksValidator, type TenantRegistry, type TenantConfig, type TenantSigningKey, type TenantStatus, type TenantHealth, type TenantRegistryOptions, type JwksValidator, type JwksValidationResult, } from './tenant-registry';
|
|
38
|
+
export { getAsset, requireAsset } from './manifest-helpers';
|
|
39
|
+
export { buildListCreativesResponse, type BuildListCreativesResponseOpts } from './list-helpers';
|
|
40
|
+
export { resolveStartTime, type ResolveStartTimeOptions } from './start-time';
|
|
41
|
+
export { createTenantAdminRouter, createTenantAdminHandlers, mountTenantAdmin, type TenantAdminHandlers, type RouterLike, } from './admin-router';
|
|
42
|
+
export { batchPoll, validationError, upstreamError } from './helpers';
|
|
43
|
+
export type { RequestShape } from './helpers';
|
|
44
|
+
export { buildProduct, buildPricingOption, buildPackage } from './assembly-helpers';
|
|
45
|
+
export type { BuildProductInput, BuildPricingOptionInput, BuildPackageInput } from './assembly-helpers';
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,SA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B,EAC1B,mCAAmC,EACnC,KAAK,iCAAiC,EACtC,KAAK,WAAW,GACjB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,EAAE,0BAA0B,EAAE,KAAK,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAIjG,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAI9E,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAM9C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpF,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DecisioningPlatform v1.0 — preview surface for the v6.0 architecture.
|
|
4
|
+
*
|
|
5
|
+
* Status: PREVIEW. Types only; not yet wired into the framework. Subject
|
|
6
|
+
* to change before 6.0 ships. Don't build production adapters against this
|
|
7
|
+
* yet — the framework still routes through the v5.x handler-style API.
|
|
8
|
+
*
|
|
9
|
+
* Design proposal: `.context/proposals/specialism-platform-interfaces-v3.md`
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.buildPackage = exports.buildPricingOption = exports.buildProduct = exports.upstreamError = exports.validationError = exports.batchPoll = exports.mountTenantAdmin = exports.createTenantAdminHandlers = exports.createTenantAdminRouter = exports.resolveStartTime = exports.buildListCreativesResponse = exports.requireAsset = exports.getAsset = exports.createDefaultJwksValidator = exports.createTenantRegistry = exports.getDecisioningTaskRegistryMigration = exports.createPostgresTaskRegistry = exports.createInMemoryTaskRegistry = exports.validatePlatform = exports.PlatformConfigError = exports.getAllAdcpMigrations = exports.createAdcpServerFromPlatform = exports.identityStatusMappers = exports.refAccountId = exports.AccountNotFoundError = exports.createInMemoryStatusChangeBus = exports.getStatusChangeBus = exports.setStatusChangeBus = exports.publishStatusChange = exports.PolicyViolationError = exports.GovernanceDeniedError = exports.ComplianceUnsatisfiedError = exports.UnsupportedFeatureError = exports.ServiceUnavailableError = exports.RateLimitedError = exports.PermissionDeniedError = exports.AuthRequiredError = exports.BackwardsTimeRangeError = exports.InvalidStateError = exports.InvalidRequestError = exports.IdempotencyConflictError = exports.BudgetExhaustedError = exports.BudgetTooLowError = exports.CreativeRejectedError = exports.ProductUnavailableError = exports.CreativeNotFoundError = exports.ProductNotFoundError = exports.MediaBuyNotFoundError = exports.PackageNotFoundError = exports.AdcpError = void 0;
|
|
15
|
+
// Adopter-facing structured-error primitive.
|
|
16
|
+
//
|
|
17
|
+
// `AdcpError` is the canonical throwable for structured rejection. Specialism
|
|
18
|
+
// methods return plain `T` for success or `throw new AdcpError(...)` to project
|
|
19
|
+
// to the wire `adcp_error` envelope.
|
|
20
|
+
//
|
|
21
|
+
// HITL is expressed in the type system via the dual-method shape on each
|
|
22
|
+
// spec-HITL tool (`xxx` for sync, `xxxTask` for HITL). No adopter-facing
|
|
23
|
+
// task primitives — the framework owns task lifecycle and dispatches the
|
|
24
|
+
// `*Task` method in the background.
|
|
25
|
+
var async_outcome_1 = require("./async-outcome");
|
|
26
|
+
Object.defineProperty(exports, "AdcpError", { enumerable: true, get: function () { return async_outcome_1.AdcpError; } });
|
|
27
|
+
// Typed `AdcpError` subclasses — adopter convenience for the highest-traffic
|
|
28
|
+
// error codes. Each class encodes the canonical code/recovery/field shape.
|
|
29
|
+
// LLM-generated platforms get autocomplete on the import; humans skim the
|
|
30
|
+
// list to find the right class. See `errors-typed.ts`.
|
|
31
|
+
var errors_typed_1 = require("./errors-typed");
|
|
32
|
+
Object.defineProperty(exports, "PackageNotFoundError", { enumerable: true, get: function () { return errors_typed_1.PackageNotFoundError; } });
|
|
33
|
+
Object.defineProperty(exports, "MediaBuyNotFoundError", { enumerable: true, get: function () { return errors_typed_1.MediaBuyNotFoundError; } });
|
|
34
|
+
Object.defineProperty(exports, "ProductNotFoundError", { enumerable: true, get: function () { return errors_typed_1.ProductNotFoundError; } });
|
|
35
|
+
Object.defineProperty(exports, "CreativeNotFoundError", { enumerable: true, get: function () { return errors_typed_1.CreativeNotFoundError; } });
|
|
36
|
+
Object.defineProperty(exports, "ProductUnavailableError", { enumerable: true, get: function () { return errors_typed_1.ProductUnavailableError; } });
|
|
37
|
+
Object.defineProperty(exports, "CreativeRejectedError", { enumerable: true, get: function () { return errors_typed_1.CreativeRejectedError; } });
|
|
38
|
+
Object.defineProperty(exports, "BudgetTooLowError", { enumerable: true, get: function () { return errors_typed_1.BudgetTooLowError; } });
|
|
39
|
+
Object.defineProperty(exports, "BudgetExhaustedError", { enumerable: true, get: function () { return errors_typed_1.BudgetExhaustedError; } });
|
|
40
|
+
Object.defineProperty(exports, "IdempotencyConflictError", { enumerable: true, get: function () { return errors_typed_1.IdempotencyConflictError; } });
|
|
41
|
+
Object.defineProperty(exports, "InvalidRequestError", { enumerable: true, get: function () { return errors_typed_1.InvalidRequestError; } });
|
|
42
|
+
Object.defineProperty(exports, "InvalidStateError", { enumerable: true, get: function () { return errors_typed_1.InvalidStateError; } });
|
|
43
|
+
Object.defineProperty(exports, "BackwardsTimeRangeError", { enumerable: true, get: function () { return errors_typed_1.BackwardsTimeRangeError; } });
|
|
44
|
+
Object.defineProperty(exports, "AuthRequiredError", { enumerable: true, get: function () { return errors_typed_1.AuthRequiredError; } });
|
|
45
|
+
Object.defineProperty(exports, "PermissionDeniedError", { enumerable: true, get: function () { return errors_typed_1.PermissionDeniedError; } });
|
|
46
|
+
Object.defineProperty(exports, "RateLimitedError", { enumerable: true, get: function () { return errors_typed_1.RateLimitedError; } });
|
|
47
|
+
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_typed_1.ServiceUnavailableError; } });
|
|
48
|
+
Object.defineProperty(exports, "UnsupportedFeatureError", { enumerable: true, get: function () { return errors_typed_1.UnsupportedFeatureError; } });
|
|
49
|
+
Object.defineProperty(exports, "ComplianceUnsatisfiedError", { enumerable: true, get: function () { return errors_typed_1.ComplianceUnsatisfiedError; } });
|
|
50
|
+
Object.defineProperty(exports, "GovernanceDeniedError", { enumerable: true, get: function () { return errors_typed_1.GovernanceDeniedError; } });
|
|
51
|
+
Object.defineProperty(exports, "PolicyViolationError", { enumerable: true, get: function () { return errors_typed_1.PolicyViolationError; } });
|
|
52
|
+
// Status-change event bus — adopter-facing primitive for spec-native
|
|
53
|
+
// lifecycle channels (media_buy / creative / audience / signal / proposal /
|
|
54
|
+
// plan / rights_grant / delivery_report). Module-level so adopters can
|
|
55
|
+
// publish from webhook handlers, crons, in-process workers without holding
|
|
56
|
+
// a server reference.
|
|
57
|
+
var status_changes_1 = require("./status-changes");
|
|
58
|
+
Object.defineProperty(exports, "publishStatusChange", { enumerable: true, get: function () { return status_changes_1.publishStatusChange; } });
|
|
59
|
+
Object.defineProperty(exports, "setStatusChangeBus", { enumerable: true, get: function () { return status_changes_1.setStatusChangeBus; } });
|
|
60
|
+
Object.defineProperty(exports, "getStatusChangeBus", { enumerable: true, get: function () { return status_changes_1.getStatusChangeBus; } });
|
|
61
|
+
Object.defineProperty(exports, "createInMemoryStatusChangeBus", { enumerable: true, get: function () { return status_changes_1.createInMemoryStatusChangeBus; } });
|
|
62
|
+
var account_1 = require("./account");
|
|
63
|
+
Object.defineProperty(exports, "AccountNotFoundError", { enumerable: true, get: function () { return account_1.AccountNotFoundError; } });
|
|
64
|
+
Object.defineProperty(exports, "refAccountId", { enumerable: true, get: function () { return account_1.refAccountId; } });
|
|
65
|
+
var status_mappers_1 = require("./status-mappers");
|
|
66
|
+
Object.defineProperty(exports, "identityStatusMappers", { enumerable: true, get: function () { return status_mappers_1.identityStatusMappers; } });
|
|
67
|
+
// Runtime (v6.0 alpha) — preview surface for adopters spiking against the
|
|
68
|
+
// new shape. Subject to change before 6.0 GA.
|
|
69
|
+
var from_platform_1 = require("./runtime/from-platform");
|
|
70
|
+
Object.defineProperty(exports, "createAdcpServerFromPlatform", { enumerable: true, get: function () { return from_platform_1.createAdcpServerFromPlatform; } });
|
|
71
|
+
Object.defineProperty(exports, "getAllAdcpMigrations", { enumerable: true, get: function () { return from_platform_1.getAllAdcpMigrations; } });
|
|
72
|
+
var validate_platform_1 = require("./runtime/validate-platform");
|
|
73
|
+
Object.defineProperty(exports, "PlatformConfigError", { enumerable: true, get: function () { return validate_platform_1.PlatformConfigError; } });
|
|
74
|
+
Object.defineProperty(exports, "validatePlatform", { enumerable: true, get: function () { return validate_platform_1.validatePlatform; } });
|
|
75
|
+
var task_registry_1 = require("./runtime/task-registry");
|
|
76
|
+
Object.defineProperty(exports, "createInMemoryTaskRegistry", { enumerable: true, get: function () { return task_registry_1.createInMemoryTaskRegistry; } });
|
|
77
|
+
var postgres_task_registry_1 = require("./runtime/postgres-task-registry");
|
|
78
|
+
Object.defineProperty(exports, "createPostgresTaskRegistry", { enumerable: true, get: function () { return postgres_task_registry_1.createPostgresTaskRegistry; } });
|
|
79
|
+
Object.defineProperty(exports, "getDecisioningTaskRegistryMigration", { enumerable: true, get: function () { return postgres_task_registry_1.getDecisioningTaskRegistryMigration; } });
|
|
80
|
+
// Multi-tenant deployment helper — wraps createAdcpServerFromPlatform with
|
|
81
|
+
// per-tenant config, health states (healthy/unverified/disabled), and JWKS
|
|
82
|
+
// validation. Composes with the existing serve() host-routing surface.
|
|
83
|
+
var tenant_registry_1 = require("./tenant-registry");
|
|
84
|
+
Object.defineProperty(exports, "createTenantRegistry", { enumerable: true, get: function () { return tenant_registry_1.createTenantRegistry; } });
|
|
85
|
+
Object.defineProperty(exports, "createDefaultJwksValidator", { enumerable: true, get: function () { return tenant_registry_1.createDefaultJwksValidator; } });
|
|
86
|
+
// Manifest helpers — typed accessors for creative_manifest.assets values.
|
|
87
|
+
// Save adopters from writing the same null-check + discriminator-check
|
|
88
|
+
// boilerplate per call.
|
|
89
|
+
var manifest_helpers_1 = require("./manifest-helpers");
|
|
90
|
+
Object.defineProperty(exports, "getAsset", { enumerable: true, get: function () { return manifest_helpers_1.getAsset; } });
|
|
91
|
+
Object.defineProperty(exports, "requireAsset", { enumerable: true, get: function () { return manifest_helpers_1.requireAsset; } });
|
|
92
|
+
// List helpers — wrap row arrays + pagination into the heavier wire shapes
|
|
93
|
+
// (today: list_creatives, which carries query_summary alongside the rows).
|
|
94
|
+
var list_helpers_1 = require("./list-helpers");
|
|
95
|
+
Object.defineProperty(exports, "buildListCreativesResponse", { enumerable: true, get: function () { return list_helpers_1.buildListCreativesResponse; } });
|
|
96
|
+
// Start-time helper — normalize the wire `start_time` union into a Date,
|
|
97
|
+
// with platform-aware ASAP lead-time injection.
|
|
98
|
+
var start_time_1 = require("./start-time");
|
|
99
|
+
Object.defineProperty(exports, "resolveStartTime", { enumerable: true, get: function () { return start_time_1.resolveStartTime; } });
|
|
100
|
+
// Admin Express router for ops visibility into the TenantRegistry.
|
|
101
|
+
// Mount on a separate port/path with operator auth.
|
|
102
|
+
var admin_router_1 = require("./admin-router");
|
|
103
|
+
Object.defineProperty(exports, "createTenantAdminRouter", { enumerable: true, get: function () { return admin_router_1.createTenantAdminRouter; } });
|
|
104
|
+
Object.defineProperty(exports, "createTenantAdminHandlers", { enumerable: true, get: function () { return admin_router_1.createTenantAdminHandlers; } });
|
|
105
|
+
Object.defineProperty(exports, "mountTenantAdmin", { enumerable: true, get: function () { return admin_router_1.mountTenantAdmin; } });
|
|
106
|
+
// Adopter helpers — batchPoll, validationError, upstreamError, RequestShape.
|
|
107
|
+
// All opt-in convenience; nothing in the framework calls these internally.
|
|
108
|
+
var helpers_1 = require("./helpers");
|
|
109
|
+
Object.defineProperty(exports, "batchPoll", { enumerable: true, get: function () { return helpers_1.batchPoll; } });
|
|
110
|
+
Object.defineProperty(exports, "validationError", { enumerable: true, get: function () { return helpers_1.validationError; } });
|
|
111
|
+
Object.defineProperty(exports, "upstreamError", { enumerable: true, get: function () { return helpers_1.upstreamError; } });
|
|
112
|
+
// Wire-shape assembly helpers — emit correct Product / PricingOption /
|
|
113
|
+
// package shapes from intent-shaped input. Reduces 30+ lines of wire
|
|
114
|
+
// boilerplate per resource. Used in slim skill examples so LLMs scaffold
|
|
115
|
+
// correct shapes from first attempt.
|
|
116
|
+
var assembly_helpers_1 = require("./assembly-helpers");
|
|
117
|
+
Object.defineProperty(exports, "buildProduct", { enumerable: true, get: function () { return assembly_helpers_1.buildProduct; } });
|
|
118
|
+
Object.defineProperty(exports, "buildPricingOption", { enumerable: true, get: function () { return assembly_helpers_1.buildPricingOption; } });
|
|
119
|
+
Object.defineProperty(exports, "buildPackage", { enumerable: true, get: function () { return assembly_helpers_1.buildPackage; } });
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,6CAA6C;AAC7C,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,qCAAqC;AACrC,EAAE;AACF,yEAAyE;AACzE,yEAAyE;AACzE,yEAAyE;AACzE,oCAAoC;AACpC,i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IAAA,0BAA0B,OAAA;AAC1B,6IAAA,mCAAmC,OAAA;AAKrC,2EAA2E;AAC3E,2EAA2E;AAC3E,uEAAuE;AACvE,qDAW2B;AAVzB,uHAAA,oBAAoB,OAAA;AACpB,6HAAA,0BAA0B,OAAA;AAW5B,0EAA0E;AAC1E,uEAAuE;AACvE,wBAAwB;AACxB,uDAA4D;AAAnD,4GAAA,QAAQ,OAAA;AAAE,gHAAA,YAAY,OAAA;AAE/B,2EAA2E;AAC3E,2EAA2E;AAC3E,+CAAiG;AAAxF,0HAAA,0BAA0B,OAAA;AAEnC,yEAAyE;AACzE,gDAAgD;AAChD,2CAA8E;AAArE,8GAAA,gBAAgB,OAAA;AAEzB,mEAAmE;AACnE,oDAAoD;AACpD,+CAMwB;AALtB,uHAAA,uBAAuB,OAAA;AACvB,yHAAA,yBAAyB,OAAA;AACzB,gHAAA,gBAAgB,OAAA;AAKlB,6EAA6E;AAC7E,2EAA2E;AAC3E,qCAAsE;AAA7D,oGAAA,SAAS,OAAA;AAAE,0GAAA,eAAe,OAAA;AAAE,wGAAA,aAAa,OAAA;AAGlD,uEAAuE;AACvE,qEAAqE;AACrE,yEAAyE;AACzE,qCAAqC;AACrC,uDAAoF;AAA3E,gHAAA,YAAY,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAAE,gHAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for building paginated list responses.
|
|
3
|
+
*
|
|
4
|
+
* `list_creatives` is the heaviest of the read tools: its response wraps the
|
|
5
|
+
* row array in `query_summary` (`total_matching`, `returned`, `filters_applied`,
|
|
6
|
+
* `sort_applied`) AND `pagination` (`has_more`, `cursor`, `total_count`).
|
|
7
|
+
* Adopters writing the wrapper by hand re-derive the same fields per call;
|
|
8
|
+
* this helper threads a row array + pagination cursor + the original request
|
|
9
|
+
* into the wire shape.
|
|
10
|
+
*
|
|
11
|
+
* `list_property_lists`, `list_collection_lists`, and other governance reads
|
|
12
|
+
* use a simpler `{ lists: [...] }` wrapper that the framework's response
|
|
13
|
+
* builders already cover — those don't need a row helper.
|
|
14
|
+
*
|
|
15
|
+
* Status: Preview / 6.0.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
import type { ListCreativesRequest, ListCreativesResponse, PaginationResponse } from '../../types/tools.generated';
|
|
20
|
+
export interface BuildListCreativesResponseOpts {
|
|
21
|
+
/** Original request — used to surface `filters_applied` + `sort_applied` summaries. */
|
|
22
|
+
request: ListCreativesRequest;
|
|
23
|
+
/** The page of creative rows. Length determines `query_summary.returned`. */
|
|
24
|
+
creatives: ListCreativesResponse['creatives'];
|
|
25
|
+
/** Pagination cursor for the next page. Required — pass `{ has_more: false }` when this is the last page. */
|
|
26
|
+
pagination: PaginationResponse;
|
|
27
|
+
/**
|
|
28
|
+
* Total count across all pages. When omitted, defaults to
|
|
29
|
+
* `pagination.total_count` if present, else `creatives.length` (last-page
|
|
30
|
+
* approximation). Set explicitly when your backend can compute the true
|
|
31
|
+
* total.
|
|
32
|
+
*/
|
|
33
|
+
totalMatching?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a `ListCreativesResponse` from a row array + pagination + the
|
|
37
|
+
* original request. Computes `query_summary.filters_applied` from
|
|
38
|
+
* `request.filters` and threads `request.sort` into `sort_applied`.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* listCreatives: async (req, ctx) => {
|
|
42
|
+
* const rows = await this.db.queryCreatives(req);
|
|
43
|
+
* const cursor = rows.length === req.pagination?.limit ? this.nextCursor(rows) : undefined;
|
|
44
|
+
* return buildListCreativesResponse({
|
|
45
|
+
* request: req,
|
|
46
|
+
* creatives: rows,
|
|
47
|
+
* pagination: { has_more: cursor != null, cursor, total_count: rows.totalCount },
|
|
48
|
+
* });
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildListCreativesResponse(opts: BuildListCreativesResponseOpts): ListCreativesResponse;
|
|
53
|
+
//# sourceMappingURL=list-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/decisioning/list-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEnH,MAAM,WAAW,8BAA8B;IAC7C,uFAAuF;IACvF,OAAO,EAAE,oBAAoB,CAAC;IAC9B,6EAA6E;IAC7E,SAAS,EAAE,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC9C,6GAA6G;IAC7G,UAAU,EAAE,kBAAkB,CAAC;IAC/B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,8BAA8B,GAAG,qBAAqB,CA0CtG"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Helpers for building paginated list responses.
|
|
4
|
+
*
|
|
5
|
+
* `list_creatives` is the heaviest of the read tools: its response wraps the
|
|
6
|
+
* row array in `query_summary` (`total_matching`, `returned`, `filters_applied`,
|
|
7
|
+
* `sort_applied`) AND `pagination` (`has_more`, `cursor`, `total_count`).
|
|
8
|
+
* Adopters writing the wrapper by hand re-derive the same fields per call;
|
|
9
|
+
* this helper threads a row array + pagination cursor + the original request
|
|
10
|
+
* into the wire shape.
|
|
11
|
+
*
|
|
12
|
+
* `list_property_lists`, `list_collection_lists`, and other governance reads
|
|
13
|
+
* use a simpler `{ lists: [...] }` wrapper that the framework's response
|
|
14
|
+
* builders already cover — those don't need a row helper.
|
|
15
|
+
*
|
|
16
|
+
* Status: Preview / 6.0.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.buildListCreativesResponse = buildListCreativesResponse;
|
|
22
|
+
/**
|
|
23
|
+
* Build a `ListCreativesResponse` from a row array + pagination + the
|
|
24
|
+
* original request. Computes `query_summary.filters_applied` from
|
|
25
|
+
* `request.filters` and threads `request.sort` into `sort_applied`.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* listCreatives: async (req, ctx) => {
|
|
29
|
+
* const rows = await this.db.queryCreatives(req);
|
|
30
|
+
* const cursor = rows.length === req.pagination?.limit ? this.nextCursor(rows) : undefined;
|
|
31
|
+
* return buildListCreativesResponse({
|
|
32
|
+
* request: req,
|
|
33
|
+
* creatives: rows,
|
|
34
|
+
* pagination: { has_more: cursor != null, cursor, total_count: rows.totalCount },
|
|
35
|
+
* });
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function buildListCreativesResponse(opts) {
|
|
40
|
+
const { request, creatives, pagination, totalMatching } = opts;
|
|
41
|
+
const filters = request.filters;
|
|
42
|
+
const filtersApplied = [];
|
|
43
|
+
if (filters) {
|
|
44
|
+
if (filters.accounts?.length)
|
|
45
|
+
filtersApplied.push('accounts');
|
|
46
|
+
if (filters.statuses?.length)
|
|
47
|
+
filtersApplied.push('statuses');
|
|
48
|
+
if (filters.tags?.length)
|
|
49
|
+
filtersApplied.push('tags');
|
|
50
|
+
if (filters.tags_any?.length)
|
|
51
|
+
filtersApplied.push('tags_any');
|
|
52
|
+
if (filters.name_contains)
|
|
53
|
+
filtersApplied.push('name_contains');
|
|
54
|
+
if (filters.creative_ids?.length)
|
|
55
|
+
filtersApplied.push('creative_ids');
|
|
56
|
+
if (filters.created_after)
|
|
57
|
+
filtersApplied.push('created_after');
|
|
58
|
+
if (filters.created_before)
|
|
59
|
+
filtersApplied.push('created_before');
|
|
60
|
+
if (filters.updated_after)
|
|
61
|
+
filtersApplied.push('updated_after');
|
|
62
|
+
if (filters.updated_before)
|
|
63
|
+
filtersApplied.push('updated_before');
|
|
64
|
+
if (filters.assigned_to_packages?.length)
|
|
65
|
+
filtersApplied.push('assigned_to_packages');
|
|
66
|
+
if (filters.media_buy_ids?.length)
|
|
67
|
+
filtersApplied.push('media_buy_ids');
|
|
68
|
+
if (filters.unassigned !== undefined)
|
|
69
|
+
filtersApplied.push('unassigned');
|
|
70
|
+
if (filters.has_served !== undefined)
|
|
71
|
+
filtersApplied.push('has_served');
|
|
72
|
+
if (filters.concept_ids?.length)
|
|
73
|
+
filtersApplied.push('concept_ids');
|
|
74
|
+
if (filters.format_ids?.length)
|
|
75
|
+
filtersApplied.push('format_ids');
|
|
76
|
+
if (filters.has_variables !== undefined)
|
|
77
|
+
filtersApplied.push('has_variables');
|
|
78
|
+
}
|
|
79
|
+
const summary = {
|
|
80
|
+
total_matching: totalMatching ?? pagination.total_count ?? creatives.length,
|
|
81
|
+
returned: creatives.length,
|
|
82
|
+
...(filtersApplied.length > 0 && { filters_applied: filtersApplied }),
|
|
83
|
+
...(request.sort && {
|
|
84
|
+
sort_applied: {
|
|
85
|
+
...(request.sort.field !== undefined && { field: request.sort.field }),
|
|
86
|
+
...(request.sort.direction !== undefined && { direction: request.sort.direction }),
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
query_summary: summary,
|
|
92
|
+
pagination,
|
|
93
|
+
creatives,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=list-helpers.js.map
|