@adcp/sdk 17.0.0-beta.13 → 17.0.0-beta.15
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/brand/index.d.mts +2 -0
- package/dist/lib/brand/index.d.ts +2 -0
- package/dist/lib/brand/index.js +3 -0
- package/dist/lib/brand/index.mjs +2 -0
- package/dist/lib/brand/selection.d.mts +13 -0
- package/dist/lib/brand/selection.d.ts +13 -0
- package/dist/lib/brand/selection.js +83 -0
- package/dist/lib/brand/selection.mjs +59 -0
- package/dist/lib/index.d.mts +2 -2
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +2 -0
- package/dist/lib/registry/types.d.mts +5 -0
- package/dist/lib/registry/types.d.ts +5 -0
- package/dist/lib/registry/types.generated.d.ts +4 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +12 -2
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +12 -2
- package/dist/lib/server/test-controller.d.mts +9 -35
- package/dist/lib/server/test-controller.d.ts +9 -35
- package/dist/lib/server/test-controller.js +4 -0
- package/dist/lib/server/test-controller.mjs +4 -0
- package/dist/lib/testing/comply-controller.d.mts +7 -10
- package/dist/lib/testing/comply-controller.d.ts +7 -10
- package/dist/lib/testing/reporting/doctor.js +2 -1
- package/dist/lib/testing/reporting/doctor.mjs +2 -1
- package/dist/lib/testing/storyboard/account-policy.d.mts +42 -0
- package/dist/lib/testing/storyboard/account-policy.d.ts +42 -0
- package/dist/lib/testing/storyboard/account-policy.js +41 -2
- package/dist/lib/testing/storyboard/account-policy.mjs +38 -1
- package/dist/lib/testing/storyboard/path.d.mts +6 -0
- package/dist/lib/testing/storyboard/path.d.ts +6 -0
- package/dist/lib/testing/storyboard/path.js +22 -0
- package/dist/lib/testing/storyboard/path.mjs +21 -0
- package/dist/lib/testing/storyboard/request-builder.js +1 -1
- package/dist/lib/testing/storyboard/request-builder.mjs +1 -1
- package/dist/lib/testing/storyboard/runner.d.mts +1 -42
- package/dist/lib/testing/storyboard/runner.d.ts +1 -42
- package/dist/lib/testing/storyboard/runner.js +8 -38
- package/dist/lib/testing/storyboard/runner.mjs +5 -35
- package/dist/lib/testing/storyboard/seeding.js +152 -2
- package/dist/lib/testing/storyboard/seeding.mjs +152 -2
- package/dist/lib/testing/storyboard/types.d.mts +4 -2
- package/dist/lib/testing/storyboard/types.d.ts +4 -2
- package/dist/lib/testing/storyboard/types.js +1 -0
- package/dist/lib/testing/storyboard/types.mjs +1 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/validations.js +60 -1
- package/dist/lib/testing/storyboard/validations.mjs +61 -1
- package/dist/lib/v2/projection/creative-delivery.js +62 -16
- package/dist/lib/v2/projection/creative-delivery.mjs +62 -16
- 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/docs/TYPE-SUMMARY.md +1 -1
- package/docs/guides/BRAND-ENTRY-SELECTION.md +56 -0
- package/docs/guides/REPORTING-LEDGER.md +142 -12
- package/docs/guides/REPORTING-OPERATIONS.md +18 -5
- package/docs/guides/VALIDATE-YOUR-AGENT.md +44 -0
- package/docs/llms.txt +1 -1
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-reporting-row-storage-alignment.md +4 -2
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { createHash, createHmac } from "node:crypto";
|
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
7
|
import { basename, join } from "node:path";
|
|
8
8
|
import { isDeepStrictEqual } from "node:util";
|
|
9
|
-
import {
|
|
9
|
+
import { applyBrandInvariant } from "./account-policy.mjs";
|
|
10
10
|
import { prepareCreativeBuildProbe } from "./creative-build-probe.mjs";
|
|
11
11
|
import {
|
|
12
12
|
createTestClient,
|
|
@@ -1191,6 +1191,7 @@ function buildPhaseCapabilitySkippedSteps(storyboard, phase, detail, context) {
|
|
|
1191
1191
|
const REQUIREMENT_TO_SKIP_REASON = {
|
|
1192
1192
|
controller: "missing_test_controller",
|
|
1193
1193
|
collect_product_pages_runner: "requirement_unmet",
|
|
1194
|
+
field_excludes_runner: "requirement_unmet",
|
|
1194
1195
|
seeded_state: "requirement_unmet",
|
|
1195
1196
|
real_wire: "requirement_unmet",
|
|
1196
1197
|
webhook_receiver: "requirement_unmet",
|
|
@@ -1324,6 +1325,7 @@ async function checkRequires(requires, storyboard, options, profile, precomputed
|
|
|
1324
1325
|
continue;
|
|
1325
1326
|
}
|
|
1326
1327
|
switch (requirement) {
|
|
1328
|
+
case "field_excludes_runner":
|
|
1327
1329
|
case "collect_product_pages_runner":
|
|
1328
1330
|
break;
|
|
1329
1331
|
case "controller": {
|
|
@@ -8273,39 +8275,7 @@ function evalContributesIf(expr, priorStepResults) {
|
|
|
8273
8275
|
const prior = priorStepResults.get(stepId);
|
|
8274
8276
|
return !!prior?.passed && !prior.skipped;
|
|
8275
8277
|
}
|
|
8276
|
-
|
|
8277
|
-
function applyBrandInvariant(request, options, taskName, stepFlags) {
|
|
8278
|
-
if (!options.brand && !options.brand_manifest) return request;
|
|
8279
|
-
if (taskName !== void 0 && BRAND_SUBJECT_TASKS.has(taskName)) return request;
|
|
8280
|
-
const brand = resolveBrand(options);
|
|
8281
|
-
const topBrandOk = !taskName || schemaAllowsTopLevelField(taskName, "brand");
|
|
8282
|
-
const topAccountOk = !taskName || schemaAllowsTopLevelField(taskName, "account");
|
|
8283
|
-
const result = { ...request };
|
|
8284
|
-
if (topBrandOk) result.brand = brand;
|
|
8285
|
-
if (stepFlags?.omit_account) return result;
|
|
8286
|
-
if ("account" in request) {
|
|
8287
|
-
const existingAccount = request.account;
|
|
8288
|
-
if (existingAccount && typeof existingAccount === "object" && !Array.isArray(existingAccount)) {
|
|
8289
|
-
const acct = existingAccount;
|
|
8290
|
-
const isNaturalKeyVariant = "brand" in acct || "operator" in acct;
|
|
8291
|
-
if (isNaturalKeyVariant) {
|
|
8292
|
-
const preserveWholesaleAccountBrand = (taskName === "get_products" && request.buying_mode === "wholesale" || taskName === "get_signals" && request.discovery_mode === "wholesale") && acct.brand !== void 0;
|
|
8293
|
-
const merged = {
|
|
8294
|
-
...acct,
|
|
8295
|
-
brand: preserveWholesaleAccountBrand ? acct.brand : brand
|
|
8296
|
-
};
|
|
8297
|
-
const accountBrand = merged.brand;
|
|
8298
|
-
if (typeof merged.operator !== "string" && typeof accountBrand?.domain === "string") {
|
|
8299
|
-
merged.operator = accountBrand.domain;
|
|
8300
|
-
}
|
|
8301
|
-
result.account = merged;
|
|
8302
|
-
}
|
|
8303
|
-
}
|
|
8304
|
-
} else if (topAccountOk && taskName !== "list_accounts" && !ACCOUNT_FREE_DISCOVERY_TASKS.has(taskName ?? "")) {
|
|
8305
|
-
result.account = resolveAccount(options);
|
|
8306
|
-
}
|
|
8307
|
-
return result;
|
|
8308
|
-
}
|
|
8278
|
+
import { applyBrandInvariant as applyBrandInvariant2, BRAND_SUBJECT_TASKS } from "./account-policy.mjs";
|
|
8309
8279
|
function applyDisableSandboxHint(request, taskName) {
|
|
8310
8280
|
if (taskName && !schemaAllowsTopLevelField(taskName, "ext")) return request;
|
|
8311
8281
|
const existingExt = request.ext;
|
|
@@ -8664,7 +8634,7 @@ export {
|
|
|
8664
8634
|
__selectProtectedToolTargetForTest,
|
|
8665
8635
|
__sessionControlCredentialsForTest,
|
|
8666
8636
|
applyAdcpVersionRunOptions,
|
|
8667
|
-
applyBrandInvariant,
|
|
8637
|
+
applyBrandInvariant2 as applyBrandInvariant,
|
|
8668
8638
|
applyDisableSandboxHint,
|
|
8669
8639
|
applyFixtureBindingsSafely,
|
|
8670
8640
|
applyIdempotencyInvariant,
|
|
@@ -36,9 +36,147 @@ var import_rawResponseCapture = require('../../protocols/rawResponseCapture.js')
|
|
|
36
36
|
var import_fixture_resolution = require('./fixture-resolution.js');
|
|
37
37
|
var import_collection_selection = require('./collection-selection.js');
|
|
38
38
|
var import_path = require('./path.js');
|
|
39
|
+
var import_context = require('./context.js');
|
|
40
|
+
var import_account_policy = require('./account-policy.js');
|
|
39
41
|
var import_redact_secrets = require('../../utils/redact-secrets.js');
|
|
42
|
+
var import_jcs = require('../../utils/jcs.js');
|
|
40
43
|
var import_discovery_evidence = require('../discovery-evidence.js');
|
|
41
44
|
var import_redact_credential_patterns = require('../../utils/redact-credential-patterns.js');
|
|
45
|
+
function storyboardSeedScope(storyboard, context, options, call) {
|
|
46
|
+
if (call.scenario !== "seed_product" && call.scenario !== "seed_pricing_option") return {};
|
|
47
|
+
if (context.account !== void 0) {
|
|
48
|
+
if (!isPlainRecord(context.account) || /\$(?:context\.|generate:)/.test(JSON.stringify(context.account))) {
|
|
49
|
+
throw new Error("Automatic fixture seeding needs a resolved context.account reference");
|
|
50
|
+
}
|
|
51
|
+
if (context.account.sandbox === false) throw new Error("Automatic fixture seeding requires a sandbox account");
|
|
52
|
+
if (typeof context.account.account_id !== "string" && (options.brand || options.brand_manifest) && (0, import_jcs.canonicalize)(context.account.brand) !== (0, import_jcs.canonicalize)((0, import_client.resolveBrand)(options))) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"Explicit fixture context.account conflicts with the run-scoped brand; choose one account identity"
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
account: { ...context.account, sandbox: true }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const provisioningAliases = /* @__PURE__ */ new Map();
|
|
62
|
+
const provisioningAccounts = [];
|
|
63
|
+
for (const phase of storyboard.phases)
|
|
64
|
+
for (const step of phase.steps) {
|
|
65
|
+
if (step.task !== "sync_accounts" || step.expect_error) continue;
|
|
66
|
+
const request = (0, import_context.injectContext)(step.sample_request ?? {}, context);
|
|
67
|
+
if (!Array.isArray(request.accounts) || request.accounts.length !== 1) continue;
|
|
68
|
+
const row = request.accounts[0];
|
|
69
|
+
if (!isPlainRecord(row) || !isPlainRecord(row.brand) || typeof row.operator !== "string") continue;
|
|
70
|
+
const { brand, operator, operator_unit, currency, timezone, sandbox } = row;
|
|
71
|
+
const account = {
|
|
72
|
+
brand,
|
|
73
|
+
operator,
|
|
74
|
+
...operator_unit !== void 0 && { operator_unit },
|
|
75
|
+
...currency !== void 0 && { currency },
|
|
76
|
+
...timezone !== void 0 && { timezone },
|
|
77
|
+
...sandbox !== void 0 && { sandbox }
|
|
78
|
+
};
|
|
79
|
+
provisioningAccounts.push(account);
|
|
80
|
+
for (const output of step.context_outputs ?? []) {
|
|
81
|
+
if (output.path === "accounts[0].account_id" && output.key) provisioningAliases.set(output.key, account);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const accounts = /* @__PURE__ */ new Map();
|
|
85
|
+
const resolvedScopes = /* @__PURE__ */ new Set();
|
|
86
|
+
const deferredScopes = /* @__PURE__ */ new Set();
|
|
87
|
+
const seedScopeSteps = [
|
|
88
|
+
...storyboard.phases.flatMap((phase) => phase.steps),
|
|
89
|
+
...provisioningAccounts.map((account, index) => ({
|
|
90
|
+
id: `seed-scope-${index}`,
|
|
91
|
+
title: "Seed scope from account provisioning",
|
|
92
|
+
task: "sync_accounts",
|
|
93
|
+
sample_request: { account }
|
|
94
|
+
}))
|
|
95
|
+
];
|
|
96
|
+
for (const step of seedScopeSteps) {
|
|
97
|
+
if (step.expect_error || step.omit_account) continue;
|
|
98
|
+
const source = options.request ?? step.sample_request ?? {};
|
|
99
|
+
if (JSON.stringify(source.account ?? {}).includes("$generate:")) {
|
|
100
|
+
throw new Error("Automatic fixture seeding needs an explicit resolved account for generated identities");
|
|
101
|
+
}
|
|
102
|
+
let request = (0, import_context.injectContext)(
|
|
103
|
+
{
|
|
104
|
+
...source.account !== void 0 && { account: source.account },
|
|
105
|
+
buying_mode: source.buying_mode,
|
|
106
|
+
discovery_mode: source.discovery_mode
|
|
107
|
+
},
|
|
108
|
+
context
|
|
109
|
+
);
|
|
110
|
+
if (step.context_inputs?.length) request = (0, import_context.applyContextInputs)(request, step.context_inputs, context);
|
|
111
|
+
request = (0, import_account_policy.applyBrandInvariant)(request, options, step.task, { omit_account: step.omit_account });
|
|
112
|
+
if (request.account === void 0) continue;
|
|
113
|
+
if (JSON.stringify(request.account).includes("$generate:")) {
|
|
114
|
+
throw new Error("Automatic fixture seeding needs an explicit resolved account for generated identities");
|
|
115
|
+
}
|
|
116
|
+
let injected = request.account;
|
|
117
|
+
if (isPlainRecord(injected) && typeof injected.account_id === "string") {
|
|
118
|
+
const capture = /^\$context\.(\w+)$/.exec(injected.account_id)?.[1];
|
|
119
|
+
if (capture && provisioningAliases.has(capture)) injected = provisioningAliases.get(capture);
|
|
120
|
+
}
|
|
121
|
+
if (!isPlainRecord(injected)) throw new Error("Automatic fixture seeding needs a resolved account reference");
|
|
122
|
+
const account = { ...injected };
|
|
123
|
+
let deferred = false;
|
|
124
|
+
for (const key2 of ["currency", "timezone"]) {
|
|
125
|
+
if (typeof account[key2] === "string" && /^\$context\./.test(account[key2])) {
|
|
126
|
+
delete account[key2];
|
|
127
|
+
deferred = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (JSON.stringify(account).includes("$context.")) {
|
|
131
|
+
throw new Error("Automatic fixture seeding needs a resolved account reference");
|
|
132
|
+
}
|
|
133
|
+
const hasIdentity = typeof account.account_id === "string" && account.account_id.length > 0 || isPlainRecord(account.brand) && typeof account.brand.domain === "string" && account.brand.domain.length > 0 && typeof account.operator === "string" && account.operator.length > 0;
|
|
134
|
+
if (!hasIdentity) continue;
|
|
135
|
+
if (account.sandbox === false) throw new Error("Automatic fixture seeding requires a sandbox account");
|
|
136
|
+
const sandboxAccount = { ...account, sandbox: true };
|
|
137
|
+
const { currency: _currency, timezone: _timezone, ...identity } = sandboxAccount;
|
|
138
|
+
const key = (0, import_jcs.canonicalize)(identity);
|
|
139
|
+
(deferred ? deferredScopes : resolvedScopes).add(key);
|
|
140
|
+
const prior = accounts.get(key);
|
|
141
|
+
if (prior) {
|
|
142
|
+
for (const dimension of ["currency", "timezone"]) {
|
|
143
|
+
if (prior[dimension] !== void 0 && sandboxAccount[dimension] !== void 0 && prior[dimension] !== sandboxAccount[dimension]) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"Automatic fixture seeding needs an explicit context.account when a storyboard uses multiple accounts"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
accounts.set(key, { ...prior, ...sandboxAccount });
|
|
151
|
+
}
|
|
152
|
+
if ([...deferredScopes].some((key) => !resolvedScopes.has(key))) {
|
|
153
|
+
throw new Error("Automatic fixture seeding needs a resolved account reference before later account enrichment");
|
|
154
|
+
}
|
|
155
|
+
if (accounts.size === 1) return { account: [...accounts.values()][0] };
|
|
156
|
+
if (accounts.size > 1) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
"Automatic fixture seeding needs an explicit context.account when a storyboard uses multiple accounts"
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const sandboxAccounts = (storyboard.fixtures?.accounts ?? []).flatMap((entry) => {
|
|
162
|
+
const fixture = isPlainRecord(entry.fixture) ? entry.fixture : entry;
|
|
163
|
+
if (fixture.sandbox !== true || !isPlainRecord(fixture.brand) || typeof fixture.operator !== "string") return [];
|
|
164
|
+
const { brand, operator, operator_unit, currency, timezone } = fixture;
|
|
165
|
+
return [
|
|
166
|
+
{
|
|
167
|
+
brand,
|
|
168
|
+
operator,
|
|
169
|
+
...operator_unit !== void 0 && { operator_unit },
|
|
170
|
+
...currency !== void 0 && { currency },
|
|
171
|
+
...timezone !== void 0 && { timezone },
|
|
172
|
+
sandbox: true
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
});
|
|
176
|
+
if (sandboxAccounts.length === 1) return { account: sandboxAccounts[0] };
|
|
177
|
+
if (sandboxAccounts.length > 1) throw new Error("Automatic fixture seeding needs an explicit context.account");
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
42
180
|
const CONTROLLER_SEEDING_PHASE_ID = "__controller_seeding__";
|
|
43
181
|
function buildSeedCalls(fixtures) {
|
|
44
182
|
if (!fixtures) return [];
|
|
@@ -267,7 +405,12 @@ async function runControllerSeeding(client, storyboard, options, context, discov
|
|
|
267
405
|
try {
|
|
268
406
|
const raw = await (0, import_test_controller.callControllerRaw)(
|
|
269
407
|
client,
|
|
270
|
-
{
|
|
408
|
+
{
|
|
409
|
+
...storyboardSeedScope(storyboard, context, options, call),
|
|
410
|
+
scenario: call.scenario,
|
|
411
|
+
params: call.params,
|
|
412
|
+
context: seedContext
|
|
413
|
+
},
|
|
271
414
|
options
|
|
272
415
|
);
|
|
273
416
|
const data = raw.data;
|
|
@@ -560,6 +703,7 @@ async function runDeclaredFixtureResolution(seedClient, discoveryClient, storybo
|
|
|
560
703
|
const raw = await (0, import_test_controller.callControllerRaw)(
|
|
561
704
|
seedClient,
|
|
562
705
|
{
|
|
706
|
+
...storyboardSeedScope(storyboard, context, seedOptions, call),
|
|
563
707
|
scenario: call.scenario,
|
|
564
708
|
params: isPlainRecord(controllerRequest.params) ? controllerRequest.params : call.params,
|
|
565
709
|
context: seedContext
|
|
@@ -590,6 +734,7 @@ async function runDeclaredFixtureResolution(seedClient, discoveryClient, storybo
|
|
|
590
734
|
// `call.params` when the bound params are not a plain
|
|
591
735
|
// record, and adds the seeding correlation context.
|
|
592
736
|
payload: (0, import_redact_secrets.redactSecrets)({
|
|
737
|
+
...storyboardSeedScope(storyboard, context, seedOptions, call),
|
|
593
738
|
scenario: call.scenario,
|
|
594
739
|
params: isPlainRecord(controllerRequest.params) ? controllerRequest.params : call.params,
|
|
595
740
|
context: seedContext
|
|
@@ -956,7 +1101,12 @@ async function executeLegacySeedCall(client, storyboard, call, options, context,
|
|
|
956
1101
|
try {
|
|
957
1102
|
const raw = await (0, import_test_controller.callControllerRaw)(
|
|
958
1103
|
client,
|
|
959
|
-
{
|
|
1104
|
+
{
|
|
1105
|
+
...storyboardSeedScope(storyboard, context, options, call),
|
|
1106
|
+
scenario: call.scenario,
|
|
1107
|
+
params: call.params,
|
|
1108
|
+
context: seedContext
|
|
1109
|
+
},
|
|
960
1110
|
options
|
|
961
1111
|
);
|
|
962
1112
|
const data = raw.data;
|
|
@@ -16,9 +16,147 @@ import {
|
|
|
16
16
|
} from "./fixture-resolution.mjs";
|
|
17
17
|
import { readCollectionWitness } from "./collection-selection.mjs";
|
|
18
18
|
import { resolvePath } from "./path.mjs";
|
|
19
|
+
import { injectContext, applyContextInputs } from "./context.mjs";
|
|
20
|
+
import { applyBrandInvariant } from "./account-policy.mjs";
|
|
19
21
|
import { redactSecrets } from "../../utils/redact-secrets.mjs";
|
|
22
|
+
import { canonicalize } from "../../utils/jcs.mjs";
|
|
20
23
|
import { redactDiscoveryEvidence as redactDiscoveryResponse } from "../discovery-evidence.mjs";
|
|
21
24
|
import { redactCredentialPatterns } from "../../utils/redact-credential-patterns.mjs";
|
|
25
|
+
function storyboardSeedScope(storyboard, context, options, call) {
|
|
26
|
+
if (call.scenario !== "seed_product" && call.scenario !== "seed_pricing_option") return {};
|
|
27
|
+
if (context.account !== void 0) {
|
|
28
|
+
if (!isPlainRecord(context.account) || /\$(?:context\.|generate:)/.test(JSON.stringify(context.account))) {
|
|
29
|
+
throw new Error("Automatic fixture seeding needs a resolved context.account reference");
|
|
30
|
+
}
|
|
31
|
+
if (context.account.sandbox === false) throw new Error("Automatic fixture seeding requires a sandbox account");
|
|
32
|
+
if (typeof context.account.account_id !== "string" && (options.brand || options.brand_manifest) && canonicalize(context.account.brand) !== canonicalize(resolveBrand(options))) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
"Explicit fixture context.account conflicts with the run-scoped brand; choose one account identity"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
account: { ...context.account, sandbox: true }
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const provisioningAliases = /* @__PURE__ */ new Map();
|
|
42
|
+
const provisioningAccounts = [];
|
|
43
|
+
for (const phase of storyboard.phases)
|
|
44
|
+
for (const step of phase.steps) {
|
|
45
|
+
if (step.task !== "sync_accounts" || step.expect_error) continue;
|
|
46
|
+
const request = injectContext(step.sample_request ?? {}, context);
|
|
47
|
+
if (!Array.isArray(request.accounts) || request.accounts.length !== 1) continue;
|
|
48
|
+
const row = request.accounts[0];
|
|
49
|
+
if (!isPlainRecord(row) || !isPlainRecord(row.brand) || typeof row.operator !== "string") continue;
|
|
50
|
+
const { brand, operator, operator_unit, currency, timezone, sandbox } = row;
|
|
51
|
+
const account = {
|
|
52
|
+
brand,
|
|
53
|
+
operator,
|
|
54
|
+
...operator_unit !== void 0 && { operator_unit },
|
|
55
|
+
...currency !== void 0 && { currency },
|
|
56
|
+
...timezone !== void 0 && { timezone },
|
|
57
|
+
...sandbox !== void 0 && { sandbox }
|
|
58
|
+
};
|
|
59
|
+
provisioningAccounts.push(account);
|
|
60
|
+
for (const output of step.context_outputs ?? []) {
|
|
61
|
+
if (output.path === "accounts[0].account_id" && output.key) provisioningAliases.set(output.key, account);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const accounts = /* @__PURE__ */ new Map();
|
|
65
|
+
const resolvedScopes = /* @__PURE__ */ new Set();
|
|
66
|
+
const deferredScopes = /* @__PURE__ */ new Set();
|
|
67
|
+
const seedScopeSteps = [
|
|
68
|
+
...storyboard.phases.flatMap((phase) => phase.steps),
|
|
69
|
+
...provisioningAccounts.map((account, index) => ({
|
|
70
|
+
id: `seed-scope-${index}`,
|
|
71
|
+
title: "Seed scope from account provisioning",
|
|
72
|
+
task: "sync_accounts",
|
|
73
|
+
sample_request: { account }
|
|
74
|
+
}))
|
|
75
|
+
];
|
|
76
|
+
for (const step of seedScopeSteps) {
|
|
77
|
+
if (step.expect_error || step.omit_account) continue;
|
|
78
|
+
const source = options.request ?? step.sample_request ?? {};
|
|
79
|
+
if (JSON.stringify(source.account ?? {}).includes("$generate:")) {
|
|
80
|
+
throw new Error("Automatic fixture seeding needs an explicit resolved account for generated identities");
|
|
81
|
+
}
|
|
82
|
+
let request = injectContext(
|
|
83
|
+
{
|
|
84
|
+
...source.account !== void 0 && { account: source.account },
|
|
85
|
+
buying_mode: source.buying_mode,
|
|
86
|
+
discovery_mode: source.discovery_mode
|
|
87
|
+
},
|
|
88
|
+
context
|
|
89
|
+
);
|
|
90
|
+
if (step.context_inputs?.length) request = applyContextInputs(request, step.context_inputs, context);
|
|
91
|
+
request = applyBrandInvariant(request, options, step.task, { omit_account: step.omit_account });
|
|
92
|
+
if (request.account === void 0) continue;
|
|
93
|
+
if (JSON.stringify(request.account).includes("$generate:")) {
|
|
94
|
+
throw new Error("Automatic fixture seeding needs an explicit resolved account for generated identities");
|
|
95
|
+
}
|
|
96
|
+
let injected = request.account;
|
|
97
|
+
if (isPlainRecord(injected) && typeof injected.account_id === "string") {
|
|
98
|
+
const capture = /^\$context\.(\w+)$/.exec(injected.account_id)?.[1];
|
|
99
|
+
if (capture && provisioningAliases.has(capture)) injected = provisioningAliases.get(capture);
|
|
100
|
+
}
|
|
101
|
+
if (!isPlainRecord(injected)) throw new Error("Automatic fixture seeding needs a resolved account reference");
|
|
102
|
+
const account = { ...injected };
|
|
103
|
+
let deferred = false;
|
|
104
|
+
for (const key2 of ["currency", "timezone"]) {
|
|
105
|
+
if (typeof account[key2] === "string" && /^\$context\./.test(account[key2])) {
|
|
106
|
+
delete account[key2];
|
|
107
|
+
deferred = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (JSON.stringify(account).includes("$context.")) {
|
|
111
|
+
throw new Error("Automatic fixture seeding needs a resolved account reference");
|
|
112
|
+
}
|
|
113
|
+
const hasIdentity = typeof account.account_id === "string" && account.account_id.length > 0 || isPlainRecord(account.brand) && typeof account.brand.domain === "string" && account.brand.domain.length > 0 && typeof account.operator === "string" && account.operator.length > 0;
|
|
114
|
+
if (!hasIdentity) continue;
|
|
115
|
+
if (account.sandbox === false) throw new Error("Automatic fixture seeding requires a sandbox account");
|
|
116
|
+
const sandboxAccount = { ...account, sandbox: true };
|
|
117
|
+
const { currency: _currency, timezone: _timezone, ...identity } = sandboxAccount;
|
|
118
|
+
const key = canonicalize(identity);
|
|
119
|
+
(deferred ? deferredScopes : resolvedScopes).add(key);
|
|
120
|
+
const prior = accounts.get(key);
|
|
121
|
+
if (prior) {
|
|
122
|
+
for (const dimension of ["currency", "timezone"]) {
|
|
123
|
+
if (prior[dimension] !== void 0 && sandboxAccount[dimension] !== void 0 && prior[dimension] !== sandboxAccount[dimension]) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
"Automatic fixture seeding needs an explicit context.account when a storyboard uses multiple accounts"
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
accounts.set(key, { ...prior, ...sandboxAccount });
|
|
131
|
+
}
|
|
132
|
+
if ([...deferredScopes].some((key) => !resolvedScopes.has(key))) {
|
|
133
|
+
throw new Error("Automatic fixture seeding needs a resolved account reference before later account enrichment");
|
|
134
|
+
}
|
|
135
|
+
if (accounts.size === 1) return { account: [...accounts.values()][0] };
|
|
136
|
+
if (accounts.size > 1) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
"Automatic fixture seeding needs an explicit context.account when a storyboard uses multiple accounts"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
const sandboxAccounts = (storyboard.fixtures?.accounts ?? []).flatMap((entry) => {
|
|
142
|
+
const fixture = isPlainRecord(entry.fixture) ? entry.fixture : entry;
|
|
143
|
+
if (fixture.sandbox !== true || !isPlainRecord(fixture.brand) || typeof fixture.operator !== "string") return [];
|
|
144
|
+
const { brand, operator, operator_unit, currency, timezone } = fixture;
|
|
145
|
+
return [
|
|
146
|
+
{
|
|
147
|
+
brand,
|
|
148
|
+
operator,
|
|
149
|
+
...operator_unit !== void 0 && { operator_unit },
|
|
150
|
+
...currency !== void 0 && { currency },
|
|
151
|
+
...timezone !== void 0 && { timezone },
|
|
152
|
+
sandbox: true
|
|
153
|
+
}
|
|
154
|
+
];
|
|
155
|
+
});
|
|
156
|
+
if (sandboxAccounts.length === 1) return { account: sandboxAccounts[0] };
|
|
157
|
+
if (sandboxAccounts.length > 1) throw new Error("Automatic fixture seeding needs an explicit context.account");
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
22
160
|
const CONTROLLER_SEEDING_PHASE_ID = "__controller_seeding__";
|
|
23
161
|
function buildSeedCalls(fixtures) {
|
|
24
162
|
if (!fixtures) return [];
|
|
@@ -247,7 +385,12 @@ async function runControllerSeeding(client, storyboard, options, context, discov
|
|
|
247
385
|
try {
|
|
248
386
|
const raw = await callControllerRaw(
|
|
249
387
|
client,
|
|
250
|
-
{
|
|
388
|
+
{
|
|
389
|
+
...storyboardSeedScope(storyboard, context, options, call),
|
|
390
|
+
scenario: call.scenario,
|
|
391
|
+
params: call.params,
|
|
392
|
+
context: seedContext
|
|
393
|
+
},
|
|
251
394
|
options
|
|
252
395
|
);
|
|
253
396
|
const data = raw.data;
|
|
@@ -540,6 +683,7 @@ async function runDeclaredFixtureResolution(seedClient, discoveryClient, storybo
|
|
|
540
683
|
const raw = await callControllerRaw(
|
|
541
684
|
seedClient,
|
|
542
685
|
{
|
|
686
|
+
...storyboardSeedScope(storyboard, context, seedOptions, call),
|
|
543
687
|
scenario: call.scenario,
|
|
544
688
|
params: isPlainRecord(controllerRequest.params) ? controllerRequest.params : call.params,
|
|
545
689
|
context: seedContext
|
|
@@ -570,6 +714,7 @@ async function runDeclaredFixtureResolution(seedClient, discoveryClient, storybo
|
|
|
570
714
|
// `call.params` when the bound params are not a plain
|
|
571
715
|
// record, and adds the seeding correlation context.
|
|
572
716
|
payload: redactSecrets({
|
|
717
|
+
...storyboardSeedScope(storyboard, context, seedOptions, call),
|
|
573
718
|
scenario: call.scenario,
|
|
574
719
|
params: isPlainRecord(controllerRequest.params) ? controllerRequest.params : call.params,
|
|
575
720
|
context: seedContext
|
|
@@ -936,7 +1081,12 @@ async function executeLegacySeedCall(client, storyboard, call, options, context,
|
|
|
936
1081
|
try {
|
|
937
1082
|
const raw = await callControllerRaw(
|
|
938
1083
|
client,
|
|
939
|
-
{
|
|
1084
|
+
{
|
|
1085
|
+
...storyboardSeedScope(storyboard, context, options, call),
|
|
1086
|
+
scenario: call.scenario,
|
|
1087
|
+
params: call.params,
|
|
1088
|
+
context: seedContext
|
|
1089
|
+
},
|
|
940
1090
|
options
|
|
941
1091
|
);
|
|
942
1092
|
const data = raw.data;
|
|
@@ -90,6 +90,8 @@ export interface Storyboard {
|
|
|
90
90
|
* not actually present.
|
|
91
91
|
* - `collect_product_pages_runner` — intrinsic support for explicit wholesale
|
|
92
92
|
* all-page steps; unavailable on older runners that ignore this metadata.
|
|
93
|
+
* - `field_excludes_runner` — intrinsic full-response negative membership support;
|
|
94
|
+
* older runners skip before seeding instead of ignoring an unknown check.
|
|
93
95
|
* - `real_wire` — always available. Tag scenarios that observe
|
|
94
96
|
* production behavior with this when you want them excluded from
|
|
95
97
|
* a future `--mock-only` mode; today the tag is a no-op gate.
|
|
@@ -1017,7 +1019,7 @@ export type StoryboardValidationCheck = 'response_schema' | 'field_present'
|
|
|
1017
1019
|
* envelope fields such as `adcp_major_version` should use
|
|
1018
1020
|
* `envelope_field_value`.
|
|
1019
1021
|
*/
|
|
1020
|
-
| 'envelope_field_pattern' | 'field_contains' | 'status_code' | 'error_code' | 'http_status' | 'http_status_in' | 'on_401_require_header'
|
|
1022
|
+
| 'envelope_field_pattern' | 'field_contains' | 'field_excludes' | 'status_code' | 'error_code' | 'http_status' | 'http_status_in' | 'on_401_require_header'
|
|
1021
1023
|
/**
|
|
1022
1024
|
* Assert that the step's probe reported no grading error, without asserting
|
|
1023
1025
|
* anything about an HTTP exchange. For probes whose verdict is decided
|
|
@@ -2415,7 +2417,7 @@ export interface RunnerSelectionResult {
|
|
|
2415
2417
|
*
|
|
2416
2418
|
* Spec: adcp-client#1626, adcp-client#2281, adcp-client#2356.
|
|
2417
2419
|
*/
|
|
2418
|
-
export type RequirementName = 'controller' | 'collect_product_pages_runner' | 'seeded_state' | 'real_wire' | 'webhook_receiver' | 'webhook_replay_receiver' | 'trusted_match_context_router_runner' | 'trusted_match_publisher_auth_runner' | 'property_list_reference_runner' | 'request_signer' | 'multi_agent';
|
|
2420
|
+
export type RequirementName = 'controller' | 'collect_product_pages_runner' | 'field_excludes_runner' | 'seeded_state' | 'real_wire' | 'webhook_receiver' | 'webhook_replay_receiver' | 'trusted_match_context_router_runner' | 'trusted_match_publisher_auth_runner' | 'property_list_reference_runner' | 'request_signer' | 'multi_agent';
|
|
2419
2421
|
/**
|
|
2420
2422
|
* Enumeration of every requirement this SDK knows how to satisfy. The loader
|
|
2421
2423
|
* accepts other non-empty strings for forward compatibility; the runner treats
|
|
@@ -90,6 +90,8 @@ export interface Storyboard {
|
|
|
90
90
|
* not actually present.
|
|
91
91
|
* - `collect_product_pages_runner` — intrinsic support for explicit wholesale
|
|
92
92
|
* all-page steps; unavailable on older runners that ignore this metadata.
|
|
93
|
+
* - `field_excludes_runner` — intrinsic full-response negative membership support;
|
|
94
|
+
* older runners skip before seeding instead of ignoring an unknown check.
|
|
93
95
|
* - `real_wire` — always available. Tag scenarios that observe
|
|
94
96
|
* production behavior with this when you want them excluded from
|
|
95
97
|
* a future `--mock-only` mode; today the tag is a no-op gate.
|
|
@@ -1017,7 +1019,7 @@ export type StoryboardValidationCheck = 'response_schema' | 'field_present'
|
|
|
1017
1019
|
* envelope fields such as `adcp_major_version` should use
|
|
1018
1020
|
* `envelope_field_value`.
|
|
1019
1021
|
*/
|
|
1020
|
-
| 'envelope_field_pattern' | 'field_contains' | 'status_code' | 'error_code' | 'http_status' | 'http_status_in' | 'on_401_require_header'
|
|
1022
|
+
| 'envelope_field_pattern' | 'field_contains' | 'field_excludes' | 'status_code' | 'error_code' | 'http_status' | 'http_status_in' | 'on_401_require_header'
|
|
1021
1023
|
/**
|
|
1022
1024
|
* Assert that the step's probe reported no grading error, without asserting
|
|
1023
1025
|
* anything about an HTTP exchange. For probes whose verdict is decided
|
|
@@ -2415,7 +2417,7 @@ export interface RunnerSelectionResult {
|
|
|
2415
2417
|
*
|
|
2416
2418
|
* Spec: adcp-client#1626, adcp-client#2281, adcp-client#2356.
|
|
2417
2419
|
*/
|
|
2418
|
-
export type RequirementName = 'controller' | 'collect_product_pages_runner' | 'seeded_state' | 'real_wire' | 'webhook_receiver' | 'webhook_replay_receiver' | 'trusted_match_context_router_runner' | 'trusted_match_publisher_auth_runner' | 'property_list_reference_runner' | 'request_signer' | 'multi_agent';
|
|
2420
|
+
export type RequirementName = 'controller' | 'collect_product_pages_runner' | 'field_excludes_runner' | 'seeded_state' | 'real_wire' | 'webhook_receiver' | 'webhook_replay_receiver' | 'trusted_match_context_router_runner' | 'trusted_match_publisher_auth_runner' | 'property_list_reference_runner' | 'request_signer' | 'multi_agent';
|
|
2419
2421
|
/**
|
|
2420
2422
|
* Enumeration of every requirement this SDK knows how to satisfy. The loader
|
|
2421
2423
|
* accepts other non-empty strings for forward compatibility; the runner treats
|
|
@@ -200,7 +200,7 @@ export interface UpstreamTrafficQueryResult {
|
|
|
200
200
|
*/
|
|
201
201
|
export declare function runValidations(validations: StoryboardValidation[], context: ValidationContext): ValidationResult[];
|
|
202
202
|
/** Capability semver emitted in run summaries and used for advisory expiry. */
|
|
203
|
-
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.
|
|
203
|
+
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.15";
|
|
204
204
|
/** True when a failed validation contributes to the owning step's grade. */
|
|
205
205
|
export declare function validationFailsStep(result: ValidationResult): boolean;
|
|
206
206
|
/**
|
|
@@ -200,7 +200,7 @@ export interface UpstreamTrafficQueryResult {
|
|
|
200
200
|
*/
|
|
201
201
|
export declare function runValidations(validations: StoryboardValidation[], context: ValidationContext): ValidationResult[];
|
|
202
202
|
/** Capability semver emitted in run summaries and used for advisory expiry. */
|
|
203
|
-
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.
|
|
203
|
+
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.15";
|
|
204
204
|
/** True when a failed validation contributes to the owning step's grade. */
|
|
205
205
|
export declare function validationFailsStep(result: ValidationResult): boolean;
|
|
206
206
|
/**
|
|
@@ -108,6 +108,7 @@ function runValidation(validation, ctx) {
|
|
|
108
108
|
return validateFieldValueOrAbsent(validation, resolveTarget(ctx));
|
|
109
109
|
case "field_pattern":
|
|
110
110
|
return validateFieldPattern(validation, resolveTarget(ctx));
|
|
111
|
+
case "field_excludes":
|
|
111
112
|
case "field_contains":
|
|
112
113
|
return validateFieldContains(validation, resolveTarget(ctx));
|
|
113
114
|
case "status_code":
|
|
@@ -970,7 +971,7 @@ function validateFieldPattern(validation, taskResult) {
|
|
|
970
971
|
}
|
|
971
972
|
function validateFieldContains(validation, taskResult) {
|
|
972
973
|
const checkName = validation.check;
|
|
973
|
-
if (!validation.path) {
|
|
974
|
+
if (typeof validation.path !== "string" || !validation.path) {
|
|
974
975
|
return {
|
|
975
976
|
check: checkName,
|
|
976
977
|
passed: false,
|
|
@@ -982,6 +983,18 @@ function validateFieldContains(validation, taskResult) {
|
|
|
982
983
|
actual: null
|
|
983
984
|
};
|
|
984
985
|
}
|
|
986
|
+
if (validation.allowed_values !== void 0 && !Array.isArray(validation.allowed_values)) {
|
|
987
|
+
return {
|
|
988
|
+
check: checkName,
|
|
989
|
+
passed: false,
|
|
990
|
+
description: validation.description,
|
|
991
|
+
path: validation.path,
|
|
992
|
+
json_pointer: (0, import_path.toJsonPointer)(validation.path),
|
|
993
|
+
error: `${checkName} allowed_values must be an array`,
|
|
994
|
+
expected: "an array of values",
|
|
995
|
+
actual: validation.allowed_values
|
|
996
|
+
};
|
|
997
|
+
}
|
|
985
998
|
if (validation.value === void 0 && !validation.allowed_values?.length) {
|
|
986
999
|
return {
|
|
987
1000
|
check: checkName,
|
|
@@ -994,6 +1007,9 @@ function validateFieldContains(validation, taskResult) {
|
|
|
994
1007
|
actual: null
|
|
995
1008
|
};
|
|
996
1009
|
}
|
|
1010
|
+
if (checkName === "field_excludes") {
|
|
1011
|
+
return validateFieldExcludes(validation, taskResult);
|
|
1012
|
+
}
|
|
997
1013
|
const resolved = (0, import_path.resolvePathAll)(taskResult.data, validation.path);
|
|
998
1014
|
const pointer = (0, import_path.toJsonPointer)(validation.path);
|
|
999
1015
|
const candidates = validation.allowed_values?.length ? validation.allowed_values : [validation.value];
|
|
@@ -1021,6 +1037,49 @@ function validateFieldContains(validation, taskResult) {
|
|
|
1021
1037
|
actual: resolved
|
|
1022
1038
|
};
|
|
1023
1039
|
}
|
|
1040
|
+
function validateFieldExcludes(validation, taskResult) {
|
|
1041
|
+
const path = validation.path;
|
|
1042
|
+
const candidates = validation.allowed_values?.length ? validation.allowed_values : [validation.value];
|
|
1043
|
+
const expected = { excludes: validation.allowed_values?.length ? validation.allowed_values : validation.value };
|
|
1044
|
+
const base = {
|
|
1045
|
+
check: validation.check,
|
|
1046
|
+
description: validation.description,
|
|
1047
|
+
path,
|
|
1048
|
+
json_pointer: (0, import_path.toJsonPointer)(path)
|
|
1049
|
+
};
|
|
1050
|
+
const unresolvedContext = (value) => {
|
|
1051
|
+
if (typeof value === "string") return /^\$context\./.test(value);
|
|
1052
|
+
if (Array.isArray(value)) return value.some(unresolvedContext);
|
|
1053
|
+
return value !== null && typeof value === "object" && Object.values(value).some(unresolvedContext);
|
|
1054
|
+
};
|
|
1055
|
+
if (candidates.some(unresolvedContext)) {
|
|
1056
|
+
return {
|
|
1057
|
+
...base,
|
|
1058
|
+
passed: false,
|
|
1059
|
+
error: "field_excludes comparator contains an unresolved context reference",
|
|
1060
|
+
expected: "a resolved value or allowed_values comparator",
|
|
1061
|
+
actual: candidates
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
if (path.length > 1024 || !/^[^.[\]]+(?:\[(?:\d+|\*)?\]|\.[^.[\]]+)*$/.test(path) || (0, import_path.parsePathWithWildcards)(path).some(
|
|
1065
|
+
(segment) => typeof segment === "string" && ["__proto__", "constructor", "prototype"].includes(segment)
|
|
1066
|
+
)) {
|
|
1067
|
+
return {
|
|
1068
|
+
...base,
|
|
1069
|
+
passed: false,
|
|
1070
|
+
error: "Invalid field_excludes path",
|
|
1071
|
+
expected: "a valid safe storyboard path",
|
|
1072
|
+
actual: path
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
const comparisonKey = comparisonKeyFromPath(path);
|
|
1076
|
+
for (const actual of (0, import_path.iteratePathAll)(taskResult.data, path)) {
|
|
1077
|
+
if (candidates.some((candidate) => containsValueMatches(actual, candidate, comparisonKey))) {
|
|
1078
|
+
return { ...base, passed: false, error: `Prohibited value found at ${path}`, expected, actual: [actual] };
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return { ...base, passed: true };
|
|
1082
|
+
}
|
|
1024
1083
|
function validateArrayLength(validation, taskResult) {
|
|
1025
1084
|
const checkName = "array_length";
|
|
1026
1085
|
if (!validation.path) {
|