@juo/blocks 2.0.0-alpha.1 → 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 (86) hide show
  1. package/dist/{ExtensionRoot-DRpD5EcC.js → ExtensionRoot-CG9dH98z.js} +1 -1
  2. package/dist/{bridge-Mz0CqG6E.js → bridge-Bss7Xq3D.js} +7 -0
  3. package/dist/core.js +1289 -54
  4. package/dist/{css-runtime-B7tZrBIp.js → css-runtime-CjZl0K48.js} +23 -17
  5. package/dist/editor/bridge.d.ts.map +1 -1
  6. package/dist/editor/components.d.ts +11 -0
  7. package/dist/editor/components.d.ts.map +1 -1
  8. package/dist/editor/handler.d.ts.map +1 -1
  9. package/dist/editor.js +37 -10
  10. package/dist/{gridstack-adapter-BGKGC-eO.js → gridstack-adapter-C1Q8gbsH.js} +2 -2
  11. package/dist/languages.d.ts +51 -0
  12. package/dist/languages.d.ts.map +1 -0
  13. package/dist/main.d.ts +1 -0
  14. package/dist/main.d.ts.map +1 -1
  15. package/dist/{morph-CT5hc5Qp.js → morph-LwttdRML.js} +1 -1
  16. package/dist/preact.js +1 -1
  17. package/dist/{project-gridstack-PxN_DIfP.js → project-gridstack-CRZ_7HoT.js} +1 -1
  18. package/dist/react.js +1 -1
  19. package/dist/services/customer/adapter.d.ts +14 -1
  20. package/dist/services/customer/adapter.d.ts.map +1 -1
  21. package/dist/services/customer/adapter.test.d.ts +2 -0
  22. package/dist/services/customer/adapter.test.d.ts.map +1 -0
  23. package/dist/services/customer/customerService.d.ts.map +1 -1
  24. package/dist/services/customer/customerService.test.d.ts +2 -0
  25. package/dist/services/customer/customerService.test.d.ts.map +1 -0
  26. package/dist/services/customer/index.d.ts +2 -2
  27. package/dist/services/customer/index.d.ts.map +1 -1
  28. package/dist/services/customer/types.d.ts +29 -0
  29. package/dist/services/customer/types.d.ts.map +1 -1
  30. package/dist/services/login/adapter.d.ts.map +1 -1
  31. package/dist/services/login/index.d.ts +1 -0
  32. package/dist/services/login/index.d.ts.map +1 -1
  33. package/dist/services/login/loginService.d.ts +1 -0
  34. package/dist/services/login/loginService.d.ts.map +1 -1
  35. package/dist/services/login/loginService.test.d.ts +2 -0
  36. package/dist/services/login/loginService.test.d.ts.map +1 -0
  37. package/dist/services/login/refreshLock.d.ts +28 -0
  38. package/dist/services/login/refreshLock.d.ts.map +1 -0
  39. package/dist/services/login/refreshLock.test.d.ts +2 -0
  40. package/dist/services/login/refreshLock.test.d.ts.map +1 -0
  41. package/dist/services/order/adapter.d.ts +11 -1
  42. package/dist/services/order/adapter.d.ts.map +1 -1
  43. package/dist/services/order/adapter.test.d.ts +2 -0
  44. package/dist/services/order/adapter.test.d.ts.map +1 -0
  45. package/dist/services/order/index.d.ts +2 -2
  46. package/dist/services/order/index.d.ts.map +1 -1
  47. package/dist/services/order/types.d.ts +56 -6
  48. package/dist/services/order/types.d.ts.map +1 -1
  49. package/dist/services/product/adapter.d.ts +42 -0
  50. package/dist/services/product/adapter.d.ts.map +1 -1
  51. package/dist/services/product/index.d.ts +1 -1
  52. package/dist/services/product/index.d.ts.map +1 -1
  53. package/dist/services/settings/types.d.ts +15 -0
  54. package/dist/services/settings/types.d.ts.map +1 -1
  55. package/dist/services/subscription/adapter.d.ts +56 -1
  56. package/dist/services/subscription/adapter.d.ts.map +1 -1
  57. package/dist/services/subscription/index.d.ts +4 -1
  58. package/dist/services/subscription/index.d.ts.map +1 -1
  59. package/dist/services/subscription/instantOrderErrors.d.ts +91 -0
  60. package/dist/services/subscription/instantOrderErrors.d.ts.map +1 -0
  61. package/dist/services/subscription/lineRemoval.d.ts +56 -0
  62. package/dist/services/subscription/lineRemoval.d.ts.map +1 -0
  63. package/dist/services/subscription/lineRemoval.test.d.ts +2 -0
  64. package/dist/services/subscription/lineRemoval.test.d.ts.map +1 -0
  65. package/dist/services/subscription/paymentInstrument.d.ts +119 -0
  66. package/dist/services/subscription/paymentInstrument.d.ts.map +1 -0
  67. package/dist/services/subscription/paymentInstrument.test.d.ts +2 -0
  68. package/dist/services/subscription/paymentInstrument.test.d.ts.map +1 -0
  69. package/dist/services/subscription/store.d.ts.map +1 -1
  70. package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
  71. package/dist/services/subscription/types.d.ts +351 -11
  72. package/dist/services/subscription/types.d.ts.map +1 -1
  73. package/dist/theme-state.d.ts +10 -1
  74. package/dist/theme-state.d.ts.map +1 -1
  75. package/dist/utils/index.d.ts +7 -0
  76. package/dist/utils/index.d.ts.map +1 -1
  77. package/dist/vue/context.d.ts +25 -1
  78. package/dist/vue/context.d.ts.map +1 -1
  79. package/dist/vue/useTranslatedProp.test.d.ts +2 -0
  80. package/dist/vue/useTranslatedProp.test.d.ts.map +1 -0
  81. package/dist/vue.js +37 -3
  82. package/dist/web-components/editor/InlineText.d.ts +1 -0
  83. package/dist/web-components/editor/InlineText.d.ts.map +1 -1
  84. package/dist/web-components-editor.js +15 -7
  85. package/dist/web-components-runtime.js +2 -2
  86. package/package.json +1 -1
