@wix/agent-skills 1.33.0 → 1.34.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/README.md +23 -0
- package/package.json +2 -2
- package/skills/wix-app/references/DASHBOARD_PAGE.md +1 -1
- package/skills/wix-export/SKILL.md +83 -0
- package/skills/wix-harmony-editor/.publish-manifest.json +8 -0
- package/skills/wix-harmony-editor/COPY-SITE.md +494 -0
- package/skills/wix-harmony-editor/SKILL.md +317 -0
- package/skills/wix-harmony-editor/scripts/copy/build-description.mjs +249 -0
- package/skills/wix-harmony-editor/scripts/copy/check-description.mjs +225 -0
- package/skills/wix-harmony-editor/scripts/copy/check-mirror.mjs +89 -0
- package/skills/wix-harmony-editor/scripts/copy/compare-preview.mjs +76 -0
- package/skills/wix-harmony-editor/scripts/copy/deploy-description.mjs +212 -0
- package/skills/wix-harmony-editor/scripts/copy/desc-hash.mjs +44 -0
- package/skills/wix-harmony-editor/scripts/copy/editor-run.mjs +45 -0
- package/skills/wix-harmony-editor/scripts/copy/export-page.mjs +53 -0
- package/skills/wix-harmony-editor/scripts/copy/find-interactions.mjs +76 -0
- package/skills/wix-harmony-editor/scripts/copy/hide-scrollbars.mjs +16 -0
- package/skills/wix-harmony-editor/scripts/copy/import-media.mjs +150 -0
- package/skills/wix-harmony-editor/scripts/copy/link-url.mjs +27 -0
- package/skills/wix-harmony-editor/scripts/copy/lint-api.mjs +56 -0
- package/skills/wix-harmony-editor/scripts/copy/measure-source.mjs +211 -0
- package/skills/wix-harmony-editor/scripts/copy/merge-mirrors.mjs +29 -0
- package/skills/wix-harmony-editor/scripts/copy/mirror-site.mjs +92 -0
- package/skills/wix-harmony-editor/scripts/copy/mobile-stage.mjs +56 -0
- package/skills/wix-harmony-editor/scripts/copy/preview-widths.mjs +73 -0
- package/skills/wix-harmony-editor/scripts/copy/render-plate.mjs +67 -0
- package/skills/wix-harmony-editor/scripts/copy/serve-mirror.mjs +102 -0
- package/skills/wix-harmony-editor/scripts/copy/snapshot-capabilities.mjs +40 -0
- package/skills/wix-harmony-editor/scripts/copy/split-sections.mjs +191 -0
- package/skills/wix-harmony-editor/scripts/copy/upload-media-manager.mjs +61 -0
- package/skills/wix-harmony-editor/scripts/launch.sh +359 -0
- package/skills/wix-headless/SKILL.md +7 -2
- package/skills/wix-headless/references/CAPABILITIES.md +6 -1
- package/skills/wix-headless/references/DISCOVERY.md +2 -1
- package/skills/wix-headless/references/SDK_HANDOFF.md +6 -1
- package/skills/wix-headless/references/SEED.md +3 -2
- package/skills/wix-headless/references/SETUP.md +1 -0
- package/skills/wix-headless/references/inline-recipes/experience-donations.md +102 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-donations.md +146 -0
- package/skills/wix-headless/references/inline-recipes/setup-donations.md +15 -0
- package/skills/wix-headless/references/managed/CREATE.md +1 -1
- package/skills/wix-headless-kit/SKILL.md +110 -21
- package/skills/wix-headless-kit/guides/api-run.md +15 -13
- package/skills/wix-headless-kit/guides/existing-site.md +31 -0
- package/skills/wix-headless-kit/guides/migration.md +49 -17
- package/skills/wix-headless-kit/install/agents-md.mjs +1 -1
- package/skills/wix-headless-kit/install/context.mjs +61 -6
- package/skills/wix-headless-kit/install/pins.json +1 -1
- package/skills/wix-headless-kit/install/setup.mjs +107 -12
- package/skills/wix-headless-replatform/.publish-manifest.json +8 -0
- package/skills/wix-headless-replatform/SKILL.md +116 -0
- package/skills/wix-headless-replatform/agents/openai.yaml +6 -0
- package/skills/wix-headless-replatform/references/control-and-visual-fidelity-contract.md +43 -0
- package/skills/wix-headless-replatform/references/extraction-schema.md +187 -0
- package/skills/wix-headless-replatform/references/interaction-runtime-contract.md +137 -0
- package/skills/wix-headless-replatform/references/layout-blueprint-contract.md +41 -0
- package/skills/wix-headless-replatform/references/output-contract.md +93 -0
- package/skills/wix-headless-replatform/references/post-build-gap-contract.md +125 -0
- package/skills/wix-headless-replatform/references/qa-checklist.md +83 -0
- package/skills/wix-headless-replatform/references/safety.md +19 -0
- package/skills/wix-headless-replatform/references/ui-normalization-contract.md +70 -0
- package/skills/wix-headless-replatform/references/workflow.md +157 -0
- package/skills/wix-headless-replatform/registry/README.md +20 -0
- package/skills/wix-headless-replatform/registry/approvals/button/shadcn-default-ac60ef5.json +28 -0
- package/skills/wix-headless-replatform/registry/items/button/shadcn-default-ac60ef5/button.tsx +54 -0
- package/skills/wix-headless-replatform/registry/items/button/shadcn-default-ac60ef5/capabilities.json +60 -0
- package/skills/wix-headless-replatform/registry/items/button/shadcn-default-ac60ef5/contract.md +48 -0
- package/skills/wix-headless-replatform/registry/licenses/shadcn-ui-ac60ef5-MIT.txt +21 -0
- package/skills/wix-headless-replatform/registry/registry.json +36 -0
- package/skills/wix-headless-replatform/resources/rp-facelift/SKILL.md +32 -0
- package/skills/wix-headless-replatform/resources/rp-project-context/SKILL.md +62 -0
- package/skills/wix-headless-replatform/resources/rp-qa-gap-loop/SKILL.md +64 -0
- package/skills/wix-headless-replatform/resources/rp-source-evidence/SKILL.md +42 -0
- package/skills/wix-headless-replatform/resources/rp-ui-implementation/SKILL.md +73 -0
- package/skills/wix-headless-replatform/schemas/build-plan.schema.json +10 -0
- package/skills/wix-headless-replatform/schemas/candidate.schema.json +19 -0
- package/skills/wix-headless-replatform/schemas/common.schema.json +33 -0
- package/skills/wix-headless-replatform/schemas/decision-patch.schema.json +10 -0
- package/skills/wix-headless-replatform/schemas/decision-request.schema.json +10 -0
- package/skills/wix-headless-replatform/schemas/extraction-gap.schema.json +28 -0
- package/skills/wix-headless-replatform/schemas/extraction-manifest.schema.json +34 -0
- package/skills/wix-headless-replatform/schemas/final-report.schema.json +10 -0
- package/skills/wix-headless-replatform/schemas/foundation.schema.json +11 -0
- package/skills/wix-headless-replatform/schemas/metadata.schema.json +11 -0
- package/skills/wix-headless-replatform/schemas/observation-packet.schema.json +17 -0
- package/skills/wix-headless-replatform/schemas/page-capture.schema.json +11 -0
- package/skills/wix-headless-replatform/schemas/page-resolution.schema.json +33 -0
- package/skills/wix-headless-replatform/schemas/shared-chrome.schema.json +11 -0
- package/skills/wix-headless-replatform/schemas/unit.schema.json +40 -0
- package/skills/wix-headless-replatform/scripts/assemble-extraction.mjs +844 -0
- package/skills/wix-headless-replatform/scripts/benchmark-extraction.mjs +163 -0
- package/skills/wix-headless-replatform/scripts/browser-extraction-preflight.mjs +42 -0
- package/skills/wix-headless-replatform/scripts/build-extracted-homepage.mjs +228 -0
- package/skills/wix-headless-replatform/scripts/clear-wix-starter.mjs +87 -0
- package/skills/wix-headless-replatform/scripts/create-wix-project.mjs +505 -0
- package/skills/wix-headless-replatform/scripts/discover-urls.mjs +142 -0
- package/skills/wix-headless-replatform/scripts/extract-assets.mjs +140 -0
- package/skills/wix-headless-replatform/scripts/extract-design-system.mjs +637 -0
- package/skills/wix-headless-replatform/scripts/extract-interactions.mjs +1903 -0
- package/skills/wix-headless-replatform/scripts/extract-page.mjs +2461 -0
- package/skills/wix-headless-replatform/scripts/extract-seo.mjs +25 -0
- package/skills/wix-headless-replatform/scripts/extract-tokens.mjs +63 -0
- package/skills/wix-headless-replatform/scripts/finalize-extraction-report.mjs +126 -0
- package/skills/wix-headless-replatform/scripts/finalize-gap-review.mjs +180 -0
- package/skills/wix-headless-replatform/scripts/finalize-gap-review.test.mjs +98 -0
- package/skills/wix-headless-replatform/scripts/finalize-migration-website.mjs +103 -0
- package/skills/wix-headless-replatform/scripts/generate-control-state-contract.mjs +176 -0
- package/skills/wix-headless-replatform/scripts/generate-design-md.mjs +261 -0
- package/skills/wix-headless-replatform/scripts/generate-extraction-validators.mjs +25 -0
- package/skills/wix-headless-replatform/scripts/generate-invoice-download-backend.mjs +342 -0
- package/skills/wix-headless-replatform/scripts/generate-layout-blueprint.mjs +140 -0
- package/skills/wix-headless-replatform/scripts/generate-repeater-cms.mjs +22 -0
- package/skills/wix-headless-replatform/scripts/generate-route-plan.mjs +143 -0
- package/skills/wix-headless-replatform/scripts/generate-scene-contract.mjs +288 -0
- package/skills/wix-headless-replatform/scripts/generate-ui-normalization.mjs +266 -0
- package/skills/wix-headless-replatform/scripts/generate-visual-assets.mjs +111 -0
- package/skills/wix-headless-replatform/scripts/lib/browser-tooling.mjs +570 -0
- package/skills/wix-headless-replatform/scripts/lib/common.mjs +329 -0
- package/skills/wix-headless-replatform/scripts/lib/component-capabilities.mjs +121 -0
- package/skills/wix-headless-replatform/scripts/lib/component-registry.mjs +282 -0
- package/skills/wix-headless-replatform/scripts/lib/content-boundary.mjs +61 -0
- package/skills/wix-headless-replatform/scripts/lib/extraction-contract.mjs +374 -0
- package/skills/wix-headless-replatform/scripts/lib/extraction-detectors.mjs +243 -0
- package/skills/wix-headless-replatform/scripts/lib/extraction-validators.generated.mjs +1139 -0
- package/skills/wix-headless-replatform/scripts/lib/font-contract.mjs +326 -0
- package/skills/wix-headless-replatform/scripts/lib/frontend-automation-state.mjs +184 -0
- package/skills/wix-headless-replatform/scripts/lib/gap-analysis.mjs +396 -0
- package/skills/wix-headless-replatform/scripts/lib/html-extract.mjs +168 -0
- package/skills/wix-headless-replatform/scripts/lib/interaction-bootstrap.mjs +10 -0
- package/skills/wix-headless-replatform/scripts/lib/interaction-runtime.mjs +194 -0
- package/skills/wix-headless-replatform/scripts/lib/interaction-timeline.mjs +348 -0
- package/skills/wix-headless-replatform/scripts/lib/layout-blueprint/classifiers.mjs +141 -0
- package/skills/wix-headless-replatform/scripts/lib/layout-blueprint/geometry.mjs +43 -0
- package/skills/wix-headless-replatform/scripts/lib/layout-blueprint/vocabulary.mjs +18 -0
- package/skills/wix-headless-replatform/scripts/lib/ui-normalization.css +64 -0
- package/skills/wix-headless-replatform/scripts/optimize-svg.mjs +31 -0
- package/skills/wix-headless-replatform/scripts/post-build-gap.mjs +358 -0
- package/skills/wix-headless-replatform/scripts/provision-repeater-cms.mjs +25 -0
- package/skills/wix-headless-replatform/scripts/record-gap-decision.mjs +39 -0
- package/skills/wix-headless-replatform/scripts/replay-extraction.mjs +107 -0
- package/skills/wix-headless-replatform/scripts/resolve-home-page.mjs +96 -0
- package/skills/wix-headless-replatform/scripts/site-clone.mjs +658 -0
- package/skills/wix-headless-replatform/scripts/validate-font-contract.mjs +29 -0
- package/skills/wix-headless-replatform/scripts/verify-interactions.mjs +669 -0
- package/skills/wix-headless-replatform/scripts/visual-qa.mjs +370 -0
- package/skills/wix-headless-templates/donations/INSTRUCTIONS.md +37 -24
- package/skills/wix-headless-templates/donations/app/components/donations/DonateForm.tsx +49 -23
- package/skills/wix-headless-templates/donations/app/components/donations/DonationReceipt.tsx +6 -5
- package/skills/wix-headless-templates/donations/app/components/donations/GoalProgress.tsx +5 -5
- package/skills/wix-headless-templates/donations/app/wix/donations/campaigns.ts +4 -4
- package/skills/wix-headless-templates/donations/app/wix/donations/donate.ts +7 -3
- package/skills/wix-headless-templates/donations/app/wix/donations/donation-store.ts +2 -2
- package/skills/wix-headless-templates/donations/app/wix/donations/donations-core.ts +12 -9
- package/skills/wix-headless-templates/donations/project/src/components/donations/DonateForm.tsx +49 -23
- package/skills/wix-headless-templates/donations/project/src/components/donations/DonationReceipt.tsx +6 -5
- package/skills/wix-headless-templates/donations/project/src/components/donations/GoalProgress.tsx +5 -5
- package/skills/wix-headless-templates/donations/project/src/wix/donations/campaigns.ts +4 -4
- package/skills/wix-headless-templates/donations/project/src/wix/donations/donate.ts +7 -3
- package/skills/wix-headless-templates/donations/project/src/wix/donations/donation-store.ts +2 -2
- package/skills/wix-headless-templates/donations/project/src/wix/donations/donations-core.ts +12 -9
- package/skills/wix-headless-templates/donations/rest/campaigns.ts +4 -4
- package/skills/wix-headless-templates/donations/rest/donate.ts +7 -3
- package/skills/wix-headless-templates/donations/seed/SEED.md +12 -7
- package/skills/wix-headless-templates/donations/tests/donation-contract.test.mjs +71 -0
- package/skills/wix-headless-templates/donations/tests/donation-form.test.cjs +137 -0
- package/skills/wix-headless-templates/restaurants/INSTRUCTIONS.md +28 -14
- package/skills/wix-headless-templates/restaurants/app/components/restaurants/OrderCartDrawer.tsx +87 -5
- package/skills/wix-headless-templates/restaurants/app/hooks/restaurants/useOrderCart.ts +9 -1
- package/skills/wix-headless-templates/restaurants/app/wix/restaurants/order-store.ts +33 -4
- package/skills/wix-headless-templates/restaurants/app/wix/restaurants/ordering-core.ts +100 -5
- package/skills/wix-headless-templates/restaurants/app/wix/restaurants/ordering.ts +101 -15
- package/skills/wix-headless-templates/restaurants/app/wix/restaurants/types.ts +35 -1
- package/skills/wix-headless-templates/restaurants/project/src/components/restaurants/OrderCartDrawer.tsx +87 -5
- package/skills/wix-headless-templates/restaurants/project/src/hooks/restaurants/useOrderCart.ts +9 -1
- package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/order-store.ts +33 -4
- package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/ordering-core.ts +100 -5
- package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/ordering.ts +101 -15
- package/skills/wix-headless-templates/restaurants/project/src/wix/restaurants/types.ts +35 -1
- package/skills/wix-headless-templates/restaurants/rest/ordering.ts +91 -14
- package/skills/wix-import/SKILL.md +90 -0
- package/skills/wix-manage/SKILL.md +38 -10
- package/skills/wix-manage/references/automations/actions.md +11 -11
- package/skills/wix-manage/references/automations/activation-status.md +6 -9
- package/skills/wix-manage/references/automations/api-catalog.md +48 -32
- package/skills/wix-manage/references/automations/automation-model.md +97 -22
- package/skills/wix-manage/references/automations/bracket-expressions.md +7 -7
- package/skills/wix-manage/references/automations/build-and-manage-automations.md +140 -309
- package/skills/wix-manage/references/automations/conditions.md +187 -0
- package/skills/wix-manage/references/automations/schemas-and-scheduling.md +191 -0
- package/skills/wix-manage/references/automations/special-actions.md +210 -0
- package/skills/wix-manage/references/automations/triggers.md +47 -10
- package/skills/wix-manage/references/automations/validation-and-verification.md +320 -0
- package/skills/wix-manage/references/custom-apps/use-app-tools.md +124 -0
- package/skills/wix-manage/references/dashboard-navigation/dashboard-navigation.md +2 -1
- package/skills/wix-manage/references/dashboard-navigation/routes.json +249 -0
- package/skills/wix-manage/references/donations/create-and-update-donation-campaigns.md +139 -0
- package/skills/wix-manage/references/events/create-wix-event.md +136 -73
- package/skills/wix-manage/references/events/events-dashboard-navigation.md +81 -0
- package/skills/wix-manage/references/events/manage-event-guests.md +366 -0
- package/skills/wix-manage/references/events/manage-event-tickets.md +293 -0
- package/skills/wix-manage/references/events/manage-wix-events.md +313 -55
- package/skills/wix-manage/references/sites/manage-oauth-apps.md +1 -0
- package/skills/wix-manage/references/sites/upload-static-site.md +127 -8
- package/skills/wix-manage/references/stores/update-product-with-options.md +58 -2
- package/skills/wix-replatform/.publish-manifest.json +5 -5
- package/skills/wix-replatform/CLI.md +162 -0
- package/skills/wix-replatform/README.md +52 -0
- package/skills/wix-replatform/SKILL.md +229 -684
- package/skills/wix-replatform/console/account.css +1 -0
- package/skills/wix-replatform/console/app.css +1 -0
- package/skills/wix-replatform/console/app.js +117 -0
- package/skills/wix-replatform/console/index.html +4 -0
- package/skills/wix-replatform/console/json.css +11 -0
- package/skills/wix-replatform/lib/agent-adapters/index.js +71 -0
- package/skills/wix-replatform/lib/app-page-routing.js +75 -0
- package/skills/wix-replatform/lib/artifact-freshness.js +11 -1
- package/skills/wix-replatform/lib/blocked-data-requests.js +427 -0
- package/skills/wix-replatform/lib/census-reconciliation.js +426 -0
- package/skills/wix-replatform/lib/completion-report.js +1393 -13
- package/skills/wix-replatform/lib/config-env.js +85 -11
- package/skills/wix-replatform/lib/confirmed-pictures.js +212 -0
- package/skills/wix-replatform/lib/dependency-readiness.js +423 -0
- package/skills/wix-replatform/lib/dependency-recovery.js +21 -0
- package/skills/wix-replatform/lib/destination-choice.js +163 -0
- package/skills/wix-replatform/lib/destination-handoff.js +62 -0
- package/skills/wix-replatform/lib/destination-http.js +81 -0
- package/skills/wix-replatform/lib/destination-route.js +98 -0
- package/skills/wix-replatform/lib/destination.js +919 -0
- package/skills/wix-replatform/lib/discovered-census.js +231 -0
- package/skills/wix-replatform/lib/discovered-set-status.js +255 -0
- package/skills/wix-replatform/lib/document-url-guard.js +203 -0
- package/skills/wix-replatform/lib/entity-qa-attestation.js +339 -0
- package/skills/wix-replatform/lib/entity-verification.js +18 -0
- package/skills/wix-replatform/lib/execution-capability.js +120 -0
- package/skills/wix-replatform/lib/execution-log.js +170 -0
- package/skills/wix-replatform/lib/execution-manifest.js +20 -2
- package/skills/wix-replatform/lib/execution-state.js +22 -0
- package/skills/wix-replatform/lib/expectations-ledger.js +96 -0
- package/skills/wix-replatform/lib/generated-plugin-handoff.js +140 -0
- package/skills/wix-replatform/lib/import-readiness-contract.js +23 -0
- package/skills/wix-replatform/lib/import-recovery.js +800 -6
- package/skills/wix-replatform/lib/imported-redirect-targets.js +608 -0
- package/skills/wix-replatform/lib/internal-link-reconciliation.js +166 -0
- package/skills/wix-replatform/lib/link-audit.js +173 -0
- package/skills/wix-replatform/lib/link-census.js +194 -0
- package/skills/wix-replatform/lib/link-plan.js +148 -0
- package/skills/wix-replatform/lib/link-verification.js +274 -0
- package/skills/wix-replatform/lib/link-write-journal.js +42 -0
- package/skills/wix-replatform/lib/local-state.js +869 -30
- package/skills/wix-replatform/lib/member-completion.js +658 -0
- package/skills/wix-replatform/lib/member-crosswalk.js +69 -0
- package/skills/wix-replatform/lib/member-outcome-registry.js +265 -0
- package/skills/wix-replatform/lib/migration-completion.js +311 -0
- package/skills/wix-replatform/lib/operator-identity.js +47 -0
- package/skills/wix-replatform/lib/orchestration-decisions.js +248 -0
- package/skills/wix-replatform/lib/orchestration-preflight.js +401 -19
- package/skills/wix-replatform/lib/orchestration-router.js +608 -32
- package/skills/wix-replatform/lib/orchestration-state.js +188 -12
- package/skills/wix-replatform/lib/order-reference-readiness.js +30 -0
- package/skills/wix-replatform/lib/payments-outcome-registry.js +200 -0
- package/skills/wix-replatform/lib/plugin-cms-fallback.js +618 -0
- package/skills/wix-replatform/lib/preservation-approval-stamp.js +54 -0
- package/skills/wix-replatform/lib/product-media-deferral.js +96 -0
- package/skills/wix-replatform/lib/progress-log.js +19 -3
- package/skills/wix-replatform/lib/read-back-approval.js +184 -0
- package/skills/wix-replatform/lib/read-back-comparison.js +136 -0
- package/skills/wix-replatform/lib/read-back-contract.js +243 -0
- package/skills/wix-replatform/lib/read-back-extract.js +118 -0
- package/skills/wix-replatform/lib/read-back-gate.js +734 -0
- package/skills/wix-replatform/lib/read-back-reads.js +94 -0
- package/skills/wix-replatform/lib/read-back-state.js +107 -0
- package/skills/wix-replatform/lib/read-back-summary.js +81 -0
- package/skills/wix-replatform/lib/rerun-conflicts.js +334 -0
- package/skills/wix-replatform/lib/run-controller.js +401 -0
- package/skills/wix-replatform/lib/seo-outcome-registry.js +45 -0
- package/skills/wix-replatform/lib/setup-verification.js +148 -0
- package/skills/wix-replatform/lib/source-access.js +231 -0
- package/skills/wix-replatform/lib/source-coverage.js +1130 -0
- package/skills/wix-replatform/lib/source-secrets.js +277 -0
- package/skills/wix-replatform/lib/structured-link-patch.js +59 -0
- package/skills/wix-replatform/lib/task-state.js +110 -0
- package/skills/wix-replatform/lib/url-preservation-report.js +319 -0
- package/skills/wix-replatform/lib/url-preservation-state.js +349 -1
- package/skills/wix-replatform/lib/url-redirect-plan.js +728 -0
- package/skills/wix-replatform/lib/url-verification.js +315 -0
- package/skills/wix-replatform/lib/user-action-effects.js +42 -0
- package/skills/wix-replatform/lib/user-actions.js +264 -0
- package/skills/wix-replatform/lib/website-handoff.js +1220 -0
- package/skills/wix-replatform/lib/wix-client-callers.js +54 -0
- package/skills/wix-replatform/lib/wix-dashboard-url.js +35 -0
- package/skills/wix-replatform/lib/write-verification-state.js +92 -0
- package/skills/wix-replatform/lib/write-verification.js +274 -0
- package/skills/wix-replatform/resources/rp-destination/SKILL.md +137 -0
- package/skills/wix-replatform/resources/rp-discovery/SKILL.md +189 -16
- package/skills/wix-replatform/resources/rp-discovery/scripts/promote-source-coverage.js +47 -0
- package/skills/wix-replatform/resources/rp-execute-import/SKILL.md +869 -29
- package/skills/wix-replatform/resources/rp-execute-import/scripts/shipping-estimate-audit.js +70 -0
- package/skills/wix-replatform/resources/rp-execute-setup/SKILL.md +195 -29
- package/skills/wix-replatform/resources/rp-execute-setup/scripts/execute-setup.js +442 -0
- package/skills/wix-replatform/resources/rp-execution-policy/SKILL.md +112 -0
- package/skills/wix-replatform/resources/rp-execution-policy/lib/coupon-currency-plan-report.js +143 -0
- package/skills/wix-replatform/resources/rp-execution-policy/lib/payments-report.js +244 -0
- package/skills/wix-replatform/resources/rp-import-codegen/SKILL.md +2082 -38
- package/skills/wix-replatform/resources/rp-mapper/SKILL.md +528 -11
- package/skills/wix-replatform/resources/rp-mapper/lib/structure-bridge-planning.js +303 -0
- package/skills/wix-replatform/resources/rp-mapper/scripts/coverage-reconcile.js +88 -0
- package/skills/wix-replatform/resources/rp-mapper/wix-business-solutions-taxonomy.md +6 -5
- package/skills/wix-replatform/resources/rp-preflight/SKILL.md +40 -0
- package/skills/wix-replatform/resources/rp-project-intake/SKILL.md +55 -0
- package/skills/wix-replatform/resources/rp-quick-runtime/SKILL.md +60 -0
- package/skills/wix-replatform/resources/rp-quick-runtime/lib/import-progress.js +89 -0
- package/skills/wix-replatform/resources/rp-quick-runtime/lib/limit-recovery.js +36 -0
- package/skills/wix-replatform/resources/rp-quick-shopify/SKILL.md +123 -0
- package/skills/wix-replatform/resources/rp-quick-shopify/quick-mode.json +124 -0
- package/skills/wix-replatform/resources/rp-quick-shopify/scripts/quick-mode.js +522 -0
- package/skills/wix-replatform/resources/rp-quick-woocommerce/SKILL.md +56 -0
- package/skills/wix-replatform/resources/rp-quick-woocommerce/quick-mode.json +91 -0
- package/skills/wix-replatform/resources/rp-quick-woocommerce/scripts/quick-mode.js +255 -0
- package/skills/wix-replatform/resources/rp-setup-discovery/SKILL.md +80 -10
- package/skills/wix-replatform/resources/rp-setup-discovery/scripts/quick-setup-plan.js +44 -0
- package/skills/wix-replatform/resources/rp-source-csv/SKILL.md +3 -0
- package/skills/wix-replatform/resources/rp-source-csv/lib/csv-fileset.js +0 -0
- package/skills/wix-replatform/resources/rp-source-csv/scripts/csv-discovery.js +21 -1
- package/skills/wix-replatform/resources/rp-source-inputs/SKILL.md +66 -0
- package/skills/wix-replatform/resources/rp-source-sfcc/SKILL.md +153 -0
- package/skills/wix-replatform/resources/rp-source-shopify/SKILL.md +394 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/discovery-reads.js +200 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/import-findings.js +34 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-bulk-sqlite-worker.js +44 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-bulk.js +1470 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-cli.js +446 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-gift-cards.js +474 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-protected-fields.js +879 -0
- package/skills/wix-replatform/resources/rp-source-shopify/lib/shopify-session.js +426 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/articles.graphql +24 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/blogs.graphql +18 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/collections.graphql +40 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/customers.graphql +76 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/delivery-profiles.graphql +51 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/discounts.graphql +35 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/files.graphql +20 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/gift-cards.graphql +18 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/inventory.graphql +31 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/locations.graphql +21 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/menus.graphql +21 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/metaobjects.graphql +30 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/orders-core.graphql +150 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/orders-fulfillments.graphql +36 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/orders-refunds.graphql +48 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/pages.graphql +20 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-address.graphql +8 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-email.graphql +6 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-name.graphql +8 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-customers-phone.graphql +8 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-address.graphql +12 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-email.graphql +6 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-name.graphql +13 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/probe-orders-phone.graphql +13 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/products.graphql +73 -0
- package/skills/wix-replatform/resources/rp-source-shopify/queries/url-redirects.graphql +13 -0
- package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-discovery.js +693 -0
- package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-extract.js +283 -0
- package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-gift-card-remedy.js +191 -0
- package/skills/wix-replatform/resources/rp-source-shopify/scripts/shopify-session-check.js +115 -0
- package/skills/wix-replatform/resources/rp-source-shopify/source-schema.example.json +201 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/PLUGIN-READ-PLANS.md +146 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/SKILL.md +736 -22
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/blocked-data-handlers.js +73 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/checkout-field-csv-parser.js +115 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/checkout-field-csv-parser.test-fixture.js +91 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/coupon-discovery.js +440 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/currency-gate.js +125 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/gateway-source-keys.js +252 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/gateway-source-keys.json +183 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/gateway-summary.mjs +333 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/invoice-discovery.js +426 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/plugin-disposition.js +400 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/plugin-entity-read-plan.js +633 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/plugin-knowledge.js +1127 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/refund-corroboration.js +194 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/refund-corroboration.json +100 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/sampled-ids-batch.js +157 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/secret-value-guard.js +234 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/store-currency.js +101 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/structure-bridge-reader.js +755 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/wix-wp-plugin-v2-client.js +1074 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/wix-wp-plugin-v2-client.test-fixture.js +149 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/woo-inventory.js +25 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-http.js +204 -9
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-image-url.js +186 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-plugin-detect.js +1422 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-redirect-sources.js +343 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/wp-route-classifier.js +262 -26
- package/skills/wix-replatform/resources/rp-source-wordpress/lib/yoast-product-seo-evidence.js +272 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/README.md +373 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/advanced-custom-fields.json +101 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/back-in-stock-notifier-for-woocommerce.json +81 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/capabilities-pending-decision.json +128 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/cms-fallback-eligible.json +18 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/contact-form-7.json +104 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/facebook-for-woocommerce.json +44 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/fingerprint-aliases.json +49 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/free-gifts-for-woocommerce.json +94 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/index.json +863 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/mailpoet.json +52 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/membership-for-woocommerce.json +161 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/mwb-bookings-for-woocommerce.json +180 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/no-migration-needed.json +286 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/pricing-deals-for-woocommerce.json +79 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/product-extras-for-woocommerce.json +120 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/pw-woocommerce-gift-cards.json +128 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/requires-development.json +88 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/seo-by-rank-math.json +80 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/seriously-simple-podcasting.json +46 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/strong-testimonials.json +55 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/subscriptions-for-woocommerce.json +99 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/tablepress.json +55 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/the-events-calendar.json +160 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/ti-woocommerce-wishlist.json +81 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woo-checkout-field-editor-pro.json +60 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woo-discount-rules.json +74 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woo-product-bundle.json +75 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-gift-cards.json +60 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-other-payment-gateway.json +44 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-pdf-invoices-packing-slips.json +57 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-product-addon.json +141 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/woocommerce-progressive-discounts.json +54 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/wordpress-seo.json +158 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/wpc-composite-products.json +97 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/plugins/wpforms-lite.json +86 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/scripts/capture-store-settings.js +90 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/scripts/plugin-knowledge-validate.js +51 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/scripts/plugin-knowledge.js +103 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/scripts/wp-discovery.js +1668 -33
- package/skills/wix-replatform/resources/rp-source-wordpress/scripts/wp-plugin-inventory.js +273 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/secret-value-patterns.v1.json +11 -0
- package/skills/wix-replatform/resources/rp-source-wordpress/sub-parts.json +13 -0
- package/skills/wix-replatform/resources/rp-target-wix/SKILL.md +446 -32
- package/skills/wix-replatform/resources/rp-target-wix/app-page-routing-capabilities.json +36 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/README.md +38 -2
- package/skills/wix-replatform/resources/rp-target-wix/domains/SERVICE-PLUGINS.md +322 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/blog/docs-survey.json +70 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/blog/domain.json +19 -9
- package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/category.json +42 -8
- package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/comment.json +54 -8
- package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/post.json +66 -10
- package/skills/wix-replatform/resources/rp-target-wix/domains/blog/entities/tag.json +38 -7
- package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/docs-survey.json +332 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/domain.json +75 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/entities/booking.json +181 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/entities/service-add-on.json +130 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/bookings/entities/service.json +180 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/cms/docs-survey.json +161 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/cms/domain.json +15 -4
- package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/collection.json +39 -7
- package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/data-item.json +47 -8
- package/skills/wix-replatform/resources/rp-target-wix/domains/cms/entities/reference.json +7 -1
- package/skills/wix-replatform/resources/rp-target-wix/domains/crm/docs-survey.json +204 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/crm/domain.json +17 -4
- package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/contact.json +159 -15
- package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/email-subscription.json +80 -12
- package/skills/wix-replatform/resources/rp-target-wix/domains/crm/entities/label.json +48 -8
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/docs-survey.json +306 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/domain.json +30 -7
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/delivery-profile.json +171 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/discount-rule.json +182 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-applied-discount.json +129 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-invoice-document.json +192 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-line-item-options.json +123 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-line-item.json +60 -12
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-merchant-note.json +112 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-payment.json +191 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order-refund.json +140 -13
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/order.json +383 -18
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/pickup-location.json +122 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/shipping-option.json +98 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/ecom/entities/wishlist-item.json +86 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/events/docs-survey.json +128 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/events/domain.json +38 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/category.json +73 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/event.json +107 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/registration-form.json +89 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/rsvp.json +118 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/events/entities/ticket-definition.json +93 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/forms/docs-survey.json +86 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/forms/domain.json +56 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/forms/entities/form-submission.json +121 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/forms/entities/form.json +134 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/docs-survey.json +41 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/domain.json +50 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/entities/gift-card-product.json +87 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/gift-cards/entities/gift-card.json +130 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/index.json +914 -24
- package/skills/wix-replatform/resources/rp-target-wix/domains/media/docs-survey.json +41 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/media/domain.json +14 -4
- package/skills/wix-replatform/resources/rp-target-wix/domains/media/entities/media-file.json +45 -8
- package/skills/wix-replatform/resources/rp-target-wix/domains/media/entities/media-folder.json +41 -7
- package/skills/wix-replatform/resources/rp-target-wix/domains/members/docs-survey.json +119 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/members/domain.json +13 -3
- package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/badge.json +41 -7
- package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/custom-field.json +82 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/member-about.json +77 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/members/entities/member.json +165 -13
- package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/docs-survey.json +41 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/domain.json +46 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/entities/plan-order.json +137 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/pricing-plans/entities/plan.json +133 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/docs-survey.json +7 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/domain.json +36 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/amazon-shop-connect.json +71 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/ebay-shop-connect.json +67 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/google-youtube-connect.json +72 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/meta-catalog-connect.json +74 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/pinterest-catalog-connect.json +69 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/sales-channels/entities/tiktok-catalog-connect.json +61 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/schema.json +28 -1
- package/skills/wix-replatform/resources/rp-target-wix/domains/seo/docs-survey.json +109 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/seo/domain.json +73 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/seo/entities/item-seo-tags.json +148 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/seo/entities/seo-pattern.json +91 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/seo/entities/site-seo-tags.json +79 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/site/docs-survey.json +32 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/site/domain.json +49 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/site/entities/business-contact.json +103 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/docs-survey.json +203 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/domain.json +27 -10
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/back-in-stock-request.json +119 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/brand.json +111 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/category.json +52 -8
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/coupon.json +214 -10
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/inventory-item.json +93 -13
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product-customization.json +111 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product-tag.json +52 -10
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/product.json +145 -14
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/promotion.json +84 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/review.json +178 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/stores/entities/subscription-product.json +87 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/tax/docs-survey.json +106 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/tax/domain.json +64 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/manual-tax-mapping.json +119 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/tax-group.json +94 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/tax-region.json +113 -0
- package/skills/wix-replatform/resources/rp-target-wix/domains/tax/entities/tax-settings.json +65 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-author-attribution.js +165 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-client.js +60 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-duplicates.js +201 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-ledger.js +306 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-report.js +229 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build-stage.js +55 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-build.js +715 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/blog-post-media.js +567 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/bulk-results.js +73 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/contact-extended-fields.js +194 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/contact-import.js +133 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/contract-ledger.js +13 -4
- package/skills/wix-replatform/resources/rp-target-wix/lib/coupon-redemption-drift.js +491 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/customer-member.js +104 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/data-extension-schema.js +673 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/domain-knowledge.js +453 -2
- package/skills/wix-replatform/resources/rp-target-wix/lib/gift-card-balance-reconciliation.js +119 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/gift-card-build.js +566 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/gift-card-redemption-build.js +249 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/order-applied-discount-build.js +63 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/order-buyer.js +187 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/order-channel-build.js +64 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/order-history.js +1027 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/order-invoice-contract.js +90 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/order-payment-mapping.js +420 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/pricing-plan-definition.js +177 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/product-import.js +151 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/product-seo.js +723 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/seo-redirects.js +353 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/shipping-build.js +1437 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/shipping-option-stage.js +354 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/store-config-build.js +134 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/stores-category-attach.js +221 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/stores-inventory.js +248 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/stores-verification.js +86 -3
- package/skills/wix-replatform/resources/rp-target-wix/lib/tax-build.js +231 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/url-mapper-transport.js +28 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/value-utils.js +14 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/variant-correlation.js +34 -0
- package/skills/wix-replatform/resources/rp-target-wix/lib/wix-build.js +166 -15
- package/skills/wix-replatform/resources/rp-target-wix/lib/wix-target-spec.js +19 -2
- package/skills/wix-replatform/resources/rp-target-wix/lib/wix-writers.js +4079 -257
- package/skills/wix-replatform/resources/rp-target-wix/lib/write-verification.js +3 -0
- package/skills/wix-replatform/resources/rp-target-wix/scripts/docs-survey-sync.js +150 -0
- package/skills/wix-replatform/resources/rp-target-wix/scripts/domain-knowledge-validate.js +40 -2
- package/skills/wix-replatform/resources/rp-target-wix/scripts/verify-stores.js +6 -1
- package/skills/wix-replatform/resources/rp-telemetry/SKILL.md +148 -8
- package/skills/wix-replatform/resources/rp-telemetry/lib/bi-sink.js +83 -15
- package/skills/wix-replatform/resources/rp-telemetry/lib/telemetry-recorder.js +1119 -215
- package/skills/wix-replatform/resources/rp-telemetry/lib/transcript-digest.js +318 -0
- package/skills/wix-replatform/resources/rp-telemetry/scripts/meter-from-audit.js +2 -2
- package/skills/wix-replatform/resources/rp-telemetry/scripts/rp-telemetry.js +106 -4
- package/skills/wix-replatform/resources/rp-website-continuation/SKILL.md +94 -0
- package/skills/wix-replatform/scripts/census-reconciliation.js +25 -0
- package/skills/wix-replatform/scripts/cms-fallback.js +89 -0
- package/skills/wix-replatform/scripts/discovered-census.js +26 -0
- package/skills/wix-replatform/scripts/discovered-set-status.js +33 -0
- package/skills/wix-replatform/scripts/entity-qa-attestation.js +130 -0
- package/skills/wix-replatform/scripts/execution-health-check.js +415 -0
- package/skills/wix-replatform/scripts/execution-manifest-validate.js +1 -1
- package/skills/wix-replatform/scripts/execution-state-prepare.js +1 -1
- package/skills/wix-replatform/scripts/expectations-ledger.js +44 -0
- package/skills/wix-replatform/scripts/import-contract-verify.js +183 -0
- package/skills/wix-replatform/scripts/internal-link-audit.js +90 -0
- package/skills/wix-replatform/scripts/item-seo-tags-verify.js +205 -0
- package/skills/wix-replatform/scripts/migration-completion.js +76 -0
- package/skills/wix-replatform/scripts/orchestration-preflight.js +21 -2
- package/skills/wix-replatform/scripts/orchestration-route.js +32 -1
- package/skills/wix-replatform/scripts/orchestration-state.js +146 -10
- package/skills/wix-replatform/scripts/read-back-gate.js +175 -0
- package/skills/wix-replatform/scripts/replatform-console.js +146 -0
- package/skills/wix-replatform/scripts/replatform.js +436 -0
- package/skills/wix-replatform/scripts/source-secrets.js +77 -0
- package/skills/wix-replatform/scripts/url-redirects.js +286 -0
- package/skills/wix-replatform/scripts/user-action.js +58 -0
- package/skills/wix-replatform/scripts/website-handoff-generate.js +64 -0
- package/skills/wix-replatform/scripts/wix-dashboard-url.js +54 -0
- package/skills/wix-replatform/scripts/wix-destination.js +143 -0
- package/skills/wix-replatform/scripts/wix-headless-scaffold.js +762 -0
- package/skills/wix-vibe-headless/SKILL.md +7 -3
- package/skills/wix-vibe-headless/install/deploy.cjs +61 -34
- package/skills/wix-vibe-headless/platforms/base44.md +1 -0
- package/skills/wix-vibe-headless/references/donations/INSTRUCTIONS.md +88 -0
- package/skills/wix-vibe-headless/references/donations/app/rest/wix-donations.js +112 -0
- package/skills/wix-vibe-headless/references/donations/seed/SEED.md +11 -0
- package/skills/wix-vibe-headless/references/donations/tests/donations.test.mjs +258 -0
- package/skills/wix-vibe-headless/references/restaurants/INSTRUCTIONS.md +5 -2
- package/skills/wix-vibe-headless/references/restaurants/app/context/OrderCartContext.jsx +4 -1
- package/skills/wix-vibe-headless/references/restaurants/app/rest/wix-restaurants-ordering.js +67 -3
- package/skills/wix-vibe-headless/references/shared/app/rest/wix-client.js +4 -3
- package/skills/wix-manage/references/custom-apps/use-app-skills-and-app-tools.md +0 -208
- package/skills/wix-replatform/resources/rp-target-wix/SPEC-product-reviews-and-blog-authorship.md +0 -330
|
@@ -5,6 +5,21 @@ const path = require('node:path');
|
|
|
5
5
|
|
|
6
6
|
const SCHEMA_VERSION = 1;
|
|
7
7
|
|
|
8
|
+
// `process.kill(pid, 0)` throwing does not by itself mean the
|
|
9
|
+
// process is dead -- Node surfaces the same exception for ESRCH (no such process) and EPERM (a
|
|
10
|
+
// real, live process this user cannot signal, e.g. owned by a different UID on a shared
|
|
11
|
+
// sandbox). Only ESRCH means dead; only Node's own `error.code` is needed to tell the two apart,
|
|
12
|
+
// no filesystem check required. Shared with `execution-health-check.js`, which had its own
|
|
13
|
+
// independent copy of this exact check before round 5 consolidated them.
|
|
14
|
+
function isProcessAlive(pid) {
|
|
15
|
+
try {
|
|
16
|
+
process.kill(pid, 0);
|
|
17
|
+
return true;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return error && error.code === 'EPERM';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
8
23
|
const CROSSWALK_STATUS = new Set(['imported']);
|
|
9
24
|
const ATTEMPT_STATUS = new Set([
|
|
10
25
|
'started',
|
|
@@ -16,8 +31,96 @@ const ATTEMPT_STATUS = new Set([
|
|
|
16
31
|
'needs_verification',
|
|
17
32
|
'skipped_already_imported',
|
|
18
33
|
'skipped_safe_mode_blocked',
|
|
34
|
+
// A record excluded by an accepted
|
|
35
|
+
// out-of-scope rule (`entityCompleteness.skippedOutOfScope`) needs its own
|
|
36
|
+
// terminal attempt-journal status alongside the other `skipped_*` outcomes below, or the
|
|
37
|
+
// very first such row written to a project's real ledger makes `validateAttemptRow` throw
|
|
38
|
+
// and poisons every future read of that append-only journal (`loadAttemptJournal`,
|
|
39
|
+
// `readAttemptJournalSince`) for the rest of the project's life. Like its `skipped_*`
|
|
40
|
+
// siblings, it makes no journal-count claim and is intentionally not a branch in
|
|
41
|
+
// `coverageStatusCounts` (import-recovery.js) or `DEFERRED_ATTEMPT_STATUSES` below.
|
|
42
|
+
'skipped_out_of_scope',
|
|
43
|
+
// An in-scope record the runner skipped WITHOUT an accepted source-data rule.
|
|
44
|
+
// Deliberately not `deferred` (an accepted, reasoned deferral) and in none of the deferred,
|
|
45
|
+
// uncertain or failure-required sets: it was never sent, so recovery treats it as missing.
|
|
46
|
+
'skipped_unexpected',
|
|
19
47
|
]);
|
|
20
48
|
|
|
49
|
+
// An UNRESOLVED outcome is a write whose result we do not know: it may or may
|
|
50
|
+
// not have landed on the merchant's store. Its next action is to READ THE TARGET BACK, never to
|
|
51
|
+
// re-send, so it is deliberately a different class from `failed` (re-attempt) and from
|
|
52
|
+
// `deferred` (reconsider when the blocker clears). Folding it into `failed` is how a recovery
|
|
53
|
+
// pass creates a duplicate on a live store.
|
|
54
|
+
//
|
|
55
|
+
// This is NOT import-recovery's UNCERTAIN_ATTEMPT_STATUSES, which additionally covers the
|
|
56
|
+
// deferred pair for a different question ("could a prior write already exist?").
|
|
57
|
+
const UNRESOLVED_ATTEMPT_STATUSES = new Set(['started', 'succeeded_unverified']);
|
|
58
|
+
|
|
59
|
+
// These statuses must carry a structured `failure` block, because for each of
|
|
60
|
+
// them the identifying facts are the whole value of the row. `started` is excluded on purpose:
|
|
61
|
+
// a `started` row is written BEFORE the outcome is known, so it has no facts to carry yet. It
|
|
62
|
+
// becomes unresolved only by dangling — by never getting a terminal follow-on row — which is a
|
|
63
|
+
// property of the journal, not of the row, and is resolved in the projection below.
|
|
64
|
+
const FAILURE_REQUIRED_STATUSES = new Set(['failed_retryable', 'failed_terminal', 'succeeded_unverified']);
|
|
65
|
+
const FAILURE_OUTCOMES = new Set(['failed_terminal', 'failed_retryable', 'unresolved']);
|
|
66
|
+
const PRODUCT_MEDIA_FAILURE_REASONS = new Set([
|
|
67
|
+
'no-source-id',
|
|
68
|
+
'no-source-record',
|
|
69
|
+
'source-unreadable',
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
// The outcome a given status must declare, so a row cannot say `failed_terminal` in one field
|
|
73
|
+
// and `unresolved` in the other.
|
|
74
|
+
const FAILURE_OUTCOME_FOR_STATUS = {
|
|
75
|
+
failed_retryable: 'failed_retryable',
|
|
76
|
+
failed_terminal: 'failed_terminal',
|
|
77
|
+
succeeded_unverified: 'unresolved',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// The truncation rule made checkable. The defect this closes: a coupon failure
|
|
81
|
+
// kept the first 300 characters of the error message, and in every case the identifier of the
|
|
82
|
+
// thing that failed sat past the cut. A GUID is the identifier shape the target uses, it never
|
|
83
|
+
// occurs in ordinary prose, and so a GUID present in `failure.message` and nowhere else on the
|
|
84
|
+
// row is exactly the evidence-destroying pattern -- detectable with no heuristics.
|
|
85
|
+
const GUID_IN_TEXT = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
86
|
+
|
|
87
|
+
// a message naming exactly one GUID is not always
|
|
88
|
+
// naming THIS row's own target -- Wix's own validator errors routinely echo back a REFERENCED
|
|
89
|
+
// entity's id while explaining why some OTHER entity's reference to it failed, e.g.
|
|
90
|
+
// `scope.group={name:product,entityId:<PRODUCT-GUID>} entityId not found` on a failed
|
|
91
|
+
// coupon-create. That message names exactly one distinct GUID, but it is the product the coupon
|
|
92
|
+
// referenced, not the coupon itself -- and the single-GUID auto-extraction below would have
|
|
93
|
+
// misattributed that product's id to the coupon row as its own targetEntityId. `scope.group=`
|
|
94
|
+
// and `entityId ... not found` are the two markers Wix's own foreign-reference-lookup failures use
|
|
95
|
+
// to describe an id that belongs to some OTHER record; when either appears, the message is
|
|
96
|
+
// self-evidently talking about a reference, not self-identifying, so this is treated the same as
|
|
97
|
+
// the already-handled two-distinct-GUIDs case -- leave targetEntityId unguessed.
|
|
98
|
+
//
|
|
99
|
+
// BUG FIX: the second alternative used to require the literal, ADJACENT
|
|
100
|
+
// substring "entityId not found" -- but Wix's actual documented error text for this exact case
|
|
101
|
+
// (domains/stores/entities/coupon.json, wix-writers.js:4148) is `entityId '<id>' not found`, with
|
|
102
|
+
// the referenced GUID quoted in between "entityId" and "not found". That real shape matched
|
|
103
|
+
// neither alternative, so a coupon-create failure carrying Wix's own documented wording still hit
|
|
104
|
+
// the single-GUID auto-extraction path and misattributed the referenced product's GUID to the
|
|
105
|
+
// coupon row -- the identical misattribution bug this guard exists to close, just via a phrasing
|
|
106
|
+
// the marker didn't cover. Broadened to `entityId\b.*not found`, which still requires "entityId"
|
|
107
|
+
// to actually appear before "not found" (so an unrelated, later "not found" elsewhere in a long
|
|
108
|
+
// message can't match on its own): confirmed against every "entityId ... not found" error shape
|
|
109
|
+
// documented in this repo (coupon.json, wix-writers.js) that this is the only live use of the
|
|
110
|
+
// phrase, always in the same foreign-reference-scope context, so widening it introduces no
|
|
111
|
+
// self-referential false positive.
|
|
112
|
+
// `.*` cannot span a newline, but `wix.send()` embeds up to 400
|
|
113
|
+
// raw response characters into `error.message` (see below), which can be a pretty-printed,
|
|
114
|
+
// multi-line 400 body. `[\s\S]*` matches the same "entityId ... not found" shape across an
|
|
115
|
+
// embedded newline, where a bare `.` would silently fail to match and let the single-GUID
|
|
116
|
+
// auto-extraction below misattribute a referenced entity's GUID as this row's own targetEntityId.
|
|
117
|
+
// BUG FIX: `entityId\b` has no boundary BEFORE "entityId", so it also
|
|
118
|
+
// matched inside a compound identifier like "targetEntityId" (e.g. "field targetEntityId is
|
|
119
|
+
// required but was not found..."), a false positive about the row's OWN record, not a foreign
|
|
120
|
+
// reference -- suppressing legitimate GUID auto-extraction for that row. The negative lookbehind
|
|
121
|
+
// requires "entityId" not be preceded by a letter, so it only matches as its own token.
|
|
122
|
+
const FOREIGN_REFERENCE_MARKER = /scope\.group\s*=|(?<![a-zA-Z])entityId\b[\s\S]*not found/i;
|
|
123
|
+
|
|
21
124
|
function stateDir(projectDir) {
|
|
22
125
|
return path.join(projectDir, 'state');
|
|
23
126
|
}
|
|
@@ -46,6 +149,26 @@ function wixRequestCapturesPath(projectDir) {
|
|
|
46
149
|
return path.join(attemptsDir(projectDir), 'wix-request-captures.ndjson');
|
|
47
150
|
}
|
|
48
151
|
|
|
152
|
+
// A validation pass keeps its rows under a PARALLEL SUBTREE, not beside the real
|
|
153
|
+
// journal under a different filename. The dry-run crosswalk's sibling-filename convention is
|
|
154
|
+
// deliberately not followed here and is not changed by this: the property this buys is
|
|
155
|
+
// that a validation pass has no path to the real ledger at all, and a sibling filename leaves
|
|
156
|
+
// the real journal one string substitution away -- which is precisely how a record limit came
|
|
157
|
+
// to select a truncating open against the right path.
|
|
158
|
+
function sampleStateDir(projectDir) {
|
|
159
|
+
return path.join(projectDir, 'state', 'sample');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function sampleAttemptJournalPath(projectDir) {
|
|
163
|
+
return path.join(sampleStateDir(projectDir), 'attempts', 'write-attempts.ndjson');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// A derived re-read queue, rebuilt from the journal. It is a PROJECTION: deleting
|
|
167
|
+
// it loses nothing and it is never a source of truth.
|
|
168
|
+
function unresolvedWritesPath(projectDir) {
|
|
169
|
+
return path.join(projectDir, 'execution', 'unresolved-writes.ndjson');
|
|
170
|
+
}
|
|
171
|
+
|
|
49
172
|
function cmsMirrorDir(projectDir) {
|
|
50
173
|
return path.join(stateDir(projectDir), 'cms-mirror');
|
|
51
174
|
}
|
|
@@ -92,7 +215,7 @@ async function writeJsonAtomic(filePath, data) {
|
|
|
92
215
|
async function writeTextAtomic(filePath, text) {
|
|
93
216
|
await mkdirp(path.dirname(filePath));
|
|
94
217
|
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
95
|
-
await fs.writeFile(tempPath, text, 'utf8');
|
|
218
|
+
await fs.writeFile(tempPath, text, { encoding: 'utf8', mode: 0o600 });
|
|
96
219
|
await fs.rename(tempPath, filePath);
|
|
97
220
|
}
|
|
98
221
|
|
|
@@ -139,6 +262,19 @@ function requireString(row, field, label, errors) {
|
|
|
139
262
|
}
|
|
140
263
|
}
|
|
141
264
|
|
|
265
|
+
const crosswalkListeners = new Map();
|
|
266
|
+
async function crosswalkFileStamp(file) { try { const stat = await fs.stat(file); return `${stat.ino}:${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`; } catch (error) { if (error.code === 'ENOENT') return 'missing'; throw error; } }
|
|
267
|
+
function onCrosswalkChange(projectDir, listener) {
|
|
268
|
+
const root = path.resolve(projectDir); if (!crosswalkListeners.has(root)) crosswalkListeners.set(root, new Set());
|
|
269
|
+
crosswalkListeners.get(root).add(listener); return () => crosswalkListeners.get(root)?.delete(listener);
|
|
270
|
+
}
|
|
271
|
+
async function notifyCrosswalkChange(projectDir, event) { for (const listener of crosswalkListeners.get(path.resolve(projectDir)) || []) listener(event); }
|
|
272
|
+
function stampSite(projectDir, row) {
|
|
273
|
+
const context = require('./execution-capability').projectContext(projectDir);
|
|
274
|
+
if (context && row.siteId && row.siteId !== context.siteId) throw new Error('SITE_EVIDENCE_MISMATCH');
|
|
275
|
+
return context ? { ...row, siteId: context.siteId } : row;
|
|
276
|
+
}
|
|
277
|
+
|
|
142
278
|
function validateCrosswalkRow(row, { allowThrow = true, label = 'crosswalk row' } = {}) {
|
|
143
279
|
const errors = [];
|
|
144
280
|
try {
|
|
@@ -149,6 +285,7 @@ function validateCrosswalkRow(row, { allowThrow = true, label = 'crosswalk row'
|
|
|
149
285
|
}
|
|
150
286
|
return { ok: false, errors: [error.message] };
|
|
151
287
|
}
|
|
288
|
+
if (row.siteId !== undefined && (typeof row.siteId !== 'string' || !row.siteId)) errors.push(`${label}.siteId must be a nonempty string`);
|
|
152
289
|
if (row.schemaVersion !== SCHEMA_VERSION) {
|
|
153
290
|
errors.push(`${label}.schemaVersion must be ${SCHEMA_VERSION}`);
|
|
154
291
|
}
|
|
@@ -170,12 +307,347 @@ function validateCrosswalkRow(row, { allowThrow = true, label = 'crosswalk row'
|
|
|
170
307
|
if (row.updatedAt !== undefined && Number.isNaN(Date.parse(row.updatedAt))) {
|
|
171
308
|
errors.push(`${label}.updatedAt must be an ISO timestamp when present`);
|
|
172
309
|
}
|
|
310
|
+
// The version pair recorded from a CONFIRMED write, so a rerun can tell a
|
|
311
|
+
// changed source record from an unchanged one. All four stay OPTIONAL, because rows written
|
|
312
|
+
// before this existed must still load -- but absence is never read as "unchanged" (see
|
|
313
|
+
// rerunDecision, which reports `unknown` rather than skipping).
|
|
314
|
+
if (row.sourceVersionField !== undefined
|
|
315
|
+
&& (typeof row.sourceVersionField !== 'string' || row.sourceVersionField === '')) {
|
|
316
|
+
errors.push(`${label}.sourceVersionField must be a non-empty string when present`);
|
|
317
|
+
}
|
|
318
|
+
if (row.sourceVersion !== undefined
|
|
319
|
+
&& !(typeof row.sourceVersion === 'string' || typeof row.sourceVersion === 'number')) {
|
|
320
|
+
errors.push(`${label}.sourceVersion must be a string or number when present`);
|
|
321
|
+
}
|
|
322
|
+
if (row.sourceVersion !== undefined && row.sourceVersionField === undefined) {
|
|
323
|
+
errors.push(`${label}.sourceVersion requires sourceVersionField — a version with no named field cannot be compared`);
|
|
324
|
+
}
|
|
325
|
+
if (row.targetRevision !== undefined
|
|
326
|
+
&& (typeof row.targetRevision !== 'string' || row.targetRevision === '')) {
|
|
327
|
+
errors.push(`${label}.targetRevision must be a non-empty opaque string when present`);
|
|
328
|
+
}
|
|
329
|
+
if (row.sourceHash !== undefined && (typeof row.sourceHash !== 'string' || row.sourceHash === '')) {
|
|
330
|
+
errors.push(`${label}.sourceHash must be a non-empty string when present`);
|
|
331
|
+
}
|
|
332
|
+
if (row.sourceHashDefinition !== undefined
|
|
333
|
+
&& (typeof row.sourceHashDefinition !== 'string' || row.sourceHashDefinition === '')) {
|
|
334
|
+
errors.push(`${label}.sourceHashDefinition must be a non-empty string when present`);
|
|
335
|
+
}
|
|
173
336
|
if (errors.length && allowThrow) {
|
|
174
337
|
throw new Error(errors.join('; '));
|
|
175
338
|
}
|
|
176
339
|
return { ok: errors.length === 0, errors };
|
|
177
340
|
}
|
|
178
341
|
|
|
342
|
+
// Decides what a rerun does with one source record, given its crosswalk
|
|
343
|
+
// baseline. Pure: no I/O, no writes, so the same inputs always give the same verdict.
|
|
344
|
+
//
|
|
345
|
+
// The load-bearing rule is the LAST one: a linked record with no usable comparison evidence is
|
|
346
|
+
// `unknown`, never `skip` and never a blind `update`. "We lost the baseline" and "the source did
|
|
347
|
+
// not change" are different facts, and conflating them either silently drops a real change or
|
|
348
|
+
// silently overwrites a merchant's Wix edit.
|
|
349
|
+
const RERUN_ACTIONS = new Set(['create', 'skip', 'update', 'unknown']);
|
|
350
|
+
|
|
351
|
+
function comparableVersion(value) {
|
|
352
|
+
if (value === undefined || value === null || value === '') {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
// Version IDs are opaque: compare as strings, never numerically or by recency.
|
|
356
|
+
return String(value);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function rerunDecision({
|
|
360
|
+
crosswalkRow = null,
|
|
361
|
+
sourceVersion = undefined,
|
|
362
|
+
sourceVersionField = null,
|
|
363
|
+
sourceHash = undefined,
|
|
364
|
+
sourceHashDefinition = null,
|
|
365
|
+
} = {}) {
|
|
366
|
+
if (!crosswalkRow) {
|
|
367
|
+
return {
|
|
368
|
+
action: 'create',
|
|
369
|
+
reason: 'no_crosswalk_link',
|
|
370
|
+
targetId: null,
|
|
371
|
+
targetRevision: null,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
const targetId = crosswalkRow.targetId || null;
|
|
375
|
+
const targetRevision = crosswalkRow.targetRevision || null;
|
|
376
|
+
const base = { targetId, targetRevision };
|
|
377
|
+
|
|
378
|
+
const baselineVersion = comparableVersion(crosswalkRow.sourceVersion);
|
|
379
|
+
const currentVersion = comparableVersion(sourceVersion);
|
|
380
|
+
const baselineField = crosswalkRow.sourceVersionField || null;
|
|
381
|
+
const baselineHash = comparableVersion(crosswalkRow.sourceHash);
|
|
382
|
+
const currentHash = comparableVersion(sourceHash);
|
|
383
|
+
|
|
384
|
+
// Changing the comparison field/hash definition invalidates that baseline until
|
|
385
|
+
// reconciled. A baseline captured from `date_modified_gmt` says nothing about a version now
|
|
386
|
+
// read from a different field.
|
|
387
|
+
if (baselineField && sourceVersionField && baselineField !== sourceVersionField) {
|
|
388
|
+
return { ...base, action: 'unknown', reason: 'version_field_changed' };
|
|
389
|
+
}
|
|
390
|
+
// The same rule applies to the hash: changing the comparison field/hash definition
|
|
391
|
+
// invalidates that baseline until reconciled. A hash computed over a different set of mapped
|
|
392
|
+
// fields is not comparable with the stored one -- without this, a redefinition falls through
|
|
393
|
+
// to `update` and quietly overwrites Wix on every rerun.
|
|
394
|
+
if (crosswalkRow.sourceHashDefinition && sourceHashDefinition
|
|
395
|
+
&& crosswalkRow.sourceHashDefinition !== sourceHashDefinition) {
|
|
396
|
+
return { ...base, action: 'unknown', reason: 'hash_definition_changed' };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const versionComparable = baselineVersion !== null && currentVersion !== null;
|
|
400
|
+
const hashComparable = baselineHash !== null && currentHash !== null;
|
|
401
|
+
|
|
402
|
+
// A hash difference catches a change the timestamp missed (coarse or unchanged mtime), so it
|
|
403
|
+
// is checked even when the versions match.
|
|
404
|
+
if (hashComparable && baselineHash !== currentHash) {
|
|
405
|
+
if (!targetRevision) {
|
|
406
|
+
return { ...base, action: 'unknown', reason: 'no_saved_revision_for_update' };
|
|
407
|
+
}
|
|
408
|
+
return { ...base, action: 'update', reason: 'source_hash_differs' };
|
|
409
|
+
}
|
|
410
|
+
if (versionComparable && baselineVersion !== currentVersion) {
|
|
411
|
+
// A linked row with no saved revision cannot be updated safely: the write would carry no
|
|
412
|
+
// revision and therefore no conflict protection, so a merchant edit would be overwritten
|
|
413
|
+
// silently. Legacy rows written before the version pair existed land here too.
|
|
414
|
+
if (!targetRevision) {
|
|
415
|
+
return { ...base, action: 'unknown', reason: 'no_saved_revision_for_update' };
|
|
416
|
+
}
|
|
417
|
+
return { ...base, action: 'update', reason: 'source_version_differs' };
|
|
418
|
+
}
|
|
419
|
+
if (versionComparable || hashComparable) {
|
|
420
|
+
// Equality WITH adequate evidence. Wix may have changed on its own; that is not a reason to
|
|
421
|
+
// write, and not a reason to refresh the saved revision either.
|
|
422
|
+
return { ...base, action: 'skip', reason: versionComparable ? 'source_version_equal' : 'source_hash_equal' };
|
|
423
|
+
}
|
|
424
|
+
return {
|
|
425
|
+
...base,
|
|
426
|
+
action: 'unknown',
|
|
427
|
+
reason: crosswalkRow.sourceVersion === undefined && crosswalkRow.sourceHash === undefined
|
|
428
|
+
? 'no_baseline_recorded'
|
|
429
|
+
: 'source_version_unavailable',
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// The pair advances ONLY on a confirmed write. A failed, conflicted,
|
|
434
|
+
// dry-run or skipped write leaves the previous baseline exactly where it was, so the record
|
|
435
|
+
// stays eligible for recovery instead of being recorded as applied.
|
|
436
|
+
const CONFIRMED_WRITE_OUTCOMES = new Set(['created', 'updated']);
|
|
437
|
+
|
|
438
|
+
function nextCrosswalkBaseline({
|
|
439
|
+
existingRow = null,
|
|
440
|
+
outcome = null,
|
|
441
|
+
sourceVersion = undefined,
|
|
442
|
+
sourceVersionField = null,
|
|
443
|
+
sourceHash = undefined,
|
|
444
|
+
sourceHashDefinition = null,
|
|
445
|
+
targetRevision = undefined,
|
|
446
|
+
} = {}) {
|
|
447
|
+
if (!CONFIRMED_WRITE_OUTCOMES.has(outcome)) {
|
|
448
|
+
return { advanced: false, reason: `outcome_not_confirmed:${outcome === null ? 'none' : outcome}`, row: existingRow };
|
|
449
|
+
}
|
|
450
|
+
// Consistent with validateCrosswalkRow, which hard-rejects the same shape: a version with no
|
|
451
|
+
// named field cannot be compared later, so accepting it silently would write an unusable
|
|
452
|
+
// baseline that reads as "compared and equal" on the next rerun.
|
|
453
|
+
if (sourceVersion !== undefined && !sourceVersionField) {
|
|
454
|
+
throw new Error('nextCrosswalkBaseline: sourceVersion requires sourceVersionField — an unnamed version cannot be compared on a later rerun');
|
|
455
|
+
}
|
|
456
|
+
const next = { ...(existingRow || {}) };
|
|
457
|
+
if (sourceVersion !== undefined && sourceVersionField) {
|
|
458
|
+
next.sourceVersion = sourceVersion;
|
|
459
|
+
next.sourceVersionField = sourceVersionField;
|
|
460
|
+
}
|
|
461
|
+
if (sourceHash !== undefined) {
|
|
462
|
+
next.sourceHash = sourceHash;
|
|
463
|
+
}
|
|
464
|
+
if (sourceHashDefinition) {
|
|
465
|
+
next.sourceHashDefinition = sourceHashDefinition;
|
|
466
|
+
}
|
|
467
|
+
// Preserve its exact value; do not increment it locally. An absent revision in the
|
|
468
|
+
// response is not a reason to invent one, and not a reason to drop a known-good earlier one.
|
|
469
|
+
const haveRevision = targetRevision !== undefined && targetRevision !== null && targetRevision !== '';
|
|
470
|
+
if (haveRevision) {
|
|
471
|
+
next.targetRevision = String(targetRevision);
|
|
472
|
+
}
|
|
473
|
+
// If the response lacks a revision, reconcile a readback with the expected written
|
|
474
|
+
// values before establishing a baseline. Advancing the SOURCE version while keeping the OLD
|
|
475
|
+
// revision would pair a new source state with a revision that predates the write — the saved
|
|
476
|
+
// pair would no longer describe the same write, and the next change would send a stale
|
|
477
|
+
// revision and self-conflict. An update that returns no revision is therefore not a baseline;
|
|
478
|
+
// it needs reconciliation.
|
|
479
|
+
// This applies to a FIRST write too, not only to a re-write of an already-linked record. A
|
|
480
|
+
// create whose response carried no revision leaves the pair half-formed: the source version
|
|
481
|
+
// says "this state is applied" while there is no revision to protect the next update, so the
|
|
482
|
+
// next change would be written with no concurrency guard at all. Half a pair is not a
|
|
483
|
+
// baseline.
|
|
484
|
+
if (!haveRevision) {
|
|
485
|
+
return {
|
|
486
|
+
advanced: false,
|
|
487
|
+
reason: 'confirmed_write_without_returned_revision',
|
|
488
|
+
needsReconciliation: true,
|
|
489
|
+
row: existingRow,
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
return { advanced: true, reason: outcome, row: next };
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// `runId` and `phase` join the required set. The
|
|
496
|
+
// asymmetry this closes: validateWixRequestCaptureRow and validateDryRunCrosswalkRow already
|
|
497
|
+
// require `runId`; the durable journal -- the one artifact a reader still has a year later --
|
|
498
|
+
// was the only one that did not. Without them, "how many records did this pass import" cannot
|
|
499
|
+
// be answered from the file at all, and every per-ROW count silently reads as a per-RECORD one.
|
|
500
|
+
//
|
|
501
|
+
// This array is the single source of truth for the documented required set: the codegen skill
|
|
502
|
+
// document is checked against it by tests/orchestration/runtime-contract-test.js, so a prose
|
|
503
|
+
// list cannot drift from the validator.
|
|
504
|
+
const ATTEMPT_REQUIRED_FIELDS = [
|
|
505
|
+
'attemptId',
|
|
506
|
+
'sourceStableKey',
|
|
507
|
+
'writeSpecId',
|
|
508
|
+
'operation',
|
|
509
|
+
'targetEntityType',
|
|
510
|
+
'status',
|
|
511
|
+
'runId',
|
|
512
|
+
'phase',
|
|
513
|
+
];
|
|
514
|
+
|
|
515
|
+
// A limited pass that writes for REAL is not a sample: its rows belong in the
|
|
516
|
+
// real journal, stamped like any other pass, and `selection` is what makes its scope legible.
|
|
517
|
+
function validateAttemptSelection(row, label, errors) {
|
|
518
|
+
if (row.selection === undefined) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
const selection = row.selection;
|
|
522
|
+
if (!selection || typeof selection !== 'object' || Array.isArray(selection)) {
|
|
523
|
+
errors.push(`${label}.selection must be an object`);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
for (const field of ['offset', 'limit']) {
|
|
527
|
+
const value = selection[field];
|
|
528
|
+
if (value === undefined || value === null) {
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
532
|
+
errors.push(`${label}.selection.${field} must be a non-negative integer or null`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (selection.filters !== undefined && selection.filters !== null
|
|
536
|
+
&& (typeof selection.filters !== 'object' || Array.isArray(selection.filters))) {
|
|
537
|
+
errors.push(`${label}.selection.filters must be an object`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// `reconcile` is the structured evidence an unknown-outcome recovery needs: the
|
|
542
|
+
// region and the ids that existed before the POST, plus any candidate ids found afterwards. Ids
|
|
543
|
+
// live here as fields, never only inside `failure.message`.
|
|
544
|
+
function validateAttemptReconcile(row, label, errors) {
|
|
545
|
+
if (row.reconcile === undefined) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const reconcile = row.reconcile;
|
|
549
|
+
if (!reconcile || typeof reconcile !== 'object' || Array.isArray(reconcile)) {
|
|
550
|
+
errors.push(`${label}.reconcile must be an object`);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (reconcile.deliveryRegionId !== undefined && (typeof reconcile.deliveryRegionId !== 'string' || !reconcile.deliveryRegionId)) {
|
|
554
|
+
errors.push(`${label}.reconcile.deliveryRegionId must be a non-empty string when present`);
|
|
555
|
+
}
|
|
556
|
+
for (const field of ['preWriteTargetIds', 'candidateTargetIds']) {
|
|
557
|
+
const value = reconcile[field];
|
|
558
|
+
if (value !== undefined && (!Array.isArray(value) || value.some((id) => typeof id !== 'string' || !id))) {
|
|
559
|
+
errors.push(`${label}.reconcile.${field} must be an array of non-empty strings when present`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// A failure keeps its identifying facts as FIELDS; only the human sentence is
|
|
565
|
+
// ever shortened.
|
|
566
|
+
function validateAttemptFailure(row, label, errors) {
|
|
567
|
+
const required = FAILURE_REQUIRED_STATUSES.has(row.status);
|
|
568
|
+
if (row.failure === undefined || row.failure === null) {
|
|
569
|
+
if (required) {
|
|
570
|
+
errors.push(`${label}.failure is required when status is ${row.status} — a truncated sentence is not a record of what failed`);
|
|
571
|
+
}
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
const failure = row.failure;
|
|
575
|
+
const failureLabel = `${label}.failure`;
|
|
576
|
+
if (typeof failure !== 'object' || Array.isArray(failure)) {
|
|
577
|
+
errors.push(`${failureLabel} must be an object`);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
for (const field of ['sourceId', 'operation']) {
|
|
581
|
+
requireString(failure, field, failureLabel, errors);
|
|
582
|
+
}
|
|
583
|
+
if (typeof failure.message !== 'string') {
|
|
584
|
+
errors.push(`${failureLabel}.message must be a string`);
|
|
585
|
+
}
|
|
586
|
+
if (!FAILURE_OUTCOMES.has(failure.outcome)) {
|
|
587
|
+
errors.push(`${failureLabel}.outcome must be one of: ${Array.from(FAILURE_OUTCOMES).join(', ')}`);
|
|
588
|
+
}
|
|
589
|
+
if (failure.reason !== undefined && !PRODUCT_MEDIA_FAILURE_REASONS.has(failure.reason)) {
|
|
590
|
+
errors.push(`${failureLabel}.reason must be one of: ${Array.from(PRODUCT_MEDIA_FAILURE_REASONS).join(', ')}`);
|
|
591
|
+
}
|
|
592
|
+
const expectedOutcome = FAILURE_OUTCOME_FOR_STATUS[row.status];
|
|
593
|
+
if (expectedOutcome && failure.outcome && failure.outcome !== expectedOutcome) {
|
|
594
|
+
errors.push(`${failureLabel}.outcome must be ${expectedOutcome} when status is ${row.status}`);
|
|
595
|
+
}
|
|
596
|
+
// Present-and-nullable: the KEY must exist, so "we looked and the request named none" is
|
|
597
|
+
// distinguishable from "nobody extracted it". targetEntityId is the field the run lost inside
|
|
598
|
+
// a 300-character slice, so its absence is an error rather than a default.
|
|
599
|
+
for (const field of ['targetEntityId', 'errorCode', 'scopeGroupName']) {
|
|
600
|
+
if (!(field in failure)) {
|
|
601
|
+
errors.push(`${failureLabel}.${field} must be present (string or null)`);
|
|
602
|
+
} else if (failure[field] !== null && typeof failure[field] !== 'string') {
|
|
603
|
+
errors.push(`${failureLabel}.${field} must be a string or null`);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (!('httpStatus' in failure)) {
|
|
607
|
+
errors.push(`${failureLabel}.httpStatus must be present (integer or null)`);
|
|
608
|
+
} else if (failure.httpStatus !== null && !Number.isInteger(failure.httpStatus)) {
|
|
609
|
+
errors.push(`${failureLabel}.httpStatus must be an integer or null`);
|
|
610
|
+
}
|
|
611
|
+
assertNoIdentifierOnlyInMessage(row, failureLabel, errors);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// The truncation rule, stated as a rule because it IS the defect: no identifier may
|
|
615
|
+
// exist only inside `failure.message`. Implementations extract the identifying fields from the
|
|
616
|
+
// error BEFORE shortening the message, never after — so a GUID that the message carries and no
|
|
617
|
+
// structured field repeats means the extraction was skipped and the evidence is one truncation
|
|
618
|
+
// away from being gone.
|
|
619
|
+
//
|
|
620
|
+
// this rule is about `failure.message` specifically,
|
|
621
|
+
// not about every field on the row -- `failure.originalMessage` (see `tolerateIdentifierOnlyMessage`
|
|
622
|
+
// below) is a DELIBERATE exception, not a gap in this check. It preserves the raw pre-redaction
|
|
623
|
+
// text for a human/later diagnosis pass in the ambiguous/foreign-reference case where
|
|
624
|
+
// `targetEntityId` is intentionally left unguessed (a wrong guess there is worse than none) -- it
|
|
625
|
+
// is not itself a structured, machine-actionable identifier field, so an identifier that exists
|
|
626
|
+
// ONLY in `originalMessage` still counts as "only in message-shaped text" for this rule's
|
|
627
|
+
// purpose, same as `failure.message` itself, and must be excluded from "elsewhere" below.
|
|
628
|
+
// (`originalMessage` is always the pre-redaction copy of `message`, so leaving it in "elsewhere"
|
|
629
|
+
// would also let it trivially self-corroborate -- the same text checked against itself is not
|
|
630
|
+
// independent evidence in a different field.) `assertNoIdentifierOnlyInMessage` is intentionally
|
|
631
|
+
// never called against `originalMessage` itself: this rule fires on the CURRENT `message`, and a
|
|
632
|
+
// redacted `message` (replaced with `<redacted-id>`) no longer carries a raw GUID to flag --
|
|
633
|
+
// exactly the truncation rule being satisfied, not bypassed, since the identifier no longer sits
|
|
634
|
+
// only in message-shaped text once it has been removed from `message` and structured extraction
|
|
635
|
+
// was attempted (`targetEntityId`, when unambiguous) or deliberately declined with the reason
|
|
636
|
+
// recorded (the foreign-reference/ambiguous comment above).
|
|
637
|
+
function assertNoIdentifierOnlyInMessage(row, failureLabel, errors) {
|
|
638
|
+
const message = typeof row.failure.message === 'string' ? row.failure.message : '';
|
|
639
|
+
const found = message.match(GUID_IN_TEXT);
|
|
640
|
+
if (!found) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
const elsewhere = JSON.stringify({ ...row, failure: { ...row.failure, message: '', originalMessage: '' } }).toLowerCase();
|
|
644
|
+
for (const guid of new Set(found.map((value) => value.toLowerCase()))) {
|
|
645
|
+
if (!elsewhere.includes(guid)) {
|
|
646
|
+
errors.push(`${failureLabel}.message carries identifier ${guid} that appears in no other field — extract identifying facts into fields before truncating the message`);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
179
651
|
function validateAttemptRow(row, { allowThrow = true, label = 'attempt row' } = {}) {
|
|
180
652
|
const errors = [];
|
|
181
653
|
try {
|
|
@@ -186,21 +658,126 @@ function validateAttemptRow(row, { allowThrow = true, label = 'attempt row' } =
|
|
|
186
658
|
}
|
|
187
659
|
return { ok: false, errors: [error.message] };
|
|
188
660
|
}
|
|
661
|
+
if (row.siteId !== undefined && (typeof row.siteId !== 'string' || !row.siteId)) errors.push(`${label}.siteId must be a nonempty string`);
|
|
189
662
|
if (row.schemaVersion !== SCHEMA_VERSION) {
|
|
190
663
|
errors.push(`${label}.schemaVersion must be ${SCHEMA_VERSION}`);
|
|
191
664
|
}
|
|
192
|
-
for (const field of
|
|
665
|
+
for (const field of ATTEMPT_REQUIRED_FIELDS) {
|
|
193
666
|
requireString(row, field, label, errors);
|
|
194
667
|
}
|
|
195
668
|
if (row.status && !ATTEMPT_STATUS.has(row.status)) {
|
|
196
669
|
errors.push(`${label}.status must be one of: ${Array.from(ATTEMPT_STATUS).join(', ')}`);
|
|
197
670
|
}
|
|
671
|
+
if (row.deferral !== undefined && (row.status !== 'deferred' || !row.deferral || typeof row.deferral.reason !== 'string')) errors.push(`${label}.deferral invalid`);
|
|
672
|
+
validateAttemptSelection(row, label, errors);
|
|
673
|
+
validateAttemptFailure(row, label, errors);
|
|
674
|
+
validateAttemptReconcile(row, label, errors);
|
|
675
|
+
if (row.blockedDataSnapshot !== undefined) {
|
|
676
|
+
const snapshot = row.blockedDataSnapshot;
|
|
677
|
+
if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) {
|
|
678
|
+
errors.push(`${label}.blockedDataSnapshot must be an object`);
|
|
679
|
+
} else {
|
|
680
|
+
for (const field of ['sourceEntityRef', 'extractedAt', 'checksum']) requireString(snapshot, field, `${label}.blockedDataSnapshot`, errors);
|
|
681
|
+
if (!Number.isInteger(snapshot.snapshotVersion) || snapshot.snapshotVersion < 1) {
|
|
682
|
+
errors.push(`${label}.blockedDataSnapshot.snapshotVersion must be a positive integer`);
|
|
683
|
+
}
|
|
684
|
+
if (snapshot.extractedAt !== undefined && Number.isNaN(Date.parse(snapshot.extractedAt))) {
|
|
685
|
+
errors.push(`${label}.blockedDataSnapshot.extractedAt must be an ISO timestamp`);
|
|
686
|
+
}
|
|
687
|
+
if (snapshot.checksum !== undefined && !/^sha256:[a-f0-9]{64}$/.test(snapshot.checksum)) {
|
|
688
|
+
errors.push(`${label}.blockedDataSnapshot.checksum must be a sha256 digest`);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
198
692
|
if (errors.length && allowThrow) {
|
|
199
693
|
throw new Error(errors.join('; '));
|
|
200
694
|
}
|
|
201
695
|
return { ok: errors.length === 0, errors };
|
|
202
696
|
}
|
|
203
697
|
|
|
698
|
+
// assertNoIdentifierOnlyInMessage above
|
|
699
|
+
// is deliberate and correct: an identifier that exists ONLY inside `failure.message` really is
|
|
700
|
+
// undocumented evidence on that row, and this function must never weaken that guard. But
|
|
701
|
+
// `wix.send()` (rp-target-wix/lib/wix-writers.js) embeds the full request URL and up to 400 raw
|
|
702
|
+
// response characters into `error.message`, so a genuine Wix API error can legitimately echo
|
|
703
|
+
// back some entity's GUID that the caller never thought to extract into a structured field --
|
|
704
|
+
// and a validator rejection at write time must never crash the whole import run over message
|
|
705
|
+
// phrasing. In the incident, a project's own catch-all recovery path then tried to log a SECOND
|
|
706
|
+
// attempt row built from the validation error's own message -- which still carried the same
|
|
707
|
+
// GUID -- and THAT rejection was uncaught, which is what actually took the run down.
|
|
708
|
+
//
|
|
709
|
+
// The fix, ported from that project's local `recordAttemptGuarded` wrapper into the one place
|
|
710
|
+
// every generated importer already goes through: on exactly this rejection, extract the GUID
|
|
711
|
+
// into a real structured field when that's unambiguous, and EITHER WAY keep the original message
|
|
712
|
+
// on the row (never just delete it) before retrying once. A row that is broken for any OTHER
|
|
713
|
+
// reason -- the GUID is embedded a second way with no single unambiguous target, or unrelated
|
|
714
|
+
// fields are missing/invalid -- still throws, from the retry's own validateAttemptRow call, so a
|
|
715
|
+
// genuinely different caller bug is never silently swallowed.
|
|
716
|
+
//
|
|
717
|
+
// Two failure modes this must not reintroduce, both found in review after the redact-only version
|
|
718
|
+
// shipped: (1) redacting `failure.message` in place and discarding the original text loses the
|
|
719
|
+
// only surviving evidence of what the identifier actually was, with nothing on the row saying a
|
|
720
|
+
// redaction even happened -- exactly the truncation-without-extraction defect
|
|
721
|
+
// assertNoIdentifierOnlyInMessage exists to catch, just moved one step later. (2) this must run on
|
|
722
|
+
// READ as well as write: a row already on disk before this function existed (or written by some
|
|
723
|
+
// other path) fails the same validator on every future `loadAttemptJournal` call, which
|
|
724
|
+
// `markAttempt` depends on to find the row it is patching -- one bad historical row would
|
|
725
|
+
// otherwise wedge every future read of an append-only journal that is never rewritten or trimmed.
|
|
726
|
+
function tolerateIdentifierOnlyMessage(row) {
|
|
727
|
+
const validation = validateAttemptRow(row, { allowThrow: false });
|
|
728
|
+
if (validation.ok) {
|
|
729
|
+
return { ok: true, row };
|
|
730
|
+
}
|
|
731
|
+
const carriesUnredactedIdentifier = row && row.failure && typeof row.failure.message === 'string'
|
|
732
|
+
&& validation.errors.some((error) => error.includes('appears in no other field'));
|
|
733
|
+
if (!carriesUnredactedIdentifier) {
|
|
734
|
+
return { ok: false, errors: validation.errors };
|
|
735
|
+
}
|
|
736
|
+
const originalMessage = row.failure.message;
|
|
737
|
+
const found = originalMessage.match(GUID_IN_TEXT) || [];
|
|
738
|
+
const distinctGuids = Array.from(new Set(found.map((value) => value.toLowerCase())));
|
|
739
|
+
const patchedFailure = { ...row.failure };
|
|
740
|
+
// Prefer real structured extraction over redact-and-hide: if targetEntityId is explicitly null
|
|
741
|
+
// (present, "we looked and there was none yet") and the message names exactly one candidate
|
|
742
|
+
// GUID, that GUID is almost certainly the record the message is about -- put it where
|
|
743
|
+
// assertNoIdentifierOnlyInMessage always wanted it. Two or more distinct GUIDs, an already-set
|
|
744
|
+
// targetEntityId naming something else, or the KEY BEING ABSENT ENTIRELY are all left alone:
|
|
745
|
+
// a missing key (as opposed to an explicit null) is its own caller bug -- "nobody populated
|
|
746
|
+
// this field at all" -- and synthesizing one from the message text would silently paper over
|
|
747
|
+
// that, not fix it; the row still throws below with the real "targetEntityId must be present"
|
|
748
|
+
// error in that case. A single GUID corroborated as a FOREIGN reference (see
|
|
749
|
+
// FOREIGN_REFERENCE_MARKER above) is left unguessed for the same reason two distinct GUIDs are:
|
|
750
|
+
// "unambiguous" here has to mean "unambiguously THIS row's own record", not merely "only one
|
|
751
|
+
// GUID appears in the text" -- a message can name exactly one GUID and still be talking about
|
|
752
|
+
// someone else's identity entirely.
|
|
753
|
+
if (
|
|
754
|
+
'targetEntityId' in patchedFailure && patchedFailure.targetEntityId === null
|
|
755
|
+
&& distinctGuids.length === 1 && !FOREIGN_REFERENCE_MARKER.test(originalMessage)
|
|
756
|
+
) {
|
|
757
|
+
patchedFailure.targetEntityId = found[0];
|
|
758
|
+
}
|
|
759
|
+
// Whichever way that went, never destroy the original text: keep it in its own field so a
|
|
760
|
+
// human or a later diagnosis pass can still see exactly what the source system said, and so
|
|
761
|
+
// `assertNoIdentifierOnlyInMessage`'s own "does this identifier appear anywhere else on the
|
|
762
|
+
// row" check (which this redaction must still satisfy) finds it there rather than nowhere.
|
|
763
|
+
patchedFailure.message = originalMessage.replace(GUID_IN_TEXT, '<redacted-id>');
|
|
764
|
+
patchedFailure.originalMessage = originalMessage;
|
|
765
|
+
const redactedRow = { ...row, failure: patchedFailure };
|
|
766
|
+
const revalidation = validateAttemptRow(redactedRow, { allowThrow: false });
|
|
767
|
+
if (!revalidation.ok) {
|
|
768
|
+
return { ok: false, errors: revalidation.errors };
|
|
769
|
+
}
|
|
770
|
+
return { ok: true, row: redactedRow };
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
function withIdentifierRedactionRetry(row) {
|
|
774
|
+
const result = tolerateIdentifierOnlyMessage(row);
|
|
775
|
+
if (!result.ok) {
|
|
776
|
+
throw new Error(result.errors.join('; '));
|
|
777
|
+
}
|
|
778
|
+
return result.row;
|
|
779
|
+
}
|
|
780
|
+
|
|
204
781
|
function validateSafeModeEmailReplacementRow(row, { allowThrow = true, label = 'safe-mode email replacement row' } = {}) {
|
|
205
782
|
const errors = [];
|
|
206
783
|
try {
|
|
@@ -211,6 +788,7 @@ function validateSafeModeEmailReplacementRow(row, { allowThrow = true, label = '
|
|
|
211
788
|
}
|
|
212
789
|
return { ok: false, errors: [error.message] };
|
|
213
790
|
}
|
|
791
|
+
if (row.siteId !== undefined && (typeof row.siteId !== 'string' || !row.siteId)) errors.push(`${label}.siteId must be a nonempty string`);
|
|
214
792
|
if (row.schemaVersion !== SCHEMA_VERSION) {
|
|
215
793
|
errors.push(`${label}.schemaVersion must be ${SCHEMA_VERSION}`);
|
|
216
794
|
}
|
|
@@ -248,6 +826,7 @@ function validateSafeModeBlockedRecordRow(row, { allowThrow = true, label = 'saf
|
|
|
248
826
|
}
|
|
249
827
|
return { ok: false, errors: [error.message] };
|
|
250
828
|
}
|
|
829
|
+
if (row.siteId !== undefined && (typeof row.siteId !== 'string' || !row.siteId)) errors.push(`${label}.siteId must be a nonempty string`);
|
|
251
830
|
if (row.schemaVersion !== SCHEMA_VERSION) {
|
|
252
831
|
errors.push(`${label}.schemaVersion must be ${SCHEMA_VERSION}`);
|
|
253
832
|
}
|
|
@@ -289,6 +868,7 @@ function validateWixRequestCaptureRow(row, { allowThrow = true, label = 'Wix req
|
|
|
289
868
|
}
|
|
290
869
|
return { ok: false, errors: [error.message] };
|
|
291
870
|
}
|
|
871
|
+
if (row.siteId !== undefined && (typeof row.siteId !== 'string' || !row.siteId)) errors.push(`${label}.siteId must be a nonempty string`);
|
|
292
872
|
if (row.schemaVersion !== SCHEMA_VERSION) {
|
|
293
873
|
errors.push(`${label}.schemaVersion must be ${SCHEMA_VERSION}`);
|
|
294
874
|
}
|
|
@@ -326,6 +906,7 @@ function validateDryRunCrosswalkRow(row, { allowThrow = true, label = 'dry-run c
|
|
|
326
906
|
}
|
|
327
907
|
return { ok: false, errors: [error.message] };
|
|
328
908
|
}
|
|
909
|
+
if (row.siteId !== undefined && (typeof row.siteId !== 'string' || !row.siteId)) errors.push(`${label}.siteId must be a nonempty string`);
|
|
329
910
|
if (row.schemaVersion !== SCHEMA_VERSION) {
|
|
330
911
|
errors.push(`${label}.schemaVersion must be ${SCHEMA_VERSION}`);
|
|
331
912
|
}
|
|
@@ -378,21 +959,49 @@ async function loadCrosswalk(projectDir) {
|
|
|
378
959
|
}
|
|
379
960
|
|
|
380
961
|
async function appendCrosswalkRow(projectDir, row) {
|
|
962
|
+
row = stampSite(projectDir, row);
|
|
381
963
|
validateCrosswalkRow(row);
|
|
964
|
+
const before = await crosswalkFileStamp(crosswalkPath(projectDir));
|
|
382
965
|
await appendNdjson(crosswalkPath(projectDir), row);
|
|
966
|
+
await notifyCrosswalkChange(projectDir, { updates: [row], remove: [], before, after: await crosswalkFileStamp(crosswalkPath(projectDir)), dryRun: false });
|
|
383
967
|
return row;
|
|
384
968
|
}
|
|
385
969
|
|
|
386
|
-
async function
|
|
387
|
-
|
|
970
|
+
async function updateCrosswalkRows(projectDir, updates, { remove = [] } = {}) {
|
|
971
|
+
updates = updates.map(row => stampSite(projectDir, row));
|
|
972
|
+
// Load protected receipts once per batch, not once per crosswalk row.
|
|
973
|
+
const states = new Map();
|
|
974
|
+
const verifier = require('./write-verification');
|
|
975
|
+
for (const row of updates) {
|
|
976
|
+
validateCrosswalkRow(row);
|
|
977
|
+
if (!row.verification) continue;
|
|
978
|
+
let receipt = row.verification;
|
|
979
|
+
if (receipt.storage === 'write-verification') {
|
|
980
|
+
const ref = receipt;
|
|
981
|
+
if (!states.has(ref.siteId)) states.set(ref.siteId, await require('./write-verification-state').load(projectDir, ref.siteId));
|
|
982
|
+
const candidate = states.get(ref.siteId).rows[row.sourceStableKey];
|
|
983
|
+
if (candidate?.identityConflict) throw new Error('Revoked crosswalk verification');
|
|
984
|
+
receipt = [candidate?.receipt, candidate?.lastVerifiedReceipt].find(r => r && ref.receiptDigest === verifier.digest(r));
|
|
985
|
+
if (!receipt || ref.receiptDigest !== verifier.digest(receipt) || ref.sourceKey !== row.sourceStableKey || ref.targetId !== row.targetId || ref.siteId !== receipt?.siteId || ref.kind !== receipt?.kind) throw new Error('Invalid crosswalk verification reference');
|
|
986
|
+
}
|
|
987
|
+
if (!verifier.validReceipt(receipt, { sourceKey: row.sourceStableKey, targetId: row.targetId })) throw new Error('Invalid crosswalk verification');
|
|
988
|
+
}
|
|
989
|
+
const before = await crosswalkFileStamp(crosswalkPath(projectDir));
|
|
388
990
|
const current = await loadCrosswalk(projectDir);
|
|
389
|
-
current.bySource[
|
|
991
|
+
for (const key of remove) delete current.bySource[key];
|
|
992
|
+
for (const row of updates) current.bySource[row.sourceStableKey] = row;
|
|
390
993
|
const rows = Object.values(current.bySource).sort((a, b) => a.sourceStableKey.localeCompare(b.sourceStableKey));
|
|
391
|
-
|
|
392
|
-
await writeTextAtomic(crosswalkPath(projectDir), text ? `${text}\n` : '');
|
|
994
|
+
await writeTextAtomic(crosswalkPath(projectDir), rows.map(row => JSON.stringify(row)).join('\n') + (rows.length ? '\n' : ''));
|
|
393
995
|
await rebuildCrosswalkIndexes(projectDir);
|
|
996
|
+
await notifyCrosswalkChange(projectDir, { updates, remove, before, after: await crosswalkFileStamp(crosswalkPath(projectDir)), dryRun: false });
|
|
997
|
+
}
|
|
998
|
+
async function upsertCrosswalkRow(projectDir, row) {
|
|
999
|
+
await updateCrosswalkRows(projectDir, [row]);
|
|
394
1000
|
return row;
|
|
395
1001
|
}
|
|
1002
|
+
async function removeCrosswalkRow(projectDir, sourceStableKey) {
|
|
1003
|
+
await updateCrosswalkRows(projectDir, [], { remove: [sourceStableKey] });
|
|
1004
|
+
}
|
|
396
1005
|
|
|
397
1006
|
function foldAttempts(rows) {
|
|
398
1007
|
const byAttemptId = {};
|
|
@@ -405,18 +1014,169 @@ function foldAttempts(rows) {
|
|
|
405
1014
|
return byAttemptId;
|
|
406
1015
|
}
|
|
407
1016
|
|
|
408
|
-
|
|
409
|
-
|
|
1017
|
+
// The ONLY discriminator between the real ledger and the sample one is whether
|
|
1018
|
+
// live writes occur — never whether a record limit is set. A caller passes `{ sample: true }`
|
|
1019
|
+
// for a pass that writes nothing to the merchant's store; everything else, including a limited
|
|
1020
|
+
// but real pass, lands in the real journal.
|
|
1021
|
+
function attemptJournalPathFor(projectDir, { sample = false } = {}) {
|
|
1022
|
+
return sample ? sampleAttemptJournalPath(projectDir) : attemptJournalPath(projectDir);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
async function loadAttemptJournal(projectDir, options = {}) {
|
|
1026
|
+
const raw = await readNdjson(attemptJournalPathFor(projectDir, options));
|
|
1027
|
+
// Tolerate the identifier-only-in-message class on READ too, the same way `appendAttempt`/
|
|
1028
|
+
// `markAttempt` already tolerate it on write -- a row written before this validator existed
|
|
1029
|
+
// (or by any path other than those two) must not wedge every future read of a journal that is
|
|
1030
|
+
// never rewritten or trimmed. Any OTHER validation failure still throws, unchanged.
|
|
1031
|
+
const rows = raw.map((row) => {
|
|
1032
|
+
const result = tolerateIdentifierOnlyMessage(row);
|
|
1033
|
+
if (!result.ok) {
|
|
1034
|
+
throw new Error(result.errors.join('; '));
|
|
1035
|
+
}
|
|
1036
|
+
return result.row;
|
|
1037
|
+
});
|
|
1038
|
+
return { rows, byAttemptId: foldAttempts(rows) };
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// Reads only the bytes appended since `offset`, validating each new row the same
|
|
1042
|
+
// way `loadAttemptJournal` does (including the identifier-only-message tolerance), so a per-flush
|
|
1043
|
+
// coverage check can stay cheap without re-parsing the whole journal every time. Scoped to the
|
|
1044
|
+
// LIVE journal only -- never the sample one; the coverage check this exists for never reads
|
|
1045
|
+
// the sample journal. Throws a typed error (`error.code`) the caller maps onto the coverage check's reasons:
|
|
1046
|
+
// `JOURNAL_MISSING` (ENOENT), `JOURNAL_READ_FAILED` (any other read failure), or `JOURNAL_INVALID`
|
|
1047
|
+
// (a complete line that is not JSON, or fails `validateAttemptRow`/its identifier-only tolerance).
|
|
1048
|
+
async function readAttemptJournalSince(projectDir, offset = 0) {
|
|
1049
|
+
const filePath = attemptJournalPath(projectDir);
|
|
1050
|
+
let stat;
|
|
1051
|
+
try {
|
|
1052
|
+
stat = await fs.stat(filePath);
|
|
1053
|
+
} catch (error) {
|
|
1054
|
+
if (error && error.code === 'ENOENT') {
|
|
1055
|
+
const err = new Error(`${filePath} does not exist`);
|
|
1056
|
+
err.code = 'JOURNAL_MISSING';
|
|
1057
|
+
throw err;
|
|
1058
|
+
}
|
|
1059
|
+
const err = new Error(error.message);
|
|
1060
|
+
err.code = 'JOURNAL_READ_FAILED';
|
|
1061
|
+
err.cause = error;
|
|
1062
|
+
throw err;
|
|
1063
|
+
}
|
|
1064
|
+
// A journal shorter than the cached offset was truncated or replaced underneath the cache: the
|
|
1065
|
+
// caller must drop whatever it folded so far and do one full read, never read a negative range.
|
|
1066
|
+
const truncated = stat.size < offset;
|
|
1067
|
+
const readFrom = truncated ? 0 : offset;
|
|
1068
|
+
const length = stat.size - readFrom;
|
|
1069
|
+
let text = '';
|
|
1070
|
+
if (length > 0) {
|
|
1071
|
+
let fh = null;
|
|
1072
|
+
try {
|
|
1073
|
+
fh = await fs.open(filePath, 'r');
|
|
1074
|
+
const buffer = Buffer.alloc(length);
|
|
1075
|
+
await fh.read(buffer, 0, length, readFrom);
|
|
1076
|
+
text = buffer.toString('utf8');
|
|
1077
|
+
} catch (error) {
|
|
1078
|
+
const err = new Error(error.message);
|
|
1079
|
+
err.code = 'JOURNAL_READ_FAILED';
|
|
1080
|
+
err.cause = error;
|
|
1081
|
+
throw err;
|
|
1082
|
+
} finally {
|
|
1083
|
+
if (fh) {
|
|
1084
|
+
await fh.close();
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
// A partial trailing line -- the writer appended only part of the next row -- is left for the
|
|
1089
|
+
// next read and never parsed as if it were complete.
|
|
1090
|
+
const lastNewline = text.lastIndexOf('\n');
|
|
1091
|
+
const completeText = lastNewline === -1 ? '' : text.slice(0, lastNewline + 1);
|
|
1092
|
+
const nextOffset = readFrom + Buffer.byteLength(completeText, 'utf8');
|
|
1093
|
+
const rows = [];
|
|
1094
|
+
if (completeText) {
|
|
1095
|
+
for (const rawLine of completeText.split('\n')) {
|
|
1096
|
+
const line = rawLine.trim();
|
|
1097
|
+
if (!line) {
|
|
1098
|
+
continue;
|
|
1099
|
+
}
|
|
1100
|
+
let parsed;
|
|
1101
|
+
try {
|
|
1102
|
+
parsed = JSON.parse(line);
|
|
1103
|
+
} catch (error) {
|
|
1104
|
+
const err = new Error(`${filePath}: invalid NDJSON: ${error.message}`);
|
|
1105
|
+
err.code = 'JOURNAL_INVALID';
|
|
1106
|
+
err.line = line;
|
|
1107
|
+
throw err;
|
|
1108
|
+
}
|
|
1109
|
+
const result = tolerateIdentifierOnlyMessage(parsed);
|
|
1110
|
+
if (!result.ok) {
|
|
1111
|
+
const err = new Error(result.errors.join('; '));
|
|
1112
|
+
err.code = 'JOURNAL_INVALID';
|
|
1113
|
+
err.line = line;
|
|
1114
|
+
throw err;
|
|
1115
|
+
}
|
|
1116
|
+
rows.push(result.row);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return { rows, nextOffset, size: stat.size, truncated };
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
// Append only. `appendNdjson` (-> fs.appendFile) is the only writer, and there is no flag, env
|
|
1123
|
+
// var or mode that selects a truncating open against this path. Rotation and compaction are not
|
|
1124
|
+
// permitted: a journal is never rewritten, folded in place, or trimmed.
|
|
1125
|
+
async function appendAttempt(projectDir, row, options = {}) {
|
|
1126
|
+
row = stampSite(projectDir, row);
|
|
1127
|
+
const toWrite = withIdentifierRedactionRetry(row);
|
|
1128
|
+
await appendNdjson(attemptJournalPathFor(projectDir, options), toWrite);
|
|
1129
|
+
return toWrite;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// Latest row per source record, in file order. This is the fold that turns a
|
|
1133
|
+
// per-ROW file into per-RECORD counts; grouping the same rows by `runId` gives the per-PASS
|
|
1134
|
+
// counts instead. Both are derivable from the journal alone, which is the point.
|
|
1135
|
+
function foldAttemptsBySourceKey(rows) {
|
|
1136
|
+
const bySource = new Map();
|
|
410
1137
|
for (const row of rows) {
|
|
411
|
-
|
|
1138
|
+
if (row && row.sourceStableKey) {
|
|
1139
|
+
bySource.set(row.sourceStableKey, row);
|
|
1140
|
+
}
|
|
412
1141
|
}
|
|
413
|
-
return
|
|
1142
|
+
return bySource;
|
|
414
1143
|
}
|
|
415
1144
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
1145
|
+
// Rebuild `execution/unresolved-writes.ndjson` from the journal. Deleting this
|
|
1146
|
+
// file loses nothing — it is a projection, never a source of truth — so it is rewritten whole
|
|
1147
|
+
// and deterministically, and rebuilding it reproduces it byte for byte.
|
|
1148
|
+
//
|
|
1149
|
+
// A `deferred` row is NOT unresolved. Its next action is "reconsider once the blocker clears",
|
|
1150
|
+
// not "read the target back", and a source-data-rule skip must never reach this queue.
|
|
1151
|
+
async function rebuildUnresolvedWrites(projectDir) {
|
|
1152
|
+
const { rows } = await loadAttemptJournal(projectDir);
|
|
1153
|
+
const latest = foldAttemptsBySourceKey(rows);
|
|
1154
|
+
const queue = [];
|
|
1155
|
+
for (const row of latest.values()) {
|
|
1156
|
+
if (!UNRESOLVED_ATTEMPT_STATUSES.has(row.status)) {
|
|
1157
|
+
continue;
|
|
1158
|
+
}
|
|
1159
|
+
queue.push({
|
|
1160
|
+
schemaVersion: SCHEMA_VERSION,
|
|
1161
|
+
sourceStableKey: row.sourceStableKey,
|
|
1162
|
+
attemptId: row.attemptId,
|
|
1163
|
+
runId: row.runId,
|
|
1164
|
+
phase: row.phase,
|
|
1165
|
+
operation: row.operation,
|
|
1166
|
+
targetEntityType: row.targetEntityType,
|
|
1167
|
+
status: row.status,
|
|
1168
|
+
nextAction: 'read_target_back',
|
|
1169
|
+
failure: row.failure === undefined ? null : row.failure,
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
queue.sort((a, b) => a.sourceStableKey.localeCompare(b.sourceStableKey));
|
|
1173
|
+
const text = queue.map((row) => JSON.stringify(row)).join('\n') + (queue.length ? '\n' : '');
|
|
1174
|
+
await writeTextAtomic(unresolvedWritesPath(projectDir), text);
|
|
1175
|
+
return queue;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
async function loadUnresolvedWrites(projectDir) {
|
|
1179
|
+
return readNdjson(unresolvedWritesPath(projectDir));
|
|
420
1180
|
}
|
|
421
1181
|
|
|
422
1182
|
async function appendSafeModeEmailReplacement(projectDir, row) {
|
|
@@ -484,24 +1244,27 @@ function dryRunUpsertDecision({ localCrosswalkRow = null, requiresRevision = fal
|
|
|
484
1244
|
};
|
|
485
1245
|
}
|
|
486
1246
|
|
|
487
|
-
async function markAttempt(projectDir, attemptId, patch) {
|
|
1247
|
+
async function markAttempt(projectDir, attemptId, patch, options = {}) {
|
|
488
1248
|
if (!attemptId || typeof attemptId !== 'string') {
|
|
489
1249
|
throw new Error('attemptId must be a non-empty string');
|
|
490
1250
|
}
|
|
491
1251
|
assertObject(patch, 'attempt patch');
|
|
492
|
-
const journal = await loadAttemptJournal(projectDir);
|
|
1252
|
+
const journal = await loadAttemptJournal(projectDir, options);
|
|
493
1253
|
const current = journal.byAttemptId[attemptId];
|
|
494
1254
|
if (!current) {
|
|
495
1255
|
throw new Error(`unknown attemptId: ${attemptId}`);
|
|
496
1256
|
}
|
|
1257
|
+
// The follow-on row carries the `runId` and `phase` of the run APPENDING it,
|
|
1258
|
+
// which may differ from the row it supersedes. That is the point — it is how a later pass's
|
|
1259
|
+
// confirmation of an earlier pass's write stays legible.
|
|
497
1260
|
const row = {
|
|
498
1261
|
...current,
|
|
499
1262
|
...patch,
|
|
500
1263
|
attemptId,
|
|
501
1264
|
};
|
|
502
|
-
|
|
503
|
-
await appendNdjson(
|
|
504
|
-
return
|
|
1265
|
+
const toWrite = withIdentifierRedactionRetry(row);
|
|
1266
|
+
await appendNdjson(attemptJournalPathFor(projectDir, options), toWrite);
|
|
1267
|
+
return toWrite;
|
|
505
1268
|
}
|
|
506
1269
|
|
|
507
1270
|
async function rebuildCrosswalkIndexes(projectDir) {
|
|
@@ -589,29 +1352,94 @@ async function seedCrosswalkFromCmsMirror(projectDir, rows) {
|
|
|
589
1352
|
return { seeded: true, accepted: acceptedRows.length, rejected: rejected.length, conflicts: 0 };
|
|
590
1353
|
}
|
|
591
1354
|
|
|
592
|
-
|
|
1355
|
+
// The READ side of the crosswalk, and the single place a ledger row becomes
|
|
1356
|
+
// CMS-mirror item input. It lives here, once, rather than being re-derived inside every
|
|
1357
|
+
// generated project, because that is the seam that makes the mirror's item shape enforceable
|
|
1358
|
+
// instead of advisory.
|
|
1359
|
+
//
|
|
1360
|
+
// It is NOT a pass-through, and handing a raw ledger row to `buildImportCrosswalkItem` is a bug,
|
|
1361
|
+
// not a shortcut: the ledger names the fields `sourceEntityType`/`targetEntityType`, while
|
|
1362
|
+
// `buildImportCrosswalkItem` requires `entityType`/`targetType` and throws
|
|
1363
|
+
// 'buildImportCrosswalkItem: entityType and sourceId are required' without the first of them.
|
|
1364
|
+
//
|
|
1365
|
+
// It deliberately composes NO id. The mirror item id is `buildImportCrosswalkItem`'s own
|
|
1366
|
+
// `sourceStableKey`, with no project or source-instance prefix -- see the KNOWN, UNRESOLVED
|
|
1367
|
+
// LIMITATION comment on `buildImportCrosswalkItem` in rp-target-wix/lib/wix-writers.js. That cross-project collision is left open on purpose; it needs an approved identity/schema
|
|
1368
|
+
// decision of its own, not a prefix invented inside a writer or a projection.
|
|
1369
|
+
//
|
|
1370
|
+
// Layering: this module must not require rp-target-wix, so it returns the INPUTS
|
|
1371
|
+
// `buildImportCrosswalkItem` takes, and the caller does the build.
|
|
1372
|
+
function crosswalkRowsToMirrorItemInputs(rows) {
|
|
1373
|
+
if (!Array.isArray(rows)) {
|
|
1374
|
+
throw new Error('crosswalkRowsToMirrorItemInputs: rows must be an array of crosswalk rows');
|
|
1375
|
+
}
|
|
1376
|
+
return rows.map((row, i) => {
|
|
1377
|
+
assertObject(row, `crosswalk row ${i}`);
|
|
1378
|
+
return {
|
|
1379
|
+
entityType: row.sourceEntityType,
|
|
1380
|
+
sourceId: row.sourceId,
|
|
1381
|
+
sourceStableKey: row.sourceStableKey,
|
|
1382
|
+
targetId: row.targetId,
|
|
1383
|
+
targetType: row.targetEntityType,
|
|
1384
|
+
updatedAt: row.updatedAt,
|
|
1385
|
+
};
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
async function withStateLock(projectDir, fn, { script } = {}) {
|
|
593
1390
|
const lockPath = path.join(stateDir(projectDir), '.lock');
|
|
594
|
-
await mkdirp(
|
|
1391
|
+
await mkdirp(lockPath);
|
|
1392
|
+
const host = Buffer.from(require('node:os').hostname()).toString('base64url');
|
|
1393
|
+
// Unique claim files avoid deleting/replacing a directory another runner just acquired.
|
|
1394
|
+
// Publish the claim before scanning. Concurrent entrants see each other and at least
|
|
1395
|
+
// one backs off; a process that starts later always sees the active owner's claim.
|
|
1396
|
+
const claim = `${host}.${process.pid}.${require('node:crypto').randomUUID()}.owner`;
|
|
1397
|
+
const claimPath = path.join(lockPath, claim);
|
|
1398
|
+
// the claim used to carry only pid/host/acquiredAt, with no
|
|
1399
|
+
// record of WHICH script/writer acquired it. execution-health-check.js's hasLiveLocalProcess
|
|
1400
|
+
// trusted ANY live claim in the project as proof that the specific `--script` it was asked
|
|
1401
|
+
// about was alive -- a genuinely crashed run-import.js could be reported healthy merely because
|
|
1402
|
+
// an unrelated concurrent writer (e.g. run-extract.js) held its own live claim in the same
|
|
1403
|
+
// project. An explicit `script` identifies the claim; a caller that already knows its own
|
|
1404
|
+
// identity may pass it, and every current caller (product-import.js, contact-import.js) is
|
|
1405
|
+
// itself invoked from whichever file node is actually running as a script -- `process.argv[1]`
|
|
1406
|
+
// -- so that is the correct default with no call-site changes required.
|
|
1407
|
+
const scriptId = script || process.argv[1] || null;
|
|
1408
|
+
await fs.writeFile(claimPath, JSON.stringify({ pid: process.pid, host, acquiredAt: new Date().toISOString(), script: scriptId }), { flag: 'wx', mode: 0o600 });
|
|
595
1409
|
try {
|
|
596
|
-
await fs.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
throw new Error(`state lock
|
|
1410
|
+
for (const entry of await fs.readdir(lockPath)) {
|
|
1411
|
+
if (entry === claim) continue;
|
|
1412
|
+
const match = /^([^.]+)\.(\d+)\.[a-f0-9-]+\.owner$/.exec(entry);
|
|
1413
|
+
if (!match || match[1] !== host) throw new Error(`state lock owner cannot be checked locally: ${path.join(lockPath, entry)}; confirm that importer is stopped before removing its claim`);
|
|
1414
|
+
// `kill(2)` errors are EINVAL/EPERM/ESRCH only -- never ENOENT -- so the shared
|
|
1415
|
+
// `isProcessAlive` correctly folds every other-than-EPERM error into "dead" here.
|
|
1416
|
+
if (!isProcessAlive(Number(match[2]))) { await fs.rm(path.join(lockPath, entry), { force: true }); continue; }
|
|
1417
|
+
throw new Error(`state lock already held by PID ${match[2]}: ${lockPath}`);
|
|
600
1418
|
}
|
|
601
|
-
throw error;
|
|
602
|
-
}
|
|
603
|
-
try {
|
|
604
1419
|
return await fn();
|
|
605
1420
|
} finally {
|
|
606
|
-
await fs.rm(
|
|
1421
|
+
await fs.rm(claimPath, { force: true });
|
|
1422
|
+
// Keep the empty container: its existence is not ownership. SIGKILL leaves only
|
|
1423
|
+
// this process's uniquely named claim, which the next local process can reclaim.
|
|
607
1424
|
}
|
|
608
1425
|
}
|
|
609
1426
|
|
|
610
1427
|
module.exports = {
|
|
1428
|
+
onCrosswalkChange,
|
|
611
1429
|
SCHEMA_VERSION,
|
|
612
1430
|
stateDir,
|
|
613
1431
|
crosswalkPath,
|
|
614
1432
|
attemptJournalPath,
|
|
1433
|
+
sampleStateDir,
|
|
1434
|
+
sampleAttemptJournalPath,
|
|
1435
|
+
unresolvedWritesPath,
|
|
1436
|
+
ATTEMPT_STATUS,
|
|
1437
|
+
ATTEMPT_REQUIRED_FIELDS,
|
|
1438
|
+
UNRESOLVED_ATTEMPT_STATUSES,
|
|
1439
|
+
FAILURE_REQUIRED_STATUSES,
|
|
1440
|
+
foldAttemptsBySourceKey,
|
|
1441
|
+
rebuildUnresolvedWrites,
|
|
1442
|
+
loadUnresolvedWrites,
|
|
615
1443
|
wixRequestCapturesPath,
|
|
616
1444
|
cmsMirrorDir,
|
|
617
1445
|
safeModeDir,
|
|
@@ -621,8 +1449,13 @@ module.exports = {
|
|
|
621
1449
|
loadCrosswalk,
|
|
622
1450
|
appendCrosswalkRow,
|
|
623
1451
|
upsertCrosswalkRow,
|
|
1452
|
+
updateCrosswalkRows,
|
|
1453
|
+
removeCrosswalkRow,
|
|
624
1454
|
loadAttemptJournal,
|
|
1455
|
+
readAttemptJournalSince,
|
|
625
1456
|
appendAttempt,
|
|
1457
|
+
validateCrosswalkRow,
|
|
1458
|
+
validateAttemptRow,
|
|
626
1459
|
appendSafeModeEmailReplacement,
|
|
627
1460
|
appendSafeModeBlockedRecord,
|
|
628
1461
|
appendWixRequestCapture,
|
|
@@ -630,6 +1463,10 @@ module.exports = {
|
|
|
630
1463
|
appendDryRunCrosswalkRow,
|
|
631
1464
|
loadDryRunCrosswalk,
|
|
632
1465
|
dryRunUpsertDecision,
|
|
1466
|
+
RERUN_ACTIONS,
|
|
1467
|
+
rerunDecision,
|
|
1468
|
+
CONFIRMED_WRITE_OUTCOMES,
|
|
1469
|
+
nextCrosswalkBaseline,
|
|
633
1470
|
validateSafeModeEmailReplacementRow,
|
|
634
1471
|
validateSafeModeBlockedRecordRow,
|
|
635
1472
|
validateWixRequestCaptureRow,
|
|
@@ -638,5 +1475,7 @@ module.exports = {
|
|
|
638
1475
|
rebuildCrosswalkIndexes,
|
|
639
1476
|
localCrosswalkStateExists,
|
|
640
1477
|
seedCrosswalkFromCmsMirror,
|
|
1478
|
+
crosswalkRowsToMirrorItemInputs,
|
|
641
1479
|
withStateLock,
|
|
1480
|
+
isProcessAlive,
|
|
642
1481
|
};
|