@juo/blocks 1.20.0 → 2.0.0-alpha.10

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 (152) hide show
  1. package/dist/{ExtensionRoot-DfpvN94s.js → ExtensionRoot-CG9dH98z.js} +24 -6
  2. package/dist/block-BjJztStr.js +993 -0
  3. package/dist/{block-dVP4Rqgz.js → block-DnhzyZ1H.js} +29 -3
  4. package/dist/block.d.ts +56 -0
  5. package/dist/block.d.ts.map +1 -1
  6. package/dist/{bridge-4Eq-G73Z.js → bridge-Bss7Xq3D.js} +39 -31
  7. package/dist/core.js +1620 -333
  8. package/dist/css-runtime-CjZl0K48.js +755 -0
  9. package/dist/devtools/hook.d.ts +0 -5
  10. package/dist/devtools/hook.d.ts.map +1 -1
  11. package/dist/devtools/index.d.ts +0 -1
  12. package/dist/devtools/index.d.ts.map +1 -1
  13. package/dist/devtools/protocol.d.ts +15 -1
  14. package/dist/devtools/protocol.d.ts.map +1 -1
  15. package/dist/devtools.js +42 -9
  16. package/dist/editor/bridge.d.ts +7 -7
  17. package/dist/editor/bridge.d.ts.map +1 -1
  18. package/dist/editor/components.d.ts.map +1 -1
  19. package/dist/editor/main.d.ts +2 -1
  20. package/dist/editor/main.d.ts.map +1 -1
  21. package/dist/editor/messages.d.ts +13 -2
  22. package/dist/editor/messages.d.ts.map +1 -1
  23. package/dist/editor/overlays.d.ts +14 -0
  24. package/dist/editor/overlays.d.ts.map +1 -0
  25. package/dist/editor/overlays.test.d.ts +2 -0
  26. package/dist/editor/overlays.test.d.ts.map +1 -0
  27. package/dist/editor.js +47 -33
  28. package/dist/{gridstack-adapter-BZWybRw1.js → gridstack-adapter-C1Q8gbsH.js} +2 -2
  29. package/dist/main.d.ts +3 -1
  30. package/dist/main.d.ts.map +1 -1
  31. package/dist/{morph-DHn3ol8M.js → morph-LwttdRML.js} +1 -1
  32. package/dist/overlay-wrapper.d.ts +69 -0
  33. package/dist/overlay-wrapper.d.ts.map +1 -0
  34. package/dist/overlay-wrapper.test.d.ts +2 -0
  35. package/dist/overlay-wrapper.test.d.ts.map +1 -0
  36. package/dist/overlays/OverlayService.d.ts +34 -0
  37. package/dist/overlays/OverlayService.d.ts.map +1 -0
  38. package/dist/overlays/OverlayService.test.d.ts +2 -0
  39. package/dist/overlays/OverlayService.test.d.ts.map +1 -0
  40. package/dist/preact/block.d.ts.map +1 -1
  41. package/dist/preact/context.d.ts.map +1 -1
  42. package/dist/preact/context.test.d.ts +2 -0
  43. package/dist/preact/context.test.d.ts.map +1 -0
  44. package/dist/preact/signals.d.ts +19 -0
  45. package/dist/preact/signals.d.ts.map +1 -1
  46. package/dist/preact/useContextSubscription.test.d.ts +2 -0
  47. package/dist/preact/useContextSubscription.test.d.ts.map +1 -0
  48. package/dist/preact.js +33 -7
  49. package/dist/{project-gridstack-C2cSYRMx.js → project-gridstack-CRZ_7HoT.js} +1 -1
  50. package/dist/react/block.d.ts.map +1 -1
  51. package/dist/react/context.d.ts.map +1 -1
  52. package/dist/react/context.test.d.ts +2 -0
  53. package/dist/react/context.test.d.ts.map +1 -0
  54. package/dist/react/signals.d.ts +19 -0
  55. package/dist/react/signals.d.ts.map +1 -1
  56. package/dist/react/useContextSubscription.test.d.ts +2 -0
  57. package/dist/react/useContextSubscription.test.d.ts.map +1 -0
  58. package/dist/react.js +40 -8
  59. package/dist/services/customer/adapter.d.ts +14 -1
  60. package/dist/services/customer/adapter.d.ts.map +1 -1
  61. package/dist/services/customer/adapter.test.d.ts +2 -0
  62. package/dist/services/customer/adapter.test.d.ts.map +1 -0
  63. package/dist/services/customer/customerService.d.ts.map +1 -1
  64. package/dist/services/customer/customerService.test.d.ts +2 -0
  65. package/dist/services/customer/customerService.test.d.ts.map +1 -0
  66. package/dist/services/customer/index.d.ts +2 -2
  67. package/dist/services/customer/index.d.ts.map +1 -1
  68. package/dist/services/customer/types.d.ts +29 -0
  69. package/dist/services/customer/types.d.ts.map +1 -1
  70. package/dist/services/index.d.ts +1 -1
  71. package/dist/services/index.d.ts.map +1 -1
  72. package/dist/services/login/adapter.d.ts +0 -10
  73. package/dist/services/login/adapter.d.ts.map +1 -1
  74. package/dist/services/login/index.d.ts +3 -3
  75. package/dist/services/login/index.d.ts.map +1 -1
  76. package/dist/services/login/loginService.d.ts +13 -1
  77. package/dist/services/login/loginService.d.ts.map +1 -1
  78. package/dist/services/login/refreshLock.d.ts +28 -0
  79. package/dist/services/login/refreshLock.d.ts.map +1 -0
  80. package/dist/services/login/refreshLock.test.d.ts +2 -0
  81. package/dist/services/login/refreshLock.test.d.ts.map +1 -0
  82. package/dist/services/order/adapter.d.ts +17 -6
  83. package/dist/services/order/adapter.d.ts.map +1 -1
  84. package/dist/services/order/adapter.test.d.ts +2 -0
  85. package/dist/services/order/adapter.test.d.ts.map +1 -0
  86. package/dist/services/order/index.d.ts +3 -4
  87. package/dist/services/order/index.d.ts.map +1 -1
  88. package/dist/services/order/orderService.d.ts +2 -3
  89. package/dist/services/order/orderService.d.ts.map +1 -1
  90. package/dist/services/order/orderService.test.d.ts +2 -0
  91. package/dist/services/order/orderService.test.d.ts.map +1 -0
  92. package/dist/services/order/types.d.ts +103 -14
  93. package/dist/services/order/types.d.ts.map +1 -1
  94. package/dist/services/product/adapter.d.ts +42 -0
  95. package/dist/services/product/adapter.d.ts.map +1 -1
  96. package/dist/services/product/index.d.ts +1 -1
  97. package/dist/services/product/index.d.ts.map +1 -1
  98. package/dist/services/settings/types.d.ts +15 -0
  99. package/dist/services/settings/types.d.ts.map +1 -1
  100. package/dist/services/subscription/adapter.d.ts +48 -7
  101. package/dist/services/subscription/adapter.d.ts.map +1 -1
  102. package/dist/services/subscription/index.d.ts +3 -1
  103. package/dist/services/subscription/index.d.ts.map +1 -1
  104. package/dist/services/subscription/instantOrderErrors.d.ts +11 -0
  105. package/dist/services/subscription/instantOrderErrors.d.ts.map +1 -1
  106. package/dist/services/subscription/lineRemoval.d.ts +56 -0
  107. package/dist/services/subscription/lineRemoval.d.ts.map +1 -0
  108. package/dist/services/subscription/lineRemoval.test.d.ts +2 -0
  109. package/dist/services/subscription/lineRemoval.test.d.ts.map +1 -0
  110. package/dist/services/subscription/paymentInstrument.d.ts +119 -0
  111. package/dist/services/subscription/paymentInstrument.d.ts.map +1 -0
  112. package/dist/services/subscription/paymentInstrument.test.d.ts +2 -0
  113. package/dist/services/subscription/paymentInstrument.test.d.ts.map +1 -0
  114. package/dist/services/subscription/store.d.ts.map +1 -1
  115. package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
  116. package/dist/services/subscription/types.d.ts +265 -34
  117. package/dist/services/subscription/types.d.ts.map +1 -1
  118. package/dist/shared/context.d.ts +10 -3
  119. package/dist/shared/context.d.ts.map +1 -1
  120. package/dist/shared/touchSignals.d.ts +17 -0
  121. package/dist/shared/touchSignals.d.ts.map +1 -0
  122. package/dist/shared/touchSignals.test.d.ts +2 -0
  123. package/dist/shared/touchSignals.test.d.ts.map +1 -0
  124. package/dist/theme-state.d.ts +2 -1
  125. package/dist/theme-state.d.ts.map +1 -1
  126. package/dist/theme-state.params.test.d.ts +2 -0
  127. package/dist/theme-state.params.test.d.ts.map +1 -0
  128. package/dist/theme-state.translations.test.d.ts +2 -0
  129. package/dist/theme-state.translations.test.d.ts.map +1 -0
  130. package/dist/vue/block.d.ts.map +1 -1
  131. package/dist/vue.js +16 -13
  132. package/dist/web-components/ExtensionRoot.d.ts +1 -0
  133. package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
  134. package/dist/web-components-editor.js +6 -5
  135. package/dist/web-components-runtime.js +3 -2
  136. package/package.json +1 -1
  137. package/dist/css-runtime-DTiXcYSs.js +0 -1576
  138. package/dist/devtools/instrumentation.d.ts +0 -47
  139. package/dist/devtools/instrumentation.d.ts.map +0 -1
  140. package/dist/index-JSv6UH_o.js +0 -169
  141. package/dist/services/login/errors.d.ts +0 -21
  142. package/dist/services/login/errors.d.ts.map +0 -1
  143. package/dist/services/orders/adapter.d.ts +0 -10
  144. package/dist/services/orders/adapter.d.ts.map +0 -1
  145. package/dist/services/orders/index.d.ts +0 -4
  146. package/dist/services/orders/index.d.ts.map +0 -1
  147. package/dist/services/orders/ordersService.d.ts +0 -6
  148. package/dist/services/orders/ordersService.d.ts.map +0 -1
  149. package/dist/services/orders/ordersService.test.d.ts +0 -2
  150. package/dist/services/orders/ordersService.test.d.ts.map +0 -1
  151. package/dist/services/orders/types.d.ts +0 -60
  152. package/dist/services/orders/types.d.ts.map +0 -1
