Wix Replatform
WixOfficialPublished by Wix
- Skill
- Workflow
- Automation and integrations
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
wix-replatform acts as a central supervisor for migrating data and content to Wix. It does not perform migration tasks directly but instead inspects migration artifacts to determine the next required stage in the pipeline. By maintaining a deterministic state, it ensures that migrations can be started, resumed, or recovered reliably without duplicating work or creating redundant destination sites. It manages the flow through various phases including discovery, mapping, setup, and import, while enforcing strict validation and approval gates.
What it does
- Routes migration tasks to appropriate sub-modules based on current project state.
- Ensures resumability by tracking migration progress through authoritative artifacts.
- Enforces mandatory approval gates before performing write operations.
- Dispatches specialized subagents for specific tasks to maintain context boundaries.
- Validates artifacts at each stage to prevent proceeding with corrupted or stale data.
- Handles reruns for incremental data updates without re-scaffolding the entire project.
When to use it
- When initiating a new migration from an external source to a Wix site.
- When resuming a migration that was interrupted or stopped.
- When recovering from a failed migration stage by addressing specific errors.
- When performing incremental imports to sync new or modified records after an initial migration.
Advantages
- Prevents data duplication by enforcing idempotent write operations.
- Maintains a clear audit trail through structured telemetry and completion reports.
- Reduces risk by requiring explicit approvals before critical setup or import steps.
- Supports both standard interactive flows and automated 1-click execution modes.
Usage examples
- “Start a new migration for my project in ./migrations/my-store.”
- The agent resolves the project directory, initializes orchestration artifacts, and routes to the project intake module.
- “Resume the migration in ./migrations/my-store.”
- The agent inspects the existing artifacts, determines the last completed stage, and dispatches the next required module.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/wix/wix-replatform-fya3/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip wix-replatform.zip -d .agents/skills
Documentation by Wix
wix-replatform
wix-replatform is the compact supervisor for a resumable source-to-Wix migration. It
selects one internal module for the active stage; it does not carry every stage procedure
in its own context.
Always-active contract
Resolve the active project under
migrations/<project>/(orREPLATFORM_MIGRATIONS_DIR) before inspecting or creating anything. Only that project's artifacts are authoritative.Preserve
EXPECTATIONS.mdat that project root. It is the user's free-form record of how they expected the run to behave; initialization creates it once and never overwrites it.Start/resume
resources/rp-telemetry/at the beginning of every run and finalize it at a terminal state. Never hand-write telemetry events.Use orchestration JSON plus validated stage artifacts as resume authority. Logs and chat history are diagnostic context only.
Preserve user data: write idempotently, dedupe by source identity, resume rather than restart, and never create a second destination site for a migration.
Never print secrets, secret-bearing config contents, tokens, or credentials. Report only key names and present/blank/missing status.
Do not declare a migration complete from prose or a single artifact. The deterministic router and aggregate completion artifact own terminal completion.
Preserve the owner's cutover handoff: unresolved data, applicable manual setup, missing apps and changed plugin behavior. Reconcile discovery, mapping decisions, setup receipts and final outcomes; imported records alone do not establish working functionality. The producing resources own this guidance and durable completion/handoff artifacts. Use a supported cutover publisher when available; report missing publication integration explicitly rather than claiming the application received local artifacts.
CLI-launched runs and human actions
When a migration is started through replatform, the terminal is deliberately
non-interactive: do not use an agent question UI, ask for stdin, or wait for a person in the
current agent turn. The runner owns process lifecycle and emits only observed events; it does
not replace this skill's router or completion receipts.
When a human choice, review, approval, or manual prerequisite is needed, create a durable
request with node skills/wix-replatform/scripts/user-action.js create --project <projectDir> --request-file <request.json>, then end the turn. Put only reviewed artifact paths in the
request. The person can later use replatform requests, replatform show, and
replatform answer; a resumed agent reads the answered request from
orchestration/user-actions/, never from reconstructed chat context.
Cancellation is not completion. If the runner has recorded cancel_requested, canceled, interrupted or an explicit stop (blocked,
transition --status blocked --resume-from '<json>'; routes run_blocked until explicit resume or --status running, never answer --continue), preserve partial/recovery
artifacts and let a later explicit replatform resume route recovery. Never create aggregate migration completion from an aborted execution report.
Pipeline
intake → destination → source inputs → preflight → (standard: discovery → mapping → codegen;
quick: adapter preflight → quick plan) → setup discovery → website handoff
→ safety review/approval → setup → import
→ storefront continuation (website only) → aggregate finalization → Migration reviewDelivery modes are management (backend only), website (frontend only), and
management_and_website (the integrated flow above). Accept user input both as
management_and_website and persist the canonical value.
For deliveryMode=management, aggregate finalization requires valid backend import
accounting. For deliveryMode=management_and_website, it additionally requires a current
website/completion.json with completed screenshot review, no unresolved critical/high
gaps, and release evidence. execution/completion-report.json is backend accounting,
never website-migration completion by itself.
Route before acting
On every new or resumed turn:
Resolve the project and initialize/load its orchestration artifacts.
Run
node skills/wix-replatform/scripts/orchestration-route.js <projectDir>.Dispatch the
nextResourceto a Developer subagent instead of loading and following it yourself. Give it the project directory and the resource to run; it follows that resource's contract exactly as written, unchanged. Read back only its result — never its transcript, tool output, or logs.Every dispatch (Developer or QA) is a fresh subagent, never a resumed one; pass only a handoff file and stay within a context budget — follow
resources/rp-subagent-dispatch/. Never readstate/attempts/write-attempts.ndjsonraw; usescripts/write-log-summary.js.A Developer may fan out to sub-subagents only for harmless read-only work with no shared state, and only if the host supports it; writes stay one at a time, as each resource says.
Dispatch a QA subagent to check the Developer's result against that resource's own stated required outputs (its own "artifacts to create or update" or "## Output" section, and any review/gap documents it defines). QA is read-only — it never writes or calls Wix. If something's missing, dispatch a new Developer for the same resource with QA's findings; otherwise the stage is done.
At the end of each pipeline phase (discovery, mapping, setup discovery, import, and so on — see the pipeline above; a phase spans several resource-level stages), dispatch a QA subagent to review that phase's documents as a whole (for example
mapping/review/mapping-summary.mdandmapping-gaps.json, orexecution/completion-report.json) before routing to the next phase. This catches anything a single per-task check could miss. For the import phase specifically, this review must be entity-by-entity against the accepted mapping plan, not a skim of the top-level status string — seerp-execute-import's "Entity-by-entity QA" section. Any run-fixing dispatch mid-phase (a crash fix, a slowness fix, a resumed pass) does not itself satisfy this; run the phase-level QA again once the fix lands, since fixing one entity's defect certifies nothing about its neighbors. Mapping QA also checks exact source coverage, decided operation/path semantics and canonical projections. Codegen QA reads the Developer's independently expected synthetic request evidence and its freshness; it does not execute examples. Semantic defects return to mapper, implementation defects to codegen. One-click tests defer unresolved scope and finish independent work with a typed incomplete result, without questions or repeated redispatch; customer runs retain their existing checkpoints.Route again after every stage boundary. Stale requests use
resources/rp-user-action-recovery/; unreadable request artifacts block until repaired. Never discard pending requests or decide the next stage from memory.
The router (lib/orchestration-router.js) is the only routing and resume authority. It
recomputes the route from decisions, approvals, preflight, run.json status and the phase
outputs on every call; run.json.currentState is diagnostic only, never a routing input.
A recorded rejection stops the route in every mode, one-click included:
execution_approval_rejectedisblockedbefore any setup or import write, andmapping_approval_rejectedreturns torp-mapperfor a new plan.A gated output that exists but is unusable (
source_schema_invalid,mapping_plan_invalid,setup_plan_invalid,setup_requirements_invalid,execution_manifest_invalid) isblockedwitherrorsand the producer asnextResource. Do not re-run the producer automatically; report the errors to the Import Operator and stop.The import routes (
missing_completion_report,import_interrupted= a stopped run's aborted report,quick_mode_import_required) carryimportProgress.interruptedlistsrecoveryArtifacts: resume it, never a second import.interruptedReport: "missing": first runscripts/interrupted-completion-report.js.
If an artifact is malformed, partial, stale, or fails its validator, treat its producing stage as incomplete and route to the producer. Do not make parallel replacement artifacts.
A user action whose reviewed artifacts changed after it was created is refused with
user_action_stale and stays pending. Create a new request from the current artifacts.
Catching up a finished migration is a rerun, not a new project. When the user asks to pull
in records that arrived or changed since the import — "the source kept selling", "these orders
are missing", "re-run it" — reuse the same project, destination, mapping, generated importer
and crosswalk, and route to rp-execute-import → "Rerunning an import for new and modified
records". Do not scaffold a second project or re-approve an unchanged mapping; a
mapping or scope change does go back through the existing gates. A rerun's revision conflicts
are user decisions even in 1-click mode.
Demand-loaded module map
| Router situation | Dispatch |
|---|---|
| project, delivery mode, source mode, or grouped intake is unresolved | resources/rp-project-intake/ |
| destination is absent, conflicting, or needs creation/adoption | resources/rp-destination/ |
| source URL/files/config/acquisition mode/credentials are required, including source credentials said to exist already on another site | resources/rp-source-inputs/ |
| deterministic preflight is missing, repaired, or blocked on CLI checks | resources/rp-preflight/ |
| quick mode needs platform resolution, endpoint preflight, plan, extraction, or import | selected resources/rp-quick-<platform>/ |
| source schema is missing | resources/rp-discovery/ and its selected source adapter |
| mapping is missing or needs review | resources/rp-mapper/ |
| Wix requirements are missing | resources/rp-setup-discovery/ |
| import code/review is missing or stale | resources/rp-import-codegen/ |
| setup verification is missing | resources/rp-execute-setup/ |
| backend completion report is missing | resources/rp-execute-import/ |
| frontend-only work, or integrated website handoff/build/gap loop/release receipt is incomplete | resources/rp-website-continuation/ |
| aggregate completion is missing | resources/rp-execution-policy/ |
| aggregate completion exists but the local review publication or current recap is missing | resources/rp-migration-review/ |
The resource named by the route is the complete stage contract, dispatched as described in "Route before acting" — the main session itself never loads it directly. Only the dispatched Developer loads source-file, secret, scaffolding, or storefront procedures, and only for the stage that actually needs them; nothing about a stage where they're irrelevant is loaded, by the main session or the Developer.
Interaction policy
Normal mode asks only for a missing required input, a genuinely ambiguous active project, or a mandatory write approval. Ask one question at a time unless a module says otherwise.
When the user says add to expectations: <note> (or an unambiguous natural-language
equivalent), append the note to the active project's EXPECTATIONS.md before continuing.
Use scripts/expectations-ledger.js so the entry retains the supplied statement plus safe
current context (stage/state, relevant project-relative artifacts, and known entity/field
labels). Do not treat this as approval or silently change a mapping. Never record secrets,
tokens, raw customer data, or raw source records; redact them if supplied and say so.
Before writes, preserve the mandatory execution-plan approval gate. Read-only discovery, mapping, setup verification, code generation, and review happen before it.
Quick management import mode
When managementImportMode=quick, select the platform adapter only after the deterministic
source probe identifies a compatible platform. Quick mode is a bounded public-data import:
the adapter's versioned quick-mode.json owns its source routes, entity graph, field matrix,
and exclusions. Do not run agentic discovery, mapping, or project-specific code generation for
the quick backend branch. Still run destination setup, application installation, Catalog-V3 and
notification safety checks, execution approval, shared write runtime, crosswalks, and completion
accounting. If no adapter qualifies, persist the unsupported-mode result and ask the user to
select standard mode; never silently fall back.
Halt only for missing/invalid required input, a manual action with no API, or a systemic failure/data-loss risk. A halt must persist the code, evidence, owner, and exact unblock action; never silently stop.
1-click mode
When explicitly requested by the user, record automationMode=one_click with
source=user and apply the following. A missing mode or a one_click value recorded as
deterministic_inference/prior_artifact is normal interactive mode and must not skip a
checkpoint:
collect all still-missing intake values in one grouped request; then do not pause for routine approvals;
record mapping and execution approvals as
approved,decidedBy=agent; skipping a pause without state is invalid;for CSV/file-only runs, validate and accept the required sample preview as the agent; without explicit user-authored one-click, pause for the normal mapping review, sample preview validation, and execution approval;
default to a new isolated site unless an existing destination is explicitly supplied or already pinned, but never default the new site's type (Headless, Studio or Harmony): ask it in the grouped intake; choose website scope deterministically from discovered route families;
retry PATH/tool-resolution failures under the operator's compatible interactive login shell; request required browser/network sandbox escalation and retry before calling it blocked;
retry the obvious recovery before stopping: aligned shell first for PATH/tool failures, then the required escalation retry for sandboxed browser or network/API failures;
continue through the complete selected deliverable. In
management_and_websitemode that includes frontend build, post-build gap analysis, bounded fix loop, and release receipt; when the user selected facelift at intake, it also includes the separate post-clone facelift review;before yielding, re-route. A 1-click run is only
completedwithcompletion/migration-completion.json, orblockedwith a typed durable blocker.
Use the operator's compatible local Node/Yarn shell when recovering from a PATH or tool resolution failure. Machine-specific shell paths belong only in local, git-excluded agent instructions.
Repo-local interactive shell contract: a PATH/tool-resolution failure on first attempt may
mean the command ran under a plain, non-interactive shell that never sourced the operator's
Node/Yarn profile. Resolve the operator's compatible login shell from the local environment or
git-excluded agent instructions, verify that it is executable, and retry the exact same command
through that shell in interactive login mode so the profile that resolves node/yarn/npx
loads. Do not hardcode a machine-specific shell path in this public skill. Only escalate to a
durable blocker if the compatible-shell retry itself fails.
Guardrails
Never bypass a validator, approval-state update, verified notification mute, or Catalog-V3 gate to make a stage appear finished.
websitemeans frontend only;management_and_websitemeans the integrated backend and frontend migration. Never hand the integrated migration destination to the frontend skill or create a second frontend site in that mode.A Studio or Harmony destination (
targetSiteType) is created and verified byrp-destination's coordinator and is never published, unpublished or handed towix-headless-replatform; its website and publication remain operator handoff items.Do not implement a storefront manually when
wix-headless-replatformis unavailable; persist a blocker with the exact required runtime capability.In management mode, still generate
website/handoff.*after setup discovery so a later storefront can start without repeating backend discovery.
Files
- .publish-manifest.json210 B
- ATTRIBUTION.mdAdded by AutoGineer815 B
- CLI.md9.8 KiB
- LICENSELicence file added by AutoGineer1.0 KiB
- README.md11.9 KiB
- SKILL.md16.4 KiB
- VERSION6 B
- console/account.css633 B
- console/app.css5.2 KiB
- console/app.jsScript22.9 KiB
- console/index.html837 B
- console/json.css639 B
- lib/agent-adapters/index.jsScript2.9 KiB
- lib/app-page-routing.jsScript4.3 KiB
- lib/app-requirements.jsScript1.5 KiB
- lib/artifact-freshness.jsScript12.7 KiB
- lib/blocked-data-requests.jsScript21.4 KiB
- lib/cached-json.jsScript1.3 KiB
- lib/catalog-baseline.jsScript23.3 KiB
- lib/census-reconciliation.jsScript22.8 KiB
- lib/cms-collection-compatibility.jsScript2.0 KiB
- lib/completion-report.jsScript124.6 KiB
- lib/config-env.jsScript6.1 KiB
- lib/confirmed-pictures.jsScript6.9 KiB
- lib/crosswalk-adoption.jsScript6.3 KiB
- lib/dependency-proofs.jsScript46.7 KiB
- lib/dependency-readiness.jsScript112.3 KiB
- lib/dependency-recovery.jsScript1.5 KiB
- lib/dependency-waves.jsScript2.1 KiB
- lib/destination-choice.jsScript9.7 KiB
- lib/destination-handoff.jsScript12.5 KiB
- lib/destination-http.jsScript2.7 KiB
- lib/destination-route.jsScript5.1 KiB
- lib/destination.jsScript57.1 KiB
- lib/discovered-census.jsScript11.0 KiB
- lib/discovered-set-status.jsScript15.2 KiB
- lib/document-url-guard.jsScript12.7 KiB
- lib/editor-type.jsScript748 B
- lib/egress-proxy.jsScript20.8 KiB
- lib/entity-qa-attestation.jsScript19.4 KiB
- lib/entity-verification.jsScript1.3 KiB
- lib/execution-capability.jsScript7.3 KiB
- lib/execution-log.jsScript6.4 KiB
- lib/execution-manifest.jsScript10.2 KiB
- lib/execution-state.jsScript5.9 KiB
- lib/expectations-ledger.jsScript3.4 KiB
- lib/extract-ledger.jsScript21.4 KiB
- lib/field-mapping-examples.jsScript7.3 KiB
- lib/generated-plugin-handoff.jsScript8.7 KiB
- lib/import-interruption.jsScript13.6 KiB
- lib/import-readiness-contract.jsScript4.3 KiB
- lib/import-recovery.jsScript54.0 KiB
- lib/import-task-runner.jsScript18.1 KiB
- lib/imported-redirect-targets.jsScript32.5 KiB
- lib/internal-link-reconciliation.jsScript10.7 KiB
- lib/link-audit.jsScript11.1 KiB
- lib/link-census.jsScript11.0 KiB
- lib/link-plan.jsScript9.4 KiB
- lib/link-verification.jsScript18.7 KiB
- lib/link-waivers.jsScript5.8 KiB
- lib/link-write-journal.jsScript1.8 KiB
- lib/local-state.js66.8 KiB
- lib/mapping-field-contract.js54.1 KiB
- lib/mapping-omission-approval.js7.6 KiB
- lib/mapping-recovery.js22.4 KiB
- lib/mapping-resolution.js6.1 KiB
- lib/mapping-target-rules.js7.4 KiB
- lib/member-completion.js31.6 KiB
- lib/member-crosswalk.js2.9 KiB
- lib/member-outcome-registry.js13.6 KiB
- lib/migration-completion.js18.3 KiB
- lib/migration-review-mapping.js21.4 KiB
- lib/migration-review.js73.7 KiB
- lib/multi-step-attempt.js4.4 KiB
- lib/multilingual-public-report.js14.5 KiB
- lib/multilingual-public.js26.3 KiB
- lib/notification-mute.js9.9 KiB
- lib/operation-assessments.js9.8 KiB
- lib/operator-identity.js1.2 KiB
- lib/orchestration-decisions.js8.7 KiB
- lib/orchestration-preflight.js25.1 KiB
- lib/orchestration-router.js50.8 KiB
- lib/orchestration-state.js30.9 KiB
- lib/order-reference-readiness.js2.8 KiB
- lib/output-applicability.js5.0 KiB
- lib/payments-outcome-registry.js9.8 KiB
- lib/plan-order-outcome-registry.js13.1 KiB
- lib/plugin-cms-fallback.js35.1 KiB
- lib/preservation-approval-stamp.js2.8 KiB
- lib/product-media-deferral.js3.8 KiB
- lib/product-videos.js7.1 KiB
- lib/progress-log.js6.6 KiB
- lib/progress-log.sh4.1 KiB
- lib/raw-request-guard.js18.5 KiB
- lib/read-back-approval.js16.1 KiB
- lib/read-back-comparison.js10.5 KiB
- lib/read-back-contract.js37.4 KiB
- lib/read-back-extract.js4.0 KiB
- lib/read-back-gate.js46.6 KiB
- lib/read-back-reads.js2.9 KiB
- lib/read-back-state.js3.4 KiB
- lib/read-back-summary.js6.5 KiB
- lib/rerun-conflicts.js14.5 KiB
- lib/run-controller.js26.3 KiB
- lib/seo-outcome-registry.js3.2 KiB
- lib/setup-producers.js1.3 KiB
- lib/setup-verification.js11.6 KiB
- lib/site-regional-gate.js3.3 KiB
- lib/site-regional-report.js10.3 KiB
- lib/site-regional.js37.0 KiB
- lib/source-access.js11.2 KiB
- lib/source-coverage.js54.0 KiB
- lib/source-location.js10.6 KiB
- lib/source-redirect-capture.js2.6 KiB
- lib/source-regional.js15.5 KiB
- lib/source-secrets.js8.1 KiB
- lib/structured-link-patch.js3.1 KiB
- lib/subagent-handoff.js8.9 KiB
- lib/target-import-support.js18.4 KiB
- lib/task-state.js6.2 KiB
- lib/toolkit-dependencies.js947 B
- lib/url-preservation-report.js20.4 KiB
- lib/url-preservation-state.js27.0 KiB
- lib/url-redirect-plan.js36.3 KiB
- lib/url-verification.js15.5 KiB
- lib/user-action-effects.js2.9 KiB
- lib/user-actions.js18.4 KiB
- lib/vendor-closure.js5.6 KiB
- lib/website-handoff.js60.6 KiB
- lib/wix-auth.js11.0 KiB
- lib/wix-client-callers.js6.7 KiB
- lib/wix-dashboard-url.js1.0 KiB
- lib/write-log-summary.js9.4 KiB
- lib/write-verification-state.js7.9 KiB
- lib/write-verification.js30.0 KiB
- scripts/artifact-freshness.js2.3 KiB
- scripts/census-reconciliation.js781 B
- scripts/cms-fallback.js3.2 KiB
- scripts/cms-item-quota.js3.9 KiB
- scripts/crosswalk-adopt.js3.0 KiB
- scripts/dependency-preflight.js2.2 KiB
- scripts/discovered-census.js867 B
- scripts/discovered-set-status.js1.1 KiB
- scripts/entity-qa-attestation.js4.8 KiB
- scripts/execution-health-check.js19.9 KiB
- scripts/execution-manifest-validate.js1.7 KiB
- scripts/execution-state-prepare.js3.9 KiB
- scripts/expectations-ledger.js1.5 KiB
- scripts/extract-ledger.js1.9 KiB
- scripts/import-contract-verify.js20.4 KiB
- scripts/import-supervise.js16.1 KiB
- scripts/internal-link-audit.js6.5 KiB
- scripts/interrupted-completion-report.js2.7 KiB
- scripts/item-seo-tags-verify.js8.2 KiB
- scripts/link-waiver.js3.8 KiB
- scripts/migration-completion.js3.8 KiB
- scripts/migration-review.js3.7 KiB
- scripts/orchestration-preflight.js3.5 KiB
- scripts/orchestration-route.js3.7 KiB
- scripts/orchestration-state.js18.9 KiB
- scripts/read-back-gate.js11.3 KiB
- scripts/replatform-console.js12.9 KiB
- scripts/replatform.js35.4 KiB
- scripts/site-regional.js2.4 KiB
- scripts/source-secrets.js2.9 KiB
- scripts/subagent-handoff.js2.5 KiB
- scripts/url-redirects.js13.0 KiB
- scripts/user-action.js2.9 KiB
- scripts/vendor-closure.js1.0 KiB
- scripts/website-handoff-generate.js2.3 KiB
- scripts/wix-dashboard-url.js1.6 KiB
- scripts/wix-destination.js6.4 KiB
- scripts/wix-env.js1.5 KiB
- scripts/wix-headless-scaffold.js34.8 KiB
- scripts/write-log-summary.js2.2 KiB
- vendor/README.md604 B
- vendor/commander/LICENSE1.1 KiB
- vendor/commander/index.js711 B
- vendor/commander/lib/argument.js3.1 KiB
- vendor/commander/lib/command.js85.6 KiB
- vendor/commander/lib/error.js1.1 KiB
- vendor/commander/lib/help.js20.3 KiB
- vendor/commander/lib/option.js10.0 KiB
- vendor/commander/lib/suggestSimilar.js2.7 KiB
- vendor/commander/package.json1.6 KiB
lib/write-verification.js
'use strict';
const { isDeepStrictEqual } = require('node:util');
const crypto = require('node:crypto');
const { contactId, opaqueId } = require('./entity-verification');
const { normalizedDescriptionText } = require('../resources/rp-target-wix/lib/wix-build.js');
const { choiceNames } = require('../resources/rp-target-wix/lib/variant-correlation.js');
const email = value => typeof value === 'string' ? value.trim().toLowerCase() : value;
// Mirrors the same named+numeric HTML-entity decode every source adapter already needs for its
// own "plain text fields are HTML-entity-encoded but never DOM-parsed" trap (e.g.
// rp-import-codegen's product-transform.js decodeEntities): a source HTML body commonly carries
// numeric/hex entities (LIVE-VERIFIED: WooCommerce ships an en dash as `–`) that Wix's own
// server-side HTML->Ricos conversion decodes into the real character on read-back. Comparing
// visible text without first decoding the SENT side's entities the same way would see every such
// entity as a permanent mismatch, which is exactly the false failure this comparator exists to
// avoid. Kept local (not required from a project's transform code) because write-verification.js
// must not depend on any per-project generated file.
// Live-diagnosed gap (2026-09-28): a 6-entry map covered only the XML-reserved five plus nbsp.
// WordPress's own `wptexturize` (which runs on every post/product description by default)
// rewrites plain typography into exactly these named entities -- straight quotes into curly
// ones, `--`/`---` into en/em dashes, `...` into an ellipsis -- so real WooCommerce/WordPress
// content routinely contains `—`, `…`, `’`, `©`, and similar even when the
// author never typed a literal entity. Any of these left undecoded on the "expected" (sent) side
// while Wix's Ricos round-trip decodes them on the "actual" (read-back) side produced exactly the
// false verification mismatch this comparator was built to eliminate, just for a different name
// than the numeric-entity case it already handled. Extended to the common WordPress/WooCommerce
// typographic and symbol set, not just the XML-reserved five -- still a static table, not the
// full HTML5 named-character-reference list, because this file has no external dependency and a
// generated description is human-authored prose, not arbitrary markup.
const NAMED_HTML_ENTITIES = {
amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ',
// wptexturize's own typographic substitutions
mdash: '—', ndash: '–', hellip: '…',
lsquo: '‘', rsquo: '’', ldquo: '“', rdquo: '”',
sbquo: '‚', bdquo: '„', laquo: '«', raquo: '»',
// Common symbols that show up in product/blog copy
copy: '©', reg: '®', trade: '™', deg: '°',
plusmn: '±', times: '×', divide: '÷', middot: '·',
sect: '§', para: '¶', bull: '•', dagger: '†',
Dagger: '‡', permil: '‰', prime: '′', Prime: '″',
euro: '€', pound: '£', yen: '¥', cent: '¢', curren: '¤',
// BUG FIX: still no Latin-1 accented-letter entities -- common in
// WooCommerce/WordPress content authored or copy-pasted via older tools/CMSes. The full HTML4
// Latin-1-Supplement letter block, both cases (both are real, distinct named references).
agrave: 'à', aacute: 'á', acirc: 'â', atilde: 'ã', auml: 'ä', aring: 'å', aelig: 'æ', ccedil: 'ç',
egrave: 'è', eacute: 'é', ecirc: 'ê', euml: 'ë',
igrave: 'ì', iacute: 'í', icirc: 'î', iuml: 'ï',
eth: 'ð', ntilde: 'ñ',
ograve: 'ò', oacute: 'ó', ocirc: 'ô', otilde: 'õ', ouml: 'ö', oslash: 'ø',
ugrave: 'ù', uacute: 'ú', ucirc: 'û', uuml: 'ü',
yacute: 'ý', thorn: 'þ', yuml: 'ÿ', szlig: 'ß',
Agrave: 'À', Aacute: 'Á', Acirc: 'Â', Atilde: 'Ã', Auml: 'Ä', Aring: 'Å', AElig: 'Æ', Ccedil: 'Ç',
Egrave: 'È', Eacute: 'É', Ecirc: 'Ê', Euml: 'Ë',
Igrave: 'Ì', Iacute: 'Í', Icirc: 'Î', Iuml: 'Ï',
ETH: 'Ð', Ntilde: 'Ñ',
Ograve: 'Ò', Oacute: 'Ó', Ocirc: 'Ô', Otilde: 'Õ', Ouml: 'Ö', Oslash: 'Ø',
Ugrave: 'Ù', Uacute: 'Ú', Ucirc: 'Û', Uuml: 'Ü',
Yacute: 'Ý', THORN: 'Þ',
};
function decodeHtmlEntities(value) {
// BUG FIX: the numeric-hex branch's prefix was a literal lowercase `x`
// (`#x?`), with no `i` flag on the regex -- so an uppercase `—` matched neither
// alternative (the hex-prefix alternative requires the literal "x", and "X" is not itself a
// valid hex digit once the optional "x" fails to consume it) and was left completely
// undecoded, even though the handler below already anticipates `entity[1] === 'X'`. Widened to
// `#[xX]?` so both cases of the hex prefix match; the named-entity branch (`[a-zA-Z]+`) is
// deliberately left case-sensitive, since HTML named references are themselves case-sensitive
// (`&` is a valid reference, `&` is not) and NAMED_HTML_ENTITIES is keyed accordingly.
return String(value == null ? '' : value).replace(/&(#[xX]?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, entity) => {
if (entity[0] === '#') {
const code = entity[1] === 'x' || entity[1] === 'X' ? parseInt(entity.slice(2), 16) : parseInt(entity.slice(1), 10);
return Number.isFinite(code) ? String.fromCodePoint(code) : match;
}
return Object.prototype.hasOwnProperty.call(NAMED_HTML_ENTITIES, entity) ? NAMED_HTML_ENTITIES[entity] : match;
});
}
// BUG FIX: this used to strip ALL whitespace (`.replace(/\s+/g, '')`)
// on top of normalizedDescriptionText's own collapse-to-single-space -- which destroys the very
// word boundaries a re-serialization difference needs to be judged against. "Fresh Roasted Coffee
// Beans" (correct) and "FreshRoasted CoffeeBeans" (a genuine lost word boundary) both collapsed to
// the identical "FreshRoastedCoffeeBeans" once every space vanished, so a real word-merge/split
// corruption verified as a pass. normalizedDescriptionText already collapses every run of
// whitespace (including tag-boundary spaces introduced by stripping markup) to exactly one space
// and trims the ends -- since decodeHtmlEntities+normalizedDescriptionText run identically on both
// the sent and read-back sides, that single-space normalization is already symmetric and already
// tolerates markup/entity re-serialization; no further whitespace removal is needed or safe.
// Inline elements do not separate words when rendered ("<span>Brand</span><span>Acme</span>"
// displays "BrandAcme", and Stores V3 reads it back that way, LIVE-VERIFIED 2026-10-15), so they
// are removed without a space; every other tag still separates words.
const INLINE_TAG = /<\/?(?:a|abbr|b|bdi|bdo|cite|code|data|dfn|em|font|i|kbd|mark|q|s|samp|small|span|strong|sub|sup|time|u|var)\b[^>]*>/gi;
// Tags (and comments) are removed BEFORE entities are decoded: an attribute value may carry encoded
// markup (LIVE-OBSERVED 2026-10-22: class="[&:has(...)>*]:..." in descriptions pasted from a
// chat UI), and decoding first turns its > into a '>' that ends the tag early and leaks attribute
// text into the "visible" text. Wix renders only the element text, so a read-back never matched.
const stripMarkup = html => html.replace(/<!--[\s\S]*?-->/g, ' ').replace(/<[^>]*>/g, ' ');
const visibleDescriptionText = html => normalizedDescriptionText(decodeHtmlEntities(stripMarkup(String(html == null ? '' : html).replace(INLINE_TAG, ''))));
// LIVE-VERIFIED (2026-10-15): the stored Ricos description keeps every <br> as
// a "\n" text node, but the plainDescription read-back serializes a <br> run either as one
// space ("here<br />and" -> "here and", 2026-09-27) or as nothing, trimming the whitespace beside
// it ("Tools! <br><br>Next" -> "Tools!Next"). At a <br> position, accept exactly those two
// outcomes; every other character and every other whitespace must still match.
const BREAK_MARK = '\uE000';
const BREAK_RUN = /(?:\s| )*(?:<br\b[^>]*>(?:\s| )*)+/gi;
const escapeRegExp = value => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
function descriptionTextMatches(expectedHtml, actualHtml) {
const wantsText = visibleDescriptionText(expectedHtml);
const actualText = visibleDescriptionText(actualHtml);
if (wantsText === '') return false;
if (wantsText === actualText) return true;
const segments = visibleDescriptionText(String(expectedHtml).replace(BREAK_RUN, ` ${BREAK_MARK} `)).split(new RegExp(`\\s*${BREAK_MARK}\\s*`));
if (segments.length < 2) return false;
return new RegExp(`^${segments.map(escapeRegExp).join(' ?')}$`).test(actualText);
}
const digest = value => crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex');
const own = (o, k) => o != null && Object.prototype.hasOwnProperty.call(o, k);
// Expected fields come from the source projection. Extra server fields do not satisfy
// missing fields, and null/empty/false/zero remain distinct. No heuristic normalization.
function assertProjection(value, path = 'expected') {
if (value === undefined) throw new Error(`Undefined verification value at ${path}; omit the key or supply an explicit JSON value`);
if (value && typeof value === 'object') {
if (Array.isArray(value)) for (let i = 0; i < value.length; i++) assertProjection(value[i], `${path}[${i}]`);
else for (const [key, child] of Object.entries(value)) assertProjection(child, `${path}.${key}`);
}
}
// LIVE-VERIFIED (2026-10-20, live product canary): Stores V3 accepts `displayName` on a
// url-set media item but never returns it on read -- neither on the item nor under item.image.
// The ingested file keeps a name in `image.filename` (extension included), so that is the
// per-item name that survives the rehost. A sent displayName is matched by, in order:
// an echoed displayName (exact), else the filename whose stem (or whole name) equals the
// displayName as the writer sends it (trimmed, at most 80 characters), or the filename equal to
// the sent url's own decoded file name. Anything else -- no filename, a different file, a swapped
// slot -- does not match. Counting items never stands in for this check.
const MEDIA_DISPLAY_NAME_SENT_MAX = 80;
function sentUrlFileName(url) {
if (typeof url !== 'string') return undefined;
try {
const name = new URL(url).pathname.split('/').pop();
return name ? decodeURIComponent(name) : undefined;
} catch { return undefined; }
}
function mediaItemNameMatches(item, child) {
const sent = item.displayName.trim().slice(0, MEDIA_DISPLAY_NAME_SENT_MAX);
const echoed = child?.displayName || child?.image?.displayName || child?.video?.displayName;
if (typeof echoed === 'string' && echoed !== '') return echoed === item.displayName || echoed === sent;
const filename = child?.image?.filename || child?.video?.filename;
if (typeof filename !== 'string' || filename === '') return false;
const stem = filename.replace(/\.[^./]+$/, '');
// LIVE-VERIFIED (2026-10-22): the stored file name replaces each '"' of the sent title with '_'.
const stored = sent.replace(/"/g, '_');
return filename === sent || stem === sent || stem === stored || filename === stored || filename === sentUrlFileName(item.url);
}
// LIVE-VERIFIED (2026-10-21): a PHYSICAL product is created with the required empty
// product-level physicalProperties, and Stores V3 reads it back with a shippingWeightRange it
// derives from the variant weights. Only that server-derived key is tolerated beside an empty
// expected object; variant weights are still compared where they were sent.
const SERVER_DERIVED_PHYSICAL_KEYS = new Set(['shippingWeightRange']);
const onlyServerPhysical = a => a !== null && typeof a === 'object' && !Array.isArray(a) && Object.keys(a).every(k => SERVER_DERIVED_PHYSICAL_KEYS.has(k));
// LIVE-VERIFIED (2026-10-21): variant choices sent as optionChoiceNames read back as
// optionChoiceIds. The comparison view resolves them through the product's option/choice
// dictionary; an id that does not resolve to exactly one option and choice stays as returned, so
// it cannot match a sent name.
// LIVE-VERIFIED (2026-10-31): Stores V3 reads a variant's stock flag back as
// inventoryStatus.inStock, not under the inventoryItem the writer sent it in; the view places the
// read flag where it was sent. A read that does carry inventoryItem.inStock is left as returned.
function variantInventoryView(variant) {
const inStock = variant?.inventoryStatus?.inStock;
if (typeof inStock !== 'boolean' || variant.inventoryItem?.inStock !== undefined) return variant;
return { ...variant, inventoryItem: { ...(variant.inventoryItem || {}), inStock } };
}
function variantComparisonView(variant, product) {
const view = variantInventoryView(variant);
if (!Array.isArray(view?.choices)) return view;
try {
return { ...view, choices: view.choices.map(c => c?.optionChoiceNames ? c : { optionChoiceNames: choiceNames(c, product) }) };
} catch { return view; }
}
// LIVE-VERIFIED (2026-10-21, Tuti first-batch probe): the Media Manager file created from a
// url-set product media item keeps the sent displayName with the ORIGINAL file's extension
// appended ("ceramic-mug" -> "ceramic-mug.jpg" for source file ceramic-mug-1.jpg). A title landed
// when the stored name equals it exactly, or equals it plus that file's own extension. The
// original file name, another extension or a case-changed title does not count.
function mediaTitleLanded(landedName, sentItem) {
if (typeof landedName !== 'string' || !sentItem || typeof sentItem.displayName !== 'string' || sentItem.displayName === '') return false;
if (landedName === sentItem.displayName) return true;
const ext = (sentUrlFileName(sentItem.url) || '').match(/\.[A-Za-z0-9]{1,5}$/);
return Boolean(ext) && landedName === `${sentItem.displayName}${ext[0]}`;
}
// A within-write media dependency is verified per intended item, never by counting: every sent
// item must have landed as its own type in its slot, and the same comparator product read-back
// uses must match its altText/displayName evidence. Two slots holding one media ID are a
// substitution unless both slots were sent the same source URL (a repeated source image). An item
// sent with neither altText nor displayName has no surviving identity, so it cannot be verified.
function correlateProductMedia(expectedItems, actualItems) {
if (!Array.isArray(expectedItems) || !expectedItems.length) throw new Error('correlateProductMedia: expectedItems must be a non-empty array');
const blank = value => typeof value !== 'string' || value.trim() === '';
if (expectedItems.some(item => !item || blank(item.altText) && blank(item.displayName))) return { verified: false, correlatable: false, reasons: ['media-identity-uncorrelatable'], mediaIds: [] };
const items = Array.isArray(actualItems) ? actualItems : [];
const mediaIds = items.map(item => item?.mediaType === 'VIDEO' ? item.video?.id : (item?.mediaType === undefined || item?.mediaType === 'IMAGE') ? item.image?.id : undefined);
const reasons = [];
if (items.length !== expectedItems.length) reasons.push('media-count-mismatch');
expectedItems.forEach((item, i) => { if (!mediaIds[i]) reasons.push(`media-not-landed:${i}`); });
const comparison = compareProjection({ media: { itemsInfo: { items: expectedItems } } }, { media: { itemsInfo: { items } } });
for (const check of comparison.checks) if (!check.matches) reasons.push(`media-mismatch:${check.path}`);
for (let i = 0; i < mediaIds.length; i++) for (let j = i + 1; j < mediaIds.length; j++) {
if (mediaIds[i] && mediaIds[i] === mediaIds[j] && expectedItems[i]?.url !== expectedItems[j]?.url) reasons.push(`media-duplicate-substitution:${i}:${j}`);
}
return { verified: reasons.length === 0, correlatable: true, reasons: [...new Set(reasons)], mediaIds };
}
function leafScore(wanted, actual) {
if (wanted && typeof wanted === 'object') return Object.entries(wanted).reduce((n, [k, v]) => n + leafScore(v, actual?.[k]), 0);
return isDeepStrictEqual(wanted, actual) ? 1 : 0;
}
// Pairs an unordered list one to one (Contacts V5 address items). `matches` must be
// the caller's own final comparison of one item, so pairing can never disagree with it. Full matches come
// from a maximum bipartite matching, so a less specific item never takes the only actual item a
// more specific one can match. A wanted item left without a full match is paired with its most
// similar leftover actual item, so a changed field reports as changed, not dropped; with none
// left it pairs with undefined. Returns [wanted, actual | undefined] in wanted order.
function pairUnordered(wanted, actual, matches) {
if (typeof matches !== 'function') throw new Error('pairUnordered requires the caller\'s item comparison');
const pool = Array.isArray(actual) ? actual : [];
const owner = new Array(pool.length).fill(-1);
const assign = (i, seen) => {
for (let j = 0; j < pool.length; j++) {
if (seen[j] || !matches(wanted[i], pool[j])) continue;
seen[j] = true;
if (owner[j] < 0 || assign(owner[j], seen)) { owner[j] = i; return true; }
}
return false;
};
for (let i = 0; i < wanted.length; i++) assign(i, new Array(pool.length).fill(false));
const pairedTo = new Array(wanted.length).fill(-1);
owner.forEach((i, j) => { if (i >= 0) pairedTo[i] = j; });
const free = new Set(pool.map((_, j) => j).filter(j => owner[j] < 0));
for (let i = 0; i < wanted.length; i++) {
if (pairedTo[i] >= 0 || !free.size) continue;
let best = -1, bestScore = -1;
for (const j of free) { const score = leafScore(wanted[i], pool[j]); if (score > bestScore) { best = j; bestScore = score; } }
pairedTo[i] = best; free.delete(best);
}
return wanted.map((item, i) => [item, pairedTo[i] >= 0 ? pool[pairedTo[i]] : undefined]);
}
function compareProjection(expected, actual, options = {}) {
assertProjection(expected);
const checks = projectionChecks(expected, actual, options);
return { verified: checks.length > 0 && checks.every(c => c.matches), checks };
}
// The comparison itself, also used to pair one unordered item with its own rules.
function projectionChecks(expected, actual, { kind = '', path = '' } = {}) {
const checks = [];
const itemVerifies = (e, a, p) => { const sub = projectionChecks(e, a, { kind, path: p }); return sub.length > 0 && sub.every(c => c.matches); };
function compare(e, a, p, present) {
if (kind === 'contact' && p === 'email.email') {
checks.push({ path: p, matches: present && email(e) === email(a) });
} else if (p === 'plainDescription' && typeof e === 'string') {
// LIVE-VERIFIED (2026-09-27): Stores V3's Get Product does not
// echo plainDescription -- it converts the HTML to a Ricos document server-side and reads
// back a RE-SERIALIZATION of that document, not the sent bytes (e.g. a source <strong>
// becomes <span style="font-weight: 700">, and HTML entities get decoded). That is Wix's
// own conversion, unavoidable and benign, so this leaf compares VISIBLE TEXT -- the same
// extractor wix-build.js's composeProductDescription uses to decide whether a description
// is real content -- never markup. A genuinely different or lost description still fails:
// this tolerates re-serialization, not a text change, and never passes on empty text.
checks.push({ path: p, matches: present && typeof a === 'string' && descriptionTextMatches(e, a) });
} else if (/(^|\.)amount$/.test(p) && typeof e === 'string' && /^-?\d+(\.\d+)?$/.test(e.trim())) {
// LIVE-VERIFIED (2026-10-15): Stores V3 normalizes decimal strings on
// read-back -- a sent price "65.00" comes back "65", "21.20" comes back "21.2". The money
// value is identical, so an amount leaf compares numerically; a different amount (or a
// missing / non-numeric one) still fails.
checks.push({ path: p, matches: present && typeof a === 'string' && /^-?\d+(\.\d+)?$/.test(a.trim()) && Number(e) === Number(a) });
} else if (Array.isArray(e) && /(^|\.)media\.itemsInfo\.items$/.test(p)) {
// LIVE-VERIFIED (2026-09-27): every product image is rehosted
// to Wix's own CDN (static.wixstatic.com) under a server-minted id/url the instant it
// ingests -- expected, unavoidable platform behavior, not data loss. The url this
// comparator sent will therefore never appear in the read-back, so identity here is never
// the url (or a filename derived from it): it is the item COUNT, plus -- for whichever
// items the writer's own record shows we asked to carry alt text -- that altText survives
// the rehost verbatim (LIVE-VERIFIED: Wix echoes it back exactly, both on the item itself
// and nested under item.image). A missing/extra image, or a changed altText, still fails.
//
// KNOWN LIMITATION: this cannot detect two
// images swapped between slots, or an entirely wrong image landing in a slot, when neither
// altText nor displayName was set on the sent side -- common for sources with no alt text.
// `buildMedia` (wix-build.js) sends only `{url, altText, displayName}` per item; the sent
// `url` is the ONLY other candidate per-item identity and it is exactly the field this
// comment already establishes never survives the rehost, so nothing else is available to
// compare here without new information from Wix's API. This check also assumes rehosted
// items keep the SENT order (`a[i]` correlates to `e[i]` throughout this block) -- that
// assumption is undocumented and has not been independently live-verified either; if Wix's
// rehost does not preserve order, the existing altText/displayName checks below could
// already be comparing against the wrong item, not just this count check.
checks.push({ path: p, matches: Array.isArray(a) && e.length === a.length });
e.forEach((item, i) => {
const child = Array.isArray(a) ? a[i] : undefined;
const alt = item && typeof item === 'object' ? item.altText : undefined;
if (typeof alt === 'string' && alt.trim() !== '') {
// `??` only falls through on null/undefined -- an actual side that carries altText as
// an EMPTY STRING (the rehost keeping the field but losing its value) must still count
// as "did not survive", the same as a missing field entirely. `||` falls through on any
// falsy value, which is what "only check the field when non-empty" means everywhere else
// in this comparator (see isBlank-style checks in wix-build.js).
const actualAlt = child?.altText || child?.image?.altText;
checks.push({ path: `${p}[${i}].altText`, matches: Boolean(child) && actualAlt === alt });
}
// wix-build.js's buildMedia writes displayName on every media item it constructs whenever
// the source record has one (domains/stores/entities/product.json: displayName "must not
// be flattened away"). Only check it when the writer's own record shows we asked to carry
// it -- the same "only check what we actually asked for" pattern altText uses above -- so
// a product with no displayName at all is never penalized for it being absent. Wix does
// not echo displayName; see mediaItemNameMatches for what stands in for it on read.
const displayName = item && typeof item === 'object' ? item.displayName : undefined;
if (typeof displayName === 'string' && displayName.trim() !== '') {
checks.push({ path: `${p}[${i}].displayName`, matches: Boolean(child) && mediaItemNameMatches(item, child) });
}
});
} else if (Array.isArray(e) && kind === 'contact' && p === 'addresses') {
// Contact addresses are an unordered set; the read-back comparison pairs them the same way.
checks.push({ path: p, matches: Array.isArray(a) && e.length === a.length });
pairUnordered(e, a, (v, candidate) => itemVerifies(v, candidate, `${p}[]`)).forEach(([v, match], i) => compare(v, match, `${p}[${i}]`, match !== undefined));
} else if (Array.isArray(e)) {
checks.push({ path: p, matches: Array.isArray(a) && e.length === a.length });
e.forEach((v, i) => compare(v, a?.[i], `${p}[${i}]`, Array.isArray(a) && i < a.length));
} else if (e && typeof e === 'object') {
if (!Object.keys(e).length && p === 'physicalProperties') checks.push({ path: p, matches: present && onlyServerPhysical(a) });
else if (!Object.keys(e).length) checks.push({ path: p, matches: present && isDeepStrictEqual(e, a) });
else for (const [k, v] of Object.entries(e)) compare(v, a?.[k], p ? `${p}.${k}` : k, own(a, k));
} else checks.push({ path: p, matches: present && isDeepStrictEqual(e, a) });
}
compare(expected, actual, path, actual !== undefined);
return checks;
}
function contactIdentity(expected, actual, id) {
const checks = [{ path: 'id', matches: contactId(id) && actual?.id === id && !actual?._dryRunPlaceholder }];
const hasExternal = typeof expected?.externalId === 'string' && expected.externalId.trim() !== '';
const hasEmail = typeof expected?.email?.email === 'string' && email(expected.email.email) !== '';
checks.push({ path: 'source-identity', matches: hasExternal || hasEmail });
if (hasExternal) checks.push({ path: 'externalId', matches: actual?.externalId === expected.externalId });
if (hasEmail) checks.push({ path: 'email.email', matches: email(actual?.email?.email) === email(expected.email.email) });
return { verified: checks.every(c => c.matches), checks };
}
function verifyContact(expected, actual, id) {
const identity = contactIdentity(expected, actual, id);
const values = compareProjection(expected, actual, { kind: 'contact' });
return { verified: identity.verified && values.verified, checks: [...identity.checks, ...values.checks] };
}
function subscriptionExpected(product) {
const value = product?.subscriptionDetails;
const entries = value?.subscriptions;
if (!Array.isArray(entries) || !entries.length || entries.some(s => !s?.title) || new Set(entries.map(s => s.title)).size !== entries.length) {
throw new Error('Subscription verification requires nonempty, uniquely titled subscriptions');
}
if (typeof value.allowOneTimePurchases !== 'boolean' || entries.some(s =>
!['title', 'description', 'frequency', 'interval', 'autoRenewal'].every(k => own(s, k)))) {
throw new Error('Subscription verification requires the complete expected field projection');
}
return JSON.parse(JSON.stringify(value));
}
function verifySubscriptionEvidence(evidence) {
try {
if (!evidence || evidence.dryRun || !opaqueId(evidence.targetId)) throw new Error('Invalid evidence');
const expected = subscriptionExpected({ subscriptionDetails: evidence.expected });
const actual = evidence.actual;
const entries = actual?.subscriptionDetails?.subscriptions;
const checks = [{ path: 'product.id', matches: actual?.id === evidence.targetId && !actual?._dryRunPlaceholder },
{ path: 'subscriptionDetails.subscriptions.length', matches: Array.isArray(entries) && entries.length === expected.subscriptions.length },
{ path: 'subscriptionDetails.allowOneTimePurchases', matches: actual?.subscriptionDetails?.allowOneTimePurchases === expected.allowOneTimePurchases }];
for (const wanted of expected.subscriptions) {
const matches = (entries || []).filter(s => s?.title === wanted.title);
const entry = matches.length === 1 ? matches[0] : undefined;
checks.push({ path: `subscriptions:${wanted.title}.id`, matches: matches.length === 1 && opaqueId(entry?.id) });
checks.push(...compareProjection(wanted, entry, { path: `subscriptions:${wanted.title}` }).checks);
}
return { verified: checks.every(c => c.matches), checks };
} catch { return { verified: false, checks: [{ path: 'evidence', matches: false }] }; }
}
function verifyProduct(expected, actual, id, { marker, variants = [] } = {}) {
const checks = [{ path: 'id', matches: opaqueId(id) && actual?.id === id && !actual?._dryRunPlaceholder }];
// Marker must have been selected from the source, not filled from the returned entity.
checks.push({ path: 'source-marker', matches: Boolean(marker?.path) && marker.value !== undefined && marker.value !== '' });
if (marker?.path) {
const value = marker.path.split('.').reduce((v, k) => v?.[k], actual);
checks.push({ path: marker.path, matches: isDeepStrictEqual(marker.value, value) });
}
checks.push(...compareProjection(expected, actual).checks);
const targetVariants = actual?.variantsInfo?.variants;
const seen = new Set();
for (const v of variants) {
const matches = (targetVariants || []).filter(t => t?.id === v.variantId);
checks.push({ path: `variant:${v.variantId}`, matches: opaqueId(v.variantId) && !seen.has(v.variantId) && matches.length === 1 });
seen.add(v.variantId);
checks.push(...compareProjection(v.expected, variantComparisonView(matches[0], actual)).checks);
}
return { verified: checks.every(c => c.matches), checks };
}
const CONTRACT_DIGEST = digest({ version: 1, contact: 'source-key/externalId+email/exact-values', product: 'source-marker/variant-id/exact-values' });
function receipt({ siteId, sourceKey, kind, expected, targetId, actual, marker, variants, operation, attempts = 1, dryRun = false }) {
const comparison = kind === 'contact' ? verifyContact(expected, actual, targetId) : verifyProduct(expected, actual, targetId, { marker, variants });
return { schemaVersion: 1, siteId, sourceKey, kind, targetId, expected, actual, marker, variants, operation, attempts, dryRun,
payloadDigest: digest({ expected, marker, variants }), contractDigest: CONTRACT_DIGEST,
...comparison, verified: !dryRun && Boolean(siteId && sourceKey && operation) && comparison.verified };
}
function validReceipt(r, context = {}) {
if (!r || r.schemaVersion !== 1 || !['contact', 'product'].includes(r.kind) || !r.verified || r.dryRun || r.contractDigest !== CONTRACT_DIGEST) return false;
if (!r.expected || r.payloadDigest !== digest({ expected: r.expected, marker: r.marker, variants: r.variants })) return false;
for (const key of ['siteId', 'sourceKey', 'targetId', 'payloadDigest', 'kind']) if (context[key] !== undefined && r[key] !== context[key]) return false;
try { return receipt(r).verified; } catch { return false; }
}
module.exports = { assertProjection, email, digest, compareProjection, pairUnordered, correlateProductMedia, variantComparisonView, onlyServerPhysical, mediaTitleLanded, contactIdentity, verifyContact, subscriptionExpected,
verifySubscriptionEvidence, verifyProduct, receipt, validReceipt, CONTRACT_DIGEST };
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Wix
- Publisher
- Wix (Official)
- Source
- wix/skills · skills/wix-replatform · commit d168bc2
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Wix.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download wix-replatform.zip