@fayz-ai/shop 0.10.0 → 0.12.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.
Files changed (65) hide show
  1. package/dist/{chunk-IL6GA4ER.js → chunk-2WACO2TG.js} +3 -3
  2. package/dist/{chunk-IL6GA4ER.js.map → chunk-2WACO2TG.js.map} +1 -1
  3. package/dist/{chunk-RGTIJQJL.js → chunk-6BO2TMZ5.js} +3 -3
  4. package/dist/{chunk-RGTIJQJL.js.map → chunk-6BO2TMZ5.js.map} +1 -1
  5. package/dist/{chunk-XOP6SHPB.js → chunk-NWW3WJ7Y.js} +4 -10
  6. package/dist/chunk-NWW3WJ7Y.js.map +1 -0
  7. package/dist/{chunk-XERLK5LD.js → chunk-STRNMFC4.js} +28 -5
  8. package/dist/chunk-STRNMFC4.js.map +1 -0
  9. package/dist/{chunk-U3O2I3RM.js → chunk-U6HV3LVP.js} +385 -23
  10. package/dist/chunk-U6HV3LVP.js.map +1 -0
  11. package/dist/data/checkout-gateways.d.ts +28 -0
  12. package/dist/data/checkout-gateways.d.ts.map +1 -0
  13. package/dist/data/customer-search.d.ts +3 -0
  14. package/dist/data/customer-search.d.ts.map +1 -0
  15. package/dist/data/functions.d.ts +9 -0
  16. package/dist/data/functions.d.ts.map +1 -0
  17. package/dist/data/media.d.ts +37 -0
  18. package/dist/data/media.d.ts.map +1 -0
  19. package/dist/data/mock-provider.d.ts +40 -8
  20. package/dist/data/mock-provider.d.ts.map +1 -1
  21. package/dist/data/provider.d.ts +205 -7
  22. package/dist/data/provider.d.ts.map +1 -1
  23. package/dist/data/supabase-provider.d.ts +118 -5
  24. package/dist/data/supabase-provider.d.ts.map +1 -1
  25. package/dist/data/tables.d.ts +3 -0
  26. package/dist/data/tables.d.ts.map +1 -1
  27. package/dist/entities/index.d.ts +0 -1
  28. package/dist/entities/index.d.ts.map +1 -1
  29. package/dist/entities.js +2 -2
  30. package/dist/index.d.ts +16 -5
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +925 -60
  33. package/dist/index.js.map +1 -1
  34. package/dist/inventory/index.d.ts +2 -2
  35. package/dist/inventory/index.d.ts.map +1 -1
  36. package/dist/inventory/stock-types.d.ts +60 -1
  37. package/dist/inventory/stock-types.d.ts.map +1 -1
  38. package/dist/inventory/supabase-stock-store.d.ts +1 -0
  39. package/dist/inventory/supabase-stock-store.d.ts.map +1 -1
  40. package/dist/inventory.js +1 -1
  41. package/dist/lib/commerce.d.ts.map +1 -1
  42. package/dist/lib/document.d.ts +13 -0
  43. package/dist/lib/document.d.ts.map +1 -0
  44. package/dist/lib/variant-matrix.d.ts +120 -0
  45. package/dist/lib/variant-matrix.d.ts.map +1 -0
  46. package/dist/mock.js +2 -2
  47. package/dist/providers/checkout.d.ts +129 -0
  48. package/dist/providers/checkout.d.ts.map +1 -0
  49. package/dist/providers/index.d.ts +5 -0
  50. package/dist/providers/index.d.ts.map +1 -0
  51. package/dist/providers/shipping.d.ts +43 -0
  52. package/dist/providers/shipping.d.ts.map +1 -0
  53. package/dist/providers.js +70 -0
  54. package/dist/providers.js.map +1 -0
  55. package/dist/runtime.js +3 -3
  56. package/dist/shipping/label-provider.d.ts +43 -0
  57. package/dist/shipping/label-provider.d.ts.map +1 -0
  58. package/dist/types.d.ts +475 -0
  59. package/dist/types.d.ts.map +1 -1
  60. package/package.json +8 -4
  61. package/dist/chunk-U3O2I3RM.js.map +0 -1
  62. package/dist/chunk-XERLK5LD.js.map +0 -1
  63. package/dist/chunk-XOP6SHPB.js.map +0 -1
  64. package/dist/entities/sidecar.d.ts +0 -9
  65. package/dist/entities/sidecar.d.ts.map +0 -1
@@ -1,8 +1,8 @@
1
1
  export { StockMovementError, stockBalanceKey, replayStockLedger, mirroredInventoryCount } from './stock-store';
2
2
  export { registerStockStore, getRegisteredStockStore, resolveStockStore, clearStockStores, } from './stock-store';
3
3
  export type { StockStore } from './stock-store';