@@ -1,9 +1,20 @@
1
- import { Order } from './types';
2
- import { ApiFetcher, Result } from '../../utils';
3
- export interface OrderAdapter {
4
- getHistory(): Promise<Result<Order[]>>;
5
- getById(id: string): Promise<Result<Order | null>>;
6
- }
1
+ import { ApiFetcher } from '../../utils';
2
+ import { OrderAdapter, GetOrdersParams } from './types';
3
+ /**
4
+ * Returns a mock `OrderAdapter` with sample orders including customAttributes.
5
+ * Hosts can override the methods to seed real fixtures.
6
+ * Used as a starting point by storybook helpers (`createMockOrderService`) and theme preview.
7
+ */
7
8
  export declare function createMockOrderAdapter(): OrderAdapter;
9
+ /**
10
+ * Fold the typed options into the one `query` string the endpoint takes.
11
+ *
12
+ * `subscriptionId` is ANDed onto whatever the caller already wrote, with the
13
+ * caller's own query parenthesized so their `OR` cannot swallow the added term.
14
+ * `includeOneTime` keeps using its own parameter: the endpoint still accepts it
15
+ * (deprecated) and rejects it alongside any filter, so folding it into the
16
+ * string here would only turn a clear server-side error into a confusing one.
17
+ */
18
+ export declare function buildOrdersQuery(params?: GetOrdersParams): string | null;
8
19
  export declare function createApiOrderAdapter(fetcher: ApiFetcher): OrderAdapter;
