@juo/blocks 1.15.0 → 1.16.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 (90) hide show
  1. package/dist/{block-VhmfGB3N.js → block-dVP4Rqgz.js} +9 -0
  2. package/dist/core.js +2294 -378
  3. package/dist/preact.js +2 -2
  4. package/dist/react.js +2 -2
  5. package/dist/services/customer/adapter.d.ts +8 -0
  6. package/dist/services/customer/adapter.d.ts.map +1 -0
  7. package/dist/services/customer/customerService.d.ts +3 -2
  8. package/dist/services/customer/customerService.d.ts.map +1 -1
  9. package/dist/services/customer/index.d.ts +1 -0
  10. package/dist/services/customer/index.d.ts.map +1 -1
  11. package/dist/services/customer/types.d.ts +4 -1
  12. package/dist/services/customer/types.d.ts.map +1 -1
  13. package/dist/services/index.d.ts +3 -0
  14. package/dist/services/index.d.ts.map +1 -1
  15. package/dist/services/login/adapter.d.ts +33 -0
  16. package/dist/services/login/adapter.d.ts.map +1 -0
  17. package/dist/services/login/index.d.ts +3 -1
  18. package/dist/services/login/index.d.ts.map +1 -1
  19. package/dist/services/login/loginService.d.ts +6 -2
  20. package/dist/services/login/loginService.d.ts.map +1 -1
  21. package/dist/services/order/adapter.d.ts +9 -0
  22. package/dist/services/order/adapter.d.ts.map +1 -0
  23. package/dist/services/order/index.d.ts +5 -0
  24. package/dist/services/order/index.d.ts.map +1 -0
  25. package/dist/services/order/orderService.d.ts +7 -0
  26. package/dist/services/order/orderService.d.ts.map +1 -0
  27. package/dist/services/order/types.d.ts +21 -0
  28. package/dist/services/order/types.d.ts.map +1 -0
  29. package/dist/services/orders/adapter.d.ts +2 -0
  30. package/dist/services/orders/adapter.d.ts.map +1 -1
  31. package/dist/services/orders/index.d.ts +1 -1
  32. package/dist/services/orders/index.d.ts.map +1 -1
  33. package/dist/services/product/adapter.d.ts +27 -2
  34. package/dist/services/product/adapter.d.ts.map +1 -1
  35. package/dist/services/product/adapter.test.d.ts +2 -0
  36. package/dist/services/product/adapter.test.d.ts.map +1 -0
  37. package/dist/services/product/index.d.ts +1 -1
  38. package/dist/services/product/index.d.ts.map +1 -1
  39. package/dist/services/product/productService.d.ts.map +1 -1
  40. package/dist/services/product/types.d.ts +68 -0
  41. package/dist/services/product/types.d.ts.map +1 -1
  42. package/dist/services/schedules/adapter.d.ts +94 -0
  43. package/dist/services/schedules/adapter.d.ts.map +1 -0
  44. package/dist/services/schedules/adapter.test.d.ts +2 -0
  45. package/dist/services/schedules/adapter.test.d.ts.map +1 -0
  46. package/dist/services/schedules/apiSchedulesAdapter.test.d.ts +2 -0
  47. package/dist/services/schedules/apiSchedulesAdapter.test.d.ts.map +1 -0
  48. package/dist/services/schedules/index.d.ts +5 -0
  49. package/dist/services/schedules/index.d.ts.map +1 -0
  50. package/dist/services/schedules/schedulesService.d.ts +11 -0
  51. package/dist/services/schedules/schedulesService.d.ts.map +1 -0
  52. package/dist/services/schedules/schedulesService.test.d.ts +2 -0
  53. package/dist/services/schedules/schedulesService.test.d.ts.map +1 -0
  54. package/dist/services/schedules/types.d.ts +290 -0
  55. package/dist/services/schedules/types.d.ts.map +1 -0
  56. package/dist/services/settings/index.d.ts +3 -0
  57. package/dist/services/settings/index.d.ts.map +1 -0
  58. package/dist/services/settings/settingsService.d.ts +7 -0
  59. package/dist/services/settings/settingsService.d.ts.map +1 -0
  60. package/dist/services/settings/settingsService.test.d.ts +2 -0
  61. package/dist/services/settings/settingsService.test.d.ts.map +1 -0
  62. package/dist/services/settings/types.d.ts +35 -0
  63. package/dist/services/settings/types.d.ts.map +1 -0
  64. package/dist/services/shop/index.d.ts +3 -0
  65. package/dist/services/shop/index.d.ts.map +1 -0
  66. package/dist/services/shop/shopService.d.ts +12 -0
  67. package/dist/services/shop/shopService.d.ts.map +1 -0
  68. package/dist/services/shop/shopService.test.d.ts +2 -0
  69. package/dist/services/shop/shopService.test.d.ts.map +1 -0
  70. package/dist/services/shop/types.d.ts +7 -0
  71. package/dist/services/shop/types.d.ts.map +1 -0
  72. package/dist/services/subscription/adapter.d.ts +77 -2
  73. package/dist/services/subscription/adapter.d.ts.map +1 -1
  74. package/dist/services/subscription/adapter.test.d.ts +2 -0
  75. package/dist/services/subscription/adapter.test.d.ts.map +1 -0
  76. package/dist/services/subscription/index.d.ts +1 -1
  77. package/dist/services/subscription/index.d.ts.map +1 -1
  78. package/dist/services/subscription/subscriptionService.d.ts +1 -6
  79. package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
  80. package/dist/services/subscription/types.d.ts +220 -9
  81. package/dist/services/subscription/types.d.ts.map +1 -1
  82. package/dist/services/subscription/types.test.d.ts +2 -0
  83. package/dist/services/subscription/types.test.d.ts.map +1 -0
  84. package/dist/shared/context.d.ts.map +1 -1
  85. package/dist/utils/index.d.ts +6 -0
  86. package/dist/utils/index.d.ts.map +1 -1
  87. package/dist/vue/context.d.ts +1 -0
  88. package/dist/vue/context.d.ts.map +1 -1
  89. package/dist/vue.js +12 -2
  90. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiSchedulesAdapter.test.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/apiSchedulesAdapter.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export type { SchedulesAdapter, } from './adapter';
