@aglyn/plugins-commerce 1.0.0-beta.220 → 1.0.0-beta.222

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.
Files changed (130) hide show
  1. package/README.md +4 -2
  2. package/package.json +14 -13
  3. package/src/lib/components/console/catalog-organization-card.component.js +9 -0
  4. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
  5. package/src/lib/components/console/discounts-card.component.js +8 -0
  6. package/src/lib/components/console/discounts-card.component.js.map +1 -1
  7. package/src/lib/components/console/gift-cards-card.component.js +8 -0
  8. package/src/lib/components/console/gift-cards-card.component.js.map +1 -1
  9. package/src/lib/components/console/host-coupons-card.component.js +8 -0
  10. package/src/lib/components/console/host-coupons-card.component.js.map +1 -1
  11. package/src/lib/components/console/host-orders-card.component.js +34 -70
  12. package/src/lib/components/console/host-orders-card.component.js.map +1 -1
  13. package/src/lib/components/console/product-zones.d.ts +7 -6
  14. package/src/lib/components/console/product-zones.js +5 -4
  15. package/src/lib/components/console/product-zones.js.map +1 -1
  16. package/src/lib/components/console/products-hub-card.component.js +86 -284
  17. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  18. package/src/lib/declarations.console-server.d.ts +38 -0
  19. package/src/lib/declarations.console-server.js +67 -0
  20. package/src/lib/declarations.console-server.js.map +1 -0
  21. package/src/lib/model/commerce-gift-cards.d.ts +26 -0
  22. package/src/lib/model/commerce-gift-cards.js +42 -0
  23. package/src/lib/model/commerce-gift-cards.js.map +1 -1
  24. package/src/lib/model/commerce-orders.d.ts +0 -57
  25. package/src/lib/model/commerce-orders.js +0 -80
  26. package/src/lib/model/commerce-orders.js.map +1 -1
  27. package/src/lib/model/index.d.ts +0 -1
  28. package/src/lib/model/index.js +0 -1
  29. package/src/lib/model/index.js.map +1 -1
  30. package/src/lib/plugin.js +5 -0
  31. package/src/lib/plugin.js.map +1 -1
  32. package/src/lib/server/api-v1/openapi.d.ts +27 -0
  33. package/src/lib/server/api-v1/openapi.js +219 -0
  34. package/src/lib/server/api-v1/openapi.js.map +1 -0
  35. package/src/lib/server/api-v1/orders-and-products.d.ts +19 -0
  36. package/src/lib/server/api-v1/orders-and-products.js +419 -0
  37. package/src/lib/server/api-v1/orders-and-products.js.map +1 -0
  38. package/src/lib/server/billing-webhook.js +83 -56
  39. package/src/lib/server/billing-webhook.js.map +1 -1
  40. package/src/lib/server/download.js +4 -1
  41. package/src/lib/server/download.js.map +1 -1
  42. package/src/lib/server/fulfill-order.d.ts +52 -11
  43. package/src/lib/server/fulfill-order.js +6 -9
  44. package/src/lib/server/fulfill-order.js.map +1 -1
  45. package/src/lib/server/gift-card-issue.d.ts +57 -0
  46. package/src/lib/server/gift-card-issue.js +155 -0
  47. package/src/lib/server/gift-card-issue.js.map +1 -0
  48. package/src/lib/server/gift-cards.js +25 -84
  49. package/src/lib/server/gift-cards.js.map +1 -1
  50. package/src/lib/server/membership-register.js +9 -8
  51. package/src/lib/server/membership-register.js.map +1 -1
  52. package/src/lib/server/newsletter.js +7 -5
  53. package/src/lib/server/newsletter.js.map +1 -1
  54. package/src/lib/server/paid-media-delivery.d.ts +21 -0
  55. package/src/lib/server/paid-media-delivery.js +23 -5
  56. package/src/lib/server/paid-media-delivery.js.map +1 -1
  57. package/src/lib/server/paid-media-serve-count.d.ts +28 -0
  58. package/src/lib/server/paid-media-serve-count.js +46 -0
  59. package/src/lib/server/paid-media-serve-count.js.map +1 -0
  60. package/src/lib/server/person-eraser.d.ts +45 -0
  61. package/src/lib/server/person-eraser.js +57 -0
  62. package/src/lib/server/person-eraser.js.map +1 -0
  63. package/src/lib/server/pos-order.js +17 -9
  64. package/src/lib/server/pos-order.js.map +1 -1
  65. package/src/lib/server/refund.js +15 -15
  66. package/src/lib/server/refund.js.map +1 -1
  67. package/src/lib/server/restock-flag.d.ts +2 -2
  68. package/src/lib/server/restock-flag.js +1 -1
  69. package/src/lib/server/restock-flag.js.map +1 -1
  70. package/src/lib/server/stream.js +4 -1
  71. package/src/lib/server/stream.js.map +1 -1
  72. package/src/lib/server.js +5 -21
  73. package/src/lib/server.js.map +1 -1
  74. package/src/lib/testing/stand-in-person-records.d.ts +43 -0
  75. package/src/lib/testing/stand-in-person-records.js +63 -0
  76. package/src/lib/testing/stand-in-person-records.js.map +1 -0
  77. package/src/lib/testing/stand-in-record-system.d.ts +11 -2
  78. package/src/lib/testing/stand-in-record-system.js +5 -3
  79. package/src/lib/testing/stand-in-record-system.js.map +1 -1
  80. package/src/lib/transfer/gift-card-confirm-step.component.d.ts +22 -0
  81. package/src/lib/transfer/gift-card-confirm-step.component.js +259 -0
  82. package/src/lib/transfer/gift-card-confirm-step.component.js.map +1 -0
  83. package/src/lib/transfer/gift-cards-plan.d.ts +29 -0
  84. package/src/lib/transfer/gift-cards-plan.js +40 -0
  85. package/src/lib/transfer/gift-cards-plan.js.map +1 -0
  86. package/src/lib/transfer/gift-cards.server.d.ts +34 -0
  87. package/src/lib/transfer/gift-cards.server.js +296 -0
  88. package/src/lib/transfer/gift-cards.server.js.map +1 -0
  89. package/src/lib/transfer/list-filter.d.ts +29 -0
  90. package/src/lib/transfer/list-filter.js +112 -0
  91. package/src/lib/transfer/list-filter.js.map +1 -0
  92. package/src/lib/transfer/product-import-results.d.ts +29 -0
  93. package/src/lib/transfer/product-import-results.js +49 -0
  94. package/src/lib/transfer/product-import-results.js.map +1 -0
  95. package/src/lib/transfer/product-import-step.component.d.ts +30 -0
  96. package/src/lib/transfer/product-import-step.component.js +99 -0
  97. package/src/lib/transfer/product-import-step.component.js.map +1 -0
  98. package/src/lib/transfer/product-transfer.d.ts +211 -0
  99. package/src/lib/transfer/product-transfer.js +1594 -0
  100. package/src/lib/transfer/product-transfer.js.map +1 -0
  101. package/src/lib/transfer/products.server.d.ts +44 -0
  102. package/src/lib/transfer/products.server.js +550 -0
  103. package/src/lib/transfer/products.server.js.map +1 -0
  104. package/src/lib/transfer/records-transfer.d.ts +182 -0
  105. package/src/lib/transfer/records-transfer.js +1153 -0
  106. package/src/lib/transfer/records-transfer.js.map +1 -0
  107. package/src/lib/transfer/records.server.d.ts +68 -0
  108. package/src/lib/transfer/records.server.js +455 -0
  109. package/src/lib/transfer/records.server.js.map +1 -0
  110. package/src/lib/transfer/register-transfer-resources.d.ts +17 -0
  111. package/src/lib/transfer/register-transfer-resources.js +171 -0
  112. package/src/lib/transfer/register-transfer-resources.js.map +1 -0
  113. package/src/lib/transfer/register-transfer-ui.d.ts +23 -0
  114. package/src/lib/transfer/register-transfer-ui.js +78 -0
  115. package/src/lib/transfer/register-transfer-ui.js.map +1 -0
  116. package/src/lib/transfer/server-common.d.ts +76 -0
  117. package/src/lib/transfer/server-common.js +165 -0
  118. package/src/lib/transfer/server-common.js.map +1 -0
  119. package/src/lib/transfer/transfer-header-actions.component.d.ts +39 -0
  120. package/src/lib/transfer/transfer-header-actions.component.js +79 -0
  121. package/src/lib/transfer/transfer-header-actions.component.js.map +1 -0
  122. package/src/lib/transfer/transfer-keys.d.ts +31 -0
  123. package/src/lib/transfer/transfer-keys.js +56 -0
  124. package/src/lib/transfer/transfer-keys.js.map +1 -0
  125. package/src/lib/model/commerce-io.d.ts +0 -36
  126. package/src/lib/model/commerce-io.js +0 -245
  127. package/src/lib/model/commerce-io.js.map +0 -1
  128. package/src/lib/server/contact-refund.d.ts +0 -117
  129. package/src/lib/server/contact-refund.js +0 -196
  130. package/src/lib/server/contact-refund.js.map +0 -1