9
20
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/order/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;CACpD;AA+BD,wBAAgB,sBAAsB,IAAI,YAAY,CAiCrD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY,CA2BvE"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/order/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAGV,YAAY,EAEZ,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAmErD;AA2ED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAWxE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY,CA6BvE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.test.d.ts","sourceRoot":"","sources":["../../../src/services/order/adapter.test.ts"],"names":[],"mappings":""}
@@ -1,5 +1,4 @@
1
- export type { OrderAdapter } from './adapter';
2
- export { createMockOrderAdapter, createApiOrderAdapter } from './adapter';
3
- export { createOrderService, OrderServiceContext } from './orderService';
4
- export * from './types';
1
+ export type { GetOrdersParams, Order, OrderLine, OrderAdapter, OrderPaymentStatus, OrderService, } from './types';
2
+ export { buildOrdersQuery, createMockOrderAdapter, createApiOrderAdapter, } from './adapter';
3
+ export { createOrderService, OrderServiceContext, } from './orderService';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/order/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACzE,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/order/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,KAAK,EACL,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC"}
@@ -1,7 +1,6 @@
1
- import { OrderAdapter } from './adapter';
2
- import { OrderService } from './types';
1
+ import { OrderAdapter, OrderService } from './types';
2
+ export declare function createOrderService(adapter: OrderAdapter): OrderService;
3
3
  export declare const OrderServiceContext: {
4
4
  __context__: OrderService;
5
5
  };
6
- export declare function createOrderService(adapter: OrderAdapter): OrderService;
7
6
  //# sourceMappingURL=orderService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"orderService.d.ts","sourceRoot":"","sources":["../../../src/services/order/orderService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,mBAAmB;;CAAgD,CAAC;AAEjF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAKtE"}
