@juo/blocks 1.13.0-alpha.0 → 1.13.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +355 -78
- package/dist/services/orders/adapter.d.ts +2 -0
- package/dist/services/orders/adapter.d.ts.map +1 -1
- package/dist/services/orders/index.d.ts +1 -1
- package/dist/services/orders/index.d.ts.map +1 -1
- package/dist/services/schedules/adapter.d.ts +25 -1
- package/dist/services/schedules/adapter.d.ts.map +1 -1
- package/dist/services/schedules/schedulesService.d.ts.map +1 -1
- package/dist/services/schedules/types.d.ts +132 -7
- package/dist/services/schedules/types.d.ts.map +1 -1
- package/dist/services/subscription/adapter.d.ts +19 -0
- package/dist/services/subscription/adapter.d.ts.map +1 -1
- package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
- package/dist/services/subscription/types.d.ts +9 -5
- package/dist/services/subscription/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -742,6 +742,55 @@ function createMockOrdersAdapter() {
|
|
|
742
742
|
}
|
|
743
743
|
};
|
|
744
744
|
}
|
|
745
|
+
function mapOrderLine(item) {
|
|
746
|
+
var _a;
|
|
747
|
+
return {
|
|
748
|
+
id: item.id,
|
|
749
|
+
title: item.title,
|
|
750
|
+
quantity: item.quantity,
|
|
751
|
+
variantImage: ((_a = item.variantImage) == null ? void 0 : _a.url) ? { url: item.variantImage.url, altText: item.variantImage.altText ?? void 0 } : null,
|
|
752
|
+
customAttributes: item.customAttributes
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
function mapOrder(order) {
|
|
756
|
+
return {
|
|
757
|
+
id: order.id,
|
|
758
|
+
createdAt: order.createdAt,
|
|
759
|
+
placedAt: order.placedAt,
|
|
760
|
+
currencyCode: order.currencyCode,
|
|
761
|
+
totalPrice: order.totalPrice,
|
|
762
|
+
financialStatus: order.financialStatus,
|
|
763
|
+
fulfillmentStatus: order.fulfillmentStatus,
|
|
764
|
+
lines: order.items.map(mapOrderLine),
|
|
765
|
+
customAttributes: order.customAttributes
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
function createApiOrdersAdapter(fetcher) {
|
|
769
|
+
return {
|
|
770
|
+
async getOrders(params) {
|
|
771
|
+
const query = new URLSearchParams();
|
|
772
|
+
if ((params == null ? void 0 : params.limit) != null) query.set("limit", String(params.limit));
|
|
773
|
+
if ((params == null ? void 0 : params.after) != null) query.set("after", params.after);
|
|
774
|
+
if ((params == null ? void 0 : params.before) != null) query.set("before", params.before);
|
|
775
|
+
if ((params == null ? void 0 : params.query) != null) query.set("query", params.query);
|
|
776
|
+
if ((params == null ? void 0 : params.includeOneTime) != null) query.set("includeOneTime", String(params.includeOneTime));
|
|
777
|
+
if ((params == null ? void 0 : params.sort) != null) query.set("sort", params.sort);
|
|
778
|
+
const qs = query.toString();
|
|
779
|
+
const res = await fetcher(`/customer/v1/orders${qs ? `?${qs}` : ""}`);
|
|
780
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
781
|
+
const body = await res.json();
|
|
782
|
+
return {
|
|
783
|
+
items: body.data.map(mapOrder),
|
|
784
|
+
pageInfo: {
|
|
785
|
+
hasNextPage: body.hasNextPage,
|
|
786
|
+
hasPrevPage: body.hasPrevPage,
|
|
787
|
+
startCursor: body.startCursor,
|
|
788
|
+
endCursor: body.endCursor
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
}
|
|
745
794
|
function createOrdersService(adapter) {
|
|
746
795
|
return {
|
|
747
796
|
async getOrders(params) {
|
|
@@ -1246,6 +1295,9 @@ function createMockRouterService() {
|
|
|
1246
1295
|
}
|
|
1247
1296
|
}).routerService;
|
|
1248
1297
|
}
|
|
1298
|
+
function toAttributeArray(next) {
|
|
1299
|
+
return Object.entries(next).map(([key, value]) => ({ key, value }));
|
|
1300
|
+
}
|
|
1249
1301
|
function createMockSubscriptionAdapter(options = {}) {
|
|
1250
1302
|
const richBase = (id, itemId, renewalId) => ({
|
|
1251
1303
|
id,
|
|
@@ -1556,6 +1608,30 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1556
1608
|
subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1557
1609
|
return { _tag: "Success", data: void 0 };
|
|
1558
1610
|
},
|
|
1611
|
+
async updateItemAttributes({ subscriptionId, lineId, customAttributes }) {
|
|
1612
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
1613
|
+
const subscription = mockSubscriptions.find((sub) => sub.id === subscriptionId);
|
|
1614
|
+
if (!subscription) {
|
|
1615
|
+
return { _tag: "Failure", error: "Subscription not found" };
|
|
1616
|
+
}
|
|
1617
|
+
const item = subscription.items.find((i3) => i3.id === lineId);
|
|
1618
|
+
if (!item) {
|
|
1619
|
+
return { _tag: "Failure", error: "Line item not found" };
|
|
1620
|
+
}
|
|
1621
|
+
item.customAttributes = toAttributeArray(customAttributes);
|
|
1622
|
+
subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1623
|
+
return { _tag: "Success", data: void 0 };
|
|
1624
|
+
},
|
|
1625
|
+
async updateAttributes({ subscriptionId, customAttributes }) {
|
|
1626
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
1627
|
+
const subscription = mockSubscriptions.find((sub) => sub.id === subscriptionId);
|
|
1628
|
+
if (!subscription) {
|
|
1629
|
+
return { _tag: "Failure", error: "Subscription not found" };
|
|
1630
|
+
}
|
|
1631
|
+
subscription.customAttributes = toAttributeArray(customAttributes);
|
|
1632
|
+
subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1633
|
+
return { _tag: "Success", data: void 0 };
|
|
1634
|
+
},
|
|
1559
1635
|
async skipLineItem() {
|
|
1560
1636
|
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
1561
1637
|
return { _tag: "Success", data: void 0 };
|
|
@@ -1597,6 +1673,24 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1597
1673
|
subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1598
1674
|
return { _tag: "Success", data: { ...subscription } };
|
|
1599
1675
|
},
|
|
1676
|
+
async updateCustomAttributes(params) {
|
|
1677
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
1678
|
+
const subscription = mockSubscriptions.find(
|
|
1679
|
+
(sub) => sub.id === params.subscriptionId
|
|
1680
|
+
);
|
|
1681
|
+
if (!subscription) {
|
|
1682
|
+
return { _tag: "Failure", error: "Subscription not found" };
|
|
1683
|
+
}
|
|
1684
|
+
const preserved = (subscription.customAttributes ?? []).filter(
|
|
1685
|
+
(attr) => attr.key.startsWith("_")
|
|
1686
|
+
);
|
|
1687
|
+
const next = Object.entries(params.customAttributes).map(
|
|
1688
|
+
([key, value]) => ({ key, value })
|
|
1689
|
+
);
|
|
1690
|
+
subscription.customAttributes = [...preserved, ...next];
|
|
1691
|
+
subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1692
|
+
return { _tag: "Success", data: { ...subscription } };
|
|
1693
|
+
},
|
|
1600
1694
|
async resume(params) {
|
|
1601
1695
|
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
1602
1696
|
const subscription = mockSubscriptions.find(
|
|
@@ -1776,7 +1870,8 @@ function mapSubscription(raw) {
|
|
|
1776
1870
|
title: item.title,
|
|
1777
1871
|
variantTitle: item.subtitle ?? void 0,
|
|
1778
1872
|
// recurringCycleLimit === 1 means the item charges exactly once (one-time upsell)
|
|
1779
|
-
|
|
1873
|
+
recurringCycleLimit: item.recurringCycleLimit ?? null,
|
|
1874
|
+
customAttributes: Array.isArray(item.customAttributes) ? item.customAttributes : []
|
|
1780
1875
|
})
|
|
1781
1876
|
),
|
|
1782
1877
|
discounts: (raw.discounts ?? []).map(
|
|
@@ -1804,7 +1899,8 @@ function mapSubscription(raw) {
|
|
|
1804
1899
|
createdAt: raw.createdAt,
|
|
1805
1900
|
updatedAt: raw.updatedAt,
|
|
1806
1901
|
billingPolicy: raw.billingPolicy ?? null,
|
|
1807
|
-
deliveryPolicy: raw.deliveryPolicy ?? null
|
|
1902
|
+
deliveryPolicy: raw.deliveryPolicy ?? null,
|
|
1903
|
+
customAttributes: Array.isArray(raw.customAttributes) ? raw.customAttributes : []
|
|
1808
1904
|
};
|
|
1809
1905
|
}
|
|
1810
1906
|
function createApiSubscriptionAdapter(fetcher) {
|
|
@@ -1906,6 +2002,38 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1906
2002
|
return { _tag: "Failure", error: e2 };
|
|
1907
2003
|
}
|
|
1908
2004
|
},
|
|
2005
|
+
async updateItemAttributes({ subscriptionId, lineId, customAttributes }) {
|
|
2006
|
+
try {
|
|
2007
|
+
const res = await fetcher(
|
|
2008
|
+
`/customer/v1/subscriptions/${subscriptionId}/items/${lineId}`,
|
|
2009
|
+
{
|
|
2010
|
+
method: "PATCH",
|
|
2011
|
+
headers: { "Content-Type": "application/json" },
|
|
2012
|
+
body: JSON.stringify({ customAttributes })
|
|
2013
|
+
}
|
|
2014
|
+
);
|
|
2015
|
+
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2016
|
+
return { _tag: "Success", data: void 0 };
|
|
2017
|
+
} catch (e2) {
|
|
2018
|
+
return { _tag: "Failure", error: e2 };
|
|
2019
|
+
}
|
|
2020
|
+
},
|
|
2021
|
+
async updateAttributes({ subscriptionId, customAttributes }) {
|
|
2022
|
+
try {
|
|
2023
|
+
const res = await fetcher(
|
|
2024
|
+
`/customer/v1/subscriptions/${subscriptionId}`,
|
|
2025
|
+
{
|
|
2026
|
+
method: "PATCH",
|
|
2027
|
+
headers: { "Content-Type": "application/json" },
|
|
2028
|
+
body: JSON.stringify({ customAttributes })
|
|
2029
|
+
}
|
|
2030
|
+
);
|
|
2031
|
+
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2032
|
+
return { _tag: "Success", data: void 0 };
|
|
2033
|
+
} catch (e2) {
|
|
2034
|
+
return { _tag: "Failure", error: e2 };
|
|
2035
|
+
}
|
|
2036
|
+
},
|
|
1909
2037
|
async skipLineItem({ subscriptionId, lineId, nextBillingDate }) {
|
|
1910
2038
|
try {
|
|
1911
2039
|
const res = await fetcher(
|
|
@@ -1984,6 +2112,24 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1984
2112
|
return { _tag: "Failure", error: e2 };
|
|
1985
2113
|
}
|
|
1986
2114
|
},
|
|
2115
|
+
// PATCH /customer/v1/subscriptions/{id} with the full customer-visible set.
|
|
2116
|
+
async updateCustomAttributes({ subscriptionId, customAttributes }) {
|
|
2117
|
+
try {
|
|
2118
|
+
const res = await fetcher(
|
|
2119
|
+
`/customer/v1/subscriptions/${subscriptionId}`,
|
|
2120
|
+
{
|
|
2121
|
+
method: "PATCH",
|
|
2122
|
+
headers: { "Content-Type": "application/json" },
|
|
2123
|
+
body: JSON.stringify({ customAttributes })
|
|
2124
|
+
}
|
|
2125
|
+
);
|
|
2126
|
+
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2127
|
+
const data = await res.json();
|
|
2128
|
+
return { _tag: "Success", data: mapSubscription(data) };
|
|
2129
|
+
} catch (e2) {
|
|
2130
|
+
return { _tag: "Failure", error: e2 };
|
|
2131
|
+
}
|
|
2132
|
+
},
|
|
1987
2133
|
async resume({ subscriptionId }) {
|
|
1988
2134
|
try {
|
|
1989
2135
|
const res = await fetcher(
|
|
@@ -2179,6 +2325,25 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2179
2325
|
};
|
|
2180
2326
|
return adapter;
|
|
2181
2327
|
}
|
|
2328
|
+
function toIsoOrNull(value) {
|
|
2329
|
+
const date = new Date(value);
|
|
2330
|
+
return Number.isNaN(date.getTime()) ? null : date.toISOString();
|
|
2331
|
+
}
|
|
2332
|
+
function buildMatcher(params) {
|
|
2333
|
+
const { cycle, date } = params;
|
|
2334
|
+
let iso;
|
|
2335
|
+
if (date != null) {
|
|
2336
|
+
const parsed = toIsoOrNull(date);
|
|
2337
|
+
if (parsed == null) return { ok: false, error: "date must be a valid date" };
|
|
2338
|
+
iso = parsed;
|
|
2339
|
+
}
|
|
2340
|
+
if (cycle != null && iso != null) {
|
|
2341
|
+
return { ok: true, matcher: { type: "CYCLE_AND_DATE", input: { cycle, date: iso } } };
|
|
2342
|
+
}
|
|
2343
|
+
if (cycle != null) return { ok: true, matcher: { type: "CYCLE", input: { cycle } } };
|
|
2344
|
+
if (iso != null) return { ok: true, matcher: { type: "DATE", input: { date: iso } } };
|
|
2345
|
+
return { ok: false, error: "Either cycle or date is required" };
|
|
2346
|
+
}
|
|
2182
2347
|
const DELIVERY_PRICE_CENTS = 500;
|
|
2183
2348
|
const DELIVERY_OFFSET_DAYS = 2;
|
|
2184
2349
|
function toCents(amount) {
|
|
@@ -2224,11 +2389,8 @@ function mapItem(sub, item, cycle) {
|
|
|
2224
2389
|
parentLineId: item.parentLineId ?? null,
|
|
2225
2390
|
isVirtual: item.isVirtual ?? false,
|
|
2226
2391
|
isUpsell: item.isUpsell ?? false,
|
|
2227
|
-
|
|
2228
|
-
customAttributes:
|
|
2229
|
-
name: a3.key,
|
|
2230
|
-
value: a3.value
|
|
2231
|
-
}))
|
|
2392
|
+
recurringCycleLimit: item.recurringCycleLimit ?? null,
|
|
2393
|
+
customAttributes: item.customAttributes ?? []
|
|
2232
2394
|
};
|
|
2233
2395
|
}
|
|
2234
2396
|
function projectUpcomingOrders(sub, count) {
|
|
@@ -2271,16 +2433,21 @@ function projectUpcomingOrders(sub, count) {
|
|
|
2271
2433
|
}
|
|
2272
2434
|
return orders;
|
|
2273
2435
|
}
|
|
2274
|
-
function applyAdjustments(orders,
|
|
2436
|
+
function applyAdjustments(orders, stored) {
|
|
2275
2437
|
return orders.map((order) => {
|
|
2276
2438
|
let next = order;
|
|
2277
|
-
for (const
|
|
2278
|
-
if (
|
|
2279
|
-
if (
|
|
2280
|
-
|
|
2439
|
+
for (const { adjustment, subscriptionId, cycle } of stored) {
|
|
2440
|
+
if (subscriptionId !== order.subscriptionId) continue;
|
|
2441
|
+
if (cycle !== order.cycleIndex) continue;
|
|
2442
|
+
const { action } = adjustment;
|
|
2443
|
+
if (action.type === "SKIP_ORDER") {
|
|
2281
2444
|
next = { ...next, skipped: true, status: "skipped" };
|
|
2282
|
-
} else if (
|
|
2283
|
-
next = {
|
|
2445
|
+
} else if (action.type === "CHANGE_DATE") {
|
|
2446
|
+
next = {
|
|
2447
|
+
...next,
|
|
2448
|
+
date: action.input.newDate,
|
|
2449
|
+
deliveryDate: action.input.newDate
|
|
2450
|
+
};
|
|
2284
2451
|
}
|
|
2285
2452
|
}
|
|
2286
2453
|
return next;
|
|
@@ -2288,7 +2455,8 @@ function applyAdjustments(orders, adjustments) {
|
|
|
2288
2455
|
}
|
|
2289
2456
|
function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapter()) {
|
|
2290
2457
|
const RESOLVE_DEPTH = 12;
|
|
2291
|
-
let
|
|
2458
|
+
let stored = [];
|
|
2459
|
+
let idSeq = 0;
|
|
2292
2460
|
async function subscriptionsToProject(subscriptionId) {
|
|
2293
2461
|
if (subscriptionId) {
|
|
2294
2462
|
const res = await subscriptions.getById(subscriptionId);
|
|
@@ -2309,28 +2477,38 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
|
|
|
2309
2477
|
function resolveCycle(orders, opts) {
|
|
2310
2478
|
if (opts.cycle != null) return opts.cycle;
|
|
2311
2479
|
if (opts.date) {
|
|
2312
|
-
const
|
|
2313
|
-
const
|
|
2480
|
+
const iso = toIsoOrNull(opts.date);
|
|
2481
|
+
const target = iso == null ? void 0 : iso.split("T")[0];
|
|
2482
|
+
const match = target ? orders.find(
|
|
2314
2483
|
(o2) => o2.deliveryDate.split("T")[0] === target || o2.date.split("T")[0] === target
|
|
2315
|
-
);
|
|
2484
|
+
) : void 0;
|
|
2316
2485
|
if (match) return match.cycleIndex;
|
|
2317
2486
|
}
|
|
2318
2487
|
const firstScheduled = orders.find((o2) => o2.status === "scheduled");
|
|
2319
2488
|
return (firstScheduled == null ? void 0 : firstScheduled.cycleIndex) ?? null;
|
|
2320
2489
|
}
|
|
2321
|
-
async function recordAdjustment(subscriptionId, opts,
|
|
2490
|
+
async function recordAdjustment(subscriptionId, opts, buildAction) {
|
|
2322
2491
|
const res = await subscriptions.getById(subscriptionId);
|
|
2323
2492
|
const sub = res._tag === "Success" ? res.data : null;
|
|
2324
2493
|
if (!sub) return { _tag: "Failure", error: "No scheduled order found" };
|
|
2325
2494
|
const orders = applyAdjustments(
|
|
2326
2495
|
projectUpcomingOrders(sub, RESOLVE_DEPTH),
|
|
2327
|
-
|
|
2496
|
+
stored
|
|
2328
2497
|
);
|
|
2329
2498
|
const cycle = resolveCycle(orders, opts);
|
|
2330
2499
|
if (cycle == null) {
|
|
2331
2500
|
return { _tag: "Failure", error: "No scheduled order found" };
|
|
2332
2501
|
}
|
|
2333
|
-
|
|
2502
|
+
const built = buildMatcher({ cycle, date: opts.date });
|
|
2503
|
+
const matcher = built.ok ? built.matcher : { type: "CYCLE", input: { cycle } };
|
|
2504
|
+
stored = [
|
|
2505
|
+
...stored,
|
|
2506
|
+
{
|
|
2507
|
+
adjustment: { id: `adj-${idSeq++}`, matcher, action: buildAction() },
|
|
2508
|
+
subscriptionId,
|
|
2509
|
+
cycle
|
|
2510
|
+
}
|
|
2511
|
+
];
|
|
2334
2512
|
return { _tag: "Success", data: void 0 };
|
|
2335
2513
|
}
|
|
2336
2514
|
return {
|
|
@@ -2338,45 +2516,90 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
|
|
|
2338
2516
|
await new Promise((r) => setTimeout(r, 200));
|
|
2339
2517
|
const subs = await subscriptionsToProject(subscriptionId);
|
|
2340
2518
|
const orders = subs.flatMap(
|
|
2341
|
-
(sub) => applyAdjustments(projectUpcomingOrders(sub, count),
|
|
2519
|
+
(sub) => applyAdjustments(projectUpcomingOrders(sub, count), stored)
|
|
2342
2520
|
).sort((a3, b3) => a3.date.localeCompare(b3.date));
|
|
2343
2521
|
return { _tag: "Success", data: orders.slice(0, count) };
|
|
2344
2522
|
},
|
|
2345
2523
|
async getAdjustments() {
|
|
2346
2524
|
await new Promise((r) => setTimeout(r, 200));
|
|
2347
|
-
return { _tag: "Success", data:
|
|
2525
|
+
return { _tag: "Success", data: stored.map((s2) => s2.adjustment) };
|
|
2348
2526
|
},
|
|
2349
2527
|
async skipOrder({ subscriptionId, cycle, date }) {
|
|
2350
2528
|
await new Promise((r) => setTimeout(r, 300));
|
|
2351
|
-
return recordAdjustment(subscriptionId, { cycle, date }, (
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
type: "skip",
|
|
2355
|
-
cycle: resolved
|
|
2529
|
+
return recordAdjustment(subscriptionId, { cycle, date }, () => ({
|
|
2530
|
+
type: "SKIP_ORDER",
|
|
2531
|
+
input: { reason: "" }
|
|
2356
2532
|
}));
|
|
2357
2533
|
},
|
|
2358
|
-
async changeDateAdjustment({ subscriptionId, newDate, currentDate }) {
|
|
2534
|
+
async changeDateAdjustment({ subscriptionId, newDate, cycle, currentDate }) {
|
|
2359
2535
|
await new Promise((r) => setTimeout(r, 300));
|
|
2536
|
+
const newIso = toIsoOrNull(newDate);
|
|
2537
|
+
if (newIso == null) {
|
|
2538
|
+
return { _tag: "Failure", error: "newDate must be a valid date" };
|
|
2539
|
+
}
|
|
2360
2540
|
return recordAdjustment(
|
|
2361
2541
|
subscriptionId,
|
|
2362
|
-
{ date: currentDate },
|
|
2363
|
-
(
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
type: "date_change",
|
|
2367
|
-
cycle: resolved,
|
|
2368
|
-
newDate
|
|
2542
|
+
{ cycle, date: currentDate },
|
|
2543
|
+
() => ({
|
|
2544
|
+
type: "CHANGE_DATE",
|
|
2545
|
+
input: { newDate: newIso }
|
|
2369
2546
|
})
|
|
2370
2547
|
);
|
|
2371
2548
|
},
|
|
2549
|
+
async updateShippingAdjustment({ subscriptionId, address, cycle, date }) {
|
|
2550
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
2551
|
+
return recordAdjustment(subscriptionId, { cycle, date }, () => ({
|
|
2552
|
+
type: "UPDATE_SHIPPING",
|
|
2553
|
+
input: { address }
|
|
2554
|
+
}));
|
|
2555
|
+
},
|
|
2556
|
+
async updatePaymentMethodAdjustment({
|
|
2557
|
+
subscriptionId,
|
|
2558
|
+
paymentMethodId,
|
|
2559
|
+
cycle,
|
|
2560
|
+
date
|
|
2561
|
+
}) {
|
|
2562
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
2563
|
+
return recordAdjustment(subscriptionId, { cycle, date }, () => ({
|
|
2564
|
+
type: "UPDATE_PAYMENT_METHOD",
|
|
2565
|
+
input: { paymentMethodId }
|
|
2566
|
+
}));
|
|
2567
|
+
},
|
|
2568
|
+
async updateProductsAdjustment({ subscriptionId, lines, cycle, date }) {
|
|
2569
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
2570
|
+
return recordAdjustment(subscriptionId, { cycle, date }, () => ({
|
|
2571
|
+
type: "UPDATE_PRODUCTS",
|
|
2572
|
+
input: { lines }
|
|
2573
|
+
}));
|
|
2574
|
+
},
|
|
2575
|
+
async applyDiscountAdjustment({ subscriptionId, discountCode, cycle }) {
|
|
2576
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
2577
|
+
return recordAdjustment(subscriptionId, { cycle }, () => ({
|
|
2578
|
+
type: "APPLY_DISCOUNT",
|
|
2579
|
+
input: { discountSource: "code", discountCode }
|
|
2580
|
+
}));
|
|
2581
|
+
},
|
|
2372
2582
|
async removeAdjustment({ adjustmentId }) {
|
|
2373
2583
|
await new Promise((r) => setTimeout(r, 200));
|
|
2374
|
-
|
|
2584
|
+
stored = stored.filter((s2) => s2.adjustment.id !== adjustmentId);
|
|
2375
2585
|
return { _tag: "Success", data: void 0 };
|
|
2376
2586
|
}
|
|
2377
2587
|
};
|
|
2378
2588
|
}
|
|
2379
2589
|
function createApiSchedulesAdapter(fetcher) {
|
|
2590
|
+
async function postAdjustment(matcher, action) {
|
|
2591
|
+
try {
|
|
2592
|
+
const res = await fetcher(`/customer/v1/schedules/adjustments`, {
|
|
2593
|
+
method: "POST",
|
|
2594
|
+
headers: { "Content-Type": "application/json" },
|
|
2595
|
+
body: JSON.stringify({ matcher, action })
|
|
2596
|
+
});
|
|
2597
|
+
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2598
|
+
return { _tag: "Success", data: void 0 };
|
|
2599
|
+
} catch (e2) {
|
|
2600
|
+
return { _tag: "Failure", error: e2 };
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2380
2603
|
return {
|
|
2381
2604
|
async getUpcomingOrders({ count, subscriptionId }) {
|
|
2382
2605
|
try {
|
|
@@ -2397,9 +2620,8 @@ function createApiSchedulesAdapter(fetcher) {
|
|
|
2397
2620
|
const data = await res.json();
|
|
2398
2621
|
const adjustments = data.data.map((a3) => ({
|
|
2399
2622
|
id: a3.id,
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
newDate: a3.newDate
|
|
2623
|
+
matcher: a3.matcher,
|
|
2624
|
+
action: a3.action
|
|
2403
2625
|
}));
|
|
2404
2626
|
return { _tag: "Success", data: adjustments };
|
|
2405
2627
|
} catch (e2) {
|
|
@@ -2407,50 +2629,61 @@ function createApiSchedulesAdapter(fetcher) {
|
|
|
2407
2629
|
}
|
|
2408
2630
|
},
|
|
2409
2631
|
async skipOrder({ cycle, date }) {
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
method: "POST",
|
|
2417
|
-
headers: { "Content-Type": "application/json" },
|
|
2418
|
-
body: JSON.stringify({
|
|
2419
|
-
matcher,
|
|
2420
|
-
action: { type: "SKIP_ORDER", input: { reason: "" } }
|
|
2421
|
-
})
|
|
2422
|
-
});
|
|
2423
|
-
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2424
|
-
return { _tag: "Success", data: void 0 };
|
|
2425
|
-
} catch (e2) {
|
|
2426
|
-
return { _tag: "Failure", error: e2 };
|
|
2427
|
-
}
|
|
2632
|
+
const built = buildMatcher({ cycle, date });
|
|
2633
|
+
if (!built.ok) return { _tag: "Failure", error: built.error };
|
|
2634
|
+
return postAdjustment(built.matcher, {
|
|
2635
|
+
type: "SKIP_ORDER",
|
|
2636
|
+
input: { reason: "" }
|
|
2637
|
+
});
|
|
2428
2638
|
},
|
|
2429
|
-
async changeDateAdjustment({ newDate,
|
|
2430
|
-
if (
|
|
2639
|
+
async changeDateAdjustment({ newDate, cycle }) {
|
|
2640
|
+
if (cycle == null) {
|
|
2431
2641
|
return {
|
|
2432
2642
|
_tag: "Failure",
|
|
2433
|
-
error: "
|
|
2643
|
+
error: "cycle is required for changeDateAdjustment"
|
|
2434
2644
|
};
|
|
2435
2645
|
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
method: "POST",
|
|
2440
|
-
headers: { "Content-Type": "application/json" },
|
|
2441
|
-
body: JSON.stringify({
|
|
2442
|
-
matcher,
|
|
2443
|
-
action: {
|
|
2444
|
-
type: "CHANGE_DATE",
|
|
2445
|
-
input: { newDate: new Date(newDate).toISOString() }
|
|
2446
|
-
}
|
|
2447
|
-
})
|
|
2448
|
-
});
|
|
2449
|
-
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2450
|
-
return { _tag: "Success", data: void 0 };
|
|
2451
|
-
} catch (e2) {
|
|
2452
|
-
return { _tag: "Failure", error: e2 };
|
|
2646
|
+
const newIso = toIsoOrNull(newDate);
|
|
2647
|
+
if (newIso == null) {
|
|
2648
|
+
return { _tag: "Failure", error: "newDate must be a valid date" };
|
|
2453
2649
|
}
|
|
2650
|
+
return postAdjustment(
|
|
2651
|
+
{ type: "CYCLE", input: { cycle } },
|
|
2652
|
+
{ type: "CHANGE_DATE", input: { newDate: newIso } }
|
|
2653
|
+
);
|
|
2654
|
+
},
|
|
2655
|
+
async updateShippingAdjustment({ address, cycle, date }) {
|
|
2656
|
+
const built = buildMatcher({ cycle, date });
|
|
2657
|
+
if (!built.ok) return { _tag: "Failure", error: built.error };
|
|
2658
|
+
return postAdjustment(built.matcher, {
|
|
2659
|
+
type: "UPDATE_SHIPPING",
|
|
2660
|
+
input: { address }
|
|
2661
|
+
});
|
|
2662
|
+
},
|
|
2663
|
+
async updatePaymentMethodAdjustment({ paymentMethodId, cycle, date }) {
|
|
2664
|
+
const built = buildMatcher({ cycle, date });
|
|
2665
|
+
if (!built.ok) return { _tag: "Failure", error: built.error };
|
|
2666
|
+
return postAdjustment(built.matcher, {
|
|
2667
|
+
type: "UPDATE_PAYMENT_METHOD",
|
|
2668
|
+
input: { paymentMethodId }
|
|
2669
|
+
});
|
|
2670
|
+
},
|
|
2671
|
+
async updateProductsAdjustment({ lines, cycle, date }) {
|
|
2672
|
+
const built = buildMatcher({ cycle, date });
|
|
2673
|
+
if (!built.ok) return { _tag: "Failure", error: built.error };
|
|
2674
|
+
return postAdjustment(built.matcher, {
|
|
2675
|
+
type: "UPDATE_PRODUCTS",
|
|
2676
|
+
input: { lines }
|
|
2677
|
+
});
|
|
2678
|
+
},
|
|
2679
|
+
async applyDiscountAdjustment({ discountCode, cycle }) {
|
|
2680
|
+
return postAdjustment(
|
|
2681
|
+
{ type: "CYCLE", input: { cycle } },
|
|
2682
|
+
{
|
|
2683
|
+
type: "APPLY_DISCOUNT",
|
|
2684
|
+
input: { discountSource: "code", discountCode }
|
|
2685
|
+
}
|
|
2686
|
+
);
|
|
2454
2687
|
},
|
|
2455
2688
|
async removeAdjustment({ adjustmentId }) {
|
|
2456
2689
|
try {
|
|
@@ -2518,6 +2751,34 @@ function createSchedulesService(adapter, opts) {
|
|
|
2518
2751
|
}
|
|
2519
2752
|
return result;
|
|
2520
2753
|
},
|
|
2754
|
+
async updateShippingAdjustment(params) {
|
|
2755
|
+
const result = await adapter.updateShippingAdjustment(params);
|
|
2756
|
+
if (result._tag === "Success") {
|
|
2757
|
+
await reloadCurrent(params.subscriptionId);
|
|
2758
|
+
}
|
|
2759
|
+
return result;
|
|
2760
|
+
},
|
|
2761
|
+
async updatePaymentMethodAdjustment(params) {
|
|
2762
|
+
const result = await adapter.updatePaymentMethodAdjustment(params);
|
|
2763
|
+
if (result._tag === "Success") {
|
|
2764
|
+
await reloadCurrent(params.subscriptionId);
|
|
2765
|
+
}
|
|
2766
|
+
return result;
|
|
2767
|
+
},
|
|
2768
|
+
async updateProductsAdjustment(params) {
|
|
2769
|
+
const result = await adapter.updateProductsAdjustment(params);
|
|
2770
|
+
if (result._tag === "Success") {
|
|
2771
|
+
await reloadCurrent(params.subscriptionId);
|
|
2772
|
+
}
|
|
2773
|
+
return result;
|
|
2774
|
+
},
|
|
2775
|
+
async applyDiscountAdjustment(params) {
|
|
2776
|
+
const result = await adapter.applyDiscountAdjustment(params);
|
|
2777
|
+
if (result._tag === "Success") {
|
|
2778
|
+
await reloadCurrent(params.subscriptionId);
|
|
2779
|
+
}
|
|
2780
|
+
return result;
|
|
2781
|
+
},
|
|
2521
2782
|
async removeAdjustment(params) {
|
|
2522
2783
|
return adapter.removeAdjustment(params);
|
|
2523
2784
|
},
|
|
@@ -2628,6 +2889,20 @@ function createSubscriptionService(adapter) {
|
|
|
2628
2889
|
}
|
|
2629
2890
|
return result;
|
|
2630
2891
|
},
|
|
2892
|
+
updateItemAttributes: async (subscriptionId, lineId, customAttributes) => {
|
|
2893
|
+
const result = await adapter.updateItemAttributes({ subscriptionId, lineId, customAttributes });
|
|
2894
|
+
if (result._tag === "Success") {
|
|
2895
|
+
await refreshAfterItemChange();
|
|
2896
|
+
}
|
|
2897
|
+
return result;
|
|
2898
|
+
},
|
|
2899
|
+
updateAttributes: async (subscriptionId, customAttributes) => {
|
|
2900
|
+
const result = await adapter.updateAttributes({ subscriptionId, customAttributes });
|
|
2901
|
+
if (result._tag === "Success") {
|
|
2902
|
+
await reload();
|
|
2903
|
+
}
|
|
2904
|
+
return result;
|
|
2905
|
+
},
|
|
2631
2906
|
skipLineItem: async (subscriptionId, lineId, nextBillingDate) => {
|
|
2632
2907
|
const result = await adapter.skipLineItem({ subscriptionId, lineId, nextBillingDate });
|
|
2633
2908
|
if (result._tag === "Success") {
|
|
@@ -2674,6 +2949,7 @@ function createSubscriptionService(adapter) {
|
|
|
2674
2949
|
return result;
|
|
2675
2950
|
},
|
|
2676
2951
|
reschedule: (subscriptionId, newDate) => adapter.reschedule({ subscriptionId, newDate }),
|
|
2952
|
+
updateCustomAttributes: (subscriptionId, customAttributes) => adapter.updateCustomAttributes({ subscriptionId, customAttributes }),
|
|
2677
2953
|
resume: (subscriptionId) => adapter.resume({ subscriptionId }),
|
|
2678
2954
|
pause: (subscriptionId) => adapter.pause({ subscriptionId }),
|
|
2679
2955
|
reactivate: (subscriptionId) => adapter.reactivate({ subscriptionId }),
|
|
@@ -2980,6 +3256,7 @@ export {
|
|
|
2980
3256
|
w as computed,
|
|
2981
3257
|
createApiCustomerAdapter,
|
|
2982
3258
|
createApiLoginAdapter,
|
|
3259
|
+
createApiOrdersAdapter,
|
|
2983
3260
|
createApiProductAdapter,
|
|
2984
3261
|
createApiSchedulesAdapter,
|
|
2985
3262
|
createApiSubscriptionAdapter,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApiFetcher } from '../../utils';
|
|
1
2
|
import { OrdersAdapter } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Returns a mock `OrdersAdapter` with sample orders including customAttributes.
|
|
@@ -5,4 +6,5 @@ import { OrdersAdapter } from './types';
|
|
|
5
6
|
* Used as a starting point by storybook helpers (`createMockOrdersService`) and theme preview.
|
|
6
7
|
*/
|
|
7
8
|
export declare function createMockOrdersAdapter(): OrdersAdapter;
|
|
9
|
+
export declare function createApiOrdersAdapter(fetcher: ApiFetcher): OrdersAdapter;
|
|
8
10
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/orders/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/orders/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAoB,aAAa,EAAmB,MAAM,SAAS,CAAC;AAEhF;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,CA6DvD;AAwDD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,UAAU,GAAG,aAAa,CA2BzE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { GetOrdersParams, Order, OrderLine, OrdersAdapter, OrdersService, } from './types';
|
|
2
|
-
export { createMockOrdersAdapter } from './adapter';
|
|
2
|
+
export { createMockOrdersAdapter, createApiOrdersAdapter } from './adapter';
|
|
3
3
|
export { createOrdersService, OrdersServiceContext, } from './ordersService';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/orders/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,KAAK,EACL,SAAS,EACT,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/orders/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,KAAK,EACL,SAAS,EACT,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiFetcher, Result } from '../../utils';
|
|
2
2
|
import { SubscriptionAdapter } from '../subscription/adapter';
|
|
3
3
|
import { Subscription } from '../subscription/types';
|
|
4
|
-
import { ScheduleAdjustment, ScheduleOrder } from './types';
|
|
4
|
+
import { ScheduleAdjustment, ScheduleOrder, ScheduleShippingAddressInput, ScheduleUpdateProductsLine } from './types';
|
|
5
5
|
export interface SchedulesAdapter {
|
|
6
6
|
getUpcomingOrders(params: {
|
|
7
7
|
count: number;
|
|
@@ -16,8 +16,32 @@ export interface SchedulesAdapter {
|
|
|
16
16
|
changeDateAdjustment(params: {
|
|
17
17
|
subscriptionId: string;
|
|
18
18
|
newDate: string;
|
|
19
|
+
cycle: number;
|
|
19
20
|
currentDate?: string;
|
|
20
21
|
}): Promise<Result>;
|
|
22
|
+
updateShippingAdjustment(params: {
|
|
23
|
+
subscriptionId: string;
|
|
24
|
+
address: ScheduleShippingAddressInput;
|
|
25
|
+
cycle?: number;
|
|
26
|
+
date?: string;
|
|
27
|
+
}): Promise<Result>;
|
|
28
|
+
updatePaymentMethodAdjustment(params: {
|
|
29
|
+
subscriptionId: string;
|
|
30
|
+
paymentMethodId: string;
|
|
31
|
+
cycle?: number;
|
|
32
|
+
date?: string;
|
|
33
|
+
}): Promise<Result>;
|
|
34
|
+
updateProductsAdjustment(params: {
|
|
35
|
+
subscriptionId: string;
|
|
36
|
+
lines: ScheduleUpdateProductsLine[];
|
|
37
|
+
cycle?: number;
|
|
38
|
+
date?: string;
|
|
39
|
+
}): Promise<Result>;
|
|
40
|
+
applyDiscountAdjustment(params: {
|
|
41
|
+
subscriptionId: string;
|
|
42
|
+
discountCode: string;
|
|
43
|
+
cycle: number;
|
|
44
|
+
}): Promise<Result>;
|
|
21
45
|
removeAdjustment(params: {
|
|
22
46
|
adjustmentId: string;
|
|
23
47
|
}): Promise<Result>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAiC,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAiC,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,kBAAkB,EAElB,aAAa,EAEb,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,CAAC,MAAM,EAAE;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACrC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;IACxD,SAAS,CAAC,MAAM,EAAE;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,oBAAoB,CAAC,MAAM,EAAE;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAA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AAa,GAAE,kBAAoD,GAClE,gBAAgB,CA0KlB;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAyI/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedulesService.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/schedulesService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,uBAAuB;;CACmB,CAAC;AAExD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;CAAE,GAC7C,WAAW,CAAC,OAAO,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"schedulesService.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/schedulesService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE/D,eAAO,MAAM,uBAAuB;;CACmB,CAAC;AAExD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;CAAE,GAC7C,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAmH7C"}
|
|
@@ -21,9 +21,9 @@ export interface ScheduleOrderItem {
|
|
|
21
21
|
parentLineId?: string | null;
|
|
22
22
|
isVirtual?: boolean;
|
|
23
23
|
isUpsell?: boolean;
|
|
24
|
-
|
|
24
|
+
recurringCycleLimit?: number | null;
|
|
25
25
|
customAttributes?: {
|
|
26
|
-
|
|
26
|
+
key: string;
|
|
27
27
|
value: string;
|
|
28
28
|
}[];
|
|
29
29
|
sellingPlanId?: string | null;
|
|
@@ -43,12 +43,103 @@ export interface ScheduleOrderDiscount {
|
|
|
43
43
|
type: "percentage" | "fixed_amount";
|
|
44
44
|
value: number;
|
|
45
45
|
}
|
|
46
|
+
export type ScheduleInterval = "DAY" | "WEEK" | "MONTH" | "YEAR";
|
|
47
|
+
/**
|
|
48
|
+
* Selects which order(s) an adjustment applies to. Mirrors the Customer API
|
|
49
|
+
* matcher union (`POST /customer/v1/schedules/adjustments`). Adjustments are
|
|
50
|
+
* customer-scoped — matched by billing cycle and/or date, not subscription id.
|
|
51
|
+
*/
|
|
52
|
+
export type ScheduleAdjustmentMatcher = {
|
|
53
|
+
type: "CYCLE";
|
|
54
|
+
input: {
|
|
55
|
+
cycle: number;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
type: "DATE";
|
|
59
|
+
input: {
|
|
60
|
+
date: string;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
type: "CYCLE_AND_DATE";
|
|
64
|
+
input: {
|
|
65
|
+
cycle: number;
|
|
66
|
+
date: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/** Address input for the `UPDATE_SHIPPING` adjustment action. */
|
|
70
|
+
export interface ScheduleShippingAddressInput {
|
|
71
|
+
firstName?: string | null;
|
|
72
|
+
lastName?: string | null;
|
|
73
|
+
address1?: string | null;
|
|
74
|
+
address2?: string | null;
|
|
75
|
+
zip?: string | null;
|
|
76
|
+
city?: string | null;
|
|
77
|
+
countryCode?: string | null;
|
|
78
|
+
provinceCode?: string | null;
|
|
79
|
+
phone?: string | null;
|
|
80
|
+
company?: string | null;
|
|
81
|
+
}
|
|
82
|
+
/** Per-line input for the `UPDATE_PRODUCTS` adjustment action. */
|
|
83
|
+
export interface ScheduleUpdateProductsLine {
|
|
84
|
+
lineId: string;
|
|
85
|
+
variantId?: string;
|
|
86
|
+
quantity?: number;
|
|
87
|
+
interval?: {
|
|
88
|
+
intervalCount: number;
|
|
89
|
+
interval: ScheduleInterval;
|
|
90
|
+
};
|
|
91
|
+
nextBillingDate?: string;
|
|
92
|
+
customAttributes?: {
|
|
93
|
+
key: string;
|
|
94
|
+
value: string;
|
|
95
|
+
}[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* What an adjustment does to the matched order(s). Mirrors the Customer API
|
|
99
|
+
* action union. `APPLY_DISCOUNT` is code-only here — the manual-discount variant
|
|
100
|
+
* is Admin-API only and intentionally not surfaced to the customer portal.
|
|
101
|
+
*/
|
|
102
|
+
export type ScheduleAdjustmentAction = {
|
|
103
|
+
type: "SKIP_ORDER";
|
|
104
|
+
input: {
|
|
105
|
+
reason: string;
|
|
106
|
+
};
|
|
107
|
+
} | {
|
|
108
|
+
type: "CHANGE_DATE";
|
|
109
|
+
input: {
|
|
110
|
+
newDate: string;
|
|
111
|
+
};
|
|
112
|
+
} | {
|
|
113
|
+
type: "UPDATE_SHIPPING";
|
|
114
|
+
input: {
|
|
115
|
+
address: ScheduleShippingAddressInput;
|
|
116
|
+
};
|
|
117
|
+
} | {
|
|
118
|
+
type: "UPDATE_PAYMENT_METHOD";
|
|
119
|
+
input: {
|
|
120
|
+
paymentMethodId: string;
|
|
121
|
+
};
|
|
122
|
+
} | {
|
|
123
|
+
type: "UPDATE_PRODUCTS";
|
|
124
|
+
input: {
|
|
125
|
+
lines: ScheduleUpdateProductsLine[];
|
|
126
|
+
};
|
|
127
|
+
} | {
|
|
128
|
+
type: "APPLY_DISCOUNT";
|
|
129
|
+
input: {
|
|
130
|
+
discountSource: "code";
|
|
131
|
+
discountCode: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* A persisted schedule adjustment as returned by the Customer API. Carries the
|
|
136
|
+
* full `matcher`/`action` pair so every action type round-trips — not just
|
|
137
|
+
* skip/date-change.
|
|
138
|
+
*/
|
|
46
139
|
export interface ScheduleAdjustment {
|
|
47
140
|
id: string;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
cycle?: number;
|
|
51
|
-
newDate?: string;
|
|
141
|
+
matcher: ScheduleAdjustmentMatcher;
|
|
142
|
+
action: ScheduleAdjustmentAction;
|
|
52
143
|
}
|
|
53
144
|
export interface ScheduleOrder {
|
|
54
145
|
id: string;
|
|
@@ -75,17 +166,51 @@ export interface SchedulesService {
|
|
|
75
166
|
getUpcomingOrder(): Promise<Result<ScheduleOrder | null>>;
|
|
76
167
|
getUpcomingOrders(count: number): Promise<Result<ScheduleOrder[]>>;
|
|
77
168
|
getAdjustments(): Promise<Result<ScheduleAdjustment[]>>;
|
|
78
|
-
/** Adjustment. */
|
|
169
|
+
/** Adjustment — skip the matched order. Matcher: CYCLE or DATE. */
|
|
79
170
|
skipOrder(params: {
|
|
80
171
|
subscriptionId: string;
|
|
81
172
|
cycle?: number;
|
|
82
173
|
date?: string;
|
|
83
174
|
}): Promise<Result>;
|
|
175
|
+
/**
|
|
176
|
+
* Reschedule the matched order. Backend requires a CYCLE matcher, so `cycle`
|
|
177
|
+
* is required and enforced at runtime by both adapters; `currentDate` is kept
|
|
178
|
+
* only to resolve the cycle in the mock adapter and is ignored by the API
|
|
179
|
+
* adapter.
|
|
180
|
+
*/
|
|
84
181
|
changeDateAdjustment(params: {
|
|
85
182
|
subscriptionId: string;
|
|
86
183
|
newDate: string;
|
|
184
|
+
cycle: number;
|
|
87
185
|
currentDate?: string;
|
|
88
186
|
}): Promise<Result>;
|
|
187
|
+
/** Adjustment — override the shipping address for the matched order. */
|
|
188
|
+
updateShippingAdjustment(params: {
|
|
189
|
+
subscriptionId: string;
|
|
190
|
+
address: ScheduleShippingAddressInput;
|
|
191
|
+
cycle?: number;
|
|
192
|
+
date?: string;
|
|
193
|
+
}): Promise<Result>;
|
|
194
|
+
/** Adjustment — use a different payment method for the matched order. */
|
|
195
|
+
updatePaymentMethodAdjustment(params: {
|
|
196
|
+
subscriptionId: string;
|
|
197
|
+
paymentMethodId: string;
|
|
198
|
+
cycle?: number;
|
|
199
|
+
date?: string;
|
|
200
|
+
}): Promise<Result>;
|
|
201
|
+
/** Adjustment — swap variant / change quantity / interval on order lines. */
|
|
202
|
+
updateProductsAdjustment(params: {
|
|
203
|
+
subscriptionId: string;
|
|
204
|
+
lines: ScheduleUpdateProductsLine[];
|
|
205
|
+
cycle?: number;
|
|
206
|
+
date?: string;
|
|
207
|
+
}): Promise<Result>;
|
|
208
|
+
/** Adjustment — apply a discount code. Backend requires a CYCLE matcher. */
|
|
209
|
+
applyDiscountAdjustment(params: {
|
|
210
|
+
subscriptionId: string;
|
|
211
|
+
discountCode: string;
|
|
212
|
+
cycle: number;
|
|
213
|
+
}): Promise<Result>;
|
|
89
214
|
removeAdjustment(params: {
|
|
90
215
|
adjustmentId: string;
|
|
91
216
|
}): Promise<Result>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/schedules/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,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,CA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AM,CAAC,CAAC;IACpB,6EAA6E;IAC7E,wBAAwB,CAAC,MAAM,EAAE;QAC/B,cAAc,EAAE,MAAM,CAAC;QACvB,KAAK,EAAE,0BAA0B,EAAE,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,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"}
|
|
@@ -45,6 +45,15 @@ export interface SubscriptionAdapter {
|
|
|
45
45
|
items: UpdateBoxItem[];
|
|
46
46
|
shippingMethodHandle?: string;
|
|
47
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>;
|
|
48
57
|
addDiscount(params: {
|
|
49
58
|
subscriptionId: string;
|
|
50
59
|
code: string;
|
|
@@ -57,6 +66,16 @@ export interface SubscriptionAdapter {
|
|
|
57
66
|
subscriptionId: string;
|
|
58
67
|
newDate: string;
|
|
59
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>>;
|
|
60
79
|
resume(params: {
|
|
61
80
|
subscriptionId: string;
|
|
62
81
|
}): Promise<Result<Subscription>>;
|
|
@@ -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;AAC1B,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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AAC;IAG3D,iBAAiB,CAAC,CAAC,MAAM,EAAE;QACzB,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IAErC,gBAAgB,CAAC,CAAC,MAAM,EAAE;QACxB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,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;
|
|
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,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CAAC,CAAC,CAAC;IAErC,gBAAgB,CAAC,CAAC,MAAM,EAAE;QACxB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,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;AAwHD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,UAAU,GAClB,mBAAmB,CAqdrB"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAsLrB"}
|
|
@@ -20,11 +20,7 @@ export interface SubscriptionItem {
|
|
|
20
20
|
/** Human-readable product/line title (legacy line.title). */
|
|
21
21
|
title?: string;
|
|
22
22
|
variantTitle?: string;
|
|
23
|
-
|
|
24
|
-
* True when recurringCycleLimit === 1 (item charges exactly once).
|
|
25
|
-
* Populated by the real adapter from the customer v1 API response.
|
|
26
|
-
*/
|
|
27
|
-
isOneTime?: boolean;
|
|
23
|
+
recurringCycleLimit?: number | null;
|
|
28
24
|
/** Box grouping: parent subscription LINE id (primary) and parent PRODUCT id (fallback). */
|
|
29
25
|
parentLineId?: string;
|
|
30
26
|
parentProductId?: string;
|
|
@@ -273,6 +269,8 @@ export type SubscriptionService = {
|
|
|
273
269
|
addItem(subscriptionId: string, item: PostableSubscriptionItem): Promise<Result>;
|
|
274
270
|
removeItem(subscriptionId: string, itemId: string): Promise<Result>;
|
|
275
271
|
updateItem(subscriptionId: string, lineId: string, update: UpdateSubscriptionItem): Promise<Result>;
|
|
272
|
+
updateItemAttributes(subscriptionId: string, lineId: string, customAttributes: Record<string, string>): Promise<Result>;
|
|
273
|
+
updateAttributes(subscriptionId: string, customAttributes: Record<string, string>): Promise<Result>;
|
|
276
274
|
skipLineItem(subscriptionId: string, lineId: string, nextBillingDate: string): Promise<Result>;
|
|
277
275
|
updateBoxItems(subscriptionId: string, params: {
|
|
278
276
|
parentId: string;
|
|
@@ -288,6 +286,12 @@ export type SubscriptionService = {
|
|
|
288
286
|
oneTime?: boolean;
|
|
289
287
|
}): Promise<Result>;
|
|
290
288
|
reschedule(subscriptionId: string, newDate: string): Promise<Result<Subscription>>;
|
|
289
|
+
/**
|
|
290
|
+
* Replace the subscription's customer-visible custom attributes. `customAttributes`
|
|
291
|
+
* is the complete desired set — omitted keys are removed. Internal (`_`-prefixed) /
|
|
292
|
+
* reserved keys are preserved server-side and must not be included.
|
|
293
|
+
*/
|
|
294
|
+
updateCustomAttributes(subscriptionId: string, customAttributes: Record<string, string>): Promise<Result<Subscription>>;
|
|
291
295
|
resume(subscriptionId: string): Promise<Result<Subscription>>;
|
|
292
296
|
pause(subscriptionId: string): Promise<Result<Subscription>>;
|
|
293
297
|
reactivate(subscriptionId: string): Promise<Result<Subscription>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,iBAAiB,CAAC;IACzB,gBAAgB,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;I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