@nextcommerce/campaigns-os 1.55.0 → 1.57.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 +64 -0
- package/CONTEXT.md +11 -0
- package/campaign-spec/README.md +15 -1
- package/campaign-spec/dist/checkout-flow.d.ts +90 -0
- package/campaign-spec/dist/checkout-flow.js +229 -0
- package/campaign-spec/dist/index.d.ts +1 -0
- package/campaign-spec/dist/index.js +6 -1
- package/campaign-spec/dist/normalize.d.ts +3 -2
- package/campaign-spec/dist/normalize.js +7 -5
- package/campaign-spec/dist/routing.d.ts +6 -3
- package/campaign-spec/dist/routing.js +6 -3
- package/campaign-spec/dist/rules/checkout-forward-target.d.ts +17 -0
- package/campaign-spec/dist/rules/checkout-forward-target.js +48 -0
- package/campaign-spec/dist/rules/checkout-step-reaches-checkout.d.ts +12 -0
- package/campaign-spec/dist/rules/checkout-step-reaches-checkout.js +37 -0
- package/campaign-spec/dist/rules/exit-intent-validation.js +2 -1
- package/campaign-spec/dist/rules/index.d.ts +4 -0
- package/campaign-spec/dist/rules/index.js +12 -0
- package/campaign-spec/dist/rules/one-checkout-per-path.d.ts +25 -0
- package/campaign-spec/dist/rules/one-checkout-per-path.js +84 -0
- package/campaign-spec/dist/rules/pre-payment-forward-target.d.ts +12 -0
- package/campaign-spec/dist/rules/pre-payment-forward-target.js +42 -0
- package/campaign-spec/dist/rules/promo-code-input-validation.js +2 -1
- package/campaign-spec/dist/rules/schema-version.d.ts +9 -4
- package/campaign-spec/dist/rules/schema-version.js +10 -5
- package/campaign-spec/dist/types.d.ts +20 -3
- package/campaign-spec/dist/types.js +3 -2
- package/compatibility.json +2 -2
- package/contracts/fixtures/runtime-recipe/accept/current.json +6 -1
- package/contracts/fixtures/runtime-recipe/accept/minimal.json +6 -1
- package/contracts/fixtures/runtime-recipe/dist-states.json +1 -1
- package/contracts/fixtures/runtime-recipe/reject/advisory-enforcement.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/allowlist-without-hosts.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/committed-output-claim.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/engines-disagreement-warns.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/lifecycle-scripts-enabled.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/missing-required-field.json +1 -1
- package/contracts/fixtures/runtime-recipe/reject/unknown-kind.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/unknown-network-policy.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/unknown-output-check.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/unknown-revision.json +5 -0
- package/contracts/fixtures/runtime-recipe/reject/unknown-step-id.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/unperformable-check-skipped.json +6 -1
- package/contracts/fixtures/runtime-recipe/reject/unpinned-lockfile.json +6 -1
- package/contracts/release-ledger.json +705 -0
- package/contracts/runtime-recipe.campaigns-os-node-v1.json +6 -1
- package/contracts/supported-surface.json +8 -4
- package/docs/build-packet.md +52 -8
- package/docs/local-setup.md +1 -1
- package/docs/orientation-contract-reference.md +1 -1
- package/docs/qa-and-test-orders.md +78 -18
- package/docs/runtime-readiness.md +8 -3
- package/docs/skills-revision.md +10 -10
- package/docs/supported-surface.md +1 -1
- package/docs/versioning.md +4 -1
- package/package.json +2 -1
- package/schemas/campaign-runtime-build-context.v0.schema.json +3 -1
- package/schemas/campaign-runtime-build-packet.v0.schema.json +3 -1
- package/schemas/campaign-spec.v5.schema.json +586 -0
- package/skills/campaign-lifecycle-orientation/SKILL.md +10 -8
- package/skills/campaign-readback-classification/SKILL.md +3 -3
- package/skills/campaign-run-evidence/SKILL.md +3 -3
- package/skills/contribution-intake/SKILL.md +3 -3
- package/skills/next-campaigns-build/SKILL.md +6 -4
- package/skills/next-campaigns-os/SKILL.md +3 -3
- package/skills/next-campaigns-os-setup/SKILL.md +3 -3
- package/skills/next-campaigns-polish/SKILL.md +21 -6
- package/skills/next-campaigns-qa/SKILL.md +4 -3
- package/skills.json +10 -10
- package/src/adapter-decision-contract.mjs +1 -1
- package/src/build-brief.mjs +14 -5
- package/src/cli-helpers.mjs +129 -0
- package/src/cli.mjs +121 -53
- package/src/commercial-journey.mjs +25 -2
- package/src/design-source-package.mjs +1 -1
- package/src/design-source-publication.mjs +7 -7
- package/src/doctor/checks.mjs +196 -13
- package/src/doctor/inspect.mjs +4 -2
- package/src/doctor/next-step.mjs +31 -11
- package/src/doctor-sidecar.mjs +5 -3
- package/src/gate-actions.mjs +21 -1
- package/src/input-refresh.mjs +6 -6
- package/src/local-preview-policy.mjs +110 -12
- package/src/polish-node.mjs +3 -3
- package/src/qa-browser.mjs +226 -34
- package/src/qa-cart-entry.mjs +78 -14
- package/src/qa-node.mjs +35 -33
- package/src/qa-test-order-topology.mjs +118 -1
- package/src/qa-verdict-discovery.mjs +21 -4
- package/src/runtime-state-ignore.mjs +7 -5
- package/src/source-html-intake.mjs +46 -4
- package/src/stage-ledger.mjs +4 -2
- package/src/stage-record.mjs +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Preview policy: one place that decides which missing evidence a preview
|
|
2
|
+
// carries forward as a warning instead of a blocker.
|
|
3
3
|
//
|
|
4
4
|
// The local preview is a packet whose deploy target is `local-serve`, served
|
|
5
5
|
// from a loopback host. There a campaign must still prove its commerce (store
|
|
@@ -8,16 +8,20 @@
|
|
|
8
8
|
// evidence is reported as missing, never as passed: a carried-forward gate is
|
|
9
9
|
// a warning in doctor, `next` does not stop on it, and QA records it as a
|
|
10
10
|
// `warn` row, so the verdict is at best `ready_with_exceptions`. A hosted
|
|
11
|
-
// preview
|
|
12
|
-
//
|
|
11
|
+
// preview carries forward only the all-template no-capturable-routes
|
|
12
|
+
// shape and the missing Polish report/evidence it owns. QA against the
|
|
13
|
+
// packet's production URL stays strict. Every other check keeps its meaning.
|
|
13
14
|
//
|
|
14
15
|
// Doctor and QA apply this to the gates they evaluate; `next` reads doctor's
|
|
15
16
|
// gates. Recording a stage (`record polish`) and the waiver commands keep the
|
|
16
17
|
// strict gates; `record deploy` follows next past a carried-forward polish.
|
|
17
18
|
import { isLocalServePacket } from "./local-proof.mjs";
|
|
18
19
|
import { isLoopbackHostname } from "./remit.mjs";
|
|
20
|
+
import { hostedTemplateQaAction, HOSTED_TEMPLATE_PREVIEW_URL_ACTION } from "./gate-actions.mjs";
|
|
21
|
+
import { normalizePublicRouteSlug } from "./route-identity.mjs";
|
|
19
22
|
|
|
20
23
|
export const LOCAL_PREVIEW_POLICY = "local_preview";
|
|
24
|
+
export const HOSTED_TEMPLATE_PREVIEW_POLICY = "hosted_template_preview";
|
|
21
25
|
export const CARRIED_FORWARD = "carried_forward";
|
|
22
26
|
|
|
23
27
|
// The checks carried forward, one by one. Each is evidence the campaign does
|
|
@@ -30,6 +34,9 @@ const CARRIED_POLISH_CODES = Object.freeze(new Set([
|
|
|
30
34
|
"polish.report_missing",
|
|
31
35
|
"polish.evidence_missing",
|
|
32
36
|
]));
|
|
37
|
+
export function polishGateCanCarryPreview(gate) {
|
|
38
|
+
return Boolean(gate?.owned_checkpoint_only || CARRIED_POLISH_CODES.has(gate?.code));
|
|
39
|
+
}
|
|
33
40
|
export const NO_CAPTURABLE_ROUTES_CODE = "polish.hidden_eager_media.no_capturable_routes";
|
|
34
41
|
const MISSING_CAPTURE_CODE = "polish.hidden_eager_media.capture_malformed";
|
|
35
42
|
|
|
@@ -53,21 +60,96 @@ export function isLocalPreview(packet, { baseUrl = null } = {}) {
|
|
|
53
60
|
&& loopbackOrAbsent(baseUrl);
|
|
54
61
|
}
|
|
55
62
|
|
|
63
|
+
function comparableUrl(value) {
|
|
64
|
+
try {
|
|
65
|
+
const url = new URL(String(value));
|
|
66
|
+
if (!/^https?:$/.test(url.protocol)) return null;
|
|
67
|
+
return `${url.origin}${url.pathname.replace(/\/+$/, "") || "/"}`;
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function ensureUrlTrailingSlash(value) {
|
|
74
|
+
try {
|
|
75
|
+
const url = new URL(value);
|
|
76
|
+
if (!url.pathname.endsWith("/")) url.pathname += "/";
|
|
77
|
+
return url.toString();
|
|
78
|
+
} catch {
|
|
79
|
+
return value.endsWith("/") ? value : `${value}/`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// QA composes a campaign slug onto a site root before testing it. Preview
|
|
84
|
+
// policy compares those same targets, ignoring only query and fragment.
|
|
85
|
+
export function normalizeQaBaseUrl(value, publicRouteSlug) {
|
|
86
|
+
const baseUrl = typeof value === "string" && value.trim() ? value.trim() : null;
|
|
87
|
+
if (!baseUrl) return null;
|
|
88
|
+
const slug = normalizePublicRouteSlug(publicRouteSlug);
|
|
89
|
+
if (!slug) return ensureUrlTrailingSlash(baseUrl);
|
|
90
|
+
try {
|
|
91
|
+
const url = new URL(ensureUrlTrailingSlash(baseUrl));
|
|
92
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
93
|
+
if (segments.at(-1) === slug) return ensureUrlTrailingSlash(url.toString());
|
|
94
|
+
return new URL(`${slug}/`, url).toString();
|
|
95
|
+
} catch {
|
|
96
|
+
return ensureUrlTrailingSlash(baseUrl);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function comparableQaTarget(value, packet) {
|
|
101
|
+
const slug = packet?.campaign?.public_route_slug || packet?.deploy?.live_url_path;
|
|
102
|
+
return comparableUrl(normalizeQaBaseUrl(value, slug));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function isHostedTemplatePreview(packet, { baseUrl = null } = {}) {
|
|
106
|
+
const preview = comparableQaTarget(packet?.deploy?.preview_url, packet);
|
|
107
|
+
const production = comparableQaTarget(packet?.deploy?.production_url, packet);
|
|
108
|
+
const tested = baseUrl == null ? preview : comparableQaTarget(baseUrl, packet);
|
|
109
|
+
return Boolean(packet?.deploy?.target && packet.deploy.target !== "local-serve"
|
|
110
|
+
&& preview && tested === preview && preview !== production
|
|
111
|
+
&& !isLoopbackHostname(new URL(preview).hostname));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function hostedTemplateNeedsUsablePreview(packet, gate) {
|
|
115
|
+
return gate?.code === NO_CAPTURABLE_ROUTES_CODE
|
|
116
|
+
&& packet?.deploy?.target && packet.deploy.target !== "local-serve"
|
|
117
|
+
&& !isHostedTemplatePreview(packet);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function hostedTemplateNeedsPreviewUrl(packet, gate) {
|
|
121
|
+
return gate?.code === NO_CAPTURABLE_ROUTES_CODE
|
|
122
|
+
&& packet?.deploy?.target && packet.deploy.target !== "local-serve"
|
|
123
|
+
&& !packet.deploy.preview_url;
|
|
124
|
+
}
|
|
125
|
+
|
|
56
126
|
function pageLoadRecorded(report) {
|
|
57
127
|
return report?.stages?.polish?.evidence?.visual_review?.page_load != null;
|
|
58
128
|
}
|
|
59
129
|
|
|
60
|
-
function carried(gate) {
|
|
130
|
+
export function carried(gate, policy = LOCAL_PREVIEW_POLICY, packet = null) {
|
|
131
|
+
const previewUrl = packet?.deploy?.preview_url;
|
|
132
|
+
if (policy === HOSTED_TEMPLATE_PREVIEW_POLICY && !comparableUrl(previewUrl)) return gate;
|
|
61
133
|
return {
|
|
62
134
|
...gate,
|
|
63
135
|
status: CARRIED_FORWARD,
|
|
64
|
-
|
|
136
|
+
...(policy === HOSTED_TEMPLATE_PREVIEW_POLICY
|
|
137
|
+
? { required_actions: [hostedTemplateQaAction(previewUrl)] }
|
|
138
|
+
: {}),
|
|
139
|
+
carried_forward: { policy, from_status: gate.status, evidence: "missing" },
|
|
65
140
|
};
|
|
66
141
|
}
|
|
67
142
|
|
|
68
143
|
// The hidden eager-media checkpoint, evaluated on its own.
|
|
69
144
|
export function applyLocalPreviewToCheckpoint(gate, { packet, report, baseUrl = null } = {}) {
|
|
70
|
-
if (gate?.status !== "blocked"
|
|
145
|
+
if (gate?.status !== "blocked") return gate;
|
|
146
|
+
if (hostedTemplateNeedsUsablePreview(packet, gate)) {
|
|
147
|
+
return { ...gate, required_actions: [HOSTED_TEMPLATE_PREVIEW_URL_ACTION] };
|
|
148
|
+
}
|
|
149
|
+
if (gate.code === NO_CAPTURABLE_ROUTES_CODE && isHostedTemplatePreview(packet, { baseUrl })) {
|
|
150
|
+
return carried(gate, HOSTED_TEMPLATE_PREVIEW_POLICY, packet);
|
|
151
|
+
}
|
|
152
|
+
if (!isLocalPreview(packet, { baseUrl })) return gate;
|
|
71
153
|
const missing = gate.code === NO_CAPTURABLE_ROUTES_CODE
|
|
72
154
|
|| (gate.code === MISSING_CAPTURE_CODE && !pageLoadRecorded(report));
|
|
73
155
|
return missing ? carried(gate) : gate;
|
|
@@ -82,11 +164,24 @@ export function polishCarriedForwardForLadder(report, gate) {
|
|
|
82
164
|
}
|
|
83
165
|
|
|
84
166
|
export function applyLocalPreviewToPolishGate(gate, { packet, checkpointGate = null, baseUrl = null } = {}) {
|
|
85
|
-
if (gate?.status !== "blocked"
|
|
167
|
+
if (gate?.status !== "blocked") return gate;
|
|
168
|
+
// A template-stock map has no route that capture can measure, even when
|
|
169
|
+
// the preview is strict. Do not keep an impossible recapture action.
|
|
170
|
+
const actionableGate = checkpointGate?.code === NO_CAPTURABLE_ROUTES_CODE
|
|
171
|
+
? { ...gate, required_actions: (gate.required_actions || []).filter((action) => action.id !== "polish.hidden_eager_media.capture") }
|
|
172
|
+
: gate;
|
|
173
|
+
if (polishGateCanCarryPreview(gate) && hostedTemplateNeedsUsablePreview(packet, checkpointGate)) {
|
|
174
|
+
return { ...actionableGate, required_actions: [HOSTED_TEMPLATE_PREVIEW_URL_ACTION] };
|
|
175
|
+
}
|
|
176
|
+
const hostedTemplate = checkpointGate?.code === NO_CAPTURABLE_ROUTES_CODE
|
|
177
|
+
&& checkpointGate?.carried_forward?.policy === HOSTED_TEMPLATE_PREVIEW_POLICY
|
|
178
|
+
&& isHostedTemplatePreview(packet, { baseUrl });
|
|
179
|
+
if (!hostedTemplate && !isLocalPreview(packet, { baseUrl })) return actionableGate;
|
|
86
180
|
const checkpointCarried = checkpointGate?.status === CARRIED_FORWARD;
|
|
87
|
-
if (gate.owned_checkpoint_status === "blocked" && !checkpointCarried) return
|
|
88
|
-
|
|
89
|
-
|
|
181
|
+
if (gate.owned_checkpoint_status === "blocked" && !checkpointCarried) return actionableGate;
|
|
182
|
+
const policy = hostedTemplate ? HOSTED_TEMPLATE_PREVIEW_POLICY : LOCAL_PREVIEW_POLICY;
|
|
183
|
+
if (gate.owned_checkpoint_only) return checkpointCarried ? carried(actionableGate, policy, packet) : actionableGate;
|
|
184
|
+
return CARRIED_POLISH_CODES.has(gate.code) ? carried(actionableGate, policy, packet) : actionableGate;
|
|
90
185
|
}
|
|
91
186
|
|
|
92
187
|
export function starterResidueIsExpected(themeGate, { packet, baseUrl = null } = {}) {
|
|
@@ -94,5 +189,8 @@ export function starterResidueIsExpected(themeGate, { packet, baseUrl = null } =
|
|
|
94
189
|
}
|
|
95
190
|
|
|
96
191
|
export function carriedForwardMessage(gate) {
|
|
97
|
-
|
|
192
|
+
if (gate?.carried_forward?.policy === HOSTED_TEMPLATE_PREVIEW_POLICY) {
|
|
193
|
+
return `Carried forward on the hosted preview: ${gate.reason} This evidence is missing, not passed; production QA still requires it.`;
|
|
194
|
+
}
|
|
195
|
+
return `Carried forward on the local preview: ${gate.reason} This evidence is missing, not passed; production QA still requires it.`;
|
|
98
196
|
}
|
package/src/polish-node.mjs
CHANGED
|
@@ -160,7 +160,7 @@ export function planPolishCapture({ packet, baseUrl } = {}) {
|
|
|
160
160
|
if (routes.length === 0) {
|
|
161
161
|
const error = new Error(
|
|
162
162
|
"polish capture has no mapped non-skipped routes to capture: every mapped page is template stock (skip_reason), so there is no design route to compare."
|
|
163
|
-
+ " On a local
|
|
163
|
+
+ " On a local or hosted preview, missing polish evidence is carried forward as a warning; run `next` for the next stage.",
|
|
164
164
|
);
|
|
165
165
|
error.code = NO_CAPTURABLE_ROUTES_ERROR;
|
|
166
166
|
throw error;
|
|
@@ -226,13 +226,13 @@ function recordedAuthorityBlock({ packet, report, plan = null, now } = {}) {
|
|
|
226
226
|
|
|
227
227
|
// Every mapped page is template stock: there is nothing for polish capture to
|
|
228
228
|
// measure, which is missing evidence rather than a malformed packet. It stays
|
|
229
|
-
// a non-waivable block; the
|
|
229
|
+
// a non-waivable block; the preview policy carries it forward.
|
|
230
230
|
function noCapturableRoutesBlock({ packet, report, now } = {}) {
|
|
231
231
|
const block = recordedAuthorityBlock({ packet, report, now });
|
|
232
232
|
return {
|
|
233
233
|
...block,
|
|
234
234
|
code: NO_CAPTURABLE_ROUTES_CODE,
|
|
235
|
-
reason: "Every mapped page is template stock (skip_reason), so
|
|
235
|
+
reason: "Every mapped page is template stock (skip_reason), so this build has no design route to compare and no page-load evidence.",
|
|
236
236
|
required_actions: [HIDDEN_EAGER_MEDIA_ACTIONS.map_design_route],
|
|
237
237
|
};
|
|
238
238
|
}
|