2
+ export { createMockSchedulesAdapter, createApiSchedulesAdapter, } from './adapter';
3
+ export { createSchedulesService, SchedulesServiceContext, } from './schedulesService';
4
+ export * from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ReadonlySignal } from '@preact/signals-core';
2
+ import { ContextType } from '../../context';
3
+ import { SchedulesAdapter } from './adapter';
4
+ import { SchedulesService } from './types';
5
+ export declare const SchedulesServiceContext: {
6
+ __context__: SchedulesService;
7
+ };
8
+ export declare function createSchedulesService(adapter: SchedulesAdapter, opts?: {
9
+ hasPendingBilling?: ReadonlySignal<boolean>;
10
+ }): ContextType<typeof SchedulesServiceContext>;
11
+ //# sourceMappingURL=schedulesService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedulesService.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/schedulesService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAKV,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,uBAAuB;;CACmB,CAAC;AA4DxD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE;IAAE,iBAAiB,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;CAAE,GACrD,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAoN7C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schedulesService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedulesService.test.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/schedulesService.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,290 @@
1
+ import { ReadonlySignal, Signal } from '@preact/signals-core';
2
+ import { Result } from '../../utils';
3
+ export interface ScheduleOrderItem {
4
+ id: string;
5
+ title: string;
6
+ subtitle?: string | null;
7
+ imageUrl?: string;
8
+ variantId: string;
9
+ quantity: number;
10
+ price: number;
11
+ totalPrice: number;
12
+ /**
13
+ * True when a SKIP_ITEM adjustment drops this line from the cycle. The
14
+ * backend zeroes the line's totalPrice at recalculation time, so
15
+ * skipped-inclusive reads return zeroed skipped lines (unit price stays).
16
+ */
17
+ skipped: boolean;
18
+ variantImage?: {
19
+ url: string;
20
+ altText?: string;
21
+ } | null;
22
+ variantAvailableForSale?: boolean;
23
+ subscriptionId: string;
24
+ subscriptionLineId: string;
25
+ productId?: string;
26
+ parentProductId?: string | null;
27
+ parentLineId?: string | null;
28
+ isVirtual?: boolean;
29
+ isUpsell?: boolean;
30
+ recurringCycleLimit?: number | null;
31
+ customAttributes?: {
32
+ key: string;
33
+ value: string;
34
+ }[];
35
+ sellingPlanId?: string | null;
36
+ sellingPlanName?: string | null;
37
+ nextBillingDate?: string | null;
38
+ billingPolicy?: {
39
+ interval: "DAY" | "MONTH" | "WEEK" | "YEAR";
40
+ intervalCount: number;
41
+ } | null;
42
+ subscriptionStatus?: string | null;
43
+ subscriptionIsEditable?: boolean | null;
44
+ requiredBillingCyclesLeft?: number | null;
45
+ }
46
+ export interface ScheduleOrderDiscount {
47
+ id: string;
48
+ title?: string;
49
+ type: "percentage" | "fixed_amount";
50
+ value: number;
51
+ }
52
+ export type ScheduleInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
53
+ /**
54
+ * Selects which order(s) an adjustment applies to. Mirrors the Customer API
55
+ * matcher union (`POST /customer/v1/schedules/adjustments`). Adjustments are
56
+ * customer-scoped — matched by billing cycle and/or date, not subscription id.
57
+ */
58
+ export type ScheduleAdjustmentMatcher = {
59
+ type: "CYCLE";
60
+ input: {
61
+ cycle: number;
62
+ };
63
+ } | {
64
+ type: "DATE";
65
+ input: {
66
+ date: string;
67
+ };
68
+ } | {
69
+ type: "CYCLE_AND_DATE";
70
+ input: {
71
+ cycle: number;
72
+ date: string;
73
+ };
74
+ };
75
+ /** Address input for the `UPDATE_SHIPPING` adjustment action. */
76
+ export interface ScheduleShippingAddressInput {
77
+ firstName?: string | null;
78
+ lastName?: string | null;
79
+ address1?: string | null;
80
+ address2?: string | null;
81
+ zip?: string | null;
82
+ city?: string | null;
83
+ countryCode?: string | null;
84
+ provinceCode?: string | null;
85
+ phone?: string | null;
86
+ company?: string | null;
87
+ }
88
+ /** Per-line input for the `UPDATE_PRODUCTS` adjustment action. */
89
+ export interface ScheduleUpdateProductsLine {
90
+ lineId: string;
91
+ variantId?: string;
92
+ quantity?: number;
93
+ interval?: {
94
+ intervalCount: number;
95
+ interval: ScheduleInterval;
96
+ };
97
+ nextBillingDate?: string;
98
+ customAttributes?: {
99
+ key: string;
100
+ value: string;
101
+ }[];
102
+ }
103
+ /**
104
+ * What an adjustment does to the matched order(s). Mirrors the Customer API
105
+ * action union. `APPLY_DISCOUNT` is code-only here — the manual-discount variant
106
+ * is Admin-API only and intentionally not surfaced to the customer portal.
107
+ */
108
+ export type ScheduleAdjustmentAction = {
109
+ type: "SKIP_ORDER";
110
+ input: {
111
+ reason: string;
112
+ };
113
+ }
114
+ /**
115
+ * Skips individual lines within the matched cycle. `lineIds` stays an array
116
+ * on this READ shape so foreign (admin-created) multi-line adjustments
117
+ * round-trip through getAdjustments; blocks itself only ever writes a
118
+ * single-line `[lineId]` (see SchedulesAdapter.skipItem, R1).
119
+ */
120
+ | {
121
+ type: "SKIP_ITEM";
122
+ input: {
123
+ lineIds: string[];
124
+ reason?: string;
125
+ };
126
+ } | {
127
+ type: "CHANGE_DATE";
128
+ input: {
129
+ newDate: string;
130
+ };
131
+ } | {
132
+ type: "UPDATE_SHIPPING";
133
+ input: {
134
+ address: ScheduleShippingAddressInput;
135
+ };
136
+ } | {
137
+ type: "UPDATE_PAYMENT_METHOD";
138
+ input: {
139
+ paymentMethodId: string;
140
+ };
141
+ } | {
142
+ type: "UPDATE_PRODUCTS";
143
+ input: {
144
+ lines: ScheduleUpdateProductsLine[];
145
+ };
146
+ } | {
147
+ type: "APPLY_DISCOUNT";
148
+ input: {
149
+ discountSource: "code";
150
+ discountCode: string;
151
+ };
152
+ };
153
+ /**
154
+ * A persisted schedule adjustment as returned by the Customer API. Carries the
155
+ * full `matcher`/`action` pair so every action type round-trips — not just
156
+ * skip/date-change.
157
+ */
158
+ export interface ScheduleAdjustment {
159
+ id: string;
160
+ matcher: ScheduleAdjustmentMatcher;
161
+ action: ScheduleAdjustmentAction;
162
+ }
163
+ export interface ScheduleOrder {
164
+ id: string;
165
+ customerId: string;
166
+ subscriptionId?: string;
167
+ date: string;
168
+ skipped: boolean;
169
+ currencyCode: string;
170
+ subtotal: number;
171
+ deliveryPrice: number;
172
+ cycleIndex: number;
173
+ deliveryDate: string;
174
+ status: "scheduled" | "processing" | "delivered" | "skipped";
175
+ items: ScheduleOrderItem[];
176
+ discounts: ScheduleOrderDiscount[];
177
+ }
178
+ export interface SchedulesService {
179
+ /** Reactive signal — shared upcoming orders for multi-block access. `null` until first loaded. */
180
+ current: Signal<ScheduleOrder[] | null>;
181
+ currentLoading: Signal<boolean>;
182
+ /** Sourced from SubscriptionService — guards billing-sensitive actions */
183
+ hasPendingBilling: ReadonlySignal<boolean>;
184
+ /**
185
+ * Monotonic counter; bumps after EVERY successful schedule mutation —
186
+ * including scope-less ones that can't reload `current` (R8). Complete-
187
+ * schedule consumers (e.g. a skip/unskip list) watch it to re-read; it also
188
+ * fires for cross-actor changes (e.g. RenewalSummary's whole-order skip).
189
+ * Mirrors SubscriptionService.itemsChangedAt.
190
+ */
191
+ schedulesChangedAt: ReadonlySignal<number>;
192
+ /** Read-only projection. */
193
+ getUpcomingOrder(): Promise<Result<ScheduleOrder | null>>;
194
+ /**
195
+ * Pure read (never writes `current`). Forwards the excludeSkipped seam +
196
+ * scope so a consumer can fetch the complete, skipped-inclusive schedule.
197
+ * Backward-compatible: existing callers pass `count` only (the adapter
198
+ * defaults excludeSkipped to true — the billable view).
199
+ */
200
+ getUpcomingOrders(count: number, opts?: {
201
+ excludeSkipped?: boolean;
202
+ subscriptionId?: string;
203
+ }): Promise<Result<ScheduleOrder[]>>;
204
+ getAdjustments(): Promise<Result<ScheduleAdjustment[]>>;
205
+ /** Adjustment — skip the matched order. Matcher: CYCLE or DATE. */
206
+ skipOrder(params: {
207
+ subscriptionId: string;
208
+ cycle?: number;
209
+ date?: string;
210
+ }): Promise<Result>;
211
+ /**
212
+ * Skip one line in the matched cycle. Creates a one-line SKIP_ITEM
213
+ * adjustment (single-arm matcher — CYCLE preferred, R10).
214
+ */
215
+ skipItem(params: {
216
+ subscriptionId: string;
217
+ lineId: string;
218
+ cycle?: number;
219
+ date?: string;
220
+ reason?: string;
221
+ }): Promise<Result>;
222
+ /**
223
+ * Unskip one line. Resolves single-line SKIP_ITEM adjustment(s) covering
224
+ * this line + cycle/date via getAdjustments and deletes them (exact-cover
225
+ * rule, R1). Both `cycle` AND `date` are required (R6): coverage mirrors
226
+ * the backend's OR application, so DATE-matched foreign adjustments are
227
+ * discoverable too — the caller has both on the ScheduleOrder
228
+ * (`cycleIndex`, `date`). A line covered by any multi-line adjustment (R5),
229
+ * or by a CYCLE_AND_DATE adjustment whose arms don't both identify this
230
+ * order (R10), fails with a distinct error — removeAdjustment is the tool
231
+ * for those.
232
+ */
233
+ unskipItem(params: {
234
+ subscriptionId: string;
235
+ lineId: string;
236
+ cycle: number;
237
+ date: string;
238
+ }): Promise<Result>;
239
+ /**
240
+ * Reschedule the matched order. Backend requires a CYCLE matcher, so `cycle`
241
+ * is required and enforced at runtime by both adapters; `currentDate` is kept
242
+ * only to resolve the cycle in the mock adapter and is ignored by the API
243
+ * adapter.
244
+ */
245
+ changeDateAdjustment(params: {
246
+ subscriptionId: string;
247
+ newDate: string;
248
+ cycle: number;
249
+ currentDate?: string;
250
+ }): Promise<Result>;
251
+ /** Adjustment — override the shipping address for the matched order. */
252
+ updateShippingAdjustment(params: {
253
+ subscriptionId: string;
254
+ address: ScheduleShippingAddressInput;
255
+ cycle?: number;
256
+ date?: string;
257
+ }): Promise<Result>;
258
+ /** Adjustment — use a different payment method for the matched order. */
259
+ updatePaymentMethodAdjustment(params: {
260
+ subscriptionId: string;
261
+ paymentMethodId: string;
262
+ cycle?: number;
263
+ date?: string;
264
+ }): Promise<Result>;
265
+ /** Adjustment — swap variant / change quantity / interval on order lines. */
266
+ updateProductsAdjustment(params: {
267
+ subscriptionId: string;
268
+ lines: ScheduleUpdateProductsLine[];
269
+ cycle?: number;
270
+ date?: string;
271
+ }): Promise<Result>;
272
+ /** Adjustment — apply a discount code. Backend requires a CYCLE matcher. */
273
+ applyDiscountAdjustment(params: {
274
+ subscriptionId: string;
275
+ discountCode: string;
276
+ cycle: number;
277
+ }): Promise<Result>;
278
+ removeAdjustment(params: {
279
+ adjustmentId: string;
280
+ }): Promise<Result>;
281
+ /**
282
+ * Refresh `current` for the given subscription.
283
+ *
284
+ * Useful after a mutation (e.g. skip) when the subscription `id` is unchanged
285
+ * but the upcoming-order state has shifted — the host's id-based watcher
286
+ * does not fire in that case.
287
+ */
288
+ reloadCurrent(subscriptionId: string): Promise<void>;
289
+ }
290
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAA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AAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,4EAA4E;IAC5E,uBAAuB,CAAC,MAAM,EAAE;QAC9B,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,gBAAgB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpE;;;;;;OAMG;IACH,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD"}
@@ -0,0 +1,3 @@
1
+ export { createSettingsService, SettingsServiceContext, } from './settingsService';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/settings/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ContextType } from '../../context';
2
+ import { Settings, SettingsService } from './types';
3
+ export declare const SettingsServiceContext: {
4
+ __context__: SettingsService;
5
+ };
6
+ export declare function createSettingsService(initial?: Settings): ContextType<typeof SettingsServiceContext>;
7
+ //# sourceMappingURL=settingsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settingsService.d.ts","sourceRoot":"","sources":["../../../src/services/settings/settingsService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzD,eAAO,MAAM,sBAAsB;;CACkB,CAAC;AAEtD,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,QAAa,GACrB,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAQ5C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=settingsService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settingsService.test.d.ts","sourceRoot":"","sources":["../../../src/services/settings/settingsService.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { Signal } from '@preact/signals-core';
2
+ /**
3
+ * Slice covering RenewalSummary visibility flags.
4
+ * Future blocks widen this interface as they migrate.
5
+ *
6
+ * Convention: `undefined` means "default visible". Hosts should leave keys
7
+ * unset rather than seed `true` for visible-by-default actions, so consumers
8
+ * can render the default UX without the host having to know every flag.
9
+ */
10
+ export interface RenewalSummarySettings {
11
+ renewNow?: boolean;
12
+ skip?: boolean;
13
+ reactivate?: boolean;
14
+ reactivateFailed?: boolean;
15
+ pause?: boolean;
16
+ resume?: boolean;
17
+ cancel?: boolean;
18
+ changeFrequency?: boolean;
19
+ changeRenewalDate?: boolean;
20
+ customDeliveryEnabled?: boolean;
21
+ customChangePlanMessage?: string;
22
+ }
23
+ export interface Settings extends RenewalSummarySettings {
24
+ editQuantity?: boolean;
25
+ editVariant?: boolean;
26
+ swap?: boolean;
27
+ removeLine?: boolean;
28
+ addLine?: boolean;
29
+ redeemDiscount?: boolean;
30
+ }
31
+ export interface SettingsService {
32
+ current: Signal<Settings>;
33
+ get<K extends keyof Settings>(key: K): Settings[K] | undefined;
34
+ }
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ export { type ShopService } from './types';
2
+ export { createShopService, ShopServiceContext } from './shopService';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/shop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { ContextType } from '../../context';
2
+ import { ShopService } from './types';
3
+ type CreateShopServiceOptions = {
4
+ /** Called once at creation; hosts update `contactEmail` in a `watchEffect`. */
5
+ getContactEmail: () => string;
6
+ };
7
+ export declare function createShopService(options: CreateShopServiceOptions): ContextType<typeof ShopServiceContext>;
8
+ export declare const ShopServiceContext: {
9
+ __context__: ShopService;
10
+ };
11
+ export {};
12
+ //# sourceMappingURL=shopService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopService.d.ts","sourceRoot":"","sources":["../../../src/services/shop/shopService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,KAAK,wBAAwB,GAAG;IAC9B,+EAA+E;IAC/E,eAAe,EAAE,MAAM,MAAM,CAAC;CAC/B,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAIxC;AAED,eAAO,MAAM,kBAAkB;;CAA8C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shopService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopService.test.d.ts","sourceRoot":"","sources":["../../../src/services/shop/shopService.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { Signal } from '@preact/signals-core';
2
+ /** Minimal shop-level data needed by blocks. Widen as blocks adopt it. */
3
+ export interface ShopService {
4
+ /** Storefront contact email, e.g. for the SEPA early-payment overlay. */
5
+ contactEmail: Signal<string>;
6
+ }
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/shop/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CAC9B"}
@@ -1,13 +1,26 @@
1
- import { Subscription, SellingPlan, SearchOptions, PostableSubscriptionItem } from './types';
1
+ import { ApiFetcher, PaginatedList, Result } from '../../utils';
2
+ import { Subscription, SellingPlan, SellingPlanInterval, SearchOptions, PostableSubscriptionItem, UpdateSubscriptionItem, UpdateBoxItem, LastOrder, RenewNowResult, UpsellProduct } from './types';
2
3
  import { ApplyDiscountError, DiscountRejectionReason, RemoveDiscountError } from './discountErrors';