@@ -0,0 +1,182 @@
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
+ import { type BuildTransferPlanInput, type MatchKeySpec, type PlannedTransferRow, type TransferField, type TransferPlan } from '@aglyn/aglyn/data-transfer';
18
+ import type { PicklistSpec } from '@aglyn/aglyn/app-utils/picklists';
19
+ import type { DiscountKind, HostDiscount } from '../model/commerce-discounts';
20
+ import { type HostGiftCard } from '../model/commerce-gift-cards';
21
+ import { type HostOrder } from '../model/commerce-orders';
22
+ /** A planned row's changes, by field id. */
23
+ export declare function rowChanges(row: PlannedTransferRow): Record<string, unknown>;
24
+ /**
25
+ * The core's plan with the fields a NEW record cannot be made without
26
+ * marked required — never in the catalog, where a required field must be
27
+ * mapped, and a file that only switches discounts off would be refused.
28
+ */
29
+ export declare function planWithCreateRequired(input: BuildTransferPlanInput, required: readonly string[]): TransferPlan;
30
+ export declare const ORDER_TRANSFER_FIELDS: readonly TransferField[];
31
+ export declare const ORDER_TRANSFER_GROUPS: {
32
+ id: string;
33
+ label: string;
34
+ }[];
35
+ /** An order as a stored document, with the id the export reads it under. */
36
+ export type StoredOrder = Partial<HostOrder> & {
37
+ createdAt?: unknown;
38
+ createdAtMs?: number;
39
+ amountCents?: number;
40
+ feeCents?: number;
41
+ productId?: string;
42
+ };
43
+ /**
44
+ * One order as a file names it. The money is what was ACTUALLY charged:
45
+ * the order's `totals`, and the legacy flat fields only where a buy-now order
46
+ * of old carries nothing else (AGL-1747) — a POS or draft order has no flat
47
+ * field, and reading those first exported every one of them at $0.00. A
48
+ * legacy row is named from `productNames`, never as "Product".
49
+ */
50
+ export declare function orderRecord(id: string, stored: StoredOrder, productNames?: Readonly<Record<string, string>>): Record<string, unknown>;
51
+ export declare const DISCOUNT_KIND_PICKLIST = "commerce.discountKind";
52
+ export declare const DISCOUNT_KIND_SPEC: PicklistSpec;
53
+ /** A discount kind's id from a label or id in any case, or `null`. */
54
+ export declare function discountKindOf(value: unknown): DiscountKind | null;
55
+ export declare const DISCOUNT_TRANSFER_FIELDS: readonly TransferField[];
56
+ export declare const DISCOUNT_MATCH_KEYS: readonly MatchKeySpec[];
57
+ /** A code as the discounts card stores it: upper case, letters, digits, `_` and `-`. */
58
+ export declare function promotionCode(value: unknown, max?: number): string;
59
+ export declare function discountRecord(id: string, stored: Partial<HostDiscount> & {
60
+ code?: string | null;
61
+ }): Record<string, unknown>;
62
+ /**
63
+ * The document a discount's changes make, over what it holds: the stored
64
+ * shape the discounts card writes, or the sentence refusing it.
65
+ */
66
+ export declare function discountWrite(current: (Partial<HostDiscount> & {
67
+ code?: string | null;
68
+ }) | null, changes: Readonly<Record<string, unknown>>): {
69
+ doc: Record<string, unknown>;
70
+ } | {
71
+ problem: string;
72
+ };
73
+ export declare const COUPON_TRANSFER_FIELDS: readonly TransferField[];
74
+ export declare const COUPON_MATCH_KEYS: readonly MatchKeySpec[];
75
+ export interface StoredCoupon {
76
+ percentOff?: number;
77
+ enabled?: boolean;
78
+ redemptions?: number;
79
+ maxRedemptions?: number;
80
+ expiresAtMs?: number;
81
+ createdAt?: unknown;
82
+ }
83
+ export declare function couponRecord(id: string, stored: StoredCoupon): Record<string, unknown>;
84
+ /** A coupon's document from its changes, as the coupons card writes one, or the refusal. */
85
+ export declare function couponWrite(current: StoredCoupon | null, changes: Readonly<Record<string, unknown>>): {
86
+ doc: Record<string, unknown>;
87
+ } | {
88
+ problem: string;
89
+ };
90
+ export declare const GIFT_CARD_TRANSFER_FIELDS: readonly TransferField[];
91
+ /** A card is found by its code, which is its ID. */
92
+ export declare const GIFT_CARD_MATCH_KEYS: readonly MatchKeySpec[];
93
+ /** The fields an issued card's undo entry holds: any of them moving means the card was spent. */
94
+ export declare const GIFT_CARD_UNDO_FIELDS: readonly ["balance", "status", "lastUsedAt"];
95
+ export type StoredGiftCard = HostGiftCard & {
96
+ initialCents?: number;
97
+ recipientEmail?: string | null;
98
+ orderId?: string | null;
99
+ note?: string;
100
+ createdAtMs?: number;
101
+ lastUsedAtMs?: number;
102
+ importJobId?: string;
103
+ importRow?: number;
104
+ };
105
+ export declare function giftCardRecord(id: string, stored: StoredGiftCard): Record<string, unknown>;
106
+ /** Dollars and cents as a person reads them: `$1,250.00`. */
107
+ export declare function giftCardMoney(amountCents: number): string;
108
+ /** A total as a person types it (`1250`, `$1,250.00`), in cents; `null` for anything else. */
109
+ export declare function typedDollarsToCents(typed: unknown): number | null;
110
+ /** The Confirm step's answer. */
111
+ export interface GiftCardConfirmation {
112
+ /** The total the person typed, in cents. */
113
+ totalCents: number;
114
+ /** Email each card's recipient their code as it is issued. */
115
+ email: boolean;
116
+ }
117
+ /** The Confirm step's answer from `extras`, or `null` for none: a total is a whole number of cents. */
118
+ export declare function readGiftCardConfirmation(extras: Readonly<Record<string, unknown>> | undefined): GiftCardConfirmation | null;
119
+ /** The card one planned row issues, as the plan decided it. */
120
+ export interface GiftCardRowPlan {
121
+ /** The code the card is issued under. */
122
+ code: string;
123
+ /** The file's code was taken, and the person chose a new one. */
124
+ newCode: boolean;
125
+ /** The file named no code, so one was made. */
126
+ madeCode: boolean;
127
+ amountCents: number;
128
+ recipientEmail: string | null;
129
+ note: string | null;
130
+ /** Why the row issues nothing; the `gift-card-issuable` invariant fails it. */
131
+ problem?: string;
132
+ /** What every card this import issues adds up to. */
133
+ totalCents: number;
134
+ /** Whether the person typed exactly that total on the Confirm step. */
135
+ confirmed: boolean;
136
+ }
137
+ export type GiftCardPlannedRow = PlannedTransferRow & {
138
+ giftCard?: GiftCardRowPlan;
139
+ };
140
+ /** The card a row's changes issue, or the sentence refusing it. */
141
+ export declare function giftCardIssueOf(changes: Readonly<Record<string, unknown>>, code: {
142
+ value: string;
143
+ fromFile: boolean;
144
+ }): Omit<GiftCardRowPlan, 'newCode' | 'madeCode' | 'totalCents' | 'confirmed'>;
145
+ /**
146
+ * The core's plan for a gift card file, made into the cards it issues: each
147
+ * create carrying the card it issues ({@link GiftCardRowPlan}), each row
148
+ * that would change an existing card refused, the total of every card
149
+ * counted, and a `screening` warning stating that total — and, when the
150
+ * Confirm step's answer is missing or names another total, that nothing is
151
+ * issued until it is confirmed.
152
+ */
153
+ export declare function planGiftCardRows(plan: TransferPlan, input: {
154
+ confirmation: GiftCardConfirmation | null;
155
+ mintCode: () => string;
156
+ /** The file's codes a card on the site already holds, however the file spelled them. */
157
+ taken?: ReadonlySet<string>;
158
+ }): TransferPlan;
159
+ export declare const CATEGORY_TRANSFER_FIELDS: readonly TransferField[];
160
+ export declare const CATEGORY_MATCH_KEYS: readonly MatchKeySpec[];
161
+ export interface StoredCategory {
162
+ name?: string;
163
+ slug?: string;
164
+ parentId?: string | null;
165
+ order?: number;
166
+ }
167
+ export declare function categoryRecord(id: string, stored: StoredCategory, slugs?: ReadonlyMap<string, string>): Record<string, unknown>;
168
+ /** Every category's slug, name and parent, by id: what a parent is resolved against. */
169
+ export type CategoryIndex = Map<string, StoredCategory>;
170
+ /** The category a parent cell names — by id, slug, then name — or `null`. */
171
+ export declare function resolveCategoryParent(index: CategoryIndex, value: unknown): string | null;
172
+ /**
173
+ * A category's document from its changes: the name and the slug made from
174
+ * it, the parent resolved — never itself or one of its own descendants —
175
+ * and the position. A parent the site does not have is refused, not
176
+ * guessed.
177
+ */
178
+ export declare function categoryWrite(id: string, current: StoredCategory | null, changes: Readonly<Record<string, unknown>>, index: CategoryIndex): {
179
+ doc: Record<string, unknown>;
180
+ } | {
181
+ problem: string;
182
+ };