@sonordev/contracts 2.25.0 → 2.27.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 +12 -0
- package/README.md +67 -0
- package/dist/booking-intake-normalize.d.ts +152 -0
- package/dist/booking-intake.d.ts +68 -0
- package/dist/booking-intake.js +221 -0
- package/dist/booking-intake.mjs +203 -0
- package/dist/property-interest.d.ts +100 -0
- package/dist/property-interest.js +261 -0
- package/dist/property-interest.mjs +244 -0
- package/dist/quote-screen.d.ts +29 -0
- package/dist/quote-screen.js +194 -0
- package/dist/quote-screen.mjs +190 -0
- package/dist/quote-screen.vectors.d.ts +23 -0
- package/dist/resonance-confirmation.d.ts +238 -0
- package/dist/resonance-confirmation.js +163 -0
- package/dist/resonance-confirmation.mjs +131 -0
- package/dist/resonance.d.ts +266 -2
- package/dist/resonance.js +263 -6
- package/dist/resonance.mjs +246 -7
- package/dist/schema-placeholders.d.ts +2 -2
- package/dist/seo-pages.js +3 -3
- package/dist/seo-pages.mjs +3 -3
- package/dist/sites-normalize.d.ts +7 -0
- package/dist/sites.d.ts +1 -3
- package/dist/sites.js +3 -3
- package/dist/sites.mjs +3 -3
- package/package.json +22 -2
package/dist/resonance.js
CHANGED
|
@@ -58,6 +58,9 @@ function createWireSchema(fail3, isValidationError) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// src/contracts/sites-normalize.ts
|
|
61
|
+
function stripWww(host) {
|
|
62
|
+
return host.startsWith("www.") ? host.slice(4) : host;
|
|
63
|
+
}
|
|
61
64
|
function normalizeSiteHost(site2) {
|
|
62
65
|
if (!site2 || typeof site2 !== "string") return null;
|
|
63
66
|
let s = site2.trim().toLowerCase();
|
|
@@ -72,9 +75,6 @@ function normalizeSiteHost(site2) {
|
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
// src/contracts/sites.ts
|
|
75
|
-
function stripWww(host) {
|
|
76
|
-
return host.startsWith("www.") ? host.slice(4) : host;
|
|
77
|
-
}
|
|
78
78
|
function sameSite(a, b) {
|
|
79
79
|
if (!a || !b) return false;
|
|
80
80
|
return stripWww(a) === stripWww(b);
|
|
@@ -368,13 +368,16 @@ var resolvedQualificationRule = refine2(object2({
|
|
|
368
368
|
ref: resource,
|
|
369
369
|
crmVariant: text2(128),
|
|
370
370
|
ladderSnapshot: list2(object2({ id: nullable2(uuid), stage_key: revision, semantic_key: nullable2(revision), is_won: bool, is_lost: bool }), 500, 1),
|
|
371
|
+
// eligibleBookingTypeIds: Sync booking types whose confirmed bookings also count, beside the one form. Absent means forms only.
|
|
371
372
|
eligibleFormIds: list2(uuid, 500, 1),
|
|
373
|
+
eligibleBookingTypeIds: optional2(list2(uuid, 100, 1)),
|
|
372
374
|
attribution: object2({ model: literal2(RESONANCE_ATTRIBUTION_MODEL), resolverRevision: literal2(1) }),
|
|
373
375
|
cohort: object2({ startAt: instant, endAt: instant, maturityDelaySeconds: integer2(0, 31536e3) })
|
|
374
376
|
}), (v, p) => {
|
|
375
377
|
checkQualificationPartitions(v, p);
|
|
376
378
|
if (v.ref.module !== "crm" || v.ref.id !== v.ref.projectId) fail2(p + ".ref", "must reference the actual CRM project configuration");
|
|
377
379
|
unique(v.eligibleFormIds, p + ".eligibleFormIds");
|
|
380
|
+
if (v.eligibleBookingTypeIds) unique(v.eligibleBookingTypeIds.map((x) => x.toLowerCase()), p + ".eligibleBookingTypeIds");
|
|
378
381
|
unique(v.ladderSnapshot.flatMap((x) => x.id ? [x.id] : []), p + ".ladderSnapshot.id");
|
|
379
382
|
unique(v.ladderSnapshot.map((x) => x.stage_key), p + ".ladderSnapshot.stage_key");
|
|
380
383
|
const partitions = [...v.positiveStageKeys, ...v.finalNegativeStageKeys, ...v.pendingStageKeys], keys = new Set(v.ladderSnapshot.map((x) => x.stage_key));
|
|
@@ -383,7 +386,21 @@ var resolvedQualificationRule = refine2(object2({
|
|
|
383
386
|
});
|
|
384
387
|
var parseResonanceResolvedQualificationRule = (v) => resolvedQualificationRule.read(v, "resolvedQualificationRule");
|
|
385
388
|
var RESONANCE_RESOLVED_QUALIFICATION_RULE_JSON_SCHEMA = resolvedQualificationRule.schema;
|
|
386
|
-
var objective = refine2(object2({
|
|
389
|
+
var objective = refine2(object2({
|
|
390
|
+
source,
|
|
391
|
+
measurementRevision: revision,
|
|
392
|
+
countingUnit: objectiveCountingUnit,
|
|
393
|
+
attributionWindowDays: integer2(1, 365),
|
|
394
|
+
maturityDelaySeconds: integer2(0, 31536e3),
|
|
395
|
+
qualificationRuleRef: nullable2(resource),
|
|
396
|
+
qualificationRule: optional2(qualificationRule),
|
|
397
|
+
// Booking types a person reviewed as counting toward the qualified-lead goal, beside its one form. Absent keeps the goal forms-only and the serialization unchanged.
|
|
398
|
+
eligibleBookingTypeIds: optional2(list2(uuid, 100, 1))
|
|
399
|
+
}), (v, p) => {
|
|
400
|
+
if (v.eligibleBookingTypeIds) {
|
|
401
|
+
if (v.source.kind !== "qualified_lead") fail2(p + ".eligibleBookingTypeIds", "requires the native qualified-lead source");
|
|
402
|
+
unique(v.eligibleBookingTypeIds.map((x) => x.toLowerCase()), p + ".eligibleBookingTypeIds");
|
|
403
|
+
}
|
|
387
404
|
if (v.qualificationRule && v.source.kind !== "qualified_lead") fail2(p + ".qualificationRule", "requires the native qualified-lead source");
|
|
388
405
|
if (v.qualificationRule && v.qualificationRuleRef && (v.qualificationRuleRef.module !== "crm" || v.qualificationRuleRef.id !== v.source.projectId)) fail2(p + ".qualificationRuleRef", "must reference actual CRM project configuration");
|
|
389
406
|
});
|
|
@@ -818,6 +835,10 @@ var RESONANCE_GOOGLE_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA = googleConfigurati
|
|
|
818
835
|
var preparedManifestRef = object2({ id: uuid, digest, providerVersion: text2(30), revision });
|
|
819
836
|
var preview = object2({ channelId: uuid, site, accountBindingId: nullable2(uuid), accountName: text2(200), accountTimeZone: timeZone, destinationUrl: text2(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) });
|
|
820
837
|
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(text2(200), 100) });
|
|
838
|
+
function bookingTypesMatch(goalIds, witnessIds) {
|
|
839
|
+
const norm = (ids) => ids === void 0 ? null : [...ids].map((id) => id.toLowerCase()).sort();
|
|
840
|
+
return canonical(norm(goalIds)) === canonical(norm(witnessIds));
|
|
841
|
+
}
|
|
821
842
|
function parseResonancePreparedPlan(v) {
|
|
822
843
|
const r = prepared.read(v, "preparedPlan");
|
|
823
844
|
checkDefinition(r.definition);
|
|
@@ -827,7 +848,7 @@ function parseResonancePreparedPlan(v) {
|
|
|
827
848
|
if (goal.source.kind === "qualified_lead") {
|
|
828
849
|
if (!goal.qualificationRule || !goal.qualificationRuleRef || !witness) fail2("preparedPlan.resolvedQualificationRule", "qualified-lead preparation requires actual configured native witness");
|
|
829
850
|
const w = witness, selected = goal.qualificationRule;
|
|
830
|
-
if (goal.countingUnit !== "unique_qualified_contact" || canonical(w.ref) !== canonical(goal.qualificationRuleRef) || w.eligibleFormIds.length !== 1 || w.eligibleFormIds[0] !== goal.source.id || w.cohort.maturityDelaySeconds !== goal.maturityDelaySeconds) fail2("preparedPlan.resolvedQualificationRule", "source, counting unit, reference or maturity mismatch");
|
|
851
|
+
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) fail2("preparedPlan.resolvedQualificationRule", "source, counting unit, reference or maturity mismatch");
|
|
831
852
|
for (const key of ["schemaVersion", "semantics", "positiveStageKeys", "finalNegativeStageKeys", "pendingStageKeys", "existingContactPolicy"]) if (canonical(w[key]) !== canonical(selected[key])) fail2("preparedPlan.resolvedQualificationRule", "selected qualification snapshot mismatch");
|
|
832
853
|
} else if (witness !== null) fail2("preparedPlan.resolvedQualificationRule", "nonqualified objectives require explicit null");
|
|
833
854
|
if (canonical(r.resolvedEvidencePolicy) !== canonical(r.definition.optimization.policy)) fail2("preparedPlan.resolvedEvidencePolicy", "policy snapshot mismatch");
|
|
@@ -886,7 +907,7 @@ function parseResonanceCommand(v, context) {
|
|
|
886
907
|
if (!channel2 || channel2.kind !== "google_search") fail2("command.channelIds", "requires one original Google channel");
|
|
887
908
|
const c = channel2;
|
|
888
909
|
const goal = plan.definition.objective, witness = plan.resolvedQualificationRule;
|
|
889
|
-
if (goal.source.kind !== "qualified_lead" || goal.countingUnit !== "unique_qualified_contact" || !witness || witness.eligibleFormIds.length !== 1 || witness.eligibleFormIds[0] !== goal.source.id || goal.source.site !== c.site) fail2("command.context.goal", "requires the original single managed-form qualified source");
|
|
910
|
+
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) fail2("command.context.goal", "requires the original single managed-form qualified source");
|
|
890
911
|
const account = plan.accounts.find((a) => a.id === c.accountBindingId);
|
|
891
912
|
if (!account || account.provider !== "google_ads" || !grant.accountBindingIds.includes(c.accountBindingId) || !grant.sites.includes(c.site)) fail2("command.context.account", "requires the original granted Google account and site");
|
|
892
913
|
const configuration = plan.channelPreviews.find((p) => p.channelId === c.id)?.googleConfiguration;
|
|
@@ -986,6 +1007,224 @@ function canonical(value) {
|
|
|
986
1007
|
var resonanceMandateDigestInput = (v) => canonical(parseResonanceMandateScope(v));
|
|
987
1008
|
var resonanceCommandDigestInput = (v) => canonical(parseResonanceCommand(v));
|
|
988
1009
|
var parseResonanceMandateTarget = (v) => mandateTarget.read(v, "target_ref");
|
|
1010
|
+
var positioningTarget = union2(
|
|
1011
|
+
object2({ kind: literal2("broadcast"), channelId: uuid }),
|
|
1012
|
+
object2({ kind: literal2("meta"), channelId: uuid, creativeId: uuid }),
|
|
1013
|
+
object2({ kind: literal2("google_search"), channelId: uuid, adGroupKey: text2(80), adKey: text2(80) })
|
|
1014
|
+
);
|
|
1015
|
+
var positioningRequest = object2({
|
|
1016
|
+
schemaVersion: literal2(1),
|
|
1017
|
+
expectedRevision: integer2(1),
|
|
1018
|
+
site,
|
|
1019
|
+
destination: optional2(object2({ kind: choice2("existing_page", "funnel"), id: uuid })),
|
|
1020
|
+
offerId: optional2(uuid),
|
|
1021
|
+
target: positioningTarget
|
|
1022
|
+
});
|
|
1023
|
+
var positioningWitnessFields = {
|
|
1024
|
+
id: operationKey,
|
|
1025
|
+
kind: choice2("page", "funnel", "offer", "brain", "buyer", "proof"),
|
|
1026
|
+
sourceId: text2(160),
|
|
1027
|
+
revision,
|
|
1028
|
+
observedAt: instant,
|
|
1029
|
+
expiresAt: instant,
|
|
1030
|
+
permission: choice2("private", "public"),
|
|
1031
|
+
certainty: choice2("verified", "reported", "conflicting")
|
|
1032
|
+
};
|
|
1033
|
+
var positioningWitness = refine2(object2(positioningWitnessFields), checkPositioningWitness);
|
|
1034
|
+
var positioningText = (max) => refine2(text2(max), (value, at) => {
|
|
1035
|
+
if (!value.trim() || /[\x00-\x08\x0b-\x1f\x7f]/.test(value)) fail2(at, "requires nonblank text without control characters");
|
|
1036
|
+
});
|
|
1037
|
+
var positioningEvidence = refine2(object2({ ...positioningWitnessFields, text: positioningText(1600) }), checkPositioningWitness);
|
|
1038
|
+
function checkPositioningWitness(value, at) {
|
|
1039
|
+
if (Date.parse(value.observedAt) >= Date.parse(value.expiresAt)) fail2(at, "requires a positive witness lifetime");
|
|
1040
|
+
}
|
|
1041
|
+
var positioningScopeFields = { schemaVersion: literal2(1), projectId: uuid, campaignId: uuid, request: positioningRequest, observedAt: instant, expiresAt: instant };
|
|
1042
|
+
function checkPositioningWindow(value, at) {
|
|
1043
|
+
if (Date.parse(value.observedAt) >= Date.parse(value.expiresAt)) fail2(at, "requires a positive review lifetime");
|
|
1044
|
+
unique(value.evidence.map((item) => item.id), at + ".evidence");
|
|
1045
|
+
if (value.evidence.some((item) => Date.parse(item.observedAt) > Date.parse(value.observedAt))) fail2(at + ".evidence", "witness observation postdates the preview");
|
|
1046
|
+
}
|
|
1047
|
+
var positioningContext = refine2(object2({
|
|
1048
|
+
...positioningScopeFields,
|
|
1049
|
+
orgId: uuid,
|
|
1050
|
+
evidence: list2(positioningEvidence, 32)
|
|
1051
|
+
}), (value, at) => {
|
|
1052
|
+
checkPositioningWindow(value, at);
|
|
1053
|
+
if (value.evidence.reduce((total, witness) => total + witness.text.length, 0) > 16e3) {
|
|
1054
|
+
fail2(at + ".evidence", "exceeds the combined source text budget");
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
var positioningEvidenceIds = uniqueList(operationKey, 8);
|
|
1058
|
+
var positioningSupportedText = object2({ text: positioningText(320), evidenceIds: positioningEvidenceIds });
|
|
1059
|
+
var positioningAlternative = refine2(object2({
|
|
1060
|
+
text: positioningText(320),
|
|
1061
|
+
kind: choice2("status_quo", "alternative"),
|
|
1062
|
+
basis: choice2("evidence", "hypothesis"),
|
|
1063
|
+
evidenceIds: positioningEvidenceIds
|
|
1064
|
+
}), (value, at) => {
|
|
1065
|
+
if (value.basis === "evidence" !== value.evidenceIds.length > 0) fail2(at, "requires evidence references exactly for evidenced alternatives");
|
|
1066
|
+
});
|
|
1067
|
+
var positioningClaim = object2({
|
|
1068
|
+
attribute: positioningText(320),
|
|
1069
|
+
value: positioningText(320),
|
|
1070
|
+
evidenceIds: uniqueList(operationKey, 8, 1),
|
|
1071
|
+
publicProofIds: positioningEvidenceIds
|
|
1072
|
+
});
|
|
1073
|
+
var positioningClaimIndexes = list2(integer2(0, 7), 8, 1);
|
|
1074
|
+
var positioningCopy = union2(
|
|
1075
|
+
object2({ kind: literal2("broadcast"), caption: positioningText(2200), claimIndexes: positioningClaimIndexes }),
|
|
1076
|
+
object2({
|
|
1077
|
+
kind: literal2("meta"),
|
|
1078
|
+
primaryText: positioningText(2200),
|
|
1079
|
+
headline: positioningText(160),
|
|
1080
|
+
body: positioningText(1e4),
|
|
1081
|
+
claimIndexes: positioningClaimIndexes
|
|
1082
|
+
}),
|
|
1083
|
+
object2({
|
|
1084
|
+
kind: literal2("google_search"),
|
|
1085
|
+
headlines: uniqueList(positioningText(30), 15, 3),
|
|
1086
|
+
descriptions: uniqueList(positioningText(90), 4, 2),
|
|
1087
|
+
claimIndexes: positioningClaimIndexes
|
|
1088
|
+
})
|
|
1089
|
+
);
|
|
1090
|
+
var positioningReasonCodes = choice2(
|
|
1091
|
+
"destination_missing",
|
|
1092
|
+
"destination_unverified",
|
|
1093
|
+
"offer_unverified",
|
|
1094
|
+
"offer_conflicting",
|
|
1095
|
+
"brain_unavailable",
|
|
1096
|
+
"buyer_evidence_sparse",
|
|
1097
|
+
"public_proof_unavailable",
|
|
1098
|
+
"fit_not_established",
|
|
1099
|
+
"status_quo_sufficient",
|
|
1100
|
+
"channel_mismatch",
|
|
1101
|
+
"source_stale",
|
|
1102
|
+
"evidence_conflicting",
|
|
1103
|
+
"generation_unavailable"
|
|
1104
|
+
);
|
|
1105
|
+
var RESONANCE_POSITIONING_METHOD_VERSION = "positioning_v1";
|
|
1106
|
+
var positioningResult = refine2(object2({
|
|
1107
|
+
methodVersion: literal2(RESONANCE_POSITIONING_METHOD_VERSION),
|
|
1108
|
+
state: choice2("ready", "provisional", "no_fit"),
|
|
1109
|
+
reasonCodes: uniqueList(positioningReasonCodes, 12),
|
|
1110
|
+
alternatives: list2(positioningAlternative, 8),
|
|
1111
|
+
claims: list2(positioningClaim, 8),
|
|
1112
|
+
bestFit: list2(positioningSupportedText, 8),
|
|
1113
|
+
category: nullable2(object2({ text: positioningText(160), style: choice2("existing_category", "focused_subcategory", "new_category"), evidenceIds: positioningEvidenceIds })),
|
|
1114
|
+
timelyContext: nullable2(positioningSupportedText),
|
|
1115
|
+
unknowns: list2(positioningText(320), 8),
|
|
1116
|
+
questions: list2(positioningText(320), 8),
|
|
1117
|
+
copy: nullable2(positioningCopy)
|
|
1118
|
+
}), (value, at) => {
|
|
1119
|
+
if (value.state !== "ready") {
|
|
1120
|
+
if (value.copy || !value.reasonCodes.length) fail2(at, "requires a reason and no draft copy when held");
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
const { copy, claims, category, bestFit, alternatives } = value;
|
|
1124
|
+
if (!copy || value.reasonCodes.length || !claims.length || !category || !bestFit.length || !alternatives.length) {
|
|
1125
|
+
return fail2(at, "requires a supported ready brief and channel draft");
|
|
1126
|
+
}
|
|
1127
|
+
unique(copy.claimIndexes.map(String), at + ".copy.claimIndexes");
|
|
1128
|
+
if (copy.claimIndexes.some((index) => index >= claims.length)) fail2(at + ".copy.claimIndexes", "requires an existing claim index");
|
|
1129
|
+
});
|
|
1130
|
+
function checkPositioningEvidence(result, context, at) {
|
|
1131
|
+
const evidence = new Map(context.evidence.map((witness) => [witness.id, witness]));
|
|
1132
|
+
const current = (witness) => witness.certainty === "verified" && Date.parse(witness.expiresAt) >= Date.parse(context.expiresAt);
|
|
1133
|
+
const cited = [
|
|
1134
|
+
...result.alternatives,
|
|
1135
|
+
...result.claims,
|
|
1136
|
+
...result.bestFit,
|
|
1137
|
+
...result.category ? [result.category] : [],
|
|
1138
|
+
...result.timelyContext ? [result.timelyContext] : []
|
|
1139
|
+
];
|
|
1140
|
+
if (cited.some((item) => item.evidenceIds.some((id) => !evidence.has(id)))) fail2(at, "references unknown evidence");
|
|
1141
|
+
for (const claim of result.claims) {
|
|
1142
|
+
for (const id of claim.publicProofIds) {
|
|
1143
|
+
const witness = evidence.get(id);
|
|
1144
|
+
if (!witness || witness.permission !== "public" || !current(witness)) fail2(at, "public proof requires a current permitted witness");
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
if (result.timelyContext && (!result.timelyContext.evidenceIds.length || result.timelyContext.evidenceIds.some((id) => {
|
|
1148
|
+
const witness = evidence.get(id);
|
|
1149
|
+
return !witness || !current(witness);
|
|
1150
|
+
}))) fail2(at, "timely context requires current verified evidence");
|
|
1151
|
+
if (!result.copy) return;
|
|
1152
|
+
if (result.copy.kind !== context.request.target.kind) fail2(at, "copy target differs from the request");
|
|
1153
|
+
const { destination: selected, offerId } = context.request;
|
|
1154
|
+
const owns = (kind, id) => {
|
|
1155
|
+
const witnesses = context.evidence.filter((w) => w.kind === kind && (!id || w.sourceId.toLowerCase() === id.toLowerCase()));
|
|
1156
|
+
return witnesses.some(current) && !witnesses.some((w) => w.certainty === "conflicting");
|
|
1157
|
+
};
|
|
1158
|
+
if (!selected || !owns(selected.kind === "existing_page" ? "page" : "funnel", selected.id) || !owns("brain") || offerId && !owns("offer", offerId)) {
|
|
1159
|
+
fail2(at, "ready copy requires current destination, Brain and selected offer witnesses");
|
|
1160
|
+
}
|
|
1161
|
+
for (const index of result.copy.claimIndexes) {
|
|
1162
|
+
const claim = result.claims[index];
|
|
1163
|
+
if (![...claim.evidenceIds, ...claim.publicProofIds].every((id) => {
|
|
1164
|
+
const witness = evidence.get(id);
|
|
1165
|
+
return witness && witness.permission === "public" && current(witness);
|
|
1166
|
+
})) fail2(at, "selected copy requires current verified public claim evidence");
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
var positioningApplicationToken = text2(32e3, /^[a-zA-Z0-9._-]+$/);
|
|
1170
|
+
var positioningPreview = refine2(object2({
|
|
1171
|
+
...positioningScopeFields,
|
|
1172
|
+
evidence: list2(positioningWitness, 32),
|
|
1173
|
+
result: positioningResult,
|
|
1174
|
+
applicationToken: nullable2(positioningApplicationToken)
|
|
1175
|
+
}), (value, at) => {
|
|
1176
|
+
checkPositioningWindow(value, at);
|
|
1177
|
+
checkPositioningEvidence(value.result, value, at + ".result");
|
|
1178
|
+
if (value.result.state === "ready" !== (value.applicationToken !== null)) fail2(at, "requires an application token exactly for ready copy");
|
|
1179
|
+
});
|
|
1180
|
+
var positioningApplyRequest = object2({ applicationToken: positioningApplicationToken });
|
|
1181
|
+
var parseResonancePositioningPreviewRequest = (value) => positioningRequest.read(value, "positioningPreviewRequest");
|
|
1182
|
+
var parseResonancePositioningContext = (value) => positioningContext.read(value, "positioningContext");
|
|
1183
|
+
function parseResonancePositioningResult(value, context) {
|
|
1184
|
+
const result = positioningResult.read(value, "positioningResult");
|
|
1185
|
+
if (context) checkPositioningEvidence(result, parseResonancePositioningContext(context), "positioningResult");
|
|
1186
|
+
return result;
|
|
1187
|
+
}
|
|
1188
|
+
var parseResonancePositioningPreview = (value) => positioningPreview.read(value, "positioningPreview");
|
|
1189
|
+
var parseResonancePositioningApplyRequest = (value) => positioningApplyRequest.read(value, "positioningApplyRequest");
|
|
1190
|
+
var resonancePositioningContextDigestInput = (value) => canonical(parseResonancePositioningContext(value));
|
|
1191
|
+
function resonancePositioningEvidenceDigestInput(value) {
|
|
1192
|
+
return positioningEvidenceDigestInput(parseResonancePositioningContext(value).evidence);
|
|
1193
|
+
}
|
|
1194
|
+
function positioningEvidenceDigestInput(evidence) {
|
|
1195
|
+
return canonical(evidence.map(({ observedAt: _observed, expiresAt: _expires, ...witness }) => witness).sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
1196
|
+
}
|
|
1197
|
+
var resonancePositioningResultDigestInput = (value) => canonical(parseResonancePositioningResult(value));
|
|
1198
|
+
var RESONANCE_POSITIONING_PREVIEW_REQUEST_JSON_SCHEMA = positioningRequest.schema;
|
|
1199
|
+
var RESONANCE_POSITIONING_CONTEXT_JSON_SCHEMA = positioningContext.schema;
|
|
1200
|
+
var RESONANCE_POSITIONING_RESULT_JSON_SCHEMA = positioningResult.schema;
|
|
1201
|
+
var RESONANCE_POSITIONING_PREVIEW_JSON_SCHEMA = positioningPreview.schema;
|
|
1202
|
+
var RESONANCE_POSITIONING_APPLY_REQUEST_JSON_SCHEMA = positioningApplyRequest.schema;
|
|
1203
|
+
function projectResonancePositioningConsistencyEvidence(value) {
|
|
1204
|
+
const context = parseResonancePositioningContext(value);
|
|
1205
|
+
const expiry = Date.parse(context.expiresAt);
|
|
1206
|
+
return context.evidence.filter((witness) => witness.permission === "public" && witness.certainty === "verified" && Date.parse(witness.expiresAt) >= expiry);
|
|
1207
|
+
}
|
|
1208
|
+
var resonancePositioningConsistencyEvidenceDigestInput = (value) => positioningEvidenceDigestInput(projectResonancePositioningConsistencyEvidence(value));
|
|
1209
|
+
var positioningConsistencyAssessment = object2({
|
|
1210
|
+
state: choice2("compatible", "conflicting", "unknown"),
|
|
1211
|
+
evidenceDigest: digest,
|
|
1212
|
+
coveredSourceIds: uniqueList(operationKey, 32)
|
|
1213
|
+
});
|
|
1214
|
+
function parseResonancePositioningConsistencyAssessment(value, expected) {
|
|
1215
|
+
const at = "positioningConsistencyAssessment";
|
|
1216
|
+
const assessment = positioningConsistencyAssessment.read(value, at);
|
|
1217
|
+
if (assessment.evidenceDigest !== digest.read(expected.evidenceDigest, at + ".expectedEvidenceDigest")) {
|
|
1218
|
+
fail2(at + ".evidenceDigest", "requires the exact current permitted evidence digest");
|
|
1219
|
+
}
|
|
1220
|
+
const eligibleIds = new Set(projectResonancePositioningConsistencyEvidence(expected.context).map((witness) => witness.id));
|
|
1221
|
+
const { state, coveredSourceIds } = assessment;
|
|
1222
|
+
if (coveredSourceIds.some((id) => !eligibleIds.has(id)) || state !== "unknown" && coveredSourceIds.length !== eligibleIds.size || state === "compatible" && coveredSourceIds.length < 1 || state === "conflicting" && coveredSourceIds.length < 2) {
|
|
1223
|
+
fail2(at + ".coveredSourceIds", "coverage does not support this consistency state");
|
|
1224
|
+
}
|
|
1225
|
+
return assessment;
|
|
1226
|
+
}
|
|
1227
|
+
var RESONANCE_POSITIONING_CONSISTENCY_ASSESSMENT_JSON_SCHEMA = positioningConsistencyAssessment.schema;
|
|
989
1228
|
var prepareCommand = object2({ expectedRevision: integer2(1), idempotencyKey: operationKey });
|
|
990
1229
|
var parseResonancePrepareCommand = (v) => prepareCommand.read(v, "prepare");
|
|
991
1230
|
var parseResonanceCommandPrepareRequest = parseResonancePrepareCommand;
|
|
@@ -2528,6 +2767,13 @@ exports.RESONANCE_OCCURRENCE_RESPONSE_JSON_SCHEMA = RESONANCE_OCCURRENCE_RESPONS
|
|
|
2528
2767
|
exports.RESONANCE_OPTIMIZATION_DECISION_JSON_SCHEMA = RESONANCE_OPTIMIZATION_DECISION_JSON_SCHEMA;
|
|
2529
2768
|
exports.RESONANCE_OPTIMIZATION_EVIDENCE_JSON_SCHEMA = RESONANCE_OPTIMIZATION_EVIDENCE_JSON_SCHEMA;
|
|
2530
2769
|
exports.RESONANCE_OPTIMIZATION_POLICY_JSON_SCHEMA = RESONANCE_OPTIMIZATION_POLICY_JSON_SCHEMA;
|
|
2770
|
+
exports.RESONANCE_POSITIONING_APPLY_REQUEST_JSON_SCHEMA = RESONANCE_POSITIONING_APPLY_REQUEST_JSON_SCHEMA;
|
|
2771
|
+
exports.RESONANCE_POSITIONING_CONSISTENCY_ASSESSMENT_JSON_SCHEMA = RESONANCE_POSITIONING_CONSISTENCY_ASSESSMENT_JSON_SCHEMA;
|
|
2772
|
+
exports.RESONANCE_POSITIONING_CONTEXT_JSON_SCHEMA = RESONANCE_POSITIONING_CONTEXT_JSON_SCHEMA;
|
|
2773
|
+
exports.RESONANCE_POSITIONING_METHOD_VERSION = RESONANCE_POSITIONING_METHOD_VERSION;
|
|
2774
|
+
exports.RESONANCE_POSITIONING_PREVIEW_JSON_SCHEMA = RESONANCE_POSITIONING_PREVIEW_JSON_SCHEMA;
|
|
2775
|
+
exports.RESONANCE_POSITIONING_PREVIEW_REQUEST_JSON_SCHEMA = RESONANCE_POSITIONING_PREVIEW_REQUEST_JSON_SCHEMA;
|
|
2776
|
+
exports.RESONANCE_POSITIONING_RESULT_JSON_SCHEMA = RESONANCE_POSITIONING_RESULT_JSON_SCHEMA;
|
|
2531
2777
|
exports.RESONANCE_PREPARED_PLAN_JSON_SCHEMA = RESONANCE_PREPARED_PLAN_JSON_SCHEMA;
|
|
2532
2778
|
exports.RESONANCE_PROVIDER_METRIC_NAMES = RESONANCE_PROVIDER_METRIC_NAMES;
|
|
2533
2779
|
exports.RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA = RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA;
|
|
@@ -2632,6 +2878,12 @@ exports.parseResonanceOccurrenceResponse = parseResonanceOccurrenceResponse;
|
|
|
2632
2878
|
exports.parseResonanceOptimizationDecision = parseResonanceOptimizationDecision;
|
|
2633
2879
|
exports.parseResonanceOptimizationEvidence = parseResonanceOptimizationEvidence;
|
|
2634
2880
|
exports.parseResonanceOptimizationPolicy = parseResonanceOptimizationPolicy;
|
|
2881
|
+
exports.parseResonancePositioningApplyRequest = parseResonancePositioningApplyRequest;
|
|
2882
|
+
exports.parseResonancePositioningConsistencyAssessment = parseResonancePositioningConsistencyAssessment;
|
|
2883
|
+
exports.parseResonancePositioningContext = parseResonancePositioningContext;
|
|
2884
|
+
exports.parseResonancePositioningPreview = parseResonancePositioningPreview;
|
|
2885
|
+
exports.parseResonancePositioningPreviewRequest = parseResonancePositioningPreviewRequest;
|
|
2886
|
+
exports.parseResonancePositioningResult = parseResonancePositioningResult;
|
|
2635
2887
|
exports.parseResonancePrepareCommand = parseResonancePrepareCommand;
|
|
2636
2888
|
exports.parseResonancePreparedPlan = parseResonancePreparedPlan;
|
|
2637
2889
|
exports.parseResonanceProviderReportingGrant = parseResonanceProviderReportingGrant;
|
|
@@ -2653,6 +2905,7 @@ exports.parseResonanceWebsiteVisitSetupOrigin = parseResonanceWebsiteVisitSetupO
|
|
|
2653
2905
|
exports.projectResonanceGoogleConfiguration = projectResonanceGoogleConfiguration;
|
|
2654
2906
|
exports.projectResonanceMeasurementConfiguration = projectResonanceMeasurementConfiguration;
|
|
2655
2907
|
exports.projectResonanceMetaConfiguration = projectResonanceMetaConfiguration;
|
|
2908
|
+
exports.projectResonancePositioningConsistencyEvidence = projectResonancePositioningConsistencyEvidence;
|
|
2656
2909
|
exports.reportedCpqlMissingOutcomeBound = reportedCpqlMissingOutcomeBound;
|
|
2657
2910
|
exports.resonanceCommandDigestInput = resonanceCommandDigestInput;
|
|
2658
2911
|
exports.resonanceGoogleConfigurationDigestInput = resonanceGoogleConfigurationDigestInput;
|
|
@@ -2669,6 +2922,10 @@ exports.resonanceOptimizationDecisionDigestInput = resonanceOptimizationDecision
|
|
|
2669
2922
|
exports.resonanceOptimizationEvidenceDigestInput = resonanceOptimizationEvidenceDigestInput;
|
|
2670
2923
|
exports.resonanceOptimizationPolicyDigestInput = resonanceOptimizationPolicyDigestInput;
|
|
2671
2924
|
exports.resonancePlanIssues = resonancePlanIssues;
|
|
2925
|
+
exports.resonancePositioningConsistencyEvidenceDigestInput = resonancePositioningConsistencyEvidenceDigestInput;
|
|
2926
|
+
exports.resonancePositioningContextDigestInput = resonancePositioningContextDigestInput;
|
|
2927
|
+
exports.resonancePositioningEvidenceDigestInput = resonancePositioningEvidenceDigestInput;
|
|
2928
|
+
exports.resonancePositioningResultDigestInput = resonancePositioningResultDigestInput;
|
|
2672
2929
|
exports.resonanceWebsiteVisitEventTime = resonanceWebsiteVisitEventTime;
|
|
2673
2930
|
exports.resonanceWebsiteVisitProfileDigestInput = resonanceWebsiteVisitProfileDigestInput;
|
|
2674
2931
|
exports.resonanceWebsiteVisitSetupDeliveryDigestInput = resonanceWebsiteVisitSetupDeliveryDigestInput;
|