@cimplify/sdk 0.44.16 → 0.44.19
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/advanced.js +22 -21
- package/dist/advanced.mjs +3 -2
- package/dist/{chunk-MBGQP6FZ.js → chunk-3FS3ZDKX.js} +60 -60
- package/dist/{chunk-UXLQ7WXI.mjs → chunk-5OK3YDZC.mjs} +2 -2
- package/dist/{chunk-MNIKXG7W.js → chunk-BN2CXGMO.js} +5 -272
- package/dist/chunk-GLOO4HUN.mjs +676 -0
- package/dist/{chunk-CFD4J32N.js → chunk-HBRCVJL4.js} +22 -21
- package/dist/{chunk-ZLEFMQC6.mjs → chunk-KSKZAXG2.mjs} +4 -498
- package/dist/{chunk-6AZZ6AOF.mjs → chunk-NRT6PVW5.mjs} +4 -251
- package/dist/{chunk-XL4CX75J.js → chunk-PGSM3NQ2.js} +237 -781
- package/dist/chunk-Q4I7JRGO.js +733 -0
- package/dist/chunk-QBQCMQ4F.js +271 -0
- package/dist/chunk-XPXAZXF2.mjs +250 -0
- package/dist/{chunk-7NML226B.mjs → chunk-XZPO5GEM.mjs} +2 -1
- package/dist/client-B_Ei3ENB.d.mts +86 -0
- package/dist/client-Bep2FooI.d.ts +86 -0
- package/dist/index.js +145 -144
- package/dist/index.mjs +4 -3
- package/dist/mock/cli.mjs +2 -0
- package/dist/mock/library.js +2 -0
- package/dist/mock/library.mjs +2 -0
- package/dist/mock/msw.js +2 -0
- package/dist/mock/msw.mjs +2 -0
- package/dist/react.js +81 -80
- package/dist/react.mjs +4 -3
- package/dist/server.js +6 -5
- package/dist/server.mjs +4 -3
- package/dist/testing/msw.d.mts +17 -0
- package/dist/testing/msw.d.ts +17 -0
- package/dist/testing/msw.js +42 -0
- package/dist/testing/msw.mjs +40 -0
- package/dist/testing/suite.d.mts +25 -0
- package/dist/testing/suite.d.ts +25 -0
- package/dist/testing/suite.js +28 -23
- package/dist/testing/suite.mjs +9 -4
- package/dist/testing.d.mts +963 -135
- package/dist/testing.d.ts +963 -135
- package/dist/testing.js +123 -59
- package/dist/testing.mjs +51 -4
- package/dist/utils.js +29 -28
- package/dist/utils.mjs +2 -1
- package/package.json +11 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBN2CXGMO_js = require('./chunk-BN2CXGMO.js');
|
|
4
|
+
var chunkQBQCMQ4F_js = require('./chunk-QBQCMQ4F.js');
|
|
4
5
|
|
|
5
6
|
// src/types/result.ts
|
|
6
7
|
function ok(value) {
|
|
@@ -84,11 +85,11 @@ function generateIdempotencyKey(prefix = "idem") {
|
|
|
84
85
|
|
|
85
86
|
// src/internal/safe.ts
|
|
86
87
|
function toCimplifyError(error) {
|
|
87
|
-
if (error instanceof
|
|
88
|
+
if (error instanceof chunkQBQCMQ4F_js.CimplifyError) return chunkQBQCMQ4F_js.enrichError(error);
|
|
88
89
|
if (error instanceof Error) {
|
|
89
|
-
return
|
|
90
|
+
return chunkQBQCMQ4F_js.enrichError(new chunkQBQCMQ4F_js.CimplifyError(chunkQBQCMQ4F_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
|
|
90
91
|
}
|
|
91
|
-
return
|
|
92
|
+
return chunkQBQCMQ4F_js.enrichError(new chunkQBQCMQ4F_js.CimplifyError(chunkQBQCMQ4F_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
|
|
92
93
|
}
|
|
93
94
|
async function safe(promise) {
|
|
94
95
|
try {
|
|
@@ -647,7 +648,7 @@ var CartOperations = class {
|
|
|
647
648
|
if (typeof updates.quantity !== "number") {
|
|
648
649
|
return {
|
|
649
650
|
ok: false,
|
|
650
|
-
error: new
|
|
651
|
+
error: new chunkQBQCMQ4F_js.CimplifyError(
|
|
651
652
|
"VALIDATION_ERROR",
|
|
652
653
|
"updateItem requires a quantity; richer mid-cart edits are not supported"
|
|
653
654
|
)
|
|
@@ -1089,7 +1090,7 @@ var CheckoutResolver = class {
|
|
|
1089
1090
|
}
|
|
1090
1091
|
}
|
|
1091
1092
|
}
|
|
1092
|
-
if (checkoutResult.requires_authorization ||
|
|
1093
|
+
if (checkoutResult.requires_authorization || chunkBN2CXGMO_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
|
|
1093
1094
|
const authorization = await this.handleAuthorization({
|
|
1094
1095
|
authorizationType,
|
|
1095
1096
|
paymentReference,
|
|
@@ -1263,18 +1264,18 @@ var CheckoutResolver = class {
|
|
|
1263
1264
|
if (statusResult.value.reference) {
|
|
1264
1265
|
paymentReference = statusResult.value.reference;
|
|
1265
1266
|
}
|
|
1266
|
-
const normalized =
|
|
1267
|
-
if (normalized.paid ||
|
|
1267
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse(statusResult.value);
|
|
1268
|
+
if (normalized.paid || chunkBN2CXGMO_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1268
1269
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1269
1270
|
}
|
|
1270
|
-
if (
|
|
1271
|
+
if (chunkBN2CXGMO_js.isPaymentStatusFailure(normalized.status)) {
|
|
1271
1272
|
return this.fail(
|
|
1272
1273
|
normalized.status ? normalized.status.toUpperCase() : "PAYMENT_FAILED",
|
|
1273
1274
|
normalized.message || "Payment failed during confirmation.",
|
|
1274
1275
|
false
|
|
1275
1276
|
);
|
|
1276
1277
|
}
|
|
1277
|
-
if (
|
|
1278
|
+
if (chunkBN2CXGMO_js.isPaymentStatusRequiresAction(normalized.status)) {
|
|
1278
1279
|
const authorization = await this.handleAuthorization({
|
|
1279
1280
|
authorizationType,
|
|
1280
1281
|
paymentReference,
|
|
@@ -1305,8 +1306,8 @@ var CheckoutResolver = class {
|
|
|
1305
1306
|
try {
|
|
1306
1307
|
const finalResult = await this.client.checkout.pollPaymentStatus(input.orderId);
|
|
1307
1308
|
if (finalResult.ok) {
|
|
1308
|
-
const normalized =
|
|
1309
|
-
if (normalized.paid ||
|
|
1309
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse(finalResult.value);
|
|
1310
|
+
if (normalized.paid || chunkBN2CXGMO_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1310
1311
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1311
1312
|
}
|
|
1312
1313
|
}
|
|
@@ -1502,12 +1503,12 @@ var CheckoutResolver = class {
|
|
|
1502
1503
|
};
|
|
1503
1504
|
}
|
|
1504
1505
|
isSuccessfulStatus(status) {
|
|
1505
|
-
const normalized =
|
|
1506
|
-
return normalized.paid ||
|
|
1506
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse({ status, paid: false });
|
|
1507
|
+
return normalized.paid || chunkBN2CXGMO_js.isPaymentStatusSuccess(normalized.status);
|
|
1507
1508
|
}
|
|
1508
1509
|
isFailureStatus(status) {
|
|
1509
|
-
const normalized =
|
|
1510
|
-
return
|
|
1510
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse({ status, paid: false });
|
|
1511
|
+
return chunkBN2CXGMO_js.isPaymentStatusFailure(normalized.status);
|
|
1511
1512
|
}
|
|
1512
1513
|
ensureNotAborted() {
|
|
1513
1514
|
if (this.signal?.aborted) {
|
|
@@ -1570,7 +1571,7 @@ var CheckoutService = class {
|
|
|
1570
1571
|
}
|
|
1571
1572
|
async initializePayment(_orderId, _method) {
|
|
1572
1573
|
return err(
|
|
1573
|
-
new
|
|
1574
|
+
new chunkQBQCMQ4F_js.CimplifyError(
|
|
1574
1575
|
"NOT_IMPLEMENTED",
|
|
1575
1576
|
"initializePayment is not available in REST mode.",
|
|
1576
1577
|
false
|
|
@@ -1642,11 +1643,11 @@ var CheckoutService = class {
|
|
|
1642
1643
|
pay_currency: data.pay_currency,
|
|
1643
1644
|
fx_quote_id: data.fx_quote_id
|
|
1644
1645
|
};
|
|
1645
|
-
const baseCurrency =
|
|
1646
|
+
const baseCurrency = chunkQBQCMQ4F_js.currencyCode(
|
|
1646
1647
|
(cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
|
|
1647
1648
|
);
|
|
1648
1649
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
1649
|
-
const payCurrencyCode = payCurrency ?
|
|
1650
|
+
const payCurrencyCode = payCurrency ? chunkQBQCMQ4F_js.currencyCode(payCurrency) : void 0;
|
|
1650
1651
|
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
1651
1652
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
1652
1653
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
@@ -2004,7 +2005,7 @@ var BusinessService = class {
|
|
|
2004
2005
|
if (!result.ok) return err(result.error);
|
|
2005
2006
|
const location = result.value.find((item) => item.id === locationId);
|
|
2006
2007
|
if (!location) {
|
|
2007
|
-
return err(new
|
|
2008
|
+
return err(new chunkQBQCMQ4F_js.CimplifyError(chunkQBQCMQ4F_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
|
|
2008
2009
|
}
|
|
2009
2010
|
return ok(location);
|
|
2010
2011
|
}
|
|
@@ -2290,7 +2291,7 @@ var EVENT_TYPES = {
|
|
|
2290
2291
|
|
|
2291
2292
|
// src/elements.ts
|
|
2292
2293
|
function toCheckoutError(code, message, recoverable) {
|
|
2293
|
-
const hint =
|
|
2294
|
+
const hint = chunkQBQCMQ4F_js.getErrorHint(code);
|
|
2294
2295
|
return {
|
|
2295
2296
|
success: false,
|
|
2296
2297
|
error: {
|
|
@@ -1,387 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { __publicField, __privateAdd, __privateSet, __privateGet, __privateMethod, ErrorCode, __privateWrapper } from './chunk-6AZZ6AOF.mjs';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
var SCHEMA_VERSION = "2026-05-07.1";
|
|
6
|
-
var MoneySchema = z.string().regex(/^-?\d+\.\d{2}$/, 'Money must be a decimal string with exactly 2 decimals (e.g. "12.50")');
|
|
7
|
-
var MoneyLooseSchema = z.string().regex(/^-?\d+(\.\d+)?$/, "Must be a decimal string");
|
|
8
|
-
var IsoDateTimeSchema = z.iso.datetime();
|
|
9
|
-
var TimestampSchema = z.union([z.iso.datetime(), z.string().min(1)]);
|
|
10
|
-
var CurrencyCodeSchema = z.string().length(3, "currency must be a 3-letter ISO 4217 code").regex(/^[A-Z]{3}$/, "currency must be uppercase letters");
|
|
11
|
-
var CountryCodeSchema = z.string().length(2, "countryCode must be ISO 3166-1 alpha-2").regex(/^[A-Z]{2}$/, "countryCode must be uppercase letters");
|
|
12
|
-
var LocaleSchema = z.string().regex(/^[a-z]{2}(_[A-Z]{2})?$/, "locale must look like 'en' or 'en_GH'");
|
|
13
|
-
var PhoneE164Schema = z.string().regex(/^\+?[0-9]{7,15}$/, "phoneTel should be E.164-ish digits (7\u201315)");
|
|
14
|
-
var SeedNameSchema = z.enum([
|
|
15
|
-
"default",
|
|
16
|
-
"empty",
|
|
17
|
-
"reesa-storefront",
|
|
18
|
-
"restaurant",
|
|
19
|
-
"retail",
|
|
20
|
-
"services",
|
|
21
|
-
"grocery",
|
|
22
|
-
"fashion"
|
|
23
|
-
]);
|
|
24
|
-
var ProductTypeSchema = z.enum([
|
|
25
|
-
"product",
|
|
26
|
-
"service",
|
|
27
|
-
"digital",
|
|
28
|
-
"bundle",
|
|
29
|
-
"composite"
|
|
30
|
-
]);
|
|
31
|
-
var LineTypeSchema = z.enum([
|
|
32
|
-
"simple",
|
|
33
|
-
"service",
|
|
34
|
-
"digital",
|
|
35
|
-
"bundle",
|
|
36
|
-
"composite"
|
|
37
|
-
]);
|
|
38
|
-
var ServiceStatusSchema = z.enum(["pending", "confirmed", "completed", "cancelled"]);
|
|
39
|
-
function makeAssertion(schema, label) {
|
|
40
|
-
return (value) => {
|
|
41
|
-
const result = schema.safeParse(value);
|
|
42
|
-
if (!result.success) {
|
|
43
|
-
const issues = result.error.issues.map((i) => ` \u2022 ${label}.${i.path.join(".")}: ${i.message}`).join("\n");
|
|
44
|
-
throw new SchemaViolationError(
|
|
45
|
-
`${label} schema violation:
|
|
46
|
-
${issues}`,
|
|
47
|
-
result.error.issues.map((i) => ({ path: i.path.map(String), message: i.message }))
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
var SchemaViolationError = class extends Error {
|
|
53
|
-
constructor(message, issues) {
|
|
54
|
-
super(message);
|
|
55
|
-
this.issues = issues;
|
|
56
|
-
this.name = "SchemaViolationError";
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var BrandSocialSchema = z.object({
|
|
60
|
-
label: z.string().min(1),
|
|
61
|
-
href: z.string().url(),
|
|
62
|
-
icon: z.string().optional()
|
|
63
|
-
});
|
|
64
|
-
var BrandNavLinkSchema = z.object({
|
|
65
|
-
label: z.string().min(1),
|
|
66
|
-
href: z.string().min(1)
|
|
67
|
-
});
|
|
68
|
-
var BrandPolicySectionSchema = z.object({
|
|
69
|
-
heading: z.string().min(1),
|
|
70
|
-
body: z.union([
|
|
71
|
-
z.string().min(1),
|
|
72
|
-
z.object({ intro: z.string(), bullets: z.array(z.string()).min(1) })
|
|
73
|
-
])
|
|
74
|
-
});
|
|
75
|
-
var BrandPolicyPageSchema = z.object({
|
|
76
|
-
eyebrow: z.string(),
|
|
77
|
-
title: z.string().min(1),
|
|
78
|
-
lastUpdated: z.string().min(1),
|
|
79
|
-
sections: z.array(BrandPolicySectionSchema).min(1)
|
|
80
|
-
});
|
|
81
|
-
var BrandContactSchema = z.object({
|
|
82
|
-
email: z.string().email(),
|
|
83
|
-
phone: z.string().min(1),
|
|
84
|
-
phoneTel: PhoneE164Schema,
|
|
85
|
-
streetAddress: z.string().min(1),
|
|
86
|
-
city: z.string().min(1),
|
|
87
|
-
countryCode: CountryCodeSchema,
|
|
88
|
-
hours: z.string().optional()
|
|
89
|
-
});
|
|
90
|
-
var BrandHeroSchema = z.object({
|
|
91
|
-
badge: z.string().optional(),
|
|
92
|
-
title: z.string().min(1),
|
|
93
|
-
subtitle: z.string().min(1),
|
|
94
|
-
primaryCta: BrandNavLinkSchema.optional(),
|
|
95
|
-
secondaryCta: BrandNavLinkSchema.optional()
|
|
96
|
-
});
|
|
97
|
-
var BrandFaqSchema = z.object({
|
|
98
|
-
eyebrow: z.string().optional(),
|
|
99
|
-
title: z.string().min(1),
|
|
100
|
-
sections: z.array(
|
|
101
|
-
z.object({
|
|
102
|
-
title: z.string(),
|
|
103
|
-
items: z.array(z.object({ q: z.string(), a: z.string() }))
|
|
104
|
-
})
|
|
105
|
-
)
|
|
106
|
-
});
|
|
107
|
-
var BrandSchema = z.object({
|
|
108
|
-
// Identity
|
|
109
|
-
name: z.string().min(1),
|
|
110
|
-
shortName: z.string().min(1),
|
|
111
|
-
microTag: z.string(),
|
|
112
|
-
description: z.string().min(20, "description should be at least 20 characters"),
|
|
113
|
-
schemaType: z.string().min(1),
|
|
114
|
-
currency: CurrencyCodeSchema,
|
|
115
|
-
locale: LocaleSchema,
|
|
116
|
-
contact: BrandContactSchema,
|
|
117
|
-
socials: z.array(BrandSocialSchema),
|
|
118
|
-
header: z.object({ nav: z.array(BrandNavLinkSchema).min(1) }),
|
|
119
|
-
hero: BrandHeroSchema,
|
|
120
|
-
// Optional sections — render conditionally when present
|
|
121
|
-
trustItems: z.array(z.object({ title: z.string().min(1), body: z.string().min(1) })).optional(),
|
|
122
|
-
brandStrip: z.object({ headline: z.string(), logos: z.array(z.string()).min(1) }).optional(),
|
|
123
|
-
promo: z.object({
|
|
124
|
-
eyebrow: z.string().optional(),
|
|
125
|
-
title: z.string().min(1),
|
|
126
|
-
cta: BrandNavLinkSchema
|
|
127
|
-
}).optional(),
|
|
128
|
-
// Standalone policy pages
|
|
129
|
-
terms: BrandPolicyPageSchema,
|
|
130
|
-
privacy: BrandPolicyPageSchema,
|
|
131
|
-
shipping: BrandPolicyPageSchema,
|
|
132
|
-
returns: BrandPolicyPageSchema,
|
|
133
|
-
accessibility: BrandPolicyPageSchema,
|
|
134
|
-
// Misc
|
|
135
|
-
newsletter: z.object({
|
|
136
|
-
eyebrow: z.string().optional(),
|
|
137
|
-
title: z.string().min(1),
|
|
138
|
-
body: z.string()
|
|
139
|
-
}),
|
|
140
|
-
about: z.object({
|
|
141
|
-
eyebrow: z.string().optional(),
|
|
142
|
-
title: z.string().min(1),
|
|
143
|
-
body: z.union([z.string(), z.array(z.string())])
|
|
144
|
-
}),
|
|
145
|
-
faq: BrandFaqSchema,
|
|
146
|
-
account: z.object({
|
|
147
|
-
eyebrow: z.string().optional(),
|
|
148
|
-
title: z.string().min(1),
|
|
149
|
-
signin: z.object({ eyebrow: z.string().optional(), title: z.string().min(1) }).optional(),
|
|
150
|
-
signup: z.object({ eyebrow: z.string().optional(), title: z.string().min(1) }).optional()
|
|
151
|
-
}),
|
|
152
|
-
contactPage: z.object({
|
|
153
|
-
eyebrow: z.string().optional(),
|
|
154
|
-
title: z.string().min(1),
|
|
155
|
-
body: z.string()
|
|
156
|
-
}),
|
|
157
|
-
trackOrder: z.object({
|
|
158
|
-
eyebrow: z.string().optional(),
|
|
159
|
-
title: z.string().min(1),
|
|
160
|
-
body: z.string()
|
|
161
|
-
}),
|
|
162
|
-
footer: z.object({
|
|
163
|
-
sitemap: z.array(z.unknown()).optional(),
|
|
164
|
-
poweredBy: z.string().optional()
|
|
165
|
-
}),
|
|
166
|
-
llms: z.object({ summary: z.string().min(20) }),
|
|
167
|
-
mock: z.object({
|
|
168
|
-
seed: SeedNameSchema,
|
|
169
|
-
businessId: z.string().regex(/^bus_/, "businessId should start with 'bus_'")
|
|
170
|
-
})
|
|
171
|
-
});
|
|
172
|
-
var assertBrand = makeAssertion(BrandSchema, "brand");
|
|
173
|
-
var BundleSelectionInputSchema = z.object({
|
|
174
|
-
component_id: z.string(),
|
|
175
|
-
variant_id: z.string().optional(),
|
|
176
|
-
quantity: z.number().int().positive(),
|
|
177
|
-
scheduled_start: z.string().optional(),
|
|
178
|
-
scheduled_end: z.string().optional()
|
|
179
|
-
});
|
|
180
|
-
var CompositeSelectionInputSchema = z.object({
|
|
181
|
-
component_id: z.string().optional(),
|
|
182
|
-
source_product_id: z.string().optional(),
|
|
183
|
-
source_stock_id: z.string().optional(),
|
|
184
|
-
source_type: z.enum(["product", "stock", "add_on", "standalone"]).optional(),
|
|
185
|
-
quantity: z.number().int().positive().optional()
|
|
186
|
-
});
|
|
187
|
-
var CustomerInputValueSchema = z.object({
|
|
188
|
-
field_id: z.string(),
|
|
189
|
-
field_name: z.string().optional(),
|
|
190
|
-
field_type: z.string().optional(),
|
|
191
|
-
value: z.unknown()
|
|
192
|
-
});
|
|
193
|
-
var AddItemPayloadSchema = z.object({
|
|
194
|
-
item_id: z.string().min(1),
|
|
195
|
-
quantity: z.number().int().positive(),
|
|
196
|
-
variant_id: z.string().optional(),
|
|
197
|
-
quote_id: z.string().optional(),
|
|
198
|
-
add_on_options: z.array(z.string()).optional(),
|
|
199
|
-
bundle_selections: z.array(BundleSelectionInputSchema).optional(),
|
|
200
|
-
composite_selections: z.array(CompositeSelectionInputSchema).optional(),
|
|
201
|
-
scheduled_start: z.string().optional(),
|
|
202
|
-
scheduled_end: z.string().optional(),
|
|
203
|
-
staff_id: z.string().optional(),
|
|
204
|
-
resource_id: z.string().optional(),
|
|
205
|
-
special_instructions: z.string().optional(),
|
|
206
|
-
customer_inputs: z.array(CustomerInputValueSchema).optional(),
|
|
207
|
-
billing_plan_id: z.string().optional(),
|
|
208
|
-
metadata: z.record(z.string(), z.unknown()).optional()
|
|
209
|
-
});
|
|
210
|
-
var assertAddItemPayload = makeAssertion(AddItemPayloadSchema, "payload");
|
|
211
|
-
var VariantDisplayAttributeSchema = z.object({
|
|
212
|
-
axis_id: z.string(),
|
|
213
|
-
axis_name: z.string(),
|
|
214
|
-
value_id: z.string(),
|
|
215
|
-
value_name: z.string()
|
|
216
|
-
});
|
|
217
|
-
var VariantInfoSchema = z.object({
|
|
218
|
-
id: z.string(),
|
|
219
|
-
name: z.string(),
|
|
220
|
-
sku: z.string().optional(),
|
|
221
|
-
price_adjustment: MoneySchema,
|
|
222
|
-
display_attributes: z.array(VariantDisplayAttributeSchema).optional(),
|
|
223
|
-
images: z.array(z.string()).optional()
|
|
224
|
-
});
|
|
225
|
-
var VariantDetailsSchema = z.object({
|
|
226
|
-
variant_id: z.string(),
|
|
227
|
-
sku: z.string().optional(),
|
|
228
|
-
properties: z.record(z.string(), z.string())
|
|
229
|
-
});
|
|
230
|
-
var ChosenPriceSchema = z.object({
|
|
231
|
-
base_price: MoneySchema,
|
|
232
|
-
final_price: MoneySchema,
|
|
233
|
-
markup_percentage: MoneySchema,
|
|
234
|
-
markup_amount: MoneySchema,
|
|
235
|
-
markup_discount_percentage: MoneySchema,
|
|
236
|
-
markup_discount_amount: MoneySchema
|
|
237
|
-
});
|
|
238
|
-
var AddOnDetailsSchema = z.object({
|
|
239
|
-
selected_options: z.array(z.unknown()),
|
|
240
|
-
total_add_on_price: MoneySchema,
|
|
241
|
-
add_ons: z.array(z.unknown())
|
|
242
|
-
});
|
|
243
|
-
var BundleResolvedSchema = z.object({
|
|
244
|
-
bundle_id: z.string(),
|
|
245
|
-
selections: z.array(z.unknown())
|
|
246
|
-
}).passthrough();
|
|
247
|
-
var CompositeResolvedSchema = z.object({
|
|
248
|
-
composite_id: z.string(),
|
|
249
|
-
selections: z.array(z.unknown()),
|
|
250
|
-
breakdown: z.object({
|
|
251
|
-
base_price: MoneySchema,
|
|
252
|
-
components_total: MoneySchema,
|
|
253
|
-
final_price: MoneySchema,
|
|
254
|
-
tier_applied: z.string().optional()
|
|
255
|
-
}).optional()
|
|
256
|
-
}).passthrough();
|
|
257
|
-
var DiscountDetailsSchema = z.object({
|
|
258
|
-
applied_count: z.number().int().nonnegative(),
|
|
259
|
-
total_amount: MoneySchema,
|
|
260
|
-
discount_ids: z.array(z.string())
|
|
261
|
-
});
|
|
262
|
-
var CartItemSchema = z.object({
|
|
263
|
-
id: z.string(),
|
|
264
|
-
cart_id: z.string(),
|
|
265
|
-
item_id: z.string(),
|
|
266
|
-
quantity: z.number().int().nonnegative(),
|
|
267
|
-
line_key: z.string(),
|
|
268
|
-
line_type: LineTypeSchema,
|
|
269
|
-
name: z.string(),
|
|
270
|
-
description: z.string().optional(),
|
|
271
|
-
image_url: z.string().optional(),
|
|
272
|
-
category_id: z.string().optional(),
|
|
273
|
-
category_name: z.string().optional(),
|
|
274
|
-
is_available: z.boolean(),
|
|
275
|
-
variant_id: z.string().optional(),
|
|
276
|
-
variant_name: z.string().optional(),
|
|
277
|
-
variant_info: VariantInfoSchema.optional(),
|
|
278
|
-
variant_details: VariantDetailsSchema.optional(),
|
|
279
|
-
base_price: MoneySchema,
|
|
280
|
-
add_ons_price: MoneySchema,
|
|
281
|
-
total_price: MoneySchema,
|
|
282
|
-
item_discount_amount: MoneySchema,
|
|
283
|
-
price_info: ChosenPriceSchema,
|
|
284
|
-
add_on_option_ids: z.array(z.string()),
|
|
285
|
-
add_on_ids: z.array(z.string()),
|
|
286
|
-
add_on_details: AddOnDetailsSchema,
|
|
287
|
-
add_on_options: z.array(z.unknown()),
|
|
288
|
-
add_ons: z.array(z.unknown()),
|
|
289
|
-
scheduled_start: z.string().optional(),
|
|
290
|
-
scheduled_end: z.string().optional(),
|
|
291
|
-
staff_id: z.string().optional(),
|
|
292
|
-
resource_id: z.string().optional(),
|
|
293
|
-
service_status: ServiceStatusSchema.optional(),
|
|
294
|
-
confirmation_code: z.string().optional(),
|
|
295
|
-
special_instructions: z.string().optional(),
|
|
296
|
-
customer_inputs: z.array(CustomerInputValueSchema).optional(),
|
|
297
|
-
bundle_selections: z.unknown().optional(),
|
|
298
|
-
bundle_resolved: BundleResolvedSchema.optional(),
|
|
299
|
-
composite_selections: z.unknown().optional(),
|
|
300
|
-
composite_resolved: CompositeResolvedSchema.optional(),
|
|
301
|
-
billing_plan_id: z.string().optional(),
|
|
302
|
-
applied_discount_ids: z.array(z.string()),
|
|
303
|
-
discount_details: DiscountDetailsSchema.optional(),
|
|
304
|
-
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
305
|
-
created_at: TimestampSchema,
|
|
306
|
-
updated_at: TimestampSchema
|
|
307
|
-
});
|
|
308
|
-
var assertCartItem = makeAssertion(CartItemSchema, "cartItem");
|
|
309
|
-
var CartPricingSchema = z.object({
|
|
310
|
-
subtotal: MoneySchema,
|
|
311
|
-
total_discounts: MoneySchema,
|
|
312
|
-
tax_amount: MoneySchema,
|
|
313
|
-
service_charge: MoneySchema,
|
|
314
|
-
total_price: MoneySchema,
|
|
315
|
-
currency: CurrencyCodeSchema,
|
|
316
|
-
tax_rate: MoneySchema.optional(),
|
|
317
|
-
service_charge_rate: MoneySchema.optional()
|
|
318
|
-
});
|
|
319
|
-
var CartSchema = z.object({
|
|
320
|
-
id: z.string(),
|
|
321
|
-
business_id: z.string(),
|
|
322
|
-
items: z.array(CartItemSchema),
|
|
323
|
-
pricing: CartPricingSchema,
|
|
324
|
-
customer_info: z.object({
|
|
325
|
-
name: z.string(),
|
|
326
|
-
email: z.string().optional(),
|
|
327
|
-
phone: z.string().optional(),
|
|
328
|
-
address: z.string().optional()
|
|
329
|
-
}),
|
|
330
|
-
created_at: TimestampSchema,
|
|
331
|
-
updated_at: TimestampSchema,
|
|
332
|
-
expires_at: TimestampSchema,
|
|
333
|
-
status: z.string(),
|
|
334
|
-
source: z.string(),
|
|
335
|
-
channel: z.string()
|
|
336
|
-
});
|
|
337
|
-
var assertCart = makeAssertion(CartSchema, "cart");
|
|
338
|
-
var CheckoutCustomerSchema = z.object({
|
|
339
|
-
name: z.string().min(1),
|
|
340
|
-
email: z.string().email(),
|
|
341
|
-
phone: z.string().min(1),
|
|
342
|
-
notes: z.string().optional(),
|
|
343
|
-
save_details: z.boolean().optional()
|
|
344
|
-
});
|
|
345
|
-
var CheckoutBodySchema = z.object({
|
|
346
|
-
cart_id: z.string().min(1),
|
|
347
|
-
location_id: z.string().optional(),
|
|
348
|
-
customer: CheckoutCustomerSchema,
|
|
349
|
-
order_type: z.string().min(1),
|
|
350
|
-
address_info: z.record(z.string(), z.unknown()).optional(),
|
|
351
|
-
payment_method: z.string().min(1),
|
|
352
|
-
mobile_money_details: z.object({ phone_number: z.string(), provider: z.string() }).optional(),
|
|
353
|
-
special_instructions: z.string().optional(),
|
|
354
|
-
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
355
|
-
pay_currency: z.string().optional(),
|
|
356
|
-
fx_quote_id: z.string().optional()
|
|
357
|
-
});
|
|
358
|
-
var assertCheckoutBody = makeAssertion(CheckoutBodySchema, "checkoutBody");
|
|
359
|
-
var AuthorizationTypeSchema = z.enum(["otp", "pin", "phone", "birthday", "address"]);
|
|
360
|
-
var NextActionSchema = z.discriminatedUnion("type", [
|
|
361
|
-
z.object({ type: z.literal("none") }),
|
|
362
|
-
z.object({ type: z.literal("redirect"), authorization_url: z.string() }),
|
|
363
|
-
z.object({
|
|
364
|
-
type: z.literal("authorization"),
|
|
365
|
-
authorization_type: z.string(),
|
|
366
|
-
display_text: z.string().optional()
|
|
367
|
-
})
|
|
368
|
-
]);
|
|
369
|
-
var CheckoutResponseSchema = z.object({
|
|
370
|
-
order_id: z.string().min(1),
|
|
371
|
-
order_number: z.string().min(1),
|
|
372
|
-
payment_status: z.string().min(1),
|
|
373
|
-
payment_reference: z.string().optional(),
|
|
374
|
-
requires_authorization: z.boolean(),
|
|
375
|
-
authorization_type: AuthorizationTypeSchema.optional(),
|
|
376
|
-
next_action: NextActionSchema,
|
|
377
|
-
provider: z.string().optional(),
|
|
378
|
-
authorization_url: z.string().optional(),
|
|
379
|
-
display_text: z.string().optional(),
|
|
380
|
-
bill_token: z.string().optional(),
|
|
381
|
-
client_secret: z.string().optional(),
|
|
382
|
-
public_key: z.string().optional()
|
|
383
|
-
});
|
|
384
|
-
var assertCheckoutResponse = makeAssertion(CheckoutResponseSchema, "checkout");
|
|
1
|
+
import { __publicField, __privateAdd, __privateSet, __privateGet, __privateMethod, ErrorCode, __privateWrapper } from './chunk-XPXAZXF2.mjs';
|
|
385
2
|
|
|
386
3
|
// ../node_modules/.bun/hono@4.12.16/node_modules/hono/dist/compose.js
|
|
387
4
|
var compose = (middleware, onError, onNotFound) => {
|
|
@@ -4657,7 +4274,9 @@ function toUICart(registry, cart) {
|
|
|
4657
4274
|
id: variant.id,
|
|
4658
4275
|
name: variantName,
|
|
4659
4276
|
sku: variant.sku,
|
|
4277
|
+
price: i.price,
|
|
4660
4278
|
price_adjustment: variant.price_adjustment,
|
|
4279
|
+
is_default: variant.is_default ?? false,
|
|
4661
4280
|
display_attributes: variantDisplayAttributes,
|
|
4662
4281
|
images: variant.images
|
|
4663
4282
|
} : void 0,
|
|
@@ -9202,117 +8821,4 @@ function createMockApp(options = {}) {
|
|
|
9202
8821
|
};
|
|
9203
8822
|
}
|
|
9204
8823
|
|
|
9205
|
-
|
|
9206
|
-
var TEST_BASE_URL = "http://test.local";
|
|
9207
|
-
async function toForwardedRequest(input, init) {
|
|
9208
|
-
if (input instanceof Request) {
|
|
9209
|
-
return {
|
|
9210
|
-
method: init?.method ?? input.method,
|
|
9211
|
-
headers: new Headers(init?.headers ?? input.headers),
|
|
9212
|
-
body: init?.body ?? (["GET", "HEAD"].includes(input.method) ? void 0 : await input.text())
|
|
9213
|
-
};
|
|
9214
|
-
}
|
|
9215
|
-
return {
|
|
9216
|
-
method: init?.method ?? "GET",
|
|
9217
|
-
headers: new Headers(init?.headers ?? {}),
|
|
9218
|
-
body: init?.body ?? void 0
|
|
9219
|
-
};
|
|
9220
|
-
}
|
|
9221
|
-
function createTestClient(options = {}) {
|
|
9222
|
-
const mock = createMockApp(options);
|
|
9223
|
-
let sessionToken;
|
|
9224
|
-
const fetchImpl = async (input, init) => {
|
|
9225
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
9226
|
-
if (!url.startsWith(TEST_BASE_URL)) {
|
|
9227
|
-
return globalThis.fetch(input, init);
|
|
9228
|
-
}
|
|
9229
|
-
const path = url.slice(TEST_BASE_URL.length);
|
|
9230
|
-
const fwd = await toForwardedRequest(input, init);
|
|
9231
|
-
if (sessionToken) fwd.headers.set("x-session-token", sessionToken);
|
|
9232
|
-
const res = await mock.request(path, {
|
|
9233
|
-
method: fwd.method,
|
|
9234
|
-
headers: fwd.headers,
|
|
9235
|
-
body: fwd.body
|
|
9236
|
-
});
|
|
9237
|
-
const echoed = res.headers.get("x-session-token");
|
|
9238
|
-
if (echoed) sessionToken = echoed;
|
|
9239
|
-
return res;
|
|
9240
|
-
};
|
|
9241
|
-
const client = createCimplifyClient({
|
|
9242
|
-
baseUrl: TEST_BASE_URL,
|
|
9243
|
-
publicKey: "test-public-key",
|
|
9244
|
-
suppressPublicKeyWarning: true,
|
|
9245
|
-
fetch: fetchImpl
|
|
9246
|
-
});
|
|
9247
|
-
return {
|
|
9248
|
-
client,
|
|
9249
|
-
mock,
|
|
9250
|
-
reset: () => {
|
|
9251
|
-
mock.deps.resetAll();
|
|
9252
|
-
sessionToken = void 0;
|
|
9253
|
-
},
|
|
9254
|
-
dispose: () => {
|
|
9255
|
-
mock.deps.resetAll();
|
|
9256
|
-
sessionToken = void 0;
|
|
9257
|
-
}
|
|
9258
|
-
};
|
|
9259
|
-
}
|
|
9260
|
-
async function pickProduct(client, opts) {
|
|
9261
|
-
const list = await client.catalogue.getProducts();
|
|
9262
|
-
if (!list.ok) throw list.error;
|
|
9263
|
-
const body = list.value;
|
|
9264
|
-
const products = body.items ?? [];
|
|
9265
|
-
if (products.length === 0) throw new Error("No products in catalogue (wrong seed?)");
|
|
9266
|
-
if (opts.slug) {
|
|
9267
|
-
const found = products.find((p) => p.slug === opts.slug);
|
|
9268
|
-
if (!found) throw new Error(`Product slug "${opts.slug}" not found in catalogue`);
|
|
9269
|
-
return found;
|
|
9270
|
-
}
|
|
9271
|
-
return products.find((p) => p.type === "product") ?? products[0];
|
|
9272
|
-
}
|
|
9273
|
-
var fixtures = {
|
|
9274
|
-
/**
|
|
9275
|
-
* Add the first available product (or a named one) to the cart.
|
|
9276
|
-
* Picks the first variant if the product has variants.
|
|
9277
|
-
*/
|
|
9278
|
-
async addFirstProduct(client, opts = {}) {
|
|
9279
|
-
const product = await pickProduct(client, opts);
|
|
9280
|
-
let variantId;
|
|
9281
|
-
if (opts.withVariant !== false) {
|
|
9282
|
-
const variants = await client.catalogue.getVariants(product.id);
|
|
9283
|
-
if (variants.ok && variants.value.length > 0) {
|
|
9284
|
-
variantId = variants.value[0]?.id;
|
|
9285
|
-
}
|
|
9286
|
-
}
|
|
9287
|
-
const res = await client.cart.addItem({
|
|
9288
|
-
item_id: product.id,
|
|
9289
|
-
quantity: 1,
|
|
9290
|
-
variant_id: variantId
|
|
9291
|
-
});
|
|
9292
|
-
if (!res.ok) throw res.error;
|
|
9293
|
-
return { product, variantId };
|
|
9294
|
-
},
|
|
9295
|
-
/** A minimal valid customer object for checkout. */
|
|
9296
|
-
customer(overrides = {}) {
|
|
9297
|
-
return {
|
|
9298
|
-
name: overrides.name ?? "Test Customer",
|
|
9299
|
-
email: overrides.email ?? "test@example.com",
|
|
9300
|
-
phone: overrides.phone ?? "+233244000000"
|
|
9301
|
-
};
|
|
9302
|
-
},
|
|
9303
|
-
/**
|
|
9304
|
-
* Run the full guest auth flow (request OTP → verify) and return
|
|
9305
|
-
* the new session token. The mock's permissive auth mode echoes
|
|
9306
|
-
* the code in `request_otp`, so we don't need to read it.
|
|
9307
|
-
*/
|
|
9308
|
-
async authenticate(client, contact = "test@example.com", code = "123456") {
|
|
9309
|
-
const req = await client.auth.requestOtp(contact);
|
|
9310
|
-
if (!req.ok) throw req.error;
|
|
9311
|
-
const verify = await client.auth.verifyOtp(contact, code);
|
|
9312
|
-
if (!verify.ok) throw verify.error;
|
|
9313
|
-
const value = verify.value;
|
|
9314
|
-
return { token: value.session_token ?? "", customerId: value.customer_id ?? "" };
|
|
9315
|
-
}
|
|
9316
|
-
};
|
|
9317
|
-
|
|
9318
|
-
export { AddItemPayloadSchema, AddOnDetailsSchema, AuthorizationTypeSchema, BrandContactSchema, BrandFaqSchema, BrandHeroSchema, BrandNavLinkSchema, BrandPolicyPageSchema, BrandPolicySectionSchema, BrandSchema, BrandSocialSchema, BundleResolvedSchema, BundleSelectionInputSchema, CartItemSchema, CartPricingSchema, CartSchema, CheckoutBodySchema, CheckoutCustomerSchema, CheckoutResponseSchema, ChosenPriceSchema, CompositeResolvedSchema, CompositeSelectionInputSchema, CountryCodeSchema, CurrencyCodeSchema, CustomerInputValueSchema, DiscountDetailsSchema, IsoDateTimeSchema, LineTypeSchema, LocaleSchema, MoneyLooseSchema, MoneySchema, NextActionSchema, PhoneE164Schema, ProductTypeSchema, SCHEMA_VERSION, SchemaViolationError, SeedNameSchema, ServiceStatusSchema, TimestampSchema, VariantDetailsSchema, VariantDisplayAttributeSchema, VariantInfoSchema, assertAddItemPayload, assertBrand, assertCart, assertCartItem, assertCheckoutBody, assertCheckoutResponse, createTestClient, fixtures, makeAssertion };
|
|
8824
|
+
export { createMockApp };
|