1
+ {"version":3,"file":"orderService.d.ts","sourceRoot":"","sources":["../../../src/services/order/orderService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAWtE;AAED,eAAO,MAAM,mBAAmB;;CACe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=orderService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderService.test.d.ts","sourceRoot":"","sources":["../../../src/services/order/orderService.test.ts"],"names":[],"mappings":""}
@@ -1,21 +1,110 @@
1
- import { Result } from '../../utils';
2
- export interface OrderItem {
1
+ import { Image, PaginatedList, Result } from '../../utils';
2
+ export interface OrderLine {
3
3
  id: string;
4
- productId: string;
5
- variantId: string;
4
+ title: string;
6
5
  quantity: number;
7
- metadata?: Record<string, unknown>;
6
+ variantImage: Image | null;
7
+ customAttributes?: Array<{
8
+ key: string;
9
+ value: string;
10
+ }>;
8
11
  }
12
+ /**
13
+ * Whether the order's money landed, normalized across payment rails.
14
+ *
15
+ * Distinct from `financialStatus`, which is Shopify's own display token and
16
+ * exists to be shown to a customer: it cannot express a chargeback, and reads
17
+ * `PENDING` for both an invoice still being collected and one Juo has given up
18
+ * collecting. Use this one for logic ("may this be paid?", "did this money come
19
+ * back?") and `financialStatus` for display.
20
+ */
21
+ export type OrderPaymentStatus = "paid" | "unpaid" | "overdue" | "refund" | "chargeback";
9
22
  export interface Order {
23
+ /** Numeric Shopify order id (the trailing segment of the order GID). The block prepends `#` for display. */
10
24
  id: string;
11
- customerId: string;
12
- items: OrderItem[];
13
- deliveryDate: string | null;
14
- status: "pending" | "confirmed" | "delivered" | "skipped";
15
- metadata?: Record<string, unknown>;
25
+ createdAt: string;
26
+ placedAt: string | null;
27
+ currencyCode: string;
28
+ totalPrice: number | null;
29
+ /** Raw Shopify financial-status token (e.g. `PAID`, `PARTIALLY_REFUNDED`); the block humanizes it for display. `null` = unknown. */
30
+ financialStatus: string | null;
31
+ /** Normalized payment status, for logic rather than display — see `OrderPaymentStatus`. */
32
+ paymentStatus: OrderPaymentStatus;
33
+ /**
34
+ * ISO timestamp of when the order was paid in full, or `null` if it never was.
35
+ * Safe to read by its name: `paidAt != null` means the order is paid. A
36
+ * partially paid, authorized-but-uncaptured, pending or abandoned order
37
+ * reports `null` rather than a partial date.
38
+ *
39
+ * A refunded or partially refunded order keeps its date, because it was paid
40
+ * in full and the money went back afterwards — `financialStatus` is what tells
41
+ * you that happened.
42
+ */
43
+ paidAt: string | null;
44
+ /** Raw Shopify fulfillment-status token (e.g. `FULFILLED`, `PARTIALLY_FULFILLED`); the block humanizes it for display. `null` = unknown. */
45
+ fulfillmentStatus: string | null;
46
+ /**
47
+ * Ids of the subscriptions this order belongs to, in the same id space as
48
+ * `Subscription.id` — so a block can link an order to a subscription it
49
+ * already holds without a second lookup. Empty for a one-time order.
50
+ */
51
+ subscriptionIds: string[];
52
+ lines: OrderLine[];
53
+ customAttributes?: Array<{
54
+ key: string;
55
+ value: string;
56
+ }>;
57
+ }
58
+ export interface GetOrdersParams {
59
+ limit?: number;
60
+ after?: string;
61
+ before?: string;
62
+ /**
63
+ * Search-language filter, the same one every public Juo list endpoint takes:
64
+ * `field:value` terms combined with `AND` / `OR` / `NOT` and parentheses, e.g.
65
+ * `type:recurring AND placedAt:>'2026-01-01'`. Values that are not
66
+ * alphanumeric must be quoted. Filterable fields are `id`, `type`,
67
+ * `subscriptionId`, `placedAt`, `createdAt` and `includeOneTime`.
68
+ *
69
+ * Free-text terms are rejected — orders have no search index behind them.
70
+ * Changing the query restarts pagination.
71
+ *
72
+ * Prefer the typed `subscriptionId` and `includeOneTime` options below for
73
+ * those two cases; they are translated into this string for you.
74
+ */
75
+ query?: string;
76
+ /**
77
+ * Include the customer's one-time orders alongside their subscription orders.
78
+ * When `false` (default), only subscription-driven orders are returned.
79
+ *
80
+ * This widens which orders are read rather than filtering them, so it cannot
81
+ * be combined with any filter — including `subscriptionId`, and any term in
82
+ * `query`. Toggling it restarts pagination.
83
+ */
84
+ includeOneTime?: boolean;
85
+ /**
86
+ * Sort order. When set to `"placedAt"`, orders are sorted by placement
87
+ * date (newest first). When omitted, the endpoint's default sort is used.
88
+ */
89
+ sort?: "placedAt";
90
+ /**
91
+ * Return only the orders belonging to this subscription (a `Subscription.id`,
92
+ * the same id `Order.subscriptionIds` carries). Filtered server-side, so
93
+ * pagination stays correct — unlike narrowing a page client-side on
94
+ * `Order.subscriptionIds`.
95
+ *
96
+ * Shorthand for a `subscriptionId:'<id>'` term in `query`, quoted and escaped
97
+ * for you; it is ANDed onto any `query` you also pass. Cannot be combined with
98
+ * `includeOneTime: true`, since a one-time order belongs to no subscription.
99
+ * Changing it restarts pagination.
100
+ */
101
+ subscriptionId?: string;
102
+ }
103
+ /** Adapter consumed by `createOrderService`. Hosts (customer portal, theme, storybook) implement this. */
104
+ export interface OrderAdapter {
105
+ getOrders(params?: GetOrdersParams): Promise<PaginatedList<Order>>;
106
+ }
107
+ export interface OrderService {
108
+ getOrders(params?: GetOrdersParams): Promise<Result<PaginatedList<Order>>>;
16
109
  }
17
- export type OrderService = {
18
- getHistory(): Promise<Result<Order[]>>;
19
- getById(id: string): Promise<Result<Order | null>>;
20
- };
21
110
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/order/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CA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B,oIAAoI;IACpI,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,2FAA2F;IAC3F,aAAa,EAAE,kBAAkB,CAAC;IAClC;;;;;;;;;OASG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,4IAA4I;IAC5I,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC;;;;OAIG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,gBAAgB,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,0GAA0G;AAC1G,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CACP,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAC1C"}
@@ -7,6 +7,36 @@ import { AvailableProduct, Box, Product, WithVariants } from './types';
7
7
  export interface ProductAdapter {
8
8
  getById(id: string): Promise<WithVariants<Product> | null>;
9
9
  getByVariantId(variantId: string): Promise<WithVariants<Product> | null>;
10
+ /**
11
+ * Search products.
12
+ *
13
+ * `query` accepts either plain text (full-text search) or field:value filter
14
+ * syntax parsed by the backend grammar. Detection is automatic:
15
+ *
16
+ * - Plain text (`"coffee beans"`): wrapped in double quotes by the adapter
17
+ * and sent as a full-text search term.
18
+ * - Filter syntax (`"collections.handle:featured"`, `"id:abc OR id:def"`,
19
+ * `"status:active"`): passed through unquoted so the backend parses it
20
+ * into structured filters.
21
+ *
22
+ * Detection is anchored: the *entire* query must be a filter expression —
23
+ * `field:value` terms, optionally negated with `-`/`NOT` and joined by
24
+ * `AND`/`OR`. Plain text that merely contains a colon (`"size:large shoes"`)
25
+ * is treated as text, not as a filter on an unknown `size` field.
26
+ *
27
+ * Values containing anything other than letters, digits and dots must be
28
+ * quoted by the caller — `collections.handle:"summer-sale"`, not
29
+ * `collections.handle:summer-sale`, since the grammar's identifier rule
30
+ * excludes hyphens. An unquoted value falls back to full-text search.
31
+ *
32
+ * A single-token query like `"time:10"` is genuinely ambiguous and is read
33
+ * as a filter. Pass free text through a search box only if that is
34
+ * acceptable.
35
+ *
36
+ * Filterable fields depend on the endpoint. Unknown fields produce a 400
37
+ * `INVALID_QUERY_FIELDS`; malformed syntax produces a 400
38
+ * `INVALID_SEARCH_QUERY`.
39
+ */
10
40
  search(opts?: {
11
41
  query?: string;
12
42
  pagination?: {
@@ -39,6 +69,18 @@ export interface ProductAdapter {
39
69
  }): Promise<Box | null>;
40
70
  }
41
71
  export declare function createMockProductAdapter(): ProductAdapter;
72
+ /**
73
+ * Whether `query` is a complete field:value filter expression rather than
74
+ * plain text.
75
+ *
76
+ * The match is anchored: the *whole* string must be a filter expression.
77
+ * Plain text that merely contains a colon (`"size:large shoes"`) is not a
78
+ * filter query and is sent as full-text search, which is what the caller
79
+ * meant and what the backend can actually parse.
80
+ *
81
+ * Parenthesised groups are not recognised and fall back to full-text search.
82
+ */
83
+ export declare function isFilterQuery(query: string): boolean;
42
84
  export declare function createApiProductAdapter(fetcher: ApiFetcher, opts?: {
43
85
  currencyCode: string;
44
86
  }): ProductAdapter;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/product/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,EAAkB,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5F;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAE3D,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAEzE,MAAM,CAAC,IAAI,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;KACrD,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAElD,gBAAgB,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEhE,cAAc,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAE/F,oBAAoB,CAAC,MAAM,EAAE;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,cAAc,GAAG,gBAAgB,C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a,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAElD,gBAAgB,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEhE,cAAc,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,EAAE,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAE/F,oBAAoB,CAAC,MAAM,EAAE;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC;QACzC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;QACvB,UAAU,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;KACrD,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEhC,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;CACrD;AAED,wBAAgB,wBAAwB,IAAI,cAAc,CAmRzD;AAwDD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAwBD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,UAAU,EACnB,IAAI,GAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAA4B,GACvD,cAAc,CAmKhB"}
@@ -1,5 +1,5 @@
1
1
  export type { ProductAdapter } from './adapter';
2
- export { createMockProductAdapter, createApiProductAdapter } from './adapter';
2
+ export { createMockProductAdapter, createApiProductAdapter, isFilterQuery, } from './adapter';
3
3
  export { createProductService, ProductServiceContext } from './productService';
4
4
  export * from './types';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/product/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAE9E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/product/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,cAAc,SAAS,CAAC"}
@@ -17,6 +17,21 @@ export interface RenewalSummarySettings {
17
17
  cancel?: boolean;
18
18
  changeFrequency?: boolean;
19
19
  changeRenewalDate?: boolean;
20
+ /**
21
+ * Whether an anchored subscription may still change its plan.
22
+ *
23
+ * The one key here that does NOT follow the `undefined` = "default visible"
24
+ * convention above, because it is a capability rather than a visibility flag:
25
+ * an anchor bars changing plan *until the merchant opts in*, so only an
26
+ * explicit `true` unblocks it. That matches the backend, which both defaults
27
+ * the setting to `false` and rejects the change server-side when it is off.
28
+ *
29
+ * Note this is not the same predicate as "the subscription is anchored" — an
30
+ * anchor permanently bars moving the renewal *date* (the anchor is the
31
+ * constraint on which day may bill) but bars a plan change only while this is
32
+ * off, since changing plan is how the governing anchor changes.
33
+ */
34
+ changeAnchoredPlan?: boolean;
20
35
  customDeliveryEnabled?: boolean;
21
36
  customChangePlanMessage?: string;
22
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/settings/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,QAAS,SAAQ,sBAAsB;IAGtD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,GAAG,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CAChE"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/settings/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;;;;;;;OAaG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,QAAS,SAAQ,sBAAsB;IAGtD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1B,GAAG,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CAChE"}
@@ -1,5 +1,5 @@
1
1
  import { ApiFetcher, PaginatedList, Result } from '../../utils';
2
- import { Subscription, SellingPlan, SellingPlanInterval, SearchOptions, PostableSubscriptionItem, UpdateSubscriptionItem, UpdateBoxItem, LastOrder, RenewNowResult, UpsellProduct, InstantOrderProducts, InstantOrderProductsQuery, InstantOrderPlacement } from './types';
2
+ import { Subscription, SellingPlan, SellingPlanInterval, SearchOptions, PostableSubscriptionItem, UpdateSubscriptionItem, UpdateBoxItem, LastOrder, RenewNowResult, UpsellProduct, UpdateDeliveryAddress, UpdateDeliveryAddressError, UpdateDeliveryMethodError, ShippingMethodOption, InstantOrderProducts, InstantOrderProductsQuery, InstantOrderPlacement, PlaceInstantOrderOptions } from './types';
3
3
  import { ApplyDiscountError, DiscountRejectionReason, RemoveDiscountError } from './discountErrors';
4
4
  import { InstantOrderProductsError, PlaceInstantOrderError } from './instantOrderErrors';
5
5
  import { ProductAdapter } from '../product/adapter';
@@ -77,6 +77,45 @@ export interface SubscriptionAdapter {
77
77
  subscriptionId: string;
78
78
  customAttributes: Record<string, string>;
79
79
  }): Promise<Result<Subscription>>;
80
+ /**
81
+ * Replace the subscription's delivery address (full replacement).
82
+ *
83
+ * The real adapter uses the legacy PUT
84
+ * /customer/subscriptions/{id}/shipping-address rather than PATCH
85
+ * /customer/v1/subscriptions/{id} with `deliveryAddress`. Only the legacy
86
+ * route preserves the delivery-method type — the v1 handler hardcodes
87
+ * `shipping`, so it converts a local-delivery contract and puts an address on
88
+ * a pickup one — and only it resolves `province` to a province code, honours
89
+ * the merchant's address-editing setting, and turns Shopify's address
90
+ * validation errors into a readable 400.
91
+ */
92
+ updateDeliveryAddress(params: {
93
+ subscriptionId: string;
94
+ address: UpdateDeliveryAddress;
95
+ }): Promise<Result<void, UpdateDeliveryAddressError>>;
96
+ /**
97
+ * Shipping methods the subscription can move to. The one it is currently on
98
+ * is included and flagged `isActive` — every entry is selectable, so this is
99
+ * not a filter.
100
+ */
101
+ getAvailableShippingMethods(params: {
102
+ subscriptionId: string;
103
+ }): Promise<Result<ShippingMethodOption[]>>;
104
+ /**
105
+ * Switch the subscription to another shipping method.
106
+ *
107
+ * Pickup points are out of scope: no parcel-locker payload is sent, which the
108
+ * endpoint reads as "preserve the existing pickup-point attributes".
109
+ *
110
+ * The handle must be one the subscription currently offers — the endpoint
111
+ * re-derives the list server-side and a stale handle fails the assertion as a
112
+ * 500, not a 4xx, so it surfaces as `UNKNOWN`. Re-read
113
+ * `getAvailableShippingMethods` before retrying.
114
+ */
115
+ updateDeliveryMethod(params: {
116
+ subscriptionId: string;
117
+ shippingMethodHandle: string;
118
+ }): Promise<Result<void, UpdateDeliveryMethodError>>;
80
119
  resume(params: {
81
120
  subscriptionId: string;
82
121
  }): Promise<Result<Subscription>>;
@@ -119,12 +158,7 @@ export interface SubscriptionAdapter {
119
158
  subscriptionId: string;
120
159
  requestKey: string;
121
160
  items: PostableSubscriptionItem[];
122
- paymentMethodId?: string;
123
- }): Promise<Result<InstantOrderPlacement, PlaceInstantOrderError>>;
124
- getInstantOrder?(params: {
125
- subscriptionId: string;
126
- orderId: string;
127
- }): Promise<Result<InstantOrderPlacement, PlaceInstantOrderError>>;
161
+ } & PlaceInstantOrderOptions): Promise<Result<InstantOrderPlacement, PlaceInstantOrderError>>;
128
162
  }
