@adcp/sdk 14.0.0 → 14.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/dist/lib/adapters/implicit-account-store.d.mts +12 -7
- package/dist/lib/adapters/implicit-account-store.d.ts +12 -7
- package/dist/lib/adapters/implicit-account-store.js +69 -15
- package/dist/lib/adapters/implicit-account-store.mjs +69 -15
- package/dist/lib/core/AgentClient.d.mts +1 -0
- package/dist/lib/core/AgentClient.d.ts +1 -0
- package/dist/lib/core/AgentClient.js +3 -0
- package/dist/lib/core/AgentClient.mjs +3 -0
- package/dist/lib/core/SingleAgentClient.d.mts +35 -2
- package/dist/lib/core/SingleAgentClient.d.ts +35 -2
- package/dist/lib/core/SingleAgentClient.js +377 -36
- package/dist/lib/core/SingleAgentClient.mjs +387 -38
- package/dist/lib/core/TaskExecutor.d.mts +3 -1
- package/dist/lib/core/TaskExecutor.d.ts +3 -1
- package/dist/lib/core/TaskExecutor.js +17 -12
- package/dist/lib/core/TaskExecutor.mjs +17 -12
- package/dist/lib/core/account-key.d.mts +3 -0
- package/dist/lib/core/account-key.d.ts +3 -0
- package/dist/lib/core/account-key.js +41 -0
- package/dist/lib/core/account-key.mjs +17 -0
- package/dist/lib/core/account-resolution.d.mts +2 -0
- package/dist/lib/core/account-resolution.d.ts +2 -0
- package/dist/lib/core/buyer-account-registry.d.mts +93 -0
- package/dist/lib/core/buyer-account-registry.d.ts +93 -0
- package/dist/lib/core/buyer-account-registry.js +602 -0
- package/dist/lib/core/buyer-account-registry.mjs +578 -0
- package/dist/lib/core/product-cache.d.mts +18 -0
- package/dist/lib/core/product-cache.d.ts +18 -0
- package/dist/lib/core/product-cache.js +137 -0
- package/dist/lib/core/product-cache.mjs +112 -0
- package/dist/lib/errors/index.d.mts +40 -1
- package/dist/lib/errors/index.d.ts +40 -1
- package/dist/lib/errors/index.js +69 -3
- package/dist/lib/errors/index.mjs +64 -3
- package/dist/lib/governance/authorization.d.mts +17 -1
- package/dist/lib/governance/authorization.d.ts +17 -1
- package/dist/lib/governance/authorization.js +55 -7
- package/dist/lib/governance/authorization.mjs +59 -7
- package/dist/lib/governance/index.d.mts +2 -2
- package/dist/lib/governance/index.d.ts +2 -2
- package/dist/lib/governance/index.js +2 -0
- package/dist/lib/governance/index.mjs +3 -1
- package/dist/lib/index.d.mts +7 -4
- package/dist/lib/index.d.ts +7 -4
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.mjs +31 -1
- package/dist/lib/net/agent-transport-fetch.d.mts +4 -0
- package/dist/lib/net/agent-transport-fetch.d.ts +4 -0
- package/dist/lib/net/agent-transport-fetch.js +18 -5
- package/dist/lib/net/agent-transport-fetch.mjs +17 -5
- package/dist/lib/protocols/a2a.js +9 -1
- package/dist/lib/protocols/a2a.mjs +9 -1
- package/dist/lib/protocols/index.js +9 -2
- package/dist/lib/protocols/index.mjs +9 -2
- package/dist/lib/protocols/mcp-modern.js +2 -1
- package/dist/lib/protocols/mcp-modern.mjs +2 -1
- package/dist/lib/protocols/mcp.js +5 -2
- package/dist/lib/protocols/mcp.mjs +5 -2
- package/dist/lib/protocols/rawResponseCapture.d.mts +6 -0
- package/dist/lib/protocols/rawResponseCapture.d.ts +6 -0
- package/dist/lib/protocols/rawResponseCapture.js +41 -29
- package/dist/lib/protocols/rawResponseCapture.mjs +40 -29
- package/dist/lib/protocols/signedRequestRejection.d.mts +9 -0
- package/dist/lib/protocols/signedRequestRejection.d.ts +9 -0
- package/dist/lib/protocols/signedRequestRejection.js +209 -0
- package/dist/lib/protocols/signedRequestRejection.mjs +189 -0
- package/dist/lib/protocols/transportDiagnostics.d.mts +1 -0
- package/dist/lib/protocols/transportDiagnostics.d.ts +1 -0
- package/dist/lib/protocols/transportDiagnostics.js +2 -0
- package/dist/lib/protocols/transportDiagnostics.mjs +1 -0
- package/dist/lib/registry/types.generated.d.mts +112 -45
- package/dist/lib/registry/types.generated.d.ts +112 -45
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/account-provisioning.d.mts +2 -0
- package/dist/lib/server/account-provisioning.d.ts +2 -0
- package/dist/lib/server/account-provisioning.js +30 -0
- package/dist/lib/server/account-provisioning.mjs +6 -0
- package/dist/lib/server/account-reference-warnings.d.mts +12 -0
- package/dist/lib/server/account-reference-warnings.d.ts +12 -0
- package/dist/lib/server/account-reference-warnings.js +48 -0
- package/dist/lib/server/account-reference-warnings.mjs +23 -0
- package/dist/lib/server/auth-signature.js +1 -0
- package/dist/lib/server/auth-signature.mjs +1 -0
- package/dist/lib/server/create-adcp-server.d.mts +34 -0
- package/dist/lib/server/create-adcp-server.d.ts +34 -0
- package/dist/lib/server/create-adcp-server.js +225 -14
- package/dist/lib/server/create-adcp-server.mjs +225 -14
- package/dist/lib/server/decisioning/account.d.mts +2 -0
- package/dist/lib/server/decisioning/account.d.ts +2 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +49 -10
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +49 -10
- package/dist/lib/server/index.d.mts +2 -2
- package/dist/lib/server/index.d.ts +2 -2
- package/dist/lib/server/index.js +2 -0
- package/dist/lib/server/index.mjs +3 -1
- package/dist/lib/signing/agent-resolver/consistency.d.mts +6 -13
- package/dist/lib/signing/agent-resolver/consistency.d.ts +6 -13
- package/dist/lib/signing/agent-resolver/consistency.js +0 -1
- package/dist/lib/signing/agent-resolver/consistency.mjs +0 -1
- package/dist/lib/signing/agent-resolver/errors.d.mts +3 -1
- package/dist/lib/signing/agent-resolver/errors.d.ts +3 -1
- package/dist/lib/signing/agent-resolver/errors.js +6 -0
- package/dist/lib/signing/agent-resolver/errors.mjs +6 -0
- package/dist/lib/signing/agent-resolver/fetch-helpers.d.mts +11 -0
- package/dist/lib/signing/agent-resolver/fetch-helpers.d.ts +11 -0
- package/dist/lib/signing/agent-resolver/fetch-helpers.js +37 -2
- package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +40 -3
- package/dist/lib/signing/agent-resolver/jwks-set.js +24 -3
- package/dist/lib/signing/agent-resolver/jwks-set.mjs +24 -3
- package/dist/lib/signing/agent-resolver/legacy-brand.d.mts +15 -0
- package/dist/lib/signing/agent-resolver/legacy-brand.d.ts +15 -0
- package/dist/lib/signing/agent-resolver/legacy-brand.js +60 -0
- package/dist/lib/signing/agent-resolver/legacy-brand.mjs +36 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.d.mts +13 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.d.ts +13 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.js +108 -0
- package/dist/lib/signing/agent-resolver/operator-authorization.mjs +84 -0
- package/dist/lib/signing/agent-resolver/resolve-agent.d.mts +14 -4
- package/dist/lib/signing/agent-resolver/resolve-agent.d.ts +14 -4
- package/dist/lib/signing/agent-resolver/resolve-agent.js +148 -137
- package/dist/lib/signing/agent-resolver/resolve-agent.mjs +157 -139
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.mts +7 -1
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.d.ts +7 -1
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.js +50 -17
- package/dist/lib/signing/agent-resolver/resolved-agent-jwks.mjs +50 -17
- package/dist/lib/signing/agent-resolver/select-agent.d.mts +14 -15
- package/dist/lib/signing/agent-resolver/select-agent.d.ts +14 -15
- package/dist/lib/signing/agent-resolver/select-agent.js +98 -13
- package/dist/lib/signing/agent-resolver/select-agent.mjs +95 -13
- package/dist/lib/signing/brand-jwks.d.mts +29 -75
- package/dist/lib/signing/brand-jwks.d.ts +29 -75
- package/dist/lib/signing/brand-jwks.js +120 -182
- package/dist/lib/signing/brand-jwks.mjs +120 -182
- package/dist/lib/signing/errors.d.mts +7 -3
- package/dist/lib/signing/errors.d.ts +7 -3
- package/dist/lib/signing/errors.js +7 -2
- package/dist/lib/signing/errors.mjs +7 -2
- package/dist/lib/signing/jwks-https.d.mts +7 -0
- package/dist/lib/signing/jwks-https.d.ts +7 -0
- package/dist/lib/signing/jwks-https.js +31 -8
- package/dist/lib/signing/jwks-https.mjs +31 -8
- package/dist/lib/signing/jwks.d.mts +8 -0
- package/dist/lib/signing/jwks.d.ts +8 -0
- package/dist/lib/signing/middleware.js +2 -1
- package/dist/lib/signing/middleware.mjs +2 -1
- package/dist/lib/signing/publisher-pins.d.mts +11 -0
- package/dist/lib/signing/publisher-pins.d.ts +11 -0
- package/dist/lib/signing/publisher-pins.js +125 -0
- package/dist/lib/signing/publisher-pins.mjs +101 -0
- package/dist/lib/signing/server.d.mts +1 -0
- package/dist/lib/signing/server.d.ts +1 -0
- package/dist/lib/signing/types.d.mts +5 -0
- package/dist/lib/signing/types.d.ts +5 -0
- package/dist/lib/signing/verifier.js +50 -5
- package/dist/lib/signing/verifier.mjs +50 -5
- package/dist/lib/signing/webhook-verifier.d.mts +7 -2
- package/dist/lib/signing/webhook-verifier.d.ts +7 -2
- package/dist/lib/signing/webhook-verifier.js +42 -2
- package/dist/lib/signing/webhook-verifier.mjs +42 -2
- package/dist/lib/testing/storyboard/account-policy.d.mts +2 -0
- package/dist/lib/testing/storyboard/account-policy.d.ts +2 -0
- package/dist/lib/testing/storyboard/account-policy.js +35 -0
- package/dist/lib/testing/storyboard/account-policy.mjs +11 -0
- package/dist/lib/testing/storyboard/context.js +6 -0
- package/dist/lib/testing/storyboard/context.mjs +6 -0
- package/dist/lib/testing/storyboard/request-builder.js +12 -2
- package/dist/lib/testing/storyboard/request-builder.mjs +12 -2
- package/dist/lib/testing/storyboard/runner.js +3 -2
- package/dist/lib/testing/storyboard/runner.mjs +3 -2
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/types/accept-proposal.d.ts +19 -1
- package/dist/lib/types/buy-products.d.ts +19 -1
- package/dist/lib/types/check-governance.d.ts +19 -1
- package/dist/lib/types/comply-test-controller.d.ts +19 -1
- package/dist/lib/types/control-media-buy.d.ts +19 -1
- package/dist/lib/types/core.generated.d.mts +14 -1
- package/dist/lib/types/core.generated.d.ts +14 -1
- package/dist/lib/types/create-media-buy.d.ts +14 -1
- package/dist/lib/types/get-media-buys.d.ts +14 -1
- package/dist/lib/types/get-products.d.ts +19 -1
- package/dist/lib/types/list-products.d.ts +19 -1
- package/dist/lib/types/refine-proposals.d.ts +19 -1
- package/dist/lib/types/request-proposals.d.ts +19 -1
- package/dist/lib/types/schemas.generated.d.ts +12 -3
- package/dist/lib/types/schemas.generated.js +4 -1
- package/dist/lib/types/schemas.generated.mjs +4 -1
- package/dist/lib/types/tools.generated.d.mts +14 -1
- package/dist/lib/types/tools.generated.d.ts +14 -1
- package/dist/lib/types/update-media-buy.d.ts +14 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/webhooks/index.d.mts +24 -0
- package/dist/lib/webhooks/index.d.ts +24 -0
- package/dist/lib/webhooks/index.js +50 -24
- package/dist/lib/webhooks/index.mjs +49 -24
- package/dist/lib/wholesale-feed-sync/index.d.mts +2 -0
- package/dist/lib/wholesale-feed-sync/index.d.ts +2 -0
- package/dist/lib/wholesale-feed-sync/index.js +7 -0
- package/dist/lib/wholesale-feed-sync/index.mjs +4 -0
- package/dist/lib/wholesale-feed-sync/mirror.d.mts +97 -0
- package/dist/lib/wholesale-feed-sync/mirror.d.ts +97 -0
- package/dist/lib/wholesale-feed-sync/mirror.js +350 -0
- package/dist/lib/wholesale-feed-sync/mirror.mjs +322 -0
- package/dist/lib/wholesale-feed-sync/sync.d.mts +13 -29
- package/dist/lib/wholesale-feed-sync/sync.d.ts +13 -29
- package/dist/lib/wholesale-feed-sync/sync.js +208 -281
- package/dist/lib/wholesale-feed-sync/sync.mjs +213 -281
- package/dist/lib/wholesale-feed-sync/types.d.mts +4 -3
- package/dist/lib/wholesale-feed-sync/types.d.ts +4 -3
- package/docs/README.md +6 -0
- package/docs/TYPE-SUMMARY.md +2 -2
- package/docs/guides/BUILD-AN-AGENT.md +2 -2
- package/docs/guides/BUYER-QUICKSTART-3.2.md +2 -0
- package/docs/guides/BUYER-STORAGE.md +3 -0
- package/docs/guides/FIRST-CALL-TO-A-SELLER.md +106 -0
- package/docs/guides/SIGNING-GUIDE.md +16 -7
- package/docs/guides/account-resolution.md +132 -10
- package/docs/llms.txt +3 -2
- package/docs/migration-14.0-to-14.1.md +85 -0
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-4.x-to-5.x.md +1 -0
- package/docs/migration-agent-resolution-3.3.md +125 -0
- package/docs/recipes/verifying-inbound-webhooks.md +60 -15
- package/package.json +3 -2
- package/skills/adcp-brand.previous/SKILL.md +0 -200
- package/skills/adcp-creative.previous/SKILL.md +0 -305
- package/skills/adcp-governance.previous/SKILL.md +0 -566
- package/skills/adcp-measurement.previous/SKILL.md +0 -136
- package/skills/adcp-media-buy.previous/SKILL.md +0 -556
- package/skills/adcp-si.previous/SKILL.md +0 -206
- package/skills/adcp-signals.previous/SKILL.md +0 -204
|
@@ -43,6 +43,7 @@ var import_protocols = require('../protocols/index.js');
|
|
|
43
43
|
var import_mcp_tasks = require('../protocols/mcp-tasks.js');
|
|
44
44
|
var import_prepared_call_context = require('../protocols/prepared-call-context.js');
|
|
45
45
|
var import_auth = require('../auth/index.js');
|
|
46
|
+
var import_signedRequestRejection = require('../protocols/signedRequestRejection.js');
|
|
46
47
|
var import_errors = require('../errors/index.js');
|
|
47
48
|
var import_client_hooks = require('../validation/client-hooks.js');
|
|
48
49
|
var import_schema_validator = require('../validation/schema-validator.js');
|
|
@@ -943,16 +944,19 @@ class TaskExecutor {
|
|
|
943
944
|
(0, import_abort.throwIfAborted)(options.signal);
|
|
944
945
|
if (beforeProtocolDispatch) {
|
|
945
946
|
let decision;
|
|
946
|
-
|
|
947
|
+
const ownsSettlement = beforeProtocolDispatch.terminalSettlement !== "executor";
|
|
948
|
+
dispatchBoundaryOwnsTerminalState = ownsSettlement;
|
|
947
949
|
try {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
950
|
+
if (ownsSettlement) {
|
|
951
|
+
this.compactClosedExternalTaskSettlementFences();
|
|
952
|
+
if (this.liveExternalTaskSettlementCount() + this.settlementCapacityReservations.size >= COMPACTED_TASK_STATE_LIMIT) {
|
|
953
|
+
throw new Error("The durable task-settlement capacity is exhausted; no mutation claim was attempted.");
|
|
954
|
+
}
|
|
955
|
+
this.settlementCapacityReservations.add(taskId);
|
|
956
|
+
if (webhookRegistrationPersisted) {
|
|
957
|
+
await this.config.onDurableSettlementRequired?.(taskId);
|
|
958
|
+
(0, import_abort.throwIfAborted)(options.signal);
|
|
959
|
+
}
|
|
956
960
|
}
|
|
957
961
|
decision = await beforeProtocolDispatch(preparedCall.args, {
|
|
958
962
|
operationId: taskId,
|
|
@@ -961,6 +965,7 @@ class TaskExecutor {
|
|
|
961
965
|
registerExternalTaskSettlement: (handler) => this.registerExternalTaskSettlement(taskId, handler)
|
|
962
966
|
});
|
|
963
967
|
if (decision.action === "dispatch_committed") {
|
|
968
|
+
if (!ownsSettlement) throw new Error("An executor-settled dispatch hook cannot claim durable settlement.");
|
|
964
969
|
if (decision.requireDeferredSettlementResumeAuthorization === true && this.config.deferredStorage !== void 0) {
|
|
965
970
|
this.requireDeferredSettlementOperationRouting(this.config.deferredStorage);
|
|
966
971
|
}
|
|
@@ -984,8 +989,8 @@ class TaskExecutor {
|
|
|
984
989
|
}
|
|
985
990
|
return (0, import_match.attachMatch)(earlyResult);
|
|
986
991
|
}
|
|
987
|
-
dispatchCommitted =
|
|
988
|
-
dispatchSettlement = decision;
|
|
992
|
+
dispatchCommitted = decision.action === "dispatch_committed";
|
|
993
|
+
dispatchSettlement = decision.action === "dispatch_committed" ? decision : void 0;
|
|
989
994
|
}
|
|
990
995
|
(0, import_abort.throwIfAborted)(options.signal);
|
|
991
996
|
const postDispatchOptions = dispatchCommitted ? { ...options, signal: void 0 } : options;
|
|
@@ -4212,7 +4217,7 @@ class TaskExecutor {
|
|
|
4212
4217
|
status: "failed",
|
|
4213
4218
|
error: error.message || String(error),
|
|
4214
4219
|
adcpError: adcpErrorInfo,
|
|
4215
|
-
errorInstance: this.buildErrorInstance(taskId, adcpErrorInfo),
|
|
4220
|
+
errorInstance: (0, import_signedRequestRejection.getSignedRequestRejection)(error) ?? this.buildErrorInstance(taskId, adcpErrorInfo),
|
|
4216
4221
|
correlationId,
|
|
4217
4222
|
metadata: this.buildMetadata({
|
|
4218
4223
|
taskId,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { listMCPTasks } from "../protocols/mcp-tasks.mjs";
|
|
8
8
|
import { withPreparedProtocolToolCall } from "../protocols/prepared-call-context.mjs";
|
|
9
9
|
import { getAuthToken } from "../auth/index.mjs";
|
|
10
|
+
import { getSignedRequestRejection } from "../protocols/signedRequestRejection.mjs";
|
|
10
11
|
import { is401Error, adcpErrorToTypedError, ConfigurationError } from "../errors/index.mjs";
|
|
11
12
|
import {
|
|
12
13
|
validateOutgoingRequest,
|
|
@@ -916,16 +917,19 @@ class TaskExecutor {
|
|
|
916
917
|
throwIfAborted(options.signal);
|
|
917
918
|
if (beforeProtocolDispatch) {
|
|
918
919
|
let decision;
|
|
919
|
-
|
|
920
|
+
const ownsSettlement = beforeProtocolDispatch.terminalSettlement !== "executor";
|
|
921
|
+
dispatchBoundaryOwnsTerminalState = ownsSettlement;
|
|
920
922
|
try {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
923
|
+
if (ownsSettlement) {
|
|
924
|
+
this.compactClosedExternalTaskSettlementFences();
|
|
925
|
+
if (this.liveExternalTaskSettlementCount() + this.settlementCapacityReservations.size >= COMPACTED_TASK_STATE_LIMIT) {
|
|
926
|
+
throw new Error("The durable task-settlement capacity is exhausted; no mutation claim was attempted.");
|
|
927
|
+
}
|
|
928
|
+
this.settlementCapacityReservations.add(taskId);
|
|
929
|
+
if (webhookRegistrationPersisted) {
|
|
930
|
+
await this.config.onDurableSettlementRequired?.(taskId);
|
|
931
|
+
throwIfAborted(options.signal);
|
|
932
|
+
}
|
|
929
933
|
}
|
|
930
934
|
decision = await beforeProtocolDispatch(preparedCall.args, {
|
|
931
935
|
operationId: taskId,
|
|
@@ -934,6 +938,7 @@ class TaskExecutor {
|
|
|
934
938
|
registerExternalTaskSettlement: (handler) => this.registerExternalTaskSettlement(taskId, handler)
|
|
935
939
|
});
|
|
936
940
|
if (decision.action === "dispatch_committed") {
|
|
941
|
+
if (!ownsSettlement) throw new Error("An executor-settled dispatch hook cannot claim durable settlement.");
|
|
937
942
|
if (decision.requireDeferredSettlementResumeAuthorization === true && this.config.deferredStorage !== void 0) {
|
|
938
943
|
this.requireDeferredSettlementOperationRouting(this.config.deferredStorage);
|
|
939
944
|
}
|
|
@@ -957,8 +962,8 @@ class TaskExecutor {
|
|
|
957
962
|
}
|
|
958
963
|
return attachMatch(earlyResult);
|
|
959
964
|
}
|
|
960
|
-
dispatchCommitted =
|
|
961
|
-
dispatchSettlement = decision;
|
|
965
|
+
dispatchCommitted = decision.action === "dispatch_committed";
|
|
966
|
+
dispatchSettlement = decision.action === "dispatch_committed" ? decision : void 0;
|
|
962
967
|
}
|
|
963
968
|
throwIfAborted(options.signal);
|
|
964
969
|
const postDispatchOptions = dispatchCommitted ? { ...options, signal: void 0 } : options;
|
|
@@ -4185,7 +4190,7 @@ class TaskExecutor {
|
|
|
4185
4190
|
status: "failed",
|
|
4186
4191
|
error: error.message || String(error),
|
|
4187
4192
|
adcpError: adcpErrorInfo,
|
|
4188
|
-
errorInstance: this.buildErrorInstance(taskId, adcpErrorInfo),
|
|
4193
|
+
errorInstance: getSignedRequestRejection(error) ?? this.buildErrorInstance(taskId, adcpErrorInfo),
|
|
4189
4194
|
correlationId,
|
|
4190
4195
|
metadata: this.buildMetadata({
|
|
4191
4196
|
taskId,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var account_key_exports = {};
|
|
20
|
+
__export(account_key_exports, {
|
|
21
|
+
accountReferenceKey: () => accountReferenceKey
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(account_key_exports);
|
|
24
|
+
function accountReferenceKey(ref) {
|
|
25
|
+
if ("account_id" in ref) return JSON.stringify(["id", ref.account_id]);
|
|
26
|
+
return JSON.stringify([
|
|
27
|
+
"natural",
|
|
28
|
+
ref.brand.domain,
|
|
29
|
+
ref.brand.brand_id ?? null,
|
|
30
|
+
ref.brand.countries ? [...ref.brand.countries].sort() : null,
|
|
31
|
+
ref.operator,
|
|
32
|
+
ref.operator_unit?.id ?? null,
|
|
33
|
+
ref.currency ?? null,
|
|
34
|
+
ref.timezone ?? null,
|
|
35
|
+
ref.sandbox === true
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
accountReferenceKey
|
|
41
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function accountReferenceKey(ref) {
|
|
2
|
+
if ("account_id" in ref) return JSON.stringify(["id", ref.account_id]);
|
|
3
|
+
return JSON.stringify([
|
|
4
|
+
"natural",
|
|
5
|
+
ref.brand.domain,
|
|
6
|
+
ref.brand.brand_id ?? null,
|
|
7
|
+
ref.brand.countries ? [...ref.brand.countries].sort() : null,
|
|
8
|
+
ref.operator,
|
|
9
|
+
ref.operator_unit?.id ?? null,
|
|
10
|
+
ref.currency ?? null,
|
|
11
|
+
ref.timezone ?? null,
|
|
12
|
+
ref.sandbox === true
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
accountReferenceKey
|
|
17
|
+
};
|
|
@@ -16,6 +16,8 @@ export interface ResolveAccountOptions {
|
|
|
16
16
|
forTask?: string;
|
|
17
17
|
/** Billing party for buyer-declared accounts when the seller has no default. */
|
|
18
18
|
billing?: 'operator' | 'agent' | 'advertiser';
|
|
19
|
+
paymentTerms?: import('../types/tools.generated.mjs').PaymentTerms;
|
|
20
|
+
billingEntity?: import('../types/tools.generated.mjs').BusinessEntity;
|
|
19
21
|
/** An account_id or a callback choosing one of the eligible list_accounts rows. */
|
|
20
22
|
select?: string | ((accounts: readonly ListedAccount[]) => string);
|
|
21
23
|
}
|
|
@@ -16,6 +16,8 @@ export interface ResolveAccountOptions {
|
|
|
16
16
|
forTask?: string;
|
|
17
17
|
/** Billing party for buyer-declared accounts when the seller has no default. */
|
|
18
18
|
billing?: 'operator' | 'agent' | 'advertiser';
|
|
19
|
+
paymentTerms?: import('../types/tools.generated').PaymentTerms;
|
|
20
|
+
billingEntity?: import('../types/tools.generated').BusinessEntity;
|
|
19
21
|
/** An account_id or a callback choosing one of the eligible list_accounts rows. */
|
|
20
22
|
select?: string | ((accounts: readonly ListedAccount[]) => string);
|
|
21
23
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AccountReference, BusinessEntity, PaymentTerms, SyncAccountsResponse } from '../types/tools.generated.mjs';
|
|
2
|
+
import type { TaskOptions, TaskResult } from './ConversationTypes.mjs';
|
|
3
|
+
export type AccountPolicy = 'auto' | 'strict' | 'off';
|
|
4
|
+
export interface EnsureAccountOptions {
|
|
5
|
+
billing?: 'operator' | 'agent' | 'advertiser';
|
|
6
|
+
paymentTerms?: PaymentTerms;
|
|
7
|
+
billingEntity?: BusinessEntity;
|
|
8
|
+
/** Caller-owned retry identity. Settle ambiguous dispatches explicitly with this key; the registry never rotates it. */
|
|
9
|
+
idempotencyKey?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ProvisionedAccount {
|
|
12
|
+
account: AccountReference;
|
|
13
|
+
account_id?: string;
|
|
14
|
+
status: string;
|
|
15
|
+
pendingTaskId?: string;
|
|
16
|
+
/** Hashes of explicitly selected setup options; billing identities themselves are never persisted. */
|
|
17
|
+
setupTerms?: Partial<Record<keyof EnsureAccountOptions, string>>;
|
|
18
|
+
/** Stored reference aliases for authoritative repair after restart. */
|
|
19
|
+
aliases?: AccountReference[];
|
|
20
|
+
/** Monotonically increasing row revision when compareAndSet is implemented. */
|
|
21
|
+
revision?: number;
|
|
22
|
+
/** Durable claim. Reconcile an uncertain dispatch explicitly before provisioning again. */
|
|
23
|
+
dispatch?: {
|
|
24
|
+
idempotencyKey: string;
|
|
25
|
+
startedAt: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Partitioned by seller and caller scope. Implementations must provide read-your-writes. */
|
|
29
|
+
export interface BuyerAccountStorage {
|
|
30
|
+
get(key: string): Promise<ProvisionedAccount | undefined>;
|
|
31
|
+
set(key: string, account: ProvisionedAccount): Promise<void>;
|
|
32
|
+
/** Atomically insert (undefined revision) or replace. Store the supplied new revision. Required for multi-process safety. */
|
|
33
|
+
compareAndSet?(key: string, expectedRevision: number | undefined, account: ProvisionedAccount): Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
export interface BuyerAccountDispatch {
|
|
36
|
+
storageKey: string;
|
|
37
|
+
account: AccountReference;
|
|
38
|
+
idempotencyKey: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BuyerAccountProvisioningDispatch {
|
|
41
|
+
idempotencyKey: string;
|
|
42
|
+
/** Invoke immediately before the transport receives the mutation. */
|
|
43
|
+
beforeDispatch(): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export interface BuyerAccountRegistryOptions {
|
|
46
|
+
/** Awaited before dispatch; rejection prevents the mutation. */
|
|
47
|
+
onDispatchStart?: (dispatch: BuyerAccountDispatch) => Promise<void>;
|
|
48
|
+
/** Awaited for each seller result before account writes. Rejection preserves the claim for caller reconciliation. */
|
|
49
|
+
onResult?: (dispatch: BuyerAccountDispatch & {
|
|
50
|
+
result: TaskResult<unknown>;
|
|
51
|
+
}) => Promise<void>;
|
|
52
|
+
maxEntries?: number;
|
|
53
|
+
normalizeOptions?: (options: EnsureAccountOptions, taskOptions?: TaskOptions) => Promise<EnsureAccountOptions>;
|
|
54
|
+
}
|
|
55
|
+
export declare class BuyerAccountRegistry {
|
|
56
|
+
private scope;
|
|
57
|
+
private provision;
|
|
58
|
+
private storage?;
|
|
59
|
+
private repair?;
|
|
60
|
+
private readonly registryOptions;
|
|
61
|
+
private entries;
|
|
62
|
+
private pending;
|
|
63
|
+
private writes;
|
|
64
|
+
private repairs;
|
|
65
|
+
private repairWaiters;
|
|
66
|
+
private invalidatedHandles;
|
|
67
|
+
private observationEpoch;
|
|
68
|
+
private observationFloor;
|
|
69
|
+
private statusEpochs;
|
|
70
|
+
private readonly maxEntries;
|
|
71
|
+
private readonly normalizeOptions?;
|
|
72
|
+
constructor(scope: () => string, provision: (key: AccountReference, options: EnsureAccountOptions, taskOptions?: TaskOptions, dispatch?: BuyerAccountProvisioningDispatch) => Promise<TaskResult<SyncAccountsResponse>>, storage?: BuyerAccountStorage | undefined, repair?: ((accountId: string, taskOptions?: TaskOptions) => Promise<readonly unknown[]>) | undefined, registryOptions?: BuyerAccountRegistryOptions);
|
|
73
|
+
private key;
|
|
74
|
+
/** Capture before a seller request; observations older than a status repair are ignored. */
|
|
75
|
+
captureObservation(): number;
|
|
76
|
+
private observationIsCurrent;
|
|
77
|
+
private remember;
|
|
78
|
+
get(account: AccountReference): Promise<ProvisionedAccount | undefined>;
|
|
79
|
+
ensure(account: AccountReference, options?: EnsureAccountOptions, taskOptions?: TaskOptions, onTaskResult?: (result: TaskResult<unknown>) => void): Promise<ProvisionedAccount>;
|
|
80
|
+
private write;
|
|
81
|
+
private record;
|
|
82
|
+
private enqueue;
|
|
83
|
+
observeSync(refs: readonly AccountReference[], rows: readonly unknown[], dryRun?: boolean, observationEpoch?: number, expectedRevision?: number): Promise<void>;
|
|
84
|
+
private reconcileId;
|
|
85
|
+
observeList(rows: readonly unknown[], queriedAccountId?: string, observationEpoch?: number): Promise<void>;
|
|
86
|
+
private observeListAtScope;
|
|
87
|
+
/** After verifying account.status_changed, repair aliases by handle from the authoritative seller. */
|
|
88
|
+
applyStatusChange(notification: {
|
|
89
|
+
account_id: string;
|
|
90
|
+
}, options?: TaskOptions): Promise<void>;
|
|
91
|
+
private repairStatus;
|
|
92
|
+
private runRepair;
|
|
93
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AccountReference, BusinessEntity, PaymentTerms, SyncAccountsResponse } from '../types/tools.generated';
|
|
2
|
+
import type { TaskOptions, TaskResult } from './ConversationTypes';
|
|
3
|
+
export type AccountPolicy = 'auto' | 'strict' | 'off';
|
|
4
|
+
export interface EnsureAccountOptions {
|
|
5
|
+
billing?: 'operator' | 'agent' | 'advertiser';
|
|
6
|
+
paymentTerms?: PaymentTerms;
|
|
7
|
+
billingEntity?: BusinessEntity;
|
|
8
|
+
/** Caller-owned retry identity. Settle ambiguous dispatches explicitly with this key; the registry never rotates it. */
|
|
9
|
+
idempotencyKey?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ProvisionedAccount {
|
|
12
|
+
account: AccountReference;
|
|
13
|
+
account_id?: string;
|
|
14
|
+
status: string;
|
|
15
|
+
pendingTaskId?: string;
|
|
16
|
+
/** Hashes of explicitly selected setup options; billing identities themselves are never persisted. */
|
|
17
|
+
setupTerms?: Partial<Record<keyof EnsureAccountOptions, string>>;
|
|
18
|
+
/** Stored reference aliases for authoritative repair after restart. */
|
|
19
|
+
aliases?: AccountReference[];
|
|
20
|
+
/** Monotonically increasing row revision when compareAndSet is implemented. */
|
|
21
|
+
revision?: number;
|
|
22
|
+
/** Durable claim. Reconcile an uncertain dispatch explicitly before provisioning again. */
|
|
23
|
+
dispatch?: {
|
|
24
|
+
idempotencyKey: string;
|
|
25
|
+
startedAt: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Partitioned by seller and caller scope. Implementations must provide read-your-writes. */
|
|
29
|
+
export interface BuyerAccountStorage {
|
|
30
|
+
get(key: string): Promise<ProvisionedAccount | undefined>;
|
|
31
|
+
set(key: string, account: ProvisionedAccount): Promise<void>;
|
|
32
|
+
/** Atomically insert (undefined revision) or replace. Store the supplied new revision. Required for multi-process safety. */
|
|
33
|
+
compareAndSet?(key: string, expectedRevision: number | undefined, account: ProvisionedAccount): Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
export interface BuyerAccountDispatch {
|
|
36
|
+
storageKey: string;
|
|
37
|
+
account: AccountReference;
|
|
38
|
+
idempotencyKey: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BuyerAccountProvisioningDispatch {
|
|
41
|
+
idempotencyKey: string;
|
|
42
|
+
/** Invoke immediately before the transport receives the mutation. */
|
|
43
|
+
beforeDispatch(): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export interface BuyerAccountRegistryOptions {
|
|
46
|
+
/** Awaited before dispatch; rejection prevents the mutation. */
|
|
47
|
+
onDispatchStart?: (dispatch: BuyerAccountDispatch) => Promise<void>;
|
|
48
|
+
/** Awaited for each seller result before account writes. Rejection preserves the claim for caller reconciliation. */
|
|
49
|
+
onResult?: (dispatch: BuyerAccountDispatch & {
|
|
50
|
+
result: TaskResult<unknown>;
|
|
51
|
+
}) => Promise<void>;
|
|
52
|
+
maxEntries?: number;
|
|
53
|
+
normalizeOptions?: (options: EnsureAccountOptions, taskOptions?: TaskOptions) => Promise<EnsureAccountOptions>;
|
|
54
|
+
}
|
|
55
|
+
export declare class BuyerAccountRegistry {
|
|
56
|
+
private scope;
|
|
57
|
+
private provision;
|
|
58
|
+
private storage?;
|
|
59
|
+
private repair?;
|
|
60
|
+
private readonly registryOptions;
|
|
61
|
+
private entries;
|
|
62
|
+
private pending;
|
|
63
|
+
private writes;
|
|
64
|
+
private repairs;
|
|
65
|
+
private repairWaiters;
|
|
66
|
+
private invalidatedHandles;
|
|
67
|
+
private observationEpoch;
|
|
68
|
+
private observationFloor;
|
|
69
|
+
private statusEpochs;
|
|
70
|
+
private readonly maxEntries;
|
|
71
|
+
private readonly normalizeOptions?;
|
|
72
|
+
constructor(scope: () => string, provision: (key: AccountReference, options: EnsureAccountOptions, taskOptions?: TaskOptions, dispatch?: BuyerAccountProvisioningDispatch) => Promise<TaskResult<SyncAccountsResponse>>, storage?: BuyerAccountStorage | undefined, repair?: ((accountId: string, taskOptions?: TaskOptions) => Promise<readonly unknown[]>) | undefined, registryOptions?: BuyerAccountRegistryOptions);
|
|
73
|
+
private key;
|
|
74
|
+
/** Capture before a seller request; observations older than a status repair are ignored. */
|
|
75
|
+
captureObservation(): number;
|
|
76
|
+
private observationIsCurrent;
|
|
77
|
+
private remember;
|
|
78
|
+
get(account: AccountReference): Promise<ProvisionedAccount | undefined>;
|
|
79
|
+
ensure(account: AccountReference, options?: EnsureAccountOptions, taskOptions?: TaskOptions, onTaskResult?: (result: TaskResult<unknown>) => void): Promise<ProvisionedAccount>;
|
|
80
|
+
private write;
|
|
81
|
+
private record;
|
|
82
|
+
private enqueue;
|
|
83
|
+
observeSync(refs: readonly AccountReference[], rows: readonly unknown[], dryRun?: boolean, observationEpoch?: number, expectedRevision?: number): Promise<void>;
|
|
84
|
+
private reconcileId;
|
|
85
|
+
observeList(rows: readonly unknown[], queriedAccountId?: string, observationEpoch?: number): Promise<void>;
|
|
86
|
+
private observeListAtScope;
|
|
87
|
+
/** After verifying account.status_changed, repair aliases by handle from the authoritative seller. */
|
|
88
|
+
applyStatusChange(notification: {
|
|
89
|
+
account_id: string;
|
|
90
|
+
}, options?: TaskOptions): Promise<void>;
|
|
91
|
+
private repairStatus;
|
|
92
|
+
private runRepair;
|
|
93
|
+
}
|