@aglyn/plugins-commerce 1.26.6 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-commerce",
3
- "version": "1.26.6",
3
+ "version": "1.27.0",
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.26.6",
29
- "@aglyn/shared-data-mdi": "1.26.6",
30
- "@aglyn/shared-ui-jsx": "1.26.6",
31
- "@aglyn/shared-ui-next": "1.26.6",
32
- "@aglyn/shared-ui-snackstack": "1.26.6",
33
- "@aglyn/shared-util-email": "1.26.6",
34
- "@aglyn/shared-util-http": "1.26.6",
35
- "@aglyn/shared-util-timestamp": "1.26.6",
36
- "@aglyn/shared-util-tools": "1.26.6",
37
- "@aglyn/tenant-data-admin": "1.26.6",
38
- "@aglyn/tenant-feature-instance": "1.26.6",
39
- "@aglyn/tenant-runtime": "1.26.6",
28
+ "@aglyn/aglyn": "1.27.0",
29
+ "@aglyn/shared-data-mdi": "1.27.0",
30
+ "@aglyn/shared-ui-jsx": "1.27.0",
31
+ "@aglyn/shared-ui-next": "1.27.0",
32
+ "@aglyn/shared-ui-snackstack": "1.27.0",
33
+ "@aglyn/shared-util-email": "1.27.0",
34
+ "@aglyn/shared-util-http": "1.27.0",
35
+ "@aglyn/shared-util-timestamp": "1.27.0",
36
+ "@aglyn/shared-util-tools": "1.27.0",
37
+ "@aglyn/tenant-data-admin": "1.27.0",
38
+ "@aglyn/tenant-feature-instance": "1.27.0",
39
+ "@aglyn/tenant-runtime": "1.27.0",
40
40
  "@stripe/react-stripe-js": "^7.0.1",
41
41
  "@stripe/stripe-js": "^10.2.1",
42
42
  "@swc/helpers": "0.5.24",
@@ -68,27 +68,7 @@ const SUPPLIER_CEILING = 50;
68
68
  'title',
69
69
  'description'
70
70
  ];
71
- /**
72
- * A product nobody has saved yet, as the editor starts one: at the default
73
- * price (AGL-3676), for the owner to change or clear.
74
- */ function blankProduct() {
75
- return {
76
- name: '',
77
- slug: '',
78
- type: 'physical',
79
- status: 'draft',
80
- variants: [
81
- {
82
- id: 'default',
83
- priceUsd: CommerceModel.COMMERCE_DEFAULT_PRICE_USD
84
- }
85
- ]
86
- };
87
- }
88
71
  /** What the editor says while a variant has no price (AGL-3676): savable, not sellable. */ export const PRODUCT_PRICE_EMPTY_NOTICE = 'Visitors will see “Price coming soon” and can’t buy this yet. Set a price to start selling it.';
89
- /** Stable key for matching variants across matrix regenerations. */ function comboKey(options) {
90
- return Object.entries(options != null ? options : {}).sort(([a], [b])=>a.localeCompare(b)).map(([name, value])=>`${name}:${value}`).join('|');
91
- }
92
72
  function comboLabel(options) {
93
73
  const values = Object.values(options != null ? options : {});
94
74
  return values.length ? values.join(' / ') : 'Default';
@@ -1194,7 +1174,7 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
1194
1174
  * dialog opened on the cache's replaces it under every field nobody
1195
1175
  * touched, and Save is held until it has (`checking`). Lazy-init per open;
1196
1176
  * the parent remounts via `key` on product change.
1197
- */ const seed = useMemo(()=>lifted != null ? lifted : blankProduct(), [
1177
+ */ const seed = useMemo(()=>lifted != null ? lifted : CommerceModel.blankProductDraft(), [
1198
1178
  lifted
1199
1179
  ]);
1200
1180
  const form = useSeedEdits(seed);
@@ -1480,28 +1460,9 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
1480
1460
  options
1481
1461
  };
1482
1462
  // Regenerate the matrix, carrying data over by option-combo key so
1483
- // edits to prices/SKUs survive option tweaks.
1484
- const previous = new Map(at.variants.map((variant)=>[
1485
- comboKey(variant.options),
1486
- variant
1487
- ]));
1488
- const fallback = at.variants[0];
1489
- const variants = CommerceModel.expandVariantMatrix(options).map((combo, comboIndex)=>{
1490
- var _ref;
1491
- const existing = previous.get(comboKey(combo));
1492
- return existing != null ? existing : // An unpriced variant is stored with no `priceUsd` (AGL-3676),
1493
- // as a proposed product's are; the type names the priced shape.
1494
- _extends({
1495
- id: `v${Date.now().toString(36)}${comboIndex}`,
1496
- options: combo
1497
- }, fallback ? CommerceModel.variantHasPrice(fallback) ? {
1498
- priceUsd: fallback.priceUsd
1499
- } : {} : {
1500
- priceUsd: CommerceModel.COMMERCE_DEFAULT_PRICE_USD
1501
- }, {
1502
- inventory: (_ref = fallback == null ? void 0 : fallback.inventory) != null ? _ref : null
1503
- });
1504
- });
1463
+ // edits to prices/SKUs survive option tweaks. The same rebuild the
1464
+ // public API's product writes make (AGL-4235).
1465
+ const variants = CommerceModel.variantsForOptions(at, options, Date.now());
1505
1466
  return {
1506
1467
  options,
1507
1468
  variants