129
163
  export interface MockSubscriptionAdapterOptions {
130
164
  addDiscountBehavior?: {
@@ -151,6 +185,13 @@ export interface MockSubscriptionAdapterOptions {
151
185
  */
152
186
  productAdapter?: Pick<ProductAdapter, "getByVariantId" | "getById">;
153
187
  }
188
+ /**
189
+ * Recognises the optimistic-concurrency rejection the legacy customer
190
+ * subscription routes raise from a scope-wide `preValidation` hook when the
191
+ * caller sends a stale `X-Last-Updated-At`. It answers 400, the same status as
192
+ * a rejected address, so the message is the only discriminator.
193
+ */
194
+ export declare function isStaleSubscriptionMessage(message: string | undefined): boolean;
154
195
  export declare function createMockSubscriptionAdapter(options?: MockSubscriptionAdapterOptions): SubscriptionAdapter;
155
196
  export declare function createApiSubscriptionAdapter(fetcher: ApiFetcher): SubscriptionAdapter;
156
197
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb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C;QACd,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,wBAAwB,CAAC;KACzD,CAAC;IACN,sBAAsB,CAAC,EACnB;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,GACnB;QACE,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EACD,SAAS,GACT,SAAS,GACT,wBAAwB,GACxB,oBAAoB,CAAC;KAC1B,CAAC;IACN;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC;CACrE;AAcD,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,mBAAmB,CA8lBrB;AA6HD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,UAAU,GAClB,mBAAmB,CA2frB"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAS,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EACV,YAAY,EAIZ,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,SAAS,EACT,cAAc,EACd,aAAa,EAEb,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EAEpB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EACV,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,OAAO,CAAC,EAAE,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nB;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,GACnB;QACE,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EACD,SAAS,GACT,SAAS,GACT,wBAAwB,GACxB,oBAAoB,CAAC;KAC1B,CAAC;IACN;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC;CACrE;AAuED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,OAAO,CAIT;AA8BD,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,mBAAmB,CAm8BrB;AAiUD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,UAAU,GAClB,mBAAmB,CAqxBrB"}
@@ -1,7 +1,9 @@
1
1
  export type { SubscriptionAdapter, MockSubscriptionAdapterOptions } from './adapter';
2
- export { createMockSubscriptionAdapter, createApiSubscriptionAdapter } from './adapter';
2
+ export { createMockSubscriptionAdapter, createApiSubscriptionAdapter, isStaleSubscriptionMessage, } from './adapter';
3
3
  export { createSubscriptionService, SubscriptionServiceContext } from './subscriptionService';
4
4
  export * from './types';
5
5
  export * from './discountErrors';
6
+ export * from './paymentInstrument';
7
+ export * from './lineRemoval';
6
8
  export * from './instantOrderErrors';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAExF,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAE9F,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAE9F,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
@@ -52,6 +52,17 @@ export type PlaceInstantOrderError =
52
52
  kind: "INVALID_REQUEST";
53
53
  message?: string;
54
54
  }
