@sonordev/contracts 2.27.0 → 2.29.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/CHANGELOG.md +16 -0
- package/README.md +166 -1
- package/dist/delegated-command.d.ts +271 -0
- package/dist/delegated-command.js +2224 -0
- package/dist/delegated-command.mjs +2197 -0
- package/dist/resonance-confirmation.d.ts +33 -11
- package/dist/resonance-confirmation.js +61 -8
- package/dist/resonance-confirmation.mjs +56 -9
- package/dist/resonance.d.ts +1474 -140
- package/dist/resonance.js +959 -507
- package/dist/resonance.mjs +926 -508
- package/dist/wire-native-cas.d.ts +7 -0
- package/package.json +6 -1
package/dist/resonance.mjs
CHANGED
|
@@ -7,31 +7,31 @@ var RESONANCE_SOURCE_MARKER_PARAMETER = "sonor_source";
|
|
|
7
7
|
var RESONANCE_SUBJECT_HEADER = "X-Sonor-Resonance-Subject";
|
|
8
8
|
|
|
9
9
|
// src/contracts/wire-schema.ts
|
|
10
|
-
function createWireSchema(
|
|
10
|
+
function createWireSchema(fail4, isValidationError) {
|
|
11
11
|
const own = (v, k) => Object.prototype.hasOwnProperty.call(v, k);
|
|
12
12
|
const field3 = (schema, read) => ({ schema, read });
|
|
13
|
-
const
|
|
14
|
-
const choice3 = (...values) => field3({ type: "string", enum: values }, (v, p) => typeof v === "string" && values.includes(v) ? v :
|
|
15
|
-
const literal3 = (value) => field3({ const: value }, (v, p) => v === value ? value :
|
|
16
|
-
const integer3 = (min = 0, max = Number.MAX_SAFE_INTEGER) => field3({ type: "integer", minimum: min, maximum: max }, (v, p) => typeof v === "number" && Number.isSafeInteger(v) && v >= min && v <= max ? v :
|
|
17
|
-
const bool2 = field3({ type: "boolean" }, (v, p) => typeof v === "boolean" ? v :
|
|
13
|
+
const text4 = (max = 200, pattern, min = 1) => field3({ type: "string", minLength: min, maxLength: max, ...pattern ? { pattern: pattern.source } : {} }, (v, p) => typeof v === "string" && v.length >= min && v.length <= max && (!pattern || pattern.test(v)) ? v : fail4(p, "invalid string"));
|
|
14
|
+
const choice3 = (...values) => field3({ type: "string", enum: values }, (v, p) => typeof v === "string" && values.includes(v) ? v : fail4(p, "unsupported value"));
|
|
15
|
+
const literal3 = (value) => field3({ const: value }, (v, p) => v === value ? value : fail4(p, "unexpected value"));
|
|
16
|
+
const integer3 = (min = 0, max = Number.MAX_SAFE_INTEGER) => field3({ type: "integer", minimum: min, maximum: max }, (v, p) => typeof v === "number" && Number.isSafeInteger(v) && v >= min && v <= max ? v : fail4(p, "invalid integer"));
|
|
17
|
+
const bool2 = field3({ type: "boolean" }, (v, p) => typeof v === "boolean" ? v : fail4(p, "must be boolean"));
|
|
18
18
|
const optional3 = (f) => ({ ...f, optional: true });
|
|
19
19
|
const nullable3 = (f) => field3({ anyOf: [f.schema, { type: "null" }] }, (v, p) => v === null ? null : f.read(v, p));
|
|
20
20
|
const list3 = (f, max = 100, min = 0) => field3({ type: "array", items: f.schema, minItems: min, maxItems: max }, (v, p) => {
|
|
21
|
-
if (!Array.isArray(v) || v.length < min || v.length > max)
|
|
21
|
+
if (!Array.isArray(v) || v.length < min || v.length > max) fail4(p, "invalid array");
|
|
22
22
|
return v.map((x, i) => f.read(x, `${p}[${i}]`));
|
|
23
23
|
});
|
|
24
24
|
const object3 = (fields2) => field3({ type: "object", additionalProperties: false, properties: Object.fromEntries(Object.entries(fields2).map(([k, f]) => [k, f.schema])), required: Object.keys(fields2).filter((k) => !("optional" in fields2[k])) }, (v, p) => {
|
|
25
|
-
if (!v || typeof v !== "object" || Array.isArray(v) || ![Object.prototype, null].includes(Object.getPrototypeOf(v)))
|
|
25
|
+
if (!v || typeof v !== "object" || Array.isArray(v) || ![Object.prototype, null].includes(Object.getPrototypeOf(v))) fail4(p, "must be a plain object");
|
|
26
26
|
const source2 = v, result = {};
|
|
27
|
-
for (const key of Reflect.ownKeys(source2)) if (typeof key !== "string" || !own(fields2, key))
|
|
27
|
+
for (const key of Reflect.ownKeys(source2)) if (typeof key !== "string" || !own(fields2, key)) fail4(p, "unknown field");
|
|
28
28
|
for (const [key, f] of Object.entries(fields2)) {
|
|
29
29
|
if (!own(source2, key)) {
|
|
30
30
|
if ("optional" in f) continue;
|
|
31
|
-
|
|
31
|
+
fail4(`${p}.${key}`, "required");
|
|
32
32
|
}
|
|
33
33
|
const descriptor = Object.getOwnPropertyDescriptor(source2, key);
|
|
34
|
-
if (!own(descriptor, "value"))
|
|
34
|
+
if (!own(descriptor, "value")) fail4(`${p}.${key}`, "accessors are not wire data");
|
|
35
35
|
result[key] = f.read(descriptor.value, `${p}.${key}`);
|
|
36
36
|
}
|
|
37
37
|
return result;
|
|
@@ -45,16 +45,35 @@ function createWireSchema(fail3, isValidationError) {
|
|
|
45
45
|
if (!isValidationError(e)) throw e;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
return found.length === 1 ? found[0] :
|
|
48
|
+
return found.length === 1 ? found[0] : fail4(p, "must match exactly one supported shape");
|
|
49
49
|
});
|
|
50
|
-
const
|
|
50
|
+
const refine4 = (f, check) => field3(f.schema, (v, p) => {
|
|
51
51
|
const result = f.read(v, p);
|
|
52
52
|
check(result, p);
|
|
53
53
|
return result;
|
|
54
54
|
});
|
|
55
|
-
return { field: field3, text:
|
|
55
|
+
return { field: field3, text: text4, choice: choice3, literal: literal3, integer: integer3, bool: bool2, optional: optional3, nullable: nullable3, list: list3, object: object3, union: union3, refine: refine4 };
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// src/contracts/wire-native-cas.ts
|
|
59
|
+
var NativeCasTimestampValidationError = class extends Error {
|
|
60
|
+
constructor(path2, reason) {
|
|
61
|
+
super(`${path2}: ${reason}`);
|
|
62
|
+
this.path = path2;
|
|
63
|
+
this.name = "NativeCasTimestampValidationError";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var fail = (path2, reason) => {
|
|
67
|
+
throw new NativeCasTimestampValidationError(path2, reason);
|
|
68
|
+
};
|
|
69
|
+
var { text, refine } = createWireSchema(fail, (error) => error instanceof NativeCasTimestampValidationError);
|
|
70
|
+
var timestamp = refine(text(32, /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d{1,6})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/), (v, p) => {
|
|
71
|
+
const calendar = v.slice(0, 19) + "Z";
|
|
72
|
+
if (v.startsWith("0000") || !Number.isFinite(Date.parse(calendar)) || new Date(calendar).toISOString().slice(0, 19) !== v.slice(0, 19)) fail(p, "invalid native CAS calendar timestamp");
|
|
73
|
+
});
|
|
74
|
+
var parseNativeCasTimestamp = (v) => timestamp.read(v, "nativeCasTimestamp");
|
|
75
|
+
var NATIVE_CAS_TIMESTAMP_JSON_SCHEMA = timestamp.schema;
|
|
76
|
+
|
|
58
77
|
// src/contracts/sites-normalize.ts
|
|
59
78
|
function stripWww(host) {
|
|
60
79
|
return host.startsWith("www.") ? host.slice(4) : host;
|
|
@@ -128,37 +147,37 @@ var SignalExperimentValidationError = class extends Error {
|
|
|
128
147
|
this.name = "SignalExperimentValidationError";
|
|
129
148
|
}
|
|
130
149
|
};
|
|
131
|
-
var
|
|
150
|
+
var fail2 = (path2, reason) => {
|
|
132
151
|
throw new SignalExperimentValidationError(path2, reason);
|
|
133
152
|
};
|
|
134
|
-
var { field, text, choice, literal, integer, optional, nullable, list, object, union, refine } = createWireSchema(
|
|
135
|
-
var percent = field({ type: "number", minimum: 0, maximum: 100 }, (v, p) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 100 ? v :
|
|
136
|
-
var page =
|
|
153
|
+
var { field, text: text2, choice, literal, integer, optional, nullable, list, object, union, refine: refine2 } = createWireSchema(fail2, (error) => error instanceof SignalExperimentValidationError);
|
|
154
|
+
var percent = field({ type: "number", minimum: 0, maximum: 100 }, (v, p) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 100 ? v : fail2(p, "must be a finite percentage from 0 to 100"));
|
|
155
|
+
var page = refine2(text2(2048, /^\/(?!\/)[^?#\s\\]*$/), (v, p) => {
|
|
137
156
|
const parsed = new URL(v, "https://example.com");
|
|
138
|
-
if (parsed.pathname !== v)
|
|
157
|
+
if (parsed.pathname !== v) fail2(p, "must be a canonical page path");
|
|
139
158
|
});
|
|
140
|
-
var variant = object({ key:
|
|
141
|
-
var variants =
|
|
142
|
-
if (new Set(v.map((x) => x.key)).size !== v.length)
|
|
143
|
-
if (Math.abs(v.reduce((sum, x) => sum + x.weight, 0) - 100) > 0.01)
|
|
159
|
+
var variant = object({ key: text2(80), name: text2(160), weight: percent, description: optional(text2(1e3, void 0, 0)) });
|
|
160
|
+
var variants = refine2(list(variant, 50, 2), (v, p) => {
|
|
161
|
+
if (new Set(v.map((x) => x.key)).size !== v.length) fail2(p, "variant keys must be unique");
|
|
162
|
+
if (Math.abs(v.reduce((sum, x) => sum + x.weight, 0) - 100) > 0.01) fail2(p, "variant weights must sum to 100");
|
|
144
163
|
});
|
|
145
|
-
var targeting = object({ pages: optional(list(page, 100)), segments: optional(list(
|
|
146
|
-
var fields = { name:
|
|
164
|
+
var targeting = object({ pages: optional(list(page, 100)), segments: optional(list(text2(160), 100)), devices: optional(list(choice("desktop", "mobile", "tablet"), 3)), geo: optional(list(text2(160), 100)) });
|
|
165
|
+
var fields = { name: text2(160), description: text2(1e4, void 0, 0), variants, traffic_allocation: percent, targeting_rules: targeting };
|
|
147
166
|
var create = object({ ...fields, description: optional(fields.description), traffic_allocation: optional(fields.traffic_allocation), targeting_rules: optional(fields.targeting_rules) });
|
|
148
167
|
var update = object({ name: optional(fields.name), description: optional(fields.description), variants: optional(fields.variants), traffic_allocation: optional(fields.traffic_allocation), targeting_rules: optional(fields.targeting_rules) });
|
|
149
168
|
var parseSignalExperimentCreate = (v) => create.read(v, "experimentCreate");
|
|
150
169
|
var parseSignalExperimentUpdate = (v) => update.read(v, "experimentUpdate");
|
|
151
170
|
var SIGNAL_EXPERIMENT_CREATE_JSON_SCHEMA = create.schema;
|
|
152
171
|
var SIGNAL_EXPERIMENT_UPDATE_JSON_SCHEMA = update.schema;
|
|
153
|
-
var measurementUuid =
|
|
154
|
-
var measurementRevision =
|
|
155
|
-
var measurementInstant =
|
|
156
|
-
if (!Number.isFinite(Date.parse(v)) || new Date(v).toISOString().replace(".000Z", "Z") !== v.replace(".000Z", "Z"))
|
|
172
|
+
var measurementUuid = text2(36, UUID_V1_TO_V8_PATTERN);
|
|
173
|
+
var measurementRevision = text2(128, /^[a-zA-Z0-9._:-]+$/);
|
|
174
|
+
var measurementInstant = refine2(text2(30, /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/), (v, p) => {
|
|
175
|
+
if (!Number.isFinite(Date.parse(v)) || new Date(v).toISOString().replace(".000Z", "Z") !== v.replace(".000Z", "Z")) fail2(p, "invalid UTC instant");
|
|
157
176
|
});
|
|
158
|
-
var measurementSite =
|
|
159
|
-
if (!isNormalizedSiteHost(v) || isBlockedPublicUrlHost(v))
|
|
177
|
+
var measurementSite = refine2(text2(253), (v, p) => {
|
|
178
|
+
if (!isNormalizedSiteHost(v) || isBlockedPublicUrlHost(v)) fail2(p, "must be a normalized public site host");
|
|
160
179
|
});
|
|
161
|
-
var measurementCount =
|
|
180
|
+
var measurementCount = text2(30, /^(?:0|[1-9][0-9]*)$/);
|
|
162
181
|
var measurementScope = object({
|
|
163
182
|
projectId: measurementUuid,
|
|
164
183
|
experimentId: measurementUuid,
|
|
@@ -171,7 +190,7 @@ var measurementScope = object({
|
|
|
171
190
|
assignedTo: measurementInstant
|
|
172
191
|
});
|
|
173
192
|
var assignmentCounts = {
|
|
174
|
-
variantKey:
|
|
193
|
+
variantKey: text2(80),
|
|
175
194
|
assignedUnits: measurementCount,
|
|
176
195
|
exposureEvents: measurementCount,
|
|
177
196
|
exposedUnits: measurementCount,
|
|
@@ -201,7 +220,7 @@ var observedFields = {
|
|
|
201
220
|
semanticRole: literal("accepted_form_diagnostic"),
|
|
202
221
|
businessMetrics
|
|
203
222
|
};
|
|
204
|
-
var observedMeasurement =
|
|
223
|
+
var observedMeasurement = refine2(union(
|
|
205
224
|
object({
|
|
206
225
|
...observedFields,
|
|
207
226
|
originalGoal: object({ ...originalGoalFields, sourceKind: formSourceKind }),
|
|
@@ -218,17 +237,17 @@ var observedMeasurement = refine(union(
|
|
|
218
237
|
})
|
|
219
238
|
), (value, p) => {
|
|
220
239
|
if (Date.parse(value.scope.assignedFrom) >= Date.parse(value.scope.assignedTo) || Date.parse(value.scope.assignedTo) > Date.parse(value.observedAt))
|
|
221
|
-
|
|
222
|
-
if (new Set(value.variants.map((v) => v.variantKey)).size !== value.variants.length)
|
|
240
|
+
fail2(p + ".scope", "requires an increasing assignment cohort ending by the native observation");
|
|
241
|
+
if (new Set(value.variants.map((v) => v.variantKey)).size !== value.variants.length) fail2(p + ".variants", "variant keys must be unique");
|
|
223
242
|
for (const [index, v] of value.variants.entries()) {
|
|
224
243
|
const assigned = BigInt(v.assignedUnits), exposed = BigInt(v.exposedUnits), mature = BigInt(v.matureAssignedUnits);
|
|
225
244
|
const at = `${p}.variants[${index}]`;
|
|
226
245
|
if (exposed > assigned || BigInt(v.exposureEvents) < exposed || BigInt(v.assignmentsWithoutExposure) !== assigned - exposed || mature + BigInt(v.immatureAssignedUnits) !== assigned)
|
|
227
|
-
|
|
246
|
+
fail2(at, "assignment, exposure and maturity counts are inconsistent");
|
|
228
247
|
if (v.acceptedFormUnits !== null && v.acceptedFormEvents !== null && v.matureAcceptedFormUnits !== null) {
|
|
229
248
|
const accepted = BigInt(v.acceptedFormUnits), matureAccepted = BigInt(v.matureAcceptedFormUnits);
|
|
230
249
|
if (accepted > exposed || accepted > BigInt(v.acceptedFormEvents) || matureAccepted > mature || matureAccepted > accepted)
|
|
231
|
-
|
|
250
|
+
fail2(at, "accepted form units must remain within their exposed, event and mature cohorts");
|
|
232
251
|
}
|
|
233
252
|
}
|
|
234
253
|
});
|
|
@@ -247,11 +266,11 @@ var scopeOption = object({
|
|
|
247
266
|
experimentId: measurementUuid,
|
|
248
267
|
experimentRevision: integer(1),
|
|
249
268
|
goalRevision: measurementRevision,
|
|
250
|
-
goalLabel: nullable(
|
|
269
|
+
goalLabel: nullable(text2(200)),
|
|
251
270
|
assignmentExtent: nullable(object({ firstAssignedAt: measurementInstant, lastAssignedAt: measurementInstant })),
|
|
252
271
|
suggestedCohort: nullable(object({ assignedFrom: measurementInstant, assignedTo: measurementInstant }))
|
|
253
272
|
});
|
|
254
|
-
var scopeOptions =
|
|
273
|
+
var scopeOptions = refine2(object({ observedAt: measurementInstant, items: list(scopeOption, 100), nextCursor: nullable(text2(4096)) }), (value, p) => {
|
|
255
274
|
const observed = Date.parse(value.observedAt), tuples = /* @__PURE__ */ new Set();
|
|
256
275
|
for (const [index, item] of value.items.entries()) {
|
|
257
276
|
const at = `${p}.items[${index}]`, accepted = Date.parse(item.acceptedAt);
|
|
@@ -263,16 +282,16 @@ var scopeOptions = refine(object({ observedAt: measurementInstant, items: list(s
|
|
|
263
282
|
item.experimentRevision,
|
|
264
283
|
item.goalRevision
|
|
265
284
|
]);
|
|
266
|
-
if (tuples.has(tuple))
|
|
285
|
+
if (tuples.has(tuple)) fail2(at, "original scope tuples must be unique");
|
|
267
286
|
tuples.add(tuple);
|
|
268
|
-
if (accepted > observed)
|
|
287
|
+
if (accepted > observed) fail2(at + ".acceptedAt", "must not follow the native observation");
|
|
269
288
|
if (item.assignmentExtent) {
|
|
270
289
|
const first = Date.parse(item.assignmentExtent.firstAssignedAt), last = Date.parse(item.assignmentExtent.lastAssignedAt);
|
|
271
|
-
if (first > last || last > observed)
|
|
290
|
+
if (first > last || last > observed) fail2(at + ".assignmentExtent", "requires first <= last <= native observation");
|
|
272
291
|
}
|
|
273
292
|
if (item.suggestedCohort) {
|
|
274
293
|
const from = Date.parse(item.suggestedCohort.assignedFrom), to = Date.parse(item.suggestedCohort.assignedTo);
|
|
275
|
-
if (from !== accepted || from >= to || to > observed)
|
|
294
|
+
if (from !== accepted || from >= to || to > observed) fail2(at + ".suggestedCohort", "requires original acceptance start and increasing cohort ending by native observation");
|
|
276
295
|
}
|
|
277
296
|
}
|
|
278
297
|
});
|
|
@@ -296,29 +315,29 @@ var ResonanceValidationError = class extends Error {
|
|
|
296
315
|
this.name = "ResonanceValidationError";
|
|
297
316
|
}
|
|
298
317
|
};
|
|
299
|
-
var
|
|
318
|
+
var fail3 = (path2, reason) => {
|
|
300
319
|
throw new ResonanceValidationError(path2, reason);
|
|
301
320
|
};
|
|
302
|
-
var { field: field2, text:
|
|
303
|
-
var uuid =
|
|
304
|
-
var digest =
|
|
305
|
-
var revision =
|
|
306
|
-
var instant =
|
|
307
|
-
if (!Number.isFinite(Date.parse(v)) || new Date(v).toISOString().replace(".000Z", "Z") !== v.replace(".000Z", "Z"))
|
|
321
|
+
var { field: field2, text: text3, choice: choice2, literal: literal2, integer: integer2, bool, optional: optional2, nullable: nullable2, list: list2, object: object2, union: union2, refine: refine3 } = createWireSchema(fail3, (error) => error instanceof ResonanceValidationError);
|
|
322
|
+
var uuid = text3(36, UUID_V1_TO_V8_PATTERN);
|
|
323
|
+
var digest = text3(64, /^[a-f0-9]{64}$/);
|
|
324
|
+
var revision = text3(128, /^[a-zA-Z0-9._:-]+$/);
|
|
325
|
+
var instant = refine3(text3(30, /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/), (v, p) => {
|
|
326
|
+
if (!Number.isFinite(Date.parse(v)) || new Date(v).toISOString().replace(".000Z", "Z") !== v.replace(".000Z", "Z")) fail3(p, "invalid UTC instant");
|
|
308
327
|
});
|
|
309
|
-
var timeZone =
|
|
328
|
+
var timeZone = refine3(text3(80), (v, p) => {
|
|
310
329
|
try {
|
|
311
330
|
new Intl.DateTimeFormat("en", { timeZone: v });
|
|
312
331
|
} catch {
|
|
313
|
-
|
|
332
|
+
fail3(p, "invalid IANA timezone");
|
|
314
333
|
}
|
|
315
334
|
});
|
|
316
|
-
var site =
|
|
317
|
-
if (!isNormalizedSiteHost(v) || isBlockedPublicUrlHost(v))
|
|
335
|
+
var site = refine3(text3(253), (v, p) => {
|
|
336
|
+
if (!isNormalizedSiteHost(v) || isBlockedPublicUrlHost(v)) fail3(p, "must be a normalized public site host");
|
|
318
337
|
});
|
|
319
|
-
var path =
|
|
320
|
-
var decimal =
|
|
321
|
-
var operationKey =
|
|
338
|
+
var path = text3(2048, /^\/(?!\/)[^?#\s\\]*$/);
|
|
339
|
+
var decimal = text3(30, /^(?:0|[1-9][0-9]{0,29})$/);
|
|
340
|
+
var operationKey = text3(200, /^[a-zA-Z0-9._:-]+$/);
|
|
322
341
|
var objectiveCountingUnit = choice2("unique_source", "unique_qualified_contact", "net_order");
|
|
323
342
|
var RESONANCE_CURRENCIES = ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRU", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLE", "SLL", "SOS", "SRD", "SSP", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VES", "VND", "VUV", "WST", "XAF", "XCD", "XCG", "XDR", "XOF", "XPF", "XSU", "YER", "ZAR", "ZMW", "ZWG", "ZWL"];
|
|
324
343
|
var currency = choice2(...RESONANCE_CURRENCIES);
|
|
@@ -327,28 +346,28 @@ var parseMoney = (value) => money.read(value, "money");
|
|
|
327
346
|
function addMoney(a, b) {
|
|
328
347
|
a = parseMoney(a);
|
|
329
348
|
b = parseMoney(b);
|
|
330
|
-
if (a.currency !== b.currency)
|
|
349
|
+
if (a.currency !== b.currency) fail3("money.currency", "currency mismatch; no implicit FX");
|
|
331
350
|
return parseMoney({ currency: a.currency, amountMicros: (BigInt(a.amountMicros) + BigInt(b.amountMicros)).toString() });
|
|
332
351
|
}
|
|
333
352
|
function moneyToProviderUnits(input, account) {
|
|
334
353
|
const m = parseMoney(input);
|
|
335
354
|
currency.read(account.currency, "account.currency");
|
|
336
355
|
decimal.read(account.maxUnits, "account.maxUnits");
|
|
337
|
-
if (m.currency !== account.currency)
|
|
338
|
-
if (![0, 2, 3, 6].includes(account.unitExponent))
|
|
356
|
+
if (m.currency !== account.currency) fail3("money.currency", "currency mismatch");
|
|
357
|
+
if (![0, 2, 3, 6].includes(account.unitExponent)) fail3("account.unitExponent", "unsupported provider exponent");
|
|
339
358
|
const factor = 10n ** BigInt(6 - account.unitExponent), amount = BigInt(m.amountMicros);
|
|
340
|
-
if (amount % factor !== 0n)
|
|
359
|
+
if (amount % factor !== 0n) fail3("money.amountMicros", "not exactly representable in provider units");
|
|
341
360
|
const units = amount / factor;
|
|
342
|
-
if (units > BigInt(account.maxUnits))
|
|
361
|
+
if (units > BigInt(account.maxUnits)) fail3("money.amountMicros", "provider overflow");
|
|
343
362
|
return units.toString();
|
|
344
363
|
}
|
|
345
364
|
function moneyFromProviderUnits(units, account) {
|
|
346
365
|
decimal.read(units, "provider.units");
|
|
347
|
-
if (![0, 2, 3, 6].includes(account.unitExponent))
|
|
366
|
+
if (![0, 2, 3, 6].includes(account.unitExponent)) fail3("account.unitExponent", "unsupported provider exponent");
|
|
348
367
|
return parseMoney({ currency: account.currency, amountMicros: (BigInt(units) * 10n ** BigInt(6 - account.unitExponent)).toString() });
|
|
349
368
|
}
|
|
350
369
|
var MONEY_JSON_SCHEMA = money.schema;
|
|
351
|
-
var sourceMarker =
|
|
370
|
+
var sourceMarker = text3(1536, /^rsm1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]{43}$/);
|
|
352
371
|
var parseResonanceSourceMarker = (v) => sourceMarker.read(v, "sourceMarker");
|
|
353
372
|
var RESONANCE_SOURCE_MARKER_JSON_SCHEMA = sourceMarker.schema;
|
|
354
373
|
var scope = { projectId: uuid, site };
|
|
@@ -358,13 +377,13 @@ var qualificationFields = { schemaVersion: literal2(1), semantics: literal2("cur
|
|
|
358
377
|
var checkQualificationPartitions = (v, p) => {
|
|
359
378
|
unique([...v.positiveStageKeys, ...v.finalNegativeStageKeys, ...v.pendingStageKeys], p + ".stagePartitions");
|
|
360
379
|
};
|
|
361
|
-
var qualificationRule =
|
|
380
|
+
var qualificationRule = refine3(object2({ ...qualificationFields, attributionModel: literal2(RESONANCE_ATTRIBUTION_MODEL) }), checkQualificationPartitions);
|
|
362
381
|
var parseResonanceQualificationRule = (v) => qualificationRule.read(v, "qualificationRule");
|
|
363
382
|
var RESONANCE_QUALIFICATION_RULE_JSON_SCHEMA = qualificationRule.schema;
|
|
364
|
-
var resolvedQualificationRule =
|
|
383
|
+
var resolvedQualificationRule = refine3(object2({
|
|
365
384
|
...qualificationFields,
|
|
366
385
|
ref: resource,
|
|
367
|
-
crmVariant:
|
|
386
|
+
crmVariant: text3(128),
|
|
368
387
|
ladderSnapshot: list2(object2({ id: nullable2(uuid), stage_key: revision, semantic_key: nullable2(revision), is_won: bool, is_lost: bool }), 500, 1),
|
|
369
388
|
// eligibleBookingTypeIds: Sync booking types whose confirmed bookings also count, beside the one form. Absent means forms only.
|
|
370
389
|
eligibleFormIds: list2(uuid, 500, 1),
|
|
@@ -373,18 +392,18 @@ var resolvedQualificationRule = refine2(object2({
|
|
|
373
392
|
cohort: object2({ startAt: instant, endAt: instant, maturityDelaySeconds: integer2(0, 31536e3) })
|
|
374
393
|
}), (v, p) => {
|
|
375
394
|
checkQualificationPartitions(v, p);
|
|
376
|
-
if (v.ref.module !== "crm" || v.ref.id !== v.ref.projectId)
|
|
395
|
+
if (v.ref.module !== "crm" || v.ref.id !== v.ref.projectId) fail3(p + ".ref", "must reference the actual CRM project configuration");
|
|
377
396
|
unique(v.eligibleFormIds, p + ".eligibleFormIds");
|
|
378
397
|
if (v.eligibleBookingTypeIds) unique(v.eligibleBookingTypeIds.map((x) => x.toLowerCase()), p + ".eligibleBookingTypeIds");
|
|
379
398
|
unique(v.ladderSnapshot.flatMap((x) => x.id ? [x.id] : []), p + ".ladderSnapshot.id");
|
|
380
399
|
unique(v.ladderSnapshot.map((x) => x.stage_key), p + ".ladderSnapshot.stage_key");
|
|
381
400
|
const partitions = [...v.positiveStageKeys, ...v.finalNegativeStageKeys, ...v.pendingStageKeys], keys = new Set(v.ladderSnapshot.map((x) => x.stage_key));
|
|
382
|
-
if (partitions.length !== keys.size || partitions.some((k) => !keys.has(k)))
|
|
383
|
-
if (Date.parse(v.cohort.endAt) <= Date.parse(v.cohort.startAt))
|
|
401
|
+
if (partitions.length !== keys.size || partitions.some((k) => !keys.has(k))) fail3(p + ".stagePartitions", "must exhaust the actual native ladder");
|
|
402
|
+
if (Date.parse(v.cohort.endAt) <= Date.parse(v.cohort.startAt)) fail3(p + ".cohort", "invalid cohort interval");
|
|
384
403
|
});
|
|
385
404
|
var parseResonanceResolvedQualificationRule = (v) => resolvedQualificationRule.read(v, "resolvedQualificationRule");
|
|
386
405
|
var RESONANCE_RESOLVED_QUALIFICATION_RULE_JSON_SCHEMA = resolvedQualificationRule.schema;
|
|
387
|
-
var objective =
|
|
406
|
+
var objective = refine3(object2({
|
|
388
407
|
source,
|
|
389
408
|
measurementRevision: revision,
|
|
390
409
|
countingUnit: objectiveCountingUnit,
|
|
@@ -396,23 +415,23 @@ var objective = refine2(object2({
|
|
|
396
415
|
eligibleBookingTypeIds: optional2(list2(uuid, 100, 1))
|
|
397
416
|
}), (v, p) => {
|
|
398
417
|
if (v.eligibleBookingTypeIds) {
|
|
399
|
-
if (v.source.kind !== "qualified_lead")
|
|
418
|
+
if (v.source.kind !== "qualified_lead") fail3(p + ".eligibleBookingTypeIds", "requires the native qualified-lead source");
|
|
400
419
|
unique(v.eligibleBookingTypeIds.map((x) => x.toLowerCase()), p + ".eligibleBookingTypeIds");
|
|
401
420
|
}
|
|
402
|
-
if (v.qualificationRule && v.source.kind !== "qualified_lead")
|
|
403
|
-
if (v.qualificationRule && v.qualificationRuleRef && (v.qualificationRuleRef.module !== "crm" || v.qualificationRuleRef.id !== v.source.projectId))
|
|
421
|
+
if (v.qualificationRule && v.source.kind !== "qualified_lead") fail3(p + ".qualificationRule", "requires the native qualified-lead source");
|
|
422
|
+
if (v.qualificationRule && v.qualificationRuleRef && (v.qualificationRuleRef.module !== "crm" || v.qualificationRuleRef.id !== v.source.projectId)) fail3(p + ".qualificationRuleRef", "must reference actual CRM project configuration");
|
|
404
423
|
});
|
|
405
|
-
var creative = object2({ id: uuid, assetRef: resource, preparedArtifactRef: nullable2(resource), headline:
|
|
424
|
+
var creative = object2({ id: uuid, assetRef: resource, preparedArtifactRef: nullable2(resource), headline: text3(160), body: text3(1e4), callToAction: text3(80), cropDigest: digest });
|
|
406
425
|
var destination = union2(
|
|
407
|
-
object2({ kind: literal2("funnel"), id: uuid, ...scope, path, funnelRef: resource, formSlug:
|
|
426
|
+
object2({ kind: literal2("funnel"), id: uuid, ...scope, path, funnelRef: resource, formSlug: text3(80, /^[a-z0-9]+(?:-[a-z0-9]+)*$/), installationRevision: revision }),
|
|
408
427
|
object2({ kind: literal2("existing_page"), id: uuid, ...scope, path, pageRevision: revision, evidenceDigest: digest })
|
|
409
428
|
);
|
|
410
429
|
var audience = object2({ ...scope, id: uuid, revision, policyRevision: revision, retentionDays: integer2(1, 540), exclusionRuleIds: list2(uuid, 50), minDaysSinceVisit: optional2(integer2(1, 179)), consentPurpose: literal2("ad_personalization") });
|
|
411
430
|
var experiment = object2({ ...scope, id: uuid, revision: integer2(1), digest });
|
|
412
|
-
var budget =
|
|
413
|
-
if (Date.parse(v.endAt) <= Date.parse(v.startAt))
|
|
414
|
-
for (const m of [v.reserveMargin, v.maxChange, ...v.dailyAllocationCeiling ? [v.dailyAllocationCeiling] : []]) if (m.currency !== v.total.currency)
|
|
415
|
-
if (BigInt(v.reserveMargin.amountMicros) > BigInt(v.total.amountMicros))
|
|
431
|
+
var budget = refine3(object2({ total: money, dailyAllocationCeiling: nullable2(money), reserveMargin: money, startAt: instant, endAt: instant, timeZone, maxChange: money, maxChangeBasisPoints: integer2(0, 1e4), cooldownSeconds: integer2(0, 31536e3) }), (v, p) => {
|
|
432
|
+
if (Date.parse(v.endAt) <= Date.parse(v.startAt)) fail3(p, "end must follow start");
|
|
433
|
+
for (const m of [v.reserveMargin, v.maxChange, ...v.dailyAllocationCeiling ? [v.dailyAllocationCeiling] : []]) if (m.currency !== v.total.currency) fail3(p, "currency mismatch");
|
|
434
|
+
if (BigInt(v.reserveMargin.amountMicros) > BigInt(v.total.amountMicros)) fail3(p, "reserve exceeds total");
|
|
416
435
|
});
|
|
417
436
|
var allocationPolicyFields = {
|
|
418
437
|
schemaVersion: literal2(1),
|
|
@@ -449,7 +468,7 @@ var finiteStopRule = choice2("exploration_cap", "flight_end", "policy_or_mandate
|
|
|
449
468
|
var positiveMicrosPattern = /^[1-9][0-9]*(?![\s\S])/;
|
|
450
469
|
var positiveMoneyShape = field2({ allOf: [money.schema, { properties: { amountMicros: { pattern: positiveMicrosPattern.source } } }] }, (v, p) => {
|
|
451
470
|
const m = money.read(v, p);
|
|
452
|
-
if (!positiveMicrosPattern.test(m.amountMicros))
|
|
471
|
+
if (!positiveMicrosPattern.test(m.amountMicros)) fail3(p, "requires positive canonical money");
|
|
453
472
|
return m;
|
|
454
473
|
});
|
|
455
474
|
var finiteMetaCandidatePolicy = object2({
|
|
@@ -477,27 +496,27 @@ function parseResonanceOptimizationPolicy(v) {
|
|
|
477
496
|
return r;
|
|
478
497
|
}
|
|
479
498
|
const p = "optimizationPolicy", ids = r.candidateChannelIds, guard = r.measurementGuard;
|
|
480
|
-
if (r.selection.candidateOrder.length !== ids.length || r.selection.candidateOrder.some((id) => !ids.includes(id)))
|
|
499
|
+
if (r.selection.candidateOrder.length !== ids.length || r.selection.candidateOrder.some((id) => !ids.includes(id))) fail3(p + ".selection.candidateOrder", "must be the exact candidate permutation");
|
|
481
500
|
unique(r.selection.eligibilitySchedule.map((s) => s.channelId), p + ".selection.eligibilitySchedule");
|
|
482
|
-
if (r.selection.eligibilitySchedule.length !== ids.length || r.selection.eligibilitySchedule.some((s) => !ids.includes(s.channelId)))
|
|
483
|
-
if (r.selection.eligibilitySchedule.some((s) => Date.parse(s.notAfter) <= Date.parse(s.notBefore) || Date.parse(s.notAfter) > Date.parse(r.expiresAt)))
|
|
484
|
-
if (r.maxConcurrentCandidates > ids.length)
|
|
485
|
-
if (BigInt(r.totalExplorationCap.amountMicros) === 0n)
|
|
486
|
-
if (guard.sourceRef.kind !== r.eligibleGoal || guard.qualificationRuleRef.module !== "crm" || guard.qualificationRuleRef.id !== guard.sourceRef.projectId || guard.qualificationRuleRef.projectId !== guard.sourceRef.projectId || guard.qualificationRuleRef.site !== guard.sourceRef.site)
|
|
501
|
+
if (r.selection.eligibilitySchedule.length !== ids.length || r.selection.eligibilitySchedule.some((s) => !ids.includes(s.channelId))) fail3(p + ".selection.eligibilitySchedule", "must cover exactly the original candidates");
|
|
502
|
+
if (r.selection.eligibilitySchedule.some((s) => Date.parse(s.notAfter) <= Date.parse(s.notBefore) || Date.parse(s.notAfter) > Date.parse(r.expiresAt))) fail3(p + ".selection.eligibilitySchedule", "invalid policy selection window");
|
|
503
|
+
if (r.maxConcurrentCandidates > ids.length) fail3(p + ".maxConcurrentCandidates", "exceeds finite candidate count");
|
|
504
|
+
if (BigInt(r.totalExplorationCap.amountMicros) === 0n) fail3(p + ".totalExplorationCap", "requires a positive reviewed ceiling");
|
|
505
|
+
if (guard.sourceRef.kind !== r.eligibleGoal || guard.qualificationRuleRef.module !== "crm" || guard.qualificationRuleRef.id !== guard.sourceRef.projectId || guard.qualificationRuleRef.projectId !== guard.sourceRef.projectId || guard.qualificationRuleRef.site !== guard.sourceRef.site) fail3(p + ".measurementGuard", "requires the original qualified source and CRM witness scope");
|
|
487
506
|
scoped(r, guard.sourceRef.projectId, [guard.sourceRef.site], p);
|
|
488
507
|
return r;
|
|
489
508
|
}
|
|
490
509
|
var RESONANCE_OPTIMIZATION_POLICY_JSON_SCHEMA = optimizationPolicy.schema;
|
|
491
510
|
var optimization = object2({ enabled: bool, policy: optimizationPolicy, stopLoss: object2({ confirmedSpend: money, unreconciledExposure: money }) });
|
|
492
511
|
var channelBase = { id: uuid, ...scope, destinationId: uuid, creativeIds: list2(uuid, 50, 1) };
|
|
493
|
-
var search = object2({ ...channelBase, localCampaignKey:
|
|
494
|
-
var metaAgeConstraint = union2(
|
|
495
|
-
if (v.min > v.max)
|
|
512
|
+
var search = object2({ ...channelBase, localCampaignKey: text3(80), kind: literal2("google_search"), provider: literal2("google_ads"), accountBindingId: uuid, capabilityRevision: revision, allocation: money, budgetMode: choice2("campaign_total", "average_daily"), keywords: list2(object2({ text: text3(80), match: choice2("exact", "phrase", "broad") }), 200, 1), negativeKeywords: list2(text3(80), 200), bidding: union2(object2({ strategy: literal2("maximize_conversions") }), object2({ strategy: literal2("target_cpa"), target: money })), locationIds: list2(text3(80), 100, 1), network: object2({ googleSearch: literal2(true), searchPartners: bool, displayExpansion: literal2(false) }), geoPresence: choice2("presence", "presence_or_interest"), excludedLocationIds: list2(text3(80), 100), adGroups: list2(object2({ localKey: text3(80), ads: list2(object2({ localKey: text3(80), creativeId: uuid, headlines: list2(text3(30), 15, 3), descriptions: list2(text3(90), 4, 2) }), 20, 1) }), 100, 1), assetAutomation: literal2("disabled") });
|
|
513
|
+
var metaAgeConstraint = union2(refine3(object2({ mode: literal2("bounded"), min: integer2(1, 120), max: integer2(1, 120) }), (v, p) => {
|
|
514
|
+
if (v.min > v.max) fail3(p, "minimum age exceeds maximum");
|
|
496
515
|
}), object2({ mode: literal2("omitted") }), object2({ mode: literal2("provider_managed") }));
|
|
497
|
-
var propertyKey = object2({ key:
|
|
516
|
+
var propertyKey = object2({ key: text3(40, /^[a-z0-9]+(?:-[a-z0-9]+)*$/), label: text3(80) });
|
|
498
517
|
var meta = object2({
|
|
499
518
|
...channelBase,
|
|
500
|
-
localCampaignKey:
|
|
519
|
+
localCampaignKey: text3(80),
|
|
501
520
|
kind: literal2("meta_retargeting"),
|
|
502
521
|
provider: literal2("meta_ads"),
|
|
503
522
|
accountBindingId: uuid,
|
|
@@ -506,34 +525,34 @@ var meta = object2({
|
|
|
506
525
|
budgetMode: choice2("lifetime", "daily"),
|
|
507
526
|
audienceRuleRefs: list2(audience, 50, 1),
|
|
508
527
|
objective: choice2("OUTCOME_LEADS", "OUTCOME_SALES", "OUTCOME_TRAFFIC"),
|
|
509
|
-
pageRef: object2({ connectionId: uuid, externalId:
|
|
510
|
-
instagramRef: nullable2(object2({ connectionId: uuid, externalId:
|
|
511
|
-
datasetRef: object2({ id:
|
|
528
|
+
pageRef: object2({ connectionId: uuid, externalId: text3(160), revision }),
|
|
529
|
+
instagramRef: nullable2(object2({ connectionId: uuid, externalId: text3(160), revision })),
|
|
530
|
+
datasetRef: object2({ id: text3(160), revision }),
|
|
512
531
|
conversionGoalRef: resource,
|
|
513
532
|
optimization: choice2("landing_page_views", "lead", "purchase"),
|
|
514
533
|
billing: literal2("impressions"),
|
|
515
534
|
bid: union2(object2({ strategy: literal2("lowest_cost") }), object2({ strategy: literal2("cost_cap"), cap: money })),
|
|
516
|
-
localAdSetKey:
|
|
517
|
-
localAdKey:
|
|
535
|
+
localAdSetKey: text3(80),
|
|
536
|
+
localAdKey: text3(80),
|
|
518
537
|
budgetOwner: choice2("campaign", "adset"),
|
|
519
538
|
specialCategories: list2(choice2("housing", "employment", "financial_products_services"), 3),
|
|
520
|
-
countryCodes: list2(
|
|
539
|
+
countryCodes: list2(text3(2, /^[A-Z]{2}$/), 30, 1),
|
|
521
540
|
placement: literal2("automatic"),
|
|
522
541
|
ageConstraint: optional2(metaAgeConstraint),
|
|
523
542
|
// Property retargeting (one channel per property under one group). Every field is optional and omitted from the canonical form when absent, so no existing reviewed digest changes.
|
|
524
543
|
channelGroup: optional2(propertyKey),
|
|
525
544
|
property: optional2(propertyKey),
|
|
526
|
-
tier: optional2(object2({ label:
|
|
527
|
-
primaryText: optional2(
|
|
545
|
+
tier: optional2(object2({ label: text3(40) })),
|
|
546
|
+
primaryText: optional2(text3(2200)),
|
|
528
547
|
convertersAcknowledged: optional2(literal2(true))
|
|
529
548
|
});
|
|
530
549
|
var owned = object2({ ...channelBase, kind: choice2("funnel", "broadcast", "outreach"), resourceRef: resource });
|
|
531
550
|
var channel = union2(search, meta, owned);
|
|
532
|
-
var definitionFields = { schemaVersion: literal2(1), projectId: uuid, name:
|
|
533
|
-
if (normalizeCampaignSlug(v) !== v)
|
|
551
|
+
var definitionFields = { schemaVersion: literal2(1), projectId: uuid, name: text3(160), slug: refine3(text3(80), (v, p) => {
|
|
552
|
+
if (normalizeCampaignSlug(v) !== v) fail3(p, "must be canonical campaign slug");
|
|
534
553
|
}), sites: list2(site, 50, 1), objective, brandRef: resource, creativeRefs: list2(creative, 100, 1), destinations: list2(destination, 100, 1), channels: list2(channel, 100, 1), experimentRefs: list2(experiment, 50), budget, optimization };
|
|
535
554
|
var definition = object2(definitionFields);
|
|
536
|
-
var draft = object2({ schemaVersion: literal2(1), projectId: uuid, name:
|
|
555
|
+
var draft = object2({ schemaVersion: literal2(1), projectId: uuid, name: text3(160, void 0, 0), slug: definitionFields.slug, sites: list2(site, 50), objective: optional2(objective), brandRef: optional2(resource), creativeRefs: optional2(list2(creative, 100)), destinations: optional2(list2(destination, 100)), channels: optional2(list2(channel, 100)), experimentRefs: optional2(list2(experiment, 50)), budget: optional2(budget), optimization: optional2(optimization) });
|
|
537
556
|
function scoped(value, projectId, sites, at) {
|
|
538
557
|
if (!value || typeof value !== "object") return;
|
|
539
558
|
if (Array.isArray(value)) {
|
|
@@ -541,36 +560,36 @@ function scoped(value, projectId, sites, at) {
|
|
|
541
560
|
return;
|
|
542
561
|
}
|
|
543
562
|
const v = value;
|
|
544
|
-
if ("projectId" in v && v.projectId !== projectId)
|
|
545
|
-
if ("site" in v && !sites.includes(v.site))
|
|
563
|
+
if ("projectId" in v && v.projectId !== projectId) fail3(at, "cross-project reference");
|
|
564
|
+
if ("site" in v && !sites.includes(v.site)) fail3(at, "site outside campaign scope");
|
|
546
565
|
for (const [k, x] of Object.entries(v)) scoped(x, projectId, sites, `${at}.${k}`);
|
|
547
566
|
}
|
|
548
567
|
function unique(values, at) {
|
|
549
|
-
if (new Set(values).size !== values.length)
|
|
568
|
+
if (new Set(values).size !== values.length) fail3(at, "duplicate identity");
|
|
550
569
|
}
|
|
551
570
|
function checkDefinition(v) {
|
|
552
571
|
unique(v.sites, "campaign.sites");
|
|
553
572
|
scoped(v, v.projectId, v.sites, "campaign");
|
|
554
573
|
parseResonanceOptimizationPolicy(v.optimization.policy);
|
|
555
|
-
if (v.optimization.enabled && v.objective.source.kind !== v.optimization.policy.eligibleGoal)
|
|
556
|
-
if ([v.optimization.stopLoss.confirmedSpend, v.optimization.stopLoss.unreconciledExposure].some((m) => m.currency !== v.budget.total.currency))
|
|
574
|
+
if (v.optimization.enabled && v.objective.source.kind !== v.optimization.policy.eligibleGoal) fail3("campaign.optimization.policy", "policy is not eligible for this goal");
|
|
575
|
+
if ([v.optimization.stopLoss.confirmedSpend, v.optimization.stopLoss.unreconciledExposure].some((m) => m.currency !== v.budget.total.currency)) fail3("campaign.optimization.stopLoss", "currency mismatch");
|
|
557
576
|
unique(v.channels.map((c) => c.id), "campaign.channels");
|
|
558
577
|
unique(v.creativeRefs.map((c) => c.id), "campaign.creativeRefs");
|
|
559
578
|
unique(v.destinations.map((d) => d.id), "campaign.destinations");
|
|
560
|
-
if (!["business_brain", "publication"].includes(v.brandRef.module))
|
|
561
|
-
for (const c of v.creativeRefs) if (c.assetRef.module !== "files" || c.preparedArtifactRef && !["files", "broadcast"].includes(c.preparedArtifactRef.module))
|
|
562
|
-
for (const d of v.destinations) if (d.kind === "funnel" && d.funnelRef.module !== "funnel")
|
|
579
|
+
if (!["business_brain", "publication"].includes(v.brandRef.module)) fail3("campaign.brandRef", "must reference existing brand owner");
|
|
580
|
+
for (const c of v.creativeRefs) if (c.assetRef.module !== "files" || c.preparedArtifactRef && !["files", "broadcast"].includes(c.preparedArtifactRef.module)) fail3("campaign.creativeRefs", "unsupported asset owner");
|
|
581
|
+
for (const d of v.destinations) if (d.kind === "funnel" && d.funnelRef.module !== "funnel") fail3("campaign.destinations", "must reference funnel owner");
|
|
563
582
|
for (const c of v.channels) {
|
|
564
|
-
const dest = v.destinations.find((d) => d.id === c.destinationId) ??
|
|
565
|
-
if (dest.site !== c.site)
|
|
566
|
-
if (c.creativeIds.some((id) => !v.creativeRefs.some((x) => x.id === id)))
|
|
567
|
-
if ("bid" in c && "cap" in c.bid && c.bid.cap.currency !== v.budget.total.currency)
|
|
583
|
+
const dest = v.destinations.find((d) => d.id === c.destinationId) ?? fail3("campaign.channels.destinationId", "must reference a destination ID");
|
|
584
|
+
if (dest.site !== c.site) fail3("campaign.channels.destinationId", "destination site mismatch");
|
|
585
|
+
if (c.creativeIds.some((id) => !v.creativeRefs.some((x) => x.id === id))) fail3("campaign.channels.creativeIds", "unknown creative");
|
|
586
|
+
if ("bid" in c && "cap" in c.bid && c.bid.cap.currency !== v.budget.total.currency) fail3("campaign.channels.bid", "currency mismatch");
|
|
568
587
|
if ("adGroups" in c) {
|
|
569
|
-
for (const g of c.adGroups) for (const a of g.ads) if (!c.creativeIds.includes(a.creativeId))
|
|
588
|
+
for (const g of c.adGroups) for (const a of g.ads) if (!c.creativeIds.includes(a.creativeId)) fail3("campaign.channels.adGroups", "ad creative outside channel");
|
|
570
589
|
}
|
|
571
|
-
if ("resourceRef" in c && c.resourceRef.module !== c.kind)
|
|
572
|
-
if ("bidding" in c && "target" in c.bidding && c.bidding.target.currency !== v.budget.total.currency)
|
|
573
|
-
if ("allocation" in c && c.allocation.currency !== v.budget.total.currency)
|
|
590
|
+
if ("resourceRef" in c && c.resourceRef.module !== c.kind) fail3("campaign.channels.resourceRef", "module owner mismatch");
|
|
591
|
+
if ("bidding" in c && "target" in c.bidding && c.bidding.target.currency !== v.budget.total.currency) fail3("campaign.channels.bidding", "currency mismatch");
|
|
592
|
+
if ("allocation" in c && c.allocation.currency !== v.budget.total.currency) fail3("campaign.channels.allocation", "currency mismatch");
|
|
574
593
|
}
|
|
575
594
|
checkChannelGroups(v.channels);
|
|
576
595
|
checkGroupedAllocations(v);
|
|
@@ -578,12 +597,12 @@ function checkDefinition(v) {
|
|
|
578
597
|
const policy = v.optimization.policy;
|
|
579
598
|
if (policy.algorithm === "finite_meta_candidates_v1") {
|
|
580
599
|
const guard = policy.measurementGuard, goal = v.objective;
|
|
581
|
-
if (canonical(guard.sourceRef) !== canonical(goal.source) || !goal.qualificationRuleRef || canonical(guard.qualificationRuleRef) !== canonical(goal.qualificationRuleRef) || guard.maturityDelaySeconds !== goal.maturityDelaySeconds || goal.countingUnit !== "unique_qualified_contact")
|
|
582
|
-
if (policy.totalExplorationCap.currency !== v.budget.total.currency || compareMoney(policy.totalExplorationCap, v.budget.total) > 0)
|
|
583
|
-
if (Date.parse(policy.expiresAt) > Date.parse(v.budget.endAt) || policy.selection.eligibilitySchedule.some((s) => Date.parse(s.notBefore) < Date.parse(v.budget.startAt) || Date.parse(s.notAfter) > Date.parse(v.budget.endAt)))
|
|
600
|
+
if (canonical(guard.sourceRef) !== canonical(goal.source) || !goal.qualificationRuleRef || canonical(guard.qualificationRuleRef) !== canonical(goal.qualificationRuleRef) || guard.maturityDelaySeconds !== goal.maturityDelaySeconds || goal.countingUnit !== "unique_qualified_contact") fail3("campaign.optimization.policy.measurementGuard", "must match the original qualified objective");
|
|
601
|
+
if (policy.totalExplorationCap.currency !== v.budget.total.currency || compareMoney(policy.totalExplorationCap, v.budget.total) > 0) fail3("campaign.optimization.policy.totalExplorationCap", "outside original budget ceiling");
|
|
602
|
+
if (Date.parse(policy.expiresAt) > Date.parse(v.budget.endAt) || policy.selection.eligibilitySchedule.some((s) => Date.parse(s.notBefore) < Date.parse(v.budget.startAt) || Date.parse(s.notAfter) > Date.parse(v.budget.endAt))) fail3("campaign.optimization.policy.selection", "selection windows must stay inside the original flight");
|
|
584
603
|
for (const id of policy.candidateChannelIds) {
|
|
585
604
|
const c = v.channels.find((c2) => c2.id === id);
|
|
586
|
-
if (!c || c.kind !== "meta_retargeting" || c.budgetMode !== "lifetime" || c.budgetOwner !== "adset" || BigInt(c.allocation.amountMicros) === 0n)
|
|
605
|
+
if (!c || c.kind !== "meta_retargeting" || c.budgetMode !== "lifetime" || c.budgetOwner !== "adset" || BigInt(c.allocation.amountMicros) === 0n) fail3("campaign.optimization.policy.candidateChannelIds", "requires an original independently capped Meta adset channel");
|
|
587
606
|
}
|
|
588
607
|
}
|
|
589
608
|
}
|
|
@@ -600,10 +619,10 @@ function parseResonanceCampaignDraft(v) {
|
|
|
600
619
|
}
|
|
601
620
|
var RESONANCE_CAMPAIGN_DEFINITION_JSON_SCHEMA = definition.schema;
|
|
602
621
|
var RESONANCE_CAMPAIGN_DRAFT_JSON_SCHEMA = draft.schema;
|
|
603
|
-
var capability = object2({ id: uuid, projectId: uuid, connectionId: uuid, provider: choice2("google_ads", "meta_ads"), externalAccountId:
|
|
622
|
+
var capability = object2({ id: uuid, projectId: uuid, connectionId: uuid, provider: choice2("google_ads", "meta_ads"), externalAccountId: text3(160), currency, timeZone, connectionRevision: revision, capabilityRevision: revision, observedAt: instant, expiresAt: instant, advertiserState: choice2("eligible", "blocked", "unknown"), operations: list2(object2({ operation: choice2("discover", "prepare", "launch", "update", "pause", "resume", "finish", "reconcile", "measure", "audience", "conversion", "experiment"), state: choice2("supported", "blocked", "unknown"), reasonCodes: list2(text3(80), 30), prerequisites: list2(text3(100), 30) }), 20), profiles: list2(object2({ profile: choice2("google_search", "meta_retargeting"), state: choice2("supported", "blocked", "unknown"), reasonCodes: list2(text3(80), 30), budgetModes: list2(choice2("campaign_total", "average_daily", "lifetime", "daily"), 4), providerApiVersion: text3(30) }), 2) });
|
|
604
623
|
var parseResonanceAccountCapability = (v) => {
|
|
605
624
|
const r = capability.read(v, "account");
|
|
606
|
-
if (Date.parse(r.expiresAt) <= Date.parse(r.observedAt))
|
|
625
|
+
if (Date.parse(r.expiresAt) <= Date.parse(r.observedAt)) fail3("account.expiresAt", "must follow observation");
|
|
607
626
|
return r;
|
|
608
627
|
};
|
|
609
628
|
var mandateRef = object2({ ledgerActionId: uuid, campaignId: uuid, preparedPlanId: uuid, reviewDigest: digest, mandateDigest: digest, expectedKillRevision: integer2(0) });
|
|
@@ -631,23 +650,110 @@ var websiteVisitFeed = object2({ profile: literal2(RESONANCE_WEBSITE_VISIT_PROFI
|
|
|
631
650
|
matchingProfileRef
|
|
632
651
|
}), 100, 1) });
|
|
633
652
|
var RESONANCE_WEBSITE_VISIT_FEED_JSON_SCHEMA = websiteVisitFeed.schema;
|
|
634
|
-
var providerReportingChannelIds =
|
|
653
|
+
var providerReportingChannelIds = refine3(uniqueList(uuid, 100, 1), (ids, p) => unique(ids.map((id) => id.toLowerCase()), p));
|
|
635
654
|
var RESONANCE_META_QUERY_ATTRIBUTION_WINDOWS = ["1d_click", "7d_click", "1d_view"];
|
|
636
655
|
var metaReportingQuery = object2({ channelId: uuid, attributionWindow: choice2(...RESONANCE_META_QUERY_ATTRIBUTION_WINDOWS), actionReportTime: literal2("conversion"), basis: literal2("explicit_query") });
|
|
637
|
-
var providerReportingMetaQueries =
|
|
656
|
+
var providerReportingMetaQueries = refine3(list2(metaReportingQuery, 100, 1), (queries, p) => unique(queries.map((query) => query.channelId.toLowerCase()), p));
|
|
638
657
|
function checkReportingQuerySubset(v, p) {
|
|
639
|
-
if (v.metaQueries?.some((query) => !v.channelIds.some((id) => id.toLowerCase() === query.channelId.toLowerCase())))
|
|
658
|
+
if (v.metaQueries?.some((query) => !v.channelIds.some((id) => id.toLowerCase() === query.channelId.toLowerCase()))) fail3(p + ".metaQueries", "query channel must be selected");
|
|
640
659
|
}
|
|
641
|
-
var providerReportingSelection =
|
|
642
|
-
var providerReportingGrant =
|
|
643
|
-
if (v.agentContactId.toLowerCase() === v.principalContactId.toLowerCase())
|
|
660
|
+
var providerReportingSelection = refine3(object2({ agentContactId: uuid, channelIds: providerReportingChannelIds, metaQueries: optional2(providerReportingMetaQueries) }), checkReportingQuerySubset);
|
|
661
|
+
var providerReportingGrant = refine3(object2({ purpose: literal2("provider_reporting_refresh"), orgId: uuid, projectId: uuid, agentContactId: uuid, principalContactId: uuid, channelIds: providerReportingChannelIds, metaQueries: optional2(providerReportingMetaQueries), reportingUntil: optional2(instant) }), (v, p) => {
|
|
662
|
+
if (v.agentContactId.toLowerCase() === v.principalContactId.toLowerCase()) fail3(p + ".principalContactId", "agent and human principal must remain distinct");
|
|
644
663
|
checkReportingQuerySubset(v, p);
|
|
645
664
|
});
|
|
646
665
|
var parseResonanceProviderReportingSelection = (v) => providerReportingSelection.read(v, "providerReportingSelection");
|
|
647
666
|
var parseResonanceProviderReportingGrant = (v) => providerReportingGrant.read(v, "providerReportingGrant");
|
|
648
667
|
var RESONANCE_PROVIDER_REPORTING_SELECTION_JSON_SCHEMA = providerReportingSelection.schema;
|
|
649
668
|
var RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA = providerReportingGrant.schema;
|
|
650
|
-
var
|
|
669
|
+
var RESONANCE_PROVIDER_REPORTING_MAX_TAIL_DAYS = 92;
|
|
670
|
+
var googleContentTarget = { channelId: uuid, adGroupLocalKey: text3(80), adLocalKey: text3(80) };
|
|
671
|
+
var normalizeResonanceGoogleCriterionText = (value) => value.trim().replace(/\s+/gu, " ").toLowerCase().normalize("NFC");
|
|
672
|
+
var googleCriterionText = text3(80, /^(?! +$)[^\x00-\x1f\x7f]+$/);
|
|
673
|
+
var googleExactText = text3(80, /^(?! +$)[^\x00-\x1f\x7f\\\[\]"]+$/);
|
|
674
|
+
var googleContentKeywords = (criterion) => refine3(list2(criterion, 20), (items, p) => {
|
|
675
|
+
const normalized = items.map(normalizeResonanceGoogleCriterionText);
|
|
676
|
+
if (normalized.some((value) => !value || value.length > 80)) fail3(p, "requires nonempty bounded criterion text");
|
|
677
|
+
unique(normalized, p);
|
|
678
|
+
items.splice(0, items.length, ...normalized.sort());
|
|
679
|
+
});
|
|
680
|
+
var rsaAsset = (length) => refine3(text3(length, /^[^\x00-\x1f\x7f]+$/), (asset, p) => {
|
|
681
|
+
if (!asset.trim() || asset.trim() !== asset) fail3(p, "requires trimmed, nonempty asset text");
|
|
682
|
+
});
|
|
683
|
+
var googleContentRsa = object2({
|
|
684
|
+
creativeRef: resource,
|
|
685
|
+
headlines: uniqueList(rsaAsset(30), 15, 3),
|
|
686
|
+
descriptions: uniqueList(rsaAsset(90), 4, 2)
|
|
687
|
+
});
|
|
688
|
+
var googleContentMaterial = {
|
|
689
|
+
negativeRemovals: googleContentKeywords(googleCriterionText),
|
|
690
|
+
exactAdditions: googleContentKeywords(googleExactText),
|
|
691
|
+
rsa: nullable2(googleContentRsa)
|
|
692
|
+
};
|
|
693
|
+
var googleContentEntry = refine3(object2({ ...googleContentTarget, ...googleContentMaterial }), (entry, p) => {
|
|
694
|
+
if (!entry.negativeRemovals.length && !entry.exactAdditions.length && !entry.rsa) fail3(p, "must select at least one bounded content effect");
|
|
695
|
+
});
|
|
696
|
+
var googleSearchContent = refine3(list2(googleContentEntry, 100), (entries, p) => {
|
|
697
|
+
const identity = (entry) => JSON.stringify([entry.channelId.toLowerCase(), entry.adGroupLocalKey, entry.adLocalKey]);
|
|
698
|
+
unique(entries.map(identity), p);
|
|
699
|
+
entries.sort((a, b) => identity(a) < identity(b) ? -1 : identity(a) > identity(b) ? 1 : 0);
|
|
700
|
+
});
|
|
701
|
+
var operatingPolicyFields = {
|
|
702
|
+
schemaVersion: literal2(1),
|
|
703
|
+
agentContactId: uuid,
|
|
704
|
+
googleSearchContent,
|
|
705
|
+
cooldownSeconds: integer2(3600, 2592e3)
|
|
706
|
+
};
|
|
707
|
+
var operatingPolicySelection = object2(operatingPolicyFields);
|
|
708
|
+
var operatingPolicy = refine3(object2({ ...operatingPolicyFields, principalContactId: uuid }), (policy, p) => {
|
|
709
|
+
if (policy.agentContactId.toLowerCase() === policy.principalContactId.toLowerCase()) {
|
|
710
|
+
fail3(p + ".principalContactId", "agent and human principal must remain distinct");
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
var operatingPolicyRef = object2({ ledgerActionId: uuid, receiptId: uuid, digest });
|
|
714
|
+
var operatingPolicyBase = object2({
|
|
715
|
+
ledgerActionId: uuid,
|
|
716
|
+
acceptanceReceiptId: uuid,
|
|
717
|
+
expectedKillRevision: integer2(0),
|
|
718
|
+
previousOperatingPolicyRef: nullable2(operatingPolicyRef)
|
|
719
|
+
});
|
|
720
|
+
var operatingPolicyActionIdentity = object2({ mandateDigest: digest, operatingPolicyBase });
|
|
721
|
+
var googleContentUpdateSelection = object2(googleContentTarget);
|
|
722
|
+
var googleContentUpdate = refine3(object2({ ...googleContentTarget, ...googleContentMaterial, policyRef: operatingPolicyRef, beforeDigest: digest }), (update2, p) => {
|
|
723
|
+
if (!update2.negativeRemovals.length && !update2.exactAdditions.length && !update2.rsa) fail3(p, "must select at least one bounded content effect");
|
|
724
|
+
});
|
|
725
|
+
var parseResonanceOperatingPolicy = (v) => operatingPolicy.read(v, "operatingPolicy");
|
|
726
|
+
var parseResonanceOperatingPolicySelection = (v) => operatingPolicySelection.read(v, "operatingPolicySelection");
|
|
727
|
+
var parseResonanceOperatingPolicyBase = (v) => operatingPolicyBase.read(v, "operatingPolicyBase");
|
|
728
|
+
var parseResonanceOperatingPolicyRef = (v) => operatingPolicyRef.read(v, "operatingPolicyRef");
|
|
729
|
+
var parseResonanceGoogleContentUpdateSelection = (v) => googleContentUpdateSelection.read(v, "googleContentUpdateSelection");
|
|
730
|
+
var parseResonanceGoogleContentUpdate = (v) => googleContentUpdate.read(v, "googleContentUpdate");
|
|
731
|
+
var resonanceOperatingPolicyDigestInput = (v) => canonical(parseResonanceOperatingPolicy(v));
|
|
732
|
+
function resonanceOperatingPolicyActionDigestInput(v) {
|
|
733
|
+
const { mandateDigest, operatingPolicyBase: base } = operatingPolicyActionIdentity.read(v, "operatingPolicyActionIdentity");
|
|
734
|
+
const previous = base.previousOperatingPolicyRef;
|
|
735
|
+
return canonical({
|
|
736
|
+
kind: "resonance_operating_policy_activation_v1",
|
|
737
|
+
mandateDigest,
|
|
738
|
+
operatingPolicyBase: {
|
|
739
|
+
...base,
|
|
740
|
+
ledgerActionId: base.ledgerActionId.toLowerCase(),
|
|
741
|
+
acceptanceReceiptId: base.acceptanceReceiptId.toLowerCase(),
|
|
742
|
+
previousOperatingPolicyRef: previous && {
|
|
743
|
+
...previous,
|
|
744
|
+
ledgerActionId: previous.ledgerActionId.toLowerCase(),
|
|
745
|
+
receiptId: previous.receiptId.toLowerCase()
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
var RESONANCE_OPERATING_POLICY_JSON_SCHEMA = operatingPolicy.schema;
|
|
751
|
+
var RESONANCE_OPERATING_POLICY_SELECTION_JSON_SCHEMA = operatingPolicySelection.schema;
|
|
752
|
+
var RESONANCE_OPERATING_POLICY_BASE_JSON_SCHEMA = operatingPolicyBase.schema;
|
|
753
|
+
var RESONANCE_OPERATING_POLICY_REF_JSON_SCHEMA = operatingPolicyRef.schema;
|
|
754
|
+
var RESONANCE_GOOGLE_CONTENT_UPDATE_SELECTION_JSON_SCHEMA = googleContentUpdateSelection.schema;
|
|
755
|
+
var RESONANCE_GOOGLE_CONTENT_UPDATE_JSON_SCHEMA = googleContentUpdate.schema;
|
|
756
|
+
var mandateScope = object2({ projectId: uuid, campaignId: uuid, preparedPlanId: uuid, reviewDigest: digest, accountBindingIds: list2(uuid, 100), sites: list2(site, 50, 1), budget, creativeRefs: list2(creative, 100, 1), audienceRuleRefs: list2(audience, 100), goal: objective, allowedOperations: mandateAllowedOperations, allowedTransformationRef: nullable2(resource), expiresAt: instant, websiteVisitFeed: optional2(websiteVisitFeed), providerReporting: optional2(providerReportingGrant), operatingPolicy: optional2(operatingPolicy) });
|
|
651
757
|
function parseResonanceMandateScope(v, preparedPlan) {
|
|
652
758
|
const r = mandateScope.read(v, "mandateScope");
|
|
653
759
|
scoped(r, r.projectId, r.sites, "mandateScope");
|
|
@@ -655,17 +761,43 @@ function parseResonanceMandateScope(v, preparedPlan) {
|
|
|
655
761
|
unique(r.websiteVisitFeed.channels.map((c) => c.channelId), "mandateScope.websiteVisitFeed.channels");
|
|
656
762
|
for (const c of r.websiteVisitFeed.channels) unique(c.resourceRuleRefs.map((rule) => rule.id), "mandateScope.websiteVisitFeed.resourceRuleRefs");
|
|
657
763
|
}
|
|
764
|
+
if (r.operatingPolicy) {
|
|
765
|
+
const p = "mandateScope.operatingPolicy";
|
|
766
|
+
if (Date.parse(r.expiresAt) <= Date.parse(r.budget.startAt) || Date.parse(r.expiresAt) > Date.parse(r.budget.endAt)) {
|
|
767
|
+
fail3(p, "operating policy remains inside the original mandate flight and expiry");
|
|
768
|
+
}
|
|
769
|
+
if (r.operatingPolicy.googleSearchContent.length && !r.allowedOperations.includes("update")) {
|
|
770
|
+
fail3(p, "Google content requires the update operation");
|
|
771
|
+
}
|
|
772
|
+
if (preparedPlan !== void 0) {
|
|
773
|
+
const plan = parseResonancePreparedPlan(preparedPlan);
|
|
774
|
+
if (r.projectId !== plan.projectId || r.campaignId !== plan.campaignId || r.preparedPlanId !== plan.id || r.reviewDigest !== plan.reviewDigest || canonical(r.goal) !== canonical(plan.definition.objective) || canonical(r.budget) !== canonical(plan.definition.budget)) fail3(p, "requires the exact original plan, review, goal and flight");
|
|
775
|
+
for (const entry of r.operatingPolicy.googleSearchContent) {
|
|
776
|
+
const channel2 = plan.definition.channels.find((item) => item.id.toLowerCase() === entry.channelId.toLowerCase());
|
|
777
|
+
if (channel2?.kind !== "google_search") return fail3(p, "requires an original Google Search channel");
|
|
778
|
+
const group = channel2.adGroups.find((item) => item.localKey === entry.adGroupLocalKey);
|
|
779
|
+
if (!r.sites.includes(channel2.site) || !r.accountBindingIds.includes(channel2.accountBindingId) || !group?.ads.some((ad) => ad.localKey === entry.adLocalKey) || entry.rsa && entry.rsa.creativeRef.site !== channel2.site) fail3(p, "requires the original account, site, ad group and ad");
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
658
783
|
if (r.providerReporting) {
|
|
659
784
|
const grant = r.providerReporting, p = "mandateScope.providerReporting";
|
|
660
|
-
if (grant.projectId !== r.projectId)
|
|
661
|
-
|
|
785
|
+
if (grant.projectId !== r.projectId) fail3(p + ".projectId", "must match the original mandate project");
|
|
786
|
+
const flightEnd = Date.parse(r.budget.endAt);
|
|
787
|
+
if (Date.parse(r.expiresAt) <= Date.parse(r.budget.startAt) || Date.parse(r.expiresAt) > flightEnd) fail3(p, "mandate expiry remains inside the original flight");
|
|
788
|
+
if (grant.reportingUntil !== void 0) {
|
|
789
|
+
const deadline = Date.parse(grant.reportingUntil);
|
|
790
|
+
if (deadline <= flightEnd || deadline > flightEnd + RESONANCE_PROVIDER_REPORTING_MAX_TAIL_DAYS * 864e5) {
|
|
791
|
+
fail3(p + ".reportingUntil", "must follow the original flight by no more than 92 elapsed days");
|
|
792
|
+
}
|
|
793
|
+
}
|
|
662
794
|
if (preparedPlan !== void 0) {
|
|
663
795
|
const plan = parseResonancePreparedPlan(preparedPlan);
|
|
664
|
-
if (r.projectId !== plan.projectId || r.campaignId !== plan.campaignId || r.preparedPlanId !== plan.id || r.reviewDigest !== plan.reviewDigest || canonical(r.goal) !== canonical(plan.definition.objective) || canonical(r.budget) !== canonical(plan.definition.budget))
|
|
665
|
-
if (r.sites.some((site2) => !plan.definition.sites.includes(site2)) || r.accountBindingIds.some((id) => !plan.accounts.some((account) => account.id === id)))
|
|
796
|
+
if (r.projectId !== plan.projectId || r.campaignId !== plan.campaignId || r.preparedPlanId !== plan.id || r.reviewDigest !== plan.reviewDigest || canonical(r.goal) !== canonical(plan.definition.objective) || canonical(r.budget) !== canonical(plan.definition.budget)) fail3(p, "requires the exact original plan, review, goal and flight");
|
|
797
|
+
if (r.sites.some((site2) => !plan.definition.sites.includes(site2)) || r.accountBindingIds.some((id) => !plan.accounts.some((account) => account.id === id))) fail3(p, "mandate sites and accounts must stay inside the original plan");
|
|
666
798
|
for (const id of grant.channelIds) {
|
|
667
799
|
const channel2 = plan.definition.channels.find((c) => c.id.toLowerCase() === id.toLowerCase());
|
|
668
|
-
if (!channel2 || !("provider" in channel2) || !r.sites.includes(channel2.site) || !r.accountBindingIds.includes(channel2.accountBindingId))
|
|
800
|
+
if (!channel2 || !("provider" in channel2) || !r.sites.includes(channel2.site) || !r.accountBindingIds.includes(channel2.accountBindingId)) fail3(p + ".channelIds", "requires an explicit original paid channel inside mandate sites and accounts");
|
|
669
801
|
}
|
|
670
802
|
}
|
|
671
803
|
}
|
|
@@ -676,7 +808,7 @@ function resonanceWebsiteVisitEventTime(value, context) {
|
|
|
676
808
|
const input = websiteVisitTimes.read(value, "websiteVisitTime");
|
|
677
809
|
const actual = object2({ mandate: mandateScope, approvedAt: instant, now: instant }).read(context, "websiteVisitTime.context");
|
|
678
810
|
const grant = parseResonanceMandateScope(actual.mandate);
|
|
679
|
-
if (!grant.websiteVisitFeed)
|
|
811
|
+
if (!grant.websiteVisitFeed) fail3("websiteVisitTime.context.mandate.websiteVisitFeed", "requires an explicit original feed selection");
|
|
680
812
|
const start = Math.max(Date.parse(grant.budget.startAt), Date.parse(actual.approvedAt));
|
|
681
813
|
const end = Math.min(Date.parse(grant.budget.endAt), Date.parse(grant.expiresAt));
|
|
682
814
|
return websiteVisitEventTime(input, start, end, Date.parse(actual.now));
|
|
@@ -684,8 +816,8 @@ function resonanceWebsiteVisitEventTime(value, context) {
|
|
|
684
816
|
function websiteVisitEventTime(input, start, end, now) {
|
|
685
817
|
const occurred = Date.parse(input.occurredAt), received = Date.parse(input.receivedAt);
|
|
686
818
|
const policy = RESONANCE_WEBSITE_VISIT_PROFILE;
|
|
687
|
-
if (received < occurred - policy.maxFutureSkewMs || received - occurred > policy.maxCaptureAgeMs || now < received || now < occurred - policy.maxFutureSkewMs || now - occurred > policy.maxDispatchAgeMs)
|
|
688
|
-
if (occurred < start || received < start || occurred >= end || received >= end || now >= end)
|
|
819
|
+
if (received < occurred - policy.maxFutureSkewMs || received - occurred > policy.maxCaptureAgeMs || now < received || now < occurred - policy.maxFutureSkewMs || now - occurred > policy.maxDispatchAgeMs) fail3("websiteVisitTime", "outside the local original observation freshness profile");
|
|
820
|
+
if (occurred < start || received < start || occurred >= end || received >= end || now >= end) fail3("websiteVisitTime", "outside the original approval and dispatch window");
|
|
689
821
|
return Math.floor(occurred / 1e3);
|
|
690
822
|
}
|
|
691
823
|
var RESONANCE_GOOGLE_SIGNAL_SEMANTICS = "qualified_at_observation_v1";
|
|
@@ -699,13 +831,13 @@ function googleConversionActionSemantics(input) {
|
|
|
699
831
|
var googleSetupPolicyInput = object2({ source, countingUnit: objectiveCountingUnit, attributionWindowDays: integer2(1, 365) });
|
|
700
832
|
function googleUploadClicksSetupSemantics(input) {
|
|
701
833
|
const v = googleSetupPolicyInput.read(input, "googleSetupPolicy");
|
|
702
|
-
if (v.source.kind !== "qualified_lead" || v.countingUnit !== "unique_qualified_contact")
|
|
703
|
-
if (v.attributionWindowDays > 90)
|
|
834
|
+
if (v.source.kind !== "qualified_lead" || v.countingUnit !== "unique_qualified_contact") fail3("googleSetupPolicy", "unsupported_counting_policy");
|
|
835
|
+
if (v.attributionWindowDays > 90) fail3("googleSetupPolicy.attributionWindowDays", "unsupported_attribution_window");
|
|
704
836
|
return { ...googleConversionActionSemantics({ sourceKind: v.source.kind, counting: "one", clickWindowDays: v.attributionWindowDays }), category: RESONANCE_GOOGLE_SOURCE_CATEGORIES.qualified_lead, countingType: "ONE_PER_CLICK" };
|
|
705
837
|
}
|
|
706
838
|
var googleGoalChoiceFields = {
|
|
707
|
-
externalId:
|
|
708
|
-
actionIds: list2(
|
|
839
|
+
externalId: text3(160, /^customers\/[0-9]+\/customConversionGoals\/[0-9]+$/),
|
|
840
|
+
actionIds: list2(text3(160, /^customers\/[0-9]+\/conversionActions\/[0-9]+$/), 100, 1)
|
|
709
841
|
};
|
|
710
842
|
var googleDeclarationChoiceFields = {
|
|
711
843
|
statement: literal2("DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING"),
|
|
@@ -721,10 +853,10 @@ var googleSetupSpec = object2({
|
|
|
721
853
|
kind: literal2("google_upload_clicks_custom_goal_v1"),
|
|
722
854
|
signalSemantics: googleSignalSemantics,
|
|
723
855
|
goalLocalKey: literal2("setup:custom-goal"),
|
|
724
|
-
requestedGoalName:
|
|
856
|
+
requestedGoalName: text3(160),
|
|
725
857
|
action: object2({
|
|
726
858
|
localKey: literal2("setup:conversion-action"),
|
|
727
|
-
requestedActionName:
|
|
859
|
+
requestedActionName: text3(160),
|
|
728
860
|
type: literal2("UPLOAD_CLICKS"),
|
|
729
861
|
category: literal2(RESONANCE_GOOGLE_SOURCE_CATEGORIES.qualified_lead),
|
|
730
862
|
countingType: literal2("ONE_PER_CLICK"),
|
|
@@ -739,20 +871,20 @@ var resonanceGoogleSetupDigestInput = (value) => canonical(parseResonanceGoogleU
|
|
|
739
871
|
var googleSaveCommonFields = { schemaVersion: literal2(1), expectedCampaignRevision: integer2(1), expectedRevision: integer2(0), idempotencyKey: operationKey, signalSemantics: googleSignalSemantics, declaration: object2(googleDeclarationChoiceFields) };
|
|
740
872
|
var googleSave = union2(
|
|
741
873
|
object2({ ...googleSaveCommonFields, mode: literal2("existing"), nativeGoal: object2(googleGoalChoiceFields) }),
|
|
742
|
-
object2({ ...googleSaveCommonFields, mode: literal2("admitted_setup"), setupIntent: object2({ requestedGoalName:
|
|
874
|
+
object2({ ...googleSaveCommonFields, mode: literal2("admitted_setup"), setupIntent: object2({ requestedGoalName: text3(160), requestedActionName: text3(160) }) })
|
|
743
875
|
);
|
|
744
876
|
function parseResonanceGoogleConfigurationSaveCommand(value) {
|
|
745
877
|
const result = googleSave.read(value, "googleConfigurationSave");
|
|
746
878
|
if (result.mode === "existing") normalizeGoogleGoal(result.nativeGoal, "googleConfigurationSave.nativeGoal");
|
|
747
879
|
return result;
|
|
748
880
|
}
|
|
749
|
-
var googleGoalDraft = object2({ ...googleGoalChoiceFields, name: nullable2(
|
|
750
|
-
var googleGoalReviewed = object2({ ...googleGoalChoiceFields, name:
|
|
881
|
+
var googleGoalDraft = object2({ ...googleGoalChoiceFields, name: nullable2(text3(200, void 0, 0)), revision: nullable2(digest) });
|
|
882
|
+
var googleGoalReviewed = object2({ ...googleGoalChoiceFields, name: text3(200, void 0, 0), revision: digest });
|
|
751
883
|
var googleDeclared = object2({
|
|
752
884
|
...googleDeclarationChoiceFields,
|
|
753
885
|
creativeDigest: digest,
|
|
754
|
-
locationIds: list2(
|
|
755
|
-
excludedLocationIds: list2(
|
|
886
|
+
locationIds: list2(text3(80), 100, 1),
|
|
887
|
+
excludedLocationIds: list2(text3(80), 100),
|
|
756
888
|
declaredByActorId: uuid,
|
|
757
889
|
declaredAt: instant,
|
|
758
890
|
declaredForCampaignRevision: integer2(1)
|
|
@@ -775,7 +907,7 @@ var googleConfigurationFields = {
|
|
|
775
907
|
var googleExistingChoiceFields = { mode: literal2("existing"), nativeGoal: googleGoalDraft };
|
|
776
908
|
var googleSetupChoiceFields = { mode: literal2("admitted_setup"), setupSpec: googleSetupSpec, setupDigest: digest };
|
|
777
909
|
function checkGoogleConfiguration(value, at) {
|
|
778
|
-
if (value.source.projectId !== value.projectId || value.source.site !== value.site)
|
|
910
|
+
if (value.source.projectId !== value.projectId || value.source.site !== value.site) fail3(at + ".source", "source scope mismatch");
|
|
779
911
|
unique(value.declaration.locationIds, at + ".declaration.locationIds");
|
|
780
912
|
unique(value.declaration.excludedLocationIds, at + ".declaration.excludedLocationIds");
|
|
781
913
|
value.declaration.locationIds.sort();
|
|
@@ -785,28 +917,28 @@ function checkGoogleConfiguration(value, at) {
|
|
|
785
917
|
normalizeGoogleGoal(value.nativeGoal, at + ".nativeGoal");
|
|
786
918
|
return;
|
|
787
919
|
}
|
|
788
|
-
if (canonical({ type: value.setupSpec.action.type, category: value.setupSpec.action.category, countingType: value.setupSpec.action.countingType, clickThroughLookbackWindowDays: value.setupSpec.action.clickThroughLookbackWindowDays, primaryForGoal: value.setupSpec.action.primaryForGoal }) !== canonical(expected))
|
|
920
|
+
if (canonical({ type: value.setupSpec.action.type, category: value.setupSpec.action.category, countingType: value.setupSpec.action.countingType, clickThroughLookbackWindowDays: value.setupSpec.action.clickThroughLookbackWindowDays, primaryForGoal: value.setupSpec.action.primaryForGoal }) !== canonical(expected)) fail3(at + ".setupSpec.action", "canonical setup semantics mismatch");
|
|
789
921
|
}
|
|
790
922
|
var googleSnapshotBase = union2(object2({ ...googleConfigurationFields, ...googleExistingChoiceFields }), object2({ ...googleConfigurationFields, ...googleSetupChoiceFields }));
|
|
791
|
-
var googleConfigurationSnapshot =
|
|
792
|
-
var googleConfigurationReview =
|
|
923
|
+
var googleConfigurationSnapshot = refine3(googleSnapshotBase, checkGoogleConfiguration);
|
|
924
|
+
var googleConfigurationReview = refine3(union2(object2({ ...googleConfigurationFields, mode: literal2("existing"), nativeGoal: googleGoalReviewed }), object2({ ...googleConfigurationFields, ...googleSetupChoiceFields })), checkGoogleConfiguration);
|
|
793
925
|
var parseResonanceGoogleConfigurationSnapshot = (value) => googleConfigurationSnapshot.read(value, "googleConfiguration");
|
|
794
926
|
var parseResonanceGoogleConfigurationReview = (value) => googleConfigurationReview.read(value, "googleConfigurationReview");
|
|
795
927
|
var { configurationRevision: _configurationRevisionField, ...googleViewContentFields } = googleConfigurationFields;
|
|
796
|
-
var googleReadinessFields = { ready: bool, activationReadiness: choice2("blocked", "pending_setup", "requires_final_verification", "verified"), reasonCodes: list2(
|
|
928
|
+
var googleReadinessFields = { ready: bool, activationReadiness: choice2("blocked", "pending_setup", "requires_final_verification", "verified"), reasonCodes: list2(text3(200), 100) };
|
|
797
929
|
var googleViewFields = { ...googleViewContentFields, revision: integer2(1), ...googleReadinessFields };
|
|
798
930
|
var googleViewBase = union2(object2({ ...googleViewFields, ...googleExistingChoiceFields }), object2({ ...googleViewFields, ...googleSetupChoiceFields }));
|
|
799
931
|
function checkGoogleView(value, at) {
|
|
800
932
|
checkGoogleConfiguration(value, at);
|
|
801
|
-
if (!value.ready && value.activationReadiness !== "blocked")
|
|
933
|
+
if (!value.ready && value.activationReadiness !== "blocked") fail3(at + ".activationReadiness", "unready configuration must be blocked");
|
|
802
934
|
if (value.mode === "existing") {
|
|
803
|
-
if (value.ready && (value.nativeGoal.name === null || value.nativeGoal.revision === null))
|
|
804
|
-
if (value.ready && value.activationReadiness !== "requires_final_verification" && value.activationReadiness !== "verified")
|
|
805
|
-
} else if (value.ready && value.activationReadiness !== "pending_setup")
|
|
935
|
+
if (value.ready && (value.nativeGoal.name === null || value.nativeGoal.revision === null)) fail3(at + ".ready", "unavailable native evidence cannot be ready");
|
|
936
|
+
if (value.ready && value.activationReadiness !== "requires_final_verification" && value.activationReadiness !== "verified") fail3(at + ".activationReadiness", "existing native setup needs current verification");
|
|
937
|
+
} else if (value.ready && value.activationReadiness !== "pending_setup") fail3(at + ".activationReadiness", "reviewed setup intent is not native activation");
|
|
806
938
|
}
|
|
807
|
-
var googleConfigurationView =
|
|
939
|
+
var googleConfigurationView = refine3(googleViewBase, checkGoogleView);
|
|
808
940
|
var googleSaveResultFields = { operationId: uuid, replayed: bool, campaignRevision: integer2(1) };
|
|
809
|
-
var googleConfigurationSaveResponse =
|
|
941
|
+
var googleConfigurationSaveResponse = refine3(union2(object2({ ...googleViewFields, ...googleExistingChoiceFields, ...googleSaveResultFields }), object2({ ...googleViewFields, ...googleSetupChoiceFields, ...googleSaveResultFields })), checkGoogleView);
|
|
810
942
|
var parseResonanceGoogleConfigurationView = (value) => googleConfigurationView.read(value, "googleConfigurationView");
|
|
811
943
|
var parseResonanceGoogleConfigurationSaveResponse = (value) => googleConfigurationSaveResponse.read(value, "googleConfigurationSaveResponse");
|
|
812
944
|
function projectResonanceGoogleConfiguration(value, readiness) {
|
|
@@ -819,7 +951,7 @@ function projectResonanceGoogleConfiguration(value, readiness) {
|
|
|
819
951
|
function googleReadiness() {
|
|
820
952
|
return object2(googleReadinessFields);
|
|
821
953
|
}
|
|
822
|
-
var googleConfigurationDigestValue =
|
|
954
|
+
var googleConfigurationDigestValue = refine3(union2(object2({ ...googleConfigurationFields, ...googleExistingChoiceFields, configurationDigest: optional2(digest) }), object2({ ...googleConfigurationFields, ...googleSetupChoiceFields, configurationDigest: optional2(digest) })), checkGoogleConfiguration);
|
|
823
955
|
function resonanceGoogleConfigurationDigestInput(value) {
|
|
824
956
|
const { configurationDigest: _self, ...content } = googleConfigurationDigestValue.read(value, "googleConfigurationDigestInput");
|
|
825
957
|
return canonical(content);
|
|
@@ -830,9 +962,9 @@ var RESONANCE_GOOGLE_CONFIGURATION_SNAPSHOT_JSON_SCHEMA = googleConfigurationSna
|
|
|
830
962
|
var RESONANCE_GOOGLE_CONFIGURATION_REVIEW_JSON_SCHEMA = googleConfigurationReview.schema;
|
|
831
963
|
var RESONANCE_GOOGLE_CONFIGURATION_VIEW_JSON_SCHEMA = googleConfigurationView.schema;
|
|
832
964
|
var RESONANCE_GOOGLE_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA = googleConfigurationSaveResponse.schema;
|
|
833
|
-
var preparedManifestRef = object2({ id: uuid, digest, providerVersion:
|
|
834
|
-
var preview = object2({ channelId: uuid, site, accountBindingId: nullable2(uuid), accountName:
|
|
835
|
-
var prepared = object2({ schemaVersion: literal2(1), id: uuid, campaignId: uuid, projectId: uuid, expectedRevision: integer2(1), definitionDigest: digest, reviewDigest: digest, definition, resolvedEvidencePolicy: optimizationPolicy, resolvedQualificationRule: nullable2(resolvedQualificationRule), accounts: list2(capability, 100), channelPreviews: list2(preview, 100, 1), preparedAt: instant, expiresAt: instant, blockingReasons: list2(
|
|
965
|
+
var preparedManifestRef = object2({ id: uuid, digest, providerVersion: text3(30), revision });
|
|
966
|
+
var preview = object2({ channelId: uuid, site, accountBindingId: nullable2(uuid), accountName: text3(200), accountTimeZone: timeZone, destinationUrl: text3(4096), attributionMarker: optional2(object2({ parameter: literal2(RESONANCE_SOURCE_MARKER_PARAMETER), value: sourceMarker })), orderedCreatives: list2(creative, 50, 1), audienceRuleRefs: list2(audience, 100), allocation: nullable2(money), capabilityRevision: revision, snapshotDigest: digest, manifestRef: preparedManifestRef, conversionRevision: revision, policyRevision: revision, googleConfiguration: nullable2(googleConfigurationReview) });
|
|
967
|
+
var prepared = object2({ schemaVersion: literal2(1), id: uuid, campaignId: uuid, projectId: uuid, expectedRevision: integer2(1), definitionDigest: digest, reviewDigest: digest, definition, resolvedEvidencePolicy: optimizationPolicy, resolvedQualificationRule: nullable2(resolvedQualificationRule), accounts: list2(capability, 100), channelPreviews: list2(preview, 100, 1), preparedAt: instant, expiresAt: instant, blockingReasons: list2(text3(200), 100) });
|
|
836
968
|
function bookingTypesMatch(goalIds, witnessIds) {
|
|
837
969
|
const norm = (ids) => ids === void 0 ? null : [...ids].map((id) => id.toLowerCase()).sort();
|
|
838
970
|
return canonical(norm(goalIds)) === canonical(norm(witnessIds));
|
|
@@ -841,139 +973,167 @@ function parseResonancePreparedPlan(v) {
|
|
|
841
973
|
const r = prepared.read(v, "preparedPlan");
|
|
842
974
|
checkDefinition(r.definition);
|
|
843
975
|
scoped(r, r.projectId, r.definition.sites, "preparedPlan");
|
|
844
|
-
if (Date.parse(r.expiresAt) <= Date.parse(r.preparedAt))
|
|
976
|
+
if (Date.parse(r.expiresAt) <= Date.parse(r.preparedAt)) fail3("preparedPlan.expiresAt", "must follow preparation");
|
|
845
977
|
const goal = r.definition.objective, witness = r.resolvedQualificationRule;
|
|
846
978
|
if (goal.source.kind === "qualified_lead") {
|
|
847
|
-
if (!goal.qualificationRule || !goal.qualificationRuleRef || !witness)
|
|
979
|
+
if (!goal.qualificationRule || !goal.qualificationRuleRef || !witness) fail3("preparedPlan.resolvedQualificationRule", "qualified-lead preparation requires actual configured native witness");
|
|
848
980
|
const w = witness, selected = goal.qualificationRule;
|
|
849
|
-
if (goal.countingUnit !== "unique_qualified_contact" || canonical(w.ref) !== canonical(goal.qualificationRuleRef) || w.eligibleFormIds.length !== 1 || w.eligibleFormIds[0] !== goal.source.id || !bookingTypesMatch(goal.eligibleBookingTypeIds, w.eligibleBookingTypeIds) || w.cohort.maturityDelaySeconds !== goal.maturityDelaySeconds)
|
|
850
|
-
for (const key of ["schemaVersion", "semantics", "positiveStageKeys", "finalNegativeStageKeys", "pendingStageKeys", "existingContactPolicy"]) if (canonical(w[key]) !== canonical(selected[key]))
|
|
851
|
-
} else if (witness !== null)
|
|
852
|
-
if (canonical(r.resolvedEvidencePolicy) !== canonical(r.definition.optimization.policy))
|
|
981
|
+
if (goal.countingUnit !== "unique_qualified_contact" || canonical(w.ref) !== canonical(goal.qualificationRuleRef) || w.eligibleFormIds.length !== 1 || w.eligibleFormIds[0] !== goal.source.id || !bookingTypesMatch(goal.eligibleBookingTypeIds, w.eligibleBookingTypeIds) || w.cohort.maturityDelaySeconds !== goal.maturityDelaySeconds) fail3("preparedPlan.resolvedQualificationRule", "source, counting unit, reference or maturity mismatch");
|
|
982
|
+
for (const key of ["schemaVersion", "semantics", "positiveStageKeys", "finalNegativeStageKeys", "pendingStageKeys", "existingContactPolicy"]) if (canonical(w[key]) !== canonical(selected[key])) fail3("preparedPlan.resolvedQualificationRule", "selected qualification snapshot mismatch");
|
|
983
|
+
} else if (witness !== null) fail3("preparedPlan.resolvedQualificationRule", "nonqualified objectives require explicit null");
|
|
984
|
+
if (canonical(r.resolvedEvidencePolicy) !== canonical(r.definition.optimization.policy)) fail3("preparedPlan.resolvedEvidencePolicy", "policy snapshot mismatch");
|
|
853
985
|
parseResonanceOptimizationPolicy(r.resolvedEvidencePolicy);
|
|
854
|
-
if (r.resolvedEvidencePolicy.algorithm === "finite_meta_candidates_v1" && Date.parse(r.resolvedEvidencePolicy.expiresAt) <= Date.parse(r.preparedAt))
|
|
986
|
+
if (r.resolvedEvidencePolicy.algorithm === "finite_meta_candidates_v1" && Date.parse(r.resolvedEvidencePolicy.expiresAt) <= Date.parse(r.preparedAt)) fail3("preparedPlan.resolvedEvidencePolicy.expiresAt", "finite policy expired before preparation");
|
|
855
987
|
unique(r.accounts.map((a) => a.id), "preparedPlan.accounts");
|
|
856
988
|
unique(r.channelPreviews.map((p) => p.channelId), "preparedPlan.channelPreviews");
|
|
857
|
-
if (r.channelPreviews.length !== r.definition.channels.length)
|
|
989
|
+
if (r.channelPreviews.length !== r.definition.channels.length) fail3("preparedPlan.channelPreviews", "must cover every channel");
|
|
858
990
|
for (const a of r.accounts) parseResonanceAccountCapability(a);
|
|
859
991
|
for (const p of r.channelPreviews) {
|
|
860
|
-
const c = r.definition.channels.find((c2) => c2.id === p.channelId) ??
|
|
861
|
-
if (c.site !== p.site)
|
|
992
|
+
const c = r.definition.channels.find((c2) => c2.id === p.channelId) ?? fail3("preparedPlan.channelPreviews", "unknown channel");
|
|
993
|
+
if (c.site !== p.site) fail3("preparedPlan.channelPreviews", "channel scope mismatch");
|
|
862
994
|
const google = p.googleConfiguration;
|
|
863
995
|
if (c.kind === "google_search") {
|
|
864
|
-
if (!google)
|
|
996
|
+
if (!google) fail3("preparedPlan.channelPreviews.googleConfiguration", "Google requires the actual reviewed configuration");
|
|
865
997
|
const g = google;
|
|
866
|
-
if (g.projectId !== r.projectId || g.campaignId !== r.campaignId || g.channelId !== c.id || g.site !== c.site || g.accountBindingId !== c.accountBindingId)
|
|
867
|
-
if (canonical(g.source) !== canonical(goal.source) || g.measurementRevision !== goal.measurementRevision || g.countingUnit !== goal.countingUnit || g.attributionWindowDays !== goal.attributionWindowDays)
|
|
998
|
+
if (g.projectId !== r.projectId || g.campaignId !== r.campaignId || g.channelId !== c.id || g.site !== c.site || g.accountBindingId !== c.accountBindingId) fail3("preparedPlan.channelPreviews.googleConfiguration", "configuration scope mismatch");
|
|
999
|
+
if (canonical(g.source) !== canonical(goal.source) || g.measurementRevision !== goal.measurementRevision || g.countingUnit !== goal.countingUnit || g.attributionWindowDays !== goal.attributionWindowDays) fail3("preparedPlan.channelPreviews.googleConfiguration.source", "objective measurement mismatch");
|
|
868
1000
|
unique(c.locationIds, "preparedPlan.channelPreviews.googleConfiguration.locationIds");
|
|
869
1001
|
unique(c.excludedLocationIds, "preparedPlan.channelPreviews.googleConfiguration.excludedLocationIds");
|
|
870
|
-
if (canonical(g.declaration.locationIds) !== canonical([...c.locationIds].sort()) || canonical(g.declaration.excludedLocationIds) !== canonical([...c.excludedLocationIds].sort()))
|
|
871
|
-
if (g.declaration.declaredForCampaignRevision > r.expectedRevision || Date.parse(g.declaration.declaredAt) > Date.parse(r.preparedAt))
|
|
872
|
-
} else if (google !== null)
|
|
1002
|
+
if (canonical(g.declaration.locationIds) !== canonical([...c.locationIds].sort()) || canonical(g.declaration.excludedLocationIds) !== canonical([...c.excludedLocationIds].sort())) fail3("preparedPlan.channelPreviews.googleConfiguration.declaration", "region scope mismatch");
|
|
1003
|
+
if (g.declaration.declaredForCampaignRevision > r.expectedRevision || Date.parse(g.declaration.declaredAt) > Date.parse(r.preparedAt)) fail3("preparedPlan.channelPreviews.googleConfiguration.declaration", "declaration follows preparation scope");
|
|
1004
|
+
} else if (google !== null) fail3("preparedPlan.channelPreviews.googleConfiguration", "non-Google channels require explicit null");
|
|
873
1005
|
const d = r.definition.destinations.find((d2) => d2.id === c.destinationId);
|
|
874
1006
|
const expectedUrl = p.attributionMarker ? new URL(`https://${p.site}${d.path}`) : null;
|
|
875
1007
|
if (expectedUrl && p.attributionMarker) expectedUrl.searchParams.set(RESONANCE_SOURCE_MARKER_PARAMETER, p.attributionMarker.value);
|
|
876
|
-
if (!sameSite(hostFromUrl(p.destinationUrl), p.site) || p.destinationUrl !== (expectedUrl?.toString() ?? `https://${p.site}${d.path}`))
|
|
877
|
-
if (canonical(p.orderedCreatives) !== canonical(c.creativeIds.map((id) => r.definition.creativeRefs.find((x) => x.id === id))))
|
|
1008
|
+
if (!sameSite(hostFromUrl(p.destinationUrl), p.site) || p.destinationUrl !== (expectedUrl?.toString() ?? `https://${p.site}${d.path}`)) fail3("preparedPlan.channelPreviews.destinationUrl", "must be exact HTTPS destination and reviewed source marker on the owned site");
|
|
1009
|
+
if (canonical(p.orderedCreatives) !== canonical(c.creativeIds.map((id) => r.definition.creativeRefs.find((x) => x.id === id)))) fail3("preparedPlan.channelPreviews.orderedCreatives", "creative order/content mismatch");
|
|
878
1010
|
if ("provider" in c) {
|
|
879
|
-
if (p.accountBindingId !== c.accountBindingId || !r.accounts.some((a) => a.id === c.accountBindingId))
|
|
880
|
-
if (canonical(p.allocation) !== canonical(c.allocation))
|
|
881
|
-
} else if (p.accountBindingId !== null || p.allocation !== null)
|
|
1011
|
+
if (p.accountBindingId !== c.accountBindingId || !r.accounts.some((a) => a.id === c.accountBindingId)) fail3("preparedPlan.channelPreviews.accountBindingId", "account binding mismatch");
|
|
1012
|
+
if (canonical(p.allocation) !== canonical(c.allocation)) fail3("preparedPlan.channelPreviews.allocation", "allocation mismatch");
|
|
1013
|
+
} else if (p.accountBindingId !== null || p.allocation !== null) fail3("preparedPlan.channelPreviews", "nonpaid child cannot select paid account/allocation");
|
|
882
1014
|
}
|
|
883
1015
|
return r;
|
|
884
1016
|
}
|
|
885
1017
|
var commandBase = { schemaVersion: literal2(1), campaignId: uuid, expectedRevision: integer2(1), idempotencyKey: operationKey, channelIds: list2(uuid, 100) };
|
|
886
1018
|
var effect = object2({ ...commandBase, operation: choice2("launch", "update", "resume"), preparedPlanId: uuid, reviewDigest: digest, mandateRef, expectedRemoteSnapshots: list2(object2({ channelId: uuid, digest }), 100) });
|
|
1019
|
+
var googleContentEffect = refine3(object2({
|
|
1020
|
+
...commandBase,
|
|
1021
|
+
operation: literal2("update"),
|
|
1022
|
+
preparedPlanId: uuid,
|
|
1023
|
+
reviewDigest: digest,
|
|
1024
|
+
mandateRef,
|
|
1025
|
+
channelIds: list2(uuid, 1, 1),
|
|
1026
|
+
expectedRemoteSnapshots: list2(object2({ channelId: uuid, digest }), 1, 1),
|
|
1027
|
+
googleContentUpdate
|
|
1028
|
+
}), (command2, p) => {
|
|
1029
|
+
const update2 = command2.googleContentUpdate, remote = command2.expectedRemoteSnapshots[0];
|
|
1030
|
+
if (command2.channelIds[0] !== update2.channelId || remote.channelId !== update2.channelId || remote.digest !== update2.beforeDigest) {
|
|
1031
|
+
fail3(p + ".googleContentUpdate", "requires the same single channel and before snapshot");
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
887
1034
|
var optimize = object2({ ...commandBase, operation: literal2("optimize"), preparedPlanId: uuid, reviewDigest: digest, mandateRef, decisionRef: object2({ id: uuid, revision, evidenceDigest: digest }), expectedRemoteSnapshots: list2(object2({ channelId: uuid, digest }), 100) });
|
|
888
1035
|
var safety = object2({ ...commandBase, operation: choice2("pause", "finish", "reconcile") });
|
|
889
1036
|
var deliverConversion = object2({ ...commandBase, operation: literal2("deliver_conversion"), channelIds: list2(uuid, 1, 1), preparedPlanId: uuid, reviewDigest: digest, mandateRef, conversionId: uuid });
|
|
890
1037
|
var deliverWebsiteVisit = object2({ ...commandBase, operation: literal2("deliver_website_visit"), channelIds: list2(uuid, 1, 1), preparedPlanId: uuid, reviewDigest: digest, mandateRef, occurrenceId: uuid });
|
|
891
|
-
var command = union2(effect, optimize, safety, deliverConversion, deliverWebsiteVisit);
|
|
1038
|
+
var command = union2(effect, googleContentEffect, optimize, safety, deliverConversion, deliverWebsiteVisit);
|
|
892
1039
|
function parseResonanceCommand(v, context) {
|
|
893
1040
|
const r = command.read(v, "command");
|
|
894
1041
|
unique(r.channelIds, "command.channelIds");
|
|
895
|
-
if ("mandateRef" in r && (r.mandateRef.campaignId !== r.campaignId || r.mandateRef.preparedPlanId !== r.preparedPlanId || r.mandateRef.reviewDigest !== r.reviewDigest))
|
|
1042
|
+
if ("mandateRef" in r && (r.mandateRef.campaignId !== r.campaignId || r.mandateRef.preparedPlanId !== r.preparedPlanId || r.mandateRef.reviewDigest !== r.reviewDigest)) fail3("command.mandateRef", "snapshot mismatch");
|
|
1043
|
+
if ("googleContentUpdate" in r && context) {
|
|
1044
|
+
const p = "command.googleContentUpdate", update2 = r.googleContentUpdate;
|
|
1045
|
+
const plan = parseResonancePreparedPlan(context.preparedPlan);
|
|
1046
|
+
const grant = parseResonanceMandateScope(context.mandate, plan);
|
|
1047
|
+
const now = Date.parse(instant.read(context.now, "command.context.now"));
|
|
1048
|
+
if (r.expectedRevision !== plan.expectedRevision || r.campaignId !== plan.campaignId || r.preparedPlanId !== plan.id || r.reviewDigest !== plan.reviewDigest || grant.projectId !== plan.projectId || grant.campaignId !== plan.campaignId || grant.preparedPlanId !== plan.id || grant.reviewDigest !== plan.reviewDigest || !grant.allowedOperations.includes("update") || canonical(grant.goal) !== canonical(plan.definition.objective) || canonical(grant.budget) !== canonical(plan.definition.budget) || now < Date.parse(grant.budget.startAt) || now >= Date.parse(grant.budget.endAt) || now >= Date.parse(grant.expiresAt)) {
|
|
1049
|
+
fail3(p, "requires the current original Google mandate and flight");
|
|
1050
|
+
}
|
|
1051
|
+
const channel2 = plan.definition.channels.find((item) => item.id === update2.channelId);
|
|
1052
|
+
if (channel2?.kind !== "google_search" || !grant.sites.includes(channel2.site) || !grant.accountBindingIds.includes(channel2.accountBindingId) || !channel2.adGroups.some((group) => group.localKey === update2.adGroupLocalKey && group.ads.some((ad) => ad.localKey === update2.adLocalKey))) {
|
|
1053
|
+
fail3(p, "requires an original Google Search group and ad in scope");
|
|
1054
|
+
} else if (update2.rsa) scoped(update2.rsa, plan.projectId, [channel2.site], p + ".rsa");
|
|
1055
|
+
}
|
|
896
1056
|
if ((r.operation === "deliver_conversion" || r.operation === "deliver_website_visit") && context) {
|
|
897
1057
|
const plan = parseResonancePreparedPlan(context.preparedPlan), grant = parseResonanceMandateScope(context.mandate);
|
|
898
1058
|
const now = Date.parse(instant.read(context.now, "command.context.now"));
|
|
899
|
-
if (r.expectedRevision !== plan.expectedRevision)
|
|
900
|
-
if (r.campaignId !== plan.campaignId || r.preparedPlanId !== plan.id || r.reviewDigest !== plan.reviewDigest || grant.projectId !== plan.projectId || grant.campaignId !== plan.campaignId || grant.preparedPlanId !== plan.id || grant.reviewDigest !== plan.reviewDigest)
|
|
901
|
-
if (canonical(grant.goal) !== canonical(plan.definition.objective) || canonical(grant.budget) !== canonical(plan.definition.budget))
|
|
1059
|
+
if (r.expectedRevision !== plan.expectedRevision) fail3("command.expectedRevision", "requires the original prepared definition revision");
|
|
1060
|
+
if (r.campaignId !== plan.campaignId || r.preparedPlanId !== plan.id || r.reviewDigest !== plan.reviewDigest || grant.projectId !== plan.projectId || grant.campaignId !== plan.campaignId || grant.preparedPlanId !== plan.id || grant.reviewDigest !== plan.reviewDigest) fail3("command.context", "requires the exact original plan and mandate scope");
|
|
1061
|
+
if (canonical(grant.goal) !== canonical(plan.definition.objective) || canonical(grant.budget) !== canonical(plan.definition.budget)) fail3("command.context.mandate", "original goal or budget mismatch");
|
|
902
1062
|
const channel2 = plan.definition.channels.find((c) => c.id === r.channelIds[0]);
|
|
903
1063
|
if (r.operation === "deliver_conversion") {
|
|
904
|
-
if (!grant.allowedOperations.includes("deliver_conversion"))
|
|
905
|
-
if (!channel2 || channel2.kind !== "google_search")
|
|
1064
|
+
if (!grant.allowedOperations.includes("deliver_conversion")) fail3("command.context.mandate.allowedOperations", "requires the explicit original delivery grant");
|
|
1065
|
+
if (!channel2 || channel2.kind !== "google_search") fail3("command.channelIds", "requires one original Google channel");
|
|
906
1066
|
const c = channel2;
|
|
907
1067
|
const goal = plan.definition.objective, witness = plan.resolvedQualificationRule;
|
|
908
|
-
if (goal.source.kind !== "qualified_lead" || goal.countingUnit !== "unique_qualified_contact" || !witness || witness.eligibleFormIds.length !== 1 || witness.eligibleFormIds[0] !== goal.source.id || !bookingTypesMatch(goal.eligibleBookingTypeIds, witness.eligibleBookingTypeIds) || goal.source.site !== c.site)
|
|
1068
|
+
if (goal.source.kind !== "qualified_lead" || goal.countingUnit !== "unique_qualified_contact" || !witness || witness.eligibleFormIds.length !== 1 || witness.eligibleFormIds[0] !== goal.source.id || !bookingTypesMatch(goal.eligibleBookingTypeIds, witness.eligibleBookingTypeIds) || goal.source.site !== c.site) fail3("command.context.goal", "requires the original single managed-form qualified source");
|
|
909
1069
|
const account = plan.accounts.find((a) => a.id === c.accountBindingId);
|
|
910
|
-
if (!account || account.provider !== "google_ads" || !grant.accountBindingIds.includes(c.accountBindingId) || !grant.sites.includes(c.site))
|
|
1070
|
+
if (!account || account.provider !== "google_ads" || !grant.accountBindingIds.includes(c.accountBindingId) || !grant.sites.includes(c.site)) fail3("command.context.account", "requires the original granted Google account and site");
|
|
911
1071
|
const configuration = plan.channelPreviews.find((p) => p.channelId === c.id)?.googleConfiguration;
|
|
912
|
-
if (!configuration || configuration.signalSemantics !== RESONANCE_GOOGLE_SIGNAL_SEMANTICS)
|
|
1072
|
+
if (!configuration || configuration.signalSemantics !== RESONANCE_GOOGLE_SIGNAL_SEMANTICS) fail3("command.context.googleConfiguration", "requires the reviewed qualified-at-observation profile");
|
|
913
1073
|
const g = configuration;
|
|
914
|
-
if (g.mode === "existing" && (g.nativeGoal.actionIds.length !== 1 || g.nativeGoal.actionIds[0].split("/")[1] !== account.externalAccountId || g.nativeGoal.externalId.split("/")[1] !== account.externalAccountId))
|
|
915
|
-
if (g.mode === "admitted_setup" && (g.setupSpec.goalStrategy !== "exclusive_custom_goal_v1" || g.setupSpec.goalActionKey !== g.setupSpec.action.localKey))
|
|
1074
|
+
if (g.mode === "existing" && (g.nativeGoal.actionIds.length !== 1 || g.nativeGoal.actionIds[0].split("/")[1] !== account.externalAccountId || g.nativeGoal.externalId.split("/")[1] !== account.externalAccountId)) fail3("command.context.googleConfiguration.nativeGoal", "requires one action owned by the original account; cross-account delivery is unsupported");
|
|
1075
|
+
if (g.mode === "admitted_setup" && (g.setupSpec.goalStrategy !== "exclusive_custom_goal_v1" || g.setupSpec.goalActionKey !== g.setupSpec.action.localKey)) fail3("command.context.googleConfiguration.setupSpec", "requires the original single-action setup intent");
|
|
916
1076
|
} else {
|
|
917
1077
|
const selected = grant.websiteVisitFeed?.channels.find((c2) => c2.channelId === r.channelIds[0]);
|
|
918
|
-
if (!selected)
|
|
919
|
-
if (!channel2 || channel2.kind !== "meta_retargeting")
|
|
1078
|
+
if (!selected) fail3("command.context.mandate.websiteVisitFeed", "requires the explicit original feed channel");
|
|
1079
|
+
if (!channel2 || channel2.kind !== "meta_retargeting") fail3("command.channelIds", "requires one original Meta channel");
|
|
920
1080
|
const c = channel2;
|
|
921
1081
|
const account = plan.accounts.find((a) => a.id === c.accountBindingId);
|
|
922
|
-
if (!account || account.provider !== "meta_ads" || !grant.accountBindingIds.includes(c.accountBindingId) || !grant.sites.includes(c.site))
|
|
923
|
-
if (c.audienceRuleRefs.some((rule) => !grant.audienceRuleRefs.some((original) => canonical(original) === canonical(rule))))
|
|
1082
|
+
if (!account || account.provider !== "meta_ads" || !grant.accountBindingIds.includes(c.accountBindingId) || !grant.sites.includes(c.site)) fail3("command.context.account", "requires the original granted Meta account and site");
|
|
1083
|
+
if (c.audienceRuleRefs.some((rule) => !grant.audienceRuleRefs.some((original) => canonical(original) === canonical(rule)))) fail3("command.context.audienceRuleRefs", "requires the original granted audience rules");
|
|
924
1084
|
}
|
|
925
|
-
if (now < Date.parse(grant.budget.startAt) || now >= Date.parse(grant.budget.endAt) || now >= Date.parse(grant.expiresAt))
|
|
1085
|
+
if (now < Date.parse(grant.budget.startAt) || now >= Date.parse(grant.budget.endAt) || now >= Date.parse(grant.expiresAt)) fail3("command.context.now", "outside the original mandate and budget dispatch window");
|
|
926
1086
|
}
|
|
927
1087
|
return r;
|
|
928
1088
|
}
|
|
929
1089
|
var RESONANCE_COMMAND_JSON_SCHEMA = command.schema;
|
|
930
|
-
var step = object2({ id: uuid, channelId: uuid, state: choice2("planned", "admitted", "confirmed", "failed", "uncertain"), providerRequestId: nullable2(
|
|
931
|
-
var receipt = object2({ schemaVersion: literal2(1), id: uuid, projectId: uuid, campaignId: uuid, preparedPlanId: nullable2(uuid), effectKey:
|
|
1090
|
+
var step = object2({ id: uuid, channelId: uuid, state: choice2("planned", "admitted", "confirmed", "failed", "uncertain"), providerRequestId: nullable2(text3(200)), admission: choice2("not_dispatched", "accepted", "rejected", "unknown"), configuredStatus: nullable2(text3(80)), effectiveStatus: nullable2(text3(80)), reviewStatus: nullable2(text3(80)), retryAfter: nullable2(instant), errorSubcode: nullable2(text3(80)), errorFieldPath: nullable2(text3(200)), resourceRefs: list2(object2({ type: text3(80), externalId: text3(200) }), 100), evidenceDigest: nullable2(digest), errorCode: nullable2(text3(80)), observedAt: nullable2(instant) });
|
|
1091
|
+
var receipt = object2({ schemaVersion: literal2(1), id: uuid, projectId: uuid, campaignId: uuid, preparedPlanId: nullable2(uuid), effectKey: text3(200), requestDigest: digest, ledgerActionId: uuid, actorId: text3(160), state: choice2("pending", "applying", "accepted", "failed", "needs_reconciliation"), steps: list2(step, 1e3), reservedExposure: money, unreconciledExposure: money, providerSemanticsNotice: list2(text3(500), 30), nextActions: list2(choice2("read", "reconcile", "retry_same_operation", "pause", "escalate"), 5) });
|
|
932
1092
|
function parseResonanceReceipt(v) {
|
|
933
1093
|
const r = receipt.read(v, "receipt");
|
|
934
|
-
if (r.reservedExposure.currency !== r.unreconciledExposure.currency)
|
|
1094
|
+
if (r.reservedExposure.currency !== r.unreconciledExposure.currency) fail3("receipt", "currency mismatch");
|
|
935
1095
|
const uncertain = r.steps.some((s) => s.state === "uncertain" || s.admission === "unknown");
|
|
936
|
-
if (uncertain && r.state !== "needs_reconciliation")
|
|
937
|
-
if ((uncertain || r.state === "needs_reconciliation") && r.nextActions.includes("retry_same_operation"))
|
|
1096
|
+
if (uncertain && r.state !== "needs_reconciliation") fail3("receipt.state", "uncertain child requires reconciliation state");
|
|
1097
|
+
if ((uncertain || r.state === "needs_reconciliation") && r.nextActions.includes("retry_same_operation")) fail3("receipt.nextActions", "unknown admission must reconcile before retry");
|
|
938
1098
|
return r;
|
|
939
1099
|
}
|
|
940
1100
|
var lifecycle = choice2("not_materialized", "pending", "partially_live", "live", "pausing", "paused", "finished", "needs_attention", "unknown");
|
|
941
|
-
var view = object2({ id: uuid, projectId: uuid, managementMode: choice2("tracking_only", "managed"), revision: integer2(0), definition: nullable2(draft), acceptedPlanId: nullable2(uuid), desiredLifecycle: choice2("draft", "running", "paused", "finished"), effectiveLifecycle: lifecycle, blockingReasons: list2(
|
|
1101
|
+
var view = object2({ id: uuid, projectId: uuid, managementMode: choice2("tracking_only", "managed"), revision: integer2(0), definition: nullable2(draft), acceptedPlanId: nullable2(uuid), desiredLifecycle: choice2("draft", "running", "paused", "finished"), effectiveLifecycle: lifecycle, blockingReasons: list2(text3(200), 100), activeOperation: nullable2(receipt), unresolvedExposure: nullable2(money) });
|
|
942
1102
|
function parseResonanceCampaignView(v) {
|
|
943
1103
|
const r = view.read(v, "campaignView");
|
|
944
|
-
if (r.managementMode === "managed" && r.revision < 1)
|
|
1104
|
+
if (r.managementMode === "managed" && r.revision < 1) fail3("campaignView.revision", "managed campaigns require revision >=1");
|
|
945
1105
|
if (r.definition) parseResonanceCampaignDraft(r.definition);
|
|
946
1106
|
if (r.activeOperation) parseResonanceReceipt(r.activeOperation);
|
|
947
|
-
if (r.definition && r.definition.projectId !== r.projectId)
|
|
948
|
-
if (r.activeOperation && (r.activeOperation.projectId !== r.projectId || r.activeOperation.campaignId !== r.id))
|
|
1107
|
+
if (r.definition && r.definition.projectId !== r.projectId) fail3("campaignView.definition", "cross-project reference");
|
|
1108
|
+
if (r.activeOperation && (r.activeOperation.projectId !== r.projectId || r.activeOperation.campaignId !== r.id)) fail3("campaignView.activeOperation", "scope mismatch");
|
|
949
1109
|
return r;
|
|
950
1110
|
}
|
|
951
|
-
var metricValue = union2(object2({ kind: literal2("count"), count: decimal }), object2({ kind: literal2("money"), money }), object2({ kind: literal2("ratio"), numerator: decimal, denominator:
|
|
952
|
-
if (v === "0")
|
|
1111
|
+
var metricValue = union2(object2({ kind: literal2("count"), count: decimal }), object2({ kind: literal2("money"), money }), object2({ kind: literal2("ratio"), numerator: decimal, denominator: refine3(decimal, (v, p) => {
|
|
1112
|
+
if (v === "0") fail3(p, "zero denominator");
|
|
953
1113
|
}) }));
|
|
954
|
-
var metricBase = { ...scope, campaignId: uuid, name: choice2("impressions", "clicks", "spend", "accepted_goals", "qualified_goals", "revenue", "conversion_rate", "reach", "results"), source: choice2("first_party", "provider", "experiment"), sourceRef: revision, goalRevision: nullable2(revision), countingUnit: choice2("unique_source", "unique_qualified_contact", "net_order", "provider_aggregate", "provider_unique_reach"), windowStart: instant, windowEnd: instant, timeZone, attributionModel: nullable2(
|
|
955
|
-
var metric = union2(object2({ ...metricBase, state: literal2("observed"), value: metricValue }), object2({ ...metricBase, state: choice2("unknown", "insufficient", "delayed", "unavailable"), value: literal2(null), reasonCode:
|
|
1114
|
+
var metricBase = { ...scope, campaignId: uuid, name: choice2("impressions", "clicks", "spend", "accepted_goals", "qualified_goals", "revenue", "conversion_rate", "reach", "results"), source: choice2("first_party", "provider", "experiment"), sourceRef: revision, goalRevision: nullable2(revision), countingUnit: choice2("unique_source", "unique_qualified_contact", "net_order", "provider_aggregate", "provider_unique_reach"), windowStart: instant, windowEnd: instant, timeZone, attributionModel: nullable2(text3(100)), asOf: instant, dataThrough: nullable2(instant), maturityDelaySeconds: integer2(0), coverageBasisPoints: nullable2(integer2(0, 1e4)), eligibleExposures: nullable2(decimal), matureOutcomes: nullable2(decimal), native: nullable2(object2({ unit: text3(80), amount: decimal, currency: nullable2(currency), unitExponent: integer2(0, 9), providerVersion: text3(30) })) };
|
|
1115
|
+
var metric = union2(object2({ ...metricBase, state: literal2("observed"), value: metricValue }), object2({ ...metricBase, state: choice2("unknown", "insufficient", "delayed", "unavailable"), value: literal2(null), reasonCode: text3(80) }));
|
|
956
1116
|
function parseResonanceMetricObservation(v) {
|
|
957
1117
|
const r = metric.read(v, "metric");
|
|
958
|
-
if (["accepted_goals", "qualified_goals", "revenue", "conversion_rate"].includes(r.name) && r.goalRevision === null)
|
|
959
|
-
if (Date.parse(r.windowEnd) <= Date.parse(r.windowStart))
|
|
960
|
-
if (r.name === "reach" !== (r.countingUnit === "provider_unique_reach"))
|
|
1118
|
+
if (["accepted_goals", "qualified_goals", "revenue", "conversion_rate"].includes(r.name) && r.goalRevision === null) fail3("metric.goalRevision", "goal measurement requires explicit revision");
|
|
1119
|
+
if (Date.parse(r.windowEnd) <= Date.parse(r.windowStart)) fail3("metric.window", "invalid window");
|
|
1120
|
+
if (r.name === "reach" !== (r.countingUnit === "provider_unique_reach")) fail3("metric.countingUnit", "reach, and only reach, counts unique provider reach");
|
|
961
1121
|
if (r.state === "observed") {
|
|
962
1122
|
const expected = r.name === "spend" || r.name === "revenue" ? "money" : r.name === "conversion_rate" ? "ratio" : "count";
|
|
963
|
-
if (r.value.kind !== expected)
|
|
1123
|
+
if (r.value.kind !== expected) fail3("metric.value", "metric unit mismatch");
|
|
964
1124
|
}
|
|
965
1125
|
return r;
|
|
966
1126
|
}
|
|
967
1127
|
var purpose = choice2("analytics_storage", "ad_storage", "ad_user_data", "ad_personalization");
|
|
968
|
-
var consent = object2({ ...scope, receiptId: uuid, visitorNamespace:
|
|
1128
|
+
var consent = object2({ ...scope, receiptId: uuid, visitorNamespace: text3(160), configRevision: revision, policyRevision: revision, consentRevision: integer2(1), state: choice2("unknown", "granted", "denied", "withdrawn"), purpose, observedAt: instant, evidenceRef: revision });
|
|
969
1129
|
var parseResonanceConsentSnapshot = (v) => consent.read(v, "consent");
|
|
970
|
-
var exposure = object2({ ...scope, experimentId: uuid, experimentRevision: integer2(1), assignmentId: uuid, variantKey:
|
|
971
|
-
var conversion = object2({ schemaVersion: literal2(1), ...scope, eventId: uuid, sourceRef: source, campaignId: nullable2(uuid), goalRevision: revision, occurredAt: instant, receivedAt: instant, value: union2(object2({ state: literal2("observed"), money }), object2({ state: choice2("unknown", "unavailable"), money: literal2(null), reasonCode:
|
|
1130
|
+
var exposure = object2({ ...scope, experimentId: uuid, experimentRevision: integer2(1), assignmentId: uuid, variantKey: text3(80), exposureId: uuid, occurredAt: instant });
|
|
1131
|
+
var conversion = object2({ schemaVersion: literal2(1), ...scope, eventId: uuid, sourceRef: source, campaignId: nullable2(uuid), goalRevision: revision, occurredAt: instant, receivedAt: instant, value: union2(object2({ state: literal2("observed"), money }), object2({ state: choice2("unknown", "unavailable"), money: literal2(null), reasonCode: text3(80) })), consent: list2(consent, 4), experiment: nullable2(exposure) });
|
|
972
1132
|
function parseResonanceConversionEnvelope(v) {
|
|
973
1133
|
const r = conversion.read(v, "conversion");
|
|
974
1134
|
unique(r.consent.map((c) => c.purpose), "conversion.consent");
|
|
975
1135
|
scoped(r, r.projectId, [r.site], "conversion");
|
|
976
|
-
if (Date.parse(r.receivedAt) < Date.parse(r.occurredAt))
|
|
1136
|
+
if (Date.parse(r.receivedAt) < Date.parse(r.occurredAt)) fail3("conversion.receivedAt", "precedes occurrence");
|
|
977
1137
|
return r;
|
|
978
1138
|
}
|
|
979
1139
|
var RESONANCE_CONVERSION_JSON_SCHEMA = conversion.schema;
|
|
@@ -987,14 +1147,17 @@ var RESONANCE_METRIC_JSON_SCHEMA = metric.schema;
|
|
|
987
1147
|
var RESONANCE_CONSENT_JSON_SCHEMA = consent.schema;
|
|
988
1148
|
var parseResonanceExperimentExposure = (v) => exposure.read(v, "exposure");
|
|
989
1149
|
var mandateTarget = object2({ project_id: uuid, campaign_id: uuid });
|
|
990
|
-
var mandateApproval = object2({ schemaVersion: literal2(1), expectedRevision: integer2(1), preparedPlanId: uuid, reviewDigest: digest, mandateDigest: digest, mandate: mandateScope });
|
|
1150
|
+
var mandateApproval = object2({ schemaVersion: literal2(1), expectedRevision: integer2(1), preparedPlanId: uuid, reviewDigest: digest, mandateDigest: digest, mandate: mandateScope, operatingPolicyBase: optional2(operatingPolicyBase) });
|
|
991
1151
|
var RESONANCE_MANDATE_APPROVAL_JSON_SCHEMA = mandateApproval.schema;
|
|
992
1152
|
var RESONANCE_MANDATE_TARGET_JSON_SCHEMA = mandateTarget.schema;
|
|
993
1153
|
var RESONANCE_MANDATE_ACTION_KIND = "resonance_mandate";
|
|
994
1154
|
function parseResonanceMandateApprovalPayload(v, target) {
|
|
995
1155
|
const r = mandateApproval.read(v, "mandateApproval"), t = mandateTarget.read(target, "target_ref");
|
|
996
1156
|
parseResonanceMandateScope(r.mandate);
|
|
997
|
-
if (r.
|
|
1157
|
+
if (r.operatingPolicyBase && !r.mandate.operatingPolicy && !r.mandate.providerReporting) {
|
|
1158
|
+
fail3("mandateApproval.operatingPolicyBase", "requires explicit prospective operating or reporting scope");
|
|
1159
|
+
}
|
|
1160
|
+
if (r.mandate.projectId !== t.project_id || r.mandate.campaignId !== t.campaign_id || r.preparedPlanId !== r.mandate.preparedPlanId || r.reviewDigest !== r.mandate.reviewDigest) fail3("mandateApproval", "target or snapshot mismatch");
|
|
998
1161
|
return r;
|
|
999
1162
|
}
|
|
1000
1163
|
function canonical(value) {
|
|
@@ -1008,7 +1171,7 @@ var parseResonanceMandateTarget = (v) => mandateTarget.read(v, "target_ref");
|
|
|
1008
1171
|
var positioningTarget = union2(
|
|
1009
1172
|
object2({ kind: literal2("broadcast"), channelId: uuid }),
|
|
1010
1173
|
object2({ kind: literal2("meta"), channelId: uuid, creativeId: uuid }),
|
|
1011
|
-
object2({ kind: literal2("google_search"), channelId: uuid, adGroupKey:
|
|
1174
|
+
object2({ kind: literal2("google_search"), channelId: uuid, adGroupKey: text3(80), adKey: text3(80) })
|
|
1012
1175
|
);
|
|
1013
1176
|
var positioningRequest = object2({
|
|
1014
1177
|
schemaVersion: literal2(1),
|
|
@@ -1021,46 +1184,46 @@ var positioningRequest = object2({
|
|
|
1021
1184
|
var positioningWitnessFields = {
|
|
1022
1185
|
id: operationKey,
|
|
1023
1186
|
kind: choice2("page", "funnel", "offer", "brain", "buyer", "proof"),
|
|
1024
|
-
sourceId:
|
|
1187
|
+
sourceId: text3(160),
|
|
1025
1188
|
revision,
|
|
1026
1189
|
observedAt: instant,
|
|
1027
1190
|
expiresAt: instant,
|
|
1028
1191
|
permission: choice2("private", "public"),
|
|
1029
1192
|
certainty: choice2("verified", "reported", "conflicting")
|
|
1030
1193
|
};
|
|
1031
|
-
var positioningWitness =
|
|
1032
|
-
var positioningText = (max) =>
|
|
1033
|
-
if (!value.trim() || /[\x00-\x08\x0b-\x1f\x7f]/.test(value))
|
|
1194
|
+
var positioningWitness = refine3(object2(positioningWitnessFields), checkPositioningWitness);
|
|
1195
|
+
var positioningText = (max) => refine3(text3(max), (value, at) => {
|
|
1196
|
+
if (!value.trim() || /[\x00-\x08\x0b-\x1f\x7f]/.test(value)) fail3(at, "requires nonblank text without control characters");
|
|
1034
1197
|
});
|
|
1035
|
-
var positioningEvidence =
|
|
1198
|
+
var positioningEvidence = refine3(object2({ ...positioningWitnessFields, text: positioningText(1600) }), checkPositioningWitness);
|
|
1036
1199
|
function checkPositioningWitness(value, at) {
|
|
1037
|
-
if (Date.parse(value.observedAt) >= Date.parse(value.expiresAt))
|
|
1200
|
+
if (Date.parse(value.observedAt) >= Date.parse(value.expiresAt)) fail3(at, "requires a positive witness lifetime");
|
|
1038
1201
|
}
|
|
1039
1202
|
var positioningScopeFields = { schemaVersion: literal2(1), projectId: uuid, campaignId: uuid, request: positioningRequest, observedAt: instant, expiresAt: instant };
|
|
1040
1203
|
function checkPositioningWindow(value, at) {
|
|
1041
|
-
if (Date.parse(value.observedAt) >= Date.parse(value.expiresAt))
|
|
1204
|
+
if (Date.parse(value.observedAt) >= Date.parse(value.expiresAt)) fail3(at, "requires a positive review lifetime");
|
|
1042
1205
|
unique(value.evidence.map((item) => item.id), at + ".evidence");
|
|
1043
|
-
if (value.evidence.some((item) => Date.parse(item.observedAt) > Date.parse(value.observedAt)))
|
|
1206
|
+
if (value.evidence.some((item) => Date.parse(item.observedAt) > Date.parse(value.observedAt))) fail3(at + ".evidence", "witness observation postdates the preview");
|
|
1044
1207
|
}
|
|
1045
|
-
var positioningContext =
|
|
1208
|
+
var positioningContext = refine3(object2({
|
|
1046
1209
|
...positioningScopeFields,
|
|
1047
1210
|
orgId: uuid,
|
|
1048
1211
|
evidence: list2(positioningEvidence, 32)
|
|
1049
1212
|
}), (value, at) => {
|
|
1050
1213
|
checkPositioningWindow(value, at);
|
|
1051
1214
|
if (value.evidence.reduce((total, witness) => total + witness.text.length, 0) > 16e3) {
|
|
1052
|
-
|
|
1215
|
+
fail3(at + ".evidence", "exceeds the combined source text budget");
|
|
1053
1216
|
}
|
|
1054
1217
|
});
|
|
1055
1218
|
var positioningEvidenceIds = uniqueList(operationKey, 8);
|
|
1056
1219
|
var positioningSupportedText = object2({ text: positioningText(320), evidenceIds: positioningEvidenceIds });
|
|
1057
|
-
var positioningAlternative =
|
|
1220
|
+
var positioningAlternative = refine3(object2({
|
|
1058
1221
|
text: positioningText(320),
|
|
1059
1222
|
kind: choice2("status_quo", "alternative"),
|
|
1060
1223
|
basis: choice2("evidence", "hypothesis"),
|
|
1061
1224
|
evidenceIds: positioningEvidenceIds
|
|
1062
1225
|
}), (value, at) => {
|
|
1063
|
-
if (value.basis === "evidence" !== value.evidenceIds.length > 0)
|
|
1226
|
+
if (value.basis === "evidence" !== value.evidenceIds.length > 0) fail3(at, "requires evidence references exactly for evidenced alternatives");
|
|
1064
1227
|
});
|
|
1065
1228
|
var positioningClaim = object2({
|
|
1066
1229
|
attribute: positioningText(320),
|
|
@@ -1101,7 +1264,7 @@ var positioningReasonCodes = choice2(
|
|
|
1101
1264
|
"generation_unavailable"
|
|
1102
1265
|
);
|
|
1103
1266
|
var RESONANCE_POSITIONING_METHOD_VERSION = "positioning_v1";
|
|
1104
|
-
var positioningResult =
|
|
1267
|
+
var positioningResult = refine3(object2({
|
|
1105
1268
|
methodVersion: literal2(RESONANCE_POSITIONING_METHOD_VERSION),
|
|
1106
1269
|
state: choice2("ready", "provisional", "no_fit"),
|
|
1107
1270
|
reasonCodes: uniqueList(positioningReasonCodes, 12),
|
|
@@ -1115,15 +1278,15 @@ var positioningResult = refine2(object2({
|
|
|
1115
1278
|
copy: nullable2(positioningCopy)
|
|
1116
1279
|
}), (value, at) => {
|
|
1117
1280
|
if (value.state !== "ready") {
|
|
1118
|
-
if (value.copy || !value.reasonCodes.length)
|
|
1281
|
+
if (value.copy || !value.reasonCodes.length) fail3(at, "requires a reason and no draft copy when held");
|
|
1119
1282
|
return;
|
|
1120
1283
|
}
|
|
1121
1284
|
const { copy, claims, category, bestFit, alternatives } = value;
|
|
1122
1285
|
if (!copy || value.reasonCodes.length || !claims.length || !category || !bestFit.length || !alternatives.length) {
|
|
1123
|
-
return
|
|
1286
|
+
return fail3(at, "requires a supported ready brief and channel draft");
|
|
1124
1287
|
}
|
|
1125
1288
|
unique(copy.claimIndexes.map(String), at + ".copy.claimIndexes");
|
|
1126
|
-
if (copy.claimIndexes.some((index) => index >= claims.length))
|
|
1289
|
+
if (copy.claimIndexes.some((index) => index >= claims.length)) fail3(at + ".copy.claimIndexes", "requires an existing claim index");
|
|
1127
1290
|
});
|
|
1128
1291
|
function checkPositioningEvidence(result, context, at) {
|
|
1129
1292
|
const evidence = new Map(context.evidence.map((witness) => [witness.id, witness]));
|
|
@@ -1135,37 +1298,37 @@ function checkPositioningEvidence(result, context, at) {
|
|
|
1135
1298
|
...result.category ? [result.category] : [],
|
|
1136
1299
|
...result.timelyContext ? [result.timelyContext] : []
|
|
1137
1300
|
];
|
|
1138
|
-
if (cited.some((item) => item.evidenceIds.some((id) => !evidence.has(id))))
|
|
1301
|
+
if (cited.some((item) => item.evidenceIds.some((id) => !evidence.has(id)))) fail3(at, "references unknown evidence");
|
|
1139
1302
|
for (const claim of result.claims) {
|
|
1140
1303
|
for (const id of claim.publicProofIds) {
|
|
1141
1304
|
const witness = evidence.get(id);
|
|
1142
|
-
if (!witness || witness.permission !== "public" || !current(witness))
|
|
1305
|
+
if (!witness || witness.permission !== "public" || !current(witness)) fail3(at, "public proof requires a current permitted witness");
|
|
1143
1306
|
}
|
|
1144
1307
|
}
|
|
1145
1308
|
if (result.timelyContext && (!result.timelyContext.evidenceIds.length || result.timelyContext.evidenceIds.some((id) => {
|
|
1146
1309
|
const witness = evidence.get(id);
|
|
1147
1310
|
return !witness || !current(witness);
|
|
1148
|
-
})))
|
|
1311
|
+
}))) fail3(at, "timely context requires current verified evidence");
|
|
1149
1312
|
if (!result.copy) return;
|
|
1150
|
-
if (result.copy.kind !== context.request.target.kind)
|
|
1313
|
+
if (result.copy.kind !== context.request.target.kind) fail3(at, "copy target differs from the request");
|
|
1151
1314
|
const { destination: selected, offerId } = context.request;
|
|
1152
1315
|
const owns = (kind, id) => {
|
|
1153
1316
|
const witnesses = context.evidence.filter((w) => w.kind === kind && (!id || w.sourceId.toLowerCase() === id.toLowerCase()));
|
|
1154
1317
|
return witnesses.some(current) && !witnesses.some((w) => w.certainty === "conflicting");
|
|
1155
1318
|
};
|
|
1156
1319
|
if (!selected || !owns(selected.kind === "existing_page" ? "page" : "funnel", selected.id) || !owns("brain") || offerId && !owns("offer", offerId)) {
|
|
1157
|
-
|
|
1320
|
+
fail3(at, "ready copy requires current destination, Brain and selected offer witnesses");
|
|
1158
1321
|
}
|
|
1159
1322
|
for (const index of result.copy.claimIndexes) {
|
|
1160
1323
|
const claim = result.claims[index];
|
|
1161
1324
|
if (![...claim.evidenceIds, ...claim.publicProofIds].every((id) => {
|
|
1162
1325
|
const witness = evidence.get(id);
|
|
1163
1326
|
return witness && witness.permission === "public" && current(witness);
|
|
1164
|
-
}))
|
|
1327
|
+
})) fail3(at, "selected copy requires current verified public claim evidence");
|
|
1165
1328
|
}
|
|
1166
1329
|
}
|
|
1167
|
-
var positioningApplicationToken =
|
|
1168
|
-
var positioningPreview =
|
|
1330
|
+
var positioningApplicationToken = text3(32e3, /^[a-zA-Z0-9._-]+$/);
|
|
1331
|
+
var positioningPreview = refine3(object2({
|
|
1169
1332
|
...positioningScopeFields,
|
|
1170
1333
|
evidence: list2(positioningWitness, 32),
|
|
1171
1334
|
result: positioningResult,
|
|
@@ -1173,7 +1336,7 @@ var positioningPreview = refine2(object2({
|
|
|
1173
1336
|
}), (value, at) => {
|
|
1174
1337
|
checkPositioningWindow(value, at);
|
|
1175
1338
|
checkPositioningEvidence(value.result, value, at + ".result");
|
|
1176
|
-
if (value.result.state === "ready" !== (value.applicationToken !== null))
|
|
1339
|
+
if (value.result.state === "ready" !== (value.applicationToken !== null)) fail3(at, "requires an application token exactly for ready copy");
|
|
1177
1340
|
});
|
|
1178
1341
|
var positioningApplyRequest = object2({ applicationToken: positioningApplicationToken });
|
|
1179
1342
|
var parseResonancePositioningPreviewRequest = (value) => positioningRequest.read(value, "positioningPreviewRequest");
|
|
@@ -1213,26 +1376,281 @@ function parseResonancePositioningConsistencyAssessment(value, expected) {
|
|
|
1213
1376
|
const at = "positioningConsistencyAssessment";
|
|
1214
1377
|
const assessment = positioningConsistencyAssessment.read(value, at);
|
|
1215
1378
|
if (assessment.evidenceDigest !== digest.read(expected.evidenceDigest, at + ".expectedEvidenceDigest")) {
|
|
1216
|
-
|
|
1379
|
+
fail3(at + ".evidenceDigest", "requires the exact current permitted evidence digest");
|
|
1217
1380
|
}
|
|
1218
1381
|
const eligibleIds = new Set(projectResonancePositioningConsistencyEvidence(expected.context).map((witness) => witness.id));
|
|
1219
1382
|
const { state, coveredSourceIds } = assessment;
|
|
1220
1383
|
if (coveredSourceIds.some((id) => !eligibleIds.has(id)) || state !== "unknown" && coveredSourceIds.length !== eligibleIds.size || state === "compatible" && coveredSourceIds.length < 1 || state === "conflicting" && coveredSourceIds.length < 2) {
|
|
1221
|
-
|
|
1384
|
+
fail3(at + ".coveredSourceIds", "coverage does not support this consistency state");
|
|
1222
1385
|
}
|
|
1223
1386
|
return assessment;
|
|
1224
1387
|
}
|
|
1225
1388
|
var RESONANCE_POSITIONING_CONSISTENCY_ASSESSMENT_JSON_SCHEMA = positioningConsistencyAssessment.schema;
|
|
1226
|
-
var prepareCommand = object2({ expectedRevision: integer2(1), idempotencyKey: operationKey });
|
|
1389
|
+
var prepareCommand = object2({ expectedRevision: integer2(1), idempotencyKey: operationKey, googleContentUpdate: optional2(googleContentUpdateSelection) });
|
|
1227
1390
|
var parseResonancePrepareCommand = (v) => prepareCommand.read(v, "prepare");
|
|
1228
1391
|
var parseResonanceCommandPrepareRequest = parseResonancePrepareCommand;
|
|
1229
|
-
var commandPreparation = object2({ command: nullable2(command), covered: bool, approvalRequirement: nullable2(choice2("existing_mandate", "current_owner")), reasonCodes: list2(
|
|
1392
|
+
var commandPreparation = object2({ command: nullable2(command), covered: bool, approvalRequirement: nullable2(choice2("existing_mandate", "current_owner")), reasonCodes: list2(text3(200), 100) });
|
|
1230
1393
|
function parseResonanceCommandPrepareResponse(v) {
|
|
1231
1394
|
const r = commandPreparation.read(v, "commandPreparation");
|
|
1232
1395
|
if (r.command) parseResonanceCommand(r.command);
|
|
1233
1396
|
return r;
|
|
1234
1397
|
}
|
|
1235
1398
|
var RESONANCE_COMMAND_PREPARE_REQUEST_JSON_SCHEMA = prepareCommand.schema;
|
|
1399
|
+
var preparationLookupRequest = object2({ expectedRevision: integer2(1), idempotencyKey: operationKey });
|
|
1400
|
+
var preparationLookupOperation = object2({
|
|
1401
|
+
operationId: uuid,
|
|
1402
|
+
preparedPlanId: uuid,
|
|
1403
|
+
executionState: choice2("reserved", "claimed", "dispatched", "succeeded", "rejected", "uncertain", "cancelled"),
|
|
1404
|
+
createdAt: instant,
|
|
1405
|
+
hasAdDispatch: bool,
|
|
1406
|
+
artifactCount: integer2(0, 512),
|
|
1407
|
+
completedArtifactCount: integer2(0, 512),
|
|
1408
|
+
originalActorMatches: bool,
|
|
1409
|
+
originalPrincipalMatches: bool
|
|
1410
|
+
});
|
|
1411
|
+
var preparationLookupResponse = object2({
|
|
1412
|
+
schemaVersion: literal2(1),
|
|
1413
|
+
projectId: uuid,
|
|
1414
|
+
campaignId: uuid,
|
|
1415
|
+
request: preparationLookupRequest,
|
|
1416
|
+
state: choice2("not_found", "working", "recovery_required", "succeeded", "rejected", "cancelled"),
|
|
1417
|
+
currentRevision: integer2(1),
|
|
1418
|
+
operation: nullable2(preparationLookupOperation),
|
|
1419
|
+
preparedPlan: nullable2(prepared),
|
|
1420
|
+
readiness: object2({ reasonCodes: list2(choice2(
|
|
1421
|
+
"PREPARATION_NOT_FOUND",
|
|
1422
|
+
"PREPARATION_WORKING",
|
|
1423
|
+
"PREPARATION_RECOVERY_REQUIRED",
|
|
1424
|
+
"PREPARATION_REJECTED",
|
|
1425
|
+
"PREPARATION_CANCELLED",
|
|
1426
|
+
"PREPARATION_OWNER_MISMATCH",
|
|
1427
|
+
"PREPARATION_REVISION_CHANGED",
|
|
1428
|
+
"PREPARATION_HAS_AD_DISPATCH",
|
|
1429
|
+
"PREPARATION_INVENTORY_UNAVAILABLE",
|
|
1430
|
+
"PREPARATION_TERMINAL_PROVIDER_REJECTION",
|
|
1431
|
+
"PREPARATION_ACCEPTED_REVIEW_AVAILABLE",
|
|
1432
|
+
"PREPARATION_FINANCIAL_EXPOSURE",
|
|
1433
|
+
"OWNER_STEP_FAILED",
|
|
1434
|
+
"OWNER_SOURCE_CHANGED",
|
|
1435
|
+
"SIGNER_CHANGED"
|
|
1436
|
+
), 30), canResume: bool })
|
|
1437
|
+
});
|
|
1438
|
+
var parseResonancePreparationLookupRequest = (v) => preparationLookupRequest.read(v, "preparationLookupRequest");
|
|
1439
|
+
function parseResonancePreparationLookupResponse(v) {
|
|
1440
|
+
const r = preparationLookupResponse.read(v, "preparationLookupResponse"), p = "preparationLookupResponse";
|
|
1441
|
+
if (r.state === "not_found") {
|
|
1442
|
+
if (r.operation || r.preparedPlan || r.readiness.canResume) fail3(p, "absence cannot carry a saved operation, plan or recovery permission");
|
|
1443
|
+
return r;
|
|
1444
|
+
}
|
|
1445
|
+
const o = r.operation;
|
|
1446
|
+
if (!o || o.completedArtifactCount > o.artifactCount) return fail3(p + ".operation", "requires the original operation and consistent artifact counts");
|
|
1447
|
+
const terminal = ["succeeded", "rejected", "cancelled"].includes(r.state);
|
|
1448
|
+
if (terminal ? o.executionState !== r.state : !["reserved", "claimed", "dispatched", "uncertain"].includes(o.executionState)) fail3(p + ".state", "does not match the original execution state");
|
|
1449
|
+
if (r.readiness.canResume && (r.state !== "recovery_required" || o.hasAdDispatch || !o.originalActorMatches || !o.originalPrincipalMatches || r.currentRevision !== r.request.expectedRevision)) fail3(p + ".readiness", "requires the same original caller and a recoverable pre-dispatch outcome");
|
|
1450
|
+
if (r.state === "succeeded") {
|
|
1451
|
+
if (!r.preparedPlan) return fail3(p + ".preparedPlan", "requires the saved original plan");
|
|
1452
|
+
const plan = parseResonancePreparedPlan(r.preparedPlan);
|
|
1453
|
+
if (plan.projectId !== r.projectId || plan.campaignId !== r.campaignId || plan.expectedRevision !== r.request.expectedRevision || plan.id !== o.preparedPlanId) fail3(p + ".preparedPlan", "must match the exact original request and operation");
|
|
1454
|
+
} else if (r.preparedPlan) fail3(p + ".preparedPlan", "an unfinished preparation cannot return a successful plan");
|
|
1455
|
+
return r;
|
|
1456
|
+
}
|
|
1457
|
+
var RESONANCE_PREPARATION_LOOKUP_REQUEST_JSON_SCHEMA = preparationLookupRequest.schema;
|
|
1458
|
+
var RESONANCE_PREPARATION_LOOKUP_RESPONSE_JSON_SCHEMA = preparationLookupResponse.schema;
|
|
1459
|
+
var preparationRetireRequest = object2({ expectedRevision: integer2(1), reason: literal2("retain_unpublished_artifacts") });
|
|
1460
|
+
var preparationRetireResponse = refine3(object2({
|
|
1461
|
+
schemaVersion: literal2(1),
|
|
1462
|
+
projectId: uuid,
|
|
1463
|
+
campaignId: uuid,
|
|
1464
|
+
preparationOperationId: uuid,
|
|
1465
|
+
state: literal2("cancelled"),
|
|
1466
|
+
replayed: bool,
|
|
1467
|
+
retainedArtifactCount: integer2(0, 512),
|
|
1468
|
+
unrecordedSlotCount: integer2(0, 512),
|
|
1469
|
+
retiredAt: instant,
|
|
1470
|
+
reasonCodes: list2(text3(100), 0)
|
|
1471
|
+
}), (v, p) => {
|
|
1472
|
+
if (v.retainedArtifactCount + v.unrecordedSlotCount > 512) fail3(p, "artifact and unrecorded slot total exceeds bound");
|
|
1473
|
+
});
|
|
1474
|
+
var parseResonancePreparationRetireRequest = (v) => preparationRetireRequest.read(v, "preparationRetireRequest");
|
|
1475
|
+
var parseResonancePreparationRetireResponse = (v) => preparationRetireResponse.read(v, "preparationRetireResponse");
|
|
1476
|
+
var RESONANCE_PREPARATION_RETIRE_REQUEST_JSON_SCHEMA = preparationRetireRequest.schema;
|
|
1477
|
+
var RESONANCE_PREPARATION_RETIRE_RESPONSE_JSON_SCHEMA = preparationRetireResponse.schema;
|
|
1478
|
+
var diagnosticsCode = text3(100, /^[A-Za-z][A-Za-z0-9_]*$/);
|
|
1479
|
+
var diagnosticsReasons = list2(diagnosticsCode, 64);
|
|
1480
|
+
var diagnosticsId = text3(30, /^[1-9][0-9]*$/);
|
|
1481
|
+
var diagnosticsResource = text3(200, /^customers\/[0-9]+\/(?:conversionActions|customConversionGoals)\/[0-9]+$/);
|
|
1482
|
+
var diagnosticsDay = refine3(text3(10, /^\d{4}-\d{2}-\d{2}$/), (v, p) => {
|
|
1483
|
+
if (!Number.isFinite(Date.parse(v)) || new Date(v).toISOString().slice(0, 10) !== v || v.startsWith("0000")) fail3(p, "invalid calendar date");
|
|
1484
|
+
});
|
|
1485
|
+
var RESONANCE_GOOGLE_DIAGNOSTICS_SECTIONS = ["campaign", "totals", "daily", "keywords", "searchTerms", "goals", "uploadDiagnostics"];
|
|
1486
|
+
var googleDiagnosticsRequestFields = {
|
|
1487
|
+
channelId: uuid,
|
|
1488
|
+
startDate: diagnosticsDay,
|
|
1489
|
+
endDate: diagnosticsDay,
|
|
1490
|
+
sections: list2(choice2(...RESONANCE_GOOGLE_DIAGNOSTICS_SECTIONS), 7, 1),
|
|
1491
|
+
directive: text3(2e3)
|
|
1492
|
+
};
|
|
1493
|
+
var checkDiagnosticsRequest = (v, p) => {
|
|
1494
|
+
unique(v.sections, p + ".sections");
|
|
1495
|
+
const days = (Date.parse(v.endDate) - Date.parse(v.startDate)) / 864e5 + 1;
|
|
1496
|
+
if (days < 1 || days > 31) fail3(p, "requires one to 31 calendar days");
|
|
1497
|
+
if (!v.directive.trim()) fail3(p + ".directive", "requires an explicit command");
|
|
1498
|
+
};
|
|
1499
|
+
var googleDiagnosticsRequest = refine3(object2(googleDiagnosticsRequestFields), checkDiagnosticsRequest);
|
|
1500
|
+
var parseResonanceGoogleCampaignDiagnosticsRequest = (v) => googleDiagnosticsRequest.read(v, "googleCampaignDiagnosticsRequest");
|
|
1501
|
+
var RESONANCE_GOOGLE_CAMPAIGN_DIAGNOSTICS_REQUEST_JSON_SCHEMA = googleDiagnosticsRequest.schema;
|
|
1502
|
+
var googleDiagnosticsPayload = refine3(object2({
|
|
1503
|
+
schemaVersion: literal2(1),
|
|
1504
|
+
campaignId: uuid,
|
|
1505
|
+
expectedRevision: integer2(1),
|
|
1506
|
+
...googleDiagnosticsRequestFields,
|
|
1507
|
+
accountBindingId: uuid,
|
|
1508
|
+
site,
|
|
1509
|
+
idempotencyKey: operationKey
|
|
1510
|
+
}), checkDiagnosticsRequest);
|
|
1511
|
+
var parseResonanceGoogleCampaignDiagnosticsPayload = (v) => googleDiagnosticsPayload.read(v, "googleCampaignDiagnosticsPayload");
|
|
1512
|
+
var RESONANCE_GOOGLE_CAMPAIGN_DIAGNOSTICS_PAYLOAD_JSON_SCHEMA = googleDiagnosticsPayload.schema;
|
|
1513
|
+
var diagnosticsMetricsFields = {
|
|
1514
|
+
spendMicros: nullable2(decimal),
|
|
1515
|
+
impressions: nullable2(decimal),
|
|
1516
|
+
clicks: nullable2(decimal),
|
|
1517
|
+
conversions: nullable2(text3(61, /^(?:0|[1-9][0-9]{0,29})(?:\.[0-9]{0,29}[1-9])?$/)),
|
|
1518
|
+
allConversions: nullable2(text3(61, /^(?:0|[1-9][0-9]{0,29})(?:\.[0-9]{0,29}[1-9])?$/))
|
|
1519
|
+
};
|
|
1520
|
+
var diagnosticsMetrics = object2(diagnosticsMetricsFields);
|
|
1521
|
+
var diagnosticsCampaignRow = object2({
|
|
1522
|
+
status: diagnosticsCode,
|
|
1523
|
+
primaryStatus: nullable2(diagnosticsCode),
|
|
1524
|
+
primaryStatusReasons: diagnosticsReasons,
|
|
1525
|
+
servingStatus: nullable2(diagnosticsCode),
|
|
1526
|
+
biddingStrategyType: nullable2(diagnosticsCode),
|
|
1527
|
+
startDate: nullable2(diagnosticsDay),
|
|
1528
|
+
endDate: nullable2(diagnosticsDay),
|
|
1529
|
+
budgetAmountMicros: nullable2(decimal),
|
|
1530
|
+
budgetPeriod: nullable2(diagnosticsCode),
|
|
1531
|
+
searchNetwork: nullable2(bool),
|
|
1532
|
+
searchPartners: nullable2(bool),
|
|
1533
|
+
displayNetwork: nullable2(bool),
|
|
1534
|
+
positiveGeoTargetType: nullable2(diagnosticsCode),
|
|
1535
|
+
negativeGeoTargetType: nullable2(diagnosticsCode),
|
|
1536
|
+
locationCriterionIds: list2(diagnosticsId, 100)
|
|
1537
|
+
});
|
|
1538
|
+
var diagnosticsKeywordRow = object2({
|
|
1539
|
+
criterionId: diagnosticsId,
|
|
1540
|
+
adGroupId: diagnosticsId,
|
|
1541
|
+
matchType: nullable2(diagnosticsCode),
|
|
1542
|
+
status: nullable2(diagnosticsCode),
|
|
1543
|
+
negative: bool,
|
|
1544
|
+
...diagnosticsMetricsFields
|
|
1545
|
+
});
|
|
1546
|
+
var diagnosticsTermRow = object2({
|
|
1547
|
+
rowId: digest,
|
|
1548
|
+
adGroupId: diagnosticsId,
|
|
1549
|
+
status: nullable2(diagnosticsCode),
|
|
1550
|
+
keywordCriterionId: nullable2(diagnosticsId),
|
|
1551
|
+
matchType: nullable2(diagnosticsCode),
|
|
1552
|
+
...diagnosticsMetricsFields
|
|
1553
|
+
});
|
|
1554
|
+
var diagnosticsGoalRow = object2({
|
|
1555
|
+
goalConfigLevel: nullable2(diagnosticsCode),
|
|
1556
|
+
customGoalResourceName: nullable2(diagnosticsResource),
|
|
1557
|
+
customGoalStatus: nullable2(diagnosticsCode),
|
|
1558
|
+
actionResourceName: diagnosticsResource,
|
|
1559
|
+
actionStatus: nullable2(diagnosticsCode),
|
|
1560
|
+
type: nullable2(diagnosticsCode),
|
|
1561
|
+
category: nullable2(diagnosticsCode),
|
|
1562
|
+
primaryForGoal: nullable2(bool),
|
|
1563
|
+
countingType: nullable2(diagnosticsCode),
|
|
1564
|
+
clickThroughLookbackWindowDays: nullable2(integer2(1, 365))
|
|
1565
|
+
});
|
|
1566
|
+
var diagnosticsUploadRow = object2({
|
|
1567
|
+
actionResourceName: diagnosticsResource,
|
|
1568
|
+
client: nullable2(diagnosticsCode),
|
|
1569
|
+
status: nullable2(diagnosticsCode),
|
|
1570
|
+
lastUploadDateTime: nullable2(text3(40, /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|[+-]\d{2}:\d{2})?$/)),
|
|
1571
|
+
totalEventCount: nullable2(decimal),
|
|
1572
|
+
successfulEventCount: nullable2(decimal),
|
|
1573
|
+
pendingEventCount: nullable2(decimal),
|
|
1574
|
+
alertCodes: diagnosticsReasons
|
|
1575
|
+
});
|
|
1576
|
+
function diagnosticsSection(row, max) {
|
|
1577
|
+
return refine3(object2({
|
|
1578
|
+
state: choice2("available", "unavailable", "capped"),
|
|
1579
|
+
reasonCodes: diagnosticsReasons,
|
|
1580
|
+
rows: list2(row, max),
|
|
1581
|
+
pagesRead: integer2(0, 100)
|
|
1582
|
+
}), (v, p) => {
|
|
1583
|
+
if (v.state === "unavailable" && v.rows.length) fail3(p, "unavailable sections cannot assert observed rows");
|
|
1584
|
+
if (v.state !== "available" && !v.reasonCodes.length) fail3(p, "incomplete sections require a reason");
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
var googleDiagnosticsReport = object2({
|
|
1588
|
+
schemaVersion: literal2(1),
|
|
1589
|
+
provider: literal2("google_ads"),
|
|
1590
|
+
projectId: uuid,
|
|
1591
|
+
campaignId: uuid,
|
|
1592
|
+
channelId: uuid,
|
|
1593
|
+
site,
|
|
1594
|
+
accountBindingId: uuid,
|
|
1595
|
+
externalCampaignId: diagnosticsId,
|
|
1596
|
+
currency,
|
|
1597
|
+
accountTimeZone: timeZone,
|
|
1598
|
+
window: object2({ startDate: diagnosticsDay, endDate: diagnosticsDay, completeness: literal2("completed_days") }),
|
|
1599
|
+
observedAt: instant,
|
|
1600
|
+
sections: object2({
|
|
1601
|
+
campaign: diagnosticsSection(diagnosticsCampaignRow, 1),
|
|
1602
|
+
totals: diagnosticsSection(diagnosticsMetrics, 1),
|
|
1603
|
+
daily: diagnosticsSection(object2({ localDate: diagnosticsDay, ...diagnosticsMetricsFields }), 31),
|
|
1604
|
+
keywords: diagnosticsSection(diagnosticsKeywordRow, 500),
|
|
1605
|
+
searchTerms: diagnosticsSection(diagnosticsTermRow, 1e3),
|
|
1606
|
+
goals: diagnosticsSection(diagnosticsGoalRow, 100),
|
|
1607
|
+
uploadDiagnostics: diagnosticsSection(diagnosticsUploadRow, 300)
|
|
1608
|
+
}),
|
|
1609
|
+
searchTermCoverage: object2({
|
|
1610
|
+
state: choice2("available", "unavailable"),
|
|
1611
|
+
reasonCodes: diagnosticsReasons,
|
|
1612
|
+
disclosed: nullable2(diagnosticsMetrics),
|
|
1613
|
+
remainder: nullable2(diagnosticsMetrics)
|
|
1614
|
+
}),
|
|
1615
|
+
providerAuthored: object2({
|
|
1616
|
+
campaignName: nullable2(text3(300)),
|
|
1617
|
+
keywords: list2(object2({ adGroupId: diagnosticsId, criterionId: diagnosticsId, text: text3(500) }), 500),
|
|
1618
|
+
searchTerms: list2(object2({ rowId: digest, text: text3(500) }), 1e3),
|
|
1619
|
+
locations: list2(object2({ criterionId: diagnosticsId, name: text3(300) }), 100)
|
|
1620
|
+
})
|
|
1621
|
+
});
|
|
1622
|
+
function parseResonanceGoogleCampaignDiagnosticsReport(v) {
|
|
1623
|
+
const r = googleDiagnosticsReport.read(v, "googleCampaignDiagnosticsReport"), p = "googleCampaignDiagnosticsReport";
|
|
1624
|
+
const { startDate, endDate } = r.window;
|
|
1625
|
+
if (endDate < startDate || Date.parse(endDate) - Date.parse(startDate) > 30 * 864e5) fail3(p + ".window", "requires at most 31 calendar days");
|
|
1626
|
+
const local = new Intl.DateTimeFormat("en-CA", { timeZone: r.accountTimeZone, year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(r.observedAt));
|
|
1627
|
+
const today = ["year", "month", "day"].map((type) => local.find((part) => part.type === type).value).join("-");
|
|
1628
|
+
if (endDate >= today) fail3(p + ".window", "requires completed advertiser-local days");
|
|
1629
|
+
const days = r.sections.daily.rows.map((row) => row.localDate);
|
|
1630
|
+
if (days.some((day) => day < startDate || day > endDate)) fail3(p + ".daily", "row outside requested window");
|
|
1631
|
+
unique(days, p + ".daily");
|
|
1632
|
+
const keywordKey = (row) => row.adGroupId + ":" + row.criterionId;
|
|
1633
|
+
unique(r.sections.keywords.rows.map(keywordKey), p + ".keywords");
|
|
1634
|
+
unique(r.sections.searchTerms.rows.map((row) => row.rowId), p + ".searchTerms");
|
|
1635
|
+
const coverage = r.searchTermCoverage;
|
|
1636
|
+
if (coverage.state === "unavailable" && (coverage.remainder || !coverage.reasonCodes.length)) fail3(p + ".searchTermCoverage", "unknown coverage must not assert a remainder");
|
|
1637
|
+
if (coverage.state === "available" && (r.sections.searchTerms.state !== "available" || r.sections.totals.state !== "available" || !coverage.disclosed || !coverage.remainder)) fail3(p + ".searchTermCoverage", "requires complete compatible totals and disclosed rows");
|
|
1638
|
+
if (coverage.state === "available") {
|
|
1639
|
+
const total = r.sections.totals.rows[0];
|
|
1640
|
+
if (!total) fail3(p + ".searchTermCoverage", "requires campaign totals");
|
|
1641
|
+
for (const metric2 of ["spendMicros", "impressions", "clicks"]) {
|
|
1642
|
+
const all = total[metric2], disclosed = coverage.disclosed[metric2], remainder = coverage.remainder[metric2];
|
|
1643
|
+
if (remainder !== null && (all === null || disclosed === null || BigInt(all) - BigInt(disclosed) !== BigInt(remainder))) fail3(p + ".searchTermCoverage", "remainder must match compatible disclosed and campaign totals");
|
|
1644
|
+
}
|
|
1645
|
+
if (coverage.remainder.conversions !== null || coverage.remainder.allConversions !== null) fail3(p + ".searchTermCoverage", "conversion remainder is not established by this profile");
|
|
1646
|
+
}
|
|
1647
|
+
const keywordIds = new Set(r.sections.keywords.rows.map(keywordKey)), termIds = new Set(r.sections.searchTerms.rows.map((row) => row.rowId));
|
|
1648
|
+
unique(r.providerAuthored.keywords.map(keywordKey), p + ".providerAuthored.keywords");
|
|
1649
|
+
unique(r.providerAuthored.searchTerms.map((row) => row.rowId), p + ".providerAuthored.searchTerms");
|
|
1650
|
+
if (r.providerAuthored.keywords.some((row) => !keywordIds.has(keywordKey(row))) || r.providerAuthored.searchTerms.some((row) => !termIds.has(row.rowId))) fail3(p + ".providerAuthored", "text must identify an observed row");
|
|
1651
|
+
return r;
|
|
1652
|
+
}
|
|
1653
|
+
var RESONANCE_GOOGLE_CAMPAIGN_DIAGNOSTICS_REPORT_JSON_SCHEMA = googleDiagnosticsReport.schema;
|
|
1236
1654
|
var RESONANCE_COMMAND_PREPARE_RESPONSE_JSON_SCHEMA = commandPreparation.schema;
|
|
1237
1655
|
function resonancePlanIssues(input, at) {
|
|
1238
1656
|
const plan = parseResonancePreparedPlan(input), issues = [];
|
|
@@ -1266,12 +1684,12 @@ function resonancePlanIssues(input, at) {
|
|
|
1266
1684
|
function compareMoney(a, b) {
|
|
1267
1685
|
a = parseMoney(a);
|
|
1268
1686
|
b = parseMoney(b);
|
|
1269
|
-
if (a.currency !== b.currency)
|
|
1687
|
+
if (a.currency !== b.currency) fail3("money.currency", "currency mismatch");
|
|
1270
1688
|
const left = BigInt(a.amountMicros), right = BigInt(b.amountMicros);
|
|
1271
1689
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
1272
1690
|
}
|
|
1273
1691
|
function subtractMoney(a, b) {
|
|
1274
|
-
if (compareMoney(a, b) < 0)
|
|
1692
|
+
if (compareMoney(a, b) < 0) fail3("money.amountMicros", "negative result");
|
|
1275
1693
|
return parseMoney({ currency: a.currency, amountMicros: (BigInt(a.amountMicros) - BigInt(b.amountMicros)).toString() });
|
|
1276
1694
|
}
|
|
1277
1695
|
function formatMoney(input) {
|
|
@@ -1283,21 +1701,21 @@ var saveCommand = object2({ definition: draft, expectedRevision: optional2(integ
|
|
|
1283
1701
|
function parseResonanceCampaignSaveCommand(v, mode = "update") {
|
|
1284
1702
|
const r = saveCommand.read(v, "save");
|
|
1285
1703
|
parseResonanceCampaignDraft(r.definition);
|
|
1286
|
-
if (mode !== "create" && mode !== "update")
|
|
1287
|
-
if (mode === "update" && (r.expectedRevision === void 0 || r.expectedRevision < 1))
|
|
1704
|
+
if (mode !== "create" && mode !== "update") fail3("save.mode", "unsupported mode");
|
|
1705
|
+
if (mode === "update" && (r.expectedRevision === void 0 || r.expectedRevision < 1)) fail3("save.expectedRevision", "required for update");
|
|
1288
1706
|
return r;
|
|
1289
1707
|
}
|
|
1290
1708
|
var acceptCommand = object2({ expectedRevision: integer2(1), ledgerActionId: uuid });
|
|
1291
1709
|
var parseResonanceAcceptCommand = (v) => acceptCommand.read(v, "accept");
|
|
1292
|
-
var bindingCommand = object2({ connectionId: uuid, provider: choice2("google_ads", "meta_ads"), externalAccountId:
|
|
1710
|
+
var bindingCommand = object2({ connectionId: uuid, provider: choice2("google_ads", "meta_ads"), externalAccountId: text3(160), expectedConnectionRevision: revision, idempotencyKey: operationKey });
|
|
1293
1711
|
var parseResonanceBindingCommand = (v) => bindingCommand.read(v, "binding");
|
|
1294
1712
|
var RESONANCE_SAVE_COMMAND_JSON_SCHEMA = saveCommand.schema;
|
|
1295
1713
|
var RESONANCE_ACCEPT_COMMAND_JSON_SCHEMA = acceptCommand.schema;
|
|
1296
1714
|
var RESONANCE_BINDING_COMMAND_JSON_SCHEMA = bindingCommand.schema;
|
|
1297
1715
|
var RESONANCE_CPQL_UNCERTAINTY_METHOD = "observational_cpql_missing_outcome_bound_v1";
|
|
1298
1716
|
var allocationHorizon = union2(
|
|
1299
|
-
|
|
1300
|
-
if (Date.parse(r.endAt) <= Date.parse(r.startAt))
|
|
1717
|
+
refine3(object2({ kind: literal2("finite_period"), startAt: instant, endAt: instant, timeZone, sourceRef: revision }), (r, p) => {
|
|
1718
|
+
if (Date.parse(r.endAt) <= Date.parse(r.startAt)) fail3(p, "invalid finite horizon");
|
|
1301
1719
|
}),
|
|
1302
1720
|
object2({ kind: literal2("daily_average"), timeZone, sourceRef: revision })
|
|
1303
1721
|
);
|
|
@@ -1309,7 +1727,7 @@ function conditionalCpqlOutcomeBound(input, spend) {
|
|
|
1309
1727
|
const n = BigInt(decimal.read(input.eligibleContacts, "bound.eligibleContacts"));
|
|
1310
1728
|
const c = BigInt(decimal.read(input.fullyResolvedContacts, "bound.fullyResolvedContacts"));
|
|
1311
1729
|
const k = BigInt(decimal.read(input.qualifiedContacts, "bound.qualifiedContacts"));
|
|
1312
|
-
if (c > n || k > c)
|
|
1730
|
+
if (c > n || k > c) fail3("bound", "inconsistent unique-contact source universe");
|
|
1313
1731
|
if (n === 0n || k === 0n || parseMoney(spend).amountMicros === "0") return null;
|
|
1314
1732
|
const u = n - c, denominator = 2n * k + u;
|
|
1315
1733
|
return Number((10000n * u + denominator - 1n) / denominator);
|
|
@@ -1337,17 +1755,17 @@ var allocationEvidenceFields = {
|
|
|
1337
1755
|
assignmentCheck: choice2("pass", "failed", "unknown", "not_applicable"),
|
|
1338
1756
|
powerCheck: choice2("pass", "failed", "unknown", "not_applicable")
|
|
1339
1757
|
};
|
|
1340
|
-
var allocationChannelFields = { channelId: uuid, site, accountBindingId: uuid, trackingState: choice2("healthy", "blocked", "unknown"), coverageBasisPoints: nullable2(integer2(0, 1e4)), coverageFamily: choice2("crm_attribution", "provider_import", "experiment_exposure"), coverageDefinitionRef: resource, coveredNumerator: nullable2(decimal), eligibleDenominator: nullable2(decimal), uncertaintyBasisPoints: nullable2(integer2(0, 1e4)), uncertaintySource: nullable2(uncertaintySource), dedupeCheck: choice2("pass", "failed", "unknown", "not_applicable"), qualificationCheck: choice2("pass", "failed", "unknown", "not_applicable"), reasonCodes: list2(
|
|
1341
|
-
if (![0, 2, 3, 6].includes(v))
|
|
1758
|
+
var allocationChannelFields = { channelId: uuid, site, accountBindingId: uuid, trackingState: choice2("healthy", "blocked", "unknown"), coverageBasisPoints: nullable2(integer2(0, 1e4)), coverageFamily: choice2("crm_attribution", "provider_import", "experiment_exposure"), coverageDefinitionRef: resource, coveredNumerator: nullable2(decimal), eligibleDenominator: nullable2(decimal), uncertaintyBasisPoints: nullable2(integer2(0, 1e4)), uncertaintySource: nullable2(uncertaintySource), dedupeCheck: choice2("pass", "failed", "unknown", "not_applicable"), qualificationCheck: choice2("pass", "failed", "unknown", "not_applicable"), reasonCodes: list2(text3(80), 50), capabilityRevision: revision, budgetMode: choice2("campaign_total", "average_daily", "lifetime", "daily"), allocationHorizon: nullable2(allocationHorizon), matureThrough: nullable2(instant), dataThrough: nullable2(instant), goalRevision: revision, countingUnit: choice2("unique_source", "unique_qualified_contact", "net_order"), attributionModel: text3(100), attributionWindowDays: integer2(1, 365), policyRevision: revision, currentAllocation: money, remoteSnapshotDigest: digest, observations: list2(metric, 100), providerUnitExponent: refine3(integer2(0, 6), (v, p) => {
|
|
1759
|
+
if (![0, 2, 3, 6].includes(v)) fail3(p, "unsupported provider exponent");
|
|
1342
1760
|
}), providerMaxUnits: decimal };
|
|
1343
1761
|
var { uncertaintySource: _legacyUncertaintyField, ...reportedChannelFields } = allocationChannelFields;
|
|
1344
1762
|
var matureOptimizationEvidence = object2({ ...allocationEvidenceFields, resolvedPolicy: matureOptimizationPolicy, channels: list2(object2({ ...allocationChannelFields, uncertaintySource: nullable2(uncertaintySource) }), 100, 1) });
|
|
1345
1763
|
var reportedCostFields = { basis: literal2("provider_reported_snapshot_v1"), observationId: uuid, sourceEvidenceDigest: digest, reportedSpend: money, queriedFrom: instant, queriedThrough: instant, firstReceivedAt: instant, receivedAt: instant, recordedAt: instant, providerFinality: literal2("unknown"), correctionsPossible: literal2(true) };
|
|
1346
1764
|
var reportedOutcomeSource = object2({ method: literal2(RESONANCE_CPQL_UNCERTAINTY_METHOD), eligibleContacts: decimal, fullyResolvedContacts: decimal, qualifiedContacts: decimal, sourceRevision: revision, qualificationRuleRef: resource, universeComplete: literal2(true) });
|
|
1347
|
-
var nativeSqlReadInstant =
|
|
1765
|
+
var nativeSqlReadInstant = refine3(text3(32, /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/), (v, p) => {
|
|
1348
1766
|
const match = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/.exec(v);
|
|
1349
1767
|
const projected = match[1] + "." + (match[2] ?? "").padEnd(3, "0").slice(0, 3) + "Z";
|
|
1350
|
-
if (!Number.isFinite(Date.parse(projected)) || new Date(projected).toISOString() !== projected)
|
|
1768
|
+
if (!Number.isFinite(Date.parse(projected)) || new Date(projected).toISOString() !== projected) fail3(p, "invalid native SQL UTC instant");
|
|
1351
1769
|
});
|
|
1352
1770
|
var providerReadClock = object2({ kind: literal2("sql_before_provider_read_lower_bound_v1"), notBeforeAt: nativeSqlReadInstant });
|
|
1353
1771
|
var channelReportedCost = object2({ ...reportedCostFields, readClock: providerReadClock });
|
|
@@ -1364,34 +1782,34 @@ function parseMatureOptimizationEvidence(v) {
|
|
|
1364
1782
|
const r = matureOptimizationEvidence.read(v, "optimizationEvidence");
|
|
1365
1783
|
for (const c of r.channels) {
|
|
1366
1784
|
if (c.uncertaintySource === null) {
|
|
1367
|
-
if (c.uncertaintyBasisPoints !== null)
|
|
1368
|
-
} else if (c.uncertaintySource.verifiedSpend.currency !== c.currentAllocation.currency || c.uncertaintyBasisPoints !== cpqlMissingOutcomeBound(c.uncertaintySource))
|
|
1785
|
+
if (c.uncertaintyBasisPoints !== null) fail3("optimizationEvidence.channels.uncertainty", "no bound without source witness");
|
|
1786
|
+
} else if (c.uncertaintySource.verifiedSpend.currency !== c.currentAllocation.currency || c.uncertaintyBasisPoints !== cpqlMissingOutcomeBound(c.uncertaintySource)) fail3("optimizationEvidence.channels.uncertainty", "source bound mismatch");
|
|
1369
1787
|
}
|
|
1370
1788
|
checkAllocationEvidence(r);
|
|
1371
1789
|
return r;
|
|
1372
1790
|
}
|
|
1373
1791
|
function checkAllocationEvidence(r) {
|
|
1374
|
-
if (r.objective.measurementRevision !== r.goalRevision)
|
|
1375
|
-
if (Date.parse(r.windowEnd) <= Date.parse(r.windowStart) || r.dataThrough !== null && Date.parse(r.dataThrough) > Date.parse(r.observedAt))
|
|
1792
|
+
if (r.objective.measurementRevision !== r.goalRevision) fail3("optimizationEvidence.goalRevision", "goal snapshot mismatch");
|
|
1793
|
+
if (Date.parse(r.windowEnd) <= Date.parse(r.windowStart) || r.dataThrough !== null && Date.parse(r.dataThrough) > Date.parse(r.observedAt)) fail3("optimizationEvidence.window", "invalid observed window");
|
|
1376
1794
|
const sites = r.channels.map((c) => c.site);
|
|
1377
1795
|
scoped(r, r.projectId, sites, "optimizationEvidence");
|
|
1378
1796
|
unique(r.channels.map((c) => c.channelId), "optimizationEvidence.channels");
|
|
1379
1797
|
const currency2 = r.channels[0].currentAllocation.currency;
|
|
1380
1798
|
for (const c of r.channels) {
|
|
1381
|
-
if (c.allocationHorizon !== null && (["campaign_total", "lifetime"].includes(c.budgetMode) ? c.allocationHorizon.kind !== "finite_period" : c.allocationHorizon.kind !== "daily_average"))
|
|
1799
|
+
if (c.allocationHorizon !== null && (["campaign_total", "lifetime"].includes(c.budgetMode) ? c.allocationHorizon.kind !== "finite_period" : c.allocationHorizon.kind !== "daily_average")) fail3("optimizationEvidence.channels.allocationHorizon", "unapproved budget period normalization");
|
|
1382
1800
|
if (c.coveredNumerator === null || c.eligibleDenominator === null || c.eligibleDenominator === "0") {
|
|
1383
|
-
if (c.coverageBasisPoints !== null)
|
|
1801
|
+
if (c.coverageBasisPoints !== null) fail3("optimizationEvidence.channels.coverage", "unknown denominator means unknown coverage");
|
|
1384
1802
|
} else {
|
|
1385
1803
|
const numerator = BigInt(c.coveredNumerator), denominator = BigInt(c.eligibleDenominator);
|
|
1386
|
-
if (numerator > denominator || c.coverageBasisPoints !== Number(numerator * 10000n / denominator))
|
|
1804
|
+
if (numerator > denominator || c.coverageBasisPoints !== Number(numerator * 10000n / denominator)) fail3("optimizationEvidence.channels.coverage", "coverage ratio mismatch");
|
|
1387
1805
|
}
|
|
1388
|
-
if (r.resolvedPolicy.sourceRef === null && c.policyRevision !== r.policyDigest)
|
|
1389
|
-
if (c.goalRevision !== r.goalRevision || c.countingUnit !== r.objective.countingUnit || c.attributionWindowDays !== r.objective.attributionWindowDays)
|
|
1390
|
-
if (c.currentAllocation.currency !== currency2)
|
|
1806
|
+
if (r.resolvedPolicy.sourceRef === null && c.policyRevision !== r.policyDigest) fail3("optimizationEvidence.channels.policyRevision", "inline policy digest mismatch");
|
|
1807
|
+
if (c.goalRevision !== r.goalRevision || c.countingUnit !== r.objective.countingUnit || c.attributionWindowDays !== r.objective.attributionWindowDays) fail3("optimizationEvidence.channels", "measurement semantics mismatch");
|
|
1808
|
+
if (c.currentAllocation.currency !== currency2) fail3("optimizationEvidence.channels", "currency mismatch");
|
|
1391
1809
|
moneyToProviderUnits(c.currentAllocation, { currency: currency2, unitExponent: c.providerUnitExponent, maxUnits: c.providerMaxUnits });
|
|
1392
1810
|
for (const observation of c.observations) {
|
|
1393
1811
|
parseResonanceMetricObservation(observation);
|
|
1394
|
-
if (observation.campaignId !== r.campaignId || observation.site !== c.site)
|
|
1812
|
+
if (observation.campaignId !== r.campaignId || observation.site !== c.site) fail3("optimizationEvidence.channels.observations", "scope mismatch");
|
|
1395
1813
|
}
|
|
1396
1814
|
}
|
|
1397
1815
|
}
|
|
@@ -1403,37 +1821,37 @@ function parseReportedOptimizationEvidence(v) {
|
|
|
1403
1821
|
function checkReportedAllocationEvidence(r) {
|
|
1404
1822
|
const p = "optimizationEvidence";
|
|
1405
1823
|
parseResonanceOptimizationPolicy(r.resolvedPolicy);
|
|
1406
|
-
if (r.objective.source.kind !== "qualified_lead" || r.objective.countingUnit !== "unique_qualified_contact" || !r.objective.qualificationRuleRef || r.objective.qualificationRuleRef.module !== "crm")
|
|
1407
|
-
if (r.dataThrough !== null)
|
|
1824
|
+
if (r.objective.source.kind !== "qualified_lead" || r.objective.countingUnit !== "unique_qualified_contact" || !r.objective.qualificationRuleRef || r.objective.qualificationRuleRef.module !== "crm") fail3(p + ".objective", "requires the original independent qualified-contact source");
|
|
1825
|
+
if (r.dataThrough !== null) fail3(p + ".dataThrough", "query coverage cannot become mature provider dataThrough");
|
|
1408
1826
|
unique(r.channels.map((c) => c.channelReportedCost.observationId), p + ".channels.channelReportedCost.observationId");
|
|
1409
1827
|
const observedAt = Date.parse(r.observedAt), windowStart = Date.parse(r.windowStart), windowEnd = Date.parse(r.windowEnd);
|
|
1410
|
-
if (windowEnd <= windowStart || windowEnd > observedAt)
|
|
1828
|
+
if (windowEnd <= windowStart || windowEnd > observedAt) fail3(p + ".window", "requires a completed observed interval");
|
|
1411
1829
|
let commonZone;
|
|
1412
1830
|
for (const c of r.channels) {
|
|
1413
1831
|
const cost = c.channelReportedCost, outcome = c.outcomeSource;
|
|
1414
|
-
if (c.dataThrough !== null)
|
|
1415
|
-
if (Date.parse(cost.queriedFrom) !== windowStart || Date.parse(cost.queriedThrough) !== windowEnd)
|
|
1832
|
+
if (c.dataThrough !== null) fail3(p + ".channels.dataThrough", "query coverage cannot become mature provider dataThrough");
|
|
1833
|
+
if (Date.parse(cost.queriedFrom) !== windowStart || Date.parse(cost.queriedThrough) !== windowEnd) fail3(p + ".channels.channelReportedCost", "requires the exact common query interval");
|
|
1416
1834
|
const firstReceived = Date.parse(cost.firstReceivedAt), received = Date.parse(cost.receivedAt), recorded = Date.parse(cost.recordedAt);
|
|
1417
1835
|
const anchor = Date.parse(cost.readClock.notBeforeAt);
|
|
1418
|
-
if (received < firstReceived)
|
|
1419
|
-
if (anchor < windowEnd || anchor > recorded || recorded > observedAt || observedAt - anchor > r.resolvedPolicy.maxEvidenceAgeSeconds * 1e3)
|
|
1420
|
-
if (cost.reportedSpend.currency !== c.currentAllocation.currency || canonical(outcome.qualificationRuleRef) !== canonical(r.objective.qualificationRuleRef))
|
|
1421
|
-
if (c.uncertaintyBasisPoints !== reportedCpqlMissingOutcomeBound({ ...outcome, reportedSpend: cost.reportedSpend }))
|
|
1836
|
+
if (received < firstReceived) fail3(p + ".channels.channelReportedCost", "HTTP receipts must retain internal ordering");
|
|
1837
|
+
if (anchor < windowEnd || anchor > recorded || recorded > observedAt || observedAt - anchor > r.resolvedPolicy.maxEvidenceAgeSeconds * 1e3) fail3(p + ".channels.channelReportedCost.readClock", "requires the original fresh SQL-before-HTTP lower bound and SQL receipt order");
|
|
1838
|
+
if (cost.reportedSpend.currency !== c.currentAllocation.currency || canonical(outcome.qualificationRuleRef) !== canonical(r.objective.qualificationRuleRef)) fail3(p + ".channels.outcomeSource", "requires original qualification reference and currency");
|
|
1839
|
+
if (c.uncertaintyBasisPoints !== reportedCpqlMissingOutcomeBound({ ...outcome, reportedSpend: cost.reportedSpend })) fail3(p + ".channels.uncertainty", "conditional source bound mismatch");
|
|
1422
1840
|
const spends = c.observations.filter((o) => o.name === "spend");
|
|
1423
|
-
if (spends.length !== 1)
|
|
1841
|
+
if (spends.length !== 1) fail3(p + ".channels.observations", "requires one exact provider spend snapshot, never overlapping sums");
|
|
1424
1842
|
const spend = spends[0];
|
|
1425
|
-
if (spend.state !== "observed" || spend.source !== "provider" || spend.countingUnit !== "provider_aggregate" || spend.attributionModel !== "provider_reported" || spend.value.kind !== "money" || canonical(spend.value.money) !== canonical(cost.reportedSpend) || Date.parse(spend.windowStart) !== windowStart || Date.parse(spend.windowEnd) !== windowEnd || spend.dataThrough !== null || Date.parse(spend.asOf) !== recorded)
|
|
1843
|
+
if (spend.state !== "observed" || spend.source !== "provider" || spend.countingUnit !== "provider_aggregate" || spend.attributionModel !== "provider_reported" || spend.value.kind !== "money" || canonical(spend.value.money) !== canonical(cost.reportedSpend) || Date.parse(spend.windowStart) !== windowStart || Date.parse(spend.windowEnd) !== windowEnd || spend.dataThrough !== null || Date.parse(spend.asOf) !== recorded) fail3(p + ".channels.observations", "reported spend must match the exact nonfinal provider snapshot");
|
|
1426
1844
|
const outcomes = c.observations.filter((o) => o.name === "qualified_goals");
|
|
1427
|
-
if (outcomes.length !== 1)
|
|
1845
|
+
if (outcomes.length !== 1) fail3(p + ".channels.observations", "requires one independent qualified-contact source");
|
|
1428
1846
|
const qualified = outcomes[0];
|
|
1429
|
-
if (qualified.state !== "observed" || qualified.source !== "first_party" || qualified.sourceRef !== outcome.sourceRevision || qualified.goalRevision !== r.goalRevision || qualified.countingUnit !== "unique_qualified_contact" || qualified.attributionModel !== r.resolvedPolicy.attributionModel || qualified.value.kind !== "count" || qualified.value.count !== outcome.qualifiedContacts || qualified.eligibleExposures !== outcome.eligibleContacts || qualified.matureOutcomes !== outcome.qualifiedContacts || qualified.dataThrough === null || Date.parse(qualified.dataThrough) < windowEnd || Date.parse(qualified.dataThrough) > observedAt || c.matureThrough === null || Date.parse(c.matureThrough) < windowEnd || Date.parse(c.matureThrough) > observedAt)
|
|
1847
|
+
if (qualified.state !== "observed" || qualified.source !== "first_party" || qualified.sourceRef !== outcome.sourceRevision || qualified.goalRevision !== r.goalRevision || qualified.countingUnit !== "unique_qualified_contact" || qualified.attributionModel !== r.resolvedPolicy.attributionModel || qualified.value.kind !== "count" || qualified.value.count !== outcome.qualifiedContacts || qualified.eligibleExposures !== outcome.eligibleContacts || qualified.matureOutcomes !== outcome.qualifiedContacts || qualified.dataThrough === null || Date.parse(qualified.dataThrough) < windowEnd || Date.parse(qualified.dataThrough) > observedAt || c.matureThrough === null || Date.parse(c.matureThrough) < windowEnd || Date.parse(c.matureThrough) > observedAt) fail3(p + ".channels.outcomeSource", "requires independent mature qualified-contact evidence");
|
|
1430
1848
|
const formatter = new Intl.DateTimeFormat("en-GB", { timeZone: spend.timeZone, hour: "2-digit", minute: "2-digit", second: "2-digit", hourCycle: "h23" });
|
|
1431
|
-
if ([r.windowStart, r.windowEnd].some((t) => new Date(t).getUTCMilliseconds() !== 0 || formatter.format(new Date(t)) !== "00:00:00") || commonZone !== void 0 && commonZone !== spend.timeZone)
|
|
1849
|
+
if ([r.windowStart, r.windowEnd].some((t) => new Date(t).getUTCMilliseconds() !== 0 || formatter.format(new Date(t)) !== "00:00:00") || commonZone !== void 0 && commonZone !== spend.timeZone) fail3(p + ".channels.observations", "requires common advertiser-local completed days without rounding");
|
|
1432
1850
|
commonZone = spend.timeZone;
|
|
1433
1851
|
for (const o of c.observations) {
|
|
1434
1852
|
parseResonanceMetricObservation(o);
|
|
1435
|
-
if (o.projectId !== r.projectId || o.campaignId !== r.campaignId || o.site !== c.site || Date.parse(o.windowStart) !== windowStart || Date.parse(o.windowEnd) !== windowEnd || o.timeZone !== spend.timeZone || Date.parse(o.asOf) > observedAt)
|
|
1436
|
-
if (o.source === "provider" && o.dataThrough !== null)
|
|
1853
|
+
if (o.projectId !== r.projectId || o.campaignId !== r.campaignId || o.site !== c.site || Date.parse(o.windowStart) !== windowStart || Date.parse(o.windowEnd) !== windowEnd || o.timeZone !== spend.timeZone || Date.parse(o.asOf) > observedAt) fail3(p + ".channels.observations", "foreign or mismatched observation interval");
|
|
1854
|
+
if (o.source === "provider" && o.dataThrough !== null) fail3(p + ".channels.observations", "reported provider observation remains nonfinal");
|
|
1437
1855
|
}
|
|
1438
1856
|
}
|
|
1439
1857
|
checkAllocationEvidence(r);
|
|
@@ -1441,9 +1859,9 @@ function checkReportedAllocationEvidence(r) {
|
|
|
1441
1859
|
var optimizationEvidenceRefFields = { id: uuid, revision, evidenceDigest: digest };
|
|
1442
1860
|
var optimizationEvidenceRef = object2(optimizationEvidenceRefFields);
|
|
1443
1861
|
var finiteOwnMeasurement = union2(
|
|
1444
|
-
object2({ state: literal2("unobserved"), observations: literal2(null), reasonCodes: list2(
|
|
1445
|
-
object2({ state: choice2("pending", "blocked"), observations: nullable2(list2(metric, 100)), reasonCodes: list2(
|
|
1446
|
-
object2({ state: literal2("mature"), observations: list2(metric, 100, 1), reasonCodes: list2(
|
|
1862
|
+
object2({ state: literal2("unobserved"), observations: literal2(null), reasonCodes: list2(text3(80), 50) }),
|
|
1863
|
+
object2({ state: choice2("pending", "blocked"), observations: nullable2(list2(metric, 100)), reasonCodes: list2(text3(80), 50) }),
|
|
1864
|
+
object2({ state: literal2("mature"), observations: list2(metric, 100, 1), reasonCodes: list2(text3(80), 50) })
|
|
1447
1865
|
);
|
|
1448
1866
|
var finiteCandidateObservation = object2({
|
|
1449
1867
|
channelId: uuid,
|
|
@@ -1461,7 +1879,7 @@ var finiteCandidateObservation = object2({
|
|
|
1461
1879
|
coverageBasisPoints: nullable2(integer2(0, 1e4)),
|
|
1462
1880
|
dedupeCheck: choice2("pass", "failed", "unknown", "not_applicable"),
|
|
1463
1881
|
qualificationCheck: choice2("pass", "failed", "unknown", "not_applicable"),
|
|
1464
|
-
reasonCodes: list2(
|
|
1882
|
+
reasonCodes: list2(text3(80), 50),
|
|
1465
1883
|
ownMeasurement: finiteOwnMeasurement
|
|
1466
1884
|
});
|
|
1467
1885
|
var finiteOptimizationEvidence = object2({
|
|
@@ -1497,48 +1915,48 @@ function parseResonanceOptimizationEvidence(v, preparedPlan) {
|
|
|
1497
1915
|
if (!("evidenceKind" in r)) return parseMatureOptimizationEvidence(r);
|
|
1498
1916
|
if (r.evidenceKind === "reported_cpql_sql_clock_v1") return parseReportedOptimizationEvidence(r);
|
|
1499
1917
|
const p = "optimizationEvidence", policy = parseResonanceOptimizationPolicy(r.resolvedPolicy);
|
|
1500
|
-
if (r.objective.measurementRevision !== r.goalRevision || r.objective.countingUnit !== "unique_qualified_contact" || canonical(policy.measurementGuard.sourceRef) !== canonical(r.objective.source) || canonical(policy.measurementGuard.qualificationRuleRef) !== canonical(r.objective.qualificationRuleRef) || policy.measurementGuard.maturityDelaySeconds !== r.objective.maturityDelaySeconds)
|
|
1501
|
-
if (Date.parse(r.windowEnd) <= Date.parse(r.windowStart) || r.dataThrough !== null && Date.parse(r.dataThrough) > Date.parse(r.observedAt))
|
|
1918
|
+
if (r.objective.measurementRevision !== r.goalRevision || r.objective.countingUnit !== "unique_qualified_contact" || canonical(policy.measurementGuard.sourceRef) !== canonical(r.objective.source) || canonical(policy.measurementGuard.qualificationRuleRef) !== canonical(r.objective.qualificationRuleRef) || policy.measurementGuard.maturityDelaySeconds !== r.objective.maturityDelaySeconds) fail3(p + ".objective", "finite policy must retain the original qualified objective");
|
|
1919
|
+
if (Date.parse(r.windowEnd) <= Date.parse(r.windowStart) || r.dataThrough !== null && Date.parse(r.dataThrough) > Date.parse(r.observedAt)) fail3(p + ".window", "invalid observed window");
|
|
1502
1920
|
unique(r.candidates.map((c) => c.channelId), p + ".candidates");
|
|
1503
|
-
if (r.candidates.length !== policy.candidateChannelIds.length || r.candidates.some((c) => !policy.candidateChannelIds.includes(c.channelId)))
|
|
1921
|
+
if (r.candidates.length !== policy.candidateChannelIds.length || r.candidates.some((c) => !policy.candidateChannelIds.includes(c.channelId))) fail3(p + ".candidates", "must cover exactly the original finite policy");
|
|
1504
1922
|
scoped(r, r.projectId, r.candidates.map((c) => c.site), p);
|
|
1505
1923
|
for (const c of r.candidates) {
|
|
1506
|
-
if (c.graphDigest !== c.manifestRef.digest)
|
|
1507
|
-
if (c.cap.currency !== policy.totalExplorationCap.currency || BigInt(c.cap.amountMicros) === 0n)
|
|
1508
|
-
if (Date.parse(c.flight.endAt) <= Date.parse(c.flight.startAt))
|
|
1924
|
+
if (c.graphDigest !== c.manifestRef.digest) fail3(p + ".candidates.graphDigest", "must match the actual original manifest graph digest");
|
|
1925
|
+
if (c.cap.currency !== policy.totalExplorationCap.currency || BigInt(c.cap.amountMicros) === 0n) fail3(p + ".candidates.cap", "requires the original positive cap currency");
|
|
1926
|
+
if (Date.parse(c.flight.endAt) <= Date.parse(c.flight.startAt)) fail3(p + ".candidates.flight", "invalid original flight");
|
|
1509
1927
|
const schedule = policy.selection.eligibilitySchedule.find((s) => s.channelId === c.channelId);
|
|
1510
|
-
if (Date.parse(schedule.notBefore) < Date.parse(c.flight.startAt) || Date.parse(schedule.notAfter) > Date.parse(c.flight.endAt))
|
|
1511
|
-
if (c.lifecycle === "not_materialized" && (c.commitmentEvidenceRef !== null || c.activationsObserved !== 0))
|
|
1512
|
-
if (["active", "stopped"].includes(c.lifecycle) && c.activationsObserved !== 1)
|
|
1513
|
-
if (c.lifecycle === "not_materialized" && c.ownMeasurement.observations !== null || c.activationsObserved === 0 && c.ownMeasurement.state === "mature")
|
|
1514
|
-
if (c.ownMeasurement.state === "mature" && c.ownMeasurement.observations.some((o) => o.state !== "observed"))
|
|
1928
|
+
if (Date.parse(schedule.notBefore) < Date.parse(c.flight.startAt) || Date.parse(schedule.notAfter) > Date.parse(c.flight.endAt)) fail3(p + ".candidates.flight", "selection must stay inside original flight");
|
|
1929
|
+
if (c.lifecycle === "not_materialized" && (c.commitmentEvidenceRef !== null || c.activationsObserved !== 0)) fail3(p + ".candidates", "absence cannot borrow a commitment or prior activation");
|
|
1930
|
+
if (["active", "stopped"].includes(c.lifecycle) && c.activationsObserved !== 1) fail3(p + ".candidates.activationsObserved", "active/stopped state requires its original activation");
|
|
1931
|
+
if (c.lifecycle === "not_materialized" && c.ownMeasurement.observations !== null || c.activationsObserved === 0 && c.ownMeasurement.state === "mature") fail3(p + ".candidates.ownMeasurement", "cold/absent candidates cannot borrow mature observations");
|
|
1932
|
+
if (c.ownMeasurement.state === "mature" && c.ownMeasurement.observations.some((o) => o.state !== "observed")) fail3(p + ".candidates.ownMeasurement", "mature observations must be observed");
|
|
1515
1933
|
for (const o of c.ownMeasurement.observations ?? []) {
|
|
1516
1934
|
parseResonanceMetricObservation(o);
|
|
1517
|
-
if (o.projectId !== r.projectId || o.campaignId !== r.campaignId || o.site !== c.site)
|
|
1518
|
-
if (Date.parse(o.asOf) > Date.parse(r.observedAt) || Date.parse(o.windowStart) < Date.parse(r.windowStart) || Date.parse(o.windowEnd) > Date.parse(r.windowEnd) || o.dataThrough !== null && Date.parse(o.dataThrough) > Date.parse(r.observedAt))
|
|
1935
|
+
if (o.projectId !== r.projectId || o.campaignId !== r.campaignId || o.site !== c.site) fail3(p + ".candidates.ownMeasurement", "foreign candidate measurement scope");
|
|
1936
|
+
if (Date.parse(o.asOf) > Date.parse(r.observedAt) || Date.parse(o.windowStart) < Date.parse(r.windowStart) || Date.parse(o.windowEnd) > Date.parse(r.windowEnd) || o.dataThrough !== null && Date.parse(o.dataThrough) > Date.parse(r.observedAt)) fail3(p + ".candidates.ownMeasurement", "outside the actual candidate evidence window");
|
|
1519
1937
|
const aggregate = o.source === "provider" && RESONANCE_PROVIDER_METRIC_NAMES.includes(o.name);
|
|
1520
|
-
if (aggregate ? o.countingUnit !== providerCountingUnit(o.name) || o.attributionModel !== "provider_reported" || o.goalRevision !== null && o.goalRevision !== r.goalRevision : o.source !== "first_party" || o.goalRevision !== r.goalRevision || o.countingUnit !== r.objective.countingUnit || o.attributionModel !== policy.measurementGuard.attributionModel)
|
|
1938
|
+
if (aggregate ? o.countingUnit !== providerCountingUnit(o.name) || o.attributionModel !== "provider_reported" || o.goalRevision !== null && o.goalRevision !== r.goalRevision : o.source !== "first_party" || o.goalRevision !== r.goalRevision || o.countingUnit !== r.objective.countingUnit || o.attributionModel !== policy.measurementGuard.attributionModel) fail3(p + ".candidates.ownMeasurement", "preserve actual provider aggregate versus first-party cohort provenance");
|
|
1521
1939
|
}
|
|
1522
1940
|
}
|
|
1523
1941
|
return r;
|
|
1524
1942
|
}
|
|
1525
1943
|
function checkOptimizationEvidencePlan(e, plan) {
|
|
1526
1944
|
const p = "optimizationEvidence";
|
|
1527
|
-
if (e.projectId !== plan.projectId || e.campaignId !== plan.campaignId || e.preparedPlanId !== plan.id || e.reviewDigest !== plan.reviewDigest || canonical(e.objective) !== canonical(plan.definition.objective) || canonical(e.resolvedPolicy) !== canonical(plan.resolvedEvidencePolicy))
|
|
1945
|
+
if (e.projectId !== plan.projectId || e.campaignId !== plan.campaignId || e.preparedPlanId !== plan.id || e.reviewDigest !== plan.reviewDigest || canonical(e.objective) !== canonical(plan.definition.objective) || canonical(e.resolvedPolicy) !== canonical(plan.resolvedEvidencePolicy)) fail3(p + ".preparedPlanId", "requires the exact original prepared scope and policy");
|
|
1528
1946
|
if (!("evidenceKind" in e)) return;
|
|
1529
1947
|
if (e.evidenceKind === "reported_cpql_sql_clock_v1") {
|
|
1530
1948
|
const cohort = plan.resolvedQualificationRule?.cohort;
|
|
1531
|
-
if (!cohort || Date.parse(e.windowStart) < Date.parse(cohort.startAt) || Date.parse(e.windowEnd) > Date.parse(cohort.endAt))
|
|
1949
|
+
if (!cohort || Date.parse(e.windowStart) < Date.parse(cohort.startAt) || Date.parse(e.windowEnd) > Date.parse(cohort.endAt)) fail3(p + ".window", "outside the original frozen qualification cohort");
|
|
1532
1950
|
for (const c of e.channels) {
|
|
1533
1951
|
const original = plan.definition.channels.find((x) => x.id === c.channelId), account = plan.accounts.find((x) => x.id === c.accountBindingId);
|
|
1534
|
-
if (!original || !("provider" in original) || original.site !== c.site || original.accountBindingId !== c.accountBindingId || !account || c.observations.some((o) => o.timeZone !== account.timeZone))
|
|
1952
|
+
if (!original || !("provider" in original) || original.site !== c.site || original.accountBindingId !== c.accountBindingId || !account || c.observations.some((o) => o.timeZone !== account.timeZone)) fail3(p + ".channels", "reported evidence must retain original channel/account/site/timezone");
|
|
1535
1953
|
}
|
|
1536
1954
|
return;
|
|
1537
1955
|
}
|
|
1538
1956
|
for (const observed of e.candidates) {
|
|
1539
1957
|
const original = plan.definition.channels.find((c) => c.id === observed.channelId), preview2 = plan.channelPreviews.find((c) => c.channelId === observed.channelId);
|
|
1540
|
-
if (!original || original.kind !== "meta_retargeting" || !preview2 || observed.site !== original.site || observed.accountBindingId !== original.accountBindingId || canonical(observed.cap) !== canonical(original.allocation) || canonical(observed.manifestRef) !== canonical(preview2.manifestRef))
|
|
1541
|
-
if (canonical(observed.flight) !== canonical({ startAt: plan.definition.budget.startAt, endAt: plan.definition.budget.endAt, timeZone: plan.definition.budget.timeZone }))
|
|
1958
|
+
if (!original || original.kind !== "meta_retargeting" || !preview2 || observed.site !== original.site || observed.accountBindingId !== original.accountBindingId || canonical(observed.cap) !== canonical(original.allocation) || canonical(observed.manifestRef) !== canonical(preview2.manifestRef)) fail3(p + ".candidates", "candidate projection differs from original channel and manifest");
|
|
1959
|
+
if (canonical(observed.flight) !== canonical({ startAt: plan.definition.budget.startAt, endAt: plan.definition.budget.endAt, timeZone: plan.definition.budget.timeZone })) fail3(p + ".candidates.flight", "must retain the original budget flight");
|
|
1542
1960
|
}
|
|
1543
1961
|
}
|
|
1544
1962
|
var matureOptimizationDecision = object2({
|
|
@@ -1557,9 +1975,9 @@ var matureOptimizationDecision = object2({
|
|
|
1557
1975
|
state: choice2("actionable", "noop", "blocked"),
|
|
1558
1976
|
decisionKind: choice2("observational_allocation", "experimental_promotion"),
|
|
1559
1977
|
executionOrder: literal2("reduce_then_increase"),
|
|
1560
|
-
reasonCodes: list2(
|
|
1561
|
-
adjustments: list2(object2({ channelId: uuid, site, budgetMode: choice2("campaign_total", "average_daily", "lifetime", "daily"), providerUnitExponent:
|
|
1562
|
-
if (![0, 2, 3, 6].includes(v))
|
|
1978
|
+
reasonCodes: list2(text3(80), 50),
|
|
1979
|
+
adjustments: list2(object2({ channelId: uuid, site, budgetMode: choice2("campaign_total", "average_daily", "lifetime", "daily"), providerUnitExponent: refine3(integer2(0, 6), (v, p) => {
|
|
1980
|
+
if (![0, 2, 3, 6].includes(v)) fail3(p, "unsupported provider exponent");
|
|
1563
1981
|
}), providerMaxUnits: decimal, before: money, after: money, remoteSnapshotDigest: digest }), 100),
|
|
1564
1982
|
createdAt: instant
|
|
1565
1983
|
});
|
|
@@ -1584,7 +2002,7 @@ var finiteDecisionFields = {
|
|
|
1584
2002
|
algorithmRevision: literal2("finite_meta_candidates_v1"),
|
|
1585
2003
|
sourceRefs: list2(revision, 200),
|
|
1586
2004
|
decisionKind: literal2("preapproved_candidate_operation"),
|
|
1587
|
-
reasonCodes: list2(
|
|
2005
|
+
reasonCodes: list2(text3(80), 50, 1)
|
|
1588
2006
|
};
|
|
1589
2007
|
var finiteOptimizationDecision = union2(
|
|
1590
2008
|
object2({ ...finiteDecisionFields, state: literal2("actionable"), candidateActions: list2(finiteCandidateActionBody, 1, 1) }),
|
|
@@ -1593,77 +2011,77 @@ var finiteOptimizationDecision = union2(
|
|
|
1593
2011
|
var optimizationDecision = union2(matureOptimizationDecision, finiteOptimizationDecision);
|
|
1594
2012
|
function parseResonanceOptimizationDecision(v, evidence, preparedPlan) {
|
|
1595
2013
|
const r = optimizationDecision.read(v, "optimizationDecision");
|
|
1596
|
-
if (Date.parse(r.expiresAt) <= Date.parse(r.createdAt))
|
|
1597
|
-
if (preparedPlan !== void 0 && evidence === void 0)
|
|
2014
|
+
if (Date.parse(r.expiresAt) <= Date.parse(r.createdAt)) fail3("optimizationDecision.expiresAt", "must follow decision");
|
|
2015
|
+
if (preparedPlan !== void 0 && evidence === void 0) fail3("optimizationDecision.evidenceRef", "plan binding requires actual evidence");
|
|
1598
2016
|
if (evidence !== void 0) checkOptimizationDecisionEvidence(r, parseResonanceOptimizationEvidence(evidence, preparedPlan));
|
|
1599
2017
|
if (r.decisionKind === "preapproved_candidate_operation") return r;
|
|
1600
2018
|
unique(r.adjustments.map((c) => c.channelId), "optimizationDecision.adjustments");
|
|
1601
2019
|
scoped(r, r.projectId, r.adjustments.map((c) => c.site), "optimizationDecision");
|
|
1602
|
-
if (r.state !== "actionable" && r.adjustments.length)
|
|
1603
|
-
if (r.state === "actionable" && !r.adjustments.length)
|
|
2020
|
+
if (r.state !== "actionable" && r.adjustments.length) fail3("optimizationDecision.adjustments", "no effects for blocked/noop decision");
|
|
2021
|
+
if (r.state === "actionable" && !r.adjustments.length) fail3("optimizationDecision.adjustments", "action requires exact adjustments");
|
|
1604
2022
|
for (const a of r.adjustments) {
|
|
1605
2023
|
compareMoney(a.before, a.after);
|
|
1606
2024
|
moneyToProviderUnits(a.before, { currency: a.before.currency, unitExponent: a.providerUnitExponent, maxUnits: a.providerMaxUnits });
|
|
1607
2025
|
moneyToProviderUnits(a.after, { currency: a.after.currency, unitExponent: a.providerUnitExponent, maxUnits: a.providerMaxUnits });
|
|
1608
|
-
if (r.adjustments[0].before.currency !== a.before.currency)
|
|
2026
|
+
if (r.adjustments[0].before.currency !== a.before.currency) fail3("optimizationDecision.adjustments", "currency mismatch");
|
|
1609
2027
|
}
|
|
1610
2028
|
return r;
|
|
1611
2029
|
}
|
|
1612
2030
|
function checkOptimizationDecisionEvidence(d, e) {
|
|
1613
2031
|
const p = "optimizationDecision";
|
|
1614
|
-
if (d.projectId !== e.projectId || d.campaignId !== e.campaignId || d.preparedPlanId !== e.preparedPlanId || d.reviewDigest !== e.reviewDigest || d.policyDigest !== e.policyDigest || canonical(d.evidenceRef) !== canonical({ id: e.id, revision: e.revision, evidenceDigest: e.evidenceDigest }))
|
|
1615
|
-
if (Date.parse(d.createdAt) < Date.parse(e.observedAt))
|
|
2032
|
+
if (d.projectId !== e.projectId || d.campaignId !== e.campaignId || d.preparedPlanId !== e.preparedPlanId || d.reviewDigest !== e.reviewDigest || d.policyDigest !== e.policyDigest || canonical(d.evidenceRef) !== canonical({ id: e.id, revision: e.revision, evidenceDigest: e.evidenceDigest })) fail3(p + ".evidenceRef", "must bind the exact original evidence and review");
|
|
2033
|
+
if (Date.parse(d.createdAt) < Date.parse(e.observedAt)) fail3(p + ".createdAt", "precedes actual evidence");
|
|
1616
2034
|
if (d.decisionKind !== "preapproved_candidate_operation") {
|
|
1617
|
-
if ("evidenceKind" in e && e.evidenceKind !== "reported_cpql_sql_clock_v1")
|
|
1618
|
-
if ("evidenceKind" in e && e.evidenceKind === "reported_cpql_sql_clock_v1" ? d.algorithmRevision !== e.resolvedPolicy.algorithm || d.decisionKind !== "observational_allocation" : d.algorithmRevision === "reported_cpql_conserved_transfer_v1")
|
|
2035
|
+
if ("evidenceKind" in e && e.evidenceKind !== "reported_cpql_sql_clock_v1") fail3(p + ".decisionKind", "mature decisions cannot borrow finite lifecycle evidence");
|
|
2036
|
+
if ("evidenceKind" in e && e.evidenceKind === "reported_cpql_sql_clock_v1" ? d.algorithmRevision !== e.resolvedPolicy.algorithm || d.decisionKind !== "observational_allocation" : d.algorithmRevision === "reported_cpql_conserved_transfer_v1") fail3(p + ".algorithmRevision", "reported-cost decisions require the exact reported evidence policy");
|
|
1619
2037
|
if ("evidenceKind" in e && e.evidenceKind === "reported_cpql_sql_clock_v1") {
|
|
1620
2038
|
const deadline = Math.min(Date.parse(e.observedAt), ...e.channels.flatMap((c) => [Date.parse(c.channelReportedCost.readClock.notBeforeAt), Date.parse(c.channelReportedCost.recordedAt)])) + e.resolvedPolicy.maxEvidenceAgeSeconds * 1e3;
|
|
1621
|
-
if (Date.parse(d.createdAt) > deadline || Date.parse(d.expiresAt) > deadline)
|
|
2039
|
+
if (Date.parse(d.createdAt) > deadline || Date.parse(d.expiresAt) > deadline) fail3(p + ".expiresAt", "outside original HTTP/database evidence freshness");
|
|
1622
2040
|
const refs = e.channels.flatMap((c) => [c.channelReportedCost.observationId, c.outcomeSource.sourceRevision]);
|
|
1623
|
-
if (refs.some((ref) => !d.sourceRefs.includes(ref)))
|
|
2041
|
+
if (refs.some((ref) => !d.sourceRefs.includes(ref))) fail3(p + ".sourceRefs", "requires immutable reported-cost and independent outcome sources");
|
|
1624
2042
|
}
|
|
1625
|
-
if (d.algorithmRevision === "finite_meta_candidates_v1")
|
|
2043
|
+
if (d.algorithmRevision === "finite_meta_candidates_v1") fail3(p + ".algorithmRevision", "mature decisions cannot use the finite algorithm");
|
|
1626
2044
|
return;
|
|
1627
2045
|
}
|
|
1628
|
-
if (!("evidenceKind" in e) || e.evidenceKind !== "finite_candidate_lifecycle_v1")
|
|
2046
|
+
if (!("evidenceKind" in e) || e.evidenceKind !== "finite_candidate_lifecycle_v1") fail3(p + ".decisionKind", "finite actions require finite lifecycle evidence");
|
|
1629
2047
|
const finite = e, policy = finite.resolvedPolicy;
|
|
1630
|
-
if (Date.parse(d.createdAt) - Date.parse(finite.observedAt) > policy.measurementGuard.maxEvidenceAgeSeconds * 1e3 || Date.parse(d.expiresAt) > Date.parse(policy.expiresAt))
|
|
2048
|
+
if (Date.parse(d.createdAt) - Date.parse(finite.observedAt) > policy.measurementGuard.maxEvidenceAgeSeconds * 1e3 || Date.parse(d.expiresAt) > Date.parse(policy.expiresAt)) fail3(p + ".expiresAt", "outside current policy/evidence freshness");
|
|
1631
2049
|
for (const a of d.candidateActions) {
|
|
1632
|
-
const c = finite.candidates.find((c2) => c2.channelId === a.channelId) ??
|
|
1633
|
-
if (!policy.allowedActions.includes(a.action) || c.graphDigest !== a.graphDigest || c.nativeStateEvidenceRef === null || canonical(c.nativeStateEvidenceRef) !== canonical(a.nativeStateEvidenceRef))
|
|
1634
|
-
if (c.lifecycle === "unknown")
|
|
2050
|
+
const c = finite.candidates.find((c2) => c2.channelId === a.channelId) ?? fail3(p + ".candidateActions", "unknown original candidate");
|
|
2051
|
+
if (!policy.allowedActions.includes(a.action) || c.graphDigest !== a.graphDigest || c.nativeStateEvidenceRef === null || canonical(c.nativeStateEvidenceRef) !== canonical(a.nativeStateEvidenceRef)) fail3(p + ".candidateActions", "outside original candidate action/state evidence");
|
|
2052
|
+
if (c.lifecycle === "unknown") fail3(p + ".candidateActions", "unknown state requires reconciliation");
|
|
1635
2053
|
if (a.action === "pause_candidate") {
|
|
1636
|
-
if (c.lifecycle !== "active")
|
|
2054
|
+
if (c.lifecycle !== "active") fail3(p + ".candidateActions", "pause requires the actual active original candidate");
|
|
1637
2055
|
continue;
|
|
1638
2056
|
}
|
|
1639
|
-
if (finite.inventoryState !== "complete" || finite.candidates.some((c2) => c2.lifecycle === "unknown") || c.activationsObserved !== 0 || finite.candidates.filter((c2) => c2.lifecycle === "active").length >= policy.maxConcurrentCandidates)
|
|
2057
|
+
if (finite.inventoryState !== "complete" || finite.candidates.some((c2) => c2.lifecycle === "unknown") || c.activationsObserved !== 0 || finite.candidates.filter((c2) => c2.lifecycle === "active").length >= policy.maxConcurrentCandidates) fail3(p + ".candidateActions", "unknown inventory, prior activation or concurrency blocks activation");
|
|
1640
2058
|
const firstEligible = policy.selection.candidateOrder.find((id) => {
|
|
1641
2059
|
const candidate = finite.candidates.find((c2) => c2.channelId === id), window = policy.selection.eligibilitySchedule.find((s) => s.channelId === id);
|
|
1642
2060
|
const permittedLifecycle = candidate.lifecycle === "not_materialized" && policy.allowedActions.includes("materialize_and_activate") && candidate.nativeStateEvidenceRef !== null || candidate.lifecycle === "paused" && policy.allowedActions.includes("activate_held") && candidate.commitmentEvidenceRef !== null && candidate.nativeStateEvidenceRef !== null;
|
|
1643
2061
|
return permittedLifecycle && candidate.activationsObserved === 0 && Date.parse(d.createdAt) >= Date.parse(window.notBefore) && Date.parse(d.createdAt) < Date.parse(window.notAfter);
|
|
1644
2062
|
});
|
|
1645
|
-
if (firstEligible !== c.channelId)
|
|
2063
|
+
if (firstEligible !== c.channelId) fail3(p + ".candidateActions", "must retain the original fixed candidate order");
|
|
1646
2064
|
const schedule = policy.selection.eligibilitySchedule.find((s) => s.channelId === c.channelId);
|
|
1647
|
-
if (Date.parse(d.createdAt) < Date.parse(schedule.notBefore) || Date.parse(d.createdAt) >= Date.parse(schedule.notAfter))
|
|
1648
|
-
if (a.action === "materialize_and_activate" && (c.lifecycle !== "not_materialized" || c.commitmentEvidenceRef !== null))
|
|
1649
|
-
if (a.action === "activate_held" && (c.lifecycle !== "paused" || !c.commitmentEvidenceRef || c.commitmentEvidenceRef.commitmentOperationId !== a.commitmentOperationId))
|
|
1650
|
-
if (compareMoney(c.cap, policy.totalExplorationCap) > 0)
|
|
1651
|
-
if (finite.trackingState !== "healthy" || c.trackingState !== "healthy" || c.coverageBasisPoints === null || c.coverageBasisPoints < policy.measurementGuard.minimumCoverageBasisPoints)
|
|
2065
|
+
if (Date.parse(d.createdAt) < Date.parse(schedule.notBefore) || Date.parse(d.createdAt) >= Date.parse(schedule.notAfter)) fail3(p + ".candidateActions", "outside original selection window");
|
|
2066
|
+
if (a.action === "materialize_and_activate" && (c.lifecycle !== "not_materialized" || c.commitmentEvidenceRef !== null)) fail3(p + ".candidateActions", "new create requires original absence, not a borrowed hold");
|
|
2067
|
+
if (a.action === "activate_held" && (c.lifecycle !== "paused" || !c.commitmentEvidenceRef || c.commitmentEvidenceRef.commitmentOperationId !== a.commitmentOperationId)) fail3(p + ".candidateActions", "held activation requires the exact original commitment reference");
|
|
2068
|
+
if (compareMoney(c.cap, policy.totalExplorationCap) > 0) fail3(p + ".candidateActions", "original full cap exceeds reviewed exploration ceiling");
|
|
2069
|
+
if (finite.trackingState !== "healthy" || c.trackingState !== "healthy" || c.coverageBasisPoints === null || c.coverageBasisPoints < policy.measurementGuard.minimumCoverageBasisPoints) fail3(p + ".candidateActions", "current required tracking coverage unavailable");
|
|
1652
2070
|
for (const check of policy.measurementGuard.requiredChecks) {
|
|
1653
|
-
if (check === "dedupe" && c.dedupeCheck !== "pass" || check === "qualification" && c.qualificationCheck !== "pass")
|
|
1654
|
-
if (["uncertainty", "assignment", "power"].includes(check))
|
|
2071
|
+
if (check === "dedupe" && c.dedupeCheck !== "pass" || check === "qualification" && c.qualificationCheck !== "pass") fail3(p + ".candidateActions", "required source check unavailable");
|
|
2072
|
+
if (["uncertainty", "assignment", "power"].includes(check)) fail3(p + ".candidateActions", "fixed exploration has no adopted measured/assignment decision policy");
|
|
1655
2073
|
}
|
|
1656
2074
|
}
|
|
1657
2075
|
}
|
|
1658
2076
|
var RESONANCE_OPTIMIZATION_EVIDENCE_JSON_SCHEMA = optimizationEvidence.schema;
|
|
1659
2077
|
var RESONANCE_OPTIMIZATION_DECISION_JSON_SCHEMA = optimizationDecision.schema;
|
|
1660
|
-
var metaBrowserWitness = object2({ controlsRevision:
|
|
2078
|
+
var metaBrowserWitness = object2({ controlsRevision: text3(60, /^[A-Z][A-Z0-9_]*$/), policyRevision: revision, witnessId: uuid, assertedAt: instant });
|
|
1661
2079
|
var publicDestination = union2(
|
|
1662
|
-
object2({ provider: literal2("google_ads"), id: uuid, tagId:
|
|
2080
|
+
object2({ provider: literal2("google_ads"), id: uuid, tagId: text3(40, /^AW-[0-9]+$/) }),
|
|
1663
2081
|
// browserWitness and tagManagerAttested are optional so configurations from before the Meta loader keep parsing; absent means no Meta browser loading.
|
|
1664
|
-
object2({ provider: literal2("meta_ads"), id: uuid, pixelId:
|
|
2082
|
+
object2({ provider: literal2("meta_ads"), id: uuid, pixelId: text3(40, /^[0-9]+$/), browserWitness: optional2(metaBrowserWitness), tagManagerAttested: optional2(bool) })
|
|
1665
2083
|
);
|
|
1666
|
-
var interestResource = object2({ ...scope, type: choice2("page", "article", "product", "listing"), id:
|
|
2084
|
+
var interestResource = object2({ ...scope, type: choice2("page", "article", "product", "listing"), id: text3(160, /^[a-zA-Z0-9._:-]+$/), revision });
|
|
1667
2085
|
var measurementConfig = object2({
|
|
1668
2086
|
schemaVersion: literal2(1),
|
|
1669
2087
|
...scope,
|
|
@@ -1674,7 +2092,7 @@ var measurementConfig = object2({
|
|
|
1674
2092
|
consentPolicy: object2({ mode: literal2("basic"), requiredPurposes: list2(purpose, 4, 1) }),
|
|
1675
2093
|
destinations: list2(publicDestination, 10),
|
|
1676
2094
|
// metaEligible is set by a person with owner or admin standing; absent means false. The browser never decides it.
|
|
1677
|
-
resourceRules: list2(object2({ id: uuid, revision, site, resource: interestResource, path, interestKey:
|
|
2095
|
+
resourceRules: list2(object2({ id: uuid, revision, site, resource: interestResource, path, interestKey: text3(100, /^[a-zA-Z0-9._:-]+$/), metaEligible: optional2(bool) }), 500)
|
|
1678
2096
|
});
|
|
1679
2097
|
function parseResonanceMeasurementConfig(v) {
|
|
1680
2098
|
const r = measurementConfig.read(v, "measurementConfig");
|
|
@@ -1682,7 +2100,7 @@ function parseResonanceMeasurementConfig(v) {
|
|
|
1682
2100
|
unique(r.destinations.map((d) => d.id), "measurementConfig.destinations");
|
|
1683
2101
|
unique(r.consentPolicy.requiredPurposes, "measurementConfig.consentPolicy.requiredPurposes");
|
|
1684
2102
|
unique(r.resourceRules.map((rule) => rule.id), "measurementConfig.resourceRules");
|
|
1685
|
-
if (r.destinations.length && ["ad_storage", "ad_user_data", "ad_personalization"].some((p) => !r.consentPolicy.requiredPurposes.includes(p)))
|
|
2103
|
+
if (r.destinations.length && ["ad_storage", "ad_user_data", "ad_personalization"].some((p) => !r.consentPolicy.requiredPurposes.includes(p))) fail3("measurementConfig.consentPolicy", "provider minimum purposes are mandatory");
|
|
1686
2104
|
return r;
|
|
1687
2105
|
}
|
|
1688
2106
|
function resonanceMeasurementConfigDigestInput(value) {
|
|
@@ -1690,7 +2108,7 @@ function resonanceMeasurementConfigDigestInput(value) {
|
|
|
1690
2108
|
return canonical(semantic);
|
|
1691
2109
|
}
|
|
1692
2110
|
var clickIdentifierPattern = /^[^\s\u0000-\u001f\u007f-\u009f]+(?![\s\S])/;
|
|
1693
|
-
var clickIdentifier = field2({ type: "string", minLength: 1, maxLength: 1024, pattern: clickIdentifierPattern.source }, (v, p) => typeof v === "string" && v.length <= 2048 && [...v].length <= 1024 && clickIdentifierPattern.test(v) ? v :
|
|
2111
|
+
var clickIdentifier = field2({ type: "string", minLength: 1, maxLength: 1024, pattern: clickIdentifierPattern.source }, (v, p) => typeof v === "string" && v.length <= 2048 && [...v].length <= 1024 && clickIdentifierPattern.test(v) ? v : fail3(p, "invalid click identifier"));
|
|
1694
2112
|
var clickIdentifiersShape = union2(object2({ gclid: clickIdentifier }), object2({ gbraid: clickIdentifier }), object2({ wbraid: clickIdentifier }));
|
|
1695
2113
|
var clickIdentifiers = field2(clickIdentifiersShape.schema, clickIdentifiersShape.read);
|
|
1696
2114
|
var parseResonanceClickIdentifiers = (v) => clickIdentifiers.read(v, "clickIdentifiers");
|
|
@@ -1698,13 +2116,13 @@ var RESONANCE_CLICK_IDENTIFIERS_JSON_SCHEMA = clickIdentifiers.schema;
|
|
|
1698
2116
|
var observedPathControl = /[\s\u0000-\u001f\u007f-\u009f]/;
|
|
1699
2117
|
var observedPagePath = field2({ ...path.schema, allOf: [{ not: { pattern: observedPathControl.source } }] }, (v, p) => {
|
|
1700
2118
|
const result = path.read(v, p);
|
|
1701
|
-
if (observedPathControl.test(result))
|
|
2119
|
+
if (observedPathControl.test(result)) fail3(p, "invalid observed path");
|
|
1702
2120
|
return result;
|
|
1703
2121
|
});
|
|
1704
2122
|
var metaCookieShape = object2({ source: literal2(RESONANCE_WEBSITE_VISIT_PROFILE.source), fbp: optional2(clickIdentifier), fbc: optional2(clickIdentifier) });
|
|
1705
2123
|
var metaCookieObservation = field2({ ...metaCookieShape.schema, anyOf: [{ required: ["fbp"] }, { required: ["fbc"] }] }, (v, p) => {
|
|
1706
2124
|
const result = metaCookieShape.read(v, p);
|
|
1707
|
-
if (!result.fbp && !result.fbc)
|
|
2125
|
+
if (!result.fbp && !result.fbc) fail3(p, "requires an actual reported cookie value");
|
|
1708
2126
|
return result;
|
|
1709
2127
|
});
|
|
1710
2128
|
var occurrenceShape = object2({
|
|
@@ -1730,17 +2148,17 @@ var occurrence = field2({ ...occurrenceShape.schema, allOf: [
|
|
|
1730
2148
|
{ if: { required: ["metaCookieObservation"] }, then: { required: ["pagePath"], properties: { kind: { const: "page_view" }, resourceRef: interestResource.schema } } }
|
|
1731
2149
|
] }, (v, p) => {
|
|
1732
2150
|
const r = occurrenceShape.read(v, p);
|
|
1733
|
-
if (r.clickIdentifiers && r.kind !== "page_view")
|
|
1734
|
-
if (r.pagePath !== void 0 && r.kind !== "page_view" && r.kind !== "experiment_exposure")
|
|
1735
|
-
if (r.metaCookieObservation && (r.kind !== "page_view" || r.pagePath === void 0 || !r.resourceRef))
|
|
2151
|
+
if (r.clickIdentifiers && r.kind !== "page_view") fail3(p + ".clickIdentifiers", "requires page_view");
|
|
2152
|
+
if (r.pagePath !== void 0 && r.kind !== "page_view" && r.kind !== "experiment_exposure") fail3(p + ".pagePath", "requires page_view or experiment_exposure");
|
|
2153
|
+
if (r.metaCookieObservation && (r.kind !== "page_view" || r.pagePath === void 0 || !r.resourceRef)) fail3(p + ".metaCookieObservation", "requires the same page_view path and resource");
|
|
1736
2154
|
return r;
|
|
1737
2155
|
});
|
|
1738
2156
|
function parseResonanceMeasurementOccurrence(v) {
|
|
1739
2157
|
const r = occurrence.read(v, "occurrence");
|
|
1740
2158
|
scoped(r, r.projectId, [r.site], "occurrence");
|
|
1741
2159
|
unique(r.consentReceiptRefs.map((c) => c.purpose), "occurrence.consentReceiptRefs");
|
|
1742
|
-
if (r.kind === "content_interest" && !r.resourceRef)
|
|
1743
|
-
if (r.kind === "experiment_exposure" && !r.experiment)
|
|
2160
|
+
if (r.kind === "content_interest" && !r.resourceRef) fail3("occurrence.resourceRef", "content interest requires resource");
|
|
2161
|
+
if (r.kind === "experiment_exposure" && !r.experiment) fail3("occurrence.experiment", "exposure requires assignment context");
|
|
1744
2162
|
return r;
|
|
1745
2163
|
}
|
|
1746
2164
|
var consentUpdate = object2({ schemaVersion: literal2(1), ...scope, configRevision: revision, policyRevision: revision, expectedConsentRevision: integer2(0), occurredAt: instant, idempotencyKey: operationKey, source: choice2("cmp", "user_preference"), purposes: list2(object2({ purpose, state: choice2("unknown", "granted", "denied", "withdrawn") }), 4, 1) });
|
|
@@ -1760,12 +2178,12 @@ function resonanceOptimizationDecisionDigestInput(v) {
|
|
|
1760
2178
|
const { requestDigest: _digest, ...body } = parseResonanceOptimizationDecision(v);
|
|
1761
2179
|
return canonical(body);
|
|
1762
2180
|
}
|
|
1763
|
-
var consentResult = object2({ subjectProof:
|
|
2181
|
+
var consentResult = object2({ subjectProof: text3(200, /^[a-zA-Z0-9_-]{32,}$/), expiresAt: instant, currentConsentRevision: integer2(1), receipts: list2(consent, 4, 4) });
|
|
1764
2182
|
function parseResonanceConsentResponse(v) {
|
|
1765
2183
|
const r = consentResult.read(v, "consentResponse"), first = r.receipts[0];
|
|
1766
|
-
if (r.receipts.some((c) => c.consentRevision !== r.currentConsentRevision))
|
|
2184
|
+
if (r.receipts.some((c) => c.consentRevision !== r.currentConsentRevision)) fail3("consentResponse.receipts", "global consent revision mismatch");
|
|
1767
2185
|
unique(r.receipts.map((c) => c.purpose), "consentResult.receipts");
|
|
1768
|
-
for (const c of r.receipts) if (c.projectId !== first.projectId || c.site !== first.site || c.configRevision !== first.configRevision || c.policyRevision !== first.policyRevision || c.visitorNamespace !== first.visitorNamespace)
|
|
2186
|
+
for (const c of r.receipts) if (c.projectId !== first.projectId || c.site !== first.site || c.configRevision !== first.configRevision || c.policyRevision !== first.policyRevision || c.visitorNamespace !== first.visitorNamespace) fail3("consentResult.receipts", "mixed consent subjects or scope");
|
|
1769
2187
|
return r;
|
|
1770
2188
|
}
|
|
1771
2189
|
var occurrenceResult = object2({ eventId: uuid, accepted: literal2(true), replayed: bool, exposureId: nullable2(uuid) });
|
|
@@ -1786,12 +2204,12 @@ var audienceDraft = object2({
|
|
|
1786
2204
|
schemaVersion: literal2(1),
|
|
1787
2205
|
expectedRevision: optional2(integer2(1)),
|
|
1788
2206
|
idempotencyKey: operationKey,
|
|
1789
|
-
definition: object2({ name:
|
|
2207
|
+
definition: object2({ name: text3(160), site, accountBindingId: uuid, resourceRuleId: uuid, excludedResourceRuleIds: list2(uuid, 50), retentionDays: integer2(1, 540), minDaysSinceVisit: optional2(integer2(1, 179)), policyRevision: revision, currentConsentPolicyRevision: revision })
|
|
1790
2208
|
});
|
|
1791
2209
|
function parseResonanceAudienceDraftSaveCommand(v) {
|
|
1792
2210
|
const r = audienceDraft.read(v, "audienceDraftSave");
|
|
1793
2211
|
unique(r.definition.excludedResourceRuleIds, "audienceDraftSave.definition.excludedResourceRuleIds");
|
|
1794
|
-
if (r.definition.minDaysSinceVisit !== void 0 && r.definition.minDaysSinceVisit >= r.definition.retentionDays)
|
|
2212
|
+
if (r.definition.minDaysSinceVisit !== void 0 && r.definition.minDaysSinceVisit >= r.definition.retentionDays) fail3("audienceDraftSave.definition.minDaysSinceVisit", "must be shorter than the retention window");
|
|
1795
2213
|
return r;
|
|
1796
2214
|
}
|
|
1797
2215
|
var RESONANCE_AUDIENCE_DRAFT_SAVE_COMMAND_JSON_SCHEMA = audienceDraft.schema;
|
|
@@ -1800,20 +2218,20 @@ var experimentCreateField = field2(SIGNAL_EXPERIMENT_CREATE_JSON_SCHEMA, (v, p)
|
|
|
1800
2218
|
try {
|
|
1801
2219
|
return parseSignalExperimentCreate(v);
|
|
1802
2220
|
} catch (error) {
|
|
1803
|
-
return
|
|
2221
|
+
return fail3(p, error instanceof Error ? error.message : "invalid experiment");
|
|
1804
2222
|
}
|
|
1805
2223
|
});
|
|
1806
2224
|
var experimentUpdateField = field2(SIGNAL_EXPERIMENT_UPDATE_JSON_SCHEMA, (v, p) => {
|
|
1807
2225
|
try {
|
|
1808
2226
|
return parseSignalExperimentUpdate(v);
|
|
1809
2227
|
} catch (error) {
|
|
1810
|
-
return
|
|
2228
|
+
return fail3(p, error instanceof Error ? error.message : "invalid experiment");
|
|
1811
2229
|
}
|
|
1812
2230
|
});
|
|
1813
2231
|
var managedExperimentCreate = object2({ ...managedExperimentBase, experiment: experimentCreateField });
|
|
1814
2232
|
var managedExperimentUpdate = object2({ ...managedExperimentBase, experiment: experimentUpdateField });
|
|
1815
2233
|
var managedExperimentLifecycle = object2(managedExperimentBase);
|
|
1816
|
-
var managedExperimentComplete = object2({ ...managedExperimentBase, winnerVariant:
|
|
2234
|
+
var managedExperimentComplete = object2({ ...managedExperimentBase, winnerVariant: text3(80) });
|
|
1817
2235
|
var managedExperimentLink = object2({ ...managedExperimentBase, experimentId: uuid });
|
|
1818
2236
|
var parseResonanceExperimentCreateCommand = (v) => managedExperimentCreate.read(v, "experimentCreateCommand");
|
|
1819
2237
|
var parseResonanceExperimentUpdateCommand = (v) => managedExperimentUpdate.read(v, "experimentUpdateCommand");
|
|
@@ -1827,18 +2245,18 @@ var RESONANCE_EXPERIMENT_COMPLETE_COMMAND_JSON_SCHEMA = managedExperimentComplet
|
|
|
1827
2245
|
var RESONANCE_EXPERIMENT_LINK_COMMAND_JSON_SCHEMA = managedExperimentLink.schema;
|
|
1828
2246
|
var nativePageRevision = field2({ ...instant.schema, pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z(?![\\s\\S])" }, (v, p) => {
|
|
1829
2247
|
const result = instant.read(v, p);
|
|
1830
|
-
if (new Date(result).toISOString() !== result)
|
|
2248
|
+
if (new Date(result).toISOString() !== result) fail3(p, "requires canonical UTC milliseconds");
|
|
1831
2249
|
return result;
|
|
1832
2250
|
});
|
|
1833
|
-
var positiveRevision =
|
|
1834
|
-
var friendlyName = field2({ type: "string", minLength: 0, maxLength: 200 }, (v, p) => typeof v === "string" && [...v].length <= 200 ? v :
|
|
2251
|
+
var positiveRevision = text3(128, /^[1-9][0-9]*(?![\s\S])/);
|
|
2252
|
+
var friendlyName = field2({ type: "string", minLength: 0, maxLength: 200 }, (v, p) => typeof v === "string" && [...v].length <= 200 ? v : fail3(p, "invalid friendly name"));
|
|
1835
2253
|
var setupConsentPolicyShape = object2({ mode: literal2("basic"), requiredPurposes: uniqueList(purpose, 4, 3) });
|
|
1836
2254
|
var setupConsentPolicy = field2({ ...setupConsentPolicyShape.schema, allOf: [{ properties: { requiredPurposes: { allOf: ["ad_storage", "ad_user_data", "ad_personalization"].map((value) => ({ contains: { const: value } })) } } }] }, (input, p) => {
|
|
1837
2255
|
const v = setupConsentPolicyShape.read(input, p);
|
|
1838
|
-
for (const required of ["ad_storage", "ad_user_data", "ad_personalization"]) if (!v.requiredPurposes.includes(required))
|
|
2256
|
+
for (const required of ["ad_storage", "ad_user_data", "ad_personalization"]) if (!v.requiredPurposes.includes(required)) fail3(p, "all advertising purpose requirements are mandatory");
|
|
1839
2257
|
return v;
|
|
1840
2258
|
});
|
|
1841
|
-
var measurementSave =
|
|
2259
|
+
var measurementSave = refine3(object2({
|
|
1842
2260
|
schemaVersion: literal2(1),
|
|
1843
2261
|
site,
|
|
1844
2262
|
expectedCampaignRevision: integer2(1),
|
|
@@ -1855,20 +2273,20 @@ var measurementSavedFields = { configurationRevision: integer2(1), configuration
|
|
|
1855
2273
|
object2(measurementSavedFields);
|
|
1856
2274
|
function checkMeasurementSaved(v, p) {
|
|
1857
2275
|
const config = parseResonanceMeasurementConfig(v.configuration);
|
|
1858
|
-
if (config.projectId !== v.projectId || config.site !== v.site)
|
|
2276
|
+
if (config.projectId !== v.projectId || config.site !== v.site) fail3(p + ".configuration", "configuration scope mismatch");
|
|
1859
2277
|
positiveRevision.read(config.configRevision, p + ".configuration.configRevision");
|
|
1860
2278
|
positiveRevision.read(config.policyRevision, p + ".configuration.policyRevision");
|
|
1861
2279
|
setupConsentPolicy.read(config.consentPolicy, p + ".configuration.consentPolicy");
|
|
1862
2280
|
unique(v.pages.map((page2) => page2.pageId), p + ".pages");
|
|
1863
|
-
if (v.pages.length !== config.resourceRules.length)
|
|
2281
|
+
if (v.pages.length !== config.resourceRules.length) fail3(p + ".pages", "must cover the exact native page rules");
|
|
1864
2282
|
for (const page2 of v.pages) {
|
|
1865
2283
|
const rule = config.resourceRules.find((rule2) => rule2.id === page2.resourceRuleId);
|
|
1866
|
-
if (page2.resourceRuleId !== page2.pageId || page2.resourceRuleRevision !== page2.evidenceDigest || !rule || rule.revision !== page2.evidenceDigest || rule.path !== page2.path || rule.interestKey !== page2.pageId || rule.resource.type !== "page" || rule.resource.id !== page2.pageId || rule.resource.revision !== page2.pageRevision)
|
|
2284
|
+
if (page2.resourceRuleId !== page2.pageId || page2.resourceRuleRevision !== page2.evidenceDigest || !rule || rule.revision !== page2.evidenceDigest || rule.path !== page2.path || rule.interestKey !== page2.pageId || rule.resource.type !== "page" || rule.resource.id !== page2.pageId || rule.resource.revision !== page2.pageRevision) fail3(p + ".pages", "native page/resource/rule version mismatch");
|
|
1867
2285
|
}
|
|
1868
2286
|
}
|
|
1869
|
-
var measurementCurrent =
|
|
2287
|
+
var measurementCurrent = refine3(union2(
|
|
1870
2288
|
object2({ schemaVersion: literal2(1), kind: literal2("unconfigured"), ...scope, configurationRevision: literal2(0) }),
|
|
1871
|
-
object2({ schemaVersion: literal2(1), kind: literal2("configured"), ...scope, ...measurementSavedFields, reasonCodes: uniqueList(
|
|
2289
|
+
object2({ schemaVersion: literal2(1), kind: literal2("configured"), ...scope, ...measurementSavedFields, reasonCodes: uniqueList(text3(200), 100) })
|
|
1872
2290
|
), (v, p) => {
|
|
1873
2291
|
if (v.kind === "configured") checkMeasurementSaved(v, p);
|
|
1874
2292
|
});
|
|
@@ -1877,8 +2295,8 @@ var measurementSnapshotShape = object2(measurementSnapshotFields);
|
|
|
1877
2295
|
function checkMeasurementSnapshot(v, p) {
|
|
1878
2296
|
checkMeasurementSaved({ ...v, saveOperationId: v.operationId }, p);
|
|
1879
2297
|
}
|
|
1880
|
-
var measurementSnapshot =
|
|
1881
|
-
var measurementSaveResponse =
|
|
2298
|
+
var measurementSnapshot = refine3(measurementSnapshotShape, checkMeasurementSnapshot);
|
|
2299
|
+
var measurementSaveResponse = refine3(object2({ ...measurementSnapshotFields, replayed: bool }), checkMeasurementSnapshot);
|
|
1882
2300
|
var parseResonanceMeasurementConfigurationCurrent = (v) => measurementCurrent.read(v, "measurementConfigurationCurrent");
|
|
1883
2301
|
var parseResonanceMeasurementConfigurationSnapshot = (v) => measurementSnapshot.read(v, "measurementConfigurationSnapshot");
|
|
1884
2302
|
var parseResonanceMeasurementConfigurationSaveResponse = (v) => measurementSaveResponse.read(v, "measurementConfigurationSaveResponse");
|
|
@@ -1886,9 +2304,9 @@ var measurementProjectionContext = object2({ projectId: uuid, current: measureme
|
|
|
1886
2304
|
function projectResonanceMeasurementConfiguration(value, context) {
|
|
1887
2305
|
const command2 = parseResonanceMeasurementConfigurationSaveCommand(value), actual = measurementProjectionContext.read(context, "measurementConfigurationProjection");
|
|
1888
2306
|
const current = parseResonanceMeasurementConfigurationCurrent(actual.current);
|
|
1889
|
-
if (current.projectId !== actual.projectId || current.site !== command2.site || current.configurationRevision !== command2.expectedConfigurationRevision)
|
|
2307
|
+
if (current.projectId !== actual.projectId || current.site !== command2.site || current.configurationRevision !== command2.expectedConfigurationRevision) fail3("measurementConfigurationProjection.current", "scope or configuration CAS mismatch");
|
|
1890
2308
|
unique(actual.pages.map((page2) => page2.pageId), "measurementConfigurationProjection.pages");
|
|
1891
|
-
if (actual.pages.length !== command2.pages.length || actual.pages.some((page2) => !command2.pages.some((selected) => selected.pageId === page2.pageId && selected.observedRevision === page2.pageRevision && selected.observedDigest === page2.evidenceDigest)))
|
|
2309
|
+
if (actual.pages.length !== command2.pages.length || actual.pages.some((page2) => !command2.pages.some((selected) => selected.pageId === page2.pageId && selected.observedRevision === page2.pageRevision && selected.observedDigest === page2.evidenceDigest))) fail3("measurementConfigurationProjection.pages", "requires the exact selected current native page evidence");
|
|
1892
2310
|
const pages = [...actual.pages].sort((a, b) => a.pageId < b.pageId ? -1 : a.pageId > b.pageId ? 1 : 0).map((page2) => ({ ...page2, resourceRuleId: page2.pageId, resourceRuleRevision: page2.evidenceDigest }));
|
|
1893
2311
|
const consentPolicy = { ...command2.consentPolicy, requiredPurposes: [...command2.consentPolicy.requiredPurposes].sort() };
|
|
1894
2312
|
const previous = current.kind === "configured" ? current.configuration : null;
|
|
@@ -1917,10 +2335,10 @@ var RESONANCE_MEASUREMENT_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA = measurementSa
|
|
|
1917
2335
|
var RESONANCE_MEASUREMENT_CONFIGURATION_CURRENT_JSON_SCHEMA = measurementCurrent.schema;
|
|
1918
2336
|
var RESONANCE_MEASUREMENT_CONFIGURATION_SNAPSHOT_JSON_SCHEMA = measurementSnapshot.schema;
|
|
1919
2337
|
var RESONANCE_MEASUREMENT_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA = measurementSaveResponse.schema;
|
|
1920
|
-
var nativeAudienceId =
|
|
2338
|
+
var nativeAudienceId = text3(160, /^[0-9]+(?![\s\S])/);
|
|
1921
2339
|
var RESONANCE_META_DATASET_NAME_MAX_LENGTH = 160;
|
|
1922
|
-
var metaDatasetName =
|
|
1923
|
-
if (!value.trim() || value !== value.trim() || /[\x00-\x1f\x7f]/.test(value))
|
|
2340
|
+
var metaDatasetName = refine3(text3(RESONANCE_META_DATASET_NAME_MAX_LENGTH), (value, at) => {
|
|
2341
|
+
if (!value.trim() || value !== value.trim() || /[\x00-\x1f\x7f]/.test(value)) fail3(at, "requires a trimmed dataset name without control characters");
|
|
1924
2342
|
});
|
|
1925
2343
|
var parseResonanceMetaDatasetName = (value) => metaDatasetName.read(value, "metaDatasetName");
|
|
1926
2344
|
var metaDatasetExistingSelection = object2({ kind: literal2("existing"), externalId: nativeAudienceId });
|
|
@@ -1966,7 +2384,7 @@ var RESONANCE_META_DATASET_SETUP_REVIEW_JSON_SCHEMA = metaDatasetSetupReview.sch
|
|
|
1966
2384
|
var metaDatasetSetupFirstOutcome = object2({
|
|
1967
2385
|
admission: choice2("accepted", "rejected", "unknown"),
|
|
1968
2386
|
externalId: nullable2(nativeAudienceId),
|
|
1969
|
-
providerRequestId: nullable2(
|
|
2387
|
+
providerRequestId: nullable2(text3(200)),
|
|
1970
2388
|
providerRequestDigest: digest
|
|
1971
2389
|
});
|
|
1972
2390
|
var metaSetupVerificationFields = {
|
|
@@ -1987,39 +2405,39 @@ var metaSetupReceiptFields = {
|
|
|
1987
2405
|
requestDigest: digest,
|
|
1988
2406
|
status: choice2("pending", "selected", "created_unverified", "verified", "rejected", "uncertain", "cancelled"),
|
|
1989
2407
|
firstOutcome: nullable2(metaDatasetSetupFirstOutcome),
|
|
1990
|
-
reasonCodes: uniqueList(
|
|
2408
|
+
reasonCodes: uniqueList(text3(80, /^[a-z][a-z0-9_]*$/), 30)
|
|
1991
2409
|
};
|
|
1992
2410
|
function checkMetaSetupReceipt(value, at, resource2) {
|
|
1993
2411
|
const { status, firstOutcome, currentVerification } = value;
|
|
1994
2412
|
if (firstOutcome && firstOutcome.admission === "accepted" !== (firstOutcome.externalId !== null)) {
|
|
1995
|
-
|
|
2413
|
+
fail3(at + ".firstOutcome", "requires the original provider ID exactly when creation was accepted");
|
|
1996
2414
|
}
|
|
1997
2415
|
switch (status) {
|
|
1998
2416
|
case "pending":
|
|
1999
2417
|
case "cancelled":
|
|
2000
|
-
if (firstOutcome || currentVerification)
|
|
2418
|
+
if (firstOutcome || currentVerification) fail3(at, "cannot carry a creation outcome or verification");
|
|
2001
2419
|
break;
|
|
2002
2420
|
case "selected":
|
|
2003
|
-
if (firstOutcome || !currentVerification)
|
|
2421
|
+
if (firstOutcome || !currentVerification) fail3(at, "requires verified existing selection without a creation outcome");
|
|
2004
2422
|
break;
|
|
2005
2423
|
case "created_unverified":
|
|
2006
|
-
if (firstOutcome?.admission !== "accepted" || currentVerification)
|
|
2424
|
+
if (firstOutcome?.admission !== "accepted" || currentVerification) fail3(at, "requires accepted creation and no verified readback");
|
|
2007
2425
|
break;
|
|
2008
2426
|
case "verified":
|
|
2009
2427
|
if (firstOutcome?.admission !== "accepted" || !currentVerification || firstOutcome.externalId !== currentVerification.externalId) {
|
|
2010
|
-
|
|
2428
|
+
fail3(at, `requires verified readback of the exact created ${resource2}`);
|
|
2011
2429
|
}
|
|
2012
2430
|
break;
|
|
2013
2431
|
case "rejected":
|
|
2014
|
-
if (firstOutcome?.admission !== "rejected")
|
|
2432
|
+
if (firstOutcome?.admission !== "rejected") fail3(at, "requires the original rejection");
|
|
2015
2433
|
break;
|
|
2016
2434
|
case "uncertain":
|
|
2017
|
-
if (firstOutcome?.admission !== "unknown" || currentVerification)
|
|
2435
|
+
if (firstOutcome?.admission !== "unknown" || currentVerification) fail3(at, `requires an unknown outcome without an attributable ${resource2}`);
|
|
2018
2436
|
break;
|
|
2019
2437
|
}
|
|
2020
2438
|
}
|
|
2021
2439
|
var metaSetupReceiptState = object2({ ...metaSetupReceiptFields, currentVerification: nullable2(metaDatasetSetupVerification) });
|
|
2022
|
-
var metaDatasetSetupReceipt =
|
|
2440
|
+
var metaDatasetSetupReceipt = refine3(metaSetupReceiptState, (value, at) => checkMetaSetupReceipt(value, at, "dataset"));
|
|
2023
2441
|
var parseResonanceMetaDatasetSetupReceipt = (value) => metaDatasetSetupReceipt.read(value, "metaDatasetSetupReceipt");
|
|
2024
2442
|
var RESONANCE_META_DATASET_SETUP_RECEIPT_JSON_SCHEMA = metaDatasetSetupReceipt.schema;
|
|
2025
2443
|
var metaAudienceSetupResource = object2({ externalId: nativeAudienceId, resourceRevision: revision });
|
|
@@ -2045,7 +2463,7 @@ var metaAudienceSetupPrepareFields = {
|
|
|
2045
2463
|
var metaAudienceSetupPrepare = object2(metaAudienceSetupPrepareFields);
|
|
2046
2464
|
var parseResonanceMetaAudienceSetupPrepareRequest = (value) => metaAudienceSetupPrepare.read(value, "metaAudienceSetupPrepare");
|
|
2047
2465
|
var RESONANCE_META_AUDIENCE_SETUP_PREPARE_REQUEST_JSON_SCHEMA = metaAudienceSetupPrepare.schema;
|
|
2048
|
-
var metaAudienceSetupIntent =
|
|
2466
|
+
var metaAudienceSetupIntent = refine3(object2({
|
|
2049
2467
|
...metaAudienceSetupPrepareFields,
|
|
2050
2468
|
...metaSetupOwnerFields,
|
|
2051
2469
|
audienceRuleRef: audience,
|
|
@@ -2058,11 +2476,11 @@ var metaAudienceSetupIntent = refine2(object2({
|
|
|
2058
2476
|
expiresAt: instant
|
|
2059
2477
|
}), (value, at) => {
|
|
2060
2478
|
const { audienceRule, audienceRuleRef, resourceRuleRef, excludedResourceRuleRefs, measurementConfigRef: measurementConfigRef2 } = value;
|
|
2061
|
-
if (audienceRuleRef.projectId !== value.projectId || audienceRuleRef.site !== value.site || audienceRuleRef.id !== audienceRule.id || audienceRuleRef.revision !== audienceRule.revision || audienceRuleRef.policyRevision !== measurementConfigRef2.policyRevision)
|
|
2479
|
+
if (audienceRuleRef.projectId !== value.projectId || audienceRuleRef.site !== value.site || audienceRuleRef.id !== audienceRule.id || audienceRuleRef.revision !== audienceRule.revision || audienceRuleRef.policyRevision !== measurementConfigRef2.policyRevision) fail3(at + ".audienceRuleRef", "requires the exact scoped audience and policy revision");
|
|
2062
2480
|
const excludedIds = excludedResourceRuleRefs.map((ref) => ref.id);
|
|
2063
2481
|
unique(excludedIds, at + ".excludedResourceRuleRefs");
|
|
2064
2482
|
if (excludedIds.includes(resourceRuleRef.id) || canonical([...audienceRuleRef.exclusionRuleIds].sort()) !== canonical(excludedIds.sort())) {
|
|
2065
|
-
|
|
2483
|
+
fail3(at + ".excludedResourceRuleRefs", "requires the exact exclusions disjoint from the positive rule");
|
|
2066
2484
|
}
|
|
2067
2485
|
checkAudienceBand(audienceRuleRef, "meta_ads", at + ".audienceRuleRef");
|
|
2068
2486
|
});
|
|
@@ -2079,14 +2497,14 @@ var metaAudienceSetupVerification = object2({
|
|
|
2079
2497
|
audienceSpecDigest: digest,
|
|
2080
2498
|
retentionDays: integer2(1, META_WEBSITE_AUDIENCE_MAX_RETENTION_DAYS)
|
|
2081
2499
|
});
|
|
2082
|
-
var metaAudienceSetupReceipt =
|
|
2500
|
+
var metaAudienceSetupReceipt = refine3(object2({
|
|
2083
2501
|
...metaSetupReceiptFields,
|
|
2084
2502
|
currentVerification: nullable2(metaAudienceSetupVerification)
|
|
2085
2503
|
}), (value, at) => checkMetaSetupReceipt(value, at, "audience"));
|
|
2086
2504
|
var parseResonanceMetaAudienceSetupReceipt = (value) => metaAudienceSetupReceipt.read(value, "metaAudienceSetupReceipt");
|
|
2087
2505
|
var resonanceMetaAudienceSetupReceiptDigestInput = (value) => canonical(parseResonanceMetaAudienceSetupReceipt(value));
|
|
2088
2506
|
var RESONANCE_META_AUDIENCE_SETUP_RECEIPT_JSON_SCHEMA = metaAudienceSetupReceipt.schema;
|
|
2089
|
-
var websiteVisitSetupGrantProof =
|
|
2507
|
+
var websiteVisitSetupGrantProof = refine3(object2({
|
|
2090
2508
|
schemaVersion: literal2(1),
|
|
2091
2509
|
grantOperationId: uuid,
|
|
2092
2510
|
audienceOperationId: uuid,
|
|
@@ -2102,10 +2520,10 @@ var websiteVisitSetupGrantProof = refine2(object2({
|
|
|
2102
2520
|
accountBindingId: uuid,
|
|
2103
2521
|
audience: metaAudienceSetupVerification
|
|
2104
2522
|
}), (value, at) => {
|
|
2105
|
-
if (value.grantOperationId.toLowerCase() === value.audienceOperationId.toLowerCase())
|
|
2106
|
-
if (Date.parse(value.audience.observedAt) > Date.parse(value.activatedAt) || Date.parse(value.activatedAt) >= Date.parse(value.expiresAt))
|
|
2523
|
+
if (value.grantOperationId.toLowerCase() === value.audienceOperationId.toLowerCase()) fail3(at + ".grantOperationId", "requires a distinct native grant operation");
|
|
2524
|
+
if (Date.parse(value.audience.observedAt) > Date.parse(value.activatedAt) || Date.parse(value.activatedAt) >= Date.parse(value.expiresAt)) fail3(at, "requires verification by activation and a nonempty grant window");
|
|
2107
2525
|
});
|
|
2108
|
-
var websiteVisitSetupGrantStatus =
|
|
2526
|
+
var websiteVisitSetupGrantStatus = refine3(object2({
|
|
2109
2527
|
proof: websiteVisitSetupGrantProof,
|
|
2110
2528
|
status: choice2("active", "revoked", "expired", "invalidated"),
|
|
2111
2529
|
checkedAt: instant,
|
|
@@ -2113,14 +2531,14 @@ var websiteVisitSetupGrantStatus = refine2(object2({
|
|
|
2113
2531
|
reasonCodes: metaSetupReceiptFields.reasonCodes
|
|
2114
2532
|
}), (value, at) => {
|
|
2115
2533
|
const checked = Date.parse(value.checkedAt), activated = Date.parse(value.proof.activatedAt), expires = Date.parse(value.proof.expiresAt);
|
|
2116
|
-
if (checked < activated)
|
|
2534
|
+
if (checked < activated) fail3(at + ".checkedAt", "cannot predate activation");
|
|
2117
2535
|
if (value.status === "revoked") {
|
|
2118
2536
|
if (!value.revokedAt || Date.parse(value.revokedAt) < activated || Date.parse(value.revokedAt) > checked) {
|
|
2119
|
-
|
|
2537
|
+
fail3(at + ".revokedAt", "requires the recorded revocation between activation and observation");
|
|
2120
2538
|
}
|
|
2121
|
-
} else if (value.revokedAt)
|
|
2539
|
+
} else if (value.revokedAt) fail3(at + ".revokedAt", "requires revoked status");
|
|
2122
2540
|
if (value.status === "active" && checked >= expires || value.status === "expired" && checked < expires) {
|
|
2123
|
-
|
|
2541
|
+
fail3(at + ".status", "must agree with the original expiry");
|
|
2124
2542
|
}
|
|
2125
2543
|
});
|
|
2126
2544
|
var parseResonanceWebsiteVisitSetupGrantProof = (value) => websiteVisitSetupGrantProof.read(value, "websiteVisitSetupGrantProof");
|
|
@@ -2132,23 +2550,23 @@ function checkMetaAudienceSetupStatus({ receipt: receipt2, grant }, at) {
|
|
|
2132
2550
|
if (!grant) return;
|
|
2133
2551
|
const { proof } = grant;
|
|
2134
2552
|
if (receipt2.status !== "selected" && receipt2.status !== "verified" || !receipt2.currentVerification || canonical(receipt2.currentVerification) !== canonical(proof.audience)) {
|
|
2135
|
-
|
|
2553
|
+
fail3(at + ".grant", "requires the same verified audience witness as the setup receipt");
|
|
2136
2554
|
}
|
|
2137
2555
|
if (proof.audienceOperationId !== receipt2.operationId || proof.requestDigest !== receipt2.requestDigest || proof.projectId !== receipt2.projectId || proof.campaignId !== receipt2.campaignId || proof.site !== receipt2.site || proof.accountBindingId !== receipt2.accountBindingId) {
|
|
2138
|
-
|
|
2556
|
+
fail3(at + ".grant", "requires the grant linked to this exact setup operation");
|
|
2139
2557
|
}
|
|
2140
2558
|
}
|
|
2141
2559
|
var metaAudienceSetupStatusShape = object2(metaAudienceSetupStatusFields);
|
|
2142
|
-
var metaAudienceSetupStatus =
|
|
2560
|
+
var metaAudienceSetupStatus = refine3(metaAudienceSetupStatusShape, checkMetaAudienceSetupStatus);
|
|
2143
2561
|
var parseResonanceMetaAudienceSetupStatus = (value) => metaAudienceSetupStatus.read(value, "metaAudienceSetupStatus");
|
|
2144
2562
|
var RESONANCE_META_AUDIENCE_SETUP_STATUS_JSON_SCHEMA = metaAudienceSetupStatus.schema;
|
|
2145
|
-
var metaAudienceSetupListItem =
|
|
2563
|
+
var metaAudienceSetupListItem = refine3(object2({ ledgerActionId: uuid, ...metaAudienceSetupStatusFields }), (item, at) => {
|
|
2146
2564
|
checkMetaAudienceSetupStatus(item, at);
|
|
2147
2565
|
if (item.grant && item.grant.proof.approvalActionId.toLowerCase() !== item.ledgerActionId.toLowerCase()) {
|
|
2148
|
-
|
|
2566
|
+
fail3(at + ".ledgerActionId", "requires the original approval linked to this grant");
|
|
2149
2567
|
}
|
|
2150
2568
|
});
|
|
2151
|
-
var metaAudienceSetupList =
|
|
2569
|
+
var metaAudienceSetupList = refine3(object2({
|
|
2152
2570
|
items: list2(metaAudienceSetupListItem, 25),
|
|
2153
2571
|
nextCursor: nullable2(uuid)
|
|
2154
2572
|
}), ({ items }, at) => {
|
|
@@ -2156,18 +2574,18 @@ var metaAudienceSetupList = refine2(object2({
|
|
|
2156
2574
|
});
|
|
2157
2575
|
var parseResonanceMetaAudienceSetupList = (value) => metaAudienceSetupList.read(value, "metaAudienceSetupList");
|
|
2158
2576
|
var RESONANCE_META_AUDIENCE_SETUP_LIST_JSON_SCHEMA = metaAudienceSetupList.schema;
|
|
2159
|
-
var websiteVisitSetupGrant =
|
|
2577
|
+
var websiteVisitSetupGrant = refine3(object2({
|
|
2160
2578
|
proof: websiteVisitSetupGrantProof,
|
|
2161
2579
|
intent: metaAudienceSetupIntent
|
|
2162
2580
|
}), (value, at) => {
|
|
2163
2581
|
const { proof, intent } = value;
|
|
2164
2582
|
const { audience: witness } = proof;
|
|
2165
|
-
if (intent.feed.kind !== "enable" || Date.parse(intent.feed.expiresAt) !== Date.parse(proof.expiresAt) || Date.parse(proof.activatedAt) >= Date.parse(intent.expiresAt))
|
|
2583
|
+
if (intent.feed.kind !== "enable" || Date.parse(intent.feed.expiresAt) !== Date.parse(proof.expiresAt) || Date.parse(proof.activatedAt) >= Date.parse(intent.expiresAt)) fail3(at, "requires the explicit original opt-in and an unexpired setup approval");
|
|
2166
2584
|
if (proof.projectId !== intent.projectId || proof.campaignId !== intent.campaignId || proof.site !== intent.site || proof.accountBindingId !== intent.accountBindingId || witness.externalAccountId !== intent.externalAccountId || witness.businessId !== intent.businessId || witness.datasetExternalId !== intent.dataset.externalId || witness.datasetResourceRevision !== intent.dataset.resourceRevision || witness.audienceSpecDigest !== intent.audienceSpecDigest || witness.retentionDays !== intent.audienceRuleRef.retentionDays) {
|
|
2167
|
-
|
|
2585
|
+
fail3(at, "requires the exact original scope and verified destination");
|
|
2168
2586
|
}
|
|
2169
2587
|
if (intent.selection.kind === "existing" && (witness.externalId !== intent.selection.externalId || witness.resourceRevision !== intent.selection.resourceRevision)) {
|
|
2170
|
-
|
|
2588
|
+
fail3(at, "requires verification of the exact existing audience");
|
|
2171
2589
|
}
|
|
2172
2590
|
});
|
|
2173
2591
|
var parseResonanceWebsiteVisitSetupGrant = (value) => websiteVisitSetupGrant.read(value, "websiteVisitSetupGrant");
|
|
@@ -2195,7 +2613,7 @@ function resonanceWebsiteVisitSetupEventTime(value, context) {
|
|
|
2195
2613
|
return websiteVisitEventTime(input, Date.parse(actual.activatedAt), Date.parse(actual.expiresAt), Date.parse(actual.now));
|
|
2196
2614
|
}
|
|
2197
2615
|
var nativeAudienceRef = object2({ externalId: nativeAudienceId, revision: digest });
|
|
2198
|
-
var metaSave =
|
|
2616
|
+
var metaSave = refine3(object2({
|
|
2199
2617
|
schemaVersion: literal2(1),
|
|
2200
2618
|
expectedCampaignRevision: integer2(1),
|
|
2201
2619
|
expectedConfigurationRevision: integer2(0),
|
|
@@ -2219,7 +2637,7 @@ var metaMaterialFields = {
|
|
|
2219
2637
|
configurationRevision: integer2(1),
|
|
2220
2638
|
saveOperationId: uuid,
|
|
2221
2639
|
channel: meta,
|
|
2222
|
-
account: object2({ id: uuid, externalId:
|
|
2640
|
+
account: object2({ id: uuid, externalId: text3(160), name: nullable2(friendlyName) }),
|
|
2223
2641
|
datasetName: nullable2(friendlyName),
|
|
2224
2642
|
pageName: nullable2(friendlyName),
|
|
2225
2643
|
instagramName: nullable2(friendlyName),
|
|
@@ -2231,34 +2649,34 @@ var metaMaterialFields = {
|
|
|
2231
2649
|
object2(metaMaterialFields);
|
|
2232
2650
|
function checkMetaMaterial(v, p) {
|
|
2233
2651
|
scoped(v, v.projectId, [v.site], p);
|
|
2234
|
-
if (v.channel.id !== v.channelId || v.channel.accountBindingId !== v.account.id || v.matchingProfileRef.id !== v.saveOperationId || v.matchingProfileRef.revision !== v.configurationRevision)
|
|
2235
|
-
if (!v.channel.instagramRef && v.instagramName !== null)
|
|
2652
|
+
if (v.channel.id !== v.channelId || v.channel.accountBindingId !== v.account.id || v.matchingProfileRef.id !== v.saveOperationId || v.matchingProfileRef.revision !== v.configurationRevision) fail3(p, "original channel/account/profile receipt mismatch");
|
|
2653
|
+
if (!v.channel.instagramRef && v.instagramName !== null) fail3(p + ".instagramName", "absent original Instagram identity requires null");
|
|
2236
2654
|
unique(v.rules.map((rule) => rule.id), p + ".rules");
|
|
2237
2655
|
unique(v.audiences.map((a) => a.audienceRuleRef.id), p + ".audiences");
|
|
2238
2656
|
unique(v.channel.audienceRuleRefs.map((a) => a.id), p + ".channel.audienceRuleRefs");
|
|
2239
|
-
if (v.audiences.length !== v.channel.audienceRuleRefs.length)
|
|
2657
|
+
if (v.audiences.length !== v.channel.audienceRuleRefs.length) fail3(p + ".audiences", "must cover exactly the original logical audiences");
|
|
2240
2658
|
checkMetaAudienceBands(v.channel, p + ".channel.audienceRuleRefs");
|
|
2241
2659
|
for (const a of v.audiences) {
|
|
2242
|
-
if (!v.channel.audienceRuleRefs.some((ref) => canonical(ref) === canonical(a.audienceRuleRef)))
|
|
2660
|
+
if (!v.channel.audienceRuleRefs.some((ref) => canonical(ref) === canonical(a.audienceRuleRef))) fail3(p + ".audiences", "original logical audience version mismatch");
|
|
2243
2661
|
unique(a.excludedResourceRuleRefs.map((ref) => ref.id), p + ".audiences.excludedResourceRuleRefs");
|
|
2244
2662
|
unique(a.audienceRuleRef.exclusionRuleIds, p + ".audiences.audienceRuleRef.exclusionRuleIds");
|
|
2245
|
-
if (canonical([...a.audienceRuleRef.exclusionRuleIds].sort()) !== canonical(a.excludedResourceRuleRefs.map((ref) => ref.id).sort()) || a.excludedResourceRuleRefs.some((ref) => ref.id === a.resourceRuleRef.id))
|
|
2246
|
-
for (const selected of [a.resourceRuleRef, ...a.excludedResourceRuleRefs]) if (!v.rules.some((rule) => rule.id === selected.id && rule.revision === selected.revision))
|
|
2247
|
-
if (a.selection.mode === "admitted_setup" && a.selection.setup.localOutputKey !== `audience:${a.audienceRuleRef.id}:${a.audienceRuleRef.revision}`)
|
|
2663
|
+
if (canonical([...a.audienceRuleRef.exclusionRuleIds].sort()) !== canonical(a.excludedResourceRuleRefs.map((ref) => ref.id).sort()) || a.excludedResourceRuleRefs.some((ref) => ref.id === a.resourceRuleRef.id)) fail3(p + ".audiences", "positive/excluded resource scope mismatch");
|
|
2664
|
+
for (const selected of [a.resourceRuleRef, ...a.excludedResourceRuleRefs]) if (!v.rules.some((rule) => rule.id === selected.id && rule.revision === selected.revision)) fail3(p + ".audiences", "resource rule version mismatch");
|
|
2665
|
+
if (a.selection.mode === "admitted_setup" && a.selection.setup.localOutputKey !== `audience:${a.audienceRuleRef.id}:${a.audienceRuleRef.revision}`) fail3(p + ".audiences.selection.setup.localOutputKey", "must retain the actual original SDK creator key");
|
|
2248
2666
|
}
|
|
2249
2667
|
}
|
|
2250
|
-
var metaSnapshot =
|
|
2668
|
+
var metaSnapshot = refine3(object2({ ...metaMaterialFields, configurationDigest: digest }), checkMetaMaterial);
|
|
2251
2669
|
var parseResonanceMetaConfigurationSnapshot = (v) => metaSnapshot.read(v, "metaConfigurationSnapshot");
|
|
2252
|
-
var metaDigestValue =
|
|
2670
|
+
var metaDigestValue = refine3(object2({ ...metaMaterialFields, configurationDigest: optional2(digest) }), checkMetaMaterial);
|
|
2253
2671
|
function resonanceMetaConfigurationDigestInput(v) {
|
|
2254
2672
|
const { configurationDigest: _self, ...material } = metaDigestValue.read(v, "metaConfigurationDigestInput");
|
|
2255
2673
|
return canonical(material);
|
|
2256
2674
|
}
|
|
2257
|
-
var metaCurrentMetadata = object2({ currentCampaignRevision: integer2(1), currentDefinitionDigest: digest, observedAt: instant, expiresAt: nullable2(instant), reasonCodes: uniqueList(
|
|
2675
|
+
var metaCurrentMetadata = object2({ currentCampaignRevision: integer2(1), currentDefinitionDigest: digest, observedAt: instant, expiresAt: nullable2(instant), reasonCodes: uniqueList(text3(200), 100), pendingRequirements: uniqueList(text3(200), 100) });
|
|
2258
2676
|
function metaReviewable(snapshot, metadata) {
|
|
2259
2677
|
return metadata.currentCampaignRevision >= snapshot.campaignRevision && metadata.currentDefinitionDigest === snapshot.reviewedDefinitionDigest && metadata.reasonCodes.length === 0 && metadata.expiresAt !== null && Date.parse(metadata.expiresAt) > Date.parse(metadata.observedAt);
|
|
2260
2678
|
}
|
|
2261
|
-
var metaView =
|
|
2679
|
+
var metaView = refine3(union2(
|
|
2262
2680
|
object2({ schemaVersion: literal2(1), kind: literal2("unconfigured"), projectId: uuid, campaignId: uuid, channelId: uuid, configurationRevision: literal2(0) }),
|
|
2263
2681
|
object2({
|
|
2264
2682
|
schemaVersion: literal2(1),
|
|
@@ -2273,14 +2691,14 @@ var metaView = refine2(union2(
|
|
|
2273
2691
|
observedAt: instant,
|
|
2274
2692
|
expiresAt: nullable2(instant),
|
|
2275
2693
|
readyForReview: bool,
|
|
2276
|
-
reasonCodes: uniqueList(
|
|
2277
|
-
pendingRequirements: uniqueList(
|
|
2694
|
+
reasonCodes: uniqueList(text3(200), 100),
|
|
2695
|
+
pendingRequirements: uniqueList(text3(200), 100)
|
|
2278
2696
|
})
|
|
2279
2697
|
), (v, p) => {
|
|
2280
2698
|
if (v.kind !== "configured") return;
|
|
2281
2699
|
const s = parseResonanceMetaConfigurationSnapshot(v.snapshot);
|
|
2282
|
-
if (v.projectId !== s.projectId || v.campaignId !== s.campaignId || v.channelId !== s.channelId || v.configurationRevision !== s.configurationRevision)
|
|
2283
|
-
if (v.readyForReview !== metaReviewable(s, v))
|
|
2700
|
+
if (v.projectId !== s.projectId || v.campaignId !== s.campaignId || v.channelId !== s.channelId || v.configurationRevision !== s.configurationRevision) fail3(p, "snapshot identity or configuration CAS mismatch");
|
|
2701
|
+
if (v.readyForReview !== metaReviewable(s, v)) fail3(p + ".readyForReview", "must reflect current review prerequisites only");
|
|
2284
2702
|
});
|
|
2285
2703
|
var parseResonanceMetaConfigurationView = (v) => metaView.read(v, "metaConfigurationView");
|
|
2286
2704
|
var RESONANCE_META_AUDIENCE_VERDICTS = ["ready", "too_small", "blocked", "unknown"];
|
|
@@ -2310,24 +2728,24 @@ var RESONANCE_META_AUDIENCE_REASONS = [
|
|
|
2310
2728
|
"meta_audience_name_sensitive"
|
|
2311
2729
|
];
|
|
2312
2730
|
var metaReadinessPage = object2({ resourceRuleRef: measurementRuleRef, path: observedPagePath, label: nullable2(friendlyName) });
|
|
2313
|
-
var metaAudienceSize =
|
|
2314
|
-
if (v.upper < v.lower)
|
|
2731
|
+
var metaAudienceSize = refine3(object2({ lower: integer2(0), upper: integer2(0) }), (v, p) => {
|
|
2732
|
+
if (v.upper < v.lower) fail3(p, "size bounds must be ordered");
|
|
2315
2733
|
});
|
|
2316
2734
|
var metaAudienceReadinessFields = {
|
|
2317
2735
|
verdict: choice2(...RESONANCE_META_AUDIENCE_VERDICTS),
|
|
2318
2736
|
reasonCodes: uniqueList(choice2(...RESONANCE_META_AUDIENCE_REASONS), 50),
|
|
2319
2737
|
size: nullable2(metaAudienceSize)
|
|
2320
2738
|
};
|
|
2321
|
-
var metaAudienceSetupReadiness =
|
|
2739
|
+
var metaAudienceSetupReadiness = refine3(object2({
|
|
2322
2740
|
status: metaAudienceSetupStatus,
|
|
2323
2741
|
delivery: nullable2(object2(websiteVisitSetupAcceptedVisitFields)),
|
|
2324
2742
|
providerAudience: nullable2(object2({ externalId: nativeAudienceId, observedAt: instant, readiness: object2(metaAudienceReadinessFields) }))
|
|
2325
2743
|
}), ({ status, delivery, providerAudience }, at) => {
|
|
2326
2744
|
if (delivery && (!status.grant || Date.parse(delivery.checkedAt) < Date.parse(status.grant.proof.activatedAt))) {
|
|
2327
|
-
|
|
2745
|
+
fail3(at + ".delivery", "requires the grant and an observation at or after activation");
|
|
2328
2746
|
}
|
|
2329
2747
|
if (providerAudience && (status.receipt.status !== "selected" && status.receipt.status !== "verified" || status.receipt.currentVerification?.externalId !== providerAudience.externalId)) {
|
|
2330
|
-
|
|
2748
|
+
fail3(at + ".providerAudience", "requires observation of the exact verified audience");
|
|
2331
2749
|
}
|
|
2332
2750
|
});
|
|
2333
2751
|
var parseResonanceMetaAudienceSetupReadiness = (value) => metaAudienceSetupReadiness.read(value, "metaAudienceSetupReadiness");
|
|
@@ -2337,23 +2755,23 @@ var metaReadinessCheck = union2(
|
|
|
2337
2755
|
object2({ state: literal2("observed"), mappingSource: choice2("selected_external_audience", "current_materialized_audience"), ...metaAudienceReadinessFields, observedAt: instant, expiresAt: nullable2(instant), sizeObservedAt: literal2(null), sizeExpiresAt: literal2(null) })
|
|
2338
2756
|
);
|
|
2339
2757
|
var metaReadinessAudience = object2({ audienceRuleRef: audience, name: friendlyName, includedPage: metaReadinessPage, excludedPages: list2(metaReadinessPage, 50), nativeAudienceId: nullable2(nativeAudienceId), check: metaReadinessCheck });
|
|
2340
|
-
var metaRetargetingReadiness =
|
|
2758
|
+
var metaRetargetingReadiness = refine3(object2({ schemaVersion: literal2(1), projectId: uuid, campaignId: uuid, channelId: uuid, site, campaignRevision: integer2(1), accountBindingId: uuid, configuration: metaView, audiences: list2(metaReadinessAudience, 50) }), (v, p) => {
|
|
2341
2759
|
const sameId = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
2342
2760
|
const config = v.configuration;
|
|
2343
|
-
if (!sameId(config.projectId, v.projectId) || !sameId(config.campaignId, v.campaignId) || !sameId(config.channelId, v.channelId))
|
|
2344
|
-
if (config.kind === "configured" && (config.currentCampaignRevision !== v.campaignRevision || config.snapshot.site !== v.site || !sameId(config.snapshot.account.id, v.accountBindingId)))
|
|
2761
|
+
if (!sameId(config.projectId, v.projectId) || !sameId(config.campaignId, v.campaignId) || !sameId(config.channelId, v.channelId)) fail3(p + ".configuration", "configuration scope mismatch");
|
|
2762
|
+
if (config.kind === "configured" && (config.currentCampaignRevision !== v.campaignRevision || config.snapshot.site !== v.site || !sameId(config.snapshot.account.id, v.accountBindingId))) fail3(p + ".configuration", "current configuration revision, site or account mismatch");
|
|
2345
2763
|
unique(v.audiences.map((row) => row.audienceRuleRef.id.toLowerCase()), p + ".audiences");
|
|
2346
2764
|
for (const row of v.audiences) {
|
|
2347
|
-
if (!sameId(row.audienceRuleRef.projectId, v.projectId) || row.audienceRuleRef.site !== v.site)
|
|
2765
|
+
if (!sameId(row.audienceRuleRef.projectId, v.projectId) || row.audienceRuleRef.site !== v.site) fail3(p + ".audiences", "audience scope mismatch");
|
|
2348
2766
|
const excluded = row.excludedPages.map((page2) => page2.resourceRuleRef.id.toLowerCase());
|
|
2349
2767
|
unique(excluded, p + ".audiences.excludedPages");
|
|
2350
2768
|
const expected = row.audienceRuleRef.exclusionRuleIds.map((id) => id.toLowerCase());
|
|
2351
2769
|
unique(expected, p + ".audiences.audienceRuleRef.exclusionRuleIds");
|
|
2352
|
-
if (excluded.includes(row.includedPage.resourceRuleRef.id.toLowerCase()) || excluded.length !== expected.length || expected.some((id) => !excluded.includes(id)))
|
|
2353
|
-
if (row.check.state === "observed" && (row.nativeAudienceId === null || config.kind !== "configured"))
|
|
2770
|
+
if (excluded.includes(row.includedPage.resourceRuleRef.id.toLowerCase()) || excluded.length !== expected.length || expected.some((id) => !excluded.includes(id))) fail3(p + ".audiences.excludedPages", "exclusion rule scope mismatch");
|
|
2771
|
+
if (row.check.state === "observed" && (row.nativeAudienceId === null || config.kind !== "configured")) fail3(p + ".audiences.check", "observed check requires configured scope and actual native audience identity");
|
|
2354
2772
|
if (config.kind === "configured" && config.currentDefinitionDigest === config.snapshot.reviewedDefinitionDigest) {
|
|
2355
2773
|
const original = config.snapshot.audiences.find((a) => sameId(a.audienceRuleRef.id, row.audienceRuleRef.id));
|
|
2356
|
-
if (!original || canonical(original.audienceRuleRef) !== canonical(row.audienceRuleRef) || canonical(original.resourceRuleRef) !== canonical(row.includedPage.resourceRuleRef) || original.excludedResourceRuleRefs.length !== row.excludedPages.length || original.excludedResourceRuleRefs.some((ref) => !row.excludedPages.some((page2) => canonical(page2.resourceRuleRef) === canonical(ref))))
|
|
2774
|
+
if (!original || canonical(original.audienceRuleRef) !== canonical(row.audienceRuleRef) || canonical(original.resourceRuleRef) !== canonical(row.includedPage.resourceRuleRef) || original.excludedResourceRuleRefs.length !== row.excludedPages.length || original.excludedResourceRuleRefs.some((ref) => !row.excludedPages.some((page2) => canonical(page2.resourceRuleRef) === canonical(ref)))) fail3(p + ".audiences", "original audience and page rule versions must match");
|
|
2357
2775
|
}
|
|
2358
2776
|
}
|
|
2359
2777
|
});
|
|
@@ -2371,38 +2789,38 @@ var RESONANCE_META_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA = metaSave.schema;
|
|
|
2371
2789
|
var RESONANCE_META_CONFIGURATION_SNAPSHOT_JSON_SCHEMA = metaSnapshot.schema;
|
|
2372
2790
|
var RESONANCE_META_CONFIGURATION_VIEW_JSON_SCHEMA = metaView.schema;
|
|
2373
2791
|
var RESONANCE_META_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA = metaSaveResponse.schema;
|
|
2374
|
-
var feedSelection =
|
|
2792
|
+
var feedSelection = refine3(object2({ channels: list2(object2({ channelId: uuid, expectedConfigurationRevision: integer2(1), resourceRuleRefs: list2(measurementRuleRef, 500, 1) }), 100, 1) }), (v, p) => {
|
|
2375
2793
|
unique(v.channels.map((c) => c.channelId), p + ".channels");
|
|
2376
2794
|
for (const c of v.channels) unique(c.resourceRuleRefs.map((ref) => ref.id), p + ".resourceRuleRefs");
|
|
2377
2795
|
});
|
|
2378
|
-
var mandateDraftRequest = object2({ expectedRevision: integer2(1), allowedOperations: mandateAllowedOperations, expiresAt: instant, websiteVisitFeedSelection: optional2(feedSelection), providerReporting: optional2(providerReportingSelection) });
|
|
2796
|
+
var mandateDraftRequest = object2({ expectedRevision: integer2(1), allowedOperations: mandateAllowedOperations, expiresAt: instant, websiteVisitFeedSelection: optional2(feedSelection), providerReporting: optional2(providerReportingSelection), operatingPolicySelection: optional2(operatingPolicySelection), activation: optional2(literal2("operating_policy")) });
|
|
2379
2797
|
var parseResonanceMandateDraftRequest = (v) => mandateDraftRequest.read(v, "mandateDraftRequest");
|
|
2380
2798
|
var RESONANCE_MANDATE_DRAFT_REQUEST_JSON_SCHEMA = mandateDraftRequest.schema;
|
|
2381
|
-
var feedReview = object2({ schemaVersion: literal2(1), approval: mandateApproval, mandateRef, configurations: list2(metaSnapshot, 100), current: object2({ state: choice2("not_enabled", "eligible", "invalidated", "unavailable"), checkedAt: instant, expiresAt: nullable2(instant), reasonCodes: uniqueList(
|
|
2799
|
+
var feedReview = object2({ schemaVersion: literal2(1), approval: mandateApproval, mandateRef, configurations: list2(metaSnapshot, 100), current: object2({ state: choice2("not_enabled", "eligible", "invalidated", "unavailable"), checkedAt: instant, expiresAt: nullable2(instant), reasonCodes: uniqueList(text3(200), 100) }) });
|
|
2382
2800
|
function parseResonanceWebsiteVisitFeedReview(v, context) {
|
|
2383
2801
|
const r = feedReview.read(v, "websiteVisitFeedReview"), original = r.approval, grant = parseResonanceMandateScope(original.mandate), ref = r.mandateRef, p = "websiteVisitFeedReview";
|
|
2384
2802
|
parseResonanceMandateApprovalPayload(original, { project_id: grant.projectId, campaign_id: grant.campaignId });
|
|
2385
|
-
if (ref.campaignId !== grant.campaignId || ref.preparedPlanId !== original.preparedPlanId || ref.reviewDigest !== original.reviewDigest || ref.mandateDigest !== original.mandateDigest)
|
|
2803
|
+
if (ref.campaignId !== grant.campaignId || ref.preparedPlanId !== original.preparedPlanId || ref.reviewDigest !== original.reviewDigest || ref.mandateDigest !== original.mandateDigest) fail3(p + ".mandateRef", "requires the same original accepted mandate");
|
|
2386
2804
|
unique(r.configurations.map((c) => c.channelId), p + ".configurations");
|
|
2387
2805
|
const feed = grant.websiteVisitFeed;
|
|
2388
2806
|
if (!feed) {
|
|
2389
|
-
if (r.configurations.length || r.current.state !== "not_enabled")
|
|
2807
|
+
if (r.configurations.length || r.current.state !== "not_enabled") fail3(p, "absent original feed requires not_enabled and no configurations");
|
|
2390
2808
|
} else {
|
|
2391
|
-
if (r.current.state === "not_enabled" || r.configurations.length !== feed.channels.length)
|
|
2809
|
+
if (r.current.state === "not_enabled" || r.configurations.length !== feed.channels.length) fail3(p, "must cover the exact original feed channels");
|
|
2392
2810
|
for (const selected of feed.channels) {
|
|
2393
2811
|
const config = r.configurations.find((c) => c.channelId === selected.channelId);
|
|
2394
|
-
if (!config || config.projectId !== grant.projectId || config.campaignId !== grant.campaignId || !grant.sites.includes(config.site) || !grant.accountBindingIds.includes(config.account.id) || config.campaignRevision > original.expectedRevision || canonical(config.measurementConfigRef) !== canonical(selected.measurementConfigRef) || canonical(config.matchingProfileRef) !== canonical(selected.matchingProfileRef))
|
|
2812
|
+
if (!config || config.projectId !== grant.projectId || config.campaignId !== grant.campaignId || !grant.sites.includes(config.site) || !grant.accountBindingIds.includes(config.account.id) || config.campaignRevision > original.expectedRevision || canonical(config.measurementConfigRef) !== canonical(selected.measurementConfigRef) || canonical(config.matchingProfileRef) !== canonical(selected.matchingProfileRef)) fail3(p + ".configurations", "original configuration/profile/scope mismatch");
|
|
2395
2813
|
const saved = config;
|
|
2396
|
-
for (const a of saved.channel.audienceRuleRefs) if (!grant.audienceRuleRefs.some((ref2) => canonical(ref2) === canonical(a)))
|
|
2814
|
+
for (const a of saved.channel.audienceRuleRefs) if (!grant.audienceRuleRefs.some((ref2) => canonical(ref2) === canonical(a))) fail3(p + ".configurations", "original logical audience grant mismatch");
|
|
2397
2815
|
const positive = saved.audiences.map((a) => a.resourceRuleRef);
|
|
2398
|
-
for (const rule of selected.resourceRuleRefs) if (!positive.some((ref2) => ref2.id === rule.id && ref2.revision === rule.revision))
|
|
2816
|
+
for (const rule of selected.resourceRuleRefs) if (!positive.some((ref2) => ref2.id === rule.id && ref2.revision === rule.revision)) fail3(p + ".configurations", "feed requires an original positive resource rule, never excluded-only");
|
|
2399
2817
|
}
|
|
2400
|
-
if (r.current.state === "eligible" && (r.current.reasonCodes.length || r.current.expiresAt === null || Date.parse(r.current.expiresAt) <= Date.parse(r.current.checkedAt)))
|
|
2818
|
+
if (r.current.state === "eligible" && (r.current.reasonCodes.length || r.current.expiresAt === null || Date.parse(r.current.expiresAt) <= Date.parse(r.current.checkedAt))) fail3(p + ".current", "eligible review requires an observed nonexpired horizon and no blockers");
|
|
2401
2819
|
}
|
|
2402
2820
|
if (context) {
|
|
2403
2821
|
const actual = object2({ preparedPlan: prepared }).read(context, p + ".context"), plan = parseResonancePreparedPlan(actual.preparedPlan);
|
|
2404
|
-
if (plan.id !== original.preparedPlanId || plan.campaignId !== grant.campaignId || plan.projectId !== grant.projectId || plan.reviewDigest !== original.reviewDigest || plan.expectedRevision !== original.expectedRevision || canonical(plan.definition.budget) !== canonical(grant.budget) || canonical(plan.definition.objective) !== canonical(grant.goal))
|
|
2405
|
-
for (const config of r.configurations) if (config.reviewedDefinitionDigest !== plan.definitionDigest || !plan.definition.channels.some((c) => canonical(c) === canonical(config.channel)))
|
|
2822
|
+
if (plan.id !== original.preparedPlanId || plan.campaignId !== grant.campaignId || plan.projectId !== grant.projectId || plan.reviewDigest !== original.reviewDigest || plan.expectedRevision !== original.expectedRevision || canonical(plan.definition.budget) !== canonical(grant.budget) || canonical(plan.definition.objective) !== canonical(grant.goal)) fail3(p + ".context", "requires the original prepared plan and mandate material");
|
|
2823
|
+
for (const config of r.configurations) if (config.reviewedDefinitionDigest !== plan.definitionDigest || !plan.definition.channels.some((c) => canonical(c) === canonical(config.channel))) fail3(p + ".context", "original channel or reviewed definition mismatch");
|
|
2406
2824
|
}
|
|
2407
2825
|
return r;
|
|
2408
2826
|
}
|
|
@@ -2410,7 +2828,7 @@ var RESONANCE_WEBSITE_VISIT_FEED_REVIEW_JSON_SCHEMA = feedReview.schema;
|
|
|
2410
2828
|
var observationIdentity = { observationId: uuid, channelId: uuid, versionId: uuid, accountBindingId: uuid };
|
|
2411
2829
|
var publicObservationMetric = union2(
|
|
2412
2830
|
object2({ ...metricBase, ...observationIdentity, source: choice2("provider", "first_party"), state: literal2("observed"), value: metricValue }),
|
|
2413
|
-
object2({ ...metricBase, ...observationIdentity, source: choice2("provider", "first_party"), state: choice2("unknown", "insufficient", "delayed", "unavailable"), value: literal2(null), reasonCode:
|
|
2831
|
+
object2({ ...metricBase, ...observationIdentity, source: choice2("provider", "first_party"), state: choice2("unknown", "insufficient", "delayed", "unavailable"), value: literal2(null), reasonCode: text3(80) })
|
|
2414
2832
|
);
|
|
2415
2833
|
function parseResonancePublicObservationMetric(v) {
|
|
2416
2834
|
const r = publicObservationMetric.read(v, "observationItem");
|
|
@@ -2419,7 +2837,7 @@ function parseResonancePublicObservationMetric(v) {
|
|
|
2419
2837
|
return r;
|
|
2420
2838
|
}
|
|
2421
2839
|
var observationDenominators = object2({ eligibleContacts: nullable2(decimal), fullyResolvedContacts: nullable2(decimal), qualifiedContacts: nullable2(decimal) });
|
|
2422
|
-
var observationSupportFields = { ...observationIdentity, currency, fetchedAt: instant, dataThrough: nullable2(instant), coverage: choice2("unknown", "partial", "complete"), reasonCode: nullable2(
|
|
2840
|
+
var observationSupportFields = { ...observationIdentity, currency, fetchedAt: instant, dataThrough: nullable2(instant), coverage: choice2("unknown", "partial", "complete"), reasonCode: nullable2(text3(80)), denominators: observationDenominators };
|
|
2423
2841
|
var firstPartyObservationSupport = object2({ ...observationSupportFields, source: literal2("first_party") });
|
|
2424
2842
|
var providerObservationSupport = object2({
|
|
2425
2843
|
...observationSupportFields,
|
|
@@ -2435,53 +2853,53 @@ var providerObservationSupport = object2({
|
|
|
2435
2853
|
var observationSupport = union2(firstPartyObservationSupport, providerObservationSupport);
|
|
2436
2854
|
function parseResonanceObservationSupport(v) {
|
|
2437
2855
|
const r = observationSupport.read(v, "observationSupport"), p = "observationSupport", d = r.denominators;
|
|
2438
|
-
if (d.fullyResolvedContacts !== null && (d.eligibleContacts === null || BigInt(d.fullyResolvedContacts) > BigInt(d.eligibleContacts)) || d.qualifiedContacts !== null && (d.fullyResolvedContacts === null || BigInt(d.qualifiedContacts) > BigInt(d.fullyResolvedContacts)))
|
|
2856
|
+
if (d.fullyResolvedContacts !== null && (d.eligibleContacts === null || BigInt(d.fullyResolvedContacts) > BigInt(d.eligibleContacts)) || d.qualifiedContacts !== null && (d.fullyResolvedContacts === null || BigInt(d.qualifiedContacts) > BigInt(d.fullyResolvedContacts))) fail3(p + ".denominators", "inconsistent independent contact universe");
|
|
2439
2857
|
if (r.source === "provider") {
|
|
2440
|
-
if (Object.values(d).some((v2) => v2 !== null))
|
|
2441
|
-
if (r.firstReceivedAt !== null && (r.receivedAt === null || Date.parse(r.firstReceivedAt) > Date.parse(r.receivedAt)))
|
|
2442
|
-
if (r.recordedAt !== null && Date.parse(r.recordedAt) !== Date.parse(r.fetchedAt))
|
|
2443
|
-
if (r.readClock !== null && (r.firstReceivedAt === null || r.receivedAt === null || r.recordedAt === null || Date.parse(r.readClock.notBeforeAt) > Date.parse(r.recordedAt)))
|
|
2444
|
-
if (r.coverageBasis === "closed_query_snapshot" ? r.coverage !== "complete" || r.reasonCode !== null || r.receivedAt === null || r.recordedAt === null || r.dataThrough !== null : r.coverage === "complete")
|
|
2858
|
+
if (Object.values(d).some((v2) => v2 !== null)) fail3(p + ".denominators", "provider reporting cannot supply qualified-contact denominators");
|
|
2859
|
+
if (r.firstReceivedAt !== null && (r.receivedAt === null || Date.parse(r.firstReceivedAt) > Date.parse(r.receivedAt))) fail3(p + ".firstReceivedAt", "preserve actual internal HTTP receipt order");
|
|
2860
|
+
if (r.recordedAt !== null && Date.parse(r.recordedAt) !== Date.parse(r.fetchedAt)) fail3(p + ".recordedAt", "must retain the native immutable SQL write time");
|
|
2861
|
+
if (r.readClock !== null && (r.firstReceivedAt === null || r.receivedAt === null || r.recordedAt === null || Date.parse(r.readClock.notBeforeAt) > Date.parse(r.recordedAt))) fail3(p + ".readClock", "requires actual earliest/final HTTP metadata and SQL lower-bound chronology");
|
|
2862
|
+
if (r.coverageBasis === "closed_query_snapshot" ? r.coverage !== "complete" || r.reasonCode !== null || r.receivedAt === null || r.recordedAt === null || r.dataThrough !== null : r.coverage === "complete") fail3(p + ".coverage", "distinguish revisable query coverage from unestablished legacy reporting");
|
|
2445
2863
|
}
|
|
2446
2864
|
return r;
|
|
2447
2865
|
}
|
|
2448
2866
|
var observationsPage = object2({ items: list2(publicObservationMetric, 500), nextCursor: nullable2(uuid), observedAt: instant, support: list2(observationSupport, 500) });
|
|
2449
2867
|
function parseResonanceObservationsPage(v) {
|
|
2450
2868
|
const r = observationsPage.read(v, "observationsPage"), p = "observationsPage";
|
|
2451
|
-
if (r.items.length !== r.support.length)
|
|
2869
|
+
if (r.items.length !== r.support.length) fail3(p + ".support", "requires one support entry for each metric item");
|
|
2452
2870
|
const pairs = /* @__PURE__ */ new Set(), rows = /* @__PURE__ */ new Map(), observedAt = Date.parse(r.observedAt);
|
|
2453
2871
|
let previous;
|
|
2454
2872
|
const first = r.items[0];
|
|
2455
2873
|
for (let i = 0; i < r.items.length; i++) {
|
|
2456
2874
|
const item = parseResonancePublicObservationMetric(r.items[i]), s = parseResonanceObservationSupport(r.support[i]), rowId = item.observationId.toLowerCase();
|
|
2457
|
-
if (Object.keys(observationIdentity).some((k) => item[k] !== s[k]))
|
|
2458
|
-
if (item.source !== s.source || item.projectId !== first.projectId || item.campaignId !== first.campaignId || item.site !== first.site)
|
|
2459
|
-
if (Date.parse(item.asOf) !== Date.parse(s.fetchedAt) || Date.parse(s.fetchedAt) > observedAt || item.dataThrough === null !== (s.dataThrough === null) || item.dataThrough !== null && s.dataThrough !== null && Date.parse(item.dataThrough) !== Date.parse(s.dataThrough))
|
|
2460
|
-
if (item.state === "observed" && item.value.kind === "money" && item.value.money.currency !== s.currency)
|
|
2461
|
-
if (previous !== void 0 && rowId < previous)
|
|
2875
|
+
if (Object.keys(observationIdentity).some((k) => item[k] !== s[k])) fail3(p + ".support", "item/support observation, channel, version and account must align in order");
|
|
2876
|
+
if (item.source !== s.source || item.projectId !== first.projectId || item.campaignId !== first.campaignId || item.site !== first.site) fail3(p + ".items", "requires one scoped provider or first-party page");
|
|
2877
|
+
if (Date.parse(item.asOf) !== Date.parse(s.fetchedAt) || Date.parse(s.fetchedAt) > observedAt || item.dataThrough === null !== (s.dataThrough === null) || item.dataThrough !== null && s.dataThrough !== null && Date.parse(item.dataThrough) !== Date.parse(s.dataThrough)) fail3(p + ".support", "preserve native SQL observation chronology and data-through meaning");
|
|
2878
|
+
if (item.state === "observed" && item.value.kind === "money" && item.value.money.currency !== s.currency) fail3(p + ".support.currency", "observed money must retain account currency");
|
|
2879
|
+
if (previous !== void 0 && rowId < previous) fail3(p + ".items", "native-row UUID order cannot be replaced by metric/time sorting");
|
|
2462
2880
|
previous = rowId;
|
|
2463
2881
|
const key = rowId + ":" + item.name;
|
|
2464
|
-
if (pairs.has(key))
|
|
2882
|
+
if (pairs.has(key)) fail3(p + ".items", "duplicate observation/metric pair");
|
|
2465
2883
|
pairs.add(key);
|
|
2466
2884
|
const supportIdentity = { ...s, fetchedAt: Date.parse(s.fetchedAt), dataThrough: s.dataThrough === null ? null : Date.parse(s.dataThrough), ...s.source === "provider" ? { firstReceivedAt: s.firstReceivedAt === null ? null : Date.parse(s.firstReceivedAt), receivedAt: s.receivedAt === null ? null : Date.parse(s.receivedAt), recordedAt: s.recordedAt === null ? null : Date.parse(s.recordedAt) } : {} };
|
|
2467
2885
|
const row = canonical({ projectId: item.projectId, campaignId: item.campaignId, site: item.site, channelId: item.channelId, versionId: item.versionId, accountBindingId: item.accountBindingId, source: item.source, windowStart: Date.parse(item.windowStart), windowEnd: Date.parse(item.windowEnd), timeZone: item.timeZone, fetchedAt: Date.parse(s.fetchedAt), support: supportIdentity });
|
|
2468
|
-
if (rows.has(rowId) && rows.get(rowId) !== row)
|
|
2886
|
+
if (rows.has(rowId) && rows.get(rowId) !== row) fail3(p + ".support", "one immutable native observation cannot change identity or support across metrics");
|
|
2469
2887
|
rows.set(rowId, row);
|
|
2470
2888
|
if (s.source === "provider") {
|
|
2471
|
-
if (item.state === "observed" && (s.coverage !== "complete" || s.coverageBasis !== "closed_query_snapshot" || s.reasonCode !== null))
|
|
2472
|
-
if (!RESONANCE_PROVIDER_METRIC_NAMES.includes(item.name) || item.sourceRef !== item.observationId || item.countingUnit !== providerCountingUnit(item.name) || item.attributionModel !== "provider_reported")
|
|
2473
|
-
if (s.readClock !== null && Date.parse(s.readClock.notBeforeAt) < Date.parse(item.windowEnd))
|
|
2889
|
+
if (item.state === "observed" && (s.coverage !== "complete" || s.coverageBasis !== "closed_query_snapshot" || s.reasonCode !== null)) fail3(p + ".support", "observed provider values require complete genuine closed-query support");
|
|
2890
|
+
if (!RESONANCE_PROVIDER_METRIC_NAMES.includes(item.name) || item.sourceRef !== item.observationId || item.countingUnit !== providerCountingUnit(item.name) || item.attributionModel !== "provider_reported") fail3(p + ".items", "provider metrics retain exact native observation and aggregate semantics");
|
|
2891
|
+
if (s.readClock !== null && Date.parse(s.readClock.notBeforeAt) < Date.parse(item.windowEnd)) fail3(p + ".support.readClock", "SQL pre-read lower bound must follow the completed query window");
|
|
2474
2892
|
} else {
|
|
2475
2893
|
const d = s.denominators;
|
|
2476
|
-
if (item.name !== "qualified_goals" || item.countingUnit !== "unique_qualified_contact" || item.goalRevision === null || item.attributionModel !== RESONANCE_ATTRIBUTION_MODEL || item.eligibleExposures !== null || item.matureOutcomes !== null)
|
|
2894
|
+
if (item.name !== "qualified_goals" || item.countingUnit !== "unique_qualified_contact" || item.goalRevision === null || item.attributionModel !== RESONANCE_ATTRIBUTION_MODEL || item.eligibleExposures !== null || item.matureOutcomes !== null) fail3(p + ".items", "preserve genuine first-party qualification without fabricated exposure counts");
|
|
2477
2895
|
const coverage = d.eligibleContacts === null || d.eligibleContacts === "0" || d.fullyResolvedContacts === null ? null : Number(BigInt(d.fullyResolvedContacts) * 10000n / BigInt(d.eligibleContacts));
|
|
2478
|
-
if (item.coverageBasisPoints !== coverage)
|
|
2479
|
-
if (item.state !== "observed" && (s.coverage === "complete" || s.reasonCode !== item.reasonCode))
|
|
2480
|
-
if (item.state === "observed" && (s.coverage !== "complete" || s.reasonCode !== null || d.eligibleContacts === null || d.fullyResolvedContacts !== d.eligibleContacts || d.qualifiedContacts === null || item.value.kind !== "count" || item.value.count !== d.qualifiedContacts))
|
|
2896
|
+
if (item.coverageBasisPoints !== coverage) fail3(p + ".support.denominators", "contact resolution coverage must match the independent universe");
|
|
2897
|
+
if (item.state !== "observed" && (s.coverage === "complete" || s.reasonCode !== item.reasonCode)) fail3(p + ".support", "unresolved qualified sources keep incomplete coverage and their native reason");
|
|
2898
|
+
if (item.state === "observed" && (s.coverage !== "complete" || s.reasonCode !== null || d.eligibleContacts === null || d.fullyResolvedContacts !== d.eligibleContacts || d.qualifiedContacts === null || item.value.kind !== "count" || item.value.count !== d.qualifiedContacts)) fail3(p + ".support", "observed qualified count requires its complete independent native universe");
|
|
2481
2899
|
}
|
|
2482
2900
|
}
|
|
2483
|
-
if (rows.size > 100)
|
|
2484
|
-
if (r.nextCursor !== null && (!r.items.length || r.nextCursor.toLowerCase() !== previous))
|
|
2901
|
+
if (rows.size > 100) fail3(p + ".items", "at most 100 native rows per page");
|
|
2902
|
+
if (r.nextCursor !== null && (!r.items.length || r.nextCursor.toLowerCase() !== previous)) fail3(p + ".nextCursor", "cursor must retain the final native row, not a metric offset");
|
|
2485
2903
|
return r;
|
|
2486
2904
|
}
|
|
2487
2905
|
var RESONANCE_PUBLIC_OBSERVATION_METRIC_JSON_SCHEMA = publicObservationMetric.schema;
|
|
@@ -2497,13 +2915,13 @@ var isMetaChannel = (c) => c.kind === "meta_retargeting";
|
|
|
2497
2915
|
var usesPropertyModel = (c) => c.channelGroup !== void 0 || c.audienceRuleRefs.some((ref) => ref.minDaysSinceVisit !== void 0);
|
|
2498
2916
|
function checkAudienceBand(ref, provider = "meta_ads", at = "audienceRuleRef") {
|
|
2499
2917
|
const min = ref.minDaysSinceVisit;
|
|
2500
|
-
if (min !== void 0 && min >= ref.retentionDays)
|
|
2918
|
+
if (min !== void 0 && min >= ref.retentionDays) fail3(at + ".minDaysSinceVisit", "must be shorter than the retention window");
|
|
2501
2919
|
if (provider === "google_ads") {
|
|
2502
|
-
if (min !== void 0)
|
|
2920
|
+
if (min !== void 0) fail3(at + ".minDaysSinceVisit", "Google audiences have no recency band");
|
|
2503
2921
|
return;
|
|
2504
2922
|
}
|
|
2505
|
-
if (ref.retentionDays > META_WEBSITE_AUDIENCE_MAX_RETENTION_DAYS)
|
|
2506
|
-
if (1 + ref.exclusionRuleIds.length + (min === void 0 ? 0 : 1) > META_AUDIENCE_RULE_LIMIT)
|
|
2923
|
+
if (ref.retentionDays > META_WEBSITE_AUDIENCE_MAX_RETENTION_DAYS) fail3(at + ".retentionDays", `exceeds the ${META_WEBSITE_AUDIENCE_MAX_RETENTION_DAYS}-day Meta website audience maximum`);
|
|
2924
|
+
if (1 + ref.exclusionRuleIds.length + (min === void 0 ? 0 : 1) > META_AUDIENCE_RULE_LIMIT) fail3(at + ".exclusionRuleIds", `a Meta audience holds at most ${META_AUDIENCE_RULE_LIMIT} rules including the page and any recency band`);
|
|
2507
2925
|
}
|
|
2508
2926
|
function checkMetaAudienceBands(channel2, at) {
|
|
2509
2927
|
if (!usesPropertyModel(channel2)) return;
|
|
@@ -2515,25 +2933,25 @@ function checkChannelGroups(channels) {
|
|
|
2515
2933
|
for (const c of channels) if (isMetaChannel(c) && c.channelGroup) groups.set(c.channelGroup.key, [...groups.get(c.channelGroup.key) ?? [], c]);
|
|
2516
2934
|
for (const [key, members] of groups) {
|
|
2517
2935
|
const at = `campaign.channelGroup.${key}`;
|
|
2518
|
-
if (members.length > RESONANCE_MAX_CHANNELS_PER_GROUP)
|
|
2936
|
+
if (members.length > RESONANCE_MAX_CHANNELS_PER_GROUP) fail3(at, `at most ${RESONANCE_MAX_CHANNELS_PER_GROUP} channels per group`);
|
|
2519
2937
|
const first = members[0];
|
|
2520
2938
|
const shared = (c) => canonical([c.site, c.accountBindingId, c.datasetRef.id, c.pageRef, c.instagramRef, c.specialCategories, c.countryCodes, c.objective, c.optimization]);
|
|
2521
2939
|
const identity = /* @__PURE__ */ new Set(), destinationOf = /* @__PURE__ */ new Map(), propertyOfDestination = /* @__PURE__ */ new Map();
|
|
2522
2940
|
for (const c of members) {
|
|
2523
|
-
if (shared(c) !== shared(first))
|
|
2524
|
-
if (c.specialCategories.length > 0 && c.ageConstraint?.mode !== "provider_managed")
|
|
2525
|
-
const pk = (c.property ??
|
|
2526
|
-
if (identity.has(id))
|
|
2941
|
+
if (shared(c) !== shared(first)) fail3(at, "channels in one group must share site, account, dataset, Page, categories, countries, objective and optimization");
|
|
2942
|
+
if (c.specialCategories.length > 0 && c.ageConstraint?.mode !== "provider_managed") fail3(at + ".ageConstraint", "a special category requires provider-managed age");
|
|
2943
|
+
const pk = (c.property ?? fail3(at + ".property", "a grouped channel names its property")).key, tier = c.tier?.label ?? "", id = `${pk}|${tier}`;
|
|
2944
|
+
if (identity.has(id)) fail3(at + ".property", "two channels share one property and tier");
|
|
2527
2945
|
identity.add(id);
|
|
2528
|
-
if (destinationOf.has(pk) && destinationOf.get(pk) !== c.destinationId)
|
|
2946
|
+
if (destinationOf.has(pk) && destinationOf.get(pk) !== c.destinationId) fail3(at + ".destinationId", "channels for one property share one destination");
|
|
2529
2947
|
destinationOf.set(pk, c.destinationId);
|
|
2530
2948
|
const other = propertyOfDestination.get(c.destinationId);
|
|
2531
|
-
if (other !== void 0 && other !== pk)
|
|
2949
|
+
if (other !== void 0 && other !== pk) fail3(at + ".destinationId", "channels for different properties have different destinations");
|
|
2532
2950
|
propertyOfDestination.set(c.destinationId, pk);
|
|
2533
2951
|
}
|
|
2534
2952
|
for (let i = 0; i < members.length; i++) for (let j = i + 1; j < members.length; j++) {
|
|
2535
2953
|
if (members[i].property?.key !== members[j].property?.key) continue;
|
|
2536
|
-
for (const a of members[i].audienceRuleRefs) for (const b of members[j].audienceRuleRefs) if (bandsOverlap(a, b))
|
|
2954
|
+
for (const a of members[i].audienceRuleRefs) for (const b of members[j].audienceRuleRefs) if (bandsOverlap(a, b)) fail3(at + ".audienceRuleRefs", "tiers of one property cannot overlap in time");
|
|
2537
2955
|
}
|
|
2538
2956
|
}
|
|
2539
2957
|
}
|
|
@@ -2541,14 +2959,14 @@ function checkGroupedAllocations(v) {
|
|
|
2541
2959
|
if (!v.channels.some((c) => isMetaChannel(c) && c.channelGroup)) return;
|
|
2542
2960
|
let sum = 0n;
|
|
2543
2961
|
for (const c of v.channels) if ("allocation" in c) sum += BigInt(c.allocation.amountMicros);
|
|
2544
|
-
if (sum > BigInt(v.budget.total.amountMicros) - BigInt(v.budget.reserveMargin.amountMicros))
|
|
2962
|
+
if (sum > BigInt(v.budget.total.amountMicros) - BigInt(v.budget.reserveMargin.amountMicros)) fail3("campaign.channels.allocation", "channel allocations exceed the campaign total less its reserve");
|
|
2545
2963
|
}
|
|
2546
2964
|
function splitBudget(total, weights, quantumMicros) {
|
|
2547
2965
|
const t = parseMoney(total), at = "splitBudget";
|
|
2548
|
-
if (!/^[1-9][0-9]{0,29}$/.test(quantumMicros))
|
|
2549
|
-
if (weights.length < 1 || weights.length > 100 || weights.some((w) => !Number.isSafeInteger(w) || w < 1))
|
|
2966
|
+
if (!/^[1-9][0-9]{0,29}$/.test(quantumMicros)) fail3(at + ".quantumMicros", "must be a positive whole number of micros");
|
|
2967
|
+
if (weights.length < 1 || weights.length > 100 || weights.some((w) => !Number.isSafeInteger(w) || w < 1)) fail3(at + ".weights", "one to 100 positive whole weights");
|
|
2550
2968
|
const quantum = BigInt(quantumMicros), micros = BigInt(t.amountMicros);
|
|
2551
|
-
if (micros % quantum !== 0n)
|
|
2969
|
+
if (micros % quantum !== 0n) fail3(at + ".total", "must be a whole number of provider quanta");
|
|
2552
2970
|
const units = micros / quantum, sum = weights.reduce((a, w) => a + BigInt(w), 0n);
|
|
2553
2971
|
const parts = weights.map((w, index) => ({ index, floor: units * BigInt(w) / sum, rest: units * BigInt(w) % sum }));
|
|
2554
2972
|
let left = units - parts.reduce((a, p) => a + p.floor, 0n);
|
|
@@ -2563,8 +2981,8 @@ function splitBudget(total, weights, quantumMicros) {
|
|
|
2563
2981
|
}
|
|
2564
2982
|
function suggestPropertyWeights(visitors, bounds = {}) {
|
|
2565
2983
|
const floor = bounds.floorBasisPoints ?? 1e3, ceiling = bounds.ceilingBasisPoints ?? 4e3, n = visitors.length, at = "suggestPropertyWeights";
|
|
2566
|
-
if (n < 1 || n > 100 || visitors.some((v) => !Number.isSafeInteger(v) || v < 0))
|
|
2567
|
-
if (!Number.isInteger(floor) || !Number.isInteger(ceiling) || floor < 0 || ceiling > 1e4 || floor > ceiling || n * floor > 1e4 || n * ceiling < 1e4)
|
|
2984
|
+
if (n < 1 || n > 100 || visitors.some((v) => !Number.isSafeInteger(v) || v < 0)) fail3(at + ".visitors", "one to 100 whole, non-negative visitor counts");
|
|
2985
|
+
if (!Number.isInteger(floor) || !Number.isInteger(ceiling) || floor < 0 || ceiling > 1e4 || floor > ceiling || n * floor > 1e4 || n * ceiling < 1e4) fail3(at + ".bounds", "floor and ceiling cannot hold every share");
|
|
2568
2986
|
const weight = visitors.map((v) => v + 1);
|
|
2569
2987
|
const total = (lambda) => weight.reduce((a, w) => a + Math.min(ceiling, Math.max(floor, lambda * w)), 0);
|
|
2570
2988
|
let low = 0, high = ceiling / Math.min(...weight) + 1;
|
|
@@ -2601,7 +3019,7 @@ var clip = (value, max) => value.length <= max ? value : value.slice(0, max);
|
|
|
2601
3019
|
function expandPropertyChannels(definition2, groupKey, additions, options) {
|
|
2602
3020
|
const at = "expandPropertyChannels";
|
|
2603
3021
|
const group = definition2.channels.filter((c) => isMetaChannel(c) && c.channelGroup?.key === groupKey);
|
|
2604
|
-
if (!group.length)
|
|
3022
|
+
if (!group.length) fail3(at + ".group", "needs an existing property channel to use as the template");
|
|
2605
3023
|
const template = group[0];
|
|
2606
3024
|
const present = new Set(group.map((c) => c.property?.key));
|
|
2607
3025
|
const keys = additions.map((a) => a.key);
|
|
@@ -2685,4 +3103,4 @@ function deriveProviderRatios(items) {
|
|
|
2685
3103
|
return { frequency, costPerResult, reasonCodes: reasons };
|
|
2686
3104
|
}
|
|
2687
3105
|
|
|
2688
|
-
export { MAX_MONEY_MICROS, META_AUDIENCE_RULE_LIMIT, META_CALL_TO_ACTIONS, META_SAC_CUSTOM_AUDIENCE_EXCLUSION_VERIFIED, META_WEBSITE_AUDIENCE_MAX_RETENTION_DAYS, MONEY_EXPONENT, MONEY_JSON_SCHEMA, RESONANCE_ACCEPT_COMMAND_JSON_SCHEMA, RESONANCE_ACCOUNT_CAPABILITY_JSON_SCHEMA, RESONANCE_ATTRIBUTION_MODEL, RESONANCE_AUDIENCE_DRAFT_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_AUDIENCE_RULE_REF_JSON_SCHEMA, RESONANCE_BINDING_COMMAND_JSON_SCHEMA, RESONANCE_CAMPAIGN_DEFINITION_JSON_SCHEMA, RESONANCE_CAMPAIGN_DRAFT_JSON_SCHEMA, RESONANCE_CAMPAIGN_VIEW_JSON_SCHEMA, RESONANCE_CLICK_IDENTIFIERS_JSON_SCHEMA, RESONANCE_COMMAND_JSON_SCHEMA, RESONANCE_COMMAND_PREPARE_REQUEST_JSON_SCHEMA, RESONANCE_COMMAND_PREPARE_RESPONSE_JSON_SCHEMA, RESONANCE_CONSENT_JSON_SCHEMA, RESONANCE_CONSENT_RESPONSE_JSON_SCHEMA, RESONANCE_CONSENT_UPDATE_JSON_SCHEMA, RESONANCE_CONVERSION_JSON_SCHEMA, RESONANCE_CPQL_UNCERTAINTY_METHOD, RESONANCE_CURRENCIES, RESONANCE_EXPERIMENT_COMPLETE_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_CREATE_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_LIFECYCLE_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_LINK_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_REF_JSON_SCHEMA, RESONANCE_EXPERIMENT_UPDATE_COMMAND_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_REVIEW_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_SNAPSHOT_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_VIEW_JSON_SCHEMA, RESONANCE_GOOGLE_SETUP_SPEC_JSON_SCHEMA, RESONANCE_GOOGLE_SIGNAL_SEMANTICS, RESONANCE_GOOGLE_SOURCE_CATEGORIES, RESONANCE_MANDATE_ACTION_KIND, RESONANCE_MANDATE_APPROVAL_JSON_SCHEMA, RESONANCE_MANDATE_DRAFT_REQUEST_JSON_SCHEMA, RESONANCE_MANDATE_REF_JSON_SCHEMA, RESONANCE_MANDATE_SCOPE_JSON_SCHEMA, RESONANCE_MANDATE_TARGET_JSON_SCHEMA, RESONANCE_MAX_CHANNELS_PER_GROUP, RESONANCE_MEASUREMENT_CONFIGURATION_CURRENT_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIGURATION_SNAPSHOT_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIG_JSON_SCHEMA, RESONANCE_MEASUREMENT_OCCURRENCE_JSON_SCHEMA, RESONANCE_META_AUDIENCE_REASONS, RESONANCE_META_AUDIENCE_SETUP_LIST_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_PREPARE_REQUEST_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_READINESS_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_RECEIPT_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_REVIEW_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_STATUS_JSON_SCHEMA, RESONANCE_META_AUDIENCE_VERDICTS, RESONANCE_META_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_META_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA, RESONANCE_META_CONFIGURATION_SNAPSHOT_JSON_SCHEMA, RESONANCE_META_CONFIGURATION_VIEW_JSON_SCHEMA, RESONANCE_META_DATASET_NAME_MAX_LENGTH, RESONANCE_META_DATASET_SELECTION_REQUEST_JSON_SCHEMA, RESONANCE_META_DATASET_SELECTION_WITNESS_JSON_SCHEMA, RESONANCE_META_DATASET_SETUP_PREPARE_REQUEST_JSON_SCHEMA, RESONANCE_META_DATASET_SETUP_RECEIPT_JSON_SCHEMA, RESONANCE_META_DATASET_SETUP_REVIEW_JSON_SCHEMA, RESONANCE_META_QUERY_ATTRIBUTION_WINDOWS, RESONANCE_META_RETARGETING_READINESS_JSON_SCHEMA, RESONANCE_METRIC_JSON_SCHEMA, RESONANCE_OBSERVATIONS_PAGE_JSON_SCHEMA, RESONANCE_OBSERVATION_SUPPORT_JSON_SCHEMA, RESONANCE_OCCURRENCE_RESPONSE_JSON_SCHEMA, RESONANCE_OPTIMIZATION_DECISION_JSON_SCHEMA, RESONANCE_OPTIMIZATION_EVIDENCE_JSON_SCHEMA, RESONANCE_OPTIMIZATION_POLICY_JSON_SCHEMA, RESONANCE_POSITIONING_APPLY_REQUEST_JSON_SCHEMA, RESONANCE_POSITIONING_CONSISTENCY_ASSESSMENT_JSON_SCHEMA, RESONANCE_POSITIONING_CONTEXT_JSON_SCHEMA, RESONANCE_POSITIONING_METHOD_VERSION, RESONANCE_POSITIONING_PREVIEW_JSON_SCHEMA, RESONANCE_POSITIONING_PREVIEW_REQUEST_JSON_SCHEMA, RESONANCE_POSITIONING_RESULT_JSON_SCHEMA, RESONANCE_PREPARED_PLAN_JSON_SCHEMA, RESONANCE_PROVIDER_METRIC_NAMES, RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA, RESONANCE_PROVIDER_REPORTING_SELECTION_JSON_SCHEMA, RESONANCE_PUBLIC_OBSERVATION_METRIC_JSON_SCHEMA, RESONANCE_QUALIFICATION_RULE_JSON_SCHEMA, RESONANCE_RECEIPT_JSON_SCHEMA, RESONANCE_RESOLVED_QUALIFICATION_RULE_JSON_SCHEMA, RESONANCE_RESOURCE_REF_JSON_SCHEMA, RESONANCE_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_SCHEMA_VERSION, RESONANCE_SOURCE_MARKER_JSON_SCHEMA, RESONANCE_SOURCE_MARKER_PARAMETER, RESONANCE_SUBJECT_HEADER, RESONANCE_SUBJECT_RENEW_COMMAND_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_FEED_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_FEED_REVIEW_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_PROFILE, RESONANCE_WEBSITE_VISIT_SETUP_DELIVERY_COMMAND_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_SETUP_GRANT_ACCEPTED_VISITS_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_SETUP_GRANT_PROOF_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_SETUP_GRANT_STATUS_JSON_SCHEMA, ResonanceValidationError, addMoney, checkAudienceBand, checkChannelGroups, compareMoney, cpqlMissingOutcomeBound, deriveProviderRatios, expandPropertyChannels, formatMoney, googleConversionActionSemantics, googleUploadClicksSetupSemantics, metaExclusionPolicy, moneyFromProviderUnits, moneyToProviderUnits, parseMoney, parseResonanceAcceptCommand, parseResonanceAccountCapability, parseResonanceAudienceDraftSaveCommand, parseResonanceAudienceRuleRef, parseResonanceBindingCommand, parseResonanceCampaignDefinition, parseResonanceCampaignDraft, parseResonanceCampaignSaveCommand, parseResonanceCampaignView, parseResonanceClickIdentifiers, parseResonanceCommand, parseResonanceCommandPrepareRequest, parseResonanceCommandPrepareResponse, parseResonanceConsentResponse, parseResonanceConsentSnapshot, parseResonanceConsentUpdate, parseResonanceConversionEnvelope, parseResonanceExperimentCompleteCommand, parseResonanceExperimentCreateCommand, parseResonanceExperimentExposure, parseResonanceExperimentLifecycleCommand, parseResonanceExperimentLinkCommand, parseResonanceExperimentRef, parseResonanceExperimentUpdateCommand, parseResonanceGoogleConfigurationReview, parseResonanceGoogleConfigurationSaveCommand, parseResonanceGoogleConfigurationSaveResponse, parseResonanceGoogleConfigurationSnapshot, parseResonanceGoogleConfigurationView, parseResonanceGoogleUploadClicksCustomGoalSpec, parseResonanceMandateApprovalPayload, parseResonanceMandateDraftRequest, parseResonanceMandateRef, parseResonanceMandateScope, parseResonanceMandateTarget, parseResonanceMeasurementConfig, parseResonanceMeasurementConfigurationCurrent, parseResonanceMeasurementConfigurationSaveCommand, parseResonanceMeasurementConfigurationSaveResponse, parseResonanceMeasurementConfigurationSnapshot, parseResonanceMeasurementOccurrence, parseResonanceMetaAudienceSetupIntent, parseResonanceMetaAudienceSetupList, parseResonanceMetaAudienceSetupPrepareRequest, parseResonanceMetaAudienceSetupReadiness, parseResonanceMetaAudienceSetupReceipt, parseResonanceMetaAudienceSetupReview, parseResonanceMetaAudienceSetupStatus, parseResonanceMetaConfigurationSaveCommand, parseResonanceMetaConfigurationSaveResponse, parseResonanceMetaConfigurationSnapshot, parseResonanceMetaConfigurationView, parseResonanceMetaDatasetName, parseResonanceMetaDatasetSelectionRequest, parseResonanceMetaDatasetSelectionWitness, parseResonanceMetaDatasetSetupIntent, parseResonanceMetaDatasetSetupPrepareRequest, parseResonanceMetaDatasetSetupReceipt, parseResonanceMetaDatasetSetupReview, parseResonanceMetaRetargetingReadiness, parseResonanceMetricObservation, parseResonanceObservationSupport, parseResonanceObservationsPage, parseResonanceOccurrenceResponse, parseResonanceOptimizationDecision, parseResonanceOptimizationEvidence, parseResonanceOptimizationPolicy, parseResonancePositioningApplyRequest, parseResonancePositioningConsistencyAssessment, parseResonancePositioningContext, parseResonancePositioningPreview, parseResonancePositioningPreviewRequest, parseResonancePositioningResult, parseResonancePrepareCommand, parseResonancePreparedPlan, parseResonanceProviderReportingGrant, parseResonanceProviderReportingSelection, parseResonancePublicObservationMetric, parseResonanceQualificationRule, parseResonanceReceipt, parseResonanceResolvedQualificationRule, parseResonanceResourceRef, parseResonanceSourceMarker, parseResonanceSubjectRenewCommand, parseResonanceWebsiteVisitFeedReview, parseResonanceWebsiteVisitSetupDeliveryCommand, parseResonanceWebsiteVisitSetupGrant, parseResonanceWebsiteVisitSetupGrantAcceptedVisits, parseResonanceWebsiteVisitSetupGrantProof, parseResonanceWebsiteVisitSetupGrantStatus, parseResonanceWebsiteVisitSetupOrigin, projectResonanceGoogleConfiguration, projectResonanceMeasurementConfiguration, projectResonanceMetaConfiguration, projectResonancePositioningConsistencyEvidence, reportedCpqlMissingOutcomeBound, resonanceCommandDigestInput, resonanceGoogleConfigurationDigestInput, resonanceGoogleSetupDigestInput, resonanceMandateDigestInput, resonanceMeasurementConfigDigestInput, resonanceMeasurementConfigurationSaveDigestInput, resonanceMetaAudienceSetupDigestInput, resonanceMetaAudienceSetupReceiptDigestInput, resonanceMetaConfigurationDigestInput, resonanceMetaConfigurationSaveDigestInput, resonanceMetaDatasetSetupDigestInput, resonanceOptimizationDecisionDigestInput, resonanceOptimizationEvidenceDigestInput, resonanceOptimizationPolicyDigestInput, resonancePlanIssues, resonancePositioningConsistencyEvidenceDigestInput, resonancePositioningContextDigestInput, resonancePositioningEvidenceDigestInput, resonancePositioningResultDigestInput, resonanceWebsiteVisitEventTime, resonanceWebsiteVisitProfileDigestInput, resonanceWebsiteVisitSetupDeliveryDigestInput, resonanceWebsiteVisitSetupEventTime, splitBudget, subtractMoney, suggestPropertyWeights };
|
|
3106
|
+
export { MAX_MONEY_MICROS, META_AUDIENCE_RULE_LIMIT, META_CALL_TO_ACTIONS, META_SAC_CUSTOM_AUDIENCE_EXCLUSION_VERIFIED, META_WEBSITE_AUDIENCE_MAX_RETENTION_DAYS, MONEY_EXPONENT, MONEY_JSON_SCHEMA, NATIVE_CAS_TIMESTAMP_JSON_SCHEMA, NativeCasTimestampValidationError, RESONANCE_ACCEPT_COMMAND_JSON_SCHEMA, RESONANCE_ACCOUNT_CAPABILITY_JSON_SCHEMA, RESONANCE_ATTRIBUTION_MODEL, RESONANCE_AUDIENCE_DRAFT_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_AUDIENCE_RULE_REF_JSON_SCHEMA, RESONANCE_BINDING_COMMAND_JSON_SCHEMA, RESONANCE_CAMPAIGN_DEFINITION_JSON_SCHEMA, RESONANCE_CAMPAIGN_DRAFT_JSON_SCHEMA, RESONANCE_CAMPAIGN_VIEW_JSON_SCHEMA, RESONANCE_CLICK_IDENTIFIERS_JSON_SCHEMA, RESONANCE_COMMAND_JSON_SCHEMA, RESONANCE_COMMAND_PREPARE_REQUEST_JSON_SCHEMA, RESONANCE_COMMAND_PREPARE_RESPONSE_JSON_SCHEMA, RESONANCE_CONSENT_JSON_SCHEMA, RESONANCE_CONSENT_RESPONSE_JSON_SCHEMA, RESONANCE_CONSENT_UPDATE_JSON_SCHEMA, RESONANCE_CONVERSION_JSON_SCHEMA, RESONANCE_CPQL_UNCERTAINTY_METHOD, RESONANCE_CURRENCIES, RESONANCE_EXPERIMENT_COMPLETE_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_CREATE_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_LIFECYCLE_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_LINK_COMMAND_JSON_SCHEMA, RESONANCE_EXPERIMENT_REF_JSON_SCHEMA, RESONANCE_EXPERIMENT_UPDATE_COMMAND_JSON_SCHEMA, RESONANCE_GOOGLE_CAMPAIGN_DIAGNOSTICS_PAYLOAD_JSON_SCHEMA, RESONANCE_GOOGLE_CAMPAIGN_DIAGNOSTICS_REPORT_JSON_SCHEMA, RESONANCE_GOOGLE_CAMPAIGN_DIAGNOSTICS_REQUEST_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_REVIEW_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_SNAPSHOT_JSON_SCHEMA, RESONANCE_GOOGLE_CONFIGURATION_VIEW_JSON_SCHEMA, RESONANCE_GOOGLE_CONTENT_UPDATE_JSON_SCHEMA, RESONANCE_GOOGLE_CONTENT_UPDATE_SELECTION_JSON_SCHEMA, RESONANCE_GOOGLE_DIAGNOSTICS_SECTIONS, RESONANCE_GOOGLE_SETUP_SPEC_JSON_SCHEMA, RESONANCE_GOOGLE_SIGNAL_SEMANTICS, RESONANCE_GOOGLE_SOURCE_CATEGORIES, RESONANCE_MANDATE_ACTION_KIND, RESONANCE_MANDATE_APPROVAL_JSON_SCHEMA, RESONANCE_MANDATE_DRAFT_REQUEST_JSON_SCHEMA, RESONANCE_MANDATE_REF_JSON_SCHEMA, RESONANCE_MANDATE_SCOPE_JSON_SCHEMA, RESONANCE_MANDATE_TARGET_JSON_SCHEMA, RESONANCE_MAX_CHANNELS_PER_GROUP, RESONANCE_MEASUREMENT_CONFIGURATION_CURRENT_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIGURATION_SNAPSHOT_JSON_SCHEMA, RESONANCE_MEASUREMENT_CONFIG_JSON_SCHEMA, RESONANCE_MEASUREMENT_OCCURRENCE_JSON_SCHEMA, RESONANCE_META_AUDIENCE_REASONS, RESONANCE_META_AUDIENCE_SETUP_LIST_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_PREPARE_REQUEST_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_READINESS_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_RECEIPT_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_REVIEW_JSON_SCHEMA, RESONANCE_META_AUDIENCE_SETUP_STATUS_JSON_SCHEMA, RESONANCE_META_AUDIENCE_VERDICTS, RESONANCE_META_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_META_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA, RESONANCE_META_CONFIGURATION_SNAPSHOT_JSON_SCHEMA, RESONANCE_META_CONFIGURATION_VIEW_JSON_SCHEMA, RESONANCE_META_DATASET_NAME_MAX_LENGTH, RESONANCE_META_DATASET_SELECTION_REQUEST_JSON_SCHEMA, RESONANCE_META_DATASET_SELECTION_WITNESS_JSON_SCHEMA, RESONANCE_META_DATASET_SETUP_PREPARE_REQUEST_JSON_SCHEMA, RESONANCE_META_DATASET_SETUP_RECEIPT_JSON_SCHEMA, RESONANCE_META_DATASET_SETUP_REVIEW_JSON_SCHEMA, RESONANCE_META_QUERY_ATTRIBUTION_WINDOWS, RESONANCE_META_RETARGETING_READINESS_JSON_SCHEMA, RESONANCE_METRIC_JSON_SCHEMA, RESONANCE_OBSERVATIONS_PAGE_JSON_SCHEMA, RESONANCE_OBSERVATION_SUPPORT_JSON_SCHEMA, RESONANCE_OCCURRENCE_RESPONSE_JSON_SCHEMA, RESONANCE_OPERATING_POLICY_BASE_JSON_SCHEMA, RESONANCE_OPERATING_POLICY_JSON_SCHEMA, RESONANCE_OPERATING_POLICY_REF_JSON_SCHEMA, RESONANCE_OPERATING_POLICY_SELECTION_JSON_SCHEMA, RESONANCE_OPTIMIZATION_DECISION_JSON_SCHEMA, RESONANCE_OPTIMIZATION_EVIDENCE_JSON_SCHEMA, RESONANCE_OPTIMIZATION_POLICY_JSON_SCHEMA, RESONANCE_POSITIONING_APPLY_REQUEST_JSON_SCHEMA, RESONANCE_POSITIONING_CONSISTENCY_ASSESSMENT_JSON_SCHEMA, RESONANCE_POSITIONING_CONTEXT_JSON_SCHEMA, RESONANCE_POSITIONING_METHOD_VERSION, RESONANCE_POSITIONING_PREVIEW_JSON_SCHEMA, RESONANCE_POSITIONING_PREVIEW_REQUEST_JSON_SCHEMA, RESONANCE_POSITIONING_RESULT_JSON_SCHEMA, RESONANCE_PREPARATION_LOOKUP_REQUEST_JSON_SCHEMA, RESONANCE_PREPARATION_LOOKUP_RESPONSE_JSON_SCHEMA, RESONANCE_PREPARATION_RETIRE_REQUEST_JSON_SCHEMA, RESONANCE_PREPARATION_RETIRE_RESPONSE_JSON_SCHEMA, RESONANCE_PREPARED_PLAN_JSON_SCHEMA, RESONANCE_PROVIDER_METRIC_NAMES, RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA, RESONANCE_PROVIDER_REPORTING_MAX_TAIL_DAYS, RESONANCE_PROVIDER_REPORTING_SELECTION_JSON_SCHEMA, RESONANCE_PUBLIC_OBSERVATION_METRIC_JSON_SCHEMA, RESONANCE_QUALIFICATION_RULE_JSON_SCHEMA, RESONANCE_RECEIPT_JSON_SCHEMA, RESONANCE_RESOLVED_QUALIFICATION_RULE_JSON_SCHEMA, RESONANCE_RESOURCE_REF_JSON_SCHEMA, RESONANCE_SAVE_COMMAND_JSON_SCHEMA, RESONANCE_SCHEMA_VERSION, RESONANCE_SOURCE_MARKER_JSON_SCHEMA, RESONANCE_SOURCE_MARKER_PARAMETER, RESONANCE_SUBJECT_HEADER, RESONANCE_SUBJECT_RENEW_COMMAND_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_FEED_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_FEED_REVIEW_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_PROFILE, RESONANCE_WEBSITE_VISIT_SETUP_DELIVERY_COMMAND_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_SETUP_GRANT_ACCEPTED_VISITS_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_SETUP_GRANT_PROOF_JSON_SCHEMA, RESONANCE_WEBSITE_VISIT_SETUP_GRANT_STATUS_JSON_SCHEMA, ResonanceValidationError, addMoney, checkAudienceBand, checkChannelGroups, compareMoney, cpqlMissingOutcomeBound, deriveProviderRatios, expandPropertyChannels, formatMoney, googleConversionActionSemantics, googleUploadClicksSetupSemantics, metaExclusionPolicy, moneyFromProviderUnits, moneyToProviderUnits, normalizeResonanceGoogleCriterionText, parseMoney, parseNativeCasTimestamp, parseResonanceAcceptCommand, parseResonanceAccountCapability, parseResonanceAudienceDraftSaveCommand, parseResonanceAudienceRuleRef, parseResonanceBindingCommand, parseResonanceCampaignDefinition, parseResonanceCampaignDraft, parseResonanceCampaignSaveCommand, parseResonanceCampaignView, parseResonanceClickIdentifiers, parseResonanceCommand, parseResonanceCommandPrepareRequest, parseResonanceCommandPrepareResponse, parseResonanceConsentResponse, parseResonanceConsentSnapshot, parseResonanceConsentUpdate, parseResonanceConversionEnvelope, parseResonanceExperimentCompleteCommand, parseResonanceExperimentCreateCommand, parseResonanceExperimentExposure, parseResonanceExperimentLifecycleCommand, parseResonanceExperimentLinkCommand, parseResonanceExperimentRef, parseResonanceExperimentUpdateCommand, parseResonanceGoogleCampaignDiagnosticsPayload, parseResonanceGoogleCampaignDiagnosticsReport, parseResonanceGoogleCampaignDiagnosticsRequest, parseResonanceGoogleConfigurationReview, parseResonanceGoogleConfigurationSaveCommand, parseResonanceGoogleConfigurationSaveResponse, parseResonanceGoogleConfigurationSnapshot, parseResonanceGoogleConfigurationView, parseResonanceGoogleContentUpdate, parseResonanceGoogleContentUpdateSelection, parseResonanceGoogleUploadClicksCustomGoalSpec, parseResonanceMandateApprovalPayload, parseResonanceMandateDraftRequest, parseResonanceMandateRef, parseResonanceMandateScope, parseResonanceMandateTarget, parseResonanceMeasurementConfig, parseResonanceMeasurementConfigurationCurrent, parseResonanceMeasurementConfigurationSaveCommand, parseResonanceMeasurementConfigurationSaveResponse, parseResonanceMeasurementConfigurationSnapshot, parseResonanceMeasurementOccurrence, parseResonanceMetaAudienceSetupIntent, parseResonanceMetaAudienceSetupList, parseResonanceMetaAudienceSetupPrepareRequest, parseResonanceMetaAudienceSetupReadiness, parseResonanceMetaAudienceSetupReceipt, parseResonanceMetaAudienceSetupReview, parseResonanceMetaAudienceSetupStatus, parseResonanceMetaConfigurationSaveCommand, parseResonanceMetaConfigurationSaveResponse, parseResonanceMetaConfigurationSnapshot, parseResonanceMetaConfigurationView, parseResonanceMetaDatasetName, parseResonanceMetaDatasetSelectionRequest, parseResonanceMetaDatasetSelectionWitness, parseResonanceMetaDatasetSetupIntent, parseResonanceMetaDatasetSetupPrepareRequest, parseResonanceMetaDatasetSetupReceipt, parseResonanceMetaDatasetSetupReview, parseResonanceMetaRetargetingReadiness, parseResonanceMetricObservation, parseResonanceObservationSupport, parseResonanceObservationsPage, parseResonanceOccurrenceResponse, parseResonanceOperatingPolicy, parseResonanceOperatingPolicyBase, parseResonanceOperatingPolicyRef, parseResonanceOperatingPolicySelection, parseResonanceOptimizationDecision, parseResonanceOptimizationEvidence, parseResonanceOptimizationPolicy, parseResonancePositioningApplyRequest, parseResonancePositioningConsistencyAssessment, parseResonancePositioningContext, parseResonancePositioningPreview, parseResonancePositioningPreviewRequest, parseResonancePositioningResult, parseResonancePreparationLookupRequest, parseResonancePreparationLookupResponse, parseResonancePreparationRetireRequest, parseResonancePreparationRetireResponse, parseResonancePrepareCommand, parseResonancePreparedPlan, parseResonanceProviderReportingGrant, parseResonanceProviderReportingSelection, parseResonancePublicObservationMetric, parseResonanceQualificationRule, parseResonanceReceipt, parseResonanceResolvedQualificationRule, parseResonanceResourceRef, parseResonanceSourceMarker, parseResonanceSubjectRenewCommand, parseResonanceWebsiteVisitFeedReview, parseResonanceWebsiteVisitSetupDeliveryCommand, parseResonanceWebsiteVisitSetupGrant, parseResonanceWebsiteVisitSetupGrantAcceptedVisits, parseResonanceWebsiteVisitSetupGrantProof, parseResonanceWebsiteVisitSetupGrantStatus, parseResonanceWebsiteVisitSetupOrigin, projectResonanceGoogleConfiguration, projectResonanceMeasurementConfiguration, projectResonanceMetaConfiguration, projectResonancePositioningConsistencyEvidence, reportedCpqlMissingOutcomeBound, resonanceCommandDigestInput, resonanceGoogleConfigurationDigestInput, resonanceGoogleSetupDigestInput, resonanceMandateDigestInput, resonanceMeasurementConfigDigestInput, resonanceMeasurementConfigurationSaveDigestInput, resonanceMetaAudienceSetupDigestInput, resonanceMetaAudienceSetupReceiptDigestInput, resonanceMetaConfigurationDigestInput, resonanceMetaConfigurationSaveDigestInput, resonanceMetaDatasetSetupDigestInput, resonanceOperatingPolicyActionDigestInput, resonanceOperatingPolicyDigestInput, resonanceOptimizationDecisionDigestInput, resonanceOptimizationEvidenceDigestInput, resonanceOptimizationPolicyDigestInput, resonancePlanIssues, resonancePositioningConsistencyEvidenceDigestInput, resonancePositioningContextDigestInput, resonancePositioningEvidenceDigestInput, resonancePositioningResultDigestInput, resonanceWebsiteVisitEventTime, resonanceWebsiteVisitProfileDigestInput, resonanceWebsiteVisitSetupDeliveryDigestInput, resonanceWebsiteVisitSetupEventTime, splitBudget, subtractMoney, suggestPropertyWeights };
|