@aglyn/plugins-commerce 1.0.0-beta.228 → 1.0.0-beta.230
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/product-zones.d.ts +14 -2
- package/src/lib/components/console/product-zones.js +10 -2
- package/src/lib/components/console/product-zones.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +39 -11
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/product-detail.js +3 -0
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/server/product-ai-capability.d.ts +42 -0
- package/src/lib/server/product-ai-capability.js +159 -0
- package/src/lib/server/product-ai-capability.js.map +1 -0
- package/src/lib/server/product-drafts.d.ts +119 -0
- package/src/lib/server/product-drafts.js +384 -0
- package/src/lib/server/product-drafts.js.map +1 -0
- package/src/lib/server.js +8 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/utils/use-storefront-purchase-event.js +4 -0
- package/src/lib/utils/use-storefront-purchase-event.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-commerce",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.230",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-ui-next": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-ui-snackstack": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-email": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
35
|
-
"@aglyn/shared-util-timestamp": "1.0.0-beta.
|
|
36
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
37
|
-
"@aglyn/tenant-data-admin": "1.0.0-beta.
|
|
38
|
-
"@aglyn/tenant-feature-instance": "1.0.0-beta.
|
|
39
|
-
"@aglyn/tenant-runtime": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.230",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.230",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.230",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.0.0-beta.230",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.0.0-beta.230",
|
|
33
|
+
"@aglyn/shared-util-email": "1.0.0-beta.230",
|
|
34
|
+
"@aglyn/shared-util-http": "1.0.0-beta.230",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.0.0-beta.230",
|
|
36
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.230",
|
|
37
|
+
"@aglyn/tenant-data-admin": "1.0.0-beta.230",
|
|
38
|
+
"@aglyn/tenant-feature-instance": "1.0.0-beta.230",
|
|
39
|
+
"@aglyn/tenant-runtime": "1.0.0-beta.230",
|
|
40
40
|
"@stripe/react-stripe-js": "^6.12.0",
|
|
41
41
|
"@stripe/stripe-js": "^9.17.0",
|
|
42
42
|
"@swc/helpers": "0.5.23",
|
|
@@ -175,11 +175,23 @@ export declare const PRODUCT_EDITOR_ZONE: import("@aglyn/aglyn/plugin-manager/pl
|
|
|
175
175
|
export declare const PRODUCTS_HUB_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<ConsoleProductsHubZoneProps>;
|
|
176
176
|
export declare const PRODUCT_IMPORT_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<ConsoleProductImportZoneProps>;
|
|
177
177
|
/**
|
|
178
|
-
*
|
|
178
|
+
* What the `productsCreate` zone hands each widget (AGL-3596): the site and
|
|
179
|
+
* its org. The zone sits beside Add product on the Products page and in the
|
|
180
|
+
* empty catalog: another way to start a product. A widget here writes nothing
|
|
181
|
+
* through the page — anything it proposes is applied through `productsHub`.
|
|
182
|
+
*/
|
|
183
|
+
export interface ConsoleProductsCreateZoneProps {
|
|
184
|
+
hostId: string;
|
|
185
|
+
/** The org the page names; `undefined` where the host does not know it. */
|
|
186
|
+
orgId: string | undefined;
|
|
187
|
+
}
|
|
188
|
+
export declare const PRODUCTS_CREATE_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<ConsoleProductsCreateZoneProps>;
|
|
189
|
+
/**
|
|
190
|
+
* Declares the four zones, from the console registrar. The ids are the ones
|
|
179
191
|
* widgets have always registered under, so a widget written for them keeps
|
|
180
192
|
* working. Each is `bare`: the section is one item of a layout this plugin
|
|
181
193
|
* draws — among the editor's fields, above the catalog table, in the import
|
|
182
|
-
* wizard's After import step — and a wrapper would add a gap the page
|
|
194
|
+
* wizard's After import step, in the row beside Add product — and a wrapper would add a gap the page
|
|
183
195
|
* already spaces.
|
|
184
196
|
*/
|
|
185
197
|
export declare function registerCommerceZones(): void;
|
|
@@ -18,12 +18,13 @@ import { BUNDLE_ID } from "../../constants/bundle-common.js";
|
|
|
18
18
|
export const PRODUCT_EDITOR_ZONE = definePluginZone('productEditor');
|
|
19
19
|
export const PRODUCTS_HUB_ZONE = definePluginZone('productsHub');
|
|
20
20
|
export const PRODUCT_IMPORT_ZONE = definePluginZone('productImport');
|
|
21
|
+
export const PRODUCTS_CREATE_ZONE = definePluginZone('productsCreate');
|
|
21
22
|
/**
|
|
22
|
-
* Declares the
|
|
23
|
+
* Declares the four zones, from the console registrar. The ids are the ones
|
|
23
24
|
* widgets have always registered under, so a widget written for them keeps
|
|
24
25
|
* working. Each is `bare`: the section is one item of a layout this plugin
|
|
25
26
|
* draws — among the editor's fields, above the catalog table, in the import
|
|
26
|
-
* wizard's After import step — and a wrapper would add a gap the page
|
|
27
|
+
* wizard's After import step, in the row beside Add product — and a wrapper would add a gap the page
|
|
27
28
|
* already spaces.
|
|
28
29
|
*/ export function registerCommerceZones() {
|
|
29
30
|
const owner = {
|
|
@@ -43,6 +44,13 @@ export const PRODUCT_IMPORT_ZONE = definePluginZone('productImport');
|
|
|
43
44
|
layout: 'bare',
|
|
44
45
|
description: 'Above the catalog table on the Products page. A widget here proposes copy, draft products, categories and switched-off discounts, and asks the hub to write them; every write is the hub’s, with its allowance and slug checks.'
|
|
45
46
|
}, owner);
|
|
47
|
+
registerPluginZone({
|
|
48
|
+
zone: PRODUCTS_CREATE_ZONE,
|
|
49
|
+
label: 'Start a product',
|
|
50
|
+
surface: 'console',
|
|
51
|
+
layout: 'bare',
|
|
52
|
+
description: 'Beside Add product on the Products page, and in the empty catalog: another way to start a product. A widget here is handed the site and its org and writes nothing through the page.'
|
|
53
|
+
}, owner);
|
|
46
54
|
registerPluginZone({
|
|
47
55
|
zone: PRODUCT_IMPORT_ZONE,
|
|
48
56
|
label: 'Product import',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/product-zones.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 {\n definePluginZone,\n registerPluginZone,\n} from '@aglyn/aglyn/plugin-manager/plugin-zones'\nimport { BUNDLE_ID } from '../../constants/bundle-common'\n\n/**\n * The zones this plugin hosts on its product surfaces (AGL-2916): the product\n * editor, the products hub and the import wizard's After import step.\n *\n * Each is drawn through the shell's renderer (`useConsoleWidgetSlot`), so a\n * widget there passes the same enablement, entitlement and permission gates as\n * one on a console page. The props are this plugin's words for its catalog,\n * declared on the zone's token; a widget from another plugin restates the\n * shape it reads rather than importing this package. A widget proposes and\n * never writes: every write is this plugin's, with the guards it carries.\n */\n\n/** A product type, as the commerce catalog names it. */\nexport type ConsoleProductType = 'physical' | 'digital' | 'service'\n\n/** A product option axis: its name and the values a shopper picks from. */\nexport interface ConsoleProductOption {\n name: string\n values: string[]\n}\n\n/** A product as the commerce editor holds it: saved, or staged and unsaved. */\nexport interface ConsoleProductDraft {\n /** `null` for a product nobody has saved yet. */\n id: string | null\n name: string\n type: ConsoleProductType\n description: string\n tags: string[]\n categoryIds: string[]\n options: ConsoleProductOption[]\n /** The product's media, in order; the first is the photo the storefront leads with. */\n mediaUrls: string[]\n seoTitle: string\n seoDescription: string\n}\n\n/**\n * Copy a widget proposes for one product. A field left out is left alone;\n * `optionNames` renames the product's options in order, keeping every\n * variant, and is ignored unless it names each option once.\n */\nexport interface ConsoleProductCopyValues {\n description?: string\n tags?: string[]\n categoryIds?: string[]\n optionNames?: string[]\n seoTitle?: string\n seoDescription?: string\n}\n\n/**\n * What the `productEditor` zone hands each widget: the product as the editor\n * holds it, and `proposeValues`, which stages copy in the editor as unsaved\n * edits. The zone sits under the product's description, tags and categories,\n * as the editor's search listing hosts `seoFields`. Save product is the\n * write, with the guards it carries.\n */\nexport interface ConsoleProductEditorZoneProps {\n hostId: string\n /** The org the page names; `undefined` where the host does not know it. */\n orgId: string | undefined\n product: ConsoleProductDraft\n /** The site's categories, as the editor's picker lists them. */\n categories: ReadonlyArray<{ id: string; name: string }>\n /**\n * Stages `values` in the editor as unsaved edits under `key`. Save product\n * is what stores them; a widget never writes the product itself.\n */\n proposeValues: (values: ConsoleProductCopyValues, key: string) => void\n}\n\n/** A catalog row as the products hub holds it. */\nexport interface ConsoleProductSummary {\n id: string\n name: string\n status: 'draft' | 'active' | 'archived'\n /** Whether a variant of the product has no price yet. */\n priceMissing: boolean\n /** Whether the product has a photo. */\n hasPhoto: boolean\n}\n\n/** A new product a widget asks the hub to create, always as a draft with no price. */\nexport interface ConsoleProposedProduct {\n name: string\n type: ConsoleProductType\n description: string\n tags: string[]\n options: ConsoleProductOption[]\n seoTitle: string\n seoDescription: string\n}\n\n/** A discount a widget asks the hub to create, always switched off. */\nexport interface ConsoleProposedDiscount {\n name: string\n /** The code a shopper types, or `null` for a discount that applies on its own. */\n code: string | null\n kind: 'percent' | 'fixed' | 'free_shipping'\n valuePct: number | null\n valueCents: number | null\n minSubtotalCents: number | null\n}\n\n/**\n * What the `productsHub` zone hands each widget: the catalog rows the hub\n * holds, the products its latest import created, and the hub's own writes a\n * widget may ask it to make — copy onto saved products, new draft products,\n * categories and switched-off discounts. The zone sits above the catalog\n * table. Each write is the hub's, with its seed, allowance and slug checks; a\n * widget writes nothing itself. Every write resolves once it is stored and\n * throws with a message a person can act on when the hub refuses it: an\n * allowance the plan has no room for, a product that is gone.\n *\n * The creates are safe to ask twice: a product or a category named like one\n * the site has, and a discount with the code (or, with no code, the name) of\n * one the site has, are passed over, so a proposal applied again, by anyone,\n * creates nothing it already created.\n */\nexport interface ConsoleProductsHubZoneProps {\n hostId: string\n /** The org the page names; `undefined` where the host does not know it. */\n orgId: string | undefined\n /** The catalog rows the hub holds, in its order. */\n products: readonly ConsoleProductSummary[]\n /**\n * The products the hub's latest import created in this visit, and the\n * options the `productImport` zone set for them; `null` before any import.\n * `key` is new for each import.\n */\n lastImport: {\n key: string\n productIds: readonly string[]\n options: Readonly<Record<string, boolean>>\n } | null\n /** Writes copy onto a saved product, read fresh from the store. */\n applyProductCopy: (productId: string, values: ConsoleProductCopyValues) => Promise<void>\n /** Creates each product as a draft with no price, and resolves with the ids it created. */\n createProductDrafts: (products: readonly ConsoleProposedProduct[]) => Promise<string[]>\n /** Creates categories by name, and resolves with how many it created. */\n createCategories: (names: readonly string[]) => Promise<number>\n /** Creates each discount switched off, and resolves with how many it created. */\n createDiscountDrafts: (discounts: readonly ConsoleProposedDiscount[]) => Promise<number>\n}\n\n/**\n * What the `productImport` zone hands each widget, in the import wizard's\n * After import step: how many products the import creates, and options a widget sets\n * for what happens to them once they land. The hub hands the options, with\n * the ids of the products the import created, to `productsHub` as its\n * `lastImport`.\n */\nexport interface ConsoleProductImportZoneProps {\n hostId: string\n /** The org the page names; `undefined` where the host does not know it. */\n orgId: string | undefined\n /** How many products the import creates. */\n count: number\n /** The options set for this import, by key. */\n options: Readonly<Record<string, boolean>>\n /** Sets one option; the hub carries it to `productsHub` with what the import created. */\n setOption: (key: string, on: boolean) => void\n}\n\nexport const PRODUCT_EDITOR_ZONE =\n definePluginZone<ConsoleProductEditorZoneProps>('productEditor')\n\nexport const PRODUCTS_HUB_ZONE =\n definePluginZone<ConsoleProductsHubZoneProps>('productsHub')\n\nexport const PRODUCT_IMPORT_ZONE =\n definePluginZone<ConsoleProductImportZoneProps>('productImport')\n\n/**\n * Declares the three zones, from the console registrar. The ids are the ones\n * widgets have always registered under, so a widget written for them keeps\n * working. Each is `bare`: the section is one item of a layout this plugin\n * draws — among the editor's fields, above the catalog table, in the import\n * wizard's After import step — and a wrapper would add a gap the page\n * already spaces.\n */\nexport function registerCommerceZones(): void {\n const owner = { pluginId: BUNDLE_ID }\n registerPluginZone(\n {\n zone: PRODUCT_EDITOR_ZONE,\n label: 'Product editor',\n surface: 'console',\n layout: 'bare',\n description:\n 'Under a product’s description, tags and categories in the product editor. A widget here proposes copy for the fields through `proposeValues`, staged as unsaved edits; Save product is the write.',\n },\n owner,\n )\n registerPluginZone(\n {\n zone: PRODUCTS_HUB_ZONE,\n label: 'Products hub',\n surface: 'console',\n layout: 'bare',\n description:\n 'Above the catalog table on the Products page. A widget here proposes copy, draft products, categories and switched-off discounts, and asks the hub to write them; every write is the hub’s, with its allowance and slug checks.',\n },\n owner,\n )\n registerPluginZone(\n {\n zone: PRODUCT_IMPORT_ZONE,\n label: 'Product import',\n surface: 'console',\n layout: 'bare',\n description:\n 'In the product import wizard’s After import step. A widget here sets options for what happens to the imported products once they land; the hub hands them to `productsHub` with the ids the import created.',\n },\n owner,\n )\n}\n"],"names":["definePluginZone","registerPluginZone","BUNDLE_ID","PRODUCT_EDITOR_ZONE","PRODUCTS_HUB_ZONE","PRODUCT_IMPORT_ZONE","registerCommerceZones","owner","pluginId","zone","label","surface","layout","description"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,gBAAgB,EAChBC,kBAAkB,QACb,2CAA0C;AACjD,SAASC,SAAS,QAAQ,mCAA+B;AAuKzD,OAAO,MAAMC,sBACXH,iBAAgD,iBAAgB;AAElE,OAAO,MAAMI,oBACXJ,iBAA8C,eAAc;AAE9D,OAAO,MAAMK,sBACXL,iBAAgD,iBAAgB;AAElE;;;;;;;CAOC,GACD,OAAO,SAASM;IACd,MAAMC,QAAQ;QAAEC,UAAUN;IAAU;IACpCD,mBACE;QACEQ,MAAMN;QACNO,OAAO;QACPC,SAAS;QACTC,QAAQ;QACRC,aACE;IACJ,GACAN;IAEFN,mBACE;QACEQ,MAAML;QACNM,OAAO;QACPC,SAAS;QACTC,QAAQ;QACRC,aACE;IACJ,GACAN;IAEFN,mBACE;QACEQ,MAAMJ;QACNK,OAAO;QACPC,SAAS;QACTC,QAAQ;QACRC,aACE;IACJ,GACAN;AAEJ"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/product-zones.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 {\n definePluginZone,\n registerPluginZone,\n} from '@aglyn/aglyn/plugin-manager/plugin-zones'\nimport { BUNDLE_ID } from '../../constants/bundle-common'\n\n/**\n * The zones this plugin hosts on its product surfaces (AGL-2916): the product\n * editor, the products hub and the import wizard's After import step.\n *\n * Each is drawn through the shell's renderer (`useConsoleWidgetSlot`), so a\n * widget there passes the same enablement, entitlement and permission gates as\n * one on a console page. The props are this plugin's words for its catalog,\n * declared on the zone's token; a widget from another plugin restates the\n * shape it reads rather than importing this package. A widget proposes and\n * never writes: every write is this plugin's, with the guards it carries.\n */\n\n/** A product type, as the commerce catalog names it. */\nexport type ConsoleProductType = 'physical' | 'digital' | 'service'\n\n/** A product option axis: its name and the values a shopper picks from. */\nexport interface ConsoleProductOption {\n name: string\n values: string[]\n}\n\n/** A product as the commerce editor holds it: saved, or staged and unsaved. */\nexport interface ConsoleProductDraft {\n /** `null` for a product nobody has saved yet. */\n id: string | null\n name: string\n type: ConsoleProductType\n description: string\n tags: string[]\n categoryIds: string[]\n options: ConsoleProductOption[]\n /** The product's media, in order; the first is the photo the storefront leads with. */\n mediaUrls: string[]\n seoTitle: string\n seoDescription: string\n}\n\n/**\n * Copy a widget proposes for one product. A field left out is left alone;\n * `optionNames` renames the product's options in order, keeping every\n * variant, and is ignored unless it names each option once.\n */\nexport interface ConsoleProductCopyValues {\n description?: string\n tags?: string[]\n categoryIds?: string[]\n optionNames?: string[]\n seoTitle?: string\n seoDescription?: string\n}\n\n/**\n * What the `productEditor` zone hands each widget: the product as the editor\n * holds it, and `proposeValues`, which stages copy in the editor as unsaved\n * edits. The zone sits under the product's description, tags and categories,\n * as the editor's search listing hosts `seoFields`. Save product is the\n * write, with the guards it carries.\n */\nexport interface ConsoleProductEditorZoneProps {\n hostId: string\n /** The org the page names; `undefined` where the host does not know it. */\n orgId: string | undefined\n product: ConsoleProductDraft\n /** The site's categories, as the editor's picker lists them. */\n categories: ReadonlyArray<{ id: string; name: string }>\n /**\n * Stages `values` in the editor as unsaved edits under `key`. Save product\n * is what stores them; a widget never writes the product itself.\n */\n proposeValues: (values: ConsoleProductCopyValues, key: string) => void\n}\n\n/** A catalog row as the products hub holds it. */\nexport interface ConsoleProductSummary {\n id: string\n name: string\n status: 'draft' | 'active' | 'archived'\n /** Whether a variant of the product has no price yet. */\n priceMissing: boolean\n /** Whether the product has a photo. */\n hasPhoto: boolean\n}\n\n/** A new product a widget asks the hub to create, always as a draft with no price. */\nexport interface ConsoleProposedProduct {\n name: string\n type: ConsoleProductType\n description: string\n tags: string[]\n options: ConsoleProductOption[]\n seoTitle: string\n seoDescription: string\n}\n\n/** A discount a widget asks the hub to create, always switched off. */\nexport interface ConsoleProposedDiscount {\n name: string\n /** The code a shopper types, or `null` for a discount that applies on its own. */\n code: string | null\n kind: 'percent' | 'fixed' | 'free_shipping'\n valuePct: number | null\n valueCents: number | null\n minSubtotalCents: number | null\n}\n\n/**\n * What the `productsHub` zone hands each widget: the catalog rows the hub\n * holds, the products its latest import created, and the hub's own writes a\n * widget may ask it to make — copy onto saved products, new draft products,\n * categories and switched-off discounts. The zone sits above the catalog\n * table. Each write is the hub's, with its seed, allowance and slug checks; a\n * widget writes nothing itself. Every write resolves once it is stored and\n * throws with a message a person can act on when the hub refuses it: an\n * allowance the plan has no room for, a product that is gone.\n *\n * The creates are safe to ask twice: a product or a category named like one\n * the site has, and a discount with the code (or, with no code, the name) of\n * one the site has, are passed over, so a proposal applied again, by anyone,\n * creates nothing it already created.\n */\nexport interface ConsoleProductsHubZoneProps {\n hostId: string\n /** The org the page names; `undefined` where the host does not know it. */\n orgId: string | undefined\n /** The catalog rows the hub holds, in its order. */\n products: readonly ConsoleProductSummary[]\n /**\n * The products the hub's latest import created in this visit, and the\n * options the `productImport` zone set for them; `null` before any import.\n * `key` is new for each import.\n */\n lastImport: {\n key: string\n productIds: readonly string[]\n options: Readonly<Record<string, boolean>>\n } | null\n /** Writes copy onto a saved product, read fresh from the store. */\n applyProductCopy: (productId: string, values: ConsoleProductCopyValues) => Promise<void>\n /** Creates each product as a draft with no price, and resolves with the ids it created. */\n createProductDrafts: (products: readonly ConsoleProposedProduct[]) => Promise<string[]>\n /** Creates categories by name, and resolves with how many it created. */\n createCategories: (names: readonly string[]) => Promise<number>\n /** Creates each discount switched off, and resolves with how many it created. */\n createDiscountDrafts: (discounts: readonly ConsoleProposedDiscount[]) => Promise<number>\n}\n\n/**\n * What the `productImport` zone hands each widget, in the import wizard's\n * After import step: how many products the import creates, and options a widget sets\n * for what happens to them once they land. The hub hands the options, with\n * the ids of the products the import created, to `productsHub` as its\n * `lastImport`.\n */\nexport interface ConsoleProductImportZoneProps {\n hostId: string\n /** The org the page names; `undefined` where the host does not know it. */\n orgId: string | undefined\n /** How many products the import creates. */\n count: number\n /** The options set for this import, by key. */\n options: Readonly<Record<string, boolean>>\n /** Sets one option; the hub carries it to `productsHub` with what the import created. */\n setOption: (key: string, on: boolean) => void\n}\n\nexport const PRODUCT_EDITOR_ZONE =\n definePluginZone<ConsoleProductEditorZoneProps>('productEditor')\n\nexport const PRODUCTS_HUB_ZONE =\n definePluginZone<ConsoleProductsHubZoneProps>('productsHub')\n\nexport const PRODUCT_IMPORT_ZONE =\n definePluginZone<ConsoleProductImportZoneProps>('productImport')\n\n/**\n * What the `productsCreate` zone hands each widget (AGL-3596): the site and\n * its org. The zone sits beside Add product on the Products page and in the\n * empty catalog: another way to start a product. A widget here writes nothing\n * through the page — anything it proposes is applied through `productsHub`.\n */\nexport interface ConsoleProductsCreateZoneProps {\n hostId: string\n /** The org the page names; `undefined` where the host does not know it. */\n orgId: string | undefined\n}\n\nexport const PRODUCTS_CREATE_ZONE =\n definePluginZone<ConsoleProductsCreateZoneProps>('productsCreate')\n\n/**\n * Declares the four zones, from the console registrar. The ids are the ones\n * widgets have always registered under, so a widget written for them keeps\n * working. Each is `bare`: the section is one item of a layout this plugin\n * draws — among the editor's fields, above the catalog table, in the import\n * wizard's After import step, in the row beside Add product — and a wrapper would add a gap the page\n * already spaces.\n */\nexport function registerCommerceZones(): void {\n const owner = { pluginId: BUNDLE_ID }\n registerPluginZone(\n {\n zone: PRODUCT_EDITOR_ZONE,\n label: 'Product editor',\n surface: 'console',\n layout: 'bare',\n description:\n 'Under a product’s description, tags and categories in the product editor. A widget here proposes copy for the fields through `proposeValues`, staged as unsaved edits; Save product is the write.',\n },\n owner,\n )\n registerPluginZone(\n {\n zone: PRODUCTS_HUB_ZONE,\n label: 'Products hub',\n surface: 'console',\n layout: 'bare',\n description:\n 'Above the catalog table on the Products page. A widget here proposes copy, draft products, categories and switched-off discounts, and asks the hub to write them; every write is the hub’s, with its allowance and slug checks.',\n },\n owner,\n )\n registerPluginZone(\n {\n zone: PRODUCTS_CREATE_ZONE,\n label: 'Start a product',\n surface: 'console',\n layout: 'bare',\n description:\n 'Beside Add product on the Products page, and in the empty catalog: another way to start a product. A widget here is handed the site and its org and writes nothing through the page.',\n },\n owner,\n )\n registerPluginZone(\n {\n zone: PRODUCT_IMPORT_ZONE,\n label: 'Product import',\n surface: 'console',\n layout: 'bare',\n description:\n 'In the product import wizard’s After import step. A widget here sets options for what happens to the imported products once they land; the hub hands them to `productsHub` with the ids the import created.',\n },\n owner,\n )\n}\n"],"names":["definePluginZone","registerPluginZone","BUNDLE_ID","PRODUCT_EDITOR_ZONE","PRODUCTS_HUB_ZONE","PRODUCT_IMPORT_ZONE","PRODUCTS_CREATE_ZONE","registerCommerceZones","owner","pluginId","zone","label","surface","layout","description"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,gBAAgB,EAChBC,kBAAkB,QACb,2CAA0C;AACjD,SAASC,SAAS,QAAQ,mCAA+B;AAuKzD,OAAO,MAAMC,sBACXH,iBAAgD,iBAAgB;AAElE,OAAO,MAAMI,oBACXJ,iBAA8C,eAAc;AAE9D,OAAO,MAAMK,sBACXL,iBAAgD,iBAAgB;AAclE,OAAO,MAAMM,uBACXN,iBAAiD,kBAAiB;AAEpE;;;;;;;CAOC,GACD,OAAO,SAASO;IACd,MAAMC,QAAQ;QAAEC,UAAUP;IAAU;IACpCD,mBACE;QACES,MAAMP;QACNQ,OAAO;QACPC,SAAS;QACTC,QAAQ;QACRC,aACE;IACJ,GACAN;IAEFP,mBACE;QACES,MAAMN;QACNO,OAAO;QACPC,SAAS;QACTC,QAAQ;QACRC,aACE;IACJ,GACAN;IAEFP,mBACE;QACES,MAAMJ;QACNK,OAAO;QACPC,SAAS;QACTC,QAAQ;QACRC,aACE;IACJ,GACAN;IAEFP,mBACE;QACES,MAAML;QACNM,OAAO;QACPC,SAAS;QACTC,QAAQ;QACRC,aACE;IACJ,GACAN;AAEJ"}
|
|
@@ -18,6 +18,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
18
18
|
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
19
19
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
20
|
import { TransferResumeImport } from "@aglyn/aglyn/app-utils/transfer-resume-import";
|
|
21
|
+
import { useConsoleWidgetSlot } from "@aglyn/aglyn/app-utils/console-widget-slot-context";
|
|
21
22
|
import * as Aglyn from "@aglyn/aglyn";
|
|
22
23
|
import * as CommerceModel from "../../model/index.js";
|
|
23
24
|
import { PRODUCT_LIST_BASE, PRODUCT_LIST_FIELDS, PRODUCT_LIST_HEADERS, PRODUCT_LIST_OPTIONS, PRODUCT_LIST_QUERY, PRODUCT_LIST_SELECT_FIELDS, productListRequestClauses } from "../../constants/product-list-query.js";
|
|
@@ -46,6 +47,7 @@ import { productSlugLedger } from "./product-slugs.js";
|
|
|
46
47
|
import { productCollectionFields } from "./smart-collections.js";
|
|
47
48
|
import ProductsHubZone from "./products-hub-zone.component.js";
|
|
48
49
|
import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
50
|
+
import { PRODUCTS_CREATE_ZONE } from "./product-zones.js";
|
|
49
51
|
import { commerceListFilter } from "../../transfer/list-filter.js";
|
|
50
52
|
import { COMMERCE_PRODUCTS_TRANSFER } from "../../transfer/transfer-keys.js";
|
|
51
53
|
/**
|
|
@@ -77,6 +79,7 @@ const STATUS_COLOR = {
|
|
|
77
79
|
*/ export function ProductsHubCard(props) {
|
|
78
80
|
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11;
|
|
79
81
|
const { hostId } = props;
|
|
82
|
+
/** The shell's zone renderer, for the `productsCreate` zone (AGL-3596). */ const CreateZone = useConsoleWidgetSlot();
|
|
80
83
|
const firestore = useFirestore();
|
|
81
84
|
const { data: user } = useUser();
|
|
82
85
|
const { enqueueSnackbar } = useSnackbar();
|
|
@@ -687,6 +690,26 @@ const STATUS_COLOR = {
|
|
|
687
690
|
width: 470
|
|
688
691
|
})
|
|
689
692
|
], PRODUCT_LIST_FIELDS, PRODUCT_LIST_OPTIONS, PRODUCT_LIST_HEADERS);
|
|
693
|
+
/** Add product: the quota first, then the create drawer. */ const startAddProduct = ()=>{
|
|
694
|
+
if (!productQuota) return;
|
|
695
|
+
if (!productQuota.allowed) {
|
|
696
|
+
return void enqueueSnackbar(`Your plan includes ${productQuota.limit} products — ` + 'upgrade for more', {
|
|
697
|
+
variant: 'info',
|
|
698
|
+
persist: false
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
setCreating(true);
|
|
702
|
+
};
|
|
703
|
+
/*
|
|
704
|
+
* Other ways to start a product (AGL-3596): the `productsCreate` zone this
|
|
705
|
+
* plugin declares, drawn through the shell's gated slot beside Add product
|
|
706
|
+
* and again in the empty catalog. `null` outside the console shell. The
|
|
707
|
+
* org is not this page's to know, so a widget reads it from the site.
|
|
708
|
+
*/ const createZone = CreateZone ? /*#__PURE__*/ _jsx(CreateZone, {
|
|
709
|
+
slot: PRODUCTS_CREATE_ZONE.id,
|
|
710
|
+
hostId: hostId,
|
|
711
|
+
orgId: undefined
|
|
712
|
+
}) : null;
|
|
690
713
|
return /*#__PURE__*/ _jsxs(CardDisplay, {
|
|
691
714
|
/*
|
|
692
715
|
* The header count is the SITE'S catalog, not the rows in hand.
|
|
@@ -720,21 +743,13 @@ const STATUS_COLOR = {
|
|
|
720
743
|
flex: 1
|
|
721
744
|
}
|
|
722
745
|
}),
|
|
746
|
+
createZone,
|
|
723
747
|
/*#__PURE__*/ _jsx(Button, {
|
|
724
748
|
variant: "contained",
|
|
725
749
|
color: "primary",
|
|
726
750
|
size: "small",
|
|
727
751
|
disabled: !productQuota,
|
|
728
|
-
onClick:
|
|
729
|
-
if (!productQuota) return;
|
|
730
|
-
if (!productQuota.allowed) {
|
|
731
|
-
return void enqueueSnackbar(`Your plan includes ${productQuota.limit} products — ` + 'upgrade for more', {
|
|
732
|
-
variant: 'info',
|
|
733
|
-
persist: false
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
setCreating(true);
|
|
737
|
-
},
|
|
752
|
+
onClick: startAddProduct,
|
|
738
753
|
children: 'Add product'
|
|
739
754
|
}),
|
|
740
755
|
/*#__PURE__*/ _jsx(TransferResumeImport, {
|
|
@@ -817,7 +832,20 @@ const STATUS_COLOR = {
|
|
|
817
832
|
}
|
|
818
833
|
},
|
|
819
834
|
noRowsLabel: filtering ? 'No products match these filters' : 'No products yet',
|
|
820
|
-
noRowsDescription: filtering ? undefined : 'Build your catalog: add a product, then drop commerce ' + 'blocks on any page in Besigner.'
|
|
835
|
+
noRowsDescription: filtering ? undefined : 'Build your catalog: add a product, then drop commerce ' + 'blocks on any page in Besigner.',
|
|
836
|
+
noRowsAction: filtering ? undefined : /*#__PURE__*/ _jsxs(Stack, {
|
|
837
|
+
direction: "row",
|
|
838
|
+
spacing: 1,
|
|
839
|
+
children: [
|
|
840
|
+
createZone,
|
|
841
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
842
|
+
variant: "contained",
|
|
843
|
+
disabled: !productQuota,
|
|
844
|
+
onClick: startAddProduct,
|
|
845
|
+
children: 'Add your first product'
|
|
846
|
+
})
|
|
847
|
+
]
|
|
848
|
+
})
|
|
821
849
|
}),
|
|
822
850
|
products.length === 0 && page === 0 && productsStatus !== 'loading' ? null : /* The count line is the PAGE's. `hasMore` is a fact from the probe
|
|
823
851
|
row; the site's total is `productCount` above, which counts the
|