@fayz-ai/shop 0.8.0 → 0.8.2
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/dist/index.cjs +149 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +149 -3
- package/dist/index.js.map +1 -1
- package/dist/mock-provider.d.ts.map +1 -1
- package/dist/mock.cjs +5 -0
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.js +5 -0
- package/dist/mock.js.map +1 -1
- package/dist/provider.d.ts +36 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/runtime.cjs +5 -0
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -1
- package/dist/supabase-provider.d.ts +20 -1
- package/dist/supabase-provider.d.ts.map +1 -1
- package/dist/tables.d.ts +1 -0
- package/dist/tables.d.ts.map +1 -1
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +4 -0
- package/src/mock-provider.ts +5 -0
- package/src/provider.ts +39 -0
- package/src/supabase-provider.ts +196 -5
- package/src/tables.ts +4 -0
- package/src/types.ts +110 -0
package/src/types.ts
CHANGED
|
@@ -191,6 +191,11 @@ export interface Order {
|
|
|
191
191
|
customerEmail: string | null
|
|
192
192
|
discountCode: string | null
|
|
193
193
|
notes: string | null
|
|
194
|
+
/** Frozen delivery address captured at purchase time (0010/0012). */
|
|
195
|
+
shippingAddress: ShippingAddressSnapshot | null
|
|
196
|
+
/** How the buyer paid — opens the ledger row in public.transactions. */
|
|
197
|
+
paymentMethodKind: PaymentMethodKind | null
|
|
198
|
+
paidAt: string | null
|
|
194
199
|
items: OrderItem[]
|
|
195
200
|
createdAt: string
|
|
196
201
|
updatedAt: string
|
|
@@ -266,6 +271,106 @@ export interface PlaceOrderLine {
|
|
|
266
271
|
* storefront order. Prices, discount math, and inventory are resolved
|
|
267
272
|
* server-side; the client supplies product ids, quantities, and intent only.
|
|
268
273
|
*/
|
|
274
|
+
/** Structured delivery address. Mirrors public.addresses so the RPC can both
|
|
275
|
+
* freeze it on the order and save it to the customer's address book. */
|
|
276
|
+
export interface ShippingAddressInput {
|
|
277
|
+
postalCode: string
|
|
278
|
+
street: string
|
|
279
|
+
number?: string
|
|
280
|
+
complement?: string
|
|
281
|
+
district?: string
|
|
282
|
+
city: string
|
|
283
|
+
state: string
|
|
284
|
+
country?: string
|
|
285
|
+
recipient?: string
|
|
286
|
+
phone?: string
|
|
287
|
+
label?: string
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type PaymentMethodKind = 'pix' | 'credit_card' | 'debit_card' | 'boleto' | 'cash' | 'other'
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* A range of postal codes the store delivers to, with its own price and ETA.
|
|
294
|
+
*
|
|
295
|
+
* `postalFrom`/`postalTo` are 8 digits, no punctuation. Ranges may overlap: the
|
|
296
|
+
* cheapest match wins, which is how a merchant layers a promotional zone over a
|
|
297
|
+
* broader one without deleting anything.
|
|
298
|
+
*/
|
|
299
|
+
export interface ShippingZone {
|
|
300
|
+
id: string
|
|
301
|
+
tenantId: string
|
|
302
|
+
name: string
|
|
303
|
+
carrier?: string | null
|
|
304
|
+
postalFrom: string
|
|
305
|
+
postalTo: string
|
|
306
|
+
rate: number
|
|
307
|
+
/** Overrides the store-wide free-delivery threshold inside this zone. */
|
|
308
|
+
freeAbove?: number | null
|
|
309
|
+
etaMinDays?: number | null
|
|
310
|
+
etaMaxDays?: number | null
|
|
311
|
+
active: boolean
|
|
312
|
+
sortOrder: number
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export type CreateShippingZoneInput = Omit<ShippingZone, 'id' | 'tenantId'>
|
|
316
|
+
export type UpdateShippingZoneInput = Partial<CreateShippingZoneInput>
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* One delivery option for a postal code, as quoted by shop_quote_shipping.
|
|
320
|
+
*
|
|
321
|
+
* `rate` already has the zone's free-above threshold applied, so the caller
|
|
322
|
+
* never re-derives a price — the number shown is the number charged. An EMPTY
|
|
323
|
+
* list of options is the meaningful answer "we do not deliver there", not an
|
|
324
|
+
* error condition.
|
|
325
|
+
*/
|
|
326
|
+
export interface ShippingQuoteOption {
|
|
327
|
+
zoneId: string
|
|
328
|
+
name: string
|
|
329
|
+
carrier?: string
|
|
330
|
+
/** Resolved against the subtotal the quote was requested for. */
|
|
331
|
+
rate: number
|
|
332
|
+
/** The zone's price before any free-above rule — lets a caller re-resolve
|
|
333
|
+
* `rate` for a changed cart without another round trip, using the same rule
|
|
334
|
+
* the server applies. Without it a stale quote had to fall back to the
|
|
335
|
+
* store-wide flat rate, which is a different zone's price. */
|
|
336
|
+
baseRate: number
|
|
337
|
+
freeAbove?: number | null
|
|
338
|
+
etaMinDays?: number
|
|
339
|
+
etaMaxDays?: number
|
|
340
|
+
/** True when the rate is 0 because the order cleared the zone's threshold. */
|
|
341
|
+
free: boolean
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* A row from the customer's address book (public.addresses).
|
|
346
|
+
*
|
|
347
|
+
* Only reachable with a signed-in shopper: the addresses_self_read policy joins
|
|
348
|
+
* plg_shop_customers.auth_user_id to auth.uid(), so an anonymous request sees
|
|
349
|
+
* nothing. Guests get an empty book and type their address, which is correct —
|
|
350
|
+
* the alternative is showing them somebody else's.
|
|
351
|
+
*/
|
|
352
|
+
export interface CustomerAddress extends ShippingAddressInput {
|
|
353
|
+
id: string
|
|
354
|
+
isDefault?: boolean
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** Address as stored on the order: snake_case, mirroring public.addresses. */
|
|
358
|
+
export interface ShippingAddressSnapshot {
|
|
359
|
+
postal_code?: string
|
|
360
|
+
street?: string
|
|
361
|
+
number?: string
|
|
362
|
+
complement?: string
|
|
363
|
+
district?: string
|
|
364
|
+
city?: string
|
|
365
|
+
state?: string
|
|
366
|
+
country?: string
|
|
367
|
+
recipient?: string
|
|
368
|
+
phone?: string
|
|
369
|
+
label?: string
|
|
370
|
+
raw?: string
|
|
371
|
+
source?: string
|
|
372
|
+
}
|
|
373
|
+
|
|
269
374
|
export interface PlaceOrderInput {
|
|
270
375
|
/** Tenant/store id. The Supabase provider falls back to the resolved shop tenant. */
|
|
271
376
|
tenantId?: string
|
|
@@ -279,6 +384,11 @@ export interface PlaceOrderInput {
|
|
|
279
384
|
discountCode?: string
|
|
280
385
|
/** Shipping cost from the store's shipping policy. Clamped to >= 0 server-side. */
|
|
281
386
|
shippingTotal?: number
|
|
387
|
+
/** Structured delivery address. Without it the address survives only as free
|
|
388
|
+
* text in `notes`, which logistics cannot read. */
|
|
389
|
+
shippingAddress?: ShippingAddressInput
|
|
390
|
+
/** How the buyer is paying. Opens the ledger row in public.transactions. */
|
|
391
|
+
paymentMethod?: PaymentMethodKind
|
|
282
392
|
items: PlaceOrderLine[]
|
|
283
393
|
}
|
|
284
394
|
|