3
- import { Result, PaginatedList } from '../../utils';
4
+ import { ProductAdapter } from '../product/adapter';
4
5
  /**
5
6
  * Adapter interface for subscription.
6
7
  * Implementations should handle API calls, error handling, and data transformation.
7
8
  */
8
9
  export interface SubscriptionAdapter {
9
10
  search(options?: SearchOptions): Promise<Result<PaginatedList<Subscription>>>;
11
+ /**
12
+ * Returns the full list of the customer's subscriptions for cross-subscription
13
+ * views (the "other subscriptions" list and the product strip), ordered with
14
+ * active/paused first. Unlike `search` (a single v1 page sorted createdAt:asc),
15
+ * this is sourced from the richer legacy list endpoint so active subscriptions
16
+ * are never paginated out behind older canceled ones. Optional: when an adapter
17
+ * does not implement it, the service falls back to `search`.
18
+ */
19
+ listAll?(): Promise<Result<Subscription[]>>;
10
20
  getById(id: string): Promise<Result<Subscription | null>>;
21
+ getLastOrder(params: {
22
+ subscriptionId: string;
23
+ }): Promise<Result<LastOrder | null>>;
11
24
  addItem(params: {
12
25
  subscriptionId: string;
13
26
  item: PostableSubscriptionItem;
@@ -16,6 +29,31 @@ export interface SubscriptionAdapter {
16
29
  subscriptionId: string;
17
30
  itemId: string;
18
31
  }): Promise<Result>;
32
+ updateItem(params: {
33
+ subscriptionId: string;
34
+ lineId: string;
35
+ update: UpdateSubscriptionItem;
36
+ }): Promise<Result>;
37
+ skipLineItem(params: {
38
+ subscriptionId: string;
39
+ lineId: string;
40
+ nextBillingDate: string;
41
+ }): Promise<Result>;
42
+ updateBoxItems(params: {
43
+ subscriptionId: string;
44
+ parentId: string;
45
+ items: UpdateBoxItem[];
46
+ shippingMethodHandle?: string;
47
+ }): Promise<Result>;
48
+ updateItemAttributes(params: {
49
+ subscriptionId: string;
50
+ lineId: string;
51
+ customAttributes: Record<string, string>;
52
+ }): Promise<Result>;
53
+ updateAttributes(params: {
54
+ subscriptionId: string;
55
+ customAttributes: Record<string, string>;
56
+ }): Promise<Result>;
19
57
  addDiscount(params: {
20
58
  subscriptionId: string;
21
59
  code: string;
@@ -28,6 +66,16 @@ export interface SubscriptionAdapter {
28
66
  subscriptionId: string;
29
67
  newDate: string;
30
68
  }): Promise<Result<Subscription>>;
69
+ /**
70
+ * Replace the customer-visible custom attributes on a subscription. `customAttributes`
71
+ * is the complete desired set of customer-editable keys — keys omitted are removed.
72
+ * Internal (`_`-prefixed) / reserved keys are always preserved server-side and must
73
+ * not be sent (the API rejects them with 400).
74
+ */
75
+ updateCustomAttributes(params: {
76
+ subscriptionId: string;
77
+ customAttributes: Record<string, string>;
78
+ }): Promise<Result<Subscription>>;
31
79
  resume(params: {
32
80
  subscriptionId: string;
33
81
  }): Promise<Result<Subscription>>;
@@ -41,10 +89,28 @@ export interface SubscriptionAdapter {
41
89
  subscriptionId: string;
42
90
  reason?: string;
43
91
  }): Promise<Result<Subscription>>;
92
+ renewNow(params: {
93
+ subscriptionId: string;
94
+ renewalId?: string;
95
+ retry?: boolean;
96
+ }): Promise<Result<RenewNowResult>>;
97
+ changeFrequency(params: {
98
+ subscriptionId: string;
99
+ plan: string | SellingPlanInterval;
100
+ }): Promise<Result<Subscription>>;
44
101
  getAvailablePlans(params: {
45
102
  subscriptionId: string;
46
103
  }): Promise<Result<SellingPlan[]>>;
47
104
  getDefaultSubscriptionId(): Promise<Result<string | null>>;
105
+ getUpsellProducts?(params: {
106
+ subscriptionId: string;
107
+ }): Promise<Result<UpsellProduct[]>>;
108
+ addUpsellProduct?(params: {
109
+ subscriptionId: string;
110
+ variantId: string;
111
+ quantity: number;
112
+ oneTime?: boolean;
113
+ }): Promise<Result>;
48
114
  }
49
115
  export interface MockSubscriptionAdapterOptions {
50
116
  addDiscountBehavior?: {
@@ -62,6 +128,15 @@ export interface MockSubscriptionAdapterOptions {
62
128
  kind: "error";
63
129
  error: "NETWORK" | "UNKNOWN" | "SUBSCRIPTION_NOT_FOUND" | "DISCOUNT_NOT_FOUND";
64
130
  };
131
+ /**
132
+ * Optional product source used by `addItem` to resolve a real title/price for
133
+ * an added line. Without it, added lines fall back to a placeholder title and
134
+ * a 0.00 price (the two mock stores are otherwise independent). Pass the same
135
+ * `createMockProductAdapter()` instance that backs the ProductService so the
136
+ * added line matches what the product picker showed.
137
+ */
138
+ productAdapter?: Pick<ProductAdapter, "getByVariantId" | "getById">;
65
139
  }
66
140
  export declare function createMockSubscriptionAdapter(options?: MockSubscriptionAdapterOptions): SubscriptionAdapter;
141
+ export declare function createApiSubscriptionAdapter(fetcher: ApiFetcher): SubscriptionAdapter;
67
142
  //# 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,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,wBAAwB,EACzB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,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,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;IAE1D,OAAO,CAAC,MAAM,EAAE;QACd,cAAc,EAA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,iBAAiB,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAEtF,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,8BAA8B;IAC7C,mBAAmB,CAAC,EAChB;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,GACnB;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,uBAAuB,CAAA;KAAE,GACrD;QACE,IAAI,EAAE,OAAO,CAAC;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;CACP;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,mBAAmB,CAiTrB"}
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,m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OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC7C,mBAAmB,CAAC,EAChB;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,GACnB;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,uBAAuB,CAAA;KAAE,GACrD;QACE,IAAI,EAAE,OAAO,CAAC;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"}
@@ -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/subscription/adapter.test.ts"],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  export type { SubscriptionAdapter, MockSubscriptionAdapterOptions } from './adapter';
2
- export { createMockSubscriptionAdapter } from './adapter';
2
+ export { createMockSubscriptionAdapter, createApiSubscriptionAdapter } from './adapter';
3
3
  export { createSubscriptionService, SubscriptionServiceContext } from './subscriptionService';
4
4
  export * from './types';
5
5
  export * from './discountErrors';
@@ -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,MAAM,WAAW,CAAC;AAE1D,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,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,12 +1,7 @@
1
- import { ContextType } from '../../context';
2
1
  import { SubscriptionAdapter } from './adapter';
3
2
  import { SubscriptionService } from './types';
4
3
  export declare const SubscriptionServiceContext: {
5
4
  __context__: SubscriptionService;
6
5
  };
7
- /**
8
- * Creates a subscription service that uses the provided adapter for data operations.
9
- * The adapter pattern decouples the service from specific SDK implementations.
10
- */
11
- export declare function createSubscriptionService(adapter: SubscriptionAdapter): ContextType<typeof SubscriptionServiceContext>;
6
+ export declare function createSubscriptionService(adapter: SubscriptionAdapter): SubscriptionService;
12
7
  //# sourceMappingURL=subscriptionService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscriptionService.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/subscriptionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,0BAA0B;;CACsB,CAAC;AAqC9D;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAmGhD"}
1
+ {"version":3,"file":"subscriptionService.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/subscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAMV,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,0BAA0B;;CACsB,CAAC;AA2B9D,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CA0LrB"}