@@ -9,6 +9,16 @@ export interface OrderLine {
9
9
  value: string;
10
10
  }>;
11
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";
12
22
  export interface Order {
13
23
  /** Numeric Shopify order id (the trailing segment of the order GID). The block prepends `#` for display. */
14
24
  id: string;
@@ -18,8 +28,27 @@ export interface Order {
18
28
  totalPrice: number | null;
19
29
  /** Raw Shopify financial-status token (e.g. `PAID`, `PARTIALLY_REFUNDED`); the block humanizes it for display. `null` = unknown. */
20
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;
21
44
  /** Raw Shopify fulfillment-status token (e.g. `FULFILLED`, `PARTIALLY_FULFILLED`); the block humanizes it for display. `null` = unknown. */
22
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[];
23
52
  lines: OrderLine[];
24
53
  customAttributes?: Array<{
25
54
  key: string;
@@ -31,17 +60,26 @@ export interface GetOrdersParams {
31
60
  after?: string;
32
61
  before?: string;
33
62
  /**
34
- * DEPRECATED: previously used for free-text / per-subscriptionId server-side
35
- * search. The backend proxy implementation ignores this parameter; accepted
36
- * for SDK backward compatibility only. Use `includeOneTime` to control
37
- * which order types are returned.
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`.
38
68
  *
39
- * @deprecated
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.
40
74
  */
41
75
  query?: string;
42
76
  /**
77
+ * Include the customer's one-time orders alongside their subscription orders.
43
78
  * When `false` (default), only subscription-driven orders are returned.
44
- * When `true`, one-time orders are included alongside subscription orders.
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.
45
83
  */
46
84
  includeOneTime?: boolean;
47
85
  /**
@@ -49,6 +87,18 @@ export interface GetOrdersParams {
49
87
  * date (newest first). When omitted, the endpoint's default sort is used.
50
88
  */
51
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;
52
102
  }
53
103
  /** Adapter consumed by `createOrderService`. Hosts (customer portal, theme, storybook) implement this. */
54
104
  export interface OrderAdapter {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/order/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,gBAAgB,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,KAAK;IACpB,4GAA4G;IAC5G,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,Q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;;;;;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,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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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AO,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,6 +1,7 @@
1
1
  import { ApiFetcher, PaginatedList, Result } from '../../utils';
2
- import { Subscription, SellingPlan, SellingPlanInterval, SearchOptions, PostableSubscriptionItem, UpdateSubscriptionItem, UpdateBoxItem, LastOrder, RenewNowResult, UpsellProduct } 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
+ import { InstantOrderProductsError, PlaceInstantOrderError } from './instantOrderErrors';
4
5
  import { ProductAdapter } from '../product/adapter';
5
6
  /**
6
7
  * Adapter interface for subscription.
@@ -76,6 +77,45 @@ export interface SubscriptionAdapter {
76
77
  subscriptionId: string;
77
78
  customAttributes: Record<string, string>;
78
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>>;
79
119
  resume(params: {
80
120
  subscriptionId: string;
81
121
  }): Promise<Result<Subscription>>;
@@ -111,6 +151,14 @@ export interface SubscriptionAdapter {
111
151
  quantity: number;
112
152
  oneTime?: boolean;
113
153
  }): Promise<Result>;
154
+ getInstantOrderProducts?(params: {
155
+ subscriptionId: string;
156
+ } & InstantOrderProductsQuery): Promise<Result<InstantOrderProducts, InstantOrderProductsError>>;
157
+ placeInstantOrder?(params: {
158
+ subscriptionId: string;
159
+ requestKey: string;
160
+ items: PostableSubscriptionItem[];
161
+ } & PlaceInstantOrderOptions): Promise<Result<InstantOrderPlacement, PlaceInstantOrderError>>;
114
162
  }
115
163
  export interface MockSubscriptionAdapterOptions {
116
164
  addDiscountBehavior?: {
@@ -137,6 +185,13 @@ export interface MockSubscriptionAdapterOptions {
137
185
  */
138
186
  productAdapter?: Pick<ProductAdapter, "getByVariantId" | "getById">;
139
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;
140
195
  export declare function createMockSubscriptionAdapter(options?: MockSubscriptionAdapterOptions): SubscriptionAdapter;
141
196
  export declare function createApiSubscriptionAdapter(fetcher: ApiFetcher): SubscriptionAdapter;
142
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,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,SAAS,EACT,cAAc,EACd,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAE5C,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;IAE1D,YAAY,CAAC,MAAM,EAAE;QACnB,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC;IAEtC,O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wB,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,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAE5C,OAAO,CAAC,EAAE,EAAE,M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Ac,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,6 +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';
8
+ export * from './instantOrderErrors';
6
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"}
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"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Typed failures for the instant-order calls, in the same shape as
3
+ * {@link ./discountErrors.ts}: a `kind`-discriminated union, with `NETWORK` and
4
+ * `UNKNOWN` as the catch-alls carrying an optional human `message`.
5
+ *
6
+ * The granularity here is exactly what the wire can support. The endpoint
7
+ * refuses with a plain HTTP status and a human `message` — it does not send a
8
+ * machine-readable code — so hosts discriminate on status. The backend's own
9
+ * refusal codes collapse accordingly: `invalid_items` and
10
+ * `shipping_method_unavailable` both arrive as 400, and `disabled`,
11
+ * `product_not_allowed` and `subscription_ineligible` all as 403. Telling those
12
+ * apart would need the backend to send a code first, the way discounts send
13
+ * `DISCOUNT_CODE_REJECTED`.
14
+ *
15
+ * `outstanding_balance` is the exception, and it is why granularity matters
16
+ * here: it gets its own status (402) precisely so a host can tell the customer
17
+ * to settle up rather than showing them the "not available" copy every other
18
+ * 403 earns. Any future refusal a customer can act on should do the same.
19
+ */
20
+ /**
21
+ * Reading the instant-order catalog. An adapter that does not implement instant
22
+ * orders is deliberately **not** an error: it resolves to an unavailable,
23
+ * empty catalog, which is precisely the signal a consumer needs to hide the
24
+ * entry point.
25
+ */
26
+ export type InstantOrderProductsError = {
27
+ kind: "SUBSCRIPTION_NOT_FOUND";
28
+ } | {
29
+ kind: "NETWORK";
30
+ message?: string;
31
+ } | {
32
+ kind: "UNKNOWN";
33
+ message?: string;
34
+ };
35
+ export type PlaceInstantOrderError =
36
+ /** The host adapter does not implement instant orders at all. */
37
+ {
38
+ kind: "UNSUPPORTED";
39
+ }
40
+ /** 409 — the request key is well-formed but belongs to another purchase. */
41
+ | {
42
+ kind: "DUPLICATE_REQUEST";
43
+ message?: string;
44
+ }
45
+ /** 429 — the subscription hit its hourly or daily instant-order cap. */
46
+ | {
47
+ kind: "RATE_LIMITED";
48
+ message?: string;
49
+ }
50
+ /** 400 — malformed items, or a shipping method the shop does not offer. */
51
+ | {
52
+ kind: "INVALID_REQUEST";
53
+ message?: string;
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
+ }
66
+ /**
67
+ * 402 — the customer has an unpaid or overdue order on their account. Split
68
+ * out of `REFUSED` because it is the only refusal the customer can act on:
69
+ * settle the outstanding order and the purchase becomes available again.
70
+ */
71
+ | {
72
+ kind: "OUTSTANDING_BALANCE";
73
+ message?: string;
74
+ }
75
+ /**
76
+ * 403 — the shop has the feature off, the product is not on the allowlist, or
77
+ * the subscription cannot carry an instant order.
78
+ */
79
+ | {
80
+ kind: "REFUSED";
81
+ message?: string;
82
+ } | {
83
+ kind: "SUBSCRIPTION_NOT_FOUND";
84
+ } | {
85
+ kind: "NETWORK";
86
+ message?: string;
87
+ } | {
88
+ kind: "UNKNOWN";
89
+ message?: string;
90
+ };
91
+ //# sourceMappingURL=instantOrderErrors.d.ts.map
@@ -0,0 +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,MAAM,sBAAsB;AAChC,iEAAiE;AAC/D;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE;AACzB,4EAA4E;GAC1E;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":""}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Payment-instrument model + display helpers.
3
+ *
4
+ * ## Why a union, and why underscore tags
5
+ *
6
+ * The backend exposes payment instruments in two shapes:
7
+ *
8
+ * - the **legacy** subscription endpoints (`/customer/subscriptions`, and its
9
+ * list form) via `processInstrument` — underscore tags (`credit_card`), and
10
+ * the only shape carrying `active` / `isRecurring` / `provider` and the BLIK
11
+ * `label`. This is the authoritative source.
12
+ * - the **v1** `?expand=paymentMethod` shape via `serializePaymentMethod` —
13
+ * hyphen tags (`credit-card`), adds `cardholderName` / shop-pay expiry /
14
+ * `lastDigits`, but cannot express `active`, `isRecurring`, `provider`, or
15
+ * the BLIK `label` at all. Adapters normalise it into this union and treat
16
+ * the missing fields as unknown.
17
+ *
18
+ * Underscore is the canonical tag here because the shared icon map
19
+ * (`paymentMethodIcons` in `@juo/customer-ui`) is keyed that way.
20
+ */
21
+ /** Instrument types, in the canonical underscore form. */
22
+ export declare const PAYMENT_INSTRUMENT_TYPES: readonly ["credit_card", "paypal", "shop_pay", "sepa_direct_debit", "blik", "mbway", "bacs", "manual"];
23
+ export type PaymentInstrumentType = (typeof PAYMENT_INSTRUMENT_TYPES)[number];
24
+ /**
25
+ * A payment instrument. Fields are required only where BOTH backend shapes
26
+ * guarantee them; anything either source may omit is optional.
27
+ */
28
+ export type SubscriptionPaymentInstrument = {
29
+ type: "credit_card";
30
+ brand: string;
31
+ maskedNumber: string;
32
+ expiryMonth?: number;
33
+ expiryYear?: number;
34
+ /** v1 only — the legacy shape drops the cardholder name. */
35
+ cardholderName?: string;
36
+ } | {
37
+ type: "paypal";
38
+ paypalAccountEmail?: string | null;
39
+ } | {
40
+ type: "shop_pay";
41
+ maskedNumber: string;
42
+ /** v1 only. */
43
+ expiryMonth?: number;
44
+ /** v1 only. */
45
+ expiryYear?: number;
46
+ /** v1 only. */
47
+ cardholderName?: string;
48
+ } | {
49
+ type: "sepa_direct_debit";
50
+ /** Account holder. Optional: the legacy contract does not guarantee it. */
51
+ consumerName?: string;
52
+ consumerBic?: string | null;
53
+ /** Masked IBAN. v1 calls this `maskedConsumerAccount` on the wire. */
54
+ consumerAccount: string;
55
+ } | {
56
+ type: "blik";
57
+ /**
58
+ * Alias label. Legacy only — omitted for an inactive alias, and the v1
59
+ * shape never carries it.
60
+ */
61
+ label?: string;
62
+ } | {
63
+ type: "mbway";
64
+ phone?: string;
65
+ } | {
66
+ type: "bacs";
67
+ maskedNumber: string;
68
+ }
69
+ /**
70
+ * No vaulted instrument: the customer pays each renewal through Shopify
71
+ * Checkout. Carries no identifying data, so it renders name-only.
72
+ */
73
+ | {
74
+ type: "manual";
75
+ };
76
+ /**
77
+ * Human-readable instrument name: the card brand for cards (which is the
78
+ * meaningful identifier there), the scheme name otherwise.
79
+ */
80
+ export declare function getPaymentInstrumentName(instrument: SubscriptionPaymentInstrument): string;
81
+ /**
82
+ * Last four identifying digits, for instruments that have a number to mask.
83
+ * `null` when the instrument is not identified by digits (PayPal, BLIK, MB WAY)
84
+ * — use `getPaymentInstrumentDetail` for those.
85
+ */
86
+ export declare function getPaymentInstrumentDigits(instrument: SubscriptionPaymentInstrument): string | null;
87
+ /**
88
+ * Secondary identifying detail, for instruments where digits are not the
89
+ * identifier: the PayPal account, the SEPA account holder, the BLIK alias
90
+ * label, the MB WAY phone. `null` when there is nothing extra to show.
91
+ */
92
+ export declare function getPaymentInstrumentDetail(instrument: SubscriptionPaymentInstrument): string | null;
93
+ export interface PaymentInstrumentExpiry {
94
+ month: number;
95
+ year: number;
96
+ /** True once the expiry month has fully passed. */
97
+ isExpired: boolean;
98
+ /** True during the expiry month itself — the last chance to update. */
99
+ expiresThisMonth: boolean;
100
+ }
101
+ /**
102
+ * Card expiry, for "your card is expiring" prompts. `null` when the instrument
103
+ * has no expiry or the source did not supply one (the legacy shape omits
104
+ * shop-pay expiry, so absence is not proof the card has none).
105
+ *
106
+ * A card is valid through the END of its expiry month, which is why this
107
+ * compares month boundaries rather than exact dates.
108
+ */
109
+ export declare function getPaymentInstrumentExpiry(instrument: SubscriptionPaymentInstrument, now?: Date): PaymentInstrumentExpiry | null;
110
+ /**
111
+ * Maps a v1 payment-instrument wire shape (hyphen tags, `maskedConsumerAccount`)
112
+ * to the canonical `SubscriptionPaymentInstrument` union.
113
+ *
114
+ * Input is `unknown` because blocks/core must not depend on SDK types; the
115
+ * function narrows internally by tag. Returns `null` for unrecognised or
116
+ * absent instruments.
117
+ */
118
+ export declare function serializeV1PaymentInstrument(raw: unknown): SubscriptionPaymentInstrument | null;
119
+ //# sourceMappingURL=paymentInstrument.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paymentInstrument.d.ts","sourceRoot":"","sources":["../../../src/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AI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAcvB;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,6BAA6B,GACxC,MAAM,CAQR;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,6BAA6B,GACxC,MAAM,GAAG,IAAI,CAWf;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,6BAA6B,GACxC,MAAM,GAAG,IAAI,CAaf;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,6BAA6B,EACzC,GAAG,GAAE,IAAiB,GACrB,uBAAuB,GAAG,IAAI,CAahC;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,OAAO,GACX,6BAA6B,GAAG,IAAI,CA0CtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=paymentInstrument.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paymentInstrument.test.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/paymentInstrument.test.ts"],"names":[],"mappings":""}