@fayz-ai/shop 0.9.0 → 0.11.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/README.md +18 -1
- package/dist/admin.d.ts +2 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/catalog.d.ts +1 -3
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +2 -2
- package/dist/{chunk-IYQHKMLB.js → chunk-2WACO2TG.js} +4 -4
- package/dist/chunk-2WACO2TG.js.map +1 -0
- package/dist/chunk-3GERSY5F.js +526 -0
- package/dist/chunk-3GERSY5F.js.map +1 -0
- package/dist/chunk-6BO2TMZ5.js +93 -0
- package/dist/chunk-6BO2TMZ5.js.map +1 -0
- package/dist/chunk-FQPGE3YN.js +3 -0
- package/dist/{chunk-JR25TISO.js.map → chunk-FQPGE3YN.js.map} +1 -1
- package/dist/{chunk-CTKZ6O2J.js → chunk-IKNGCRUM.js} +41 -15
- package/dist/chunk-IKNGCRUM.js.map +1 -0
- package/dist/chunk-KLDS7IPU.js +17 -0
- package/dist/chunk-KLDS7IPU.js.map +1 -0
- package/dist/chunk-NWW3WJ7Y.js +136 -0
- package/dist/chunk-NWW3WJ7Y.js.map +1 -0
- package/dist/chunk-STRNMFC4.js +1438 -0
- package/dist/chunk-STRNMFC4.js.map +1 -0
- package/dist/chunk-U6HV3LVP.js +1170 -0
- package/dist/chunk-U6HV3LVP.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/data/customer-search.d.ts +3 -0
- package/dist/data/customer-search.d.ts.map +1 -0
- package/dist/data/functions.d.ts +9 -0
- package/dist/data/functions.d.ts.map +1 -0
- package/dist/data/media.d.ts +37 -0
- package/dist/data/media.d.ts.map +1 -0
- package/dist/{mock-catalog.d.ts → data/mock-catalog.d.ts} +21 -1
- package/dist/data/mock-catalog.d.ts.map +1 -0
- package/dist/data/mock-provider.d.ts +165 -0
- package/dist/data/mock-provider.d.ts.map +1 -0
- package/dist/data/mock.d.ts +3 -0
- package/dist/data/mock.d.ts.map +1 -0
- package/dist/data/provider.d.ts +335 -0
- package/dist/data/provider.d.ts.map +1 -0
- package/dist/data/supabase-provider.d.ts +208 -0
- package/dist/data/supabase-provider.d.ts.map +1 -0
- package/dist/data/tables.d.ts +38 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/data/tenant.d.ts.map +1 -0
- package/dist/entities/entity-reconcile.d.ts +32 -0
- package/dist/entities/entity-reconcile.d.ts.map +1 -0
- package/dist/entities/entity-sql.d.ts +50 -0
- package/dist/entities/entity-sql.d.ts.map +1 -0
- package/dist/entities/entity-store.d.ts +58 -0
- package/dist/entities/entity-store.d.ts.map +1 -0
- package/dist/entities/index.d.ts +10 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/mock-entity-store.d.ts +17 -0
- package/dist/entities/mock-entity-store.d.ts.map +1 -0
- package/dist/entities/supabase-entity-store.d.ts +8 -0
- package/dist/entities/supabase-entity-store.d.ts.map +1 -0
- package/dist/entities.js +159 -0
- package/dist/entities.js.map +1 -0
- package/dist/index.d.ts +28 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1558 -40
- package/dist/index.js.map +1 -1
- package/dist/inventory/allocation.d.ts +98 -0
- package/dist/inventory/allocation.d.ts.map +1 -0
- package/dist/inventory/index.d.ts +13 -0
- package/dist/inventory/index.d.ts.map +1 -0
- package/dist/inventory/mock-stock-store.d.ts +89 -0
- package/dist/inventory/mock-stock-store.d.ts.map +1 -0
- package/dist/inventory/postgrest-double.d.ts +65 -0
- package/dist/inventory/postgrest-double.d.ts.map +1 -0
- package/dist/inventory/shopify-mapping.d.ts +67 -0
- package/dist/inventory/shopify-mapping.d.ts.map +1 -0
- package/dist/inventory/stock-contract.d.ts +46 -0
- package/dist/inventory/stock-contract.d.ts.map +1 -0
- package/dist/inventory/stock-store.d.ts +96 -0
- package/dist/inventory/stock-store.d.ts.map +1 -0
- package/dist/inventory/stock-types.d.ts +351 -0
- package/dist/inventory/stock-types.d.ts.map +1 -0
- package/dist/inventory/supabase-stock-store.d.ts +60 -0
- package/dist/inventory/supabase-stock-store.d.ts.map +1 -0
- package/dist/inventory/vocabulary.d.ts +86 -0
- package/dist/inventory/vocabulary.d.ts.map +1 -0
- package/dist/inventory.js +4 -0
- package/dist/inventory.js.map +1 -0
- package/dist/lib/catalog.d.ts +4 -0
- package/dist/lib/catalog.d.ts.map +1 -0
- package/dist/{commerce.d.ts → lib/commerce.d.ts} +2 -2
- package/dist/lib/commerce.d.ts.map +1 -0
- package/dist/lib/document.d.ts +13 -0
- package/dist/lib/document.d.ts.map +1 -0
- package/dist/lib/emails.d.ts +50 -0
- package/dist/lib/emails.d.ts.map +1 -0
- package/dist/lib/message-events.d.ts +4 -0
- package/dist/lib/message-events.d.ts.map +1 -0
- package/dist/lib/runtime.d.ts +5 -0
- package/dist/lib/runtime.d.ts.map +1 -0
- package/dist/lib/variant-matrix.d.ts +120 -0
- package/dist/lib/variant-matrix.d.ts.map +1 -0
- package/dist/mock.d.ts +1 -2
- package/dist/mock.d.ts.map +1 -1
- package/dist/mock.js +4 -2
- package/dist/provider.d.ts +1 -88
- package/dist/provider.d.ts.map +1 -1
- package/dist/providers/checkout.d.ts +129 -0
- package/dist/providers/checkout.d.ts.map +1 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/shipping.d.ts +43 -0
- package/dist/providers/shipping.d.ts.map +1 -0
- package/dist/providers.js +70 -0
- package/dist/providers.js.map +1 -0
- package/dist/rules/adapter.d.ts +36 -0
- package/dist/rules/adapter.d.ts.map +1 -0
- package/dist/rules/attributes.d.ts +64 -0
- package/dist/rules/attributes.d.ts.map +1 -0
- package/dist/rules/context.d.ts +43 -0
- package/dist/rules/context.d.ts.map +1 -0
- package/dist/rules/evaluator.d.ts +37 -0
- package/dist/rules/evaluator.d.ts.map +1 -0
- package/dist/rules/index.d.ts +13 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/prices.d.ts +25 -0
- package/dist/rules/prices.d.ts.map +1 -0
- package/dist/rules/rule-types.d.ts +160 -0
- package/dist/rules/rule-types.d.ts.map +1 -0
- package/dist/rules.js +22 -0
- package/dist/rules.js.map +1 -0
- package/dist/runtime.d.ts +1 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -3
- package/dist/shipping/label-provider.d.ts +43 -0
- package/dist/shipping/label-provider.d.ts.map +1 -0
- package/dist/types.d.ts +688 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +30 -20
- package/dist/chunk-CTKZ6O2J.js.map +0 -1
- package/dist/chunk-IYQHKMLB.js.map +0 -1
- package/dist/chunk-JR25TISO.js +0 -3
- package/dist/chunk-SVTCJ6HP.js +0 -440
- package/dist/chunk-SVTCJ6HP.js.map +0 -1
- package/dist/commerce.d.ts.map +0 -1
- package/dist/mock-catalog.d.ts.map +0 -1
- package/dist/mock-provider.d.ts +0 -60
- package/dist/mock-provider.d.ts.map +0 -1
- package/dist/supabase-provider.d.ts +0 -56
- package/dist/supabase-provider.d.ts.map +0 -1
- package/dist/tables.d.ts +0 -12
- package/dist/tables.d.ts.map +0 -1
- package/dist/tenant.d.ts.map +0 -1
- package/src/catalog.ts +0 -3
- package/src/commerce.ts +0 -120
- package/src/index.ts +0 -40
- package/src/mock-catalog.ts +0 -266
- package/src/mock-provider.ts +0 -480
- package/src/mock.ts +0 -2
- package/src/provider.ts +0 -117
- package/src/runtime.ts +0 -20
- package/src/supabase-provider.ts +0 -754
- package/src/tables.ts +0 -17
- package/src/tenant.ts +0 -21
- package/src/types.ts +0 -623
- /package/dist/{tenant.d.ts → data/tenant.d.ts} +0 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-variant tracking policy — a closed set, deliberately (§3).
|
|
3
|
+
*
|
|
4
|
+
* Unlike movement kinds and reason codes, these are NOT rows: each value
|
|
5
|
+
* changes what the engine does, so a tenant-invented mode would be data no
|
|
6
|
+
* code could honour. Widening this is a model change — this union, the
|
|
7
|
+
* `plg_shop_product_variants_tracking_check` CHECK, and the validator, together.
|
|
8
|
+
*
|
|
9
|
+
* - `none` — never depletes. Made-to-order, digital, services.
|
|
10
|
+
* - `quantity` — one implicit lot. THE DEFAULT, so existing stores are unchanged.
|
|
11
|
+
* - `lot` — batches with expiry; allocation is FEFO.
|
|
12
|
+
* - `serial` — every unit is unique; a serial is a lot whose quantity is 1.
|
|
13
|
+
*/
|
|
14
|
+
export declare const STOCK_TRACKING_MODES: readonly ["none", "quantity", "lot", "serial"];
|
|
15
|
+
export type StockTrackingMode = (typeof STOCK_TRACKING_MODES)[number];
|
|
16
|
+
/** The default every variant gets, so adopting the ledger costs a simple store nothing. */
|
|
17
|
+
export declare const DEFAULT_STOCK_TRACKING: StockTrackingMode;
|
|
18
|
+
/** Closed set: allocation branches on it (transit stock cannot be promised). */
|
|
19
|
+
export declare const STOCK_LOCATION_KINDS: readonly ["store", "warehouse", "transit", "virtual"];
|
|
20
|
+
export type StockLocationKind = (typeof STOCK_LOCATION_KINDS)[number];
|
|
21
|
+
/** Closed set: the §5 reservation lifecycle. */
|
|
22
|
+
export declare const STOCK_RESERVATION_STATUSES: readonly ["held", "consumed", "released"];
|
|
23
|
+
export type StockReservationStatus = (typeof STOCK_RESERVATION_STATUSES)[number];
|
|
24
|
+
export declare const STOCK_LOT_STATUSES: readonly ["active", "quarantined", "expired", "consumed"];
|
|
25
|
+
export type StockLotStatus = (typeof STOCK_LOT_STATUSES)[number];
|
|
26
|
+
/**
|
|
27
|
+
* The sign contract a movement kind carries. It lives in the VOCABULARY ROW,
|
|
28
|
+
* not in the validator, which is precisely what lets a tenant add a kind.
|
|
29
|
+
*/
|
|
30
|
+
export declare const STOCK_MOVEMENT_DIRECTIONS: readonly ["in", "out", "either"];
|
|
31
|
+
export type StockMovementDirection = (typeof STOCK_MOVEMENT_DIRECTIONS)[number];
|
|
32
|
+
/** One movement-kind vocabulary row (plg_shop_stock_movement_kinds). */
|
|
33
|
+
export interface StockMovementKind {
|
|
34
|
+
key: string;
|
|
35
|
+
label: string;
|
|
36
|
+
direction: StockMovementDirection;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One reason-code vocabulary row (plg_shop_stock_reason_codes).
|
|
40
|
+
*
|
|
41
|
+
* `movementKind` null means "valid for any kind"; naming one makes the pair
|
|
42
|
+
* checkable, so 'breakage' can never be recorded as a receipt.
|
|
43
|
+
*/
|
|
44
|
+
export interface StockReasonCode {
|
|
45
|
+
key: string;
|
|
46
|
+
label: string;
|
|
47
|
+
movementKind: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `fulfillment_provider` when the merchant dispatches by hand — a decision, not
|
|
51
|
+
* an absent one, which is why it is stored instead of inferred from "no gateway".
|
|
52
|
+
*/
|
|
53
|
+
export declare const OWN_FULFILLMENT = "own";
|
|
54
|
+
/** Where stock sits, and — since 0058 — what ships from there. */
|
|
55
|
+
export interface StockLocation {
|
|
56
|
+
id: string;
|
|
57
|
+
tenantId: string;
|
|
58
|
+
code: string;
|
|
59
|
+
name: string;
|
|
60
|
+
kind: StockLocationKind;
|
|
61
|
+
/** Stock here can be promised to a shopper. Transit stock cannot. */
|
|
62
|
+
isSellable: boolean;
|
|
63
|
+
isDefault: boolean;
|
|
64
|
+
status: 'active' | 'archived';
|
|
65
|
+
/** 8 bare digits. The origin a freight gateway quotes from. */
|
|
66
|
+
postalCode?: string | null;
|
|
67
|
+
city?: string | null;
|
|
68
|
+
state?: string | null;
|
|
69
|
+
street?: string | null;
|
|
70
|
+
number?: string | null;
|
|
71
|
+
district?: string | null;
|
|
72
|
+
complement?: string | null;
|
|
73
|
+
/** CNPJ/CPF, digits only — the carrier prints it on the label (0061). */
|
|
74
|
+
document?: string | null;
|
|
75
|
+
phone?: string | null;
|
|
76
|
+
email?: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Where THIS place drops its parcels, per carrier (0062):
|
|
79
|
+
* `{ 'melhor-envio': { id: '49276', name: 'Jadlog Barra' } }`.
|
|
80
|
+
*
|
|
81
|
+
* Per carrier because the choice is: the same warehouse can drop one
|
|
82
|
+
* carrier's parcels downtown and another's next door. Empty means "the
|
|
83
|
+
* nearest agency that accepts the service", which is what dispatch does.
|
|
84
|
+
*/
|
|
85
|
+
carrierAgencies?: Record<string, {
|
|
86
|
+
id: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
}> | null;
|
|
89
|
+
/** Online orders may be dispatched from here. */
|
|
90
|
+
shipsOnline?: boolean;
|
|
91
|
+
/** null follows the store, `OWN_FULFILLMENT` is by hand, else a connector id. */
|
|
92
|
+
fulfillmentProvider?: string | null;
|
|
93
|
+
createdAt: string;
|
|
94
|
+
updatedAt: string;
|
|
95
|
+
}
|
|
96
|
+
export interface CreateStockLocationInput {
|
|
97
|
+
name: string;
|
|
98
|
+
/** Stable handle for a CSV import or an ERP connector. Defaults to a slug of the name. */
|
|
99
|
+
code?: string;
|
|
100
|
+
kind?: StockLocationKind;
|
|
101
|
+
isSellable?: boolean;
|
|
102
|
+
isDefault?: boolean;
|
|
103
|
+
status?: 'active' | 'archived';
|
|
104
|
+
postalCode?: string | null;
|
|
105
|
+
city?: string | null;
|
|
106
|
+
state?: string | null;
|
|
107
|
+
street?: string | null;
|
|
108
|
+
number?: string | null;
|
|
109
|
+
district?: string | null;
|
|
110
|
+
complement?: string | null;
|
|
111
|
+
document?: string | null;
|
|
112
|
+
phone?: string | null;
|
|
113
|
+
email?: string | null;
|
|
114
|
+
carrierAgencies?: Record<string, {
|
|
115
|
+
id: string;
|
|
116
|
+
name?: string;
|
|
117
|
+
}> | null;
|
|
118
|
+
shipsOnline?: boolean;
|
|
119
|
+
fulfillmentProvider?: string | null;
|
|
120
|
+
}
|
|
121
|
+
export type UpdateStockLocationInput = Partial<CreateStockLocationInput>;
|
|
122
|
+
/** A batch. A serial-tracked unit is a lot whose quantity is 1. */
|
|
123
|
+
export interface StockLot {
|
|
124
|
+
id: string;
|
|
125
|
+
tenantId: string;
|
|
126
|
+
variantId: string;
|
|
127
|
+
lotCode: string;
|
|
128
|
+
serial: string | null;
|
|
129
|
+
/** Calendar dates, not timestamps: FEFO order must not depend on a time zone. */
|
|
130
|
+
manufacturedAt: string | null;
|
|
131
|
+
expiresAt: string | null;
|
|
132
|
+
receivedAt: string;
|
|
133
|
+
unitCost: number | null;
|
|
134
|
+
supplierRef: string | null;
|
|
135
|
+
status: StockLotStatus;
|
|
136
|
+
createdAt: string;
|
|
137
|
+
updatedAt: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* One ledger row. Append-only and signed: a mistake is corrected by an
|
|
141
|
+
* OPPOSING movement, never by an edit, which is what makes the ledger
|
|
142
|
+
* auditable.
|
|
143
|
+
*/
|
|
144
|
+
export interface StockMovement {
|
|
145
|
+
id: string;
|
|
146
|
+
tenantId: string;
|
|
147
|
+
/** Null only after the variant row was deleted — the history survives it. */
|
|
148
|
+
variantId: string | null;
|
|
149
|
+
productId: string | null;
|
|
150
|
+
locationId: string;
|
|
151
|
+
lotId: string | null;
|
|
152
|
+
kind: string;
|
|
153
|
+
reasonCode: string | null;
|
|
154
|
+
/** Signed. The kind's `direction` decides which signs are legal. */
|
|
155
|
+
quantity: number;
|
|
156
|
+
unitCost: number | null;
|
|
157
|
+
orderId: string | null;
|
|
158
|
+
reservationId: string | null;
|
|
159
|
+
idempotencyKey: string | null;
|
|
160
|
+
/** WHEN it happened, which is not when it was recorded. */
|
|
161
|
+
occurredAt: string;
|
|
162
|
+
createdBy: string | null;
|
|
163
|
+
note: string | null;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
}
|
|
166
|
+
/** What a caller supplies to append to the ledger. */
|
|
167
|
+
export interface RecordStockMovementInput {
|
|
168
|
+
variantId: string;
|
|
169
|
+
kind: string;
|
|
170
|
+
quantity: number;
|
|
171
|
+
reasonCode?: string | null;
|
|
172
|
+
/** Omitted ⇒ the tenant's default location, created on demand. */
|
|
173
|
+
locationId?: string | null;
|
|
174
|
+
lotId?: string | null;
|
|
175
|
+
unitCost?: number | null;
|
|
176
|
+
orderId?: string | null;
|
|
177
|
+
reservationId?: string | null;
|
|
178
|
+
/** A retried write must not decrement twice. */
|
|
179
|
+
idempotencyKey?: string | null;
|
|
180
|
+
occurredAt?: string;
|
|
181
|
+
note?: string | null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The materialised answer per (variant, lot, location) — an index over the
|
|
185
|
+
* ledger, not a second truth. `onHand` may be NEGATIVE: an over-recorded loss
|
|
186
|
+
* must stay visible rather than be refused, because refusing it would make the
|
|
187
|
+
* LEDGER lie. The clamp happens once, at the inventory_count mirror.
|
|
188
|
+
*
|
|
189
|
+
* ---------------------------------------------------------------------------
|
|
190
|
+
* NAME MAPPING TO SHOPIFY, so a connector never needs a translation table.
|
|
191
|
+
*
|
|
192
|
+
* Shopify's quantity states are `available`, `committed`, `on_hand`,
|
|
193
|
+
* `incoming`, plus `damaged`, `safety_stock` and `quality_control`. Ours:
|
|
194
|
+
*
|
|
195
|
+
* ours Shopify note
|
|
196
|
+
* ──────────── ───────────── ──────────────────────────────────────────────
|
|
197
|
+
* onHand on_hand identical
|
|
198
|
+
* available available identical (onHand − reserved)
|
|
199
|
+
* reserved committed SAME CONCEPT, different word. Ours is the
|
|
200
|
+
* schema name (0034, landed and green); theirs
|
|
201
|
+
* is published beside it by the
|
|
202
|
+
* plg_shop_stock_levels view, which exposes both
|
|
203
|
+
* `reserved` and `committed` columns. Renaming
|
|
204
|
+
* the column instead would have churned an
|
|
205
|
+
* already-green contract suite, the SQL
|
|
206
|
+
* regression, the mirror and the mock for a
|
|
207
|
+
* synonym.
|
|
208
|
+
* (a non-sellable location's
|
|
209
|
+
* balance) incoming we model it as a PLACE (`kind = 'transit'`,
|
|
210
|
+
* `is_sellable = false`) rather than as a fourth
|
|
211
|
+
* number, which is strictly more expressive:
|
|
212
|
+
* two warehouses in transit are two rows.
|
|
213
|
+
* (a `loss` movement with
|
|
214
|
+
* reason `damaged`) damaged ours is a ledger entry with a reason code, so
|
|
215
|
+
* it carries when, who and how many; Shopify's
|
|
216
|
+
* is a bucket.
|
|
217
|
+
* — safety_stock NOT MODELLED. Reorder point and low-stock
|
|
218
|
+
* threshold are §8's "forecasting", deliberately
|
|
219
|
+
* out of scope.
|
|
220
|
+
* (a `lot` with status
|
|
221
|
+
* 'quarantined') quality_control ours is a lot state, which is more precise:
|
|
222
|
+
* it is a BATCH that is under inspection, not a
|
|
223
|
+
* quantity.
|
|
224
|
+
*
|
|
225
|
+
* Where we go BEYOND Shopify we keep it: lots, `expiresAt`, FEFO and serial
|
|
226
|
+
* tracking have no native Shopify equivalent (merchants buy apps for both), and
|
|
227
|
+
* they are exactly what artorious and cristinarotondaro need. "Padrão Shopify"
|
|
228
|
+
* means compatible-by-default, never limited-to. The machine-readable form of
|
|
229
|
+
* this table is packages/shop/src/inventory/shopify-mapping.ts.
|
|
230
|
+
*/
|
|
231
|
+
export interface StockBalance {
|
|
232
|
+
id: string;
|
|
233
|
+
tenantId: string;
|
|
234
|
+
variantId: string;
|
|
235
|
+
locationId: string;
|
|
236
|
+
lotId: string | null;
|
|
237
|
+
onHand: number;
|
|
238
|
+
reserved: number;
|
|
239
|
+
/** onHand − reserved. What the mirror publishes to the storefront. */
|
|
240
|
+
available: number;
|
|
241
|
+
updatedAt: string;
|
|
242
|
+
}
|
|
243
|
+
/** A hold. Add-to-cart does NOT reserve; checkout start does (§5). */
|
|
244
|
+
export interface StockReservation {
|
|
245
|
+
id: string;
|
|
246
|
+
tenantId: string;
|
|
247
|
+
variantId: string;
|
|
248
|
+
locationId: string;
|
|
249
|
+
lotId: string | null;
|
|
250
|
+
quantity: number;
|
|
251
|
+
status: StockReservationStatus;
|
|
252
|
+
orderId: string | null;
|
|
253
|
+
cartToken: string | null;
|
|
254
|
+
/** The TTL that makes pix and boleto honest. */
|
|
255
|
+
expiresAt: string | null;
|
|
256
|
+
idempotencyKey: string | null;
|
|
257
|
+
createdBy: string | null;
|
|
258
|
+
createdAt: string;
|
|
259
|
+
updatedAt: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* One allocation-strategy vocabulary row
|
|
263
|
+
* (plg_shop_stock_allocation_strategies). The three behavioural fields are the
|
|
264
|
+
* ORDERING CONTRACT the engine reads — the same discipline as
|
|
265
|
+
* StockMovementKind.direction. Widening the vocabulary is a row, not a fork.
|
|
266
|
+
*/
|
|
267
|
+
export interface StockAllocationStrategy {
|
|
268
|
+
key: string;
|
|
269
|
+
label: string;
|
|
270
|
+
/** Order by expiry first, nulls last. FEFO. */
|
|
271
|
+
expiresFirst: boolean;
|
|
272
|
+
/** 'asc' = oldest receipt first (FIFO), 'desc' = newest first (LIFO). */
|
|
273
|
+
receivedOrder: 'asc' | 'desc';
|
|
274
|
+
/** Nothing is picked automatically; the caller names the lot. */
|
|
275
|
+
isManual: boolean;
|
|
276
|
+
}
|
|
277
|
+
/** One (lot, location) position allocation may draw from. */
|
|
278
|
+
export interface StockAllocationCandidate {
|
|
279
|
+
/** null for a quantity-tracked variant's one implicit lot. */
|
|
280
|
+
lotId: string | null;
|
|
281
|
+
locationId: string;
|
|
282
|
+
/** onHand − reserved for this position. */
|
|
283
|
+
available: number;
|
|
284
|
+
/** Calendar date, so FEFO order cannot depend on a reader's time zone. */
|
|
285
|
+
expiresAt: string | null;
|
|
286
|
+
receivedAt: string;
|
|
287
|
+
/** Transit stock exists but cannot be promised. Default true. */
|
|
288
|
+
isSellableLocation?: boolean;
|
|
289
|
+
/** Breaks ties so the answer is reproducible, not merely correct. */
|
|
290
|
+
isDefaultLocation?: boolean;
|
|
291
|
+
}
|
|
292
|
+
export interface StockAllocationRequest {
|
|
293
|
+
variantId: string;
|
|
294
|
+
quantity: number;
|
|
295
|
+
tracking: StockTrackingMode;
|
|
296
|
+
/** Narrow to one location. Omitted, the default location leads. */
|
|
297
|
+
locationId?: string | null;
|
|
298
|
+
/** Narrow to one lot — required by the `manual` strategy. */
|
|
299
|
+
lotId?: string | null;
|
|
300
|
+
/** Most specific first: explicit, then variant, then store, then derived. */
|
|
301
|
+
strategy?: string | null;
|
|
302
|
+
variantStrategy?: string | null;
|
|
303
|
+
tenantStrategy?: string | null;
|
|
304
|
+
}
|
|
305
|
+
/** One lot chosen, in picking order. They sum to the requested quantity. */
|
|
306
|
+
export interface StockAllocation {
|
|
307
|
+
lotId: string | null;
|
|
308
|
+
locationId: string;
|
|
309
|
+
quantity: number;
|
|
310
|
+
}
|
|
311
|
+
/** What a caller supplies to place a hold. Add-to-cart never calls this (§5). */
|
|
312
|
+
export interface ReserveStockInput {
|
|
313
|
+
variantId: string;
|
|
314
|
+
quantity: number;
|
|
315
|
+
locationId: string;
|
|
316
|
+
lotId?: string | null;
|
|
317
|
+
orderId?: string | null;
|
|
318
|
+
cartToken?: string | null;
|
|
319
|
+
/** The TTL that makes pix and boleto honest. Omitted ⇒ a hold with no expiry. */
|
|
320
|
+
ttlMinutes?: number | null;
|
|
321
|
+
/** A retried checkout must not hold the unit twice. */
|
|
322
|
+
idempotencyKey?: string | null;
|
|
323
|
+
}
|
|
324
|
+
export interface ListStockBalancesOptions {
|
|
325
|
+
variantId?: string;
|
|
326
|
+
variantIds?: string[];
|
|
327
|
+
locationId?: string;
|
|
328
|
+
lotId?: string;
|
|
329
|
+
/** Only rows a shopper could be promised (sellable, active locations). */
|
|
330
|
+
sellableOnly?: boolean;
|
|
331
|
+
}
|
|
332
|
+
export interface ListStockLotsOptions {
|
|
333
|
+
variantId?: string;
|
|
334
|
+
status?: StockLotStatus;
|
|
335
|
+
/** Lots expiring on or before this date — the "what is about to go off" read. */
|
|
336
|
+
expiresBefore?: string;
|
|
337
|
+
/** FEFO order: expiresAt then receivedAt, nulls last. Default true. */
|
|
338
|
+
fefo?: boolean;
|
|
339
|
+
limit?: number;
|
|
340
|
+
}
|
|
341
|
+
export interface ListStockMovementsOptions {
|
|
342
|
+
variantId?: string;
|
|
343
|
+
lotId?: string;
|
|
344
|
+
orderId?: string;
|
|
345
|
+
kind?: string;
|
|
346
|
+
reasonCode?: string;
|
|
347
|
+
/** Newest first. Default true — "why is this 3?" reads backwards. */
|
|
348
|
+
newestFirst?: boolean;
|
|
349
|
+
limit?: number;
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=stock-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-types.d.ts","sourceRoot":"","sources":["../../src/inventory/stock-types.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,gDAAiD,CAAA;AAClF,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAErE,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,EAAE,iBAA8B,CAAA;AAEnE,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,uDAAwD,CAAA;AACzF,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAErE,gDAAgD;AAChD,eAAO,MAAM,0BAA0B,2CAA4C,CAAA;AACnF,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAA;AAEhF,eAAO,MAAM,kBAAkB,2DAA4D,CAAA;AAC3F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEhE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,kCAAmC,CAAA;AACzE,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/E,wEAAwE;AACxE,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,sBAAsB,CAAA;CAClC;AAED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O,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { StockStore } from './stock-store';
|
|
2
|
+
import type { ListStockBalancesOptions, ListStockLotsOptions, ListStockMovementsOptions, RecordStockMovementInput, ReserveStockInput, StockAllocation, StockAllocationRequest, StockBalance, StockLocation, StockLot, StockMovement, StockReservation, StockReservationStatus } from './stock-types';
|
|
3
|
+
export declare function rowToStockLocation(row: any): StockLocation;
|
|
4
|
+
export declare class SupabaseStockStore implements StockStore {
|
|
5
|
+
private readonly explicitTenantId?;
|
|
6
|
+
/**
|
|
7
|
+
* An explicit tenant pins the store to one pool (what an ERP connector or a
|
|
8
|
+
* background job needs); omitted, it resolves per call through the same
|
|
9
|
+
* resolver every other plg_shop_* read uses.
|
|
10
|
+
*/
|
|
11
|
+
constructor(explicitTenantId?: string | undefined);
|
|
12
|
+
private tenantId;
|
|
13
|
+
private requireTenantId;
|
|
14
|
+
listLocations(): Promise<StockLocation[]>;
|
|
15
|
+
getDefaultLocation(): Promise<StockLocation | null>;
|
|
16
|
+
/**
|
|
17
|
+
* `sellableOnly` filters by an id set read from the locations table rather
|
|
18
|
+
* than by an embedded `!inner` join. Locations are a handful of rows per
|
|
19
|
+
* tenant, and the set is the same one mirroredInventoryCount() takes — so the
|
|
20
|
+
* mock, this store and 0036's mirror all narrow "sellable" through one
|
|
21
|
+
* definition instead of three query dialects.
|
|
22
|
+
*/
|
|
23
|
+
listBalances(options?: ListStockBalancesOptions): Promise<StockBalance[]>;
|
|
24
|
+
getAvailable(variantId: string): Promise<number>;
|
|
25
|
+
listLots(options?: ListStockLotsOptions): Promise<StockLot[]>;
|
|
26
|
+
listMovements(options?: ListStockMovementsOptions): Promise<StockMovement[]>;
|
|
27
|
+
listReservations(variantId?: string): Promise<StockReservation[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Append to the ledger. Never an update — a mistake is corrected by an
|
|
30
|
+
* opposing movement.
|
|
31
|
+
*
|
|
32
|
+
* IDEMPOTENCY IS TWO MECHANISMS, not one, and the second is the real one:
|
|
33
|
+
*
|
|
34
|
+
* 1. A pre-read on (tenant_id, idempotency_key) returns the existing
|
|
35
|
+
* movement. This is the ordinary retry — same caller, seconds later —
|
|
36
|
+
* and it costs one cheap indexed SELECT.
|
|
37
|
+
* 2. A `23505` on the INSERT is caught and re-read. This is the race the
|
|
38
|
+
* pre-read cannot cover: two retries in flight at once both miss the
|
|
39
|
+
* SELECT and both attempt the INSERT. 0034's partial unique index
|
|
40
|
+
* plg_shop_stock_movements_idempotency_key is what turns the loser into
|
|
41
|
+
* an error we can recognise instead of a second decrement.
|
|
42
|
+
*
|
|
43
|
+
* Without (2) a retried place_order under load decrements twice, which is
|
|
44
|
+
* precisely the failure the idempotency key exists to prevent.
|
|
45
|
+
*/
|
|
46
|
+
recordMovement(input: RecordStockMovementInput): Promise<StockMovement>;
|
|
47
|
+
allocate(request: Omit<StockAllocationRequest, 'tracking'>): Promise<StockAllocation[]>;
|
|
48
|
+
reserve(input: ReserveStockInput): Promise<StockReservation>;
|
|
49
|
+
setReservationStatus(reservationId: string, status: StockReservationStatus): Promise<void>;
|
|
50
|
+
sweepExpiredReservations(variantId?: string): Promise<number>;
|
|
51
|
+
private findByIdempotencyKey;
|
|
52
|
+
/** The variant facts the validator needs — tracking is 0034's new column. */
|
|
53
|
+
private readVariant;
|
|
54
|
+
private readLot;
|
|
55
|
+
/** on_hand for one lot across every location — the serial-bound predicate. */
|
|
56
|
+
private lotOnHand;
|
|
57
|
+
private sellableLocationIds;
|
|
58
|
+
}
|
|
59
|
+
export declare function createSupabaseStockStore(tenantId?: string): StockStore;
|
|
60
|
+
//# sourceMappingURL=supabase-stock-store.d.ts.map
|
|
@@ -0,0 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,aAAa,CAAC;IAoGvE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAmBvF,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwB5D,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1F,wBAAwB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAarD,oBAAoB;IAUlC,6EAA6E;YAC/D,WAAW;YAkBX,OAAO;IAarB,8EAA8E;YAChE,SAAS;YAKT,mBAAmB;CAMlC;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAEtE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Registry } from '@fayz-ai/core';
|
|
2
|
+
import type { RegistryMeta } from '@fayz-ai/core';
|
|
3
|
+
import type { RecordStockMovementInput, StockMovementKind, StockReasonCode, StockTrackingMode } from './stock-types';
|
|
4
|
+
/**
|
|
5
|
+
* The core movement kinds — the SAME rows the 0034 seed inserts with
|
|
6
|
+
* tenant_id NULL. `direction` is the sign contract:
|
|
7
|
+
* in ⇒ quantity must be positive
|
|
8
|
+
* out ⇒ quantity must be negative
|
|
9
|
+
* either ⇒ any non-zero quantity
|
|
10
|
+
*/
|
|
11
|
+
export declare const CORE_STOCK_MOVEMENT_KINDS: readonly StockMovementKind[];
|
|
12
|
+
/**
|
|
13
|
+
* The core reason codes — the SAME rows migrations 0034 and 0038 seed with
|
|
14
|
+
* tenant_id NULL. `movementKind` null = valid for any kind.
|
|
15
|
+
*
|
|
16
|
+
* The last five arrived with 0038 so that Shopify's CLOSED adjustment-reason
|
|
17
|
+
* vocabulary maps onto ours without loss (founder: "vamos padrão Shopify").
|
|
18
|
+
* They are a widening, which is exactly what I9 promises the vocabulary can
|
|
19
|
+
* take: five INSERTs and five entries here, no migration to the ENGINE and no
|
|
20
|
+
* fork. The mapping itself is published as code in shopify-mapping.ts, and
|
|
21
|
+
* stock-store.test.ts fails if a Shopify reason has no target here.
|
|
22
|
+
*/
|
|
23
|
+
export declare const CORE_STOCK_REASON_CODES: readonly StockReasonCode[];
|
|
24
|
+
/** The reason 0035 stamps on every backfilled opening balance. */
|
|
25
|
+
export declare const OPENING_BALANCE_REASON = "opening_balance";
|
|
26
|
+
/** The reason 0036's I10 shim stamps on a translated direct inventory_count write. */
|
|
27
|
+
export declare const LEGACY_WRITE_REASON = "legacy_write";
|
|
28
|
+
export declare const stockMovementKindRegistry: Registry<StockMovementKind>;
|
|
29
|
+
export declare const stockReasonCodeRegistry: Registry<StockReasonCode>;
|
|
30
|
+
/** Idempotent — consumers call before reads, mirroring registerCoreRuleAttributes. */
|
|
31
|
+
export declare function registerCoreStockVocabulary(): void;
|
|
32
|
+
export interface RegisterStockVocabularyOptions {
|
|
33
|
+
meta?: RegistryMeta;
|
|
34
|
+
/** Re-registering an existing key is an error unless the caller owns it. */
|
|
35
|
+
replace?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Widen the movement-kind vocabulary. The SQL half of this is one INSERT into
|
|
39
|
+
* plg_shop_stock_movement_kinds with the tenant's id.
|
|
40
|
+
*/
|
|
41
|
+
export declare function registerStockMovementKind(kind: StockMovementKind, options?: RegisterStockVocabularyOptions): void;
|
|
42
|
+
/** Widen the reason-code vocabulary — "quebra de vitrine" is a row, not a fork. */
|
|
43
|
+
export declare function registerStockReasonCode(reason: StockReasonCode, options?: RegisterStockVocabularyOptions): void;
|
|
44
|
+
/** The kind for a key, or an I2 hard error naming the valid set. */
|
|
45
|
+
export declare function resolveStockMovementKind(key: string): StockMovementKind;
|
|
46
|
+
/** The reason for a key, or an I2 hard error naming the valid set. */
|
|
47
|
+
export declare function resolveStockReasonCode(key: string): StockReasonCode;
|
|
48
|
+
export declare function listStockMovementKindKeys(): string[];
|
|
49
|
+
export declare function listStockReasonCodeKeys(): string[];
|
|
50
|
+
/** Every kind row, sorted — what an admin form renders itself from. */
|
|
51
|
+
export declare function listStockMovementKinds(): StockMovementKind[];
|
|
52
|
+
/** Every reason row, sorted. Optionally narrowed to one kind, which is exactly
|
|
53
|
+
* what the "record a movement" form needs once a kind is chosen. */
|
|
54
|
+
export declare function listStockReasonCodes(movementKind?: string): StockReasonCode[];
|
|
55
|
+
/** Test seam — a suite that widens the vocabulary must not leak into the next. */
|
|
56
|
+
export declare function clearStockVocabulary(): void;
|
|
57
|
+
/** What the validator needs to know about the variant a movement targets. */
|
|
58
|
+
export interface StockMovementVariantFacts {
|
|
59
|
+
tracking: StockTrackingMode;
|
|
60
|
+
/** Present only for lot/serial checks. */
|
|
61
|
+
lot?: {
|
|
62
|
+
id: string;
|
|
63
|
+
variantId: string;
|
|
64
|
+
serial: string | null;
|
|
65
|
+
} | null;
|
|
66
|
+
/**
|
|
67
|
+
* `on_hand` already recorded for (lot, location), needed ONLY by the serial
|
|
68
|
+
* rule below. Per-movement `|quantity| = 1` is not enough: two `+1` receipts
|
|
69
|
+
* on the same serial lot are each individually legal and together say the
|
|
70
|
+
* one-of-one unit exists twice. The cumulative check is what closes that,
|
|
71
|
+
* and it is the reason this fact has to be read before the write.
|
|
72
|
+
*/
|
|
73
|
+
lotOnHand?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Refuse anything the ledger must not accept. This is the TypeScript half of
|
|
77
|
+
* the specification whose SQL half is `shop_validate_stock_movement()` in
|
|
78
|
+
* migration 0034 — the two implement ONE ruleset, and
|
|
79
|
+
* `packages/shop/src/inventory/migrations.test.ts` pins the error vocabulary of
|
|
80
|
+
* both so they cannot quietly disagree.
|
|
81
|
+
*
|
|
82
|
+
* Throws with a message naming the valid set (I2). Never returns a "soft"
|
|
83
|
+
* failure: a movement that is dropped instead of refused is stock that vanishes.
|
|
84
|
+
*/
|
|
85
|
+
export declare function validateStockMovement(input: RecordStockMovementInput, facts: StockMovementVariantFacts): void;
|
|
86
|
+
//# sourceMappingURL=vocabulary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocabulary.d.ts","sourceRoot":"","sources":["../../src/inventory/vocabulary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EAClB,MAAM,eAAe,CAAA;AAsBtB;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,iBAAiB,EASjE,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,eAAe,EAyB7D,CAAA;AAED,kEAAkE;AAClE,eAAO,MAAM,sBAAsB,oBAAoB,CAAA;AACvD,sFAAsF;AACtF,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AAMjD,eAAO,MAAM,yBAAyB,6BAAuD,CAAA;AAC7F,eAAO,MAAM,uBAAuB,2BAAmD,CAAA;AAIvF,sFAAsF;AACtF,wBAAgB,2BAA2B,IAAI,IAAI,CAmBlD;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE,8BAAmC,GAC3C,IAAI,CAqBN;AAED,mFAAmF;AACnF,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,8BAAmC,GAC3C,IAAI,CAuBN;AAED,oEAAoE;AACpE,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CASvE;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CASnE;AAED,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAGpD;AAED,wBAAgB,uBAAuB,IAAI,MAAM,EAAE,CAGlD;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,IAAI,iBAAiB,EAAE,CAM5D;AAED;qEACqE;AACrE,wBAAgB,oBAAoB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CAQ7E;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C;AAID,6EAA6E;AAC7E,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,0CAA0C;IAC1C,GAAG,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAA;IACrE;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,wBAAwB,EAC/B,KAAK,EAAE,yBAAyB,GAC/B,IAAI,CAyFN"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BEYOND_SHOPIFY, CORE_RESERVATION_TTL_MINUTES, CORE_STOCK_ALLOCATION_STRATEGIES, CORE_STOCK_MOVEMENT_KINDS, CORE_STOCK_REASON_CODES, DEFAULT_STOCK_TRACKING, LEGACY_WRITE_REASON, MockStockStore, OPENING_BALANCE_REASON, OWN_FULFILLMENT, SHOPIFY_ADJUSTMENT_REASONS, SHOPIFY_DEFAULT_OPTION_NAME, SHOPIFY_DEFAULT_VARIANT_TITLE, SHOPIFY_QUANTITY_STATES, STOCK_LOCATION_KINDS, STOCK_LOT_STATUSES, STOCK_MOVEMENT_DIRECTIONS, STOCK_RESERVATION_STATUSES, STOCK_TRACKING_MODES, StockAllocationError, StockMovementError, SupabaseStockStore, TRACKING_MODES_BEYOND_SHOPIFY, allocateStock, clearStockAllocationStrategies, clearStockStores, clearStockVocabulary, compareStockAllocationCandidates, createMockStockStore, createSupabaseStockStore, getRegisteredStockStore, listStockAllocationStrategies, listStockAllocationStrategyKeys, listStockMovementKindKeys, listStockMovementKinds, listStockReasonCodeKeys, listStockReasonCodes, mirroredInventoryCount, registerCoreStockAllocationStrategies, registerCoreStockVocabulary, registerStockAllocationStrategy, registerStockMovementKind, registerStockReasonCode, registerStockStore, replayStockLedger, resolveAllocationStrategyKey, resolveReservationTtlMinutes, resolveStockAllocationStrategy, resolveStockMovementKind, resolveStockReasonCode, resolveStockStore, shopifyDefaultOptions, shopifyReasonToStockReason, stockAllocationStrategyRegistry, stockBalanceKey, stockMovementKindRegistry, stockReasonCodeRegistry, toShopifyVariantTitle, validateStockMovement } from './chunk-STRNMFC4.js';
|
|
2
|
+
import './chunk-KLDS7IPU.js';
|
|
3
|
+
//# sourceMappingURL=inventory.js.map
|
|
4
|
+
//# sourceMappingURL=inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"inventory.js"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { MOCK_PRODUCTS, MOCK_CATEGORIES, MOCK_DISCOUNTS, svgPlaceholder } from '../data/mock-catalog';
|
|
2
|
+
export { buildMockCatalog } from '../data/mock-catalog';
|
|
3
|
+
export type { CatalogInput, CatalogProductInput, CatalogCategoryInput } from '../data/mock-catalog';
|
|
4
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/lib/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ShopProvider } from '
|
|
2
|
-
import type { CartTotals, DiscountValidation, InventoryCheck, InventoryLine, Order } from '
|
|
1
|
+
import type { ShopProvider } from '../data/provider';
|
|
2
|
+
import type { CartTotals, DiscountValidation, InventoryCheck, InventoryLine, Order } from '../types';
|
|
3
3
|
/** Validate a discount code against the provider: existence, status, date window, usage limit, supported type. */
|
|
4
4
|
export declare function validateDiscount(input: {
|
|
5
5
|
code: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commerce.d.ts","sourceRoot":"","sources":["../../src/lib/commerce.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EACV,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAkB,aAAa,EAAE,KAAK,EACrF,MAAM,UAAU,CAAA;AAkBjB,kHAAkH;AAClH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/D,QAAQ,GAAE,YAAgC,GACzC,OAAO,CAAC,kBAAkB,CAAC,CA0B7B;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAS9H;AAED,8FAA8F;AAC9F,wBAAsB,cAAc,CAClC,KAAK,EAAE,aAAa,EAAE,EACtB,QAAQ,GAAE,YAAgC,GACzC,OAAO,CAAC,cAAc,CAAC,CAazB;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE;IAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAChG,QAAQ,GAAE,YAAgC,GACzC,OAAO,CAAC,UAAU,CAAC,CA2BrB;AAED,iFAAiF;AACjF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,YAAgC,GACzC,OAAO,CAAC,KAAK,EAAE,CAAC,CAElB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type DocumentKind = 'cpf' | 'cnpj';
|
|
2
|
+
export declare const documentDigits: (value: string | null | undefined) => string;
|
|
3
|
+
export declare function isValidCpf(value: string | null | undefined): boolean;
|
|
4
|
+
export declare function isValidCnpj(value: string | null | undefined): boolean;
|
|
5
|
+
/** Which document this is, by length — `null` when it is neither yet. */
|
|
6
|
+
export declare function documentKind(value: string | null | undefined): DocumentKind | null;
|
|
7
|
+
export declare function isValidDocument(value: string | null | undefined): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Progressive mask: formats what is typed so far and never blocks typing.
|
|
10
|
+
* A mask that only formats complete input leaves the field jumping at the end.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatDocument(value: string | null | undefined): string;
|
|
13
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/lib/document.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,CAAA;AAEzC,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAC1B,CAAA;AAcxC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CASpE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAOrE;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAKlF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAGzE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAavE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { EmailEventKey, EmailTemplate, EmailTemplateKind } from '../types';
|
|
2
|
+
export interface EmailEventDef {
|
|
3
|
+
event: EmailEventKey;
|
|
4
|
+
kind: EmailTemplateKind;
|
|
5
|
+
/** Template name in the list. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** What it does, in one line. */
|
|
8
|
+
description: string;
|
|
9
|
+
/** When it fires — the "event" half of the pair. */
|
|
10
|
+
trigger: string;
|
|
11
|
+
defaultSubject: string;
|
|
12
|
+
defaultBody: string;
|
|
13
|
+
/** lucide icon for the row. */
|
|
14
|
+
icon: string;
|
|
15
|
+
/** On by default in a new store. Order confirmation is the only email a buyer
|
|
16
|
+
* EXPECTS; the rest are the merchant's choice. */
|
|
17
|
+
defaultEnabled: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Placeholders the send substitutes. Documented here because this is what the
|
|
20
|
+
* merchant may type in the editor without breaking anything. */
|
|
21
|
+
export declare const EMAIL_PLACEHOLDERS: readonly ["{{store_name}}", "{{customer_name}}", "{{order_number}}", "{{order_total}}", "{{order_items}}", "{{tracking_code}}", "{{cart_url}}"];
|
|
22
|
+
export declare const SHOP_EMAIL_EVENTS: EmailEventDef[];
|
|
23
|
+
/**
|
|
24
|
+
* Substitutes the placeholders. Beside the catalog because PREVIEW and SEND must
|
|
25
|
+
* agree: a screen doing its own `replace` has the merchant approve one text and
|
|
26
|
+
* the customer receive another.
|
|
27
|
+
*
|
|
28
|
+
* An unknown placeholder stays visible as `{{foo}}` on purpose — in the preview
|
|
29
|
+
* that exposes the typo; hiding it would hide the gap until the email had gone.
|
|
30
|
+
*/
|
|
31
|
+
export declare function renderEmailTemplate(text: string, values: Record<string, string>): string;
|
|
32
|
+
/** Sample data for the preview. From no real order — the screen says so. */
|
|
33
|
+
export declare const EMAIL_PREVIEW_SAMPLE: Record<string, string>;
|
|
34
|
+
export interface ResolvedEmailTemplate extends EmailEventDef {
|
|
35
|
+
/** The merchant's override, when there is one. */
|
|
36
|
+
override: EmailTemplate | null;
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
/** Text in force: the merchant's if any, else the default. */
|
|
39
|
+
subject: string;
|
|
40
|
+
body: string;
|
|
41
|
+
/** true when the merchant rewrote the text — the list flags it. */
|
|
42
|
+
customized: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Joins the code catalog with the database overrides. A function and not a
|
|
46
|
+
* query: the merge must give the same answer in the list, the editor and the
|
|
47
|
+
* send, and three places doing the same `??` is how they start to disagree.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveEmailTemplates(overrides: EmailTemplate[]): ResolvedEmailTemplate[];
|
|
50
|
+
//# sourceMappingURL=emails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emails.d.ts","sourceRoot":"","sources":["../../src/lib/emails.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAe/E,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,aAAa,CAAA;IACpB,IAAI,EAAE,iBAAiB,CAAA;IACvB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ;uDACmD;IACnD,cAAc,EAAE,OAAO,CAAA;CACxB;AAED;iEACiE;AACjE,eAAO,MAAM,kBAAkB,iJAGrB,CAAA;AAEV,eAAO,MAAM,iBAAiB,EAAE,aAAa,EAiF5C,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAExF;AAED,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQvD,CAAA;AAED,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,kDAAkD;IAClD,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAA;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,qBAAqB,EAAE,CAazF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PluginEventDefinition, MessageDefaultsDef } from '@fayz-ai/core';
|
|
2
|
+
export declare function buildShopDomainEvents(): PluginEventDefinition[];
|
|
3
|
+
export declare function buildShopMessageDefaults(): MessageDefaultsDef[];
|
|
4
|
+
//# sourceMappingURL=message-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-events.d.ts","sourceRoot":"","sources":["../../src/lib/message-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAc,MAAM,eAAe,CAAA;AA8C1F,wBAAgB,qBAAqB,IAAI,qBAAqB,EAAE,CAU/D;AAeD,wBAAgB,wBAAwB,IAAI,kBAAkB,EAAE,CAiB/D"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ShopProvider } from '../data/provider';
|
|
2
|
+
export declare function getShopProvider(): ShopProvider;
|
|
3
|
+
export declare function setShopProvider(nextProvider: ShopProvider): void;
|
|
4
|
+
export declare function resetShopProvider(): void;
|
|
5
|
+
//# sourceMappingURL=runtime.d.ts.map
|