55
+ /**
56
+ * Refused before the request was sent: the chosen shipping method's title is
57
+ * shared by more than one available rate, so it cannot say which rate the
58
+ * customer picked. The only failure here with no status behind it — the
59
+ * endpoint identifies a rate by title and would have applied whichever it
60
+ * matched first, at that rate's price. See `PlaceInstantOrderOptions`.
61
+ */
62
+ | {
63
+ kind: "AMBIGUOUS_SHIPPING_METHOD";
64
+ message?: string;
65
+ }
55
66
  /**
56
67
  * 402 — the customer has an unpaid or overdue order on their account. Split
57
68
  * out of `REFUSED` because it is the only refusal the customer can act on:
@@ -1 +1 @@
1
- {"version":3,"file":"instantOrderErrors.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/instantOrderErrors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GACjC;IAAE,IAAI,EAAE,wBAAwB,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,MAAM,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1E;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;AACjD,wEAAwE;GACtE;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;AAC5C,2EAA2E;GACzE;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;AAC/C;;;;;;GAMG;GACD;IAAE,IAAI,EAAE,2BAA2B,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;AACzD;;;;GAIG;GACD;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;AACnD;;;GAGG;GACD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,wBAAwB,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Line-removal rules.
3
+ *
4
+ * A subscription whose every remaining line retires at the next renewal has
5
+ * nothing left to bill, so that renewal expires it. The customer must
6
+ * therefore never be able to remove the last line that actually renews
7
+ * (CS-2195). The "this is your last product" confirmation does not cover this:
8
+ * a subscription can hold several lines of which only one recurs.
9
+ *
10
+ * The rules live here, decoupled from any component, so every removal surface
11
+ * (the Edit Product overlay, the per-line menu in Upcoming Order Items)
12
+ * evaluates them identically and they stay unit tested.
13
+ */
14
+ /**
15
+ * The line shape the rules need.
16
+ *
17
+ * Identity is `subscriptionId` + `subscriptionLineId`, and both must be
18
+ * non-empty for a line to be removable at all: a schedule row generated from a
19
+ * plan rather than from an existing subscription line has no line to address,
20
+ * and those arrive with `null` or `""` rather than being omitted. Callers
21
+ * holding a different shape (e.g. `SubscriptionItem`, where `id` IS the
22
+ * subscription line id) project into this one.
23
+ *
24
+ * `id` is the host's own row id, used only to resolve box parents — a schedule
25
+ * row's `parentLineId` may reference either the parent's line id or its row id.
26
+ */
27
+ export interface RemovableLine {
28
+ subscriptionId?: string | null;
29
+ subscriptionLineId?: string | null;
30
+ id?: string | null;
31
+ productId?: string | null;
32
+ /** Box grouping: parent subscription LINE id (primary). */
33
+ parentLineId?: string | null;
34
+ /** Box grouping: parent PRODUCT id (fallback). */
35
+ parentProductId?: string | null;
36
+ /** Normalized one-time flag, when the host already derived it. */
37
+ isOneTime?: boolean;
38
+ /**
39
+ * Cycles left before the line retires; `1` means this is its last cycle.
40
+ * The blocks name for the wire's `renewalLimit`.
41
+ */
42
+ recurringCycleLimit?: number | null;
43
+ }
44
+ /** The backend has already applied the current cycle to both signals. */
45
+ export declare function isOneTimeLine(line: RemovableLine): boolean;
46
+ /**
47
+ * May the customer remove this line?
48
+ *
49
+ * `lines` may hold lines from other subscriptions (the schedule view
50
+ * aggregates several) — scoping happens here so no caller can forget it. The
51
+ * target must be an identified member of its own subscription's lines. A
52
+ * one-time can then always go; a recurring product can go only while another
53
+ * recurring product bucket remains in the same subscription.
54
+ */
55
+ export declare function canRemoveLine(line: RemovableLine, lines: readonly RemovableLine[]): boolean;
56
+ //# sourceMappingURL=lineRemoval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineRemoval.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/lineRemoval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kDAAkD;IAClD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAE1D;AA8GD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,SAAS,aAAa,EAAE,GAC9B,OAAO,CAiBT"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=lineRemoval.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineRemoval.test.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/lineRemoval.test.ts"],"names":[],"mappings":""}