@cimplify/sdk 0.82.0 → 0.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/{chunk-SRJEMEVZ.js → chunk-FKBXZ2A6.js} +212 -6
- package/dist/{chunk-7PAQR3VC.mjs → chunk-I6RE4BKH.mjs} +4 -2
- package/dist/{chunk-IZDJEDR4.js → chunk-ODEPW244.js} +5 -3
- package/dist/{chunk-BRVIXGUW.mjs → chunk-PLTP6HWW.mjs} +212 -6
- package/dist/{client-DnHP_2Jw.d.mts → client-Ba4Hng9i.d.mts} +2 -2
- package/dist/{client-BSpVgule.d.mts → client-BjUJapti.d.mts} +2 -2
- package/dist/{client-xc2aQSB4.d.ts → client-CINi3Dw3.d.ts} +2 -2
- package/dist/{client-Dh-KIIX8.d.ts → client-D8AjO8jb.d.ts} +2 -2
- package/dist/{index-Dy8D3r9b.d.mts → index-9Bl-zBAI.d.mts} +3 -3
- package/dist/{index-C4xE31-D.d.ts → index-DCPxHjbj.d.ts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/mock/cli.mjs +309 -19
- package/dist/mock/library.js +223 -6
- package/dist/mock/library.mjs +216 -7
- package/dist/mock/msw.js +212 -6
- package/dist/mock/msw.mjs +212 -6
- package/dist/{payment-nH9OCUg2.d.ts → payment-BVv9leS_.d.ts} +1 -1
- package/dist/{payment-T_0MUE9o.d.mts → payment-D61iGd0o.d.mts} +1 -1
- package/dist/{price-B8WMoldA.d.ts → price-BYWCHYO5.d.ts} +3 -1
- package/dist/{price-Bg7hujK_.d.mts → price-Cthq6nPb.d.mts} +3 -1
- package/dist/{product-DXhjLQ_w.d.mts → product-2MAoE0kZ.d.mts} +26 -1
- package/dist/{product-DXhjLQ_w.d.ts → product-2MAoE0kZ.d.ts} +26 -1
- package/dist/react.d.mts +36 -5
- package/dist/react.d.ts +36 -5
- package/dist/react.js +99 -11
- package/dist/react.mjs +99 -12
- package/dist/{server-tr993CPj.d.mts → server-BjQ0xWmc.d.mts} +87 -3
- package/dist/{server-wAB-qfyZ.d.ts → server-DDaQIYLa.d.ts} +87 -3
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +21 -21
- package/dist/testing/suite.mjs +2 -2
- package/dist/testing.d.mts +11 -5
- package/dist/testing.d.ts +11 -5
- package/dist/testing.js +77 -77
- package/dist/testing.mjs +3 -3
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/package.json +1 -1
- package/registry/default-product-layout.json +1 -1
- package/registry/retail-product-card.json +1 -1
package/dist/advanced.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, P as CartOperations, Q as CatalogueQueries, a9 as CheckoutOperations, a9 as CheckoutService, af as CimplifyElement, ag as CimplifyElements, aH as ELEMENT_TYPES, aI as EVENT_TYPES, aL as ElementEventType, aM as ElementOptions, aN as ElementType, aV as ElementsOptions, b1 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bn as LinkService, br as LiteService, by as MESSAGE_TYPES, b$ as OrderQueries, ci as PriceQuote, co as QuoteBundleSelectionInput, cp as QuoteCompositeSelectionInput, cq as QuoteDynamicBuckets, cr as QuoteStatus, cs as QuoteUiMessage, cu as RefreshQuoteInput, cv as RefreshQuoteResult, cW as SchedulingService, dB as createElements } from './client-
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, P as CartOperations, Q as CatalogueQueries, a9 as CheckoutOperations, a9 as CheckoutService, af as CimplifyElement, ag as CimplifyElements, aH as ELEMENT_TYPES, aI as EVENT_TYPES, aL as ElementEventType, aM as ElementOptions, aN as ElementType, aV as ElementsOptions, b1 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bn as LinkService, br as LiteService, by as MESSAGE_TYPES, b$ as OrderQueries, ci as PriceQuote, co as QuoteBundleSelectionInput, cp as QuoteCompositeSelectionInput, cq as QuoteDynamicBuckets, cr as QuoteStatus, cs as QuoteUiMessage, cu as RefreshQuoteInput, cv as RefreshQuoteResult, cW as SchedulingService, dB as createElements } from './client-Ba4Hng9i.mjs';
|
|
2
|
+
import './product-2MAoE0kZ.mjs';
|
|
3
|
+
import './payment-D61iGd0o.mjs';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, P as CartOperations, Q as CatalogueQueries, a9 as CheckoutOperations, a9 as CheckoutService, af as CimplifyElement, ag as CimplifyElements, aH as ELEMENT_TYPES, aI as EVENT_TYPES, aL as ElementEventType, aM as ElementOptions, aN as ElementType, aV as ElementsOptions, b1 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bn as LinkService, br as LiteService, by as MESSAGE_TYPES, b$ as OrderQueries, ci as PriceQuote, co as QuoteBundleSelectionInput, cp as QuoteCompositeSelectionInput, cq as QuoteDynamicBuckets, cr as QuoteStatus, cs as QuoteUiMessage, cu as RefreshQuoteInput, cv as RefreshQuoteResult, cW as SchedulingService, dB as createElements } from './client-
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, P as CartOperations, Q as CatalogueQueries, a9 as CheckoutOperations, a9 as CheckoutService, af as CimplifyElement, ag as CimplifyElements, aH as ELEMENT_TYPES, aI as EVENT_TYPES, aL as ElementEventType, aM as ElementOptions, aN as ElementType, aV as ElementsOptions, b1 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bn as LinkService, br as LiteService, by as MESSAGE_TYPES, b$ as OrderQueries, ci as PriceQuote, co as QuoteBundleSelectionInput, cp as QuoteCompositeSelectionInput, cq as QuoteDynamicBuckets, cr as QuoteStatus, cs as QuoteUiMessage, cu as RefreshQuoteInput, cv as RefreshQuoteResult, cW as SchedulingService, dB as createElements } from './client-CINi3Dw3.js';
|
|
2
|
+
import './product-2MAoE0kZ.js';
|
|
3
|
+
import './payment-BVv9leS_.js';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
|
@@ -5830,6 +5830,14 @@ function createLinkService({ clock, ids }) {
|
|
|
5830
5830
|
};
|
|
5831
5831
|
}
|
|
5832
5832
|
|
|
5833
|
+
// src/mock/state/snapshot.ts
|
|
5834
|
+
function applySnapshot(reg, data) {
|
|
5835
|
+
for (const [k, v] of Object.entries(data)) {
|
|
5836
|
+
const store = reg[k];
|
|
5837
|
+
if (store) store.loadJSON(v);
|
|
5838
|
+
}
|
|
5839
|
+
}
|
|
5840
|
+
|
|
5833
5841
|
// src/mock/seeds/image.ts
|
|
5834
5842
|
var CDN_BASE_URL = "https://static-tmp.cimplify.io";
|
|
5835
5843
|
function seedImage(industry, slug) {
|
|
@@ -10197,15 +10205,214 @@ function applySeed(registry, name) {
|
|
|
10197
10205
|
return fn(registry);
|
|
10198
10206
|
}
|
|
10199
10207
|
|
|
10208
|
+
// src/mock/seeds/context.ts
|
|
10209
|
+
var SEED_ISO = "2026-01-01T00:00:00.000Z";
|
|
10210
|
+
var ID_PREFIX = {
|
|
10211
|
+
business: "bus_",
|
|
10212
|
+
category: "cat_",
|
|
10213
|
+
collection: "col_",
|
|
10214
|
+
product: "prod_",
|
|
10215
|
+
service: "svc_"
|
|
10216
|
+
};
|
|
10217
|
+
var DEFAULT_CURRENCY = "GHS";
|
|
10218
|
+
function slugify(value) {
|
|
10219
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10220
|
+
}
|
|
10221
|
+
function makeSeedContext(registry) {
|
|
10222
|
+
let current;
|
|
10223
|
+
const requireBusiness = () => {
|
|
10224
|
+
if (current) return current;
|
|
10225
|
+
const sole = registry.businesses.list();
|
|
10226
|
+
if (sole.length === 1) {
|
|
10227
|
+
current = sole[0];
|
|
10228
|
+
return current;
|
|
10229
|
+
}
|
|
10230
|
+
throw new Error("Seed must create a business (ctx.business) before adding child records.");
|
|
10231
|
+
};
|
|
10232
|
+
const resolveCategoryId = (cat) => {
|
|
10233
|
+
if (!cat) return void 0;
|
|
10234
|
+
if (typeof cat !== "string") return cat.id;
|
|
10235
|
+
if (registry.categories.get(cat)) return cat;
|
|
10236
|
+
return registry.categories.list().find((c) => c.slug === cat)?.id;
|
|
10237
|
+
};
|
|
10238
|
+
const resolveCollectionId = (col) => {
|
|
10239
|
+
if (!col) return void 0;
|
|
10240
|
+
if (typeof col !== "string") return col.id;
|
|
10241
|
+
if (registry.collections.get(col)) return col;
|
|
10242
|
+
return registry.collections.list().find((c) => c.slug === col)?.id;
|
|
10243
|
+
};
|
|
10244
|
+
return {
|
|
10245
|
+
registry,
|
|
10246
|
+
business(input) {
|
|
10247
|
+
const handle = input.handle ?? slugify(input.name);
|
|
10248
|
+
const id = `${ID_PREFIX.business}${slugify(handle)}`;
|
|
10249
|
+
const business = {
|
|
10250
|
+
business_type: "other",
|
|
10251
|
+
email: `hello@${handle}.test`,
|
|
10252
|
+
default_currency: DEFAULT_CURRENCY,
|
|
10253
|
+
default_offers_table_service: false,
|
|
10254
|
+
default_accepts_online_orders: true,
|
|
10255
|
+
status: "active",
|
|
10256
|
+
created_by: "seed",
|
|
10257
|
+
preferences: {},
|
|
10258
|
+
is_online_only: true,
|
|
10259
|
+
enabled_payment_types: ["mobile_money"],
|
|
10260
|
+
default_location_settings: {},
|
|
10261
|
+
country_code: "GH",
|
|
10262
|
+
timezone: "Africa/Accra",
|
|
10263
|
+
...input,
|
|
10264
|
+
id,
|
|
10265
|
+
handle,
|
|
10266
|
+
created_at: input.created_at ?? SEED_ISO,
|
|
10267
|
+
updated_at: input.updated_at ?? SEED_ISO
|
|
10268
|
+
};
|
|
10269
|
+
registry.businesses.put(id, business);
|
|
10270
|
+
current = business;
|
|
10271
|
+
return business;
|
|
10272
|
+
},
|
|
10273
|
+
category(input) {
|
|
10274
|
+
const business = requireBusiness();
|
|
10275
|
+
const slug = input.slug ?? slugify(input.name);
|
|
10276
|
+
const id = `${ID_PREFIX.category}${slug}`;
|
|
10277
|
+
const category = {
|
|
10278
|
+
id,
|
|
10279
|
+
business_id: business.id,
|
|
10280
|
+
name: input.name,
|
|
10281
|
+
slug,
|
|
10282
|
+
description: input.description,
|
|
10283
|
+
image: input.image,
|
|
10284
|
+
product_ids: [],
|
|
10285
|
+
display_order: input.displayOrder ?? 0,
|
|
10286
|
+
is_active: true,
|
|
10287
|
+
created_at: SEED_ISO,
|
|
10288
|
+
updated_at: SEED_ISO
|
|
10289
|
+
};
|
|
10290
|
+
registry.categories.put(id, category);
|
|
10291
|
+
return category;
|
|
10292
|
+
},
|
|
10293
|
+
collection(input) {
|
|
10294
|
+
const business = requireBusiness();
|
|
10295
|
+
const slug = input.slug ?? slugify(input.name);
|
|
10296
|
+
const id = `${ID_PREFIX.collection}${slug}`;
|
|
10297
|
+
const collection = {
|
|
10298
|
+
id,
|
|
10299
|
+
business_id: business.id,
|
|
10300
|
+
name: input.name,
|
|
10301
|
+
slug,
|
|
10302
|
+
description: input.description,
|
|
10303
|
+
product_ids: [],
|
|
10304
|
+
is_active: true,
|
|
10305
|
+
created_at: SEED_ISO,
|
|
10306
|
+
updated_at: SEED_ISO
|
|
10307
|
+
};
|
|
10308
|
+
registry.collections.put(id, collection);
|
|
10309
|
+
return collection;
|
|
10310
|
+
},
|
|
10311
|
+
product(input) {
|
|
10312
|
+
const business = requireBusiness();
|
|
10313
|
+
const slug = input.slug ?? slugify(input.name);
|
|
10314
|
+
const id = `${ID_PREFIX.product}${slug}`;
|
|
10315
|
+
const categoryId = resolveCategoryId(input.category);
|
|
10316
|
+
const collectionId = resolveCollectionId(input.collection);
|
|
10317
|
+
const product = {
|
|
10318
|
+
id,
|
|
10319
|
+
business_id: business.id,
|
|
10320
|
+
name: input.name,
|
|
10321
|
+
slug,
|
|
10322
|
+
description: input.description,
|
|
10323
|
+
product_type: input.productType ?? "product",
|
|
10324
|
+
base_price: input.price,
|
|
10325
|
+
currency: input.currency ?? business.default_currency,
|
|
10326
|
+
image: input.image,
|
|
10327
|
+
images: input.images ?? (input.image ? [input.image] : []),
|
|
10328
|
+
is_available: true,
|
|
10329
|
+
category_ids: categoryId ? [categoryId] : [],
|
|
10330
|
+
collection_ids: collectionId ? [collectionId] : [],
|
|
10331
|
+
add_on_ids: [],
|
|
10332
|
+
variant_ids: [],
|
|
10333
|
+
tags: input.tags ?? [],
|
|
10334
|
+
calories: input.calories,
|
|
10335
|
+
allergies: input.allergies ?? [],
|
|
10336
|
+
ingredients: input.ingredients ?? [],
|
|
10337
|
+
pairings: [],
|
|
10338
|
+
is_signature: input.isSignature ?? false,
|
|
10339
|
+
is_new: input.isNew ?? false,
|
|
10340
|
+
duration_minutes: input.durationMinutes,
|
|
10341
|
+
metadata: input.metadata,
|
|
10342
|
+
created_at: SEED_ISO,
|
|
10343
|
+
updated_at: SEED_ISO
|
|
10344
|
+
};
|
|
10345
|
+
registry.products.put(id, product);
|
|
10346
|
+
if (categoryId) {
|
|
10347
|
+
const cat = registry.categories.get(categoryId);
|
|
10348
|
+
if (cat && !cat.product_ids.includes(id)) cat.product_ids.push(id);
|
|
10349
|
+
}
|
|
10350
|
+
if (collectionId) {
|
|
10351
|
+
const col = registry.collections.get(collectionId);
|
|
10352
|
+
if (col && !col.product_ids.includes(id)) col.product_ids.push(id);
|
|
10353
|
+
}
|
|
10354
|
+
return product;
|
|
10355
|
+
},
|
|
10356
|
+
service(input) {
|
|
10357
|
+
const business = requireBusiness();
|
|
10358
|
+
const id = `${ID_PREFIX.service}${slugify(input.name)}`;
|
|
10359
|
+
const service = {
|
|
10360
|
+
id,
|
|
10361
|
+
business_id: business.id,
|
|
10362
|
+
name: input.name,
|
|
10363
|
+
description: input.description,
|
|
10364
|
+
duration_minutes: input.durationMinutes,
|
|
10365
|
+
price: input.price,
|
|
10366
|
+
is_available: true
|
|
10367
|
+
};
|
|
10368
|
+
registry.services.put(id, service);
|
|
10369
|
+
return service;
|
|
10370
|
+
},
|
|
10371
|
+
image: seedImage,
|
|
10372
|
+
extend(name) {
|
|
10373
|
+
const result = applySeed(registry, name);
|
|
10374
|
+
current = registry.businesses.get(result.businessId) ?? current;
|
|
10375
|
+
return result;
|
|
10376
|
+
}
|
|
10377
|
+
};
|
|
10378
|
+
}
|
|
10379
|
+
|
|
10380
|
+
// src/mock/seeds/source.ts
|
|
10381
|
+
var SNAPSHOT_META_KEY = "__meta";
|
|
10382
|
+
function loadSnapshot(registry, data, businessId) {
|
|
10383
|
+
applySnapshot(registry, data);
|
|
10384
|
+
if (businessId) return { businessId };
|
|
10385
|
+
const meta = data[SNAPSHOT_META_KEY];
|
|
10386
|
+
if (meta?.defaultBusinessId) return { businessId: meta.defaultBusinessId };
|
|
10387
|
+
const businesses = registry.businesses.list();
|
|
10388
|
+
if (businesses.length === 1) return { businessId: businesses[0].id };
|
|
10389
|
+
if (businesses.length === 0) {
|
|
10390
|
+
throw new Error("Seed snapshot has no business. Add one, or set __meta.defaultBusinessId.");
|
|
10391
|
+
}
|
|
10392
|
+
throw new Error(
|
|
10393
|
+
`Seed snapshot has ${businesses.length} businesses; set __meta.defaultBusinessId to pick one.`
|
|
10394
|
+
);
|
|
10395
|
+
}
|
|
10396
|
+
function resolveSeed(registry, source) {
|
|
10397
|
+
if (typeof source === "string") return applySeed(registry, source);
|
|
10398
|
+
switch (source.kind) {
|
|
10399
|
+
case "builtin":
|
|
10400
|
+
return applySeed(registry, source.name);
|
|
10401
|
+
case "json":
|
|
10402
|
+
return loadSnapshot(registry, source.data, source.businessId);
|
|
10403
|
+
case "fn":
|
|
10404
|
+
return source.seed(makeSeedContext(registry));
|
|
10405
|
+
}
|
|
10406
|
+
}
|
|
10407
|
+
|
|
10200
10408
|
// src/mock/deps.ts
|
|
10201
10409
|
function createDeps(options = {}) {
|
|
10202
10410
|
const clock = createClock({ frozenAt: options.frozenAt });
|
|
10203
10411
|
const ids = createIdGen(options.rngSeed);
|
|
10204
10412
|
const bus = createBus({ idGen: () => ids.raw("evt"), clock: () => clock.now() });
|
|
10205
10413
|
const registry = createStateRegistry();
|
|
10206
|
-
const
|
|
10207
|
-
|
|
10208
|
-
let defaultBusinessId = seedResult.businessId;
|
|
10414
|
+
const seedSource = options.seed ?? "default";
|
|
10415
|
+
let defaultBusinessId = resolveSeed(registry, seedSource).businessId;
|
|
10209
10416
|
const auth = createAuthService({
|
|
10210
10417
|
registry,
|
|
10211
10418
|
clock,
|
|
@@ -10259,11 +10466,10 @@ function createDeps(options = {}) {
|
|
|
10259
10466
|
return defaultBusinessId;
|
|
10260
10467
|
},
|
|
10261
10468
|
chaos,
|
|
10262
|
-
resetAll(
|
|
10469
|
+
resetAll(next) {
|
|
10263
10470
|
for (const store of Object.values(registry)) store.reset();
|
|
10264
10471
|
bus.clear();
|
|
10265
|
-
|
|
10266
|
-
defaultBusinessId = r.businessId;
|
|
10472
|
+
defaultBusinessId = resolveSeed(registry, next ?? seedSource).businessId;
|
|
10267
10473
|
return defaultBusinessId;
|
|
10268
10474
|
}
|
|
10269
10475
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMockApp } from './chunk-
|
|
1
|
+
import { createMockApp } from './chunk-PLTP6HWW.mjs';
|
|
2
2
|
import { createCimplifyClient } from './chunk-NWUEWUX2.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -508,7 +508,8 @@ var CartSchema = registerSchema(
|
|
|
508
508
|
expires_at: TimestampSchema,
|
|
509
509
|
status: z.string(),
|
|
510
510
|
source: z.string(),
|
|
511
|
-
channel: z.string()
|
|
511
|
+
channel: z.string(),
|
|
512
|
+
requires_delivery: z.boolean().optional()
|
|
512
513
|
}),
|
|
513
514
|
{
|
|
514
515
|
id: "Cart",
|
|
@@ -531,6 +532,7 @@ var CheckoutBodySchema = registerSchema(
|
|
|
531
532
|
customer: CheckoutCustomerSchema,
|
|
532
533
|
order_type: z.string().min(1),
|
|
533
534
|
address_info: z.record(z.string(), z.unknown()).optional(),
|
|
535
|
+
delivery_rate_id: z.string().optional(),
|
|
534
536
|
payment_method: z.string().min(1),
|
|
535
537
|
mobile_money_details: z.object({ phone_number: z.string(), provider: z.string() }).optional(),
|
|
536
538
|
special_instructions: z.string().optional(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFKBXZ2A6_js = require('./chunk-FKBXZ2A6.js');
|
|
4
4
|
var chunkGFM5JW45_js = require('./chunk-GFM5JW45.js');
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
|
|
@@ -510,7 +510,8 @@ var CartSchema = registerSchema(
|
|
|
510
510
|
expires_at: TimestampSchema,
|
|
511
511
|
status: zod.z.string(),
|
|
512
512
|
source: zod.z.string(),
|
|
513
|
-
channel: zod.z.string()
|
|
513
|
+
channel: zod.z.string(),
|
|
514
|
+
requires_delivery: zod.z.boolean().optional()
|
|
514
515
|
}),
|
|
515
516
|
{
|
|
516
517
|
id: "Cart",
|
|
@@ -533,6 +534,7 @@ var CheckoutBodySchema = registerSchema(
|
|
|
533
534
|
customer: CheckoutCustomerSchema,
|
|
534
535
|
order_type: zod.z.string().min(1),
|
|
535
536
|
address_info: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
537
|
+
delivery_rate_id: zod.z.string().optional(),
|
|
536
538
|
payment_method: zod.z.string().min(1),
|
|
537
539
|
mobile_money_details: zod.z.object({ phone_number: zod.z.string(), provider: zod.z.string() }).optional(),
|
|
538
540
|
special_instructions: zod.z.string().optional(),
|
|
@@ -598,7 +600,7 @@ async function toForwardedRequest(input, init) {
|
|
|
598
600
|
};
|
|
599
601
|
}
|
|
600
602
|
function createTestClient(options = {}) {
|
|
601
|
-
const mock =
|
|
603
|
+
const mock = chunkFKBXZ2A6_js.createMockApp(options);
|
|
602
604
|
let sessionToken;
|
|
603
605
|
const fetchImpl = async (input, init) => {
|
|
604
606
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
@@ -5828,6 +5828,14 @@ function createLinkService({ clock, ids }) {
|
|
|
5828
5828
|
};
|
|
5829
5829
|
}
|
|
5830
5830
|
|
|
5831
|
+
// src/mock/state/snapshot.ts
|
|
5832
|
+
function applySnapshot(reg, data) {
|
|
5833
|
+
for (const [k, v] of Object.entries(data)) {
|
|
5834
|
+
const store = reg[k];
|
|
5835
|
+
if (store) store.loadJSON(v);
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
|
|
5831
5839
|
// src/mock/seeds/image.ts
|
|
5832
5840
|
var CDN_BASE_URL = "https://static-tmp.cimplify.io";
|
|
5833
5841
|
function seedImage(industry, slug) {
|
|
@@ -10195,15 +10203,214 @@ function applySeed(registry, name) {
|
|
|
10195
10203
|
return fn(registry);
|
|
10196
10204
|
}
|
|
10197
10205
|
|
|
10206
|
+
// src/mock/seeds/context.ts
|
|
10207
|
+
var SEED_ISO = "2026-01-01T00:00:00.000Z";
|
|
10208
|
+
var ID_PREFIX = {
|
|
10209
|
+
business: "bus_",
|
|
10210
|
+
category: "cat_",
|
|
10211
|
+
collection: "col_",
|
|
10212
|
+
product: "prod_",
|
|
10213
|
+
service: "svc_"
|
|
10214
|
+
};
|
|
10215
|
+
var DEFAULT_CURRENCY = "GHS";
|
|
10216
|
+
function slugify(value) {
|
|
10217
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10218
|
+
}
|
|
10219
|
+
function makeSeedContext(registry) {
|
|
10220
|
+
let current;
|
|
10221
|
+
const requireBusiness = () => {
|
|
10222
|
+
if (current) return current;
|
|
10223
|
+
const sole = registry.businesses.list();
|
|
10224
|
+
if (sole.length === 1) {
|
|
10225
|
+
current = sole[0];
|
|
10226
|
+
return current;
|
|
10227
|
+
}
|
|
10228
|
+
throw new Error("Seed must create a business (ctx.business) before adding child records.");
|
|
10229
|
+
};
|
|
10230
|
+
const resolveCategoryId = (cat) => {
|
|
10231
|
+
if (!cat) return void 0;
|
|
10232
|
+
if (typeof cat !== "string") return cat.id;
|
|
10233
|
+
if (registry.categories.get(cat)) return cat;
|
|
10234
|
+
return registry.categories.list().find((c) => c.slug === cat)?.id;
|
|
10235
|
+
};
|
|
10236
|
+
const resolveCollectionId = (col) => {
|
|
10237
|
+
if (!col) return void 0;
|
|
10238
|
+
if (typeof col !== "string") return col.id;
|
|
10239
|
+
if (registry.collections.get(col)) return col;
|
|
10240
|
+
return registry.collections.list().find((c) => c.slug === col)?.id;
|
|
10241
|
+
};
|
|
10242
|
+
return {
|
|
10243
|
+
registry,
|
|
10244
|
+
business(input) {
|
|
10245
|
+
const handle = input.handle ?? slugify(input.name);
|
|
10246
|
+
const id = `${ID_PREFIX.business}${slugify(handle)}`;
|
|
10247
|
+
const business = {
|
|
10248
|
+
business_type: "other",
|
|
10249
|
+
email: `hello@${handle}.test`,
|
|
10250
|
+
default_currency: DEFAULT_CURRENCY,
|
|
10251
|
+
default_offers_table_service: false,
|
|
10252
|
+
default_accepts_online_orders: true,
|
|
10253
|
+
status: "active",
|
|
10254
|
+
created_by: "seed",
|
|
10255
|
+
preferences: {},
|
|
10256
|
+
is_online_only: true,
|
|
10257
|
+
enabled_payment_types: ["mobile_money"],
|
|
10258
|
+
default_location_settings: {},
|
|
10259
|
+
country_code: "GH",
|
|
10260
|
+
timezone: "Africa/Accra",
|
|
10261
|
+
...input,
|
|
10262
|
+
id,
|
|
10263
|
+
handle,
|
|
10264
|
+
created_at: input.created_at ?? SEED_ISO,
|
|
10265
|
+
updated_at: input.updated_at ?? SEED_ISO
|
|
10266
|
+
};
|
|
10267
|
+
registry.businesses.put(id, business);
|
|
10268
|
+
current = business;
|
|
10269
|
+
return business;
|
|
10270
|
+
},
|
|
10271
|
+
category(input) {
|
|
10272
|
+
const business = requireBusiness();
|
|
10273
|
+
const slug = input.slug ?? slugify(input.name);
|
|
10274
|
+
const id = `${ID_PREFIX.category}${slug}`;
|
|
10275
|
+
const category = {
|
|
10276
|
+
id,
|
|
10277
|
+
business_id: business.id,
|
|
10278
|
+
name: input.name,
|
|
10279
|
+
slug,
|
|
10280
|
+
description: input.description,
|
|
10281
|
+
image: input.image,
|
|
10282
|
+
product_ids: [],
|
|
10283
|
+
display_order: input.displayOrder ?? 0,
|
|
10284
|
+
is_active: true,
|
|
10285
|
+
created_at: SEED_ISO,
|
|
10286
|
+
updated_at: SEED_ISO
|
|
10287
|
+
};
|
|
10288
|
+
registry.categories.put(id, category);
|
|
10289
|
+
return category;
|
|
10290
|
+
},
|
|
10291
|
+
collection(input) {
|
|
10292
|
+
const business = requireBusiness();
|
|
10293
|
+
const slug = input.slug ?? slugify(input.name);
|
|
10294
|
+
const id = `${ID_PREFIX.collection}${slug}`;
|
|
10295
|
+
const collection = {
|
|
10296
|
+
id,
|
|
10297
|
+
business_id: business.id,
|
|
10298
|
+
name: input.name,
|
|
10299
|
+
slug,
|
|
10300
|
+
description: input.description,
|
|
10301
|
+
product_ids: [],
|
|
10302
|
+
is_active: true,
|
|
10303
|
+
created_at: SEED_ISO,
|
|
10304
|
+
updated_at: SEED_ISO
|
|
10305
|
+
};
|
|
10306
|
+
registry.collections.put(id, collection);
|
|
10307
|
+
return collection;
|
|
10308
|
+
},
|
|
10309
|
+
product(input) {
|
|
10310
|
+
const business = requireBusiness();
|
|
10311
|
+
const slug = input.slug ?? slugify(input.name);
|
|
10312
|
+
const id = `${ID_PREFIX.product}${slug}`;
|
|
10313
|
+
const categoryId = resolveCategoryId(input.category);
|
|
10314
|
+
const collectionId = resolveCollectionId(input.collection);
|
|
10315
|
+
const product = {
|
|
10316
|
+
id,
|
|
10317
|
+
business_id: business.id,
|
|
10318
|
+
name: input.name,
|
|
10319
|
+
slug,
|
|
10320
|
+
description: input.description,
|
|
10321
|
+
product_type: input.productType ?? "product",
|
|
10322
|
+
base_price: input.price,
|
|
10323
|
+
currency: input.currency ?? business.default_currency,
|
|
10324
|
+
image: input.image,
|
|
10325
|
+
images: input.images ?? (input.image ? [input.image] : []),
|
|
10326
|
+
is_available: true,
|
|
10327
|
+
category_ids: categoryId ? [categoryId] : [],
|
|
10328
|
+
collection_ids: collectionId ? [collectionId] : [],
|
|
10329
|
+
add_on_ids: [],
|
|
10330
|
+
variant_ids: [],
|
|
10331
|
+
tags: input.tags ?? [],
|
|
10332
|
+
calories: input.calories,
|
|
10333
|
+
allergies: input.allergies ?? [],
|
|
10334
|
+
ingredients: input.ingredients ?? [],
|
|
10335
|
+
pairings: [],
|
|
10336
|
+
is_signature: input.isSignature ?? false,
|
|
10337
|
+
is_new: input.isNew ?? false,
|
|
10338
|
+
duration_minutes: input.durationMinutes,
|
|
10339
|
+
metadata: input.metadata,
|
|
10340
|
+
created_at: SEED_ISO,
|
|
10341
|
+
updated_at: SEED_ISO
|
|
10342
|
+
};
|
|
10343
|
+
registry.products.put(id, product);
|
|
10344
|
+
if (categoryId) {
|
|
10345
|
+
const cat = registry.categories.get(categoryId);
|
|
10346
|
+
if (cat && !cat.product_ids.includes(id)) cat.product_ids.push(id);
|
|
10347
|
+
}
|
|
10348
|
+
if (collectionId) {
|
|
10349
|
+
const col = registry.collections.get(collectionId);
|
|
10350
|
+
if (col && !col.product_ids.includes(id)) col.product_ids.push(id);
|
|
10351
|
+
}
|
|
10352
|
+
return product;
|
|
10353
|
+
},
|
|
10354
|
+
service(input) {
|
|
10355
|
+
const business = requireBusiness();
|
|
10356
|
+
const id = `${ID_PREFIX.service}${slugify(input.name)}`;
|
|
10357
|
+
const service = {
|
|
10358
|
+
id,
|
|
10359
|
+
business_id: business.id,
|
|
10360
|
+
name: input.name,
|
|
10361
|
+
description: input.description,
|
|
10362
|
+
duration_minutes: input.durationMinutes,
|
|
10363
|
+
price: input.price,
|
|
10364
|
+
is_available: true
|
|
10365
|
+
};
|
|
10366
|
+
registry.services.put(id, service);
|
|
10367
|
+
return service;
|
|
10368
|
+
},
|
|
10369
|
+
image: seedImage,
|
|
10370
|
+
extend(name) {
|
|
10371
|
+
const result = applySeed(registry, name);
|
|
10372
|
+
current = registry.businesses.get(result.businessId) ?? current;
|
|
10373
|
+
return result;
|
|
10374
|
+
}
|
|
10375
|
+
};
|
|
10376
|
+
}
|
|
10377
|
+
|
|
10378
|
+
// src/mock/seeds/source.ts
|
|
10379
|
+
var SNAPSHOT_META_KEY = "__meta";
|
|
10380
|
+
function loadSnapshot(registry, data, businessId) {
|
|
10381
|
+
applySnapshot(registry, data);
|
|
10382
|
+
if (businessId) return { businessId };
|
|
10383
|
+
const meta = data[SNAPSHOT_META_KEY];
|
|
10384
|
+
if (meta?.defaultBusinessId) return { businessId: meta.defaultBusinessId };
|
|
10385
|
+
const businesses = registry.businesses.list();
|
|
10386
|
+
if (businesses.length === 1) return { businessId: businesses[0].id };
|
|
10387
|
+
if (businesses.length === 0) {
|
|
10388
|
+
throw new Error("Seed snapshot has no business. Add one, or set __meta.defaultBusinessId.");
|
|
10389
|
+
}
|
|
10390
|
+
throw new Error(
|
|
10391
|
+
`Seed snapshot has ${businesses.length} businesses; set __meta.defaultBusinessId to pick one.`
|
|
10392
|
+
);
|
|
10393
|
+
}
|
|
10394
|
+
function resolveSeed(registry, source) {
|
|
10395
|
+
if (typeof source === "string") return applySeed(registry, source);
|
|
10396
|
+
switch (source.kind) {
|
|
10397
|
+
case "builtin":
|
|
10398
|
+
return applySeed(registry, source.name);
|
|
10399
|
+
case "json":
|
|
10400
|
+
return loadSnapshot(registry, source.data, source.businessId);
|
|
10401
|
+
case "fn":
|
|
10402
|
+
return source.seed(makeSeedContext(registry));
|
|
10403
|
+
}
|
|
10404
|
+
}
|
|
10405
|
+
|
|
10198
10406
|
// src/mock/deps.ts
|
|
10199
10407
|
function createDeps(options = {}) {
|
|
10200
10408
|
const clock = createClock({ frozenAt: options.frozenAt });
|
|
10201
10409
|
const ids = createIdGen(options.rngSeed);
|
|
10202
10410
|
const bus = createBus({ idGen: () => ids.raw("evt"), clock: () => clock.now() });
|
|
10203
10411
|
const registry = createStateRegistry();
|
|
10204
|
-
const
|
|
10205
|
-
|
|
10206
|
-
let defaultBusinessId = seedResult.businessId;
|
|
10412
|
+
const seedSource = options.seed ?? "default";
|
|
10413
|
+
let defaultBusinessId = resolveSeed(registry, seedSource).businessId;
|
|
10207
10414
|
const auth = createAuthService({
|
|
10208
10415
|
registry,
|
|
10209
10416
|
clock,
|
|
@@ -10257,11 +10464,10 @@ function createDeps(options = {}) {
|
|
|
10257
10464
|
return defaultBusinessId;
|
|
10258
10465
|
},
|
|
10259
10466
|
chaos,
|
|
10260
|
-
resetAll(
|
|
10467
|
+
resetAll(next) {
|
|
10261
10468
|
for (const store of Object.values(registry)) store.reset();
|
|
10262
10469
|
bus.clear();
|
|
10263
|
-
|
|
10264
|
-
defaultBusinessId = r.businessId;
|
|
10470
|
+
defaultBusinessId = resolveSeed(registry, next ?? seedSource).businessId;
|
|
10265
10471
|
return defaultBusinessId;
|
|
10266
10472
|
}
|
|
10267
10473
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as CimplifyError, Q as Category, aX as Product, f as AddOnWithOptions, aO as Pagination, b9 as ProductWithDetails, b7 as ProductVariant,
|
|
2
|
-
import { a as AuthorizationType, c as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, i as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { T as CimplifyError, Q as Category, aX as Product, f as AddOnWithOptions, aO as Pagination, b9 as ProductWithDetails, b7 as ProductVariant, bC as VariantAxis, bD as VariantAxisSelection, A as AddOn, U as Collection, E as BundleSummary, s as Bundle, a1 as Composite, $ as ComponentSelectionInput, a6 as CompositePriceResult, S as ChosenPrice, b4 as ProductTaxonomy, bv as TaxonomyWithChildren, av as EligiblePlansQuery, a$ as ProductBillingPlan, b5 as ProductTimeProfile, a_ as ProductAvailabilityNow, ah as Deal, b0 as ProductDealInfo, an as DiscountValidation, bs as TagsResponse, ac as CustomAttributeDefinition, ad as CustomAttributeValue, ba as PropertyFacet, bu as TaxonomyAttributeTemplate, aH as KnowledgeArticle, bw as UICart, J as CartItem, O as CartSummary, g as AddToCartInput, L as CartMutationResult, bB as UpdateCartItemInput, am as DiscountDetails, aM as Money, ab as CurrencyCode, aI as LineConfiguration, bI as VariantDetails, bJ as VariantDetailsDTO, a as AddOnDetails, d as AddOnOptionDetails, b as AddOnGroupDetails, z as BundleSelectionData, a8 as CompositeSelectionData, ae as CustomerInputValue, bi as SchedulingMode, at as DurationUnit, bm as Subscription, bq as SubscriptionWithDetails } from './product-2MAoE0kZ.mjs';
|
|
2
|
+
import { a as AuthorizationType, c as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, i as PaymentStatusResponse } from './payment-D61iGd0o.mjs';
|
|
3
3
|
|
|
4
4
|
interface RequestContext {
|
|
5
5
|
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ad as CimplifyClient } from './client-
|
|
2
|
-
import { A as AppHandle, C as CreateAppOptions } from './server-
|
|
1
|
+
import { ad as CimplifyClient } from './client-Ba4Hng9i.mjs';
|
|
2
|
+
import { A as AppHandle, C as CreateAppOptions } from './server-BjQ0xWmc.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Test client + fixtures.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as CimplifyError, Q as Category, aX as Product, f as AddOnWithOptions, aO as Pagination, b9 as ProductWithDetails, b7 as ProductVariant,
|
|
2
|
-
import { a as AuthorizationType, c as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, i as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { T as CimplifyError, Q as Category, aX as Product, f as AddOnWithOptions, aO as Pagination, b9 as ProductWithDetails, b7 as ProductVariant, bC as VariantAxis, bD as VariantAxisSelection, A as AddOn, U as Collection, E as BundleSummary, s as Bundle, a1 as Composite, $ as ComponentSelectionInput, a6 as CompositePriceResult, S as ChosenPrice, b4 as ProductTaxonomy, bv as TaxonomyWithChildren, av as EligiblePlansQuery, a$ as ProductBillingPlan, b5 as ProductTimeProfile, a_ as ProductAvailabilityNow, ah as Deal, b0 as ProductDealInfo, an as DiscountValidation, bs as TagsResponse, ac as CustomAttributeDefinition, ad as CustomAttributeValue, ba as PropertyFacet, bu as TaxonomyAttributeTemplate, aH as KnowledgeArticle, bw as UICart, J as CartItem, O as CartSummary, g as AddToCartInput, L as CartMutationResult, bB as UpdateCartItemInput, am as DiscountDetails, aM as Money, ab as CurrencyCode, aI as LineConfiguration, bI as VariantDetails, bJ as VariantDetailsDTO, a as AddOnDetails, d as AddOnOptionDetails, b as AddOnGroupDetails, z as BundleSelectionData, a8 as CompositeSelectionData, ae as CustomerInputValue, bi as SchedulingMode, at as DurationUnit, bm as Subscription, bq as SubscriptionWithDetails } from './product-2MAoE0kZ.js';
|
|
2
|
+
import { a as AuthorizationType, c as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, i as PaymentStatusResponse } from './payment-BVv9leS_.js';
|
|
3
3
|
|
|
4
4
|
interface RequestContext {
|
|
5
5
|
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ad as CimplifyClient } from './client-
|
|
2
|
-
import { A as AppHandle, C as CreateAppOptions } from './server-
|
|
1
|
+
import { ad as CimplifyClient } from './client-CINi3Dw3.js';
|
|
2
|
+
import { A as AppHandle, C as CreateAppOptions } from './server-DDaQIYLa.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Test client + fixtures.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { aM as Money, ab as CurrencyCode, aV as PricePathTaxInfo, aX as Product, b9 as ProductWithDetails, bc as QuantityPricingTier } from './product-
|
|
2
|
-
import { P as ProductWithPrice } from './price-
|
|
3
|
-
import { b as PaymentErrorDetails, g as PaymentResponse, i as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { aM as Money, ab as CurrencyCode, aV as PricePathTaxInfo, aX as Product, b9 as ProductWithDetails, bc as QuantityPricingTier } from './product-2MAoE0kZ.mjs';
|
|
2
|
+
import { P as ProductWithPrice } from './price-Cthq6nPb.mjs';
|
|
3
|
+
import { b as PaymentErrorDetails, g as PaymentResponse, i as PaymentStatusResponse } from './payment-D61iGd0o.mjs';
|
|
4
4
|
import { CountryCode } from 'libphonenumber-js';
|
|
5
5
|
|
|
6
6
|
declare const CURRENCY_SYMBOLS: Record<string, string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { aM as Money, ab as CurrencyCode, aV as PricePathTaxInfo, aX as Product, b9 as ProductWithDetails, bc as QuantityPricingTier } from './product-
|
|
2
|
-
import { P as ProductWithPrice } from './price-
|
|
3
|
-
import { b as PaymentErrorDetails, g as PaymentResponse, i as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { aM as Money, ab as CurrencyCode, aV as PricePathTaxInfo, aX as Product, b9 as ProductWithDetails, bc as QuantityPricingTier } from './product-2MAoE0kZ.js';
|
|
2
|
+
import { P as ProductWithPrice } from './price-BYWCHYO5.js';
|
|
3
|
+
import { b as PaymentErrorDetails, g as PaymentResponse, i as PaymentStatusResponse } from './payment-BVv9leS_.js';
|
|
4
4
|
import { CountryCode } from 'libphonenumber-js';
|
|
5
5
|
|
|
6
6
|
declare const CURRENCY_SYMBOLS: Record<string, string>;
|