@aglyn/plugins-commerce 1.0.0-beta.218 → 1.0.0-beta.220
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +14 -14
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -19
- package/src/index.js.map +1 -1
- package/src/lib/components/cart.js +2 -1
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/catalog-organization-card.component.js +665 -459
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/host-orders-card.component.js +2 -1
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/member-posts-card.component.js +1 -1
- package/src/lib/components/console/member-posts-card.component.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +8 -7
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/payments-settings-card.component.js +2 -2
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +1221 -889
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-zones.d.ts +184 -0
- package/src/lib/components/console/product-zones.js +54 -0
- package/src/lib/components/console/product-zones.js.map +1 -0
- package/src/lib/components/console/products-hub-card.component.js +3 -2
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/products-hub-zone.component.d.ts +1 -1
- package/src/lib/components/console/products-hub-zone.component.js +2 -1
- package/src/lib/components/console/products-hub-zone.component.js.map +1 -1
- package/src/lib/components/console/site-member-purchases.component.d.ts +24 -0
- package/src/lib/components/console/site-member-purchases.component.js +339 -0
- package/src/lib/components/console/site-member-purchases.component.js.map +1 -0
- package/src/lib/components/console/store-settings-card.component.js +2 -2
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/storefront-tax-summary-card.component.js +1 -1
- package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -1
- package/src/lib/components/member-signup.js +2 -2
- package/src/lib/components/member-signup.js.map +1 -1
- package/src/lib/components/newsletter-signup.js +2 -2
- package/src/lib/components/newsletter-signup.js.map +1 -1
- package/src/lib/components/product-detail.js +2 -1
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.js +1 -1
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/constants/operator-alerts.js +5 -3
- package/src/lib/constants/operator-alerts.js.map +1 -1
- package/src/lib/constants/storefront-payments.d.ts +33 -0
- package/src/lib/constants/storefront-payments.js +35 -0
- package/src/lib/constants/storefront-payments.js.map +1 -0
- package/src/lib/declarations.server.d.ts +3 -1
- package/src/lib/declarations.server.js +19 -1
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/commerce-io.js +1 -1
- package/src/lib/model/commerce-io.js.map +1 -1
- package/src/lib/model/commerce-record-lists.d.ts +31 -0
- package/src/lib/model/commerce-record-lists.js +45 -0
- package/src/lib/model/commerce-record-lists.js.map +1 -0
- package/src/lib/model/commerce-record-routes.d.ts +45 -0
- package/src/lib/model/commerce-record-routes.js +72 -0
- package/src/lib/model/commerce-record-routes.js.map +1 -0
- package/src/lib/model/commerce-search-sources.d.ts +21 -0
- package/src/lib/model/commerce-search-sources.js +42 -0
- package/src/lib/model/commerce-search-sources.js.map +1 -0
- package/src/lib/model/commerce-topics.d.ts +20 -0
- package/src/lib/model/commerce-topics.js +33 -0
- package/src/lib/model/commerce-topics.js.map +1 -0
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/product-record.d.ts +32 -0
- package/src/lib/model/product-record.js +82 -0
- package/src/lib/model/product-record.js.map +1 -0
- package/src/lib/model/site-member-purchases.d.ts +48 -0
- package/src/lib/model/site-member-purchases.js +50 -0
- package/src/lib/model/site-member-purchases.js.map +1 -0
- package/src/lib/model/storefront-tax-summary.d.ts +121 -0
- package/src/lib/model/storefront-tax-summary.js +148 -0
- package/src/lib/model/storefront-tax-summary.js.map +1 -0
- package/src/lib/plan-entitlements.d.ts +35 -0
- package/src/lib/plan-entitlements.js +54 -0
- package/src/lib/plan-entitlements.js.map +1 -0
- package/src/lib/plugin.js +21 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/billing-webhook.js +387 -248
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cart-checkout.js +3 -3
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/checkout.js +2 -2
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/connect.js +5 -5
- package/src/lib/server/connect.js.map +1 -1
- package/src/lib/server/draft-order.js +2 -2
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/gift-cards.js +7 -3
- package/src/lib/server/gift-cards.js.map +1 -1
- package/src/lib/server/low-stock.js +3 -1
- package/src/lib/server/low-stock.js.map +1 -1
- package/src/lib/server/member-post.js +2 -2
- package/src/lib/server/member-post.js.map +1 -1
- package/src/lib/server/membership-admin-password.js +4 -1
- package/src/lib/server/membership-admin-password.js.map +1 -1
- package/src/lib/server/membership-content.js +1 -1
- package/src/lib/server/membership-content.js.map +1 -1
- package/src/lib/server/membership-register.js +13 -2
- package/src/lib/server/membership-register.js.map +1 -1
- package/src/lib/server/newsletter.js +32 -19
- package/src/lib/server/newsletter.js.map +1 -1
- package/src/lib/server/pos-order.js +3 -3
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/process-abandoned.js +4 -2
- package/src/lib/server/process-abandoned.js.map +1 -1
- package/src/lib/server/process-restock.js +7 -5
- package/src/lib/server/process-restock.js.map +1 -1
- package/src/lib/server/product-record-index.d.ts +19 -0
- package/src/lib/server/product-record-index.js +83 -0
- package/src/lib/server/product-record-index.js.map +1 -0
- package/src/lib/server/reconcile-stock.js +1 -1
- package/src/lib/server/reconcile-stock.js.map +1 -1
- package/src/lib/server/reserve-stock.js +6 -1
- package/src/lib/server/reserve-stock.js.map +1 -1
- package/src/lib/server/reserve.js +2 -2
- package/src/lib/server/reserve.js.map +1 -1
- package/src/lib/server/revenue-source.d.ts +130 -0
- package/src/lib/server/revenue-source.js +286 -0
- package/src/lib/server/revenue-source.js.map +1 -0
- package/src/lib/server/supplier-outbox.js +16 -1
- package/src/lib/server/supplier-outbox.js.map +1 -1
- package/src/lib/server/supplier-update.js +19 -9
- package/src/lib/server/supplier-update.js.map +1 -1
- package/src/lib/server/tax-profile.d.ts +8 -5
- package/src/lib/server/tax-profile.js +22 -5
- package/src/lib/server/tax-profile.js.map +1 -1
- package/src/lib/server/tax-return-source.d.ts +125 -0
- package/src/lib/server/tax-return-source.js +524 -0
- package/src/lib/server/tax-return-source.js.map +1 -0
- package/src/lib/server/tax-summary.d.ts +92 -0
- package/src/lib/server/tax-summary.js +258 -0
- package/src/lib/server/tax-summary.js.map +1 -0
- package/src/lib/server.d.ts +1 -0
- package/src/lib/server.js +23 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/starter-templates.d.ts +19 -0
- package/src/lib/starter-templates.js +157 -0
- package/src/lib/starter-templates.js.map +1 -0
- package/src/lib/tenant-emails.d.ts +33 -0
- package/src/lib/tenant-emails.js +551 -0
- package/src/lib/tenant-emails.js.map +1 -0
- package/src/lib/testing/stand-in-crm-record-routes.d.ts +25 -0
- package/src/lib/testing/stand-in-crm-record-routes.js +46 -0
- package/src/lib/testing/stand-in-crm-record-routes.js.map +1 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The zones this plugin hosts on its product surfaces (AGL-2916): the product
|
|
19
|
+
* editor, the products hub and the CSV import dialog.
|
|
20
|
+
*
|
|
21
|
+
* Each is drawn through the shell's renderer (`useConsoleWidgetSlot`), so a
|
|
22
|
+
* widget there passes the same enablement, entitlement and permission gates as
|
|
23
|
+
* one on a console page. The props are this plugin's words for its catalog,
|
|
24
|
+
* declared on the zone's token; a widget from another plugin restates the
|
|
25
|
+
* shape it reads rather than importing this package. A widget proposes and
|
|
26
|
+
* never writes: every write is this plugin's, with the guards it carries.
|
|
27
|
+
*/
|
|
28
|
+
/** A product type, as the commerce catalog names it. */
|
|
29
|
+
export type ConsoleProductType = 'physical' | 'digital' | 'service';
|
|
30
|
+
/** A product option axis: its name and the values a shopper picks from. */
|
|
31
|
+
export interface ConsoleProductOption {
|
|
32
|
+
name: string;
|
|
33
|
+
values: string[];
|
|
34
|
+
}
|
|
35
|
+
/** A product as the commerce editor holds it: saved, or staged and unsaved. */
|
|
36
|
+
export interface ConsoleProductDraft {
|
|
37
|
+
/** `null` for a product nobody has saved yet. */
|
|
38
|
+
id: string | null;
|
|
39
|
+
name: string;
|
|
40
|
+
type: ConsoleProductType;
|
|
41
|
+
description: string;
|
|
42
|
+
tags: string[];
|
|
43
|
+
categoryIds: string[];
|
|
44
|
+
options: ConsoleProductOption[];
|
|
45
|
+
/** The product's media, in order; the first is the photo the storefront leads with. */
|
|
46
|
+
mediaUrls: string[];
|
|
47
|
+
seoTitle: string;
|
|
48
|
+
seoDescription: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Copy a widget proposes for one product. A field left out is left alone;
|
|
52
|
+
* `optionNames` renames the product's options in order, keeping every
|
|
53
|
+
* variant, and is ignored unless it names each option once.
|
|
54
|
+
*/
|
|
55
|
+
export interface ConsoleProductCopyValues {
|
|
56
|
+
description?: string;
|
|
57
|
+
tags?: string[];
|
|
58
|
+
categoryIds?: string[];
|
|
59
|
+
optionNames?: string[];
|
|
60
|
+
seoTitle?: string;
|
|
61
|
+
seoDescription?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* What the `productEditor` zone hands each widget: the product as the editor
|
|
65
|
+
* holds it, and `proposeValues`, which stages copy in the editor as unsaved
|
|
66
|
+
* edits. The zone sits under the product's description, tags and categories,
|
|
67
|
+
* as the editor's search listing hosts `seoFields`. Save product is the
|
|
68
|
+
* write, with the guards it carries.
|
|
69
|
+
*/
|
|
70
|
+
export interface ConsoleProductEditorZoneProps {
|
|
71
|
+
hostId: string;
|
|
72
|
+
/** The org the page names; `undefined` where the host does not know it. */
|
|
73
|
+
orgId: string | undefined;
|
|
74
|
+
product: ConsoleProductDraft;
|
|
75
|
+
/** The site's categories, as the editor's picker lists them. */
|
|
76
|
+
categories: ReadonlyArray<{
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Stages `values` in the editor as unsaved edits under `key`. Save product
|
|
82
|
+
* is what stores them; a widget never writes the product itself.
|
|
83
|
+
*/
|
|
84
|
+
proposeValues: (values: ConsoleProductCopyValues, key: string) => void;
|
|
85
|
+
}
|
|
86
|
+
/** A catalog row as the products hub holds it. */
|
|
87
|
+
export interface ConsoleProductSummary {
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
status: 'draft' | 'active' | 'archived';
|
|
91
|
+
/** Whether a variant of the product has no price yet. */
|
|
92
|
+
priceMissing: boolean;
|
|
93
|
+
/** Whether the product has a photo. */
|
|
94
|
+
hasPhoto: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** A new product a widget asks the hub to create, always as a draft with no price. */
|
|
97
|
+
export interface ConsoleProposedProduct {
|
|
98
|
+
name: string;
|
|
99
|
+
type: ConsoleProductType;
|
|
100
|
+
description: string;
|
|
101
|
+
tags: string[];
|
|
102
|
+
options: ConsoleProductOption[];
|
|
103
|
+
seoTitle: string;
|
|
104
|
+
seoDescription: string;
|
|
105
|
+
}
|
|
106
|
+
/** A discount a widget asks the hub to create, always switched off. */
|
|
107
|
+
export interface ConsoleProposedDiscount {
|
|
108
|
+
name: string;
|
|
109
|
+
/** The code a shopper types, or `null` for a discount that applies on its own. */
|
|
110
|
+
code: string | null;
|
|
111
|
+
kind: 'percent' | 'fixed' | 'free_shipping';
|
|
112
|
+
valuePct: number | null;
|
|
113
|
+
valueCents: number | null;
|
|
114
|
+
minSubtotalCents: number | null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What the `productsHub` zone hands each widget: the catalog rows the hub
|
|
118
|
+
* holds, the products its latest import created, and the hub's own writes a
|
|
119
|
+
* widget may ask it to make — copy onto saved products, new draft products,
|
|
120
|
+
* categories and switched-off discounts. The zone sits above the catalog
|
|
121
|
+
* table. Each write is the hub's, with its seed, allowance and slug checks; a
|
|
122
|
+
* widget writes nothing itself. Every write resolves once it is stored and
|
|
123
|
+
* throws with a message a person can act on when the hub refuses it: an
|
|
124
|
+
* allowance the plan has no room for, a product that is gone.
|
|
125
|
+
*
|
|
126
|
+
* The creates are safe to ask twice: a product or a category named like one
|
|
127
|
+
* the site has, and a discount with the code (or, with no code, the name) of
|
|
128
|
+
* one the site has, are passed over, so a proposal applied again, by anyone,
|
|
129
|
+
* creates nothing it already created.
|
|
130
|
+
*/
|
|
131
|
+
export interface ConsoleProductsHubZoneProps {
|
|
132
|
+
hostId: string;
|
|
133
|
+
/** The org the page names; `undefined` where the host does not know it. */
|
|
134
|
+
orgId: string | undefined;
|
|
135
|
+
/** The catalog rows the hub holds, in its order. */
|
|
136
|
+
products: readonly ConsoleProductSummary[];
|
|
137
|
+
/**
|
|
138
|
+
* The products the hub's latest CSV import created in this visit, and the
|
|
139
|
+
* options the `productImport` zone set for them; `null` before any import.
|
|
140
|
+
* `key` is new for each import.
|
|
141
|
+
*/
|
|
142
|
+
lastImport: {
|
|
143
|
+
key: string;
|
|
144
|
+
productIds: readonly string[];
|
|
145
|
+
options: Readonly<Record<string, boolean>>;
|
|
146
|
+
} | null;
|
|
147
|
+
/** Writes copy onto a saved product, read fresh from the store. */
|
|
148
|
+
applyProductCopy: (productId: string, values: ConsoleProductCopyValues) => Promise<void>;
|
|
149
|
+
/** Creates each product as a draft with no price, and resolves with the ids it created. */
|
|
150
|
+
createProductDrafts: (products: readonly ConsoleProposedProduct[]) => Promise<string[]>;
|
|
151
|
+
/** Creates categories by name, and resolves with how many it created. */
|
|
152
|
+
createCategories: (names: readonly string[]) => Promise<number>;
|
|
153
|
+
/** Creates each discount switched off, and resolves with how many it created. */
|
|
154
|
+
createDiscountDrafts: (discounts: readonly ConsoleProposedDiscount[]) => Promise<number>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* What the `productImport` zone hands each widget, inside the CSV import
|
|
158
|
+
* dialog: how many products the import creates, and options a widget sets
|
|
159
|
+
* for what happens to them once they land. The hub hands the options, with
|
|
160
|
+
* the ids of the products the import created, to `productsHub` as its
|
|
161
|
+
* `lastImport`.
|
|
162
|
+
*/
|
|
163
|
+
export interface ConsoleProductImportZoneProps {
|
|
164
|
+
hostId: string;
|
|
165
|
+
/** The org the page names; `undefined` where the host does not know it. */
|
|
166
|
+
orgId: string | undefined;
|
|
167
|
+
/** How many products the import creates. */
|
|
168
|
+
count: number;
|
|
169
|
+
/** The options set for this import, by key. */
|
|
170
|
+
options: Readonly<Record<string, boolean>>;
|
|
171
|
+
/** Sets one option; the hub carries it to `productsHub` with what the import created. */
|
|
172
|
+
setOption: (key: string, on: boolean) => void;
|
|
173
|
+
}
|
|
174
|
+
export declare const PRODUCT_EDITOR_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<ConsoleProductEditorZoneProps>;
|
|
175
|
+
export declare const PRODUCTS_HUB_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<ConsoleProductsHubZoneProps>;
|
|
176
|
+
export declare const PRODUCT_IMPORT_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<ConsoleProductImportZoneProps>;
|
|
177
|
+
/**
|
|
178
|
+
* Declares the three zones, from the console registrar. The ids are the ones
|
|
179
|
+
* widgets have always registered under, so a widget written for them keeps
|
|
180
|
+
* working. Each is `bare`: the section is one item of a layout this plugin
|
|
181
|
+
* draws — among the editor's fields, above the catalog table, inside the
|
|
182
|
+
* import dialog — and a wrapper would add a gap the page already spaces.
|
|
183
|
+
*/
|
|
184
|
+
export declare function registerCommerceZones(): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { definePluginZone, registerPluginZone } from "@aglyn/aglyn/plugin-manager/plugin-zones";
|
|
17
|
+
import { BUNDLE_ID } from "../../constants/bundle-common.js";
|
|
18
|
+
export const PRODUCT_EDITOR_ZONE = definePluginZone('productEditor');
|
|
19
|
+
export const PRODUCTS_HUB_ZONE = definePluginZone('productsHub');
|
|
20
|
+
export const PRODUCT_IMPORT_ZONE = definePluginZone('productImport');
|
|
21
|
+
/**
|
|
22
|
+
* Declares the three zones, from the console registrar. The ids are the ones
|
|
23
|
+
* widgets have always registered under, so a widget written for them keeps
|
|
24
|
+
* working. Each is `bare`: the section is one item of a layout this plugin
|
|
25
|
+
* draws — among the editor's fields, above the catalog table, inside the
|
|
26
|
+
* import dialog — and a wrapper would add a gap the page already spaces.
|
|
27
|
+
*/ export function registerCommerceZones() {
|
|
28
|
+
const owner = {
|
|
29
|
+
pluginId: BUNDLE_ID
|
|
30
|
+
};
|
|
31
|
+
registerPluginZone({
|
|
32
|
+
zone: PRODUCT_EDITOR_ZONE,
|
|
33
|
+
label: 'Product editor',
|
|
34
|
+
surface: 'console',
|
|
35
|
+
layout: 'bare',
|
|
36
|
+
description: '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.'
|
|
37
|
+
}, owner);
|
|
38
|
+
registerPluginZone({
|
|
39
|
+
zone: PRODUCTS_HUB_ZONE,
|
|
40
|
+
label: 'Products hub',
|
|
41
|
+
surface: 'console',
|
|
42
|
+
layout: 'bare',
|
|
43
|
+
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.'
|
|
44
|
+
}, owner);
|
|
45
|
+
registerPluginZone({
|
|
46
|
+
zone: PRODUCT_IMPORT_ZONE,
|
|
47
|
+
label: 'Product CSV import',
|
|
48
|
+
surface: 'console',
|
|
49
|
+
layout: 'bare',
|
|
50
|
+
description: 'Inside the CSV import dialog. 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.'
|
|
51
|
+
}, owner);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=product-zones.js.map
|
|
@@ -0,0 +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 CSV import dialog.\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 CSV 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, inside the CSV import\n * dialog: 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, inside the\n * import dialog — and a wrapper would add a gap the page 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 CSV import',\n surface: 'console',\n layout: 'bare',\n description:\n 'Inside the CSV import dialog. 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;;;;;;CAMC,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"}
|
|
@@ -46,6 +46,7 @@ import { productCollectionFields, readSmartCollections } from "./smart-collectio
|
|
|
46
46
|
import ProductsHubZone from "./products-hub-zone.component.js";
|
|
47
47
|
import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
48
48
|
import { useConsoleWidgetSlot } from "@aglyn/aglyn/app-utils/console-widget-slot-context";
|
|
49
|
+
import { PRODUCT_IMPORT_ZONE } from "./product-zones.js";
|
|
49
50
|
/** Products read per request of the CSV export's walk. */ const EXPORT_PAGE = 500;
|
|
50
51
|
/**
|
|
51
52
|
* The most products one CSV export writes (AGL-3321).
|
|
@@ -913,7 +914,7 @@ const STATUS_COLOR = {
|
|
|
913
914
|
}
|
|
914
915
|
},
|
|
915
916
|
noRowsLabel: filtering ? 'No products match these filters' : 'No products yet',
|
|
916
|
-
noRowsDescription: filtering ? undefined : 'Build your catalog: add a product, then drop commerce ' + 'blocks on any
|
|
917
|
+
noRowsDescription: filtering ? undefined : 'Build your catalog: add a product, then drop commerce ' + 'blocks on any page in Besigner.'
|
|
917
918
|
}),
|
|
918
919
|
products.length === 0 && page === 0 && productsStatus !== 'loading' ? null : /* The count line is the PAGE's. `hasMore` is a fact from the probe
|
|
919
920
|
row; the site's total is `productCount` above, which counts the
|
|
@@ -1111,7 +1112,7 @@ const STATUS_COLOR = {
|
|
|
1111
1112
|
]
|
|
1112
1113
|
}) : null,
|
|
1113
1114
|
WidgetSlot && (importing == null ? void 0 : (_importing_parsed = importing.parsed) == null ? void 0 : _importing_parsed.products.length) ? /*#__PURE__*/ _jsx(WidgetSlot, {
|
|
1114
|
-
slot:
|
|
1115
|
+
slot: PRODUCT_IMPORT_ZONE.id,
|
|
1115
1116
|
hostId: hostId,
|
|
1116
1117
|
orgId: undefined,
|
|
1117
1118
|
count: importing.parsed.products.length,
|