@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,389 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunkMNIKXG7W_js = require('./chunk-MNIKXG7W.js');
|
|
5
|
-
var zod = require('zod');
|
|
6
|
-
|
|
7
|
-
var SCHEMA_VERSION = "2026-05-07.1";
|
|
8
|
-
var MoneySchema = zod.z.string().regex(/^-?\d+\.\d{2}$/, 'Money must be a decimal string with exactly 2 decimals (e.g. "12.50")');
|
|
9
|
-
var MoneyLooseSchema = zod.z.string().regex(/^-?\d+(\.\d+)?$/, "Must be a decimal string");
|
|
10
|
-
var IsoDateTimeSchema = zod.z.iso.datetime();
|
|
11
|
-
var TimestampSchema = zod.z.union([zod.z.iso.datetime(), zod.z.string().min(1)]);
|
|
12
|
-
var CurrencyCodeSchema = zod.z.string().length(3, "currency must be a 3-letter ISO 4217 code").regex(/^[A-Z]{3}$/, "currency must be uppercase letters");
|
|
13
|
-
var CountryCodeSchema = zod.z.string().length(2, "countryCode must be ISO 3166-1 alpha-2").regex(/^[A-Z]{2}$/, "countryCode must be uppercase letters");
|
|
14
|
-
var LocaleSchema = zod.z.string().regex(/^[a-z]{2}(_[A-Z]{2})?$/, "locale must look like 'en' or 'en_GH'");
|
|
15
|
-
var PhoneE164Schema = zod.z.string().regex(/^\+?[0-9]{7,15}$/, "phoneTel should be E.164-ish digits (7\u201315)");
|
|
16
|
-
var SeedNameSchema = zod.z.enum([
|
|
17
|
-
"default",
|
|
18
|
-
"empty",
|
|
19
|
-
"reesa-storefront",
|
|
20
|
-
"restaurant",
|
|
21
|
-
"retail",
|
|
22
|
-
"services",
|
|
23
|
-
"grocery",
|
|
24
|
-
"fashion"
|
|
25
|
-
]);
|
|
26
|
-
var ProductTypeSchema = zod.z.enum([
|
|
27
|
-
"product",
|
|
28
|
-
"service",
|
|
29
|
-
"digital",
|
|
30
|
-
"bundle",
|
|
31
|
-
"composite"
|
|
32
|
-
]);
|
|
33
|
-
var LineTypeSchema = zod.z.enum([
|
|
34
|
-
"simple",
|
|
35
|
-
"service",
|
|
36
|
-
"digital",
|
|
37
|
-
"bundle",
|
|
38
|
-
"composite"
|
|
39
|
-
]);
|
|
40
|
-
var ServiceStatusSchema = zod.z.enum(["pending", "confirmed", "completed", "cancelled"]);
|
|
41
|
-
function makeAssertion(schema, label) {
|
|
42
|
-
return (value) => {
|
|
43
|
-
const result = schema.safeParse(value);
|
|
44
|
-
if (!result.success) {
|
|
45
|
-
const issues = result.error.issues.map((i) => ` \u2022 ${label}.${i.path.join(".")}: ${i.message}`).join("\n");
|
|
46
|
-
throw new SchemaViolationError(
|
|
47
|
-
`${label} schema violation:
|
|
48
|
-
${issues}`,
|
|
49
|
-
result.error.issues.map((i) => ({ path: i.path.map(String), message: i.message }))
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
var SchemaViolationError = class extends Error {
|
|
55
|
-
constructor(message, issues) {
|
|
56
|
-
super(message);
|
|
57
|
-
this.issues = issues;
|
|
58
|
-
this.name = "SchemaViolationError";
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var BrandSocialSchema = zod.z.object({
|
|
62
|
-
label: zod.z.string().min(1),
|
|
63
|
-
href: zod.z.string().url(),
|
|
64
|
-
icon: zod.z.string().optional()
|
|
65
|
-
});
|
|
66
|
-
var BrandNavLinkSchema = zod.z.object({
|
|
67
|
-
label: zod.z.string().min(1),
|
|
68
|
-
href: zod.z.string().min(1)
|
|
69
|
-
});
|
|
70
|
-
var BrandPolicySectionSchema = zod.z.object({
|
|
71
|
-
heading: zod.z.string().min(1),
|
|
72
|
-
body: zod.z.union([
|
|
73
|
-
zod.z.string().min(1),
|
|
74
|
-
zod.z.object({ intro: zod.z.string(), bullets: zod.z.array(zod.z.string()).min(1) })
|
|
75
|
-
])
|
|
76
|
-
});
|
|
77
|
-
var BrandPolicyPageSchema = zod.z.object({
|
|
78
|
-
eyebrow: zod.z.string(),
|
|
79
|
-
title: zod.z.string().min(1),
|
|
80
|
-
lastUpdated: zod.z.string().min(1),
|
|
81
|
-
sections: zod.z.array(BrandPolicySectionSchema).min(1)
|
|
82
|
-
});
|
|
83
|
-
var BrandContactSchema = zod.z.object({
|
|
84
|
-
email: zod.z.string().email(),
|
|
85
|
-
phone: zod.z.string().min(1),
|
|
86
|
-
phoneTel: PhoneE164Schema,
|
|
87
|
-
streetAddress: zod.z.string().min(1),
|
|
88
|
-
city: zod.z.string().min(1),
|
|
89
|
-
countryCode: CountryCodeSchema,
|
|
90
|
-
hours: zod.z.string().optional()
|
|
91
|
-
});
|
|
92
|
-
var BrandHeroSchema = zod.z.object({
|
|
93
|
-
badge: zod.z.string().optional(),
|
|
94
|
-
title: zod.z.string().min(1),
|
|
95
|
-
subtitle: zod.z.string().min(1),
|
|
96
|
-
primaryCta: BrandNavLinkSchema.optional(),
|
|
97
|
-
secondaryCta: BrandNavLinkSchema.optional()
|
|
98
|
-
});
|
|
99
|
-
var BrandFaqSchema = zod.z.object({
|
|
100
|
-
eyebrow: zod.z.string().optional(),
|
|
101
|
-
title: zod.z.string().min(1),
|
|
102
|
-
sections: zod.z.array(
|
|
103
|
-
zod.z.object({
|
|
104
|
-
title: zod.z.string(),
|
|
105
|
-
items: zod.z.array(zod.z.object({ q: zod.z.string(), a: zod.z.string() }))
|
|
106
|
-
})
|
|
107
|
-
)
|
|
108
|
-
});
|
|
109
|
-
var BrandSchema = zod.z.object({
|
|
110
|
-
// Identity
|
|
111
|
-
name: zod.z.string().min(1),
|
|
112
|
-
shortName: zod.z.string().min(1),
|
|
113
|
-
microTag: zod.z.string(),
|
|
114
|
-
description: zod.z.string().min(20, "description should be at least 20 characters"),
|
|
115
|
-
schemaType: zod.z.string().min(1),
|
|
116
|
-
currency: CurrencyCodeSchema,
|
|
117
|
-
locale: LocaleSchema,
|
|
118
|
-
contact: BrandContactSchema,
|
|
119
|
-
socials: zod.z.array(BrandSocialSchema),
|
|
120
|
-
header: zod.z.object({ nav: zod.z.array(BrandNavLinkSchema).min(1) }),
|
|
121
|
-
hero: BrandHeroSchema,
|
|
122
|
-
// Optional sections — render conditionally when present
|
|
123
|
-
trustItems: zod.z.array(zod.z.object({ title: zod.z.string().min(1), body: zod.z.string().min(1) })).optional(),
|
|
124
|
-
brandStrip: zod.z.object({ headline: zod.z.string(), logos: zod.z.array(zod.z.string()).min(1) }).optional(),
|
|
125
|
-
promo: zod.z.object({
|
|
126
|
-
eyebrow: zod.z.string().optional(),
|
|
127
|
-
title: zod.z.string().min(1),
|
|
128
|
-
cta: BrandNavLinkSchema
|
|
129
|
-
}).optional(),
|
|
130
|
-
// Standalone policy pages
|
|
131
|
-
terms: BrandPolicyPageSchema,
|
|
132
|
-
privacy: BrandPolicyPageSchema,
|
|
133
|
-
shipping: BrandPolicyPageSchema,
|
|
134
|
-
returns: BrandPolicyPageSchema,
|
|
135
|
-
accessibility: BrandPolicyPageSchema,
|
|
136
|
-
// Misc
|
|
137
|
-
newsletter: zod.z.object({
|
|
138
|
-
eyebrow: zod.z.string().optional(),
|
|
139
|
-
title: zod.z.string().min(1),
|
|
140
|
-
body: zod.z.string()
|
|
141
|
-
}),
|
|
142
|
-
about: zod.z.object({
|
|
143
|
-
eyebrow: zod.z.string().optional(),
|
|
144
|
-
title: zod.z.string().min(1),
|
|
145
|
-
body: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())])
|
|
146
|
-
}),
|
|
147
|
-
faq: BrandFaqSchema,
|
|
148
|
-
account: zod.z.object({
|
|
149
|
-
eyebrow: zod.z.string().optional(),
|
|
150
|
-
title: zod.z.string().min(1),
|
|
151
|
-
signin: zod.z.object({ eyebrow: zod.z.string().optional(), title: zod.z.string().min(1) }).optional(),
|
|
152
|
-
signup: zod.z.object({ eyebrow: zod.z.string().optional(), title: zod.z.string().min(1) }).optional()
|
|
153
|
-
}),
|
|
154
|
-
contactPage: zod.z.object({
|
|
155
|
-
eyebrow: zod.z.string().optional(),
|
|
156
|
-
title: zod.z.string().min(1),
|
|
157
|
-
body: zod.z.string()
|
|
158
|
-
}),
|
|
159
|
-
trackOrder: zod.z.object({
|
|
160
|
-
eyebrow: zod.z.string().optional(),
|
|
161
|
-
title: zod.z.string().min(1),
|
|
162
|
-
body: zod.z.string()
|
|
163
|
-
}),
|
|
164
|
-
footer: zod.z.object({
|
|
165
|
-
sitemap: zod.z.array(zod.z.unknown()).optional(),
|
|
166
|
-
poweredBy: zod.z.string().optional()
|
|
167
|
-
}),
|
|
168
|
-
llms: zod.z.object({ summary: zod.z.string().min(20) }),
|
|
169
|
-
mock: zod.z.object({
|
|
170
|
-
seed: SeedNameSchema,
|
|
171
|
-
businessId: zod.z.string().regex(/^bus_/, "businessId should start with 'bus_'")
|
|
172
|
-
})
|
|
173
|
-
});
|
|
174
|
-
var assertBrand = makeAssertion(BrandSchema, "brand");
|
|
175
|
-
var BundleSelectionInputSchema = zod.z.object({
|
|
176
|
-
component_id: zod.z.string(),
|
|
177
|
-
variant_id: zod.z.string().optional(),
|
|
178
|
-
quantity: zod.z.number().int().positive(),
|
|
179
|
-
scheduled_start: zod.z.string().optional(),
|
|
180
|
-
scheduled_end: zod.z.string().optional()
|
|
181
|
-
});
|
|
182
|
-
var CompositeSelectionInputSchema = zod.z.object({
|
|
183
|
-
component_id: zod.z.string().optional(),
|
|
184
|
-
source_product_id: zod.z.string().optional(),
|
|
185
|
-
source_stock_id: zod.z.string().optional(),
|
|
186
|
-
source_type: zod.z.enum(["product", "stock", "add_on", "standalone"]).optional(),
|
|
187
|
-
quantity: zod.z.number().int().positive().optional()
|
|
188
|
-
});
|
|
189
|
-
var CustomerInputValueSchema = zod.z.object({
|
|
190
|
-
field_id: zod.z.string(),
|
|
191
|
-
field_name: zod.z.string().optional(),
|
|
192
|
-
field_type: zod.z.string().optional(),
|
|
193
|
-
value: zod.z.unknown()
|
|
194
|
-
});
|
|
195
|
-
var AddItemPayloadSchema = zod.z.object({
|
|
196
|
-
item_id: zod.z.string().min(1),
|
|
197
|
-
quantity: zod.z.number().int().positive(),
|
|
198
|
-
variant_id: zod.z.string().optional(),
|
|
199
|
-
quote_id: zod.z.string().optional(),
|
|
200
|
-
add_on_options: zod.z.array(zod.z.string()).optional(),
|
|
201
|
-
bundle_selections: zod.z.array(BundleSelectionInputSchema).optional(),
|
|
202
|
-
composite_selections: zod.z.array(CompositeSelectionInputSchema).optional(),
|
|
203
|
-
scheduled_start: zod.z.string().optional(),
|
|
204
|
-
scheduled_end: zod.z.string().optional(),
|
|
205
|
-
staff_id: zod.z.string().optional(),
|
|
206
|
-
resource_id: zod.z.string().optional(),
|
|
207
|
-
special_instructions: zod.z.string().optional(),
|
|
208
|
-
customer_inputs: zod.z.array(CustomerInputValueSchema).optional(),
|
|
209
|
-
billing_plan_id: zod.z.string().optional(),
|
|
210
|
-
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
211
|
-
});
|
|
212
|
-
var assertAddItemPayload = makeAssertion(AddItemPayloadSchema, "payload");
|
|
213
|
-
var VariantDisplayAttributeSchema = zod.z.object({
|
|
214
|
-
axis_id: zod.z.string(),
|
|
215
|
-
axis_name: zod.z.string(),
|
|
216
|
-
value_id: zod.z.string(),
|
|
217
|
-
value_name: zod.z.string()
|
|
218
|
-
});
|
|
219
|
-
var VariantInfoSchema = zod.z.object({
|
|
220
|
-
id: zod.z.string(),
|
|
221
|
-
name: zod.z.string(),
|
|
222
|
-
sku: zod.z.string().optional(),
|
|
223
|
-
price_adjustment: MoneySchema,
|
|
224
|
-
display_attributes: zod.z.array(VariantDisplayAttributeSchema).optional(),
|
|
225
|
-
images: zod.z.array(zod.z.string()).optional()
|
|
226
|
-
});
|
|
227
|
-
var VariantDetailsSchema = zod.z.object({
|
|
228
|
-
variant_id: zod.z.string(),
|
|
229
|
-
sku: zod.z.string().optional(),
|
|
230
|
-
properties: zod.z.record(zod.z.string(), zod.z.string())
|
|
231
|
-
});
|
|
232
|
-
var ChosenPriceSchema = zod.z.object({
|
|
233
|
-
base_price: MoneySchema,
|
|
234
|
-
final_price: MoneySchema,
|
|
235
|
-
markup_percentage: MoneySchema,
|
|
236
|
-
markup_amount: MoneySchema,
|
|
237
|
-
markup_discount_percentage: MoneySchema,
|
|
238
|
-
markup_discount_amount: MoneySchema
|
|
239
|
-
});
|
|
240
|
-
var AddOnDetailsSchema = zod.z.object({
|
|
241
|
-
selected_options: zod.z.array(zod.z.unknown()),
|
|
242
|
-
total_add_on_price: MoneySchema,
|
|
243
|
-
add_ons: zod.z.array(zod.z.unknown())
|
|
244
|
-
});
|
|
245
|
-
var BundleResolvedSchema = zod.z.object({
|
|
246
|
-
bundle_id: zod.z.string(),
|
|
247
|
-
selections: zod.z.array(zod.z.unknown())
|
|
248
|
-
}).passthrough();
|
|
249
|
-
var CompositeResolvedSchema = zod.z.object({
|
|
250
|
-
composite_id: zod.z.string(),
|
|
251
|
-
selections: zod.z.array(zod.z.unknown()),
|
|
252
|
-
breakdown: zod.z.object({
|
|
253
|
-
base_price: MoneySchema,
|
|
254
|
-
components_total: MoneySchema,
|
|
255
|
-
final_price: MoneySchema,
|
|
256
|
-
tier_applied: zod.z.string().optional()
|
|
257
|
-
}).optional()
|
|
258
|
-
}).passthrough();
|
|
259
|
-
var DiscountDetailsSchema = zod.z.object({
|
|
260
|
-
applied_count: zod.z.number().int().nonnegative(),
|
|
261
|
-
total_amount: MoneySchema,
|
|
262
|
-
discount_ids: zod.z.array(zod.z.string())
|
|
263
|
-
});
|
|
264
|
-
var CartItemSchema = zod.z.object({
|
|
265
|
-
id: zod.z.string(),
|
|
266
|
-
cart_id: zod.z.string(),
|
|
267
|
-
item_id: zod.z.string(),
|
|
268
|
-
quantity: zod.z.number().int().nonnegative(),
|
|
269
|
-
line_key: zod.z.string(),
|
|
270
|
-
line_type: LineTypeSchema,
|
|
271
|
-
name: zod.z.string(),
|
|
272
|
-
description: zod.z.string().optional(),
|
|
273
|
-
image_url: zod.z.string().optional(),
|
|
274
|
-
category_id: zod.z.string().optional(),
|
|
275
|
-
category_name: zod.z.string().optional(),
|
|
276
|
-
is_available: zod.z.boolean(),
|
|
277
|
-
variant_id: zod.z.string().optional(),
|
|
278
|
-
variant_name: zod.z.string().optional(),
|
|
279
|
-
variant_info: VariantInfoSchema.optional(),
|
|
280
|
-
variant_details: VariantDetailsSchema.optional(),
|
|
281
|
-
base_price: MoneySchema,
|
|
282
|
-
add_ons_price: MoneySchema,
|
|
283
|
-
total_price: MoneySchema,
|
|
284
|
-
item_discount_amount: MoneySchema,
|
|
285
|
-
price_info: ChosenPriceSchema,
|
|
286
|
-
add_on_option_ids: zod.z.array(zod.z.string()),
|
|
287
|
-
add_on_ids: zod.z.array(zod.z.string()),
|
|
288
|
-
add_on_details: AddOnDetailsSchema,
|
|
289
|
-
add_on_options: zod.z.array(zod.z.unknown()),
|
|
290
|
-
add_ons: zod.z.array(zod.z.unknown()),
|
|
291
|
-
scheduled_start: zod.z.string().optional(),
|
|
292
|
-
scheduled_end: zod.z.string().optional(),
|
|
293
|
-
staff_id: zod.z.string().optional(),
|
|
294
|
-
resource_id: zod.z.string().optional(),
|
|
295
|
-
service_status: ServiceStatusSchema.optional(),
|
|
296
|
-
confirmation_code: zod.z.string().optional(),
|
|
297
|
-
special_instructions: zod.z.string().optional(),
|
|
298
|
-
customer_inputs: zod.z.array(CustomerInputValueSchema).optional(),
|
|
299
|
-
bundle_selections: zod.z.unknown().optional(),
|
|
300
|
-
bundle_resolved: BundleResolvedSchema.optional(),
|
|
301
|
-
composite_selections: zod.z.unknown().optional(),
|
|
302
|
-
composite_resolved: CompositeResolvedSchema.optional(),
|
|
303
|
-
billing_plan_id: zod.z.string().optional(),
|
|
304
|
-
applied_discount_ids: zod.z.array(zod.z.string()),
|
|
305
|
-
discount_details: DiscountDetailsSchema.optional(),
|
|
306
|
-
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
307
|
-
created_at: TimestampSchema,
|
|
308
|
-
updated_at: TimestampSchema
|
|
309
|
-
});
|
|
310
|
-
var assertCartItem = makeAssertion(CartItemSchema, "cartItem");
|
|
311
|
-
var CartPricingSchema = zod.z.object({
|
|
312
|
-
subtotal: MoneySchema,
|
|
313
|
-
total_discounts: MoneySchema,
|
|
314
|
-
tax_amount: MoneySchema,
|
|
315
|
-
service_charge: MoneySchema,
|
|
316
|
-
total_price: MoneySchema,
|
|
317
|
-
currency: CurrencyCodeSchema,
|
|
318
|
-
tax_rate: MoneySchema.optional(),
|
|
319
|
-
service_charge_rate: MoneySchema.optional()
|
|
320
|
-
});
|
|
321
|
-
var CartSchema = zod.z.object({
|
|
322
|
-
id: zod.z.string(),
|
|
323
|
-
business_id: zod.z.string(),
|
|
324
|
-
items: zod.z.array(CartItemSchema),
|
|
325
|
-
pricing: CartPricingSchema,
|
|
326
|
-
customer_info: zod.z.object({
|
|
327
|
-
name: zod.z.string(),
|
|
328
|
-
email: zod.z.string().optional(),
|
|
329
|
-
phone: zod.z.string().optional(),
|
|
330
|
-
address: zod.z.string().optional()
|
|
331
|
-
}),
|
|
332
|
-
created_at: TimestampSchema,
|
|
333
|
-
updated_at: TimestampSchema,
|
|
334
|
-
expires_at: TimestampSchema,
|
|
335
|
-
status: zod.z.string(),
|
|
336
|
-
source: zod.z.string(),
|
|
337
|
-
channel: zod.z.string()
|
|
338
|
-
});
|
|
339
|
-
var assertCart = makeAssertion(CartSchema, "cart");
|
|
340
|
-
var CheckoutCustomerSchema = zod.z.object({
|
|
341
|
-
name: zod.z.string().min(1),
|
|
342
|
-
email: zod.z.string().email(),
|
|
343
|
-
phone: zod.z.string().min(1),
|
|
344
|
-
notes: zod.z.string().optional(),
|
|
345
|
-
save_details: zod.z.boolean().optional()
|
|
346
|
-
});
|
|
347
|
-
var CheckoutBodySchema = zod.z.object({
|
|
348
|
-
cart_id: zod.z.string().min(1),
|
|
349
|
-
location_id: zod.z.string().optional(),
|
|
350
|
-
customer: CheckoutCustomerSchema,
|
|
351
|
-
order_type: zod.z.string().min(1),
|
|
352
|
-
address_info: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
353
|
-
payment_method: zod.z.string().min(1),
|
|
354
|
-
mobile_money_details: zod.z.object({ phone_number: zod.z.string(), provider: zod.z.string() }).optional(),
|
|
355
|
-
special_instructions: zod.z.string().optional(),
|
|
356
|
-
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
357
|
-
pay_currency: zod.z.string().optional(),
|
|
358
|
-
fx_quote_id: zod.z.string().optional()
|
|
359
|
-
});
|
|
360
|
-
var assertCheckoutBody = makeAssertion(CheckoutBodySchema, "checkoutBody");
|
|
361
|
-
var AuthorizationTypeSchema = zod.z.enum(["otp", "pin", "phone", "birthday", "address"]);
|
|
362
|
-
var NextActionSchema = zod.z.discriminatedUnion("type", [
|
|
363
|
-
zod.z.object({ type: zod.z.literal("none") }),
|
|
364
|
-
zod.z.object({ type: zod.z.literal("redirect"), authorization_url: zod.z.string() }),
|
|
365
|
-
zod.z.object({
|
|
366
|
-
type: zod.z.literal("authorization"),
|
|
367
|
-
authorization_type: zod.z.string(),
|
|
368
|
-
display_text: zod.z.string().optional()
|
|
369
|
-
})
|
|
370
|
-
]);
|
|
371
|
-
var CheckoutResponseSchema = zod.z.object({
|
|
372
|
-
order_id: zod.z.string().min(1),
|
|
373
|
-
order_number: zod.z.string().min(1),
|
|
374
|
-
payment_status: zod.z.string().min(1),
|
|
375
|
-
payment_reference: zod.z.string().optional(),
|
|
376
|
-
requires_authorization: zod.z.boolean(),
|
|
377
|
-
authorization_type: AuthorizationTypeSchema.optional(),
|
|
378
|
-
next_action: NextActionSchema,
|
|
379
|
-
provider: zod.z.string().optional(),
|
|
380
|
-
authorization_url: zod.z.string().optional(),
|
|
381
|
-
display_text: zod.z.string().optional(),
|
|
382
|
-
bill_token: zod.z.string().optional(),
|
|
383
|
-
client_secret: zod.z.string().optional(),
|
|
384
|
-
public_key: zod.z.string().optional()
|
|
385
|
-
});
|
|
386
|
-
var assertCheckoutResponse = makeAssertion(CheckoutResponseSchema, "checkout");
|
|
3
|
+
var chunkQBQCMQ4F_js = require('./chunk-QBQCMQ4F.js');
|
|
387
4
|
|
|
388
5
|
// ../node_modules/.bun/hono@4.12.16/node_modules/hono/dist/compose.js
|
|
389
6
|
var compose = (middleware, onError, onNotFound) => {
|
|
@@ -711,7 +328,7 @@ var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
|
|
|
711
328
|
var _validatedData, _matchResult, _HonoRequest_instances, getDecodedParam_fn, getAllDecodedParams_fn, getParamValue_fn, _cachedBody, _a;
|
|
712
329
|
var HonoRequest = (_a = class {
|
|
713
330
|
constructor(request, path = "/", matchResult = [[]]) {
|
|
714
|
-
|
|
331
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _HonoRequest_instances);
|
|
715
332
|
/**
|
|
716
333
|
* `.raw` can get the raw Request object.
|
|
717
334
|
*
|
|
@@ -726,11 +343,11 @@ var HonoRequest = (_a = class {
|
|
|
726
343
|
* })
|
|
727
344
|
* ```
|
|
728
345
|
*/
|
|
729
|
-
|
|
730
|
-
|
|
346
|
+
chunkQBQCMQ4F_js.__publicField(this, "raw");
|
|
347
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _validatedData);
|
|
731
348
|
// Short name of validatedData
|
|
732
|
-
|
|
733
|
-
|
|
349
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _matchResult);
|
|
350
|
+
chunkQBQCMQ4F_js.__publicField(this, "routeIndex", 0);
|
|
734
351
|
/**
|
|
735
352
|
* `.path` can get the pathname of the request.
|
|
736
353
|
*
|
|
@@ -743,9 +360,9 @@ var HonoRequest = (_a = class {
|
|
|
743
360
|
* })
|
|
744
361
|
* ```
|
|
745
362
|
*/
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
363
|
+
chunkQBQCMQ4F_js.__publicField(this, "path");
|
|
364
|
+
chunkQBQCMQ4F_js.__publicField(this, "bodyCache", {});
|
|
365
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _cachedBody, (key) => {
|
|
749
366
|
const { bodyCache, raw: raw2 } = this;
|
|
750
367
|
const cachedBody = bodyCache[key];
|
|
751
368
|
if (cachedBody) {
|
|
@@ -764,11 +381,11 @@ var HonoRequest = (_a = class {
|
|
|
764
381
|
});
|
|
765
382
|
this.raw = request;
|
|
766
383
|
this.path = path;
|
|
767
|
-
|
|
768
|
-
|
|
384
|
+
chunkQBQCMQ4F_js.__privateSet(this, _matchResult, matchResult);
|
|
385
|
+
chunkQBQCMQ4F_js.__privateSet(this, _validatedData, {});
|
|
769
386
|
}
|
|
770
387
|
param(key) {
|
|
771
|
-
return key ?
|
|
388
|
+
return key ? chunkQBQCMQ4F_js.__privateMethod(this, _HonoRequest_instances, getDecodedParam_fn).call(this, key) : chunkQBQCMQ4F_js.__privateMethod(this, _HonoRequest_instances, getAllDecodedParams_fn).call(this);
|
|
772
389
|
}
|
|
773
390
|
query(key) {
|
|
774
391
|
return getQueryParam(this.url, key);
|
|
@@ -802,7 +419,7 @@ var HonoRequest = (_a = class {
|
|
|
802
419
|
* ```
|
|
803
420
|
*/
|
|
804
421
|
json() {
|
|
805
|
-
return
|
|
422
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _cachedBody).call(this, "text").then((text) => JSON.parse(text));
|
|
806
423
|
}
|
|
807
424
|
/**
|
|
808
425
|
* `.text()` can parse Request body of type `text/plain`
|
|
@@ -817,7 +434,7 @@ var HonoRequest = (_a = class {
|
|
|
817
434
|
* ```
|
|
818
435
|
*/
|
|
819
436
|
text() {
|
|
820
|
-
return
|
|
437
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _cachedBody).call(this, "text");
|
|
821
438
|
}
|
|
822
439
|
/**
|
|
823
440
|
* `.arrayBuffer()` parse Request body as an `ArrayBuffer`
|
|
@@ -832,7 +449,7 @@ var HonoRequest = (_a = class {
|
|
|
832
449
|
* ```
|
|
833
450
|
*/
|
|
834
451
|
arrayBuffer() {
|
|
835
|
-
return
|
|
452
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _cachedBody).call(this, "arrayBuffer");
|
|
836
453
|
}
|
|
837
454
|
/**
|
|
838
455
|
* Parses the request body as a `Blob`.
|
|
@@ -845,7 +462,7 @@ var HonoRequest = (_a = class {
|
|
|
845
462
|
* @see https://hono.dev/docs/api/request#blob
|
|
846
463
|
*/
|
|
847
464
|
blob() {
|
|
848
|
-
return
|
|
465
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _cachedBody).call(this, "blob");
|
|
849
466
|
}
|
|
850
467
|
/**
|
|
851
468
|
* Parses the request body as `FormData`.
|
|
@@ -858,7 +475,7 @@ var HonoRequest = (_a = class {
|
|
|
858
475
|
* @see https://hono.dev/docs/api/request#formdata
|
|
859
476
|
*/
|
|
860
477
|
formData() {
|
|
861
|
-
return
|
|
478
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _cachedBody).call(this, "formData");
|
|
862
479
|
}
|
|
863
480
|
/**
|
|
864
481
|
* Adds validated data to the request.
|
|
@@ -867,10 +484,10 @@ var HonoRequest = (_a = class {
|
|
|
867
484
|
* @param data - The validated data to add.
|
|
868
485
|
*/
|
|
869
486
|
addValidatedData(target, data) {
|
|
870
|
-
|
|
487
|
+
chunkQBQCMQ4F_js.__privateGet(this, _validatedData)[target] = data;
|
|
871
488
|
}
|
|
872
489
|
valid(target) {
|
|
873
|
-
return
|
|
490
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _validatedData)[target];
|
|
874
491
|
}
|
|
875
492
|
/**
|
|
876
493
|
* `.url()` can get the request url strings.
|
|
@@ -904,7 +521,7 @@ var HonoRequest = (_a = class {
|
|
|
904
521
|
return this.raw.method;
|
|
905
522
|
}
|
|
906
523
|
get [GET_MATCH_RESULT]() {
|
|
907
|
-
return
|
|
524
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _matchResult);
|
|
908
525
|
}
|
|
909
526
|
/**
|
|
910
527
|
* `.matchedRoutes()` can return a matched route in the handler
|
|
@@ -934,7 +551,7 @@ var HonoRequest = (_a = class {
|
|
|
934
551
|
* ```
|
|
935
552
|
*/
|
|
936
553
|
get matchedRoutes() {
|
|
937
|
-
return
|
|
554
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _matchResult)[0].map(([[, route]]) => route);
|
|
938
555
|
}
|
|
939
556
|
/**
|
|
940
557
|
* `routePath()` can retrieve the path registered within the handler
|
|
@@ -953,24 +570,24 @@ var HonoRequest = (_a = class {
|
|
|
953
570
|
* ```
|
|
954
571
|
*/
|
|
955
572
|
get routePath() {
|
|
956
|
-
return
|
|
573
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _matchResult)[0].map(([[, route]]) => route)[this.routeIndex].path;
|
|
957
574
|
}
|
|
958
575
|
}, _validatedData = new WeakMap(), _matchResult = new WeakMap(), _HonoRequest_instances = new WeakSet(), getDecodedParam_fn = function(key) {
|
|
959
|
-
const paramKey =
|
|
960
|
-
const param =
|
|
576
|
+
const paramKey = chunkQBQCMQ4F_js.__privateGet(this, _matchResult)[0][this.routeIndex][1][key];
|
|
577
|
+
const param = chunkQBQCMQ4F_js.__privateMethod(this, _HonoRequest_instances, getParamValue_fn).call(this, paramKey);
|
|
961
578
|
return param && /\%/.test(param) ? tryDecodeURIComponent(param) : param;
|
|
962
579
|
}, getAllDecodedParams_fn = function() {
|
|
963
580
|
const decoded = {};
|
|
964
|
-
const keys = Object.keys(
|
|
581
|
+
const keys = Object.keys(chunkQBQCMQ4F_js.__privateGet(this, _matchResult)[0][this.routeIndex][1]);
|
|
965
582
|
for (const key of keys) {
|
|
966
|
-
const value =
|
|
583
|
+
const value = chunkQBQCMQ4F_js.__privateMethod(this, _HonoRequest_instances, getParamValue_fn).call(this, chunkQBQCMQ4F_js.__privateGet(this, _matchResult)[0][this.routeIndex][1][key]);
|
|
967
584
|
if (value !== void 0) {
|
|
968
585
|
decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
|
|
969
586
|
}
|
|
970
587
|
}
|
|
971
588
|
return decoded;
|
|
972
589
|
}, getParamValue_fn = function(paramKey) {
|
|
973
|
-
return
|
|
590
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _matchResult)[1] ? chunkQBQCMQ4F_js.__privateGet(this, _matchResult)[1][paramKey] : paramKey;
|
|
974
591
|
}, _cachedBody = new WeakMap(), _a);
|
|
975
592
|
|
|
976
593
|
// ../node_modules/.bun/hono@4.12.16/node_modules/hono/dist/utils/html.js
|
|
@@ -1022,9 +639,9 @@ var Context = (_a2 = class {
|
|
|
1022
639
|
* @param options - Optional configuration options for the context.
|
|
1023
640
|
*/
|
|
1024
641
|
constructor(req, options) {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
642
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _Context_instances);
|
|
643
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _rawRequest);
|
|
644
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _req);
|
|
1028
645
|
/**
|
|
1029
646
|
* `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
|
|
1030
647
|
*
|
|
@@ -1038,9 +655,9 @@ var Context = (_a2 = class {
|
|
|
1038
655
|
* })
|
|
1039
656
|
* ```
|
|
1040
657
|
*/
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
658
|
+
chunkQBQCMQ4F_js.__publicField(this, "env", {});
|
|
659
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _var);
|
|
660
|
+
chunkQBQCMQ4F_js.__publicField(this, "finalized", false);
|
|
1044
661
|
/**
|
|
1045
662
|
* `.error` can get the error object from the middleware if the Handler throws an error.
|
|
1046
663
|
*
|
|
@@ -1056,16 +673,16 @@ var Context = (_a2 = class {
|
|
|
1056
673
|
* })
|
|
1057
674
|
* ```
|
|
1058
675
|
*/
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
676
|
+
chunkQBQCMQ4F_js.__publicField(this, "error");
|
|
677
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _status);
|
|
678
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _executionCtx);
|
|
679
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _res);
|
|
680
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _layout);
|
|
681
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _renderer);
|
|
682
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _notFoundHandler);
|
|
683
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _preparedHeaders);
|
|
684
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _matchResult2);
|
|
685
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _path);
|
|
1069
686
|
/**
|
|
1070
687
|
* `.render()` can create a response within a layout.
|
|
1071
688
|
*
|
|
@@ -1078,9 +695,9 @@ var Context = (_a2 = class {
|
|
|
1078
695
|
* })
|
|
1079
696
|
* ```
|
|
1080
697
|
*/
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
return
|
|
698
|
+
chunkQBQCMQ4F_js.__publicField(this, "render", (...args) => {
|
|
699
|
+
chunkQBQCMQ4F_js.__privateGet(this, _renderer) ?? chunkQBQCMQ4F_js.__privateSet(this, _renderer, (content) => this.html(content));
|
|
700
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _renderer).call(this, ...args);
|
|
1084
701
|
});
|
|
1085
702
|
/**
|
|
1086
703
|
* Sets the layout for the response.
|
|
@@ -1088,13 +705,13 @@ var Context = (_a2 = class {
|
|
|
1088
705
|
* @param layout - The layout to set.
|
|
1089
706
|
* @returns The layout function.
|
|
1090
707
|
*/
|
|
1091
|
-
|
|
708
|
+
chunkQBQCMQ4F_js.__publicField(this, "setLayout", (layout) => chunkQBQCMQ4F_js.__privateSet(this, _layout, layout));
|
|
1092
709
|
/**
|
|
1093
710
|
* Gets the current layout for the response.
|
|
1094
711
|
*
|
|
1095
712
|
* @returns The current layout function.
|
|
1096
713
|
*/
|
|
1097
|
-
|
|
714
|
+
chunkQBQCMQ4F_js.__publicField(this, "getLayout", () => chunkQBQCMQ4F_js.__privateGet(this, _layout));
|
|
1098
715
|
/**
|
|
1099
716
|
* `.setRenderer()` can set the layout in the custom middleware.
|
|
1100
717
|
*
|
|
@@ -1116,8 +733,8 @@ var Context = (_a2 = class {
|
|
|
1116
733
|
* })
|
|
1117
734
|
* ```
|
|
1118
735
|
*/
|
|
1119
|
-
|
|
1120
|
-
|
|
736
|
+
chunkQBQCMQ4F_js.__publicField(this, "setRenderer", (renderer) => {
|
|
737
|
+
chunkQBQCMQ4F_js.__privateSet(this, _renderer, renderer);
|
|
1121
738
|
});
|
|
1122
739
|
/**
|
|
1123
740
|
* `.header()` can set headers.
|
|
@@ -1135,11 +752,11 @@ var Context = (_a2 = class {
|
|
|
1135
752
|
* })
|
|
1136
753
|
* ```
|
|
1137
754
|
*/
|
|
1138
|
-
|
|
755
|
+
chunkQBQCMQ4F_js.__publicField(this, "header", (name, value, options) => {
|
|
1139
756
|
if (this.finalized) {
|
|
1140
|
-
|
|
757
|
+
chunkQBQCMQ4F_js.__privateSet(this, _res, createResponseInstance(chunkQBQCMQ4F_js.__privateGet(this, _res).body, chunkQBQCMQ4F_js.__privateGet(this, _res)));
|
|
1141
758
|
}
|
|
1142
|
-
const headers =
|
|
759
|
+
const headers = chunkQBQCMQ4F_js.__privateGet(this, _res) ? chunkQBQCMQ4F_js.__privateGet(this, _res).headers : chunkQBQCMQ4F_js.__privateGet(this, _preparedHeaders) ?? chunkQBQCMQ4F_js.__privateSet(this, _preparedHeaders, new Headers());
|
|
1143
760
|
if (value === void 0) {
|
|
1144
761
|
headers.delete(name);
|
|
1145
762
|
} else if (options?.append) {
|
|
@@ -1148,8 +765,8 @@ var Context = (_a2 = class {
|
|
|
1148
765
|
headers.set(name, value);
|
|
1149
766
|
}
|
|
1150
767
|
});
|
|
1151
|
-
|
|
1152
|
-
|
|
768
|
+
chunkQBQCMQ4F_js.__publicField(this, "status", (status) => {
|
|
769
|
+
chunkQBQCMQ4F_js.__privateSet(this, _status, status);
|
|
1153
770
|
});
|
|
1154
771
|
/**
|
|
1155
772
|
* `.set()` can set the value specified by the key.
|
|
@@ -1164,9 +781,9 @@ var Context = (_a2 = class {
|
|
|
1164
781
|
* })
|
|
1165
782
|
* ```
|
|
1166
783
|
*/
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
784
|
+
chunkQBQCMQ4F_js.__publicField(this, "set", (key, value) => {
|
|
785
|
+
chunkQBQCMQ4F_js.__privateGet(this, _var) ?? chunkQBQCMQ4F_js.__privateSet(this, _var, /* @__PURE__ */ new Map());
|
|
786
|
+
chunkQBQCMQ4F_js.__privateGet(this, _var).set(key, value);
|
|
1170
787
|
});
|
|
1171
788
|
/**
|
|
1172
789
|
* `.get()` can use the value specified by the key.
|
|
@@ -1181,10 +798,10 @@ var Context = (_a2 = class {
|
|
|
1181
798
|
* })
|
|
1182
799
|
* ```
|
|
1183
800
|
*/
|
|
1184
|
-
|
|
1185
|
-
return
|
|
801
|
+
chunkQBQCMQ4F_js.__publicField(this, "get", (key) => {
|
|
802
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _var) ? chunkQBQCMQ4F_js.__privateGet(this, _var).get(key) : void 0;
|
|
1186
803
|
});
|
|
1187
|
-
|
|
804
|
+
chunkQBQCMQ4F_js.__publicField(this, "newResponse", (...args) => chunkQBQCMQ4F_js.__privateMethod(this, _Context_instances, newResponse_fn).call(this, ...args));
|
|
1188
805
|
/**
|
|
1189
806
|
* `.body()` can return the HTTP response.
|
|
1190
807
|
* You can set headers with `.header()` and set HTTP status code with `.status`.
|
|
@@ -1206,7 +823,7 @@ var Context = (_a2 = class {
|
|
|
1206
823
|
* })
|
|
1207
824
|
* ```
|
|
1208
825
|
*/
|
|
1209
|
-
|
|
826
|
+
chunkQBQCMQ4F_js.__publicField(this, "body", (data, arg, headers) => chunkQBQCMQ4F_js.__privateMethod(this, _Context_instances, newResponse_fn).call(this, data, arg, headers));
|
|
1210
827
|
/**
|
|
1211
828
|
* `.text()` can render text as `Content-Type:text/plain`.
|
|
1212
829
|
*
|
|
@@ -1219,8 +836,8 @@ var Context = (_a2 = class {
|
|
|
1219
836
|
* })
|
|
1220
837
|
* ```
|
|
1221
838
|
*/
|
|
1222
|
-
|
|
1223
|
-
return !
|
|
839
|
+
chunkQBQCMQ4F_js.__publicField(this, "text", (text, arg, headers) => {
|
|
840
|
+
return !chunkQBQCMQ4F_js.__privateGet(this, _preparedHeaders) && !chunkQBQCMQ4F_js.__privateGet(this, _status) && !arg && !headers && !this.finalized ? new Response(text) : chunkQBQCMQ4F_js.__privateMethod(this, _Context_instances, newResponse_fn).call(this, text, arg, setDefaultContentType(TEXT_PLAIN, headers));
|
|
1224
841
|
});
|
|
1225
842
|
/**
|
|
1226
843
|
* `.json()` can render JSON as `Content-Type:application/json`.
|
|
@@ -1234,11 +851,11 @@ var Context = (_a2 = class {
|
|
|
1234
851
|
* })
|
|
1235
852
|
* ```
|
|
1236
853
|
*/
|
|
1237
|
-
|
|
1238
|
-
return
|
|
854
|
+
chunkQBQCMQ4F_js.__publicField(this, "json", (object, arg, headers) => {
|
|
855
|
+
return chunkQBQCMQ4F_js.__privateMethod(this, _Context_instances, newResponse_fn).call(this, JSON.stringify(object), arg, setDefaultContentType("application/json", headers));
|
|
1239
856
|
});
|
|
1240
|
-
|
|
1241
|
-
const res = (html2) =>
|
|
857
|
+
chunkQBQCMQ4F_js.__publicField(this, "html", (html, arg, headers) => {
|
|
858
|
+
const res = (html2) => chunkQBQCMQ4F_js.__privateMethod(this, _Context_instances, newResponse_fn).call(this, html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
|
|
1242
859
|
return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
|
|
1243
860
|
});
|
|
1244
861
|
/**
|
|
@@ -1256,7 +873,7 @@ var Context = (_a2 = class {
|
|
|
1256
873
|
* })
|
|
1257
874
|
* ```
|
|
1258
875
|
*/
|
|
1259
|
-
|
|
876
|
+
chunkQBQCMQ4F_js.__publicField(this, "redirect", (location, status) => {
|
|
1260
877
|
const locationString = String(location);
|
|
1261
878
|
this.header(
|
|
1262
879
|
"Location",
|
|
@@ -1278,25 +895,25 @@ var Context = (_a2 = class {
|
|
|
1278
895
|
* })
|
|
1279
896
|
* ```
|
|
1280
897
|
*/
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
return
|
|
898
|
+
chunkQBQCMQ4F_js.__publicField(this, "notFound", () => {
|
|
899
|
+
chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler) ?? chunkQBQCMQ4F_js.__privateSet(this, _notFoundHandler, () => createResponseInstance());
|
|
900
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler).call(this, this);
|
|
1284
901
|
});
|
|
1285
|
-
|
|
902
|
+
chunkQBQCMQ4F_js.__privateSet(this, _rawRequest, req);
|
|
1286
903
|
if (options) {
|
|
1287
|
-
|
|
904
|
+
chunkQBQCMQ4F_js.__privateSet(this, _executionCtx, options.executionCtx);
|
|
1288
905
|
this.env = options.env;
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
906
|
+
chunkQBQCMQ4F_js.__privateSet(this, _notFoundHandler, options.notFoundHandler);
|
|
907
|
+
chunkQBQCMQ4F_js.__privateSet(this, _path, options.path);
|
|
908
|
+
chunkQBQCMQ4F_js.__privateSet(this, _matchResult2, options.matchResult);
|
|
1292
909
|
}
|
|
1293
910
|
}
|
|
1294
911
|
/**
|
|
1295
912
|
* `.req` is the instance of {@link HonoRequest}.
|
|
1296
913
|
*/
|
|
1297
914
|
get req() {
|
|
1298
|
-
|
|
1299
|
-
return
|
|
915
|
+
chunkQBQCMQ4F_js.__privateGet(this, _req) ?? chunkQBQCMQ4F_js.__privateSet(this, _req, new HonoRequest(chunkQBQCMQ4F_js.__privateGet(this, _rawRequest), chunkQBQCMQ4F_js.__privateGet(this, _path), chunkQBQCMQ4F_js.__privateGet(this, _matchResult2)));
|
|
916
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _req);
|
|
1300
917
|
}
|
|
1301
918
|
/**
|
|
1302
919
|
* @see {@link https://hono.dev/docs/api/context#event}
|
|
@@ -1305,8 +922,8 @@ var Context = (_a2 = class {
|
|
|
1305
922
|
* @throws Will throw an error if the context does not have a FetchEvent.
|
|
1306
923
|
*/
|
|
1307
924
|
get event() {
|
|
1308
|
-
if (
|
|
1309
|
-
return
|
|
925
|
+
if (chunkQBQCMQ4F_js.__privateGet(this, _executionCtx) && "respondWith" in chunkQBQCMQ4F_js.__privateGet(this, _executionCtx)) {
|
|
926
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _executionCtx);
|
|
1310
927
|
} else {
|
|
1311
928
|
throw Error("This context has no FetchEvent");
|
|
1312
929
|
}
|
|
@@ -1318,8 +935,8 @@ var Context = (_a2 = class {
|
|
|
1318
935
|
* @throws Will throw an error if the context does not have an ExecutionContext.
|
|
1319
936
|
*/
|
|
1320
937
|
get executionCtx() {
|
|
1321
|
-
if (
|
|
1322
|
-
return
|
|
938
|
+
if (chunkQBQCMQ4F_js.__privateGet(this, _executionCtx)) {
|
|
939
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _executionCtx);
|
|
1323
940
|
} else {
|
|
1324
941
|
throw Error("This context has no ExecutionContext");
|
|
1325
942
|
}
|
|
@@ -1329,8 +946,8 @@ var Context = (_a2 = class {
|
|
|
1329
946
|
* The Response object for the current request.
|
|
1330
947
|
*/
|
|
1331
948
|
get res() {
|
|
1332
|
-
return
|
|
1333
|
-
headers:
|
|
949
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _res) || chunkQBQCMQ4F_js.__privateSet(this, _res, createResponseInstance(null, {
|
|
950
|
+
headers: chunkQBQCMQ4F_js.__privateGet(this, _preparedHeaders) ?? chunkQBQCMQ4F_js.__privateSet(this, _preparedHeaders, new Headers())
|
|
1334
951
|
}));
|
|
1335
952
|
}
|
|
1336
953
|
/**
|
|
@@ -1339,14 +956,14 @@ var Context = (_a2 = class {
|
|
|
1339
956
|
* @param _res - The Response object to set.
|
|
1340
957
|
*/
|
|
1341
958
|
set res(_res2) {
|
|
1342
|
-
if (
|
|
959
|
+
if (chunkQBQCMQ4F_js.__privateGet(this, _res) && _res2) {
|
|
1343
960
|
_res2 = createResponseInstance(_res2.body, _res2);
|
|
1344
|
-
for (const [k, v] of
|
|
961
|
+
for (const [k, v] of chunkQBQCMQ4F_js.__privateGet(this, _res).headers.entries()) {
|
|
1345
962
|
if (k === "content-type") {
|
|
1346
963
|
continue;
|
|
1347
964
|
}
|
|
1348
965
|
if (k === "set-cookie") {
|
|
1349
|
-
const cookies =
|
|
966
|
+
const cookies = chunkQBQCMQ4F_js.__privateGet(this, _res).headers.getSetCookie();
|
|
1350
967
|
_res2.headers.delete("set-cookie");
|
|
1351
968
|
for (const cookie of cookies) {
|
|
1352
969
|
_res2.headers.append("set-cookie", cookie);
|
|
@@ -1356,7 +973,7 @@ var Context = (_a2 = class {
|
|
|
1356
973
|
}
|
|
1357
974
|
}
|
|
1358
975
|
}
|
|
1359
|
-
|
|
976
|
+
chunkQBQCMQ4F_js.__privateSet(this, _res, _res2);
|
|
1360
977
|
this.finalized = true;
|
|
1361
978
|
}
|
|
1362
979
|
/**
|
|
@@ -1371,13 +988,13 @@ var Context = (_a2 = class {
|
|
|
1371
988
|
*/
|
|
1372
989
|
// c.var.propName is a read-only
|
|
1373
990
|
get var() {
|
|
1374
|
-
if (!
|
|
991
|
+
if (!chunkQBQCMQ4F_js.__privateGet(this, _var)) {
|
|
1375
992
|
return {};
|
|
1376
993
|
}
|
|
1377
|
-
return Object.fromEntries(
|
|
994
|
+
return Object.fromEntries(chunkQBQCMQ4F_js.__privateGet(this, _var));
|
|
1378
995
|
}
|
|
1379
996
|
}, _rawRequest = new WeakMap(), _req = new WeakMap(), _var = new WeakMap(), _status = new WeakMap(), _executionCtx = new WeakMap(), _res = new WeakMap(), _layout = new WeakMap(), _renderer = new WeakMap(), _notFoundHandler = new WeakMap(), _preparedHeaders = new WeakMap(), _matchResult2 = new WeakMap(), _path = new WeakMap(), _Context_instances = new WeakSet(), newResponse_fn = function(data, arg, headers) {
|
|
1380
|
-
const responseHeaders =
|
|
997
|
+
const responseHeaders = chunkQBQCMQ4F_js.__privateGet(this, _res) ? new Headers(chunkQBQCMQ4F_js.__privateGet(this, _res).headers) : chunkQBQCMQ4F_js.__privateGet(this, _preparedHeaders) ?? new Headers();
|
|
1381
998
|
if (typeof arg === "object" && "headers" in arg) {
|
|
1382
999
|
const argHeaders = arg.headers instanceof Headers ? arg.headers : new Headers(arg.headers);
|
|
1383
1000
|
for (const [key, value] of argHeaders) {
|
|
@@ -1400,7 +1017,7 @@ var Context = (_a2 = class {
|
|
|
1400
1017
|
}
|
|
1401
1018
|
}
|
|
1402
1019
|
}
|
|
1403
|
-
const status = typeof arg === "number" ? arg : arg?.status ??
|
|
1020
|
+
const status = typeof arg === "number" ? arg : arg?.status ?? chunkQBQCMQ4F_js.__privateGet(this, _status);
|
|
1404
1021
|
return createResponseInstance(data, { status, headers: responseHeaders });
|
|
1405
1022
|
}, _a2);
|
|
1406
1023
|
|
|
@@ -1430,29 +1047,29 @@ var errorHandler = (err, c) => {
|
|
|
1430
1047
|
var _path2, __Hono_instances, clone_fn, _notFoundHandler2, addRoute_fn, handleError_fn, dispatch_fn, _a3;
|
|
1431
1048
|
var Hono = (_a3 = class {
|
|
1432
1049
|
constructor(options = {}) {
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1050
|
+
chunkQBQCMQ4F_js.__privateAdd(this, __Hono_instances);
|
|
1051
|
+
chunkQBQCMQ4F_js.__publicField(this, "get");
|
|
1052
|
+
chunkQBQCMQ4F_js.__publicField(this, "post");
|
|
1053
|
+
chunkQBQCMQ4F_js.__publicField(this, "put");
|
|
1054
|
+
chunkQBQCMQ4F_js.__publicField(this, "delete");
|
|
1055
|
+
chunkQBQCMQ4F_js.__publicField(this, "options");
|
|
1056
|
+
chunkQBQCMQ4F_js.__publicField(this, "patch");
|
|
1057
|
+
chunkQBQCMQ4F_js.__publicField(this, "all");
|
|
1058
|
+
chunkQBQCMQ4F_js.__publicField(this, "on");
|
|
1059
|
+
chunkQBQCMQ4F_js.__publicField(this, "use");
|
|
1443
1060
|
/*
|
|
1444
1061
|
This class is like an abstract class and does not have a router.
|
|
1445
1062
|
To use it, inherit the class and implement router in the constructor.
|
|
1446
1063
|
*/
|
|
1447
|
-
|
|
1448
|
-
|
|
1064
|
+
chunkQBQCMQ4F_js.__publicField(this, "router");
|
|
1065
|
+
chunkQBQCMQ4F_js.__publicField(this, "getPath");
|
|
1449
1066
|
// Cannot use `#` because it requires visibility at JavaScript runtime.
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1067
|
+
chunkQBQCMQ4F_js.__publicField(this, "_basePath", "/");
|
|
1068
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _path2, "/");
|
|
1069
|
+
chunkQBQCMQ4F_js.__publicField(this, "routes", []);
|
|
1070
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _notFoundHandler2, notFoundHandler);
|
|
1454
1071
|
// Cannot use `#` because it requires visibility at JavaScript runtime.
|
|
1455
|
-
|
|
1072
|
+
chunkQBQCMQ4F_js.__publicField(this, "errorHandler", errorHandler);
|
|
1456
1073
|
/**
|
|
1457
1074
|
* `.onError()` handles an error and returns a customized Response.
|
|
1458
1075
|
*
|
|
@@ -1469,7 +1086,7 @@ var Hono = (_a3 = class {
|
|
|
1469
1086
|
* })
|
|
1470
1087
|
* ```
|
|
1471
1088
|
*/
|
|
1472
|
-
|
|
1089
|
+
chunkQBQCMQ4F_js.__publicField(this, "onError", (handler) => {
|
|
1473
1090
|
this.errorHandler = handler;
|
|
1474
1091
|
return this;
|
|
1475
1092
|
});
|
|
@@ -1488,8 +1105,8 @@ var Hono = (_a3 = class {
|
|
|
1488
1105
|
* })
|
|
1489
1106
|
* ```
|
|
1490
1107
|
*/
|
|
1491
|
-
|
|
1492
|
-
|
|
1108
|
+
chunkQBQCMQ4F_js.__publicField(this, "notFound", (handler) => {
|
|
1109
|
+
chunkQBQCMQ4F_js.__privateSet(this, _notFoundHandler2, handler);
|
|
1493
1110
|
return this;
|
|
1494
1111
|
});
|
|
1495
1112
|
/**
|
|
@@ -1503,8 +1120,8 @@ var Hono = (_a3 = class {
|
|
|
1503
1120
|
* @returns {Response | Promise<Response>} response of request
|
|
1504
1121
|
*
|
|
1505
1122
|
*/
|
|
1506
|
-
|
|
1507
|
-
return
|
|
1123
|
+
chunkQBQCMQ4F_js.__publicField(this, "fetch", (request, ...rest) => {
|
|
1124
|
+
return chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, dispatch_fn).call(this, request, rest[1], rest[0], request.method);
|
|
1508
1125
|
});
|
|
1509
1126
|
/**
|
|
1510
1127
|
* `.request()` is a useful method for testing.
|
|
@@ -1518,7 +1135,7 @@ var Hono = (_a3 = class {
|
|
|
1518
1135
|
* ```
|
|
1519
1136
|
* @see https://hono.dev/docs/api/hono#request
|
|
1520
1137
|
*/
|
|
1521
|
-
|
|
1138
|
+
chunkQBQCMQ4F_js.__publicField(this, "request", (input, requestInit, Env, executionCtx) => {
|
|
1522
1139
|
if (input instanceof Request) {
|
|
1523
1140
|
return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
|
|
1524
1141
|
}
|
|
@@ -1549,31 +1166,31 @@ var Hono = (_a3 = class {
|
|
|
1549
1166
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
1550
1167
|
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
|
|
1551
1168
|
*/
|
|
1552
|
-
|
|
1169
|
+
chunkQBQCMQ4F_js.__publicField(this, "fire", () => {
|
|
1553
1170
|
addEventListener("fetch", (event) => {
|
|
1554
|
-
event.respondWith(
|
|
1171
|
+
event.respondWith(chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, dispatch_fn).call(this, event.request, event, void 0, event.request.method));
|
|
1555
1172
|
});
|
|
1556
1173
|
});
|
|
1557
1174
|
const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
|
|
1558
1175
|
allMethods.forEach((method) => {
|
|
1559
1176
|
this[method] = (args1, ...args) => {
|
|
1560
1177
|
if (typeof args1 === "string") {
|
|
1561
|
-
|
|
1178
|
+
chunkQBQCMQ4F_js.__privateSet(this, _path2, args1);
|
|
1562
1179
|
} else {
|
|
1563
|
-
|
|
1180
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, addRoute_fn).call(this, method, chunkQBQCMQ4F_js.__privateGet(this, _path2), args1);
|
|
1564
1181
|
}
|
|
1565
1182
|
args.forEach((handler) => {
|
|
1566
|
-
|
|
1183
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, addRoute_fn).call(this, method, chunkQBQCMQ4F_js.__privateGet(this, _path2), handler);
|
|
1567
1184
|
});
|
|
1568
1185
|
return this;
|
|
1569
1186
|
};
|
|
1570
1187
|
});
|
|
1571
1188
|
this.on = (method, path, ...handlers) => {
|
|
1572
1189
|
for (const p of [path].flat()) {
|
|
1573
|
-
|
|
1190
|
+
chunkQBQCMQ4F_js.__privateSet(this, _path2, p);
|
|
1574
1191
|
for (const m of [method].flat()) {
|
|
1575
1192
|
handlers.map((handler) => {
|
|
1576
|
-
|
|
1193
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, addRoute_fn).call(this, m.toUpperCase(), chunkQBQCMQ4F_js.__privateGet(this, _path2), handler);
|
|
1577
1194
|
});
|
|
1578
1195
|
}
|
|
1579
1196
|
}
|
|
@@ -1581,13 +1198,13 @@ var Hono = (_a3 = class {
|
|
|
1581
1198
|
};
|
|
1582
1199
|
this.use = (arg1, ...handlers) => {
|
|
1583
1200
|
if (typeof arg1 === "string") {
|
|
1584
|
-
|
|
1201
|
+
chunkQBQCMQ4F_js.__privateSet(this, _path2, arg1);
|
|
1585
1202
|
} else {
|
|
1586
|
-
|
|
1203
|
+
chunkQBQCMQ4F_js.__privateSet(this, _path2, "*");
|
|
1587
1204
|
handlers.unshift(arg1);
|
|
1588
1205
|
}
|
|
1589
1206
|
handlers.forEach((handler) => {
|
|
1590
|
-
|
|
1207
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, addRoute_fn).call(this, METHOD_NAME_ALL, chunkQBQCMQ4F_js.__privateGet(this, _path2), handler);
|
|
1591
1208
|
});
|
|
1592
1209
|
return this;
|
|
1593
1210
|
};
|
|
@@ -1624,7 +1241,7 @@ var Hono = (_a3 = class {
|
|
|
1624
1241
|
handler = async (c, next) => (await compose([], app.errorHandler)(c, () => r.handler(c, next))).res;
|
|
1625
1242
|
handler[COMPOSED_HANDLER] = r.handler;
|
|
1626
1243
|
}
|
|
1627
|
-
|
|
1244
|
+
chunkQBQCMQ4F_js.__privateMethod(_a10 = subApp, __Hono_instances, addRoute_fn).call(_a10, r.method, r.path, handler);
|
|
1628
1245
|
});
|
|
1629
1246
|
return this;
|
|
1630
1247
|
}
|
|
@@ -1642,7 +1259,7 @@ var Hono = (_a3 = class {
|
|
|
1642
1259
|
* ```
|
|
1643
1260
|
*/
|
|
1644
1261
|
basePath(path) {
|
|
1645
|
-
const subApp =
|
|
1262
|
+
const subApp = chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, clone_fn).call(this);
|
|
1646
1263
|
subApp._basePath = mergePath(this._basePath, path);
|
|
1647
1264
|
return subApp;
|
|
1648
1265
|
}
|
|
@@ -1720,7 +1337,7 @@ var Hono = (_a3 = class {
|
|
|
1720
1337
|
}
|
|
1721
1338
|
await next();
|
|
1722
1339
|
};
|
|
1723
|
-
|
|
1340
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, addRoute_fn).call(this, METHOD_NAME_ALL, mergePath(path, "*"), handler);
|
|
1724
1341
|
return this;
|
|
1725
1342
|
}
|
|
1726
1343
|
}, _path2 = new WeakMap(), __Hono_instances = new WeakSet(), clone_fn = function() {
|
|
@@ -1729,7 +1346,7 @@ var Hono = (_a3 = class {
|
|
|
1729
1346
|
getPath: this.getPath
|
|
1730
1347
|
});
|
|
1731
1348
|
clone.errorHandler = this.errorHandler;
|
|
1732
|
-
|
|
1349
|
+
chunkQBQCMQ4F_js.__privateSet(clone, _notFoundHandler2, chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler2));
|
|
1733
1350
|
clone.routes = this.routes;
|
|
1734
1351
|
return clone;
|
|
1735
1352
|
}, _notFoundHandler2 = new WeakMap(), addRoute_fn = function(method, path, handler) {
|
|
@@ -1745,7 +1362,7 @@ var Hono = (_a3 = class {
|
|
|
1745
1362
|
throw err;
|
|
1746
1363
|
}, dispatch_fn = function(request, executionCtx, env, method) {
|
|
1747
1364
|
if (method === "HEAD") {
|
|
1748
|
-
return (async () => new Response(null, await
|
|
1365
|
+
return (async () => new Response(null, await chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, dispatch_fn).call(this, request, executionCtx, env, "GET")))();
|
|
1749
1366
|
}
|
|
1750
1367
|
const path = this.getPath(request, { env });
|
|
1751
1368
|
const matchResult = this.router.match(method, path);
|
|
@@ -1754,22 +1371,22 @@ var Hono = (_a3 = class {
|
|
|
1754
1371
|
matchResult,
|
|
1755
1372
|
env,
|
|
1756
1373
|
executionCtx,
|
|
1757
|
-
notFoundHandler:
|
|
1374
|
+
notFoundHandler: chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler2)
|
|
1758
1375
|
});
|
|
1759
1376
|
if (matchResult[0].length === 1) {
|
|
1760
1377
|
let res;
|
|
1761
1378
|
try {
|
|
1762
1379
|
res = matchResult[0][0][0][0](c, async () => {
|
|
1763
|
-
c.res = await
|
|
1380
|
+
c.res = await chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler2).call(this, c);
|
|
1764
1381
|
});
|
|
1765
1382
|
} catch (err) {
|
|
1766
|
-
return
|
|
1383
|
+
return chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, handleError_fn).call(this, err, c);
|
|
1767
1384
|
}
|
|
1768
1385
|
return res instanceof Promise ? res.then(
|
|
1769
|
-
(resolved) => resolved || (c.finalized ? c.res :
|
|
1770
|
-
).catch((err) =>
|
|
1386
|
+
(resolved) => resolved || (c.finalized ? c.res : chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler2).call(this, c))
|
|
1387
|
+
).catch((err) => chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, handleError_fn).call(this, err, c)) : res ?? chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler2).call(this, c);
|
|
1771
1388
|
}
|
|
1772
|
-
const composed = compose(matchResult[0], this.errorHandler,
|
|
1389
|
+
const composed = compose(matchResult[0], this.errorHandler, chunkQBQCMQ4F_js.__privateGet(this, _notFoundHandler2));
|
|
1773
1390
|
return (async () => {
|
|
1774
1391
|
try {
|
|
1775
1392
|
const context = await composed(c);
|
|
@@ -1780,7 +1397,7 @@ var Hono = (_a3 = class {
|
|
|
1780
1397
|
}
|
|
1781
1398
|
return context.res;
|
|
1782
1399
|
} catch (err) {
|
|
1783
|
-
return
|
|
1400
|
+
return chunkQBQCMQ4F_js.__privateMethod(this, __Hono_instances, handleError_fn).call(this, err, c);
|
|
1784
1401
|
}
|
|
1785
1402
|
})();
|
|
1786
1403
|
}, _a3);
|
|
@@ -1834,19 +1451,19 @@ function compareKey(a, b) {
|
|
|
1834
1451
|
var _index, _varIndex, _children, _a4;
|
|
1835
1452
|
var Node = (_a4 = class {
|
|
1836
1453
|
constructor() {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1454
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _index);
|
|
1455
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _varIndex);
|
|
1456
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _children, /* @__PURE__ */ Object.create(null));
|
|
1840
1457
|
}
|
|
1841
1458
|
insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
|
|
1842
1459
|
if (tokens.length === 0) {
|
|
1843
|
-
if (
|
|
1460
|
+
if (chunkQBQCMQ4F_js.__privateGet(this, _index) !== void 0) {
|
|
1844
1461
|
throw PATH_ERROR;
|
|
1845
1462
|
}
|
|
1846
1463
|
if (pathErrorCheckOnly) {
|
|
1847
1464
|
return;
|
|
1848
1465
|
}
|
|
1849
|
-
|
|
1466
|
+
chunkQBQCMQ4F_js.__privateSet(this, _index, index);
|
|
1850
1467
|
return;
|
|
1851
1468
|
}
|
|
1852
1469
|
const [token, ...restTokens] = tokens;
|
|
@@ -1864,9 +1481,9 @@ var Node = (_a4 = class {
|
|
|
1864
1481
|
throw PATH_ERROR;
|
|
1865
1482
|
}
|
|
1866
1483
|
}
|
|
1867
|
-
node =
|
|
1484
|
+
node = chunkQBQCMQ4F_js.__privateGet(this, _children)[regexpStr];
|
|
1868
1485
|
if (!node) {
|
|
1869
|
-
if (Object.keys(
|
|
1486
|
+
if (Object.keys(chunkQBQCMQ4F_js.__privateGet(this, _children)).some(
|
|
1870
1487
|
(k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
|
|
1871
1488
|
)) {
|
|
1872
1489
|
throw PATH_ERROR;
|
|
@@ -1874,18 +1491,18 @@ var Node = (_a4 = class {
|
|
|
1874
1491
|
if (pathErrorCheckOnly) {
|
|
1875
1492
|
return;
|
|
1876
1493
|
}
|
|
1877
|
-
node =
|
|
1494
|
+
node = chunkQBQCMQ4F_js.__privateGet(this, _children)[regexpStr] = new _a4();
|
|
1878
1495
|
if (name !== "") {
|
|
1879
|
-
|
|
1496
|
+
chunkQBQCMQ4F_js.__privateSet(node, _varIndex, context.varIndex++);
|
|
1880
1497
|
}
|
|
1881
1498
|
}
|
|
1882
1499
|
if (!pathErrorCheckOnly && name !== "") {
|
|
1883
|
-
paramMap.push([name,
|
|
1500
|
+
paramMap.push([name, chunkQBQCMQ4F_js.__privateGet(node, _varIndex)]);
|
|
1884
1501
|
}
|
|
1885
1502
|
} else {
|
|
1886
|
-
node =
|
|
1503
|
+
node = chunkQBQCMQ4F_js.__privateGet(this, _children)[token];
|
|
1887
1504
|
if (!node) {
|
|
1888
|
-
if (Object.keys(
|
|
1505
|
+
if (Object.keys(chunkQBQCMQ4F_js.__privateGet(this, _children)).some(
|
|
1889
1506
|
(k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
|
|
1890
1507
|
)) {
|
|
1891
1508
|
throw PATH_ERROR;
|
|
@@ -1893,19 +1510,19 @@ var Node = (_a4 = class {
|
|
|
1893
1510
|
if (pathErrorCheckOnly) {
|
|
1894
1511
|
return;
|
|
1895
1512
|
}
|
|
1896
|
-
node =
|
|
1513
|
+
node = chunkQBQCMQ4F_js.__privateGet(this, _children)[token] = new _a4();
|
|
1897
1514
|
}
|
|
1898
1515
|
}
|
|
1899
1516
|
node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
|
|
1900
1517
|
}
|
|
1901
1518
|
buildRegExpStr() {
|
|
1902
|
-
const childKeys = Object.keys(
|
|
1519
|
+
const childKeys = Object.keys(chunkQBQCMQ4F_js.__privateGet(this, _children)).sort(compareKey);
|
|
1903
1520
|
const strList = childKeys.map((k) => {
|
|
1904
|
-
const c =
|
|
1905
|
-
return (typeof
|
|
1521
|
+
const c = chunkQBQCMQ4F_js.__privateGet(this, _children)[k];
|
|
1522
|
+
return (typeof chunkQBQCMQ4F_js.__privateGet(c, _varIndex) === "number" ? `(${k})@${chunkQBQCMQ4F_js.__privateGet(c, _varIndex)}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
|
|
1906
1523
|
});
|
|
1907
|
-
if (typeof
|
|
1908
|
-
strList.unshift(`#${
|
|
1524
|
+
if (typeof chunkQBQCMQ4F_js.__privateGet(this, _index) === "number") {
|
|
1525
|
+
strList.unshift(`#${chunkQBQCMQ4F_js.__privateGet(this, _index)}`);
|
|
1909
1526
|
}
|
|
1910
1527
|
if (strList.length === 0) {
|
|
1911
1528
|
return "";
|
|
@@ -1921,8 +1538,8 @@ var Node = (_a4 = class {
|
|
|
1921
1538
|
var _context, _root, _a5;
|
|
1922
1539
|
var Trie = (_a5 = class {
|
|
1923
1540
|
constructor() {
|
|
1924
|
-
|
|
1925
|
-
|
|
1541
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _context, { varIndex: 0 });
|
|
1542
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _root, new Node());
|
|
1926
1543
|
}
|
|
1927
1544
|
insert(path, index, pathErrorCheckOnly) {
|
|
1928
1545
|
const paramAssoc = [];
|
|
@@ -1950,11 +1567,11 @@ var Trie = (_a5 = class {
|
|
|
1950
1567
|
}
|
|
1951
1568
|
}
|
|
1952
1569
|
}
|
|
1953
|
-
|
|
1570
|
+
chunkQBQCMQ4F_js.__privateGet(this, _root).insert(tokens, index, paramAssoc, chunkQBQCMQ4F_js.__privateGet(this, _context), pathErrorCheckOnly);
|
|
1954
1571
|
return paramAssoc;
|
|
1955
1572
|
}
|
|
1956
1573
|
buildRegExp() {
|
|
1957
|
-
let regexp =
|
|
1574
|
+
let regexp = chunkQBQCMQ4F_js.__privateGet(this, _root).buildRegExpStr();
|
|
1958
1575
|
if (regexp === "") {
|
|
1959
1576
|
return [/^$/, [], []];
|
|
1960
1577
|
}
|
|
@@ -2061,18 +1678,18 @@ function findMiddleware(middleware, path) {
|
|
|
2061
1678
|
var _middleware, _routes, _RegExpRouter_instances, buildMatcher_fn, _a6;
|
|
2062
1679
|
var RegExpRouter = (_a6 = class {
|
|
2063
1680
|
constructor() {
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
1681
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _RegExpRouter_instances);
|
|
1682
|
+
chunkQBQCMQ4F_js.__publicField(this, "name", "RegExpRouter");
|
|
1683
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _middleware);
|
|
1684
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _routes);
|
|
1685
|
+
chunkQBQCMQ4F_js.__publicField(this, "match", match);
|
|
1686
|
+
chunkQBQCMQ4F_js.__privateSet(this, _middleware, { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) });
|
|
1687
|
+
chunkQBQCMQ4F_js.__privateSet(this, _routes, { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) });
|
|
2071
1688
|
}
|
|
2072
1689
|
add(method, path, handler) {
|
|
2073
1690
|
var _a10;
|
|
2074
|
-
const middleware =
|
|
2075
|
-
const routes =
|
|
1691
|
+
const middleware = chunkQBQCMQ4F_js.__privateGet(this, _middleware);
|
|
1692
|
+
const routes = chunkQBQCMQ4F_js.__privateGet(this, _routes);
|
|
2076
1693
|
if (!middleware || !routes) {
|
|
2077
1694
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
2078
1695
|
}
|
|
@@ -2130,17 +1747,17 @@ var RegExpRouter = (_a6 = class {
|
|
|
2130
1747
|
}
|
|
2131
1748
|
buildAllMatchers() {
|
|
2132
1749
|
const matchers = /* @__PURE__ */ Object.create(null);
|
|
2133
|
-
Object.keys(
|
|
2134
|
-
matchers[method] || (matchers[method] =
|
|
1750
|
+
Object.keys(chunkQBQCMQ4F_js.__privateGet(this, _routes)).concat(Object.keys(chunkQBQCMQ4F_js.__privateGet(this, _middleware))).forEach((method) => {
|
|
1751
|
+
matchers[method] || (matchers[method] = chunkQBQCMQ4F_js.__privateMethod(this, _RegExpRouter_instances, buildMatcher_fn).call(this, method));
|
|
2135
1752
|
});
|
|
2136
|
-
|
|
1753
|
+
chunkQBQCMQ4F_js.__privateSet(this, _middleware, chunkQBQCMQ4F_js.__privateSet(this, _routes, void 0));
|
|
2137
1754
|
clearWildcardRegExpCache();
|
|
2138
1755
|
return matchers;
|
|
2139
1756
|
}
|
|
2140
1757
|
}, _middleware = new WeakMap(), _routes = new WeakMap(), _RegExpRouter_instances = new WeakSet(), buildMatcher_fn = function(method) {
|
|
2141
1758
|
const routes = [];
|
|
2142
1759
|
let hasOwnRoute = method === METHOD_NAME_ALL;
|
|
2143
|
-
[
|
|
1760
|
+
[chunkQBQCMQ4F_js.__privateGet(this, _middleware), chunkQBQCMQ4F_js.__privateGet(this, _routes)].forEach((r) => {
|
|
2144
1761
|
const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];
|
|
2145
1762
|
if (ownRoute.length !== 0) {
|
|
2146
1763
|
hasOwnRoute || (hasOwnRoute = true);
|
|
@@ -2162,23 +1779,23 @@ var RegExpRouter = (_a6 = class {
|
|
|
2162
1779
|
var _routers, _routes2, _a7;
|
|
2163
1780
|
var SmartRouter = (_a7 = class {
|
|
2164
1781
|
constructor(init) {
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
1782
|
+
chunkQBQCMQ4F_js.__publicField(this, "name", "SmartRouter");
|
|
1783
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _routers, []);
|
|
1784
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _routes2, []);
|
|
1785
|
+
chunkQBQCMQ4F_js.__privateSet(this, _routers, init.routers);
|
|
2169
1786
|
}
|
|
2170
1787
|
add(method, path, handler) {
|
|
2171
|
-
if (!
|
|
1788
|
+
if (!chunkQBQCMQ4F_js.__privateGet(this, _routes2)) {
|
|
2172
1789
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
2173
1790
|
}
|
|
2174
|
-
|
|
1791
|
+
chunkQBQCMQ4F_js.__privateGet(this, _routes2).push([method, path, handler]);
|
|
2175
1792
|
}
|
|
2176
1793
|
match(method, path) {
|
|
2177
|
-
if (!
|
|
1794
|
+
if (!chunkQBQCMQ4F_js.__privateGet(this, _routes2)) {
|
|
2178
1795
|
throw new Error("Fatal error");
|
|
2179
1796
|
}
|
|
2180
|
-
const routers =
|
|
2181
|
-
const routes =
|
|
1797
|
+
const routers = chunkQBQCMQ4F_js.__privateGet(this, _routers);
|
|
1798
|
+
const routes = chunkQBQCMQ4F_js.__privateGet(this, _routes2);
|
|
2182
1799
|
const len = routers.length;
|
|
2183
1800
|
let i = 0;
|
|
2184
1801
|
let res;
|
|
@@ -2196,8 +1813,8 @@ var SmartRouter = (_a7 = class {
|
|
|
2196
1813
|
throw e;
|
|
2197
1814
|
}
|
|
2198
1815
|
this.match = router.match.bind(router);
|
|
2199
|
-
|
|
2200
|
-
|
|
1816
|
+
chunkQBQCMQ4F_js.__privateSet(this, _routers, [router]);
|
|
1817
|
+
chunkQBQCMQ4F_js.__privateSet(this, _routes2, void 0);
|
|
2201
1818
|
break;
|
|
2202
1819
|
}
|
|
2203
1820
|
if (i === len) {
|
|
@@ -2207,10 +1824,10 @@ var SmartRouter = (_a7 = class {
|
|
|
2207
1824
|
return res;
|
|
2208
1825
|
}
|
|
2209
1826
|
get activeRouter() {
|
|
2210
|
-
if (
|
|
1827
|
+
if (chunkQBQCMQ4F_js.__privateGet(this, _routes2) || chunkQBQCMQ4F_js.__privateGet(this, _routers).length !== 1) {
|
|
2211
1828
|
throw new Error("No active router has been determined yet.");
|
|
2212
1829
|
}
|
|
2213
|
-
return
|
|
1830
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _routers)[0];
|
|
2214
1831
|
}
|
|
2215
1832
|
}, _routers = new WeakMap(), _routes2 = new WeakMap(), _a7);
|
|
2216
1833
|
|
|
@@ -2225,23 +1842,23 @@ var hasChildren = (children) => {
|
|
|
2225
1842
|
var _methods, _children2, _patterns, _order, _params, __Node_instances, pushHandlerSets_fn, _a8;
|
|
2226
1843
|
var Node2 = (_a8 = class {
|
|
2227
1844
|
constructor(method, handler, children) {
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
1845
|
+
chunkQBQCMQ4F_js.__privateAdd(this, __Node_instances);
|
|
1846
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _methods);
|
|
1847
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _children2);
|
|
1848
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _patterns);
|
|
1849
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _order, 0);
|
|
1850
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _params, emptyParams);
|
|
1851
|
+
chunkQBQCMQ4F_js.__privateSet(this, _children2, children || /* @__PURE__ */ Object.create(null));
|
|
1852
|
+
chunkQBQCMQ4F_js.__privateSet(this, _methods, []);
|
|
2236
1853
|
if (method && handler) {
|
|
2237
1854
|
const m = /* @__PURE__ */ Object.create(null);
|
|
2238
1855
|
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
2239
|
-
|
|
1856
|
+
chunkQBQCMQ4F_js.__privateSet(this, _methods, [m]);
|
|
2240
1857
|
}
|
|
2241
|
-
|
|
1858
|
+
chunkQBQCMQ4F_js.__privateSet(this, _patterns, []);
|
|
2242
1859
|
}
|
|
2243
1860
|
insert(method, path, handler) {
|
|
2244
|
-
|
|
1861
|
+
chunkQBQCMQ4F_js.__privateSet(this, _order, ++chunkQBQCMQ4F_js.__privateWrapper(this, _order)._);
|
|
2245
1862
|
let curNode = this;
|
|
2246
1863
|
const parts = splitRoutingPath(path);
|
|
2247
1864
|
const possibleKeys = [];
|
|
@@ -2250,32 +1867,32 @@ var Node2 = (_a8 = class {
|
|
|
2250
1867
|
const nextP = parts[i + 1];
|
|
2251
1868
|
const pattern = getPattern(p, nextP);
|
|
2252
1869
|
const key = Array.isArray(pattern) ? pattern[0] : p;
|
|
2253
|
-
if (key in
|
|
2254
|
-
curNode =
|
|
1870
|
+
if (key in chunkQBQCMQ4F_js.__privateGet(curNode, _children2)) {
|
|
1871
|
+
curNode = chunkQBQCMQ4F_js.__privateGet(curNode, _children2)[key];
|
|
2255
1872
|
if (pattern) {
|
|
2256
1873
|
possibleKeys.push(pattern[1]);
|
|
2257
1874
|
}
|
|
2258
1875
|
continue;
|
|
2259
1876
|
}
|
|
2260
|
-
|
|
1877
|
+
chunkQBQCMQ4F_js.__privateGet(curNode, _children2)[key] = new _a8();
|
|
2261
1878
|
if (pattern) {
|
|
2262
|
-
|
|
1879
|
+
chunkQBQCMQ4F_js.__privateGet(curNode, _patterns).push(pattern);
|
|
2263
1880
|
possibleKeys.push(pattern[1]);
|
|
2264
1881
|
}
|
|
2265
|
-
curNode =
|
|
1882
|
+
curNode = chunkQBQCMQ4F_js.__privateGet(curNode, _children2)[key];
|
|
2266
1883
|
}
|
|
2267
|
-
|
|
1884
|
+
chunkQBQCMQ4F_js.__privateGet(curNode, _methods).push({
|
|
2268
1885
|
[method]: {
|
|
2269
1886
|
handler,
|
|
2270
1887
|
possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
|
|
2271
|
-
score:
|
|
1888
|
+
score: chunkQBQCMQ4F_js.__privateGet(this, _order)
|
|
2272
1889
|
}
|
|
2273
1890
|
});
|
|
2274
1891
|
return curNode;
|
|
2275
1892
|
}
|
|
2276
1893
|
search(method, path) {
|
|
2277
1894
|
const handlerSets = [];
|
|
2278
|
-
|
|
1895
|
+
chunkQBQCMQ4F_js.__privateSet(this, _params, emptyParams);
|
|
2279
1896
|
const curNode = this;
|
|
2280
1897
|
let curNodes = [curNode];
|
|
2281
1898
|
const parts = splitPath(path);
|
|
@@ -2288,26 +1905,26 @@ var Node2 = (_a8 = class {
|
|
|
2288
1905
|
const tempNodes = [];
|
|
2289
1906
|
for (let j = 0, len2 = curNodes.length; j < len2; j++) {
|
|
2290
1907
|
const node = curNodes[j];
|
|
2291
|
-
const nextNode =
|
|
1908
|
+
const nextNode = chunkQBQCMQ4F_js.__privateGet(node, _children2)[part];
|
|
2292
1909
|
if (nextNode) {
|
|
2293
|
-
|
|
1910
|
+
chunkQBQCMQ4F_js.__privateSet(nextNode, _params, chunkQBQCMQ4F_js.__privateGet(node, _params));
|
|
2294
1911
|
if (isLast) {
|
|
2295
|
-
if (
|
|
2296
|
-
|
|
1912
|
+
if (chunkQBQCMQ4F_js.__privateGet(nextNode, _children2)["*"]) {
|
|
1913
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Node_instances, pushHandlerSets_fn).call(this, handlerSets, chunkQBQCMQ4F_js.__privateGet(nextNode, _children2)["*"], method, chunkQBQCMQ4F_js.__privateGet(node, _params));
|
|
2297
1914
|
}
|
|
2298
|
-
|
|
1915
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Node_instances, pushHandlerSets_fn).call(this, handlerSets, nextNode, method, chunkQBQCMQ4F_js.__privateGet(node, _params));
|
|
2299
1916
|
} else {
|
|
2300
1917
|
tempNodes.push(nextNode);
|
|
2301
1918
|
}
|
|
2302
1919
|
}
|
|
2303
|
-
for (let k = 0, len3 =
|
|
2304
|
-
const pattern =
|
|
2305
|
-
const params =
|
|
1920
|
+
for (let k = 0, len3 = chunkQBQCMQ4F_js.__privateGet(node, _patterns).length; k < len3; k++) {
|
|
1921
|
+
const pattern = chunkQBQCMQ4F_js.__privateGet(node, _patterns)[k];
|
|
1922
|
+
const params = chunkQBQCMQ4F_js.__privateGet(node, _params) === emptyParams ? {} : { ...chunkQBQCMQ4F_js.__privateGet(node, _params) };
|
|
2306
1923
|
if (pattern === "*") {
|
|
2307
|
-
const astNode =
|
|
1924
|
+
const astNode = chunkQBQCMQ4F_js.__privateGet(node, _children2)["*"];
|
|
2308
1925
|
if (astNode) {
|
|
2309
|
-
|
|
2310
|
-
|
|
1926
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Node_instances, pushHandlerSets_fn).call(this, handlerSets, astNode, method, chunkQBQCMQ4F_js.__privateGet(node, _params));
|
|
1927
|
+
chunkQBQCMQ4F_js.__privateSet(astNode, _params, params);
|
|
2311
1928
|
tempNodes.push(astNode);
|
|
2312
1929
|
}
|
|
2313
1930
|
continue;
|
|
@@ -2316,7 +1933,7 @@ var Node2 = (_a8 = class {
|
|
|
2316
1933
|
if (!part && !(matcher instanceof RegExp)) {
|
|
2317
1934
|
continue;
|
|
2318
1935
|
}
|
|
2319
|
-
const child =
|
|
1936
|
+
const child = chunkQBQCMQ4F_js.__privateGet(node, _children2)[key];
|
|
2320
1937
|
if (matcher instanceof RegExp) {
|
|
2321
1938
|
if (partOffsets === null) {
|
|
2322
1939
|
partOffsets = new Array(len);
|
|
@@ -2330,9 +1947,9 @@ var Node2 = (_a8 = class {
|
|
|
2330
1947
|
const m = matcher.exec(restPathString);
|
|
2331
1948
|
if (m) {
|
|
2332
1949
|
params[name] = m[0];
|
|
2333
|
-
|
|
2334
|
-
if (hasChildren(
|
|
2335
|
-
|
|
1950
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Node_instances, pushHandlerSets_fn).call(this, handlerSets, child, method, chunkQBQCMQ4F_js.__privateGet(node, _params), params);
|
|
1951
|
+
if (hasChildren(chunkQBQCMQ4F_js.__privateGet(child, _children2))) {
|
|
1952
|
+
chunkQBQCMQ4F_js.__privateSet(child, _params, params);
|
|
2336
1953
|
const componentCount = m[0].match(/\//)?.length ?? 0;
|
|
2337
1954
|
const targetCurNodes = curNodesQueue[componentCount] || (curNodesQueue[componentCount] = []);
|
|
2338
1955
|
targetCurNodes.push(child);
|
|
@@ -2343,12 +1960,12 @@ var Node2 = (_a8 = class {
|
|
|
2343
1960
|
if (matcher === true || matcher.test(part)) {
|
|
2344
1961
|
params[name] = part;
|
|
2345
1962
|
if (isLast) {
|
|
2346
|
-
|
|
2347
|
-
if (
|
|
2348
|
-
|
|
1963
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Node_instances, pushHandlerSets_fn).call(this, handlerSets, child, method, params, chunkQBQCMQ4F_js.__privateGet(node, _params));
|
|
1964
|
+
if (chunkQBQCMQ4F_js.__privateGet(child, _children2)["*"]) {
|
|
1965
|
+
chunkQBQCMQ4F_js.__privateMethod(this, __Node_instances, pushHandlerSets_fn).call(this, handlerSets, chunkQBQCMQ4F_js.__privateGet(child, _children2)["*"], method, params, chunkQBQCMQ4F_js.__privateGet(node, _params));
|
|
2349
1966
|
}
|
|
2350
1967
|
} else {
|
|
2351
|
-
|
|
1968
|
+
chunkQBQCMQ4F_js.__privateSet(child, _params, params);
|
|
2352
1969
|
tempNodes.push(child);
|
|
2353
1970
|
}
|
|
2354
1971
|
}
|
|
@@ -2365,8 +1982,8 @@ var Node2 = (_a8 = class {
|
|
|
2365
1982
|
return [handlerSets.map(({ handler, params }) => [handler, params])];
|
|
2366
1983
|
}
|
|
2367
1984
|
}, _methods = new WeakMap(), _children2 = new WeakMap(), _patterns = new WeakMap(), _order = new WeakMap(), _params = new WeakMap(), __Node_instances = new WeakSet(), pushHandlerSets_fn = function(handlerSets, node, method, nodeParams, params) {
|
|
2368
|
-
for (let i = 0, len =
|
|
2369
|
-
const m =
|
|
1985
|
+
for (let i = 0, len = chunkQBQCMQ4F_js.__privateGet(node, _methods).length; i < len; i++) {
|
|
1986
|
+
const m = chunkQBQCMQ4F_js.__privateGet(node, _methods)[i];
|
|
2370
1987
|
const handlerSet = m[method] || m[METHOD_NAME_ALL];
|
|
2371
1988
|
const processedSet = {};
|
|
2372
1989
|
if (handlerSet !== void 0) {
|
|
@@ -2388,22 +2005,22 @@ var Node2 = (_a8 = class {
|
|
|
2388
2005
|
var _node, _a9;
|
|
2389
2006
|
var TrieRouter = (_a9 = class {
|
|
2390
2007
|
constructor() {
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2008
|
+
chunkQBQCMQ4F_js.__publicField(this, "name", "TrieRouter");
|
|
2009
|
+
chunkQBQCMQ4F_js.__privateAdd(this, _node);
|
|
2010
|
+
chunkQBQCMQ4F_js.__privateSet(this, _node, new Node2());
|
|
2394
2011
|
}
|
|
2395
2012
|
add(method, path, handler) {
|
|
2396
2013
|
const results = checkOptionalParameter(path);
|
|
2397
2014
|
if (results) {
|
|
2398
2015
|
for (let i = 0, len = results.length; i < len; i++) {
|
|
2399
|
-
|
|
2016
|
+
chunkQBQCMQ4F_js.__privateGet(this, _node).insert(method, results[i], handler);
|
|
2400
2017
|
}
|
|
2401
2018
|
return;
|
|
2402
2019
|
}
|
|
2403
|
-
|
|
2020
|
+
chunkQBQCMQ4F_js.__privateGet(this, _node).insert(method, path, handler);
|
|
2404
2021
|
}
|
|
2405
2022
|
match(method, path) {
|
|
2406
|
-
return
|
|
2023
|
+
return chunkQBQCMQ4F_js.__privateGet(this, _node).search(method, path);
|
|
2407
2024
|
}
|
|
2408
2025
|
}, _node = new WeakMap(), _a9);
|
|
2409
2026
|
|
|
@@ -2438,8 +2055,8 @@ var MockError = class extends Error {
|
|
|
2438
2055
|
};
|
|
2439
2056
|
}
|
|
2440
2057
|
};
|
|
2441
|
-
var notFound = (msg) => new MockError(
|
|
2442
|
-
var validation = (msg, ctx) => new MockError(
|
|
2058
|
+
var notFound = (msg) => new MockError(chunkQBQCMQ4F_js.ErrorCode.NOT_FOUND, msg, 404);
|
|
2059
|
+
var validation = (msg, ctx) => new MockError(chunkQBQCMQ4F_js.ErrorCode.VALIDATION_ERROR, msg, 400, ctx);
|
|
2443
2060
|
|
|
2444
2061
|
// src/mock/routes/_helpers.ts
|
|
2445
2062
|
function authMiddleware(deps) {
|
|
@@ -4659,7 +4276,9 @@ function toUICart(registry, cart) {
|
|
|
4659
4276
|
id: variant.id,
|
|
4660
4277
|
name: variantName,
|
|
4661
4278
|
sku: variant.sku,
|
|
4279
|
+
price: i.price,
|
|
4662
4280
|
price_adjustment: variant.price_adjustment,
|
|
4281
|
+
is_default: variant.is_default ?? false,
|
|
4663
4282
|
display_attributes: variantDisplayAttributes,
|
|
4664
4283
|
images: variant.images
|
|
4665
4284
|
} : void 0,
|
|
@@ -9204,167 +8823,4 @@ function createMockApp(options = {}) {
|
|
|
9204
8823
|
};
|
|
9205
8824
|
}
|
|
9206
8825
|
|
|
9207
|
-
|
|
9208
|
-
var TEST_BASE_URL = "http://test.local";
|
|
9209
|
-
async function toForwardedRequest(input, init) {
|
|
9210
|
-
if (input instanceof Request) {
|
|
9211
|
-
return {
|
|
9212
|
-
method: init?.method ?? input.method,
|
|
9213
|
-
headers: new Headers(init?.headers ?? input.headers),
|
|
9214
|
-
body: init?.body ?? (["GET", "HEAD"].includes(input.method) ? void 0 : await input.text())
|
|
9215
|
-
};
|
|
9216
|
-
}
|
|
9217
|
-
return {
|
|
9218
|
-
method: init?.method ?? "GET",
|
|
9219
|
-
headers: new Headers(init?.headers ?? {}),
|
|
9220
|
-
body: init?.body ?? void 0
|
|
9221
|
-
};
|
|
9222
|
-
}
|
|
9223
|
-
function createTestClient(options = {}) {
|
|
9224
|
-
const mock = createMockApp(options);
|
|
9225
|
-
let sessionToken;
|
|
9226
|
-
const fetchImpl = async (input, init) => {
|
|
9227
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
9228
|
-
if (!url.startsWith(TEST_BASE_URL)) {
|
|
9229
|
-
return globalThis.fetch(input, init);
|
|
9230
|
-
}
|
|
9231
|
-
const path = url.slice(TEST_BASE_URL.length);
|
|
9232
|
-
const fwd = await toForwardedRequest(input, init);
|
|
9233
|
-
if (sessionToken) fwd.headers.set("x-session-token", sessionToken);
|
|
9234
|
-
const res = await mock.request(path, {
|
|
9235
|
-
method: fwd.method,
|
|
9236
|
-
headers: fwd.headers,
|
|
9237
|
-
body: fwd.body
|
|
9238
|
-
});
|
|
9239
|
-
const echoed = res.headers.get("x-session-token");
|
|
9240
|
-
if (echoed) sessionToken = echoed;
|
|
9241
|
-
return res;
|
|
9242
|
-
};
|
|
9243
|
-
const client = chunkMBGQP6FZ_js.createCimplifyClient({
|
|
9244
|
-
baseUrl: TEST_BASE_URL,
|
|
9245
|
-
publicKey: "test-public-key",
|
|
9246
|
-
suppressPublicKeyWarning: true,
|
|
9247
|
-
fetch: fetchImpl
|
|
9248
|
-
});
|
|
9249
|
-
return {
|
|
9250
|
-
client,
|
|
9251
|
-
mock,
|
|
9252
|
-
reset: () => {
|
|
9253
|
-
mock.deps.resetAll();
|
|
9254
|
-
sessionToken = void 0;
|
|
9255
|
-
},
|
|
9256
|
-
dispose: () => {
|
|
9257
|
-
mock.deps.resetAll();
|
|
9258
|
-
sessionToken = void 0;
|
|
9259
|
-
}
|
|
9260
|
-
};
|
|
9261
|
-
}
|
|
9262
|
-
async function pickProduct(client, opts) {
|
|
9263
|
-
const list = await client.catalogue.getProducts();
|
|
9264
|
-
if (!list.ok) throw list.error;
|
|
9265
|
-
const body = list.value;
|
|
9266
|
-
const products = body.items ?? [];
|
|
9267
|
-
if (products.length === 0) throw new Error("No products in catalogue (wrong seed?)");
|
|
9268
|
-
if (opts.slug) {
|
|
9269
|
-
const found = products.find((p) => p.slug === opts.slug);
|
|
9270
|
-
if (!found) throw new Error(`Product slug "${opts.slug}" not found in catalogue`);
|
|
9271
|
-
return found;
|
|
9272
|
-
}
|
|
9273
|
-
return products.find((p) => p.type === "product") ?? products[0];
|
|
9274
|
-
}
|
|
9275
|
-
var fixtures = {
|
|
9276
|
-
/**
|
|
9277
|
-
* Add the first available product (or a named one) to the cart.
|
|
9278
|
-
* Picks the first variant if the product has variants.
|
|
9279
|
-
*/
|
|
9280
|
-
async addFirstProduct(client, opts = {}) {
|
|
9281
|
-
const product = await pickProduct(client, opts);
|
|
9282
|
-
let variantId;
|
|
9283
|
-
if (opts.withVariant !== false) {
|
|
9284
|
-
const variants = await client.catalogue.getVariants(product.id);
|
|
9285
|
-
if (variants.ok && variants.value.length > 0) {
|
|
9286
|
-
variantId = variants.value[0]?.id;
|
|
9287
|
-
}
|
|
9288
|
-
}
|
|
9289
|
-
const res = await client.cart.addItem({
|
|
9290
|
-
item_id: product.id,
|
|
9291
|
-
quantity: 1,
|
|
9292
|
-
variant_id: variantId
|
|
9293
|
-
});
|
|
9294
|
-
if (!res.ok) throw res.error;
|
|
9295
|
-
return { product, variantId };
|
|
9296
|
-
},
|
|
9297
|
-
/** A minimal valid customer object for checkout. */
|
|
9298
|
-
customer(overrides = {}) {
|
|
9299
|
-
return {
|
|
9300
|
-
name: overrides.name ?? "Test Customer",
|
|
9301
|
-
email: overrides.email ?? "test@example.com",
|
|
9302
|
-
phone: overrides.phone ?? "+233244000000"
|
|
9303
|
-
};
|
|
9304
|
-
},
|
|
9305
|
-
/**
|
|
9306
|
-
* Run the full guest auth flow (request OTP → verify) and return
|
|
9307
|
-
* the new session token. The mock's permissive auth mode echoes
|
|
9308
|
-
* the code in `request_otp`, so we don't need to read it.
|
|
9309
|
-
*/
|
|
9310
|
-
async authenticate(client, contact = "test@example.com", code = "123456") {
|
|
9311
|
-
const req = await client.auth.requestOtp(contact);
|
|
9312
|
-
if (!req.ok) throw req.error;
|
|
9313
|
-
const verify = await client.auth.verifyOtp(contact, code);
|
|
9314
|
-
if (!verify.ok) throw verify.error;
|
|
9315
|
-
const value = verify.value;
|
|
9316
|
-
return { token: value.session_token ?? "", customerId: value.customer_id ?? "" };
|
|
9317
|
-
}
|
|
9318
|
-
};
|
|
9319
|
-
|
|
9320
|
-
exports.AddItemPayloadSchema = AddItemPayloadSchema;
|
|
9321
|
-
exports.AddOnDetailsSchema = AddOnDetailsSchema;
|
|
9322
|
-
exports.AuthorizationTypeSchema = AuthorizationTypeSchema;
|
|
9323
|
-
exports.BrandContactSchema = BrandContactSchema;
|
|
9324
|
-
exports.BrandFaqSchema = BrandFaqSchema;
|
|
9325
|
-
exports.BrandHeroSchema = BrandHeroSchema;
|
|
9326
|
-
exports.BrandNavLinkSchema = BrandNavLinkSchema;
|
|
9327
|
-
exports.BrandPolicyPageSchema = BrandPolicyPageSchema;
|
|
9328
|
-
exports.BrandPolicySectionSchema = BrandPolicySectionSchema;
|
|
9329
|
-
exports.BrandSchema = BrandSchema;
|
|
9330
|
-
exports.BrandSocialSchema = BrandSocialSchema;
|
|
9331
|
-
exports.BundleResolvedSchema = BundleResolvedSchema;
|
|
9332
|
-
exports.BundleSelectionInputSchema = BundleSelectionInputSchema;
|
|
9333
|
-
exports.CartItemSchema = CartItemSchema;
|
|
9334
|
-
exports.CartPricingSchema = CartPricingSchema;
|
|
9335
|
-
exports.CartSchema = CartSchema;
|
|
9336
|
-
exports.CheckoutBodySchema = CheckoutBodySchema;
|
|
9337
|
-
exports.CheckoutCustomerSchema = CheckoutCustomerSchema;
|
|
9338
|
-
exports.CheckoutResponseSchema = CheckoutResponseSchema;
|
|
9339
|
-
exports.ChosenPriceSchema = ChosenPriceSchema;
|
|
9340
|
-
exports.CompositeResolvedSchema = CompositeResolvedSchema;
|
|
9341
|
-
exports.CompositeSelectionInputSchema = CompositeSelectionInputSchema;
|
|
9342
|
-
exports.CountryCodeSchema = CountryCodeSchema;
|
|
9343
|
-
exports.CurrencyCodeSchema = CurrencyCodeSchema;
|
|
9344
|
-
exports.CustomerInputValueSchema = CustomerInputValueSchema;
|
|
9345
|
-
exports.DiscountDetailsSchema = DiscountDetailsSchema;
|
|
9346
|
-
exports.IsoDateTimeSchema = IsoDateTimeSchema;
|
|
9347
|
-
exports.LineTypeSchema = LineTypeSchema;
|
|
9348
|
-
exports.LocaleSchema = LocaleSchema;
|
|
9349
|
-
exports.MoneyLooseSchema = MoneyLooseSchema;
|
|
9350
|
-
exports.MoneySchema = MoneySchema;
|
|
9351
|
-
exports.NextActionSchema = NextActionSchema;
|
|
9352
|
-
exports.PhoneE164Schema = PhoneE164Schema;
|
|
9353
|
-
exports.ProductTypeSchema = ProductTypeSchema;
|
|
9354
|
-
exports.SCHEMA_VERSION = SCHEMA_VERSION;
|
|
9355
|
-
exports.SchemaViolationError = SchemaViolationError;
|
|
9356
|
-
exports.SeedNameSchema = SeedNameSchema;
|
|
9357
|
-
exports.ServiceStatusSchema = ServiceStatusSchema;
|
|
9358
|
-
exports.TimestampSchema = TimestampSchema;
|
|
9359
|
-
exports.VariantDetailsSchema = VariantDetailsSchema;
|
|
9360
|
-
exports.VariantDisplayAttributeSchema = VariantDisplayAttributeSchema;
|
|
9361
|
-
exports.VariantInfoSchema = VariantInfoSchema;
|
|
9362
|
-
exports.assertAddItemPayload = assertAddItemPayload;
|
|
9363
|
-
exports.assertBrand = assertBrand;
|
|
9364
|
-
exports.assertCart = assertCart;
|
|
9365
|
-
exports.assertCartItem = assertCartItem;
|
|
9366
|
-
exports.assertCheckoutBody = assertCheckoutBody;
|
|
9367
|
-
exports.assertCheckoutResponse = assertCheckoutResponse;
|
|
9368
|
-
exports.createTestClient = createTestClient;
|
|
9369
|
-
exports.fixtures = fixtures;
|
|
9370
|
-
exports.makeAssertion = makeAssertion;
|
|
8826
|
+
exports.createMockApp = createMockApp;
|