@sonordev/contracts 2.26.0 → 2.28.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 +14 -0
- package/README.md +82 -1
- 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/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 +364 -5
- package/dist/resonance.js +194 -13
- package/dist/resonance.mjs +179 -14
- 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 +17 -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
|
});
|
|
@@ -624,7 +641,7 @@ function checkReportingQuerySubset(v, p) {
|
|
|
624
641
|
if (v.metaQueries?.some((query) => !v.channelIds.some((id) => id.toLowerCase() === query.channelId.toLowerCase()))) fail2(p + ".metaQueries", "query channel must be selected");
|
|
625
642
|
}
|
|
626
643
|
var providerReportingSelection = refine2(object2({ agentContactId: uuid, channelIds: providerReportingChannelIds, metaQueries: optional2(providerReportingMetaQueries) }), checkReportingQuerySubset);
|
|
627
|
-
var providerReportingGrant = refine2(object2({ purpose: literal2("provider_reporting_refresh"), orgId: uuid, projectId: uuid, agentContactId: uuid, principalContactId: uuid, channelIds: providerReportingChannelIds, metaQueries: optional2(providerReportingMetaQueries) }), (v, p) => {
|
|
644
|
+
var providerReportingGrant = refine2(object2({ purpose: literal2("provider_reporting_refresh"), orgId: uuid, projectId: uuid, agentContactId: uuid, principalContactId: uuid, channelIds: providerReportingChannelIds, metaQueries: optional2(providerReportingMetaQueries), reportingUntil: optional2(instant) }), (v, p) => {
|
|
628
645
|
if (v.agentContactId.toLowerCase() === v.principalContactId.toLowerCase()) fail2(p + ".principalContactId", "agent and human principal must remain distinct");
|
|
629
646
|
checkReportingQuerySubset(v, p);
|
|
630
647
|
});
|
|
@@ -632,7 +649,94 @@ var parseResonanceProviderReportingSelection = (v) => providerReportingSelection
|
|
|
632
649
|
var parseResonanceProviderReportingGrant = (v) => providerReportingGrant.read(v, "providerReportingGrant");
|
|
633
650
|
var RESONANCE_PROVIDER_REPORTING_SELECTION_JSON_SCHEMA = providerReportingSelection.schema;
|
|
634
651
|
var RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA = providerReportingGrant.schema;
|
|
635
|
-
var
|
|
652
|
+
var RESONANCE_PROVIDER_REPORTING_MAX_TAIL_DAYS = 92;
|
|
653
|
+
var googleContentTarget = { channelId: uuid, adGroupLocalKey: text2(80), adLocalKey: text2(80) };
|
|
654
|
+
var normalizeResonanceGoogleCriterionText = (value) => value.trim().replace(/\s+/gu, " ").toLowerCase().normalize("NFC");
|
|
655
|
+
var googleCriterionText = text2(80, /^(?! +$)[^\x00-\x1f\x7f]+$/);
|
|
656
|
+
var googleExactText = text2(80, /^(?! +$)[^\x00-\x1f\x7f\\\[\]"]+$/);
|
|
657
|
+
var googleContentKeywords = (criterion) => refine2(list2(criterion, 20), (items, p) => {
|
|
658
|
+
const normalized = items.map(normalizeResonanceGoogleCriterionText);
|
|
659
|
+
if (normalized.some((value) => !value || value.length > 80)) fail2(p, "requires nonempty bounded criterion text");
|
|
660
|
+
unique(normalized, p);
|
|
661
|
+
items.splice(0, items.length, ...normalized.sort());
|
|
662
|
+
});
|
|
663
|
+
var rsaAsset = (length) => refine2(text2(length, /^[^\x00-\x1f\x7f]+$/), (asset, p) => {
|
|
664
|
+
if (!asset.trim() || asset.trim() !== asset) fail2(p, "requires trimmed, nonempty asset text");
|
|
665
|
+
});
|
|
666
|
+
var googleContentRsa = object2({
|
|
667
|
+
creativeRef: resource,
|
|
668
|
+
headlines: uniqueList(rsaAsset(30), 15, 3),
|
|
669
|
+
descriptions: uniqueList(rsaAsset(90), 4, 2)
|
|
670
|
+
});
|
|
671
|
+
var googleContentMaterial = {
|
|
672
|
+
negativeRemovals: googleContentKeywords(googleCriterionText),
|
|
673
|
+
exactAdditions: googleContentKeywords(googleExactText),
|
|
674
|
+
rsa: nullable2(googleContentRsa)
|
|
675
|
+
};
|
|
676
|
+
var googleContentEntry = refine2(object2({ ...googleContentTarget, ...googleContentMaterial }), (entry, p) => {
|
|
677
|
+
if (!entry.negativeRemovals.length && !entry.exactAdditions.length && !entry.rsa) fail2(p, "must select at least one bounded content effect");
|
|
678
|
+
});
|
|
679
|
+
var googleSearchContent = refine2(list2(googleContentEntry, 100), (entries, p) => {
|
|
680
|
+
const identity = (entry) => JSON.stringify([entry.channelId.toLowerCase(), entry.adGroupLocalKey, entry.adLocalKey]);
|
|
681
|
+
unique(entries.map(identity), p);
|
|
682
|
+
entries.sort((a, b) => identity(a) < identity(b) ? -1 : identity(a) > identity(b) ? 1 : 0);
|
|
683
|
+
});
|
|
684
|
+
var operatingPolicyFields = {
|
|
685
|
+
schemaVersion: literal2(1),
|
|
686
|
+
agentContactId: uuid,
|
|
687
|
+
googleSearchContent,
|
|
688
|
+
cooldownSeconds: integer2(3600, 2592e3)
|
|
689
|
+
};
|
|
690
|
+
var operatingPolicySelection = object2(operatingPolicyFields);
|
|
691
|
+
var operatingPolicy = refine2(object2({ ...operatingPolicyFields, principalContactId: uuid }), (policy, p) => {
|
|
692
|
+
if (policy.agentContactId.toLowerCase() === policy.principalContactId.toLowerCase()) {
|
|
693
|
+
fail2(p + ".principalContactId", "agent and human principal must remain distinct");
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
var operatingPolicyRef = object2({ ledgerActionId: uuid, receiptId: uuid, digest });
|
|
697
|
+
var operatingPolicyBase = object2({
|
|
698
|
+
ledgerActionId: uuid,
|
|
699
|
+
acceptanceReceiptId: uuid,
|
|
700
|
+
expectedKillRevision: integer2(0),
|
|
701
|
+
previousOperatingPolicyRef: nullable2(operatingPolicyRef)
|
|
702
|
+
});
|
|
703
|
+
var operatingPolicyActionIdentity = object2({ mandateDigest: digest, operatingPolicyBase });
|
|
704
|
+
var googleContentUpdateSelection = object2(googleContentTarget);
|
|
705
|
+
var googleContentUpdate = refine2(object2({ ...googleContentTarget, ...googleContentMaterial, policyRef: operatingPolicyRef, beforeDigest: digest }), (update2, p) => {
|
|
706
|
+
if (!update2.negativeRemovals.length && !update2.exactAdditions.length && !update2.rsa) fail2(p, "must select at least one bounded content effect");
|
|
707
|
+
});
|
|
708
|
+
var parseResonanceOperatingPolicy = (v) => operatingPolicy.read(v, "operatingPolicy");
|
|
709
|
+
var parseResonanceOperatingPolicySelection = (v) => operatingPolicySelection.read(v, "operatingPolicySelection");
|
|
710
|
+
var parseResonanceOperatingPolicyBase = (v) => operatingPolicyBase.read(v, "operatingPolicyBase");
|
|
711
|
+
var parseResonanceOperatingPolicyRef = (v) => operatingPolicyRef.read(v, "operatingPolicyRef");
|
|
712
|
+
var parseResonanceGoogleContentUpdateSelection = (v) => googleContentUpdateSelection.read(v, "googleContentUpdateSelection");
|
|
713
|
+
var parseResonanceGoogleContentUpdate = (v) => googleContentUpdate.read(v, "googleContentUpdate");
|
|
714
|
+
var resonanceOperatingPolicyDigestInput = (v) => canonical(parseResonanceOperatingPolicy(v));
|
|
715
|
+
function resonanceOperatingPolicyActionDigestInput(v) {
|
|
716
|
+
const { mandateDigest, operatingPolicyBase: base } = operatingPolicyActionIdentity.read(v, "operatingPolicyActionIdentity");
|
|
717
|
+
const previous = base.previousOperatingPolicyRef;
|
|
718
|
+
return canonical({
|
|
719
|
+
kind: "resonance_operating_policy_activation_v1",
|
|
720
|
+
mandateDigest,
|
|
721
|
+
operatingPolicyBase: {
|
|
722
|
+
...base,
|
|
723
|
+
ledgerActionId: base.ledgerActionId.toLowerCase(),
|
|
724
|
+
acceptanceReceiptId: base.acceptanceReceiptId.toLowerCase(),
|
|
725
|
+
previousOperatingPolicyRef: previous && {
|
|
726
|
+
...previous,
|
|
727
|
+
ledgerActionId: previous.ledgerActionId.toLowerCase(),
|
|
728
|
+
receiptId: previous.receiptId.toLowerCase()
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
var RESONANCE_OPERATING_POLICY_JSON_SCHEMA = operatingPolicy.schema;
|
|
734
|
+
var RESONANCE_OPERATING_POLICY_SELECTION_JSON_SCHEMA = operatingPolicySelection.schema;
|
|
735
|
+
var RESONANCE_OPERATING_POLICY_BASE_JSON_SCHEMA = operatingPolicyBase.schema;
|
|
736
|
+
var RESONANCE_OPERATING_POLICY_REF_JSON_SCHEMA = operatingPolicyRef.schema;
|
|
737
|
+
var RESONANCE_GOOGLE_CONTENT_UPDATE_SELECTION_JSON_SCHEMA = googleContentUpdateSelection.schema;
|
|
738
|
+
var RESONANCE_GOOGLE_CONTENT_UPDATE_JSON_SCHEMA = googleContentUpdate.schema;
|
|
739
|
+
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) });
|
|
636
740
|
function parseResonanceMandateScope(v, preparedPlan) {
|
|
637
741
|
const r = mandateScope.read(v, "mandateScope");
|
|
638
742
|
scoped(r, r.projectId, r.sites, "mandateScope");
|
|
@@ -640,10 +744,36 @@ function parseResonanceMandateScope(v, preparedPlan) {
|
|
|
640
744
|
unique(r.websiteVisitFeed.channels.map((c) => c.channelId), "mandateScope.websiteVisitFeed.channels");
|
|
641
745
|
for (const c of r.websiteVisitFeed.channels) unique(c.resourceRuleRefs.map((rule) => rule.id), "mandateScope.websiteVisitFeed.resourceRuleRefs");
|
|
642
746
|
}
|
|
747
|
+
if (r.operatingPolicy) {
|
|
748
|
+
const p = "mandateScope.operatingPolicy";
|
|
749
|
+
if (Date.parse(r.expiresAt) <= Date.parse(r.budget.startAt) || Date.parse(r.expiresAt) > Date.parse(r.budget.endAt)) {
|
|
750
|
+
fail2(p, "operating policy remains inside the original mandate flight and expiry");
|
|
751
|
+
}
|
|
752
|
+
if (r.operatingPolicy.googleSearchContent.length && !r.allowedOperations.includes("update")) {
|
|
753
|
+
fail2(p, "Google content requires the update operation");
|
|
754
|
+
}
|
|
755
|
+
if (preparedPlan !== void 0) {
|
|
756
|
+
const plan = parseResonancePreparedPlan(preparedPlan);
|
|
757
|
+
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)) fail2(p, "requires the exact original plan, review, goal and flight");
|
|
758
|
+
for (const entry of r.operatingPolicy.googleSearchContent) {
|
|
759
|
+
const channel2 = plan.definition.channels.find((item) => item.id.toLowerCase() === entry.channelId.toLowerCase());
|
|
760
|
+
if (channel2?.kind !== "google_search") return fail2(p, "requires an original Google Search channel");
|
|
761
|
+
const group = channel2.adGroups.find((item) => item.localKey === entry.adGroupLocalKey);
|
|
762
|
+
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) fail2(p, "requires the original account, site, ad group and ad");
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
643
766
|
if (r.providerReporting) {
|
|
644
767
|
const grant = r.providerReporting, p = "mandateScope.providerReporting";
|
|
645
768
|
if (grant.projectId !== r.projectId) fail2(p + ".projectId", "must match the original mandate project");
|
|
646
|
-
|
|
769
|
+
const flightEnd = Date.parse(r.budget.endAt);
|
|
770
|
+
if (Date.parse(r.expiresAt) <= Date.parse(r.budget.startAt) || Date.parse(r.expiresAt) > flightEnd) fail2(p, "mandate expiry remains inside the original flight");
|
|
771
|
+
if (grant.reportingUntil !== void 0) {
|
|
772
|
+
const deadline = Date.parse(grant.reportingUntil);
|
|
773
|
+
if (deadline <= flightEnd || deadline > flightEnd + RESONANCE_PROVIDER_REPORTING_MAX_TAIL_DAYS * 864e5) {
|
|
774
|
+
fail2(p + ".reportingUntil", "must follow the original flight by no more than 92 elapsed days");
|
|
775
|
+
}
|
|
776
|
+
}
|
|
647
777
|
if (preparedPlan !== void 0) {
|
|
648
778
|
const plan = parseResonancePreparedPlan(preparedPlan);
|
|
649
779
|
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)) fail2(p, "requires the exact original plan, review, goal and flight");
|
|
@@ -818,6 +948,10 @@ var RESONANCE_GOOGLE_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA = googleConfigurati
|
|
|
818
948
|
var preparedManifestRef = object2({ id: uuid, digest, providerVersion: text2(30), revision });
|
|
819
949
|
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
950
|
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) });
|
|
951
|
+
function bookingTypesMatch(goalIds, witnessIds) {
|
|
952
|
+
const norm = (ids) => ids === void 0 ? null : [...ids].map((id) => id.toLowerCase()).sort();
|
|
953
|
+
return canonical(norm(goalIds)) === canonical(norm(witnessIds));
|
|
954
|
+
}
|
|
821
955
|
function parseResonancePreparedPlan(v) {
|
|
822
956
|
const r = prepared.read(v, "preparedPlan");
|
|
823
957
|
checkDefinition(r.definition);
|
|
@@ -827,7 +961,7 @@ function parseResonancePreparedPlan(v) {
|
|
|
827
961
|
if (goal.source.kind === "qualified_lead") {
|
|
828
962
|
if (!goal.qualificationRule || !goal.qualificationRuleRef || !witness) fail2("preparedPlan.resolvedQualificationRule", "qualified-lead preparation requires actual configured native witness");
|
|
829
963
|
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");
|
|
964
|
+
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
965
|
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
966
|
} else if (witness !== null) fail2("preparedPlan.resolvedQualificationRule", "nonqualified objectives require explicit null");
|
|
833
967
|
if (canonical(r.resolvedEvidencePolicy) !== canonical(r.definition.optimization.policy)) fail2("preparedPlan.resolvedEvidencePolicy", "policy snapshot mismatch");
|
|
@@ -865,15 +999,43 @@ function parseResonancePreparedPlan(v) {
|
|
|
865
999
|
}
|
|
866
1000
|
var commandBase = { schemaVersion: literal2(1), campaignId: uuid, expectedRevision: integer2(1), idempotencyKey: operationKey, channelIds: list2(uuid, 100) };
|
|
867
1001
|
var effect = object2({ ...commandBase, operation: choice2("launch", "update", "resume"), preparedPlanId: uuid, reviewDigest: digest, mandateRef, expectedRemoteSnapshots: list2(object2({ channelId: uuid, digest }), 100) });
|
|
1002
|
+
var googleContentEffect = refine2(object2({
|
|
1003
|
+
...commandBase,
|
|
1004
|
+
operation: literal2("update"),
|
|
1005
|
+
preparedPlanId: uuid,
|
|
1006
|
+
reviewDigest: digest,
|
|
1007
|
+
mandateRef,
|
|
1008
|
+
channelIds: list2(uuid, 1, 1),
|
|
1009
|
+
expectedRemoteSnapshots: list2(object2({ channelId: uuid, digest }), 1, 1),
|
|
1010
|
+
googleContentUpdate
|
|
1011
|
+
}), (command2, p) => {
|
|
1012
|
+
const update2 = command2.googleContentUpdate, remote = command2.expectedRemoteSnapshots[0];
|
|
1013
|
+
if (command2.channelIds[0] !== update2.channelId || remote.channelId !== update2.channelId || remote.digest !== update2.beforeDigest) {
|
|
1014
|
+
fail2(p + ".googleContentUpdate", "requires the same single channel and before snapshot");
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
868
1017
|
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) });
|
|
869
1018
|
var safety = object2({ ...commandBase, operation: choice2("pause", "finish", "reconcile") });
|
|
870
1019
|
var deliverConversion = object2({ ...commandBase, operation: literal2("deliver_conversion"), channelIds: list2(uuid, 1, 1), preparedPlanId: uuid, reviewDigest: digest, mandateRef, conversionId: uuid });
|
|
871
1020
|
var deliverWebsiteVisit = object2({ ...commandBase, operation: literal2("deliver_website_visit"), channelIds: list2(uuid, 1, 1), preparedPlanId: uuid, reviewDigest: digest, mandateRef, occurrenceId: uuid });
|
|
872
|
-
var command = union2(effect, optimize, safety, deliverConversion, deliverWebsiteVisit);
|
|
1021
|
+
var command = union2(effect, googleContentEffect, optimize, safety, deliverConversion, deliverWebsiteVisit);
|
|
873
1022
|
function parseResonanceCommand(v, context) {
|
|
874
1023
|
const r = command.read(v, "command");
|
|
875
1024
|
unique(r.channelIds, "command.channelIds");
|
|
876
1025
|
if ("mandateRef" in r && (r.mandateRef.campaignId !== r.campaignId || r.mandateRef.preparedPlanId !== r.preparedPlanId || r.mandateRef.reviewDigest !== r.reviewDigest)) fail2("command.mandateRef", "snapshot mismatch");
|
|
1026
|
+
if ("googleContentUpdate" in r && context) {
|
|
1027
|
+
const p = "command.googleContentUpdate", update2 = r.googleContentUpdate;
|
|
1028
|
+
const plan = parseResonancePreparedPlan(context.preparedPlan);
|
|
1029
|
+
const grant = parseResonanceMandateScope(context.mandate, plan);
|
|
1030
|
+
const now = Date.parse(instant.read(context.now, "command.context.now"));
|
|
1031
|
+
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)) {
|
|
1032
|
+
fail2(p, "requires the current original Google mandate and flight");
|
|
1033
|
+
}
|
|
1034
|
+
const channel2 = plan.definition.channels.find((item) => item.id === update2.channelId);
|
|
1035
|
+
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))) {
|
|
1036
|
+
fail2(p, "requires an original Google Search group and ad in scope");
|
|
1037
|
+
} else if (update2.rsa) scoped(update2.rsa, plan.projectId, [channel2.site], p + ".rsa");
|
|
1038
|
+
}
|
|
877
1039
|
if ((r.operation === "deliver_conversion" || r.operation === "deliver_website_visit") && context) {
|
|
878
1040
|
const plan = parseResonancePreparedPlan(context.preparedPlan), grant = parseResonanceMandateScope(context.mandate);
|
|
879
1041
|
const now = Date.parse(instant.read(context.now, "command.context.now"));
|
|
@@ -886,7 +1048,7 @@ function parseResonanceCommand(v, context) {
|
|
|
886
1048
|
if (!channel2 || channel2.kind !== "google_search") fail2("command.channelIds", "requires one original Google channel");
|
|
887
1049
|
const c = channel2;
|
|
888
1050
|
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");
|
|
1051
|
+
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
1052
|
const account = plan.accounts.find((a) => a.id === c.accountBindingId);
|
|
891
1053
|
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
1054
|
const configuration = plan.channelPreviews.find((p) => p.channelId === c.id)?.googleConfiguration;
|
|
@@ -968,13 +1130,16 @@ var RESONANCE_METRIC_JSON_SCHEMA = metric.schema;
|
|
|
968
1130
|
var RESONANCE_CONSENT_JSON_SCHEMA = consent.schema;
|
|
969
1131
|
var parseResonanceExperimentExposure = (v) => exposure.read(v, "exposure");
|
|
970
1132
|
var mandateTarget = object2({ project_id: uuid, campaign_id: uuid });
|
|
971
|
-
var mandateApproval = object2({ schemaVersion: literal2(1), expectedRevision: integer2(1), preparedPlanId: uuid, reviewDigest: digest, mandateDigest: digest, mandate: mandateScope });
|
|
1133
|
+
var mandateApproval = object2({ schemaVersion: literal2(1), expectedRevision: integer2(1), preparedPlanId: uuid, reviewDigest: digest, mandateDigest: digest, mandate: mandateScope, operatingPolicyBase: optional2(operatingPolicyBase) });
|
|
972
1134
|
var RESONANCE_MANDATE_APPROVAL_JSON_SCHEMA = mandateApproval.schema;
|
|
973
1135
|
var RESONANCE_MANDATE_TARGET_JSON_SCHEMA = mandateTarget.schema;
|
|
974
1136
|
var RESONANCE_MANDATE_ACTION_KIND = "resonance_mandate";
|
|
975
1137
|
function parseResonanceMandateApprovalPayload(v, target) {
|
|
976
1138
|
const r = mandateApproval.read(v, "mandateApproval"), t = mandateTarget.read(target, "target_ref");
|
|
977
1139
|
parseResonanceMandateScope(r.mandate);
|
|
1140
|
+
if (r.operatingPolicyBase && !r.mandate.operatingPolicy && !r.mandate.providerReporting) {
|
|
1141
|
+
fail2("mandateApproval.operatingPolicyBase", "requires explicit prospective operating or reporting scope");
|
|
1142
|
+
}
|
|
978
1143
|
if (r.mandate.projectId !== t.project_id || r.mandate.campaignId !== t.campaign_id || r.preparedPlanId !== r.mandate.preparedPlanId || r.reviewDigest !== r.mandate.reviewDigest) fail2("mandateApproval", "target or snapshot mismatch");
|
|
979
1144
|
return r;
|
|
980
1145
|
}
|
|
@@ -1204,7 +1369,7 @@ function parseResonancePositioningConsistencyAssessment(value, expected) {
|
|
|
1204
1369
|
return assessment;
|
|
1205
1370
|
}
|
|
1206
1371
|
var RESONANCE_POSITIONING_CONSISTENCY_ASSESSMENT_JSON_SCHEMA = positioningConsistencyAssessment.schema;
|
|
1207
|
-
var prepareCommand = object2({ expectedRevision: integer2(1), idempotencyKey: operationKey });
|
|
1372
|
+
var prepareCommand = object2({ expectedRevision: integer2(1), idempotencyKey: operationKey, googleContentUpdate: optional2(googleContentUpdateSelection) });
|
|
1208
1373
|
var parseResonancePrepareCommand = (v) => prepareCommand.read(v, "prepare");
|
|
1209
1374
|
var parseResonanceCommandPrepareRequest = parseResonancePrepareCommand;
|
|
1210
1375
|
var commandPreparation = object2({ command: nullable2(command), covered: bool, approvalRequirement: nullable2(choice2("existing_mandate", "current_owner")), reasonCodes: list2(text2(200), 100) });
|
|
@@ -2356,7 +2521,7 @@ var feedSelection = refine2(object2({ channels: list2(object2({ channelId: uuid,
|
|
|
2356
2521
|
unique(v.channels.map((c) => c.channelId), p + ".channels");
|
|
2357
2522
|
for (const c of v.channels) unique(c.resourceRuleRefs.map((ref) => ref.id), p + ".resourceRuleRefs");
|
|
2358
2523
|
});
|
|
2359
|
-
var mandateDraftRequest = object2({ expectedRevision: integer2(1), allowedOperations: mandateAllowedOperations, expiresAt: instant, websiteVisitFeedSelection: optional2(feedSelection), providerReporting: optional2(providerReportingSelection) });
|
|
2524
|
+
var mandateDraftRequest = object2({ expectedRevision: integer2(1), allowedOperations: mandateAllowedOperations, expiresAt: instant, websiteVisitFeedSelection: optional2(feedSelection), providerReporting: optional2(providerReportingSelection), operatingPolicySelection: optional2(operatingPolicySelection), activation: optional2(literal2("operating_policy")) });
|
|
2360
2525
|
var parseResonanceMandateDraftRequest = (v) => mandateDraftRequest.read(v, "mandateDraftRequest");
|
|
2361
2526
|
var RESONANCE_MANDATE_DRAFT_REQUEST_JSON_SCHEMA = mandateDraftRequest.schema;
|
|
2362
2527
|
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(text2(200), 100) }) });
|
|
@@ -2703,6 +2868,8 @@ exports.RESONANCE_GOOGLE_CONFIGURATION_SAVE_COMMAND_JSON_SCHEMA = RESONANCE_GOOG
|
|
|
2703
2868
|
exports.RESONANCE_GOOGLE_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA = RESONANCE_GOOGLE_CONFIGURATION_SAVE_RESPONSE_JSON_SCHEMA;
|
|
2704
2869
|
exports.RESONANCE_GOOGLE_CONFIGURATION_SNAPSHOT_JSON_SCHEMA = RESONANCE_GOOGLE_CONFIGURATION_SNAPSHOT_JSON_SCHEMA;
|
|
2705
2870
|
exports.RESONANCE_GOOGLE_CONFIGURATION_VIEW_JSON_SCHEMA = RESONANCE_GOOGLE_CONFIGURATION_VIEW_JSON_SCHEMA;
|
|
2871
|
+
exports.RESONANCE_GOOGLE_CONTENT_UPDATE_JSON_SCHEMA = RESONANCE_GOOGLE_CONTENT_UPDATE_JSON_SCHEMA;
|
|
2872
|
+
exports.RESONANCE_GOOGLE_CONTENT_UPDATE_SELECTION_JSON_SCHEMA = RESONANCE_GOOGLE_CONTENT_UPDATE_SELECTION_JSON_SCHEMA;
|
|
2706
2873
|
exports.RESONANCE_GOOGLE_SETUP_SPEC_JSON_SCHEMA = RESONANCE_GOOGLE_SETUP_SPEC_JSON_SCHEMA;
|
|
2707
2874
|
exports.RESONANCE_GOOGLE_SIGNAL_SEMANTICS = RESONANCE_GOOGLE_SIGNAL_SEMANTICS;
|
|
2708
2875
|
exports.RESONANCE_GOOGLE_SOURCE_CATEGORIES = RESONANCE_GOOGLE_SOURCE_CATEGORIES;
|
|
@@ -2743,6 +2910,10 @@ exports.RESONANCE_METRIC_JSON_SCHEMA = RESONANCE_METRIC_JSON_SCHEMA;
|
|
|
2743
2910
|
exports.RESONANCE_OBSERVATIONS_PAGE_JSON_SCHEMA = RESONANCE_OBSERVATIONS_PAGE_JSON_SCHEMA;
|
|
2744
2911
|
exports.RESONANCE_OBSERVATION_SUPPORT_JSON_SCHEMA = RESONANCE_OBSERVATION_SUPPORT_JSON_SCHEMA;
|
|
2745
2912
|
exports.RESONANCE_OCCURRENCE_RESPONSE_JSON_SCHEMA = RESONANCE_OCCURRENCE_RESPONSE_JSON_SCHEMA;
|
|
2913
|
+
exports.RESONANCE_OPERATING_POLICY_BASE_JSON_SCHEMA = RESONANCE_OPERATING_POLICY_BASE_JSON_SCHEMA;
|
|
2914
|
+
exports.RESONANCE_OPERATING_POLICY_JSON_SCHEMA = RESONANCE_OPERATING_POLICY_JSON_SCHEMA;
|
|
2915
|
+
exports.RESONANCE_OPERATING_POLICY_REF_JSON_SCHEMA = RESONANCE_OPERATING_POLICY_REF_JSON_SCHEMA;
|
|
2916
|
+
exports.RESONANCE_OPERATING_POLICY_SELECTION_JSON_SCHEMA = RESONANCE_OPERATING_POLICY_SELECTION_JSON_SCHEMA;
|
|
2746
2917
|
exports.RESONANCE_OPTIMIZATION_DECISION_JSON_SCHEMA = RESONANCE_OPTIMIZATION_DECISION_JSON_SCHEMA;
|
|
2747
2918
|
exports.RESONANCE_OPTIMIZATION_EVIDENCE_JSON_SCHEMA = RESONANCE_OPTIMIZATION_EVIDENCE_JSON_SCHEMA;
|
|
2748
2919
|
exports.RESONANCE_OPTIMIZATION_POLICY_JSON_SCHEMA = RESONANCE_OPTIMIZATION_POLICY_JSON_SCHEMA;
|
|
@@ -2756,6 +2927,7 @@ exports.RESONANCE_POSITIONING_RESULT_JSON_SCHEMA = RESONANCE_POSITIONING_RESULT_
|
|
|
2756
2927
|
exports.RESONANCE_PREPARED_PLAN_JSON_SCHEMA = RESONANCE_PREPARED_PLAN_JSON_SCHEMA;
|
|
2757
2928
|
exports.RESONANCE_PROVIDER_METRIC_NAMES = RESONANCE_PROVIDER_METRIC_NAMES;
|
|
2758
2929
|
exports.RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA = RESONANCE_PROVIDER_REPORTING_GRANT_JSON_SCHEMA;
|
|
2930
|
+
exports.RESONANCE_PROVIDER_REPORTING_MAX_TAIL_DAYS = RESONANCE_PROVIDER_REPORTING_MAX_TAIL_DAYS;
|
|
2759
2931
|
exports.RESONANCE_PROVIDER_REPORTING_SELECTION_JSON_SCHEMA = RESONANCE_PROVIDER_REPORTING_SELECTION_JSON_SCHEMA;
|
|
2760
2932
|
exports.RESONANCE_PUBLIC_OBSERVATION_METRIC_JSON_SCHEMA = RESONANCE_PUBLIC_OBSERVATION_METRIC_JSON_SCHEMA;
|
|
2761
2933
|
exports.RESONANCE_QUALIFICATION_RULE_JSON_SCHEMA = RESONANCE_QUALIFICATION_RULE_JSON_SCHEMA;
|
|
@@ -2789,6 +2961,7 @@ exports.googleUploadClicksSetupSemantics = googleUploadClicksSetupSemantics;
|
|
|
2789
2961
|
exports.metaExclusionPolicy = metaExclusionPolicy;
|
|
2790
2962
|
exports.moneyFromProviderUnits = moneyFromProviderUnits;
|
|
2791
2963
|
exports.moneyToProviderUnits = moneyToProviderUnits;
|
|
2964
|
+
exports.normalizeResonanceGoogleCriterionText = normalizeResonanceGoogleCriterionText;
|
|
2792
2965
|
exports.parseMoney = parseMoney;
|
|
2793
2966
|
exports.parseResonanceAcceptCommand = parseResonanceAcceptCommand;
|
|
2794
2967
|
exports.parseResonanceAccountCapability = parseResonanceAccountCapability;
|
|
@@ -2819,6 +2992,8 @@ exports.parseResonanceGoogleConfigurationSaveCommand = parseResonanceGoogleConfi
|
|
|
2819
2992
|
exports.parseResonanceGoogleConfigurationSaveResponse = parseResonanceGoogleConfigurationSaveResponse;
|
|
2820
2993
|
exports.parseResonanceGoogleConfigurationSnapshot = parseResonanceGoogleConfigurationSnapshot;
|
|
2821
2994
|
exports.parseResonanceGoogleConfigurationView = parseResonanceGoogleConfigurationView;
|
|
2995
|
+
exports.parseResonanceGoogleContentUpdate = parseResonanceGoogleContentUpdate;
|
|
2996
|
+
exports.parseResonanceGoogleContentUpdateSelection = parseResonanceGoogleContentUpdateSelection;
|
|
2822
2997
|
exports.parseResonanceGoogleUploadClicksCustomGoalSpec = parseResonanceGoogleUploadClicksCustomGoalSpec;
|
|
2823
2998
|
exports.parseResonanceMandateApprovalPayload = parseResonanceMandateApprovalPayload;
|
|
2824
2999
|
exports.parseResonanceMandateDraftRequest = parseResonanceMandateDraftRequest;
|
|
@@ -2854,6 +3029,10 @@ exports.parseResonanceMetricObservation = parseResonanceMetricObservation;
|
|
|
2854
3029
|
exports.parseResonanceObservationSupport = parseResonanceObservationSupport;
|
|
2855
3030
|
exports.parseResonanceObservationsPage = parseResonanceObservationsPage;
|
|
2856
3031
|
exports.parseResonanceOccurrenceResponse = parseResonanceOccurrenceResponse;
|
|
3032
|
+
exports.parseResonanceOperatingPolicy = parseResonanceOperatingPolicy;
|
|
3033
|
+
exports.parseResonanceOperatingPolicyBase = parseResonanceOperatingPolicyBase;
|
|
3034
|
+
exports.parseResonanceOperatingPolicyRef = parseResonanceOperatingPolicyRef;
|
|
3035
|
+
exports.parseResonanceOperatingPolicySelection = parseResonanceOperatingPolicySelection;
|
|
2857
3036
|
exports.parseResonanceOptimizationDecision = parseResonanceOptimizationDecision;
|
|
2858
3037
|
exports.parseResonanceOptimizationEvidence = parseResonanceOptimizationEvidence;
|
|
2859
3038
|
exports.parseResonanceOptimizationPolicy = parseResonanceOptimizationPolicy;
|
|
@@ -2897,6 +3076,8 @@ exports.resonanceMetaAudienceSetupReceiptDigestInput = resonanceMetaAudienceSetu
|
|
|
2897
3076
|
exports.resonanceMetaConfigurationDigestInput = resonanceMetaConfigurationDigestInput;
|
|
2898
3077
|
exports.resonanceMetaConfigurationSaveDigestInput = resonanceMetaConfigurationSaveDigestInput;
|
|
2899
3078
|
exports.resonanceMetaDatasetSetupDigestInput = resonanceMetaDatasetSetupDigestInput;
|
|
3079
|
+
exports.resonanceOperatingPolicyActionDigestInput = resonanceOperatingPolicyActionDigestInput;
|
|
3080
|
+
exports.resonanceOperatingPolicyDigestInput = resonanceOperatingPolicyDigestInput;
|
|
2900
3081
|
exports.resonanceOptimizationDecisionDigestInput = resonanceOptimizationDecisionDigestInput;
|
|
2901
3082
|
exports.resonanceOptimizationEvidenceDigestInput = resonanceOptimizationEvidenceDigestInput;
|
|
2902
3083
|
exports.resonanceOptimizationPolicyDigestInput = resonanceOptimizationPolicyDigestInput;
|