@aglyn/plugins-commerce 1.29.0 → 1.29.2
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/package.json +13 -13
- package/src/lib/components/console/checkout-tax-blocked-notice.component.d.ts +18 -0
- package/src/lib/components/console/checkout-tax-blocked-notice.component.js +67 -0
- package/src/lib/components/console/checkout-tax-blocked-notice.component.js.map +1 -0
- package/src/lib/components/console/payments-settings-card.component.d.ts +2 -2
- package/src/lib/components/console/payments-settings-card.component.js +99 -5
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +14 -3
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/stripe-tax-readiness.component.d.ts +45 -0
- package/src/lib/components/console/stripe-tax-readiness.component.js +276 -0
- package/src/lib/components/console/stripe-tax-readiness.component.js.map +1 -0
- package/src/lib/components/console/tax-settings-card.component.js +22 -8
- package/src/lib/components/console/tax-settings-card.component.js.map +1 -1
- package/src/lib/constants/operator-alerts.d.ts +9 -0
- package/src/lib/constants/operator-alerts.js +22 -1
- package/src/lib/constants/operator-alerts.js.map +1 -1
- package/src/lib/declarations.server.js +11 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/commerce-tax-readiness.d.ts +79 -0
- package/src/lib/model/commerce-tax-readiness.js +99 -0
- package/src/lib/model/commerce-tax-readiness.js.map +1 -0
- package/src/lib/model/commerce.d.ts +7 -0
- package/src/lib/model/commerce.js +17 -4
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/payments-setup-status.d.ts +68 -0
- package/src/lib/model/payments-setup-status.js +103 -0
- package/src/lib/model/payments-setup-status.js.map +1 -0
- package/src/lib/plan-entitlements.d.ts +2 -1
- package/src/lib/plan-entitlements.js +2 -1
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/server/cart-checkout.js +3 -0
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/checkout-tax-refusal.d.ts +51 -0
- package/src/lib/server/checkout-tax-refusal.js +133 -0
- package/src/lib/server/checkout-tax-refusal.js.map +1 -0
- package/src/lib/server/checkout.d.ts +2 -1
- package/src/lib/server/checkout.js +7 -2
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/connect-prefill.d.ts +65 -0
- package/src/lib/server/connect-prefill.js +85 -0
- package/src/lib/server/connect-prefill.js.map +1 -0
- package/src/lib/server/connect.d.ts +4 -2
- package/src/lib/server/connect.js +117 -37
- package/src/lib/server/connect.js.map +1 -1
- package/src/lib/server/draft-order.js +4 -2
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/pos-order.js +1 -1
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/product-writer.d.ts +27 -0
- package/src/lib/server/product-writer.js +174 -4
- package/src/lib/server/product-writer.js.map +1 -1
- package/src/lib/server/quote-pay.d.ts +6 -0
- package/src/lib/server/quote-pay.js +8 -2
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/seller-stripe-account.d.ts +19 -0
- package/src/lib/server/seller-stripe-account.js +40 -4
- package/src/lib/server/seller-stripe-account.js.map +1 -1
- package/src/lib/server/site-page-resolver.d.ts +1 -6
- package/src/lib/server/site-page-resolver.js +4 -12
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/site-search.d.ts +43 -0
- package/src/lib/server/site-search.js +124 -0
- package/src/lib/server/site-search.js.map +1 -0
- package/src/lib/server/tax-readiness.d.ts +56 -0
- package/src/lib/server/tax-readiness.js +169 -0
- package/src/lib/server/tax-readiness.js.map +1 -0
- package/src/lib/server.js +6 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/transfer/product-image-copy.server.d.ts +77 -0
- package/src/lib/transfer/product-image-copy.server.js +307 -0
- package/src/lib/transfer/product-image-copy.server.js.map +1 -0
- package/src/lib/transfer/product-images.d.ts +62 -0
- package/src/lib/transfer/product-images.js +143 -0
- package/src/lib/transfer/product-images.js.map +1 -0
- package/src/lib/transfer/product-sources.d.ts +92 -0
- package/src/lib/transfer/product-sources.js +519 -0
- package/src/lib/transfer/product-sources.js.map +1 -0
- package/src/lib/transfer/product-transfer.d.ts +26 -1
- package/src/lib/transfer/product-transfer.js +283 -11
- package/src/lib/transfer/product-transfer.js.map +1 -1
- package/src/lib/transfer/products.server.d.ts +29 -3
- package/src/lib/transfer/products.server.js +289 -13
- package/src/lib/transfer/products.server.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/transfer/product-sources.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TransferAliasDictionary, TransferPlanRow } from '@aglyn/aglyn/data-transfer'\n\n/*==========================================\n * WIX AND SQUARESPACE PRODUCT FILES (AGL-4245).\n *\n * A Shopify product CSV is laid out the way an Aglyn one is (a row per\n * variant, the product's fields on its first row, a handle on every row), so\n * its columns only need names (`SHOPIFY_PRODUCT_COLUMNS`). A Wix or\n * Squarespace export is recognized the same way, by an alias dictionary of\n * its own column names, so the Columns step maps it with nothing to pick.\n * What the two files MEAN differs from that layout, and is read here before\n * the plan, by the file's header signature:\n *\n * - **Wix Stores** (the catalog export): rows of `fieldType` `Product` carry\n * the product, its option names and each option's choices; `Variant` rows\n * sharing the `handleId` carry each variant's choice, SKU, stock and a\n * `surcharge` on the product's price. A colour choice may read `#hex:Name`,\n * and is kept as its name. `inventory` is a number, or `InStock` (not\n * counted) or `OutOfStock` (none). A `PERCENT` or `AMOUNT` discount makes\n * the discounted price the price and the full one the compare-at price.\n * `handleId` is an id, not an address, so a product's handle is made from\n * its name.\n * - **Squarespace Commerce**: a row per variant, the product's title and\n * description on its first row only. Rows are grouped by\n * `Product ID [Non Editable]`, or, without one, a row with no handle and no\n * title belongs to the product above it. `Product URL` is the old address,\n * kept as the handle. `Stock` may be `Unlimited` (not counted). `On Sale`\n * with a `Sale Price` makes the sale price the price and `Price` the\n * compare-at price. `Product Type` maps to Physical, Digital or Service, and\n * a gift card is not a product: its rows are skipped with a note.\n * - **Both**: a photo cell lists several (Wix by `;`, Squarespace by\n * spaces), read into **Images**. A weight is dropped with a note, because\n * neither file says whether it is in pounds or kilograms.\n *\n * Unknown and missing columns are never a failure: a column no field claims\n * is left unmapped, and a field no column fills is left as it is.\n *=========================================*/\n\n/** The field ids this module reads and writes; the same ids as `PRODUCT_FIELD`. */\nexport const SOURCE_FIELD = {\n handle: 'handle',\n title: 'title',\n description: 'description',\n kind: 'type',\n published: 'published',\n tags: 'tags',\n categories: 'categories',\n option1Name: 'option1Name',\n option2Name: 'option2Name',\n option3Name: 'option3Name',\n option1Value: 'option1Value',\n option2Value: 'option2Value',\n option3Value: 'option3Value',\n sku: 'sku',\n barcode: 'barcode',\n price: 'price',\n compareAtPrice: 'compareAtPrice',\n inventory: 'inventory',\n weightGrams: 'weightGrams',\n variantImage: 'variantImage',\n variantCheckIn: 'variantCheckIn',\n images: 'images',\n sourceProductId: 'sourceProductId',\n rowType: 'rowType',\n priceSurcharge: 'priceSurcharge',\n discountType: 'discountType',\n discountAmount: 'discountAmount',\n salePrice: 'salePrice',\n onSale: 'onSale',\n sourceType: 'sourceType',\n} as const\n\nconst S = SOURCE_FIELD\n\n/** The fields that exist only to read another store's file; never stored, blank on export. */\nexport const SOURCE_ONLY_FIELDS: readonly string[] = [\n S.sourceProductId,\n S.rowType,\n S.priceSurcharge,\n S.discountType,\n S.discountAmount,\n S.salePrice,\n S.onSale,\n S.sourceType,\n]\n\n/** Where a row's group key is kept once the file's own grouping is read. */\nexport const SOURCE_GROUP_KEY = '$group'\n/** Where a row that is not brought in keeps why. */\nexport const SOURCE_SKIP_KEY = '$skip'\n\n/** Wix Stores' product CSV columns, by the field each one means. */\nexport const WIX_PRODUCT_COLUMNS: Readonly<Record<string, readonly string[]>> = {\n [S.sourceProductId]: ['handleId'],\n [S.rowType]: ['fieldType'],\n [S.title]: ['name'],\n [S.description]: ['description'],\n [S.images]: ['productImageUrl'],\n [S.categories]: ['collection'],\n [S.sku]: ['sku'],\n [S.price]: ['price'],\n [S.priceSurcharge]: ['surcharge'],\n [S.published]: ['visible'],\n [S.discountType]: ['discountMode'],\n [S.discountAmount]: ['discountValue'],\n [S.inventory]: ['inventory'],\n [S.weightGrams]: ['weight'],\n [S.option1Name]: ['productOptionName1'],\n [S.option2Name]: ['productOptionName2'],\n [S.option3Name]: ['productOptionName3'],\n [S.option1Value]: ['productOptionDescription1'],\n [S.option2Value]: ['productOptionDescription2'],\n [S.option3Value]: ['productOptionDescription3'],\n}\n\n/** Squarespace's product CSV columns, by the field each one means. */\nexport const SQUARESPACE_PRODUCT_COLUMNS: Readonly<Record<string, readonly string[]>> = {\n [S.sourceProductId]: ['Product ID [Non Editable]'],\n [S.sourceType]: ['Product Type [Non Editable]'],\n [S.handle]: ['Product URL'],\n [S.title]: ['Title'],\n [S.description]: ['Description'],\n [S.sku]: ['SKU'],\n [S.option1Name]: ['Option Name 1'],\n [S.option1Value]: ['Option Value 1'],\n [S.option2Name]: ['Option Name 2'],\n [S.option2Value]: ['Option Value 2'],\n [S.option3Name]: ['Option Name 3'],\n [S.option3Value]: ['Option Value 3'],\n [S.price]: ['Price'],\n [S.salePrice]: ['Sale Price'],\n [S.onSale]: ['On Sale'],\n [S.inventory]: ['Stock'],\n [S.categories]: ['Categories'],\n [S.tags]: ['Tags'],\n [S.weightGrams]: ['Weight'],\n [S.published]: ['Visible'],\n [S.images]: ['Hosted Image URLs'],\n}\n\n/** The two dictionaries, beside Shopify's. */\nexport const SOURCE_ALIAS_DICTIONARIES: readonly TransferAliasDictionary[] = [\n { source: 'Wix', aliases: WIX_PRODUCT_COLUMNS },\n { source: 'Squarespace', aliases: SQUARESPACE_PRODUCT_COLUMNS },\n]\n\n/** Which other store's file this is. */\nexport type ProductFileSource = 'wix' | 'squarespace'\n\nconst compact = (header: unknown) => String(header ?? '').toLowerCase().replace(/[^a-z0-9]+/g, '')\n\n/**\n * The store a file came from, by its header signature: Wix's `handleId` and\n * `fieldType` beside its image or option columns; Squarespace's two\n * `[Non Editable]` ids or its hosted images. `null` for any other file,\n * Shopify's included. With no headers (a JSON file), by the columns read.\n */\nexport function productFileSource(\n headers: readonly string[] | undefined,\n rows: readonly TransferPlanRow[] = [],\n): ProductFileSource | null {\n if (headers?.length) {\n const have = new Set(headers.map(compact))\n if (have.has('handleid') && have.has('fieldtype') && (have.has('productimageurl') || have.has('productoptionname1'))) {\n return 'wix'\n }\n if (have.has('productidnoneditable') && (have.has('variantidnoneditable') || have.has('hostedimageurls'))) {\n return 'squarespace'\n }\n return null\n }\n const mapped = (fieldId: string) => rows.some((row) => fieldId in row.values)\n if (mapped(S.rowType) && mapped(S.sourceProductId)) return 'wix'\n if (mapped(S.sourceType) || mapped(S.onSale) || mapped(S.salePrice)) return 'squarespace'\n return null\n}\n\n/** Something the dry run says about how another store's file was read. */\nexport interface SourceNote {\n /** The row; `-1` for the whole file. */\n row: number\n fieldId?: string\n value?: string\n detail: string\n}\n\nconst text = (value: unknown): string => (value === null || value === undefined ? '' : String(value).trim())\n\n/** A money cell as a number of dollars; `null` for blank, unreadable or not in US dollars. */\nfunction amountOf(value: unknown): number | null {\n if (value === null || value === undefined || value === '') return null\n if (typeof value === 'number') return Number.isFinite(value) ? value : null\n if (typeof value === 'object' && 'amountMinor' in (value as object)) {\n const amount = value as { amountMinor: number; currency: string }\n return String(amount.currency).toUpperCase() === 'USD' ? Math.round(Number(amount.amountMinor)) / 100 : null\n }\n const number = Number(String(value).replace(/[$,\\s]/g, ''))\n return Number.isFinite(number) ? number : null\n}\n\nconst cents = (value: number) => Math.round(value * 100) / 100\n\nconst VARIANT_FIELDS = [\n S.option1Value,\n S.option2Value,\n S.option3Value,\n S.sku,\n S.barcode,\n S.price,\n S.compareAtPrice,\n S.inventory,\n S.weightGrams,\n S.variantImage,\n S.variantCheckIn,\n] as const\nconst OPTION_NAMES = [S.option1Name, S.option2Name, S.option3Name] as const\nconst OPTION_VALUES = [S.option1Value, S.option2Value, S.option3Value] as const\n\n/** A Wix choice as it is shown: `#ff0000:Red` is Red. */\nexport function wixChoiceName(value: unknown): string {\n return text(value).replace(/^#[0-9a-f]{3,8}\\s*:\\s*/i, '').trim()\n}\n\n/** A Wix option's choices, from the product row's comma list. */\nfunction wixChoices(value: unknown): string[] {\n return text(value)\n .split(',')\n .map(wixChoiceName)\n .filter(Boolean)\n}\n\n/** A row being read: its values and problems, writable. */\ninterface Draft {\n index: number\n values: Record<string, unknown>\n problems: Array<NonNullable<TransferPlanRow['problems']>[number]>\n source: TransferPlanRow\n}\n\nfunction draftOf(row: TransferPlanRow): Draft {\n return { index: row.index, values: { ...row.values }, problems: [...(row.problems ?? [])], source: row }\n}\n\nfunction rowOf(draft: Draft): TransferPlanRow {\n const rest: TransferPlanRow = { ...draft.source }\n delete (rest as { problems?: unknown }).problems\n return { ...rest, values: draft.values, ...(draft.problems.length ? { problems: draft.problems } : {}) }\n}\n\n/**\n * A stock cell a number could not read, as the other store wrote it:\n * `InStock` and `Unlimited` are stock that is not counted, `OutOfStock` none.\n */\nfunction readStockWords(draft: Draft): void {\n const at = draft.problems.findIndex((problem) => problem.fieldId === S.inventory)\n if (at < 0) return\n const raw = text(draft.problems[at]?.raw).toLowerCase().replace(/[\\s_-]+/g, '')\n if (raw === 'instock' || raw === 'unlimited') {\n draft.problems.splice(at, 1)\n delete draft.values[S.inventory]\n } else if (raw === 'outofstock') {\n draft.problems.splice(at, 1)\n draft.values[S.inventory] = 0\n }\n}\n\n/** The price a row ends with once a sale or discount is read: the sale price, the full one as compare-at. */\nfunction applySale(draft: Draft, full: number | null, sale: number | null): void {\n if (full === null) return\n if (sale !== null && sale > 0 && sale < full) {\n draft.values[S.price] = cents(sale)\n if (text(draft.values[S.compareAtPrice]) === '') draft.values[S.compareAtPrice] = cents(full)\n } else {\n draft.values[S.price] = cents(full)\n }\n}\n\nfunction wixDiscounted(full: number | null, mode: string, amount: number | null): number | null {\n if (full === null || amount === null || amount <= 0) return null\n if (mode === 'percent') return amount < 100 ? full * (1 - amount / 100) : null\n if (mode === 'amount') return amount < full ? full - amount : null\n return null\n}\n\nfunction dropWeights(drafts: readonly Draft[], source: ProductFileSource, notes: SourceNote[]): void {\n let dropped = false\n for (const draft of drafts) {\n if (text(draft.values[S.weightGrams]) !== '') dropped = true\n delete draft.values[S.weightGrams]\n draft.problems = draft.problems.filter((problem) => problem.fieldId !== S.weightGrams)\n }\n if (dropped) {\n notes.push({\n row: -1,\n fieldId: S.weightGrams,\n detail: `Weights are not brought in, because a ${source === 'wix' ? 'Wix' : 'Squarespace'} file does not say whether they are in pounds or kilograms. Set each product's weight on the product.`,\n })\n }\n}\n\nfunction clearSourceFields(draft: Draft): void {\n for (const fieldId of SOURCE_ONLY_FIELDS) delete draft.values[fieldId]\n}\n\nfunction adaptWix(drafts: Draft[], notes: SourceNote[]): void {\n const groups = new Map<string, Draft[]>()\n drafts.forEach((draft, position) => {\n const id = text(draft.values[S.sourceProductId])\n const key = id ? `w:${id}` : `r:${position}`\n draft.values[SOURCE_GROUP_KEY] = key\n groups.set(key, [...(groups.get(key) ?? []), draft])\n })\n for (const group of groups.values()) {\n const kind = (draft: Draft) => text(draft.values[S.rowType]).toLowerCase()\n const product = group.find((draft) => kind(draft) === 'product') ?? (group[0] as Draft)\n const variants = group.filter((draft) => draft !== product && kind(draft) === 'variant')\n const base = amountOf(product.values[S.price])\n const mode = text(product.values[S.discountType]).toLowerCase()\n const discount = amountOf(product.values[S.discountAmount])\n const priced = (draft: Draft, full: number | null) => applySale(draft, full, wixDiscounted(full, mode, discount))\n\n if (variants.length) {\n // The product row holds the product; its own SKU, price and choice lists are not a variant.\n for (const fieldId of VARIANT_FIELDS) delete product.values[fieldId]\n product.problems = product.problems.filter((problem) => !(VARIANT_FIELDS as readonly string[]).includes(problem.fieldId))\n for (const variant of variants) {\n OPTION_VALUES.forEach((fieldId) => {\n if (text(variant.values[fieldId])) variant.values[fieldId] = wixChoiceName(variant.values[fieldId])\n })\n const own = amountOf(variant.values[S.price])\n const surcharge = amountOf(variant.values[S.priceSurcharge]) ?? 0\n priced(variant, own ?? (base === null ? null : base + surcharge))\n readStockWords(variant)\n }\n } else {\n // A product with no variant rows is one variant; a choice list cannot be one.\n const lists = OPTION_VALUES.map((fieldId) => wixChoices(product.values[fieldId]))\n if (lists.some((choices) => choices.length > 1)) {\n const named = OPTION_NAMES.map((fieldId, axis) =>\n text(product.values[fieldId]) && lists[axis]?.length ? `${text(product.values[fieldId])}: ${lists[axis]?.join(', ')}` : '',\n ).filter(Boolean)\n notes.push({\n row: product.index,\n fieldId: S.option1Value,\n value: named.join('; '),\n detail:\n \"This product's choices have no variant rows in the file, so it is brought in as one variant. Add its choices on the product.\",\n })\n for (const fieldId of [...OPTION_VALUES, ...OPTION_NAMES]) delete product.values[fieldId]\n } else {\n OPTION_VALUES.forEach((fieldId, axis) => {\n if (lists[axis]?.length) product.values[fieldId] = lists[axis]?.[0]\n else delete product.values[fieldId]\n })\n }\n priced(product, base)\n readStockWords(product)\n }\n }\n}\n\n/** A Squarespace `Product URL` is the last part of the old address. */\nfunction squarespaceHandle(value: unknown): string {\n const parts = text(value).split(/[/?#]/).filter(Boolean)\n return parts[parts.length - 1] ?? ''\n}\n\nconst SQUARESPACE_KIND: Readonly<Record<string, string>> = {\n physical: 'Physical',\n digital: 'Digital',\n service: 'Service',\n}\n\nfunction adaptSquarespace(drafts: Draft[], notes: SourceNote[]): void {\n const groups = new Map<string, Draft[]>()\n let current: string | null = null\n drafts.forEach((draft, position) => {\n const id = text(draft.values[S.sourceProductId])\n if (text(draft.values[S.handle])) draft.values[S.handle] = squarespaceHandle(draft.values[S.handle])\n const handle = text(draft.values[S.handle])\n const key: string = id ? `s:${id}` : handle ? `h:${handle.toLowerCase()}` : text(draft.values[S.title]) ? `r:${position}` : (current ?? `r:${position}`)\n current = key\n draft.values[SOURCE_GROUP_KEY] = key\n groups.set(key, [...(groups.get(key) ?? []), draft])\n })\n for (const group of groups.values()) {\n const type = text(group.map((draft) => draft.values[S.sourceType]).find((value) => text(value)))\n .toLowerCase()\n .replace(/[\\s-]+/g, '_')\n const first = group[0] as Draft\n if (type === 'gift_card' || type === 'giftcard') {\n for (const draft of group) draft.values[SOURCE_SKIP_KEY] = 'giftCard'\n notes.push({\n row: first.index,\n value: text(first.values[S.title]) || undefined,\n detail: 'A gift card is not a product, so its rows are skipped. Bring gift cards in with a gift card import.',\n })\n continue\n }\n const kind = SQUARESPACE_KIND[type]\n if (kind && text(first.values[S.kind]) === '') first.values[S.kind] = kind\n for (const draft of group) {\n const full = amountOf(draft.values[S.price])\n const sale = draft.values[S.onSale] === true ? amountOf(draft.values[S.salePrice]) : null\n if (full !== null) applySale(draft, full, sale)\n readStockWords(draft)\n }\n }\n}\n\n/**\n * A sale price in any other file: below the price, it becomes the price and\n * the price the compare-at price; with an On sale column, only when it says yes.\n */\nfunction adaptSalePrices(drafts: readonly Draft[]): void {\n const flagged = drafts.some((draft) => S.onSale in draft.values)\n for (const draft of drafts) {\n if (!(S.salePrice in draft.values)) continue\n if (flagged && draft.values[S.onSale] !== true) continue\n const full = amountOf(draft.values[S.price])\n const sale = amountOf(draft.values[S.salePrice])\n if (full !== null && sale !== null) applySale(draft, full, sale)\n }\n}\n\n/**\n * The rows read into the layout the products plan reads. For another\n * store's file: each row's group under {@link SOURCE_GROUP_KEY}, prices\n * settled, stock words read, a row not brought in marked under\n * {@link SOURCE_SKIP_KEY}. For any file: a sale price settled, and the\n * source-only fields gone. What was changed or left out is in `notes`.\n */\nexport function adaptProductSourceRows(\n rows: readonly TransferPlanRow[],\n source: ProductFileSource | null,\n): { rows: TransferPlanRow[]; notes: SourceNote[] } {\n const touched = rows.some((row) => SOURCE_ONLY_FIELDS.some((fieldId) => fieldId in row.values))\n if (!source && !touched) return { rows: [...rows], notes: [] }\n const drafts = rows.map(draftOf)\n const notes: SourceNote[] = []\n // Before the rows are read, which clears a Wix product row's own variant cells.\n if (source) dropWeights(drafts, source, notes)\n if (source === 'wix') adaptWix(drafts, notes)\n else if (source === 'squarespace') adaptSquarespace(drafts, notes)\n else adaptSalePrices(drafts)\n for (const draft of drafts) clearSourceFields(draft)\n return { rows: drafts.map(rowOf), notes }\n}\n"],"names":["SOURCE_FIELD","handle","title","description","kind","published","tags","categories","option1Name","option2Name","option3Name","option1Value","option2Value","option3Value","sku","barcode","price","compareAtPrice","inventory","weightGrams","variantImage","variantCheckIn","images","sourceProductId","rowType","priceSurcharge","discountType","discountAmount","salePrice","onSale","sourceType","S","SOURCE_ONLY_FIELDS","SOURCE_GROUP_KEY","SOURCE_SKIP_KEY","WIX_PRODUCT_COLUMNS","SQUARESPACE_PRODUCT_COLUMNS","SOURCE_ALIAS_DICTIONARIES","source","aliases","compact","header","String","toLowerCase","replace","productFileSource","headers","rows","length","have","Set","map","has","mapped","fieldId","some","row","values","text","value","undefined","trim","amountOf","Number","isFinite","amount","currency","toUpperCase","Math","round","amountMinor","number","cents","VARIANT_FIELDS","OPTION_NAMES","OPTION_VALUES","wixChoiceName","wixChoices","split","filter","Boolean","draftOf","index","problems","rowOf","draft","rest","readStockWords","at","findIndex","problem","raw","splice","applySale","full","sale","wixDiscounted","mode","dropWeights","drafts","notes","dropped","push","detail","clearSourceFields","adaptWix","groups","Map","forEach","position","id","key","set","get","group","product","find","variants","base","discount","priced","includes","variant","own","surcharge","lists","choices","named","axis","join","squarespaceHandle","parts","SQUARESPACE_KIND","physical","digital","service","adaptSquarespace","current","type","first","adaptSalePrices","flagged","adaptProductSourceRows","touched"],"mappings":"AAAA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,IAAIkE,SAAS,QAAQC,SAAS,MAAMF,UAAUR,OAAOS,MAAMC;IAC7D;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAAS+C,uBACd/F,IAAgC,EAChCT,MAAgC;IAEhC,MAAMyG,UAAUhG,KAAKQ,IAAI,CAAC,CAACC,MAAQxB,mBAAmBuB,IAAI,CAAC,CAACD,UAAYA,WAAWE,IAAIC,MAAM;IAC7F,IAAI,CAACnB,UAAU,CAACyG,SAAS,OAAO;QAAEhG,MAAM;eAAIA;SAAK;QAAEqD,OAAO,EAAE;IAAC;IAC7D,MAAMD,SAASpD,KAAKI,GAAG,CAAC8B;IACxB,MAAMmB,QAAsB,EAAE;IAC9B,gFAAgF;IAChF,IAAI9D,QAAQ4D,YAAYC,QAAQ7D,QAAQ8D;IACxC,IAAI9D,WAAW,OAAOmE,SAASN,QAAQC;SAClC,IAAI9D,WAAW,eAAekG,iBAAiBrC,QAAQC;SACvDwC,gBAAgBzC;IACrB,KAAK,MAAMd,SAASc,OAAQK,kBAAkBnB;IAC9C,OAAO;QAAEtC,MAAMoD,OAAOhD,GAAG,CAACiC;QAAQgB;IAAM;AAC1C"}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { type BuildTransferPlanInput, type MatchKeySpec, type PlannedTransferRow, type TransferAliasDictionary, type TransferField, type TransferFieldGroup, type TransferLockedRule, type TransferPlan, type TransferPlanRow, type TransferResourcePreset } from '@aglyn/aglyn/data-transfer';
|
|
18
18
|
import type { PicklistSpec } from '@aglyn/aglyn/app-utils/picklists';
|
|
19
19
|
import { type HostProduct, type ProductOption, type ProductVariant } from '../model/commerce';
|
|
20
|
+
import { type ProductFileSource } from './product-sources';
|
|
20
21
|
/** The field ids, as the catalog and every file name them. */
|
|
21
22
|
export declare const PRODUCT_FIELD: {
|
|
22
23
|
readonly handle: "handle";
|
|
@@ -50,6 +51,15 @@ export declare const PRODUCT_FIELD: {
|
|
|
50
51
|
readonly weightGrams: "weightGrams";
|
|
51
52
|
readonly variantImage: "variantImage";
|
|
52
53
|
readonly variantCheckIn: "variantCheckIn";
|
|
54
|
+
readonly images: "images";
|
|
55
|
+
readonly sourceProductId: "sourceProductId";
|
|
56
|
+
readonly rowType: "rowType";
|
|
57
|
+
readonly priceSurcharge: "priceSurcharge";
|
|
58
|
+
readonly discountType: "discountType";
|
|
59
|
+
readonly discountAmount: "discountAmount";
|
|
60
|
+
readonly salePrice: "salePrice";
|
|
61
|
+
readonly onSale: "onSale";
|
|
62
|
+
readonly sourceType: "sourceType";
|
|
53
63
|
readonly priceFrom: "priceFrom";
|
|
54
64
|
readonly totalInventory: "totalInventory";
|
|
55
65
|
readonly soldOut: "soldOut";
|
|
@@ -86,7 +96,11 @@ export declare const PRODUCT_MATCH_KEYS: readonly MatchKeySpec[];
|
|
|
86
96
|
export declare const PRODUCT_LOCKED_RULES: readonly TransferLockedRule[];
|
|
87
97
|
/** Shopify's product CSV columns, by the field each one means. */
|
|
88
98
|
export declare const SHOPIFY_PRODUCT_COLUMNS: Readonly<Record<string, string>>;
|
|
89
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Shopify's export headers, so its file maps column for column, and Wix's
|
|
101
|
+
* and Squarespace's (AGL-4245), whose files are then read by their header
|
|
102
|
+
* signature (`product-sources.ts`).
|
|
103
|
+
*/
|
|
90
104
|
export declare const PRODUCT_ALIAS_DICTIONARIES: readonly TransferAliasDictionary[];
|
|
91
105
|
/**
|
|
92
106
|
* The Shopify preset: Shopify's product CSV columns, in Shopify's order and
|
|
@@ -175,6 +189,15 @@ export interface ProductPlanContext {
|
|
|
175
189
|
slugTaken?(slug: string): boolean;
|
|
176
190
|
/** How many products the site may still create; unbounded when absent. */
|
|
177
191
|
maxCreates?: number;
|
|
192
|
+
/** The other store the file came from, by its headers (`productFileSource`); `null` for Shopify's or any other. */
|
|
193
|
+
source?: ProductFileSource | null;
|
|
194
|
+
/**
|
|
195
|
+
* The library file an earlier import already copied a photo address to,
|
|
196
|
+
* as the products the file matched store it (AGL-4245); `null` for one
|
|
197
|
+
* not copied yet. A photo already copied plans as that file, so a file
|
|
198
|
+
* imported again shows its photos unchanged.
|
|
199
|
+
*/
|
|
200
|
+
copiedPhoto?(url: string): string | null;
|
|
178
201
|
}
|
|
179
202
|
/** The tags a cell names, in their own case. */
|
|
180
203
|
export declare function productTagList(value: unknown): string[];
|
|
@@ -188,6 +211,8 @@ export declare function productFromRecord(values: Readonly<Record<string, unknow
|
|
|
188
211
|
}>): HostProduct;
|
|
189
212
|
/** One variant of a document from its record values. */
|
|
190
213
|
export declare function variantFromRecord(id: string, values: Readonly<Record<string, unknown>>, optionNames: readonly (string | null | undefined)[]): ProductVariant;
|
|
214
|
+
/** The addresses the written rows of a plan copy, once each. */
|
|
215
|
+
export declare function productPlanPhotoUrls(rows: readonly PlannedTransferRow[]): string[];
|
|
191
216
|
/**
|
|
192
217
|
* The products resource's plan: the core's plan per product and per variant,
|
|
193
218
|
* folded back into one verdict per file row (see the block header).
|
|
@@ -16,9 +16,11 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/ import { validateProductForSave } from "../model/product-card-rules.js";
|
|
19
|
-
import { buildTransferPlan, isBlankTransferValue, TRANSFER_SYSTEM_GROUP, TRANSFER_WARNING_CLASSES } from "@aglyn/aglyn/data-transfer";
|
|
19
|
+
import { buildTransferPlan, isBlankTransferValue, TRANSFER_FILE_SAMPLE_ROW, TRANSFER_SYSTEM_GROUP, TRANSFER_WARNING_CLASSES } from "@aglyn/aglyn/data-transfer";
|
|
20
20
|
import { COMMERCE_MAX_VARIANTS, COMMERCE_SLUG_MAX_LENGTH, commerceSlug, productInventory, productPriceRange, variantMatrixProblem } from "../model/commerce.js";
|
|
21
21
|
import { addOnCellOf, addOnVariantIds, checkInCellOf, checkInFromCell, modifierGroupsFromAddOnCell, readAddOnCell, readCheckInCell, writeAddOnCell, writeCheckInCell } from "./product-register-cells.js";
|
|
22
|
+
import { PRODUCT_IMPORT_FOLDER_NAME, PRODUCT_IMPORT_IMAGES_MAX, productImageCell, productImageList, productImageSkipDetail } from "./product-images.js";
|
|
23
|
+
import { adaptProductSourceRows, SOURCE_ALIAS_DICTIONARIES, SOURCE_GROUP_KEY, SOURCE_SKIP_KEY } from "./product-sources.js";
|
|
22
24
|
/*
|
|
23
25
|
* PRODUCTS ON THE TRANSFER FRAMEWORK (AGL-3531).
|
|
24
26
|
*
|
|
@@ -95,6 +97,15 @@ import { addOnCellOf, addOnVariantIds, checkInCellOf, checkInFromCell, modifierG
|
|
|
95
97
|
weightGrams: 'weightGrams',
|
|
96
98
|
variantImage: 'variantImage',
|
|
97
99
|
variantCheckIn: 'variantCheckIn',
|
|
100
|
+
images: 'images',
|
|
101
|
+
sourceProductId: 'sourceProductId',
|
|
102
|
+
rowType: 'rowType',
|
|
103
|
+
priceSurcharge: 'priceSurcharge',
|
|
104
|
+
discountType: 'discountType',
|
|
105
|
+
discountAmount: 'discountAmount',
|
|
106
|
+
salePrice: 'salePrice',
|
|
107
|
+
onSale: 'onSale',
|
|
108
|
+
sourceType: 'sourceType',
|
|
98
109
|
priceFrom: 'priceFrom',
|
|
99
110
|
totalInventory: 'totalInventory',
|
|
100
111
|
soldOut: 'soldOut',
|
|
@@ -174,6 +185,10 @@ export const PRODUCT_TRANSFER_GROUPS = [
|
|
|
174
185
|
id: 'seo',
|
|
175
186
|
label: 'Search listing'
|
|
176
187
|
},
|
|
188
|
+
{
|
|
189
|
+
id: 'switching',
|
|
190
|
+
label: 'From another store'
|
|
191
|
+
},
|
|
177
192
|
{
|
|
178
193
|
id: 'computed',
|
|
179
194
|
label: 'Computed'
|
|
@@ -475,7 +490,19 @@ const OPTION_VALUE_FIELDS = [
|
|
|
475
490
|
'photo',
|
|
476
491
|
'picture'
|
|
477
492
|
],
|
|
478
|
-
description: 'One image per row; the first row’s is the photo the storefront leads with.'
|
|
493
|
+
description: 'One image per row; the first row’s is the photo the storefront leads with. Copied into your media library.'
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
id: F.images,
|
|
497
|
+
label: 'Images',
|
|
498
|
+
group: 'media',
|
|
499
|
+
type: 'longText',
|
|
500
|
+
aliases: [
|
|
501
|
+
'image urls',
|
|
502
|
+
'image links',
|
|
503
|
+
'photos'
|
|
504
|
+
],
|
|
505
|
+
description: 'Several photo addresses in one cell, split by semicolons or spaces. Each is copied into your media library.'
|
|
479
506
|
},
|
|
480
507
|
{
|
|
481
508
|
id: F.seoTitle,
|
|
@@ -567,6 +594,71 @@ const OPTION_VALUE_FIELDS = [
|
|
|
567
594
|
'modifier groups'
|
|
568
595
|
],
|
|
569
596
|
description: 'Groups split by semicolons: Milk (at least 1): Whole, Oat +$0.75; Extras (at most 3, register only): Extra shot +$1.00.'
|
|
597
|
+
},
|
|
598
|
+
// Read from another store's file (AGL-4245, `product-sources.ts`); never stored, so import-only.
|
|
599
|
+
{
|
|
600
|
+
id: F.salePrice,
|
|
601
|
+
label: 'Sale price',
|
|
602
|
+
group: 'switching',
|
|
603
|
+
importOnly: true,
|
|
604
|
+
type: 'currency',
|
|
605
|
+
description: 'Below the price, it becomes the price and the price becomes the compare-at price. With On sale, only when On sale is yes.'
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
id: F.onSale,
|
|
609
|
+
label: 'On sale',
|
|
610
|
+
group: 'switching',
|
|
611
|
+
importOnly: true,
|
|
612
|
+
type: 'boolean',
|
|
613
|
+
description: 'Whether Sale price is used.'
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
id: F.sourceProductId,
|
|
617
|
+
label: 'Old store product ID',
|
|
618
|
+
group: 'switching',
|
|
619
|
+
importOnly: true,
|
|
620
|
+
type: 'text',
|
|
621
|
+
description: 'Puts the rows of one product together in a Wix or Squarespace file. Not stored.'
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
id: F.sourceType,
|
|
625
|
+
label: 'Old store product type',
|
|
626
|
+
group: 'switching',
|
|
627
|
+
importOnly: true,
|
|
628
|
+
type: 'text',
|
|
629
|
+
description: 'Physical, Digital, Service or Gift card, in a Squarespace file. Gift cards are skipped.'
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
id: F.rowType,
|
|
633
|
+
label: 'Row type',
|
|
634
|
+
group: 'switching',
|
|
635
|
+
importOnly: true,
|
|
636
|
+
type: 'text',
|
|
637
|
+
description: 'Product or Variant, in a Wix file.'
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
id: F.priceSurcharge,
|
|
641
|
+
label: 'Price surcharge',
|
|
642
|
+
group: 'switching',
|
|
643
|
+
importOnly: true,
|
|
644
|
+
type: 'currency',
|
|
645
|
+
description: 'What a Wix variant adds to the product’s price.'
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
id: F.discountType,
|
|
649
|
+
label: 'Discount type',
|
|
650
|
+
group: 'switching',
|
|
651
|
+
importOnly: true,
|
|
652
|
+
type: 'text',
|
|
653
|
+
description: 'Percent or Amount, in a Wix file: the discounted price becomes the price, and the full price the compare-at price.'
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
id: F.discountAmount,
|
|
657
|
+
label: 'Discount',
|
|
658
|
+
group: 'switching',
|
|
659
|
+
importOnly: true,
|
|
660
|
+
type: 'number',
|
|
661
|
+
description: 'The Wix discount, with Discount type.'
|
|
570
662
|
}
|
|
571
663
|
];
|
|
572
664
|
export const PRODUCT_DERIVED_FIELDS = [
|
|
@@ -673,7 +765,11 @@ export const PRODUCT_SYSTEM_FIELDS = [
|
|
|
673
765
|
[F.variantImage]: 'Variant Image',
|
|
674
766
|
[F.status]: 'Status'
|
|
675
767
|
};
|
|
676
|
-
/**
|
|
768
|
+
/**
|
|
769
|
+
* Shopify's export headers, so its file maps column for column, and Wix's
|
|
770
|
+
* and Squarespace's (AGL-4245), whose files are then read by their header
|
|
771
|
+
* signature (`product-sources.ts`).
|
|
772
|
+
*/ export const PRODUCT_ALIAS_DICTIONARIES = [
|
|
677
773
|
{
|
|
678
774
|
source: 'Shopify',
|
|
679
775
|
aliases: Object.fromEntries(Object.entries(SHOPIFY_PRODUCT_COLUMNS).map(([fieldId, column])=>[
|
|
@@ -682,7 +778,8 @@ export const PRODUCT_SYSTEM_FIELDS = [
|
|
|
682
778
|
column
|
|
683
779
|
]
|
|
684
780
|
]))
|
|
685
|
-
}
|
|
781
|
+
},
|
|
782
|
+
...SOURCE_ALIAS_DICTIONARIES
|
|
686
783
|
];
|
|
687
784
|
/**
|
|
688
785
|
* The Shopify preset: Shopify's product CSV columns, in Shopify's order and
|
|
@@ -828,6 +925,7 @@ const isoOf = (value, ms)=>{
|
|
|
828
925
|
if (fieldId === 'id') row[fieldId] = id;
|
|
829
926
|
else if (fieldId === F.handle) row[fieldId] = record[F.handle];
|
|
830
927
|
else if (fieldId === F.image) row[fieldId] = (_images_index = images[index]) != null ? _images_index : null;
|
|
928
|
+
else if (fieldId === F.images) row[fieldId] = index === 0 && images.length ? images.join('; ') : null;
|
|
831
929
|
else if (variantFields.has(fieldId)) row[fieldId] = variant ? (_variant_fieldId = variant[fieldId]) != null ? _variant_fieldId : null : null;
|
|
832
930
|
else row[fieldId] = index === 0 ? (_record_fieldId = record[fieldId]) != null ? _record_fieldId : null : null;
|
|
833
931
|
}
|
|
@@ -975,6 +1073,8 @@ const pick = (values, fieldIds)=>{
|
|
|
975
1073
|
};
|
|
976
1074
|
const hasAny = (values, fieldIds)=>fieldIds.some((fieldId)=>!isBlankTransferValue(values[fieldId]));
|
|
977
1075
|
/** Which product a row belongs to in the file. */ function groupKey(row, position) {
|
|
1076
|
+
const grouped = text(row.values[SOURCE_GROUP_KEY]);
|
|
1077
|
+
if (grouped) return `g:${grouped}`;
|
|
978
1078
|
const handle = text(row.values[F.handle]);
|
|
979
1079
|
if (handle) return `h:${handle}`;
|
|
980
1080
|
const id = text(row.values['id']);
|
|
@@ -1125,6 +1225,133 @@ const hasAny = (values, fieldIds)=>fieldIds.some((fieldId)=>!isBlankTransferValu
|
|
|
1125
1225
|
checkIn
|
|
1126
1226
|
} : {});
|
|
1127
1227
|
}
|
|
1228
|
+
/*------------------------------------------
|
|
1229
|
+
* Photos (AGL-4245)
|
|
1230
|
+
*-----------------------------------------*/ /** The photo cells a row carries: its Image, and every address its Images cell lists. */ function imageCellsOf(values) {
|
|
1231
|
+
const one = values[F.image];
|
|
1232
|
+
return [
|
|
1233
|
+
...Array.isArray(one) ? one.map(text) : [
|
|
1234
|
+
text(one)
|
|
1235
|
+
],
|
|
1236
|
+
...productImageList(values[F.images])
|
|
1237
|
+
].filter(Boolean);
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Which photos a file's rows copy, keep or skip, in file order: the first
|
|
1241
|
+
* {@link PRODUCT_IMPORT_IMAGES_MAX} distinct addresses are copied, and every
|
|
1242
|
+
* cell left out is kept to report.
|
|
1243
|
+
*/ let PhotoPlan = class PhotoPlan {
|
|
1244
|
+
/** The value a cell is written as (its address, or the library file it names); `null` when it is skipped. */ keep(raw, row, fieldId) {
|
|
1245
|
+
const cell = productImageCell(raw);
|
|
1246
|
+
if (!cell) return null;
|
|
1247
|
+
if (cell.kind === 'stored') return cell.value;
|
|
1248
|
+
if (cell.kind === 'skip') {
|
|
1249
|
+
this.skipped.push({
|
|
1250
|
+
row,
|
|
1251
|
+
fieldId,
|
|
1252
|
+
value: cell.value,
|
|
1253
|
+
skip: cell.skip
|
|
1254
|
+
});
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1257
|
+
const stored = this.copied == null ? void 0 : this.copied.call(this, cell.url);
|
|
1258
|
+
if (stored) return stored;
|
|
1259
|
+
if (!this.copying.has(cell.url) && this.copying.size >= PRODUCT_IMPORT_IMAGES_MAX) {
|
|
1260
|
+
this.skipped.push({
|
|
1261
|
+
row,
|
|
1262
|
+
fieldId,
|
|
1263
|
+
value: cell.url,
|
|
1264
|
+
skip: 'overLimit'
|
|
1265
|
+
});
|
|
1266
|
+
return null;
|
|
1267
|
+
}
|
|
1268
|
+
this.copying.add(cell.url);
|
|
1269
|
+
return cell.url;
|
|
1270
|
+
}
|
|
1271
|
+
constructor(copied){
|
|
1272
|
+
this.copied = copied;
|
|
1273
|
+
this.copying = new Set();
|
|
1274
|
+
this.skipped = [];
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
/** The addresses the written rows of a plan copy, once each. */ export function productPlanPhotoUrls(rows) {
|
|
1278
|
+
const urls = new Set();
|
|
1279
|
+
for (const row of rows){
|
|
1280
|
+
if (row.verdict !== 'create' && row.verdict !== 'update') continue;
|
|
1281
|
+
for (const change of row.diff){
|
|
1282
|
+
if (change.fieldId !== F.image && change.fieldId !== F.variantImage) continue;
|
|
1283
|
+
const values = Array.isArray(change.after) ? change.after : [
|
|
1284
|
+
change.after
|
|
1285
|
+
];
|
|
1286
|
+
for (const value of values){
|
|
1287
|
+
const cell = productImageCell(value);
|
|
1288
|
+
if ((cell == null ? void 0 : cell.kind) === 'copy') urls.add(cell.url);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return [
|
|
1293
|
+
...urls
|
|
1294
|
+
];
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* The dry run's word on photos and on how another store's file was read: a
|
|
1298
|
+
* `screening` warning saying how many photos are copied and where, each
|
|
1299
|
+
* photo that is not and why, and each note the file's reading left. Only a
|
|
1300
|
+
* photo left out or a note needs "I understand"; a count alone does not.
|
|
1301
|
+
*/ function photoScreening(copies, photos, notes) {
|
|
1302
|
+
const samples = [];
|
|
1303
|
+
if (copies) {
|
|
1304
|
+
samples.push({
|
|
1305
|
+
row: TRANSFER_FILE_SAMPLE_ROW,
|
|
1306
|
+
fieldId: F.image,
|
|
1307
|
+
value: copies.toLocaleString('en-US'),
|
|
1308
|
+
detail: `Copies ${copies.toLocaleString('en-US')} photo${copies === 1 ? '' : 's'} into your media library, in a folder named "${PRODUCT_IMPORT_FOLDER_NAME}", so ${copies === 1 ? 'it keeps' : 'they keep'} showing after your old store closes.`
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
const skips = photos.skipped.length;
|
|
1312
|
+
if (skips) {
|
|
1313
|
+
samples.push({
|
|
1314
|
+
row: TRANSFER_FILE_SAMPLE_ROW,
|
|
1315
|
+
fieldId: F.image,
|
|
1316
|
+
value: skips.toLocaleString('en-US'),
|
|
1317
|
+
detail: `${skips.toLocaleString('en-US')} photo${skips === 1 ? ' is' : 's are'} not copied. Add ${skips === 1 ? 'it' : 'them'} on the product after the import.`
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
for (const note of notes){
|
|
1321
|
+
samples.push(_extends({
|
|
1322
|
+
row: note.row
|
|
1323
|
+
}, note.fieldId ? {
|
|
1324
|
+
fieldId: note.fieldId
|
|
1325
|
+
} : {}, note.value ? {
|
|
1326
|
+
value: note.value
|
|
1327
|
+
} : {}, {
|
|
1328
|
+
detail: note.detail
|
|
1329
|
+
}));
|
|
1330
|
+
}
|
|
1331
|
+
for (const skip of photos.skipped.slice(0, 5)){
|
|
1332
|
+
samples.push({
|
|
1333
|
+
row: skip.row,
|
|
1334
|
+
fieldId: skip.fieldId,
|
|
1335
|
+
value: skip.value,
|
|
1336
|
+
detail: productImageSkipDetail(skip.skip)
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
if (!samples.length) return null;
|
|
1340
|
+
const rows = new Set([
|
|
1341
|
+
...photos.skipped.map((skip)=>skip.row),
|
|
1342
|
+
...notes.map((note)=>note.row)
|
|
1343
|
+
].filter((row)=>row >= 0));
|
|
1344
|
+
return {
|
|
1345
|
+
class: 'screening',
|
|
1346
|
+
count: copies + skips + notes.length,
|
|
1347
|
+
rows: rows.size,
|
|
1348
|
+
fieldIds: [
|
|
1349
|
+
...new Set(samples.map((sample)=>sample.fieldId).filter((id)=>Boolean(id)))
|
|
1350
|
+
],
|
|
1351
|
+
samples,
|
|
1352
|
+
requiresAcknowledgement: skips > 0 || notes.length > 0
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1128
1355
|
/** The fields a new product is refused without. */ const PRODUCT_PLAN_FIELDS = (fields)=>fields.filter((field)=>!VARIANT_LEVEL_FIELDS.includes(field.id)).map((field)=>field.id === F.title ? _extends({}, field, {
|
|
1129
1356
|
required: true
|
|
1130
1357
|
}) : field);
|
|
@@ -1135,7 +1362,21 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1135
1362
|
* The products resource's plan: the core's plan per product and per variant,
|
|
1136
1363
|
* folded back into one verdict per file row (see the block header).
|
|
1137
1364
|
*/ export function planProductTransfer(input, context) {
|
|
1138
|
-
|
|
1365
|
+
var _context_source;
|
|
1366
|
+
var _context_copiedPhoto;
|
|
1367
|
+
// Another store's file is read into this layout first (AGL-4245, `product-sources.ts`).
|
|
1368
|
+
const adapted = adaptProductSourceRows(input.rows, (_context_source = context.source) != null ? _context_source : null);
|
|
1369
|
+
const photos = new PhotoPlan((_context_copiedPhoto = context.copiedPhoto) == null ? void 0 : _context_copiedPhoto.bind(context));
|
|
1370
|
+
const rows = adapted.rows.map(normalizeRow).map((row)=>{
|
|
1371
|
+
if (isBlankTransferValue(row.values[F.variantImage])) return row;
|
|
1372
|
+
const values = _extends({}, row.values);
|
|
1373
|
+
const kept = photos.keep(values[F.variantImage], row.index, F.variantImage);
|
|
1374
|
+
if (kept) values[F.variantImage] = kept;
|
|
1375
|
+
else delete values[F.variantImage];
|
|
1376
|
+
return _extends({}, row, {
|
|
1377
|
+
values
|
|
1378
|
+
});
|
|
1379
|
+
});
|
|
1139
1380
|
const tally = new Tally();
|
|
1140
1381
|
// The groups, in the order their first rows appear.
|
|
1141
1382
|
const groups = new Map();
|
|
@@ -1149,9 +1390,32 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1149
1390
|
group.positions.push(position);
|
|
1150
1391
|
groups.set(key, group);
|
|
1151
1392
|
});
|
|
1393
|
+
const out = new Array(rows.length);
|
|
1394
|
+
// A product the file's own store says is not one (a Squarespace gift card) is skipped whole.
|
|
1152
1395
|
const ordered = [
|
|
1153
1396
|
...groups.values()
|
|
1154
|
-
]
|
|
1397
|
+
].filter((group)=>{
|
|
1398
|
+
const first = rows[group.positions[0]];
|
|
1399
|
+
if (!first.values[SOURCE_SKIP_KEY]) return true;
|
|
1400
|
+
for (const position of group.positions){
|
|
1401
|
+
var _input_matches_position;
|
|
1402
|
+
out[position] = {
|
|
1403
|
+
index: rows[position].index,
|
|
1404
|
+
verdict: 'skip',
|
|
1405
|
+
recordId: null,
|
|
1406
|
+
reason: 'resourceRule',
|
|
1407
|
+
diff: [],
|
|
1408
|
+
heldBack: [],
|
|
1409
|
+
warnings: [
|
|
1410
|
+
'screening'
|
|
1411
|
+
],
|
|
1412
|
+
match: (_input_matches_position = input.matches[position]) != null ? _input_matches_position : {
|
|
1413
|
+
kind: 'new'
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
return false;
|
|
1418
|
+
});
|
|
1155
1419
|
// The product half: each group's first row, with the group's images and option names.
|
|
1156
1420
|
const leaders = ordered.map((group)=>{
|
|
1157
1421
|
const first = rows[group.positions[0]];
|
|
@@ -1161,10 +1425,13 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1161
1425
|
]);
|
|
1162
1426
|
const images = [];
|
|
1163
1427
|
for (const position of group.positions){
|
|
1164
|
-
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1428
|
+
const row = rows[position];
|
|
1429
|
+
for (const raw of imageCellsOf(row.values)){
|
|
1430
|
+
const kept = photos.keep(raw, row.index, F.image);
|
|
1431
|
+
if (kept && !images.includes(kept)) images.push(kept);
|
|
1432
|
+
}
|
|
1167
1433
|
}
|
|
1434
|
+
// A product whose every photo is skipped keeps the photos it has.
|
|
1168
1435
|
if (images.length) values[F.image] = images;
|
|
1169
1436
|
else delete values[F.image];
|
|
1170
1437
|
OPTION_NAME_FIELDS.forEach((fieldId)=>{
|
|
@@ -1216,7 +1483,6 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1216
1483
|
});
|
|
1217
1484
|
tally.merge(productPlan.warnings);
|
|
1218
1485
|
const variantFields = VARIANT_PLAN_FIELDS(input.fields);
|
|
1219
|
-
const out = new Array(rows.length);
|
|
1220
1486
|
// Slugs this plan gives new products, so two new ones never share one.
|
|
1221
1487
|
const handedOut = new Set();
|
|
1222
1488
|
ordered.forEach((group, at)=>{
|
|
@@ -1616,7 +1882,13 @@ const VARIANT_PLAN_FIELDS = (fields)=>fields.filter((field)=>VARIANT_LEVEL_FIELD
|
|
|
1616
1882
|
total: out.length
|
|
1617
1883
|
};
|
|
1618
1884
|
for (const row of out)summary[row.verdict] += 1;
|
|
1619
|
-
const
|
|
1885
|
+
const screening = photoScreening(productPlanPhotoUrls(out).length, photos, adapted.notes);
|
|
1886
|
+
const warnings = [
|
|
1887
|
+
...tally.list(WARNING_ORDER),
|
|
1888
|
+
...screening ? [
|
|
1889
|
+
screening
|
|
1890
|
+
] : []
|
|
1891
|
+
].sort((a, b)=>WARNING_ORDER.indexOf(a.class) - WARNING_ORDER.indexOf(b.class));
|
|
1620
1892
|
return {
|
|
1621
1893
|
rows: out,
|
|
1622
1894
|
summary,
|