4
- export { STOCK_TRACKING_MODES, DEFAULT_STOCK_TRACKING, STOCK_LOCATION_KINDS, STOCK_RESERVATION_STATUSES, STOCK_LOT_STATUSES, STOCK_MOVEMENT_DIRECTIONS, } from './stock-types';
5
- export type { StockTrackingMode, StockLocationKind, StockReservationStatus, StockLotStatus, StockMovementDirection, StockMovementKind, StockReasonCode, StockLocation, StockLot, StockMovement, StockBalance, StockReservation, RecordStockMovementInput, ListStockBalancesOptions, ListStockLotsOptions, ListStockMovementsOptions, StockAllocationStrategy, StockAllocationCandidate, StockAllocationRequest, StockAllocation, ReserveStockInput, } from './stock-types';
4
+ export { STOCK_TRACKING_MODES, DEFAULT_STOCK_TRACKING, STOCK_LOCATION_KINDS, STOCK_RESERVATION_STATUSES, STOCK_LOT_STATUSES, STOCK_MOVEMENT_DIRECTIONS, OWN_FULFILLMENT, } from './stock-types';
5
+ export type { StockTrackingMode, StockLocationKind, StockReservationStatus, StockLotStatus, StockMovementDirection, StockMovementKind, StockReasonCode, StockLocation, CreateStockLocationInput, UpdateStockLocationInput, StockLot, StockMovement, StockBalance, StockReservation, RecordStockMovementInput, ListStockBalancesOptions, ListStockLotsOptions, ListStockMovementsOptions, StockAllocationStrategy, StockAllocationCandidate, StockAllocationRequest, StockAllocation, ReserveStockInput, } from './stock-types';
6
6
  export { CORE_STOCK_MOVEMENT_KINDS, CORE_STOCK_REASON_CODES, OPENING_BALANCE_REASON, LEGACY_WRITE_REASON, stockMovementKindRegistry, stockReasonCodeRegistry, registerCoreStockVocabulary, registerStockMovementKind, registerStockReasonCode, resolveStockMovementKind, resolveStockReasonCode, listStockMovementKindKeys, listStockReasonCodeKeys, listStockMovementKinds, listStockReasonCodes, clearStockVocabulary, validateStockMovement, } from './vocabulary';
7
7
  export type { RegisterStockVocabularyOptions, StockMovementVariantFacts } from './vocabulary';
8
8
  export { CORE_STOCK_ALLOCATION_STRATEGIES, CORE_RESERVATION_TTL_MINUTES, StockAllocationError, stockAllocationStrategyRegistry, registerCoreStockAllocationStrategies, registerStockAllocationStrategy, resolveStockAllocationStrategy, resolveAllocationStrategyKey, listStockAllocationStrategyKeys, listStockAllocationStrategies, clearStockAllocationStrategies, compareStockAllocationCandidates, allocateStock, resolveReservationTtlMinutes, } from './allocation';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inventory/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC9G,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,GAClB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAE7F,OA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gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,GAClB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAE7F,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC5B,oBAAoB,EACpB,+BAA+B,EAC/B,qCAAqC,EACrC,+BAA+B,EAC/B,8BAA8B,EAC9B,4BAA4B,EAC5B,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,gCAAgC,EAChC,aAAa,EACb,4BAA4B,GAC7B,MAAM,cAAc,CAAA;AAIrB,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,uBAAuB,EACvB,0BAA0B,EAC1B,cAAc,EACd,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACrF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA"}
@@ -46,7 +46,12 @@ export interface StockReasonCode {
46
46
  label: string;
47
47
  movementKind: string | null;
48
48
  }
49
- /** Where stock sits. Single-location stores never see this concept. */
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. */
50
55
  export interface StockLocation {
51
56
  id: string;
52
57
  tenantId: string;
@@ -57,9 +62,63 @@ export interface StockLocation {
57
62
  isSellable: boolean;
58
63
  isDefault: boolean;
59
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;
60
93
  createdAt: string;
61
94
  updatedAt: string;
62
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>;
63
122
  /** A batch. A serial-tracked unit is a lot whose quantity is 1. */
64
123
  export interface StockLot {
65
124
  id: string;
@@ -1 +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;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,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,uEAAuE;IACvE,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,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"}
@@ -1,5 +1,6 @@
1
1
  import type { StockStore } from './stock-store';
2
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;
3
4
  export declare class SupabaseStockStore implements StockStore {
4
5
  private readonly explicitTenantId?;
5
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"supabase-stock-store.d.ts","sourceRoot":"","sources":["../../src/inventory/supabase-stock-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACj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GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAqBhF,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAcvE;;;;;;;;;;;;;;;;;OAiBG;IACG,cAAc,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,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"}
package/dist/inventory.js CHANGED
@@ -1,4 +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, 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-XERLK5LD.js';
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
2
  import './chunk-KLDS7IPU.js';
3
3
  //# sourceMappingURL=inventory.js.map
4
4
  //# sourceMappingURL=inventory.js.map
@@ -1 +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,CAkB7B;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,E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C;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,120 @@
1
+ import type { ShopProvider } from '../data/provider';
2
+ import type { ProductOption, ProductVariant } from '../types';
3
+ /** Shopify's ceiling, carried so a future connector never has to reject a product it can't map. */
4
+ export declare const MAX_VARIANT_AXES = 3;
5
+ export declare const MAX_VARIANT_COMBINATIONS = 100;
6
+ /** An axis as the editor holds it: no id yet, values not yet cleaned. */
7
+ export interface VariantAxisInput {
8
+ name: string;
9
+ values: string[];
10
+ }
11
+ export type VariantCombination = Record<string, string>;
12
+ /**
13
+ * The canonical string for a combination. Sorted by key because 0028 stores
14
+ * `options` as jsonb, which normalises key order on write — so
15
+ * {"Cor":"Azul","Tamanho":"P"} and {"Tamanho":"P","Cor":"Azul"} are ONE row to
16
+ * the UNIQUE index, and anything comparing them in TypeScript has to agree.
17
+ */
18
+ export declare function variantOptionsKey(options: VariantCombination): string;
19
+ /**
20
+ * Trim, drop the blanks, dedupe the values. An axis with no name or no value is
21
+ * removed outright: it cannot contribute a combination, and keeping it would
22
+ * multiply the matrix by zero.
23
+ */
24
+ export declare function normalizeVariantAxes(axes: readonly VariantAxisInput[]): VariantAxisInput[];
25
+ /**
26
+ * The cartesian product, LAST axis varying fastest — P/Cru, P/Azul, M/Cru… That
27
+ * is the order Shopify lists variants in and the order a merchant reads a size
28
+ * chart in; deriving it any other way makes the grid look shuffled.
29
+ */
30
+ export declare function variantCombinations(axes: readonly VariantAxisInput[]): VariantCombination[];
31
+ /** Why the axes cannot be saved, or null. Both limits are Shopify's. */
32
+ export declare function validateVariantAxes(axes: readonly VariantAxisInput[]): string | null;
33
+ /** One cell of the matrix: a combination and the row that carries it, if any. */
34
+ export interface VariantMatrixRow {
35
+ options: VariantCombination;
36
+ /** Grid order, written back to `position` so the DB reads in the same order. */
37
+ position: number;
38
+ variant: ProductVariant | null;
39
+ }
40
+ export interface VariantMatrixPlan {
41
+ /** The whole matrix, in grid order. */
42
+ rows: VariantMatrixRow[];
43
+ /** Combinations with no row at all — INSERT. */
44
+ create: VariantMatrixRow[];
45
+ /** Combinations whose row exists but is archived — UPDATE back to active,
46
+ * because 0028's UNIQUE (product_id, options) refuses a second row and a
47
+ * DELETE would take the archived row's stock balances with it (0034 CASCADEs). */
48
+ reactivate: VariantMatrixRow[];
49
+ /** Active rows the axes still describe. Nothing to do but reposition. */
50
+ keep: VariantMatrixRow[];
51
+ /** Active rows the axes no longer describe — ARCHIVE, never delete, for the
52
+ * same reason 0037 §4 archives the default variant. */
53
+ archive: ProductVariant[];
54
+ /**
55
+ * The default variant (0037), if the product has one. It is NEVER in any of
56
+ * the lists above: it carries no options, so the matrix can neither describe
57
+ * it nor orphan it. Its lifecycle is reconciled separately — see
58
+ * applyVariantMatrix.
59
+ */
60
+ defaultVariant: ProductVariant | null;
61
+ }
62
+ /**
63
+ * What has to happen to make the variant rows match the axes.
64
+ *
65
+ * `existing` must include ARCHIVED rows. A merchant who removes "GG" and puts
66
+ * it back an hour later is not creating a new SKU — and INSERTing one would hit
67
+ * 0028's UNIQUE (product_id, options) rather than gracefully doing anything.
68
+ */
69
+ export declare function planVariantMatrix(axes: readonly VariantAxisInput[], existing: readonly ProductVariant[]): VariantMatrixPlan;
70
+ /**
71
+ * Whether the product is option-less as far as the merchant is concerned: one
72
+ * variant, and it is 0037's placeholder. The admin shows the empty state for
73
+ * this, never a one-row grid — 0037 is explicit that the default variant MUST
74
+ * BE INVISIBLE (no picker, no admin column, no options label).
75
+ */
76
+ export declare function hasOnlyDefaultVariant(variants: readonly ProductVariant[]): boolean;
77
+ /**
78
+ * Whether applying the plan would leave the product with NOTHING ACTIVE to
79
+ * sell, and no default variant to fall back on.
80
+ *
81
+ * FOUND BY READING 0039, NOT BY USING THE SCREEN, and the failure is silent:
82
+ * with every real variant archived and 0037's default archived too (§4 archived
83
+ * it the moment the first real variant appeared), shop_place_order's resolution
84
+ * pass finds no default, falls through to the DEPRECATED product-scalar leg,
85
+ * and 0028's sync trigger then recomputes plg_shop_products.inventory_count as
86
+ * the sum of ZERO active variants. The merchant deletes an option and the
87
+ * product goes permanently sold out, with no error anywhere.
88
+ *
89
+ * applyVariantMatrix closes the case where the default row EXISTS (it revives
90
+ * it). This predicate is the residue: a product that predates 0037's backfill
91
+ * has no such row, and no client can mint one — 0047 is what fixes that.
92
+ */
93
+ export declare function leavesNothingSellable(plan: VariantMatrixPlan): boolean;
94
+ /**
95
+ * The axes a variant set implies, position-ordered — what the editor opens
96
+ * with. Taken from `options` rows rather than derived from the variants: 0028
97
+ * makes the ORDER of the values meaningful ("P before M before G is not
98
+ * alphabetical and not arbitrary, so it cannot be derived").
99
+ */
100
+ export declare function axesFromOptions(options: readonly ProductOption[]): VariantAxisInput[];
101
+ /**
102
+ * Save the axes and reconcile the variant rows to them, INCLUDING 0037's
103
+ * default variant. The whole rule lives here rather than in the screen because
104
+ * every step of it is a database invariant, and a second screen that
105
+ * re-implemented four of the five steps would be right until the day it wasn't.
106
+ *
107
+ * Order is load-bearing:
108
+ * 1. axes first, so a variant referring to a value the axes no longer declare
109
+ * is never visible even for one render;
110
+ * 2. INSERT the new combinations — which is also what fires 0037 §4 and
111
+ * archives the default variant, so we never do that by hand on this path;
112
+ * 3. revive the archived combinations (an UPDATE, which fires NO trigger —
113
+ * hence step 5);
114
+ * 4. archive what the axes dropped;
115
+ * 5. reconcile the default variant in whichever direction is now true.
116
+ */
117
+ export declare function applyVariantMatrix(provider: ShopProvider, productId: string, axes: readonly VariantAxisInput[], existing: readonly ProductVariant[]): Promise<VariantMatrixPlan>;
118
+ /** The merchant-facing label for a combination: "Tamanho: P · Cor: Azul". */
119
+ export declare function formatVariantCombination(options: VariantCombination, axes?: readonly VariantAxisInput[]): string;
120
+ //# sourceMappingURL=variant-matrix.d.ts.map
@@ -0,0 +1 @@
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,CAAA;IAC9B,yEAAyE;IACzE,IAAI,EAAE,gBAAgB,EAAE,CAAA;IACxB;4DACwD;IACxD,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB;;;;;OAKG;IACH,cAAc,EAAE,cAAc,GAAG,IAAI,CAAA;CACtC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,gBAAgB,EAAE,EACjC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,iBAAiB,CAgCnB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAGlF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAGtE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,gBAAgB,EAAE,CAIrF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,SAAS,gBAAgB,EAAE,EACjC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,OAAO,CAAC,iBAAiB,CAAC,CA0C5B;AAED,6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,CAMhH"}
package/dist/mock.js CHANGED
@@ -1,6 +1,6 @@
1
- export { MockShopProvider, createMockShopProvider } from './chunk-U3O2I3RM.js';
1
+ export { MockShopProvider, createMockShopProvider } from './chunk-U6HV3LVP.js';
2
2
  import './chunk-IKNGCRUM.js';
3
- import './chunk-XOP6SHPB.js';
3
+ import './chunk-NWW3WJ7Y.js';
4
4
  import './chunk-3GERSY5F.js';
5
5
  //# sourceMappingURL=mock.js.map
6
6
  //# sourceMappingURL=mock.js.map
@@ -0,0 +1,129 @@
1
+ import type { EffectLedger, EffectOutcome, RequestOutcome } from '@fayz-ai/core';
2
+ import { RequestBlockedError } from '@fayz-ai/core';
3
+ import type { RequestPlaneConnector } from './shipping';
4
+ /** What the buyer picked. Open on purpose — a gateway declares what it can do. */
5
+ export type CheckoutMethod = 'pix' | 'boleto' | 'credit_card' | (string & {});
6
+ /**
7
+ * The payable artifacts, one shape per method.
8
+ *
9
+ * TRANSPARENT VS REDIRECT (commerce-stack.md §8.1, open until now): Pix and
10
+ * boleto are transparent because nothing sensitive passes through us — a QR
11
+ * code and a barcode are public strings. CARD IS REDIRECT: taking a card number
12
+ * on our page moves us into PCI-DSS SAQ A-EP, which is architecture (browser
13
+ * tokenisation, scope, an audit) rather than a week of work, and this milestone
14
+ * is the contract, not the compliance programme.
15
+ *
16
+ * The decision is reversible for exactly the reason it is expressed here as an
17
+ * artifact and not as a checkout flow: transparent card becomes
18
+ * `card.tokenizationKey` alongside `card.redirectUrl`, and the storefront that
19
+ * renders whatever came back does not change.
20
+ */
21
+ export interface CheckoutArtifacts {
22
+ pix?: {
23
+ qrCode: string;
24
+ copyPaste: string;
25
+ expiresAt?: string;
26
+ };
27
+ boleto?: {
28
+ url: string;
29
+ barcode?: string;
30
+ dueDate?: string;
31
+ };
32
+ card?: {
33
+ redirectUrl: string;
34
+ installments?: number;
35
+ };
36
+ }
37
+ export type CheckoutSessionStatus = 'pending' | 'authorized' | 'paid' | 'failed' | 'expired';
38
+ export interface CheckoutSession {
39
+ sessionId: string;
40
+ method: CheckoutMethod;
41
+ status: CheckoutSessionStatus;
42
+ /** Minor units. The recomputed one — never a number that arrived from a client. */
43
+ amountCents: number;
44
+ currency: string;
45
+ artifacts: CheckoutArtifacts;
46
+ /** When the total was recomputed server-side for THIS session. The proof, carried with the value. */
47
+ amountRecomputedAt: string;
48
+ }
49
+ export interface CheckoutStartRequest {
50
+ orderId: string;
51
+ method: CheckoutMethod;
52
+ installments?: number;
53
+ }
54
+ export interface CheckoutStarterOptions {
55
+ connector: RequestPlaneConnector;
56
+ /** Recompute the payable total from the order, server-side. The ONLY source of the amount. */
57
+ recompute(orderId: string): Promise<{
58
+ amountCents: number;
59
+ currency: string;
60
+ }>;
61
+ /** The data-plane call that opens the session at the gateway. */
62
+ open(input: CheckoutStartRequest & {
63
+ amountCents: number;
64
+ currency: string;
65
+ }, signal: AbortSignal): Promise<Omit<CheckoutSession, 'amountRecomputedAt'>>;
66
+ now?(): Date;
67
+ }
68
+ /**
69
+ * Open a payment session under the gateway's declared budget.
70
+ *
71
+ * Returns the full {@link RequestOutcome} rather than the bare session so the
72
+ * caller can report `elapsedMs`; `source` is always `'provider'` here, because
73
+ * a `block` connector never degrades — it throws {@link RequestBlockedError},
74
+ * which carries the reason the buyer is shown.
75
+ */
76
+ export declare function createCheckoutStarter(options: CheckoutStarterOptions): (request: CheckoutStartRequest) => Promise<RequestOutcome<CheckoutSession>>;
77
+ export { RequestBlockedError };
78
+ export interface CapturePaymentRequest {
79
+ /** The plg_connections row acting. The tenant is resolved from it server-side. */
80
+ connectionId: string;
81
+ orderId: string;
82
+ amountCents: number;
83
+ /** A gateway webhook by default; 'manual' when an operator captures from the panel. */
84
+ triggerKind?: 'webhook' | 'manual';
85
+ }
86
+ export interface CapturePaymentOptions {
87
+ ledger: EffectLedger;
88
+ /** The data-plane call that captures at the gateway. Reached at most once per key. */
89
+ capture(request: CapturePaymentRequest, runId: string): Promise<{
90
+ status: CheckoutSessionStatus;
91
+ providerRef?: string;
92
+ }>;
93
+ }
94
+ /**
95
+ * Capture at most once per (order, amount).
96
+ *
97
+ * The key is the BUYER's — `capture:<order>:<cents>` — and not the gateway's
98
+ * transaction id, because that id only exists after the call that must not
99
+ * happen twice. A re-delivered webhook and a double-clicked button both hash to
100
+ * the same string and the second one never reaches the gateway.
101
+ */
102
+ export declare function createPaymentCapturer(options: CapturePaymentOptions): (request: CapturePaymentRequest) => Promise<EffectOutcome<{
103
+ status: CheckoutSessionStatus;
104
+ providerRef?: string;
105
+ }>>;
106
+ /**
107
+ * Buy the shipping label at most once per order.
108
+ *
109
+ * The second effect on the plane, and the reason the ledger lives in
110
+ * `@fayz-ai/core` rather than inside the gateway: a label bought twice is money
111
+ * spent twice, by the same mechanism.
112
+ */
113
+ export declare function createLabelBuyer(options: {
114
+ ledger: EffectLedger;
115
+ buy(request: {
116
+ connectionId: string;
117
+ orderId: string;
118
+ }, runId: string): Promise<{
119
+ trackingCode?: string;
120
+ labelUrl?: string;
121
+ }>;
122
+ }): (request: {
123
+ connectionId: string;
124
+ orderId: string;
125
+ }) => Promise<EffectOutcome<{
126
+ trackingCode?: string;
127
+ labelUrl?: string;
128
+ }>>;
129
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/providers/checkout.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,kFAAkF;AAClF,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAE7E;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC/D,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5D,IAAI,CAAC,EAAE;QAAE,WAAW,EAAE,M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AAW,qBAAqB;IACpC,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,uFAAuF;IACvF,WAAW,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,YAAY,CAAA;IACpB,sFAAsF;IACtF,OAAO,CAAC,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,qBAAqB,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzH;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,IAEhE,SAAS,qBAAqB,KAC7B,OAAO,CAAC,aAAa,CAAC;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAiBnF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,YAAY,CAAA;IACpB,GAAG,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9H,IACgC,SAAS;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;mBAFgB,MAAM;eAAa,MAAM;IAe3H"}
@@ -0,0 +1,5 @@
1
+ export { createShippingQuoter } from './shipping';
2
+ export type { ShippingQuoteRequest, QuotedShipping, ShippingQuoterOptions, RequestPlaneConnector, } from './shipping';
3
+ export { createCheckoutStarter, createPaymentCapturer, createLabelBuyer, RequestBlockedError } from './checkout';
4
+ export type { CheckoutMethod, CheckoutArtifacts, CheckoutSession, CheckoutSessionStatus, CheckoutStartRequest, CheckoutStarterOptions, CapturePaymentRequest, CapturePaymentOptions, } from './checkout';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChH,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,YAAY,CAAA"}
@@ -0,0 +1,43 @@
1
+ import type { ConnectorDefinition, DegradeReason } from '@fayz-ai/core';
2
+ import type { ShippingQuoteOption } from '../types';
3
+ export type RequestPlaneConnector = Pick<ConnectorDefinition, 'id' | 'planes' | 'latencyBudgetMs' | 'onFailure'>;
4
+ export interface ShippingQuoteRequest {
5
+ /** Eight bare digits. */
6
+ postalCode: string;
7
+ /** Decides free-above thresholds; the ORDER is recomputed by shop_place_order regardless. */
8
+ subtotal: number;
9
+ }
10
+ export interface QuotedShipping {
11
+ options: ShippingQuoteOption[];
12
+ /** Where the prices came from. A fallback price shown as a carrier price is how a store quotes one number and charges another. */
13
+ source: 'provider' | 'fallback';
14
+ degraded?: {
15
+ reason: DegradeReason;
16
+ detail?: string;
17
+ };
18
+ }
19
+ export interface ShippingQuoterOptions {
20
+ connector: RequestPlaneConnector;
21
+ /** The data-plane call. Receives the abort signal the budget fires. */
22
+ quote(request: ShippingQuoteRequest, signal: AbortSignal): Promise<ShippingQuoteOption[]>;
23
+ /**
24
+ * The configured zones. Must be LOCAL — a fallback that itself calls a network
25
+ * is a second budget nobody declared.
26
+ */
27
+ zones(request: ShippingQuoteRequest): Promise<ShippingQuoteOption[]>;
28
+ /** False when there is no live connection: quote from zones without spending the budget. */
29
+ connected?(): boolean;
30
+ }
31
+ /**
32
+ * A quoter that always answers.
33
+ *
34
+ * An EMPTY provider answer is a provider answer, not a failure: a carrier that
35
+ * does not serve a postcode has told us something, and the storefront already
36
+ * knows what to do with zero options (delivery.store.ts falls back to the
37
+ * store-wide rate). Inventing a merge here would be policy nobody asked for.
38
+ *
39
+ * Writes nothing, on either path. A quote is not a run — see
40
+ * packages/db/migrations/029_connections.sql.
41
+ */
42
+ export declare function createShippingQuoter(options: ShippingQuoterOptions): (request: ShippingQuoteRequest) => Promise<QuotedShipping>;
43
+ //# sourceMappingURL=shipping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping.d.ts","sourceRoot":"","sources":["../../src/providers/shipping.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,mBAAmB,EACnB,IAAI,GAAG,QAAQ,GAAG,iBAAiB,GAAG,WAAW,CAClD,CAAA;AAED,MAAM,WAAW,oBAAoB;IACnC,yBAAyB;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,mBAAmB,EAAE,CAAA;IAC9B,kIAAkI;IAClI,MAAM,EAAE,UAAU,GAAG,UAAU,CAAA;IAC/B,QAAQ,CAAC,EAAE;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACtD;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,qBAAqB,CAAA;IAChC,uEAAuE;IACvE,KAAK,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACzF;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACpE,4FAA4F;IAC5F,SAAS,CAAC,IAAI,OAAO,CAAA;CACtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,IAC7B,SAAS,oBAAoB,KAAG,OAAO,CAAC,cAAc,CAAC,CAQ5F"}
@@ -0,0 +1,70 @@
1
+ import { runRequest, runEffect, buyerIdempotencyKey } from '@fayz-ai/core';
2
+ export { RequestBlockedError } from '@fayz-ai/core';
3
+
4
+ // src/providers/shipping.ts
5
+ function createShippingQuoter(options) {
6
+ return async function quoteShipping(request) {
7
+ const outcome = await runRequest(options.connector, {
8
+ skip: options.connected ? !options.connected() : false,
9
+ call: (signal) => options.quote(request, signal),
10
+ fallback: () => options.zones(request)
11
+ });
12
+ return { options: outcome.value, source: outcome.source, degraded: outcome.degraded };
13
+ };
14
+ }
15
+ function createCheckoutStarter(options) {
16
+ const now = options.now ?? (() => /* @__PURE__ */ new Date());
17
+ return async function startCheckout(request) {
18
+ const { amountCents, currency } = await options.recompute(request.orderId);
19
+ const recomputedAt = now().toISOString();
20
+ return runRequest(options.connector, {
21
+ call: async (signal) => {
22
+ const session = await options.open({ ...request, amountCents, currency }, signal);
23
+ if (session.amountCents !== amountCents || session.currency !== currency) {
24
+ throw new Error(
25
+ `gateway opened a session for ${session.amountCents} ${session.currency}, order is ${amountCents} ${currency}`
26
+ );
27
+ }
28
+ return { ...session, amountRecomputedAt: recomputedAt };
29
+ }
30
+ });
31
+ };
32
+ }
33
+ function createPaymentCapturer(options) {
34
+ return async function capturePayment(request) {
35
+ return runEffect(
36
+ options.ledger,
37
+ {
38
+ connectionId: request.connectionId,
39
+ idempotencyKey: buyerIdempotencyKey({
40
+ effect: "capture",
41
+ subject: request.orderId,
42
+ amountCents: request.amountCents
43
+ }),
44
+ direction: "outbound",
45
+ triggerKind: request.triggerKind ?? "webhook",
46
+ stream: "payment"
47
+ },
48
+ (runId) => options.capture(request, runId)
49
+ );
50
+ };
51
+ }
52
+ function createLabelBuyer(options) {
53
+ return async function buyLabel(request) {
54
+ return runEffect(
55
+ options.ledger,
56
+ {
57
+ connectionId: request.connectionId,
58
+ idempotencyKey: buyerIdempotencyKey({ effect: "label", subject: request.orderId }),
59
+ direction: "outbound",
60
+ triggerKind: "manual",
61
+ stream: "shipment"
62
+ },
63
+ (runId) => options.buy(request, runId)
64
+ );
65
+ };
66
+ }
67
+
68
+ export { createCheckoutStarter, createLabelBuyer, createPaymentCapturer, createShippingQuoter };
69
+ //# sourceMappingURL=providers.js.map
70
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/providers/shipping.ts","../src/providers/checkout.ts"],"names":["runRequest"],"mappings":";;;;AA0DO,SAAS,qBAAqB,OAAA,EAAgC;AACnE,EAAA,OAAO,eAAe,cAAc,OAAA,EAAwD;AAC1F,IAAA,MAAM,OAAA,GAAU,MAAM,UAAA,CAAkC,OAAA,CAAQ,SAAA,EAAW;AAAA,MACzE,MAAM,OAAA,CAAQ,SAAA,GAAY,CAAC,OAAA,CAAQ,WAAU,GAAI,KAAA;AAAA,MACjD,MAAM,CAAC,MAAA,KAAW,OAAA,CAAQ,KAAA,CAAM,SAAS,MAAM,CAAA;AAAA,MAC/C,QAAA,EAAU,MAAM,OAAA,CAAQ,KAAA,CAAM,OAAO;AAAA,KACtC,CAAA;AACD,IAAA,OAAO,EAAE,SAAS,OAAA,CAAQ,KAAA,EAAO,QAAQ,OAAA,CAAQ,MAAA,EAAQ,QAAA,EAAU,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AAA,UACR,SAAS,OAAA,CAAQ,OAAA;AAAA,UACjB,aAAa,OAAA,CAAQ;AAAA,SACtB,CAAA;AAAA,QACD,SAAA,EAAW,UAAA;AAAA,QACX,WAAA,EAAa,QAAQ,WAAA,IAAe,SAAA;AAAA,QACpC,MAAA,EAAQ;AAAA,OACV;AAAA,MACA,CAAC,KAAA,KAAU,OAAA,CAAQ,OAAA,CAAQ,SAAS,KAAK;AAAA,KAC3C;AAAA,EACF,CAAA;AACF;AASO,SAAS,iBAAiB,OAAA,EAG9B;AACD,EAAA,OAAO,eAAe,SAAS,OAAA,EAAoD;AACjF,IAAA,OAAO,SAAA;AAAA,MACL,OAAA,CAAQ,MAAA;AAAA,MACR;AAAA,QACE,cAAc,OAAA,CAAQ,YAAA;AAAA,QACtB,cAAA,EAAgB,oBAAoB,EAAE,MAAA,EAAQ,SAAS,OAAA,EAAS,OAAA,CAAQ,SAAS,CAAA;AAAA,QACjF,SAAA,EAAW,UAAA;AAAA,QACX,WAAA,EAAa,QAAA;AAAA,QACb,MAAA,EAAQ;AAAA,OACV;AAAA,MACA,CAAC,KAAA,KAAU,OAAA,CAAQ,GAAA,CAAI,SAAS,KAAK;AAAA,KACvC;AAAA,EACF,CAAA;AACF","file":"providers.js","sourcesContent":["// ---------------------------------------------------------------------------\n// Freight on the request plane — the quote the buyer is waiting for\n// ---------------------------------------------------------------------------\n// FAY-1301 is explicit: quoting freight NEVER blocks the purchase. So the\n// carrier connector declares `onFailure: 'degrade'`, and this is what it\n// degrades TO — the shipping zones already in our own database, which is the\n// answer the store gave before any carrier was connected.\n//\n// Nothing here talks to a carrier. `quote` is the data-plane call (an edge\n// function holding the credential); the storefront never learns a provider's\n// URL, let alone its key — commerce-stack.md §4.\nimport { runRequest } from '@fayz-ai/core'\nimport type { ConnectorDefinition, DegradeReason } from '@fayz-ai/core'\nimport type { ShippingQuoteOption } from '../types'\n\nexport type RequestPlaneConnector = Pick<\n ConnectorDefinition,\n 'id' | 'planes' | 'latencyBudgetMs' | 'onFailure'\n>\n\nexport interface ShippingQuoteRequest {\n /** Eight bare digits. */\n postalCode: string\n /** Decides free-above thresholds; the ORDER is recomputed by shop_place_order regardless. */\n subtotal: number\n}\n\nexport interface QuotedShipping {\n options: ShippingQuoteOption[]\n /** Where the prices came from. A fallback price shown as a carrier price is how a store quotes one number and charges another. */\n source: 'provider' | 'fallback'\n degraded?: { reason: DegradeReason; detail?: string }\n}\n\nexport interface ShippingQuoterOptions {\n connector: RequestPlaneConnector\n /** The data-plane call. Receives the abort signal the budget fires. */\n quote(request: ShippingQuoteRequest, signal: AbortSignal): Promise<ShippingQuoteOption[]>\n /**\n * The configured zones. Must be LOCAL — a fallback that itself calls a network\n * is a second budget nobody declared.\n */\n zones(request: ShippingQuoteRequest): Promise<ShippingQuoteOption[]>\n /** False when there is no live connection: quote from zones without spending the budget. */\n connected?(): boolean\n}\n\n/**\n * A quoter that always answers.\n *\n * An EMPTY provider answer is a provider answer, not a failure: a carrier that\n * does not serve a postcode has told us something, and the storefront already\n * knows what to do with zero options (delivery.store.ts falls back to the\n * store-wide rate). Inventing a merge here would be policy nobody asked for.\n *\n * Writes nothing, on either path. A quote is not a run — see\n * packages/db/migrations/029_connections.sql.\n */\nexport function createShippingQuoter(options: ShippingQuoterOptions) {\n return async function quoteShipping(request: ShippingQuoteRequest): Promise<QuotedShipping> {\n const outcome = await runRequest<ShippingQuoteOption[]>(options.connector, {\n skip: options.connected ? !options.connected() : false,\n call: (signal) => options.quote(request, signal),\n fallback: () => options.zones(request),\n })\n return { options: outcome.value, source: outcome.source, degraded: outcome.degraded }\n }\n}\n","// ---------------------------------------------------------------------------\n// Checkout on the request plane — the gateway the buyer is waiting for\n// ---------------------------------------------------------------------------\n// The mirror image of shipping: freight degrades so the sale continues, payment\n// BLOCKS so an order that did not pay never reads as confirmed. Both are the\n// connector's `onFailure` field rather than a decision re-taken in each screen.\n//\n// TWO THINGS ARE ENFORCED BY SHAPE HERE, not by discipline:\n//\n// 1. The amount is not an argument. `startCheckout` takes an order id and a\n// `recompute` function; the payable total is that function's RETURN value,\n// so a number edited in devtools has nowhere to enter. Both FAY-1300 and\n// FAY-1301 say \"nothing the browser sends is trusted\" — this is the shape\n// that makes it true instead of asserted.\n// 2. The gateway's echo is compared to what we recomputed. A session opened\n// for a different amount than the order is worth is a blocked step, not a\n// warning in a log.\n//\n// The credential is never here: `open` and `capture` are data-plane calls\n// (an edge function). commerce-stack.md §4, twice.\nimport { runRequest, runEffect, buyerIdempotencyKey } from '@fayz-ai/core'\nimport type { EffectLedger, EffectOutcome, RequestOutcome } from '@fayz-ai/core'\nimport { RequestBlockedError } from '@fayz-ai/core'\nimport type { RequestPlaneConnector } from './shipping'\n\n/** What the buyer picked. Open on purpose — a gateway declares what it can do. */\nexport type CheckoutMethod = 'pix' | 'boleto' | 'credit_card' | (string & {})\n\n/**\n * The payable artifacts, one shape per method.\n *\n * TRANSPARENT VS REDIRECT (commerce-stack.md §8.1, open until now): Pix and\n * boleto are transparent because nothing sensitive passes through us — a QR\n * code and a barcode are public strings. CARD IS REDIRECT: taking a card number\n * on our page moves us into PCI-DSS SAQ A-EP, which is architecture (browser\n * tokenisation, scope, an audit) rather than a week of work, and this milestone\n * is the contract, not the compliance programme.\n *\n * The decision is reversible for exactly the reason it is expressed here as an\n * artifact and not as a checkout flow: transparent card becomes\n * `card.tokenizationKey` alongside `card.redirectUrl`, and the storefront that\n * renders whatever came back does not change.\n */\nexport interface CheckoutArtifacts {\n pix?: { qrCode: string; copyPaste: string; expiresAt?: string }\n boleto?: { url: string; barcode?: string; dueDate?: string }\n card?: { redirectUrl: string; installments?: number }\n}\n\nexport type CheckoutSessionStatus = 'pending' | 'authorized' | 'paid' | 'failed' | 'expired'\n\nexport interface CheckoutSession {\n sessionId: string\n method: CheckoutMethod\n status: CheckoutSessionStatus\n /** Minor units. The recomputed one — never a number that arrived from a client. */\n amountCents: number\n currency: string\n artifacts: CheckoutArtifacts\n /** When the total was recomputed server-side for THIS session. The proof, carried with the value. */\n amountRecomputedAt: string\n}\n\nexport interface CheckoutStartRequest {\n orderId: string\n method: CheckoutMethod\n installments?: number\n // Deliberately no `amount`. See the header.\n}\n\nexport interface CheckoutStarterOptions {\n connector: RequestPlaneConnector\n /** Recompute the payable total from the order, server-side. The ONLY source of the amount. */\n recompute(orderId: string): Promise<{ amountCents: number; currency: string }>\n /** The data-plane call that opens the session at the gateway. */\n open(\n input: CheckoutStartRequest & { amountCents: number; currency: string },\n signal: AbortSignal,\n ): Promise<Omit<CheckoutSession, 'amountRecomputedAt'>>\n now?(): Date\n}\n\n/**\n * Open a payment session under the gateway's declared budget.\n *\n * Returns the full {@link RequestOutcome} rather than the bare session so the\n * caller can report `elapsedMs`; `source` is always `'provider'` here, because\n * a `block` connector never degrades — it throws {@link RequestBlockedError},\n * which carries the reason the buyer is shown.\n */\nexport function createCheckoutStarter(options: CheckoutStarterOptions) {\n const now = options.now ?? (() => new Date())\n\n return async function startCheckout(request: CheckoutStartRequest): Promise<RequestOutcome<CheckoutSession>> {\n // Outside the budget on purpose: this is our own database, and charging the\n // gateway's allowance for our own arithmetic would shrink the window the\n // gateway actually gets.\n const { amountCents, currency } = await options.recompute(request.orderId)\n const recomputedAt = now().toISOString()\n\n return runRequest<CheckoutSession>(options.connector, {\n call: async (signal) => {\n const session = await options.open({ ...request, amountCents, currency }, signal)\n if (session.amountCents !== amountCents || session.currency !== currency) {\n // Not a warning. The session that would be shown to the buyer is for a\n // different sum than the order is worth.\n throw new Error(\n `gateway opened a session for ${session.amountCents} ${session.currency}, order is ${amountCents} ${currency}`,\n )\n }\n return { ...session, amountRecomputedAt: recomputedAt }\n },\n })\n }\n}\n\nexport { RequestBlockedError }\n\n// ---------------------------------------------------------------------------\n// Capture — the effect, and the only half of checkout that files a run\n// ---------------------------------------------------------------------------\n\nexport interface CapturePaymentRequest {\n /** The plg_connections row acting. The tenant is resolved from it server-side. */\n connectionId: string\n orderId: string\n amountCents: number\n /** A gateway webhook by default; 'manual' when an operator captures from the panel. */\n triggerKind?: 'webhook' | 'manual'\n}\n\nexport interface CapturePaymentOptions {\n ledger: EffectLedger\n /** The data-plane call that captures at the gateway. Reached at most once per key. */\n capture(request: CapturePaymentRequest, runId: string): Promise<{ status: CheckoutSessionStatus; providerRef?: string }>\n}\n\n/**\n * Capture at most once per (order, amount).\n *\n * The key is the BUYER's — `capture:<order>:<cents>` — and not the gateway's\n * transaction id, because that id only exists after the call that must not\n * happen twice. A re-delivered webhook and a double-clicked button both hash to\n * the same string and the second one never reaches the gateway.\n */\nexport function createPaymentCapturer(options: CapturePaymentOptions) {\n return async function capturePayment(\n request: CapturePaymentRequest,\n ): Promise<EffectOutcome<{ status: CheckoutSessionStatus; providerRef?: string }>> {\n return runEffect(\n options.ledger,\n {\n connectionId: request.connectionId,\n idempotencyKey: buyerIdempotencyKey({\n effect: 'capture',\n subject: request.orderId,\n amountCents: request.amountCents,\n }),\n direction: 'outbound',\n triggerKind: request.triggerKind ?? 'webhook',\n stream: 'payment',\n },\n (runId) => options.capture(request, runId),\n )\n }\n}\n\n/**\n * Buy the shipping label at most once per order.\n *\n * The second effect on the plane, and the reason the ledger lives in\n * `@fayz-ai/core` rather than inside the gateway: a label bought twice is money\n * spent twice, by the same mechanism.\n */\nexport function createLabelBuyer(options: {\n ledger: EffectLedger\n buy(request: { connectionId: string; orderId: string }, runId: string): Promise<{ trackingCode?: string; labelUrl?: string }>\n}) {\n return async function buyLabel(request: { connectionId: string; orderId: string }) {\n return runEffect(\n options.ledger,\n {\n connectionId: request.connectionId,\n idempotencyKey: buyerIdempotencyKey({ effect: 'label', subject: request.orderId }),\n direction: 'outbound',\n triggerKind: 'manual',\n stream: 'shipment',\n },\n (runId) => options.buy(request, runId),\n )\n }\n}\n"]}