@cimplify/sdk 0.102.0 → 0.103.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/advanced.js +23 -22
- package/dist/advanced.mjs +4 -3
- package/dist/{chunk-DCMXUKDQ.mjs → chunk-C2JSNJUC.mjs} +404 -95
- package/dist/chunk-CNN7Z2IP.js +125 -0
- package/dist/{chunk-DKLHCZ5M.mjs → chunk-GERXZQSX.mjs} +487 -11
- package/dist/chunk-GOHSXBKW.mjs +105 -0
- package/dist/{chunk-4KNFBPV2.mjs → chunk-H7ACMHM3.mjs} +32 -14
- package/dist/{chunk-Z3K2D3TE.mjs → chunk-J6PNHDHL.mjs} +453 -483
- package/dist/{chunk-NIOUSKQQ.js → chunk-JG5CQNCB.js} +5 -0
- package/dist/{chunk-YER7DIOM.js → chunk-JSWJ4XDE.js} +471 -519
- package/dist/{chunk-DLW3RWRK.mjs → chunk-M4URVKHE.mjs} +46 -12
- package/dist/{chunk-WMEC5JWN.js → chunk-NNG6IFFX.js} +50 -13
- package/dist/{chunk-LOWSMGRT.js → chunk-QOWPGS7Z.js} +34 -16
- package/dist/{chunk-YDA46OZ6.js → chunk-R6OLQ33I.js} +560 -80
- package/dist/{chunk-EAZGA7LD.js → chunk-VIL6IQCG.js} +406 -97
- package/dist/{chunk-O3YUHLZL.mjs → chunk-VNPEYLB2.mjs} +5 -0
- package/dist/{client-B40KFazg.d.ts → client-BfpNjJ_a.d.mts} +90 -299
- package/dist/{client-BizGfqB7.d.mts → client-DHBwvh7U.d.ts} +90 -299
- package/dist/{client-BdErclfU.d.mts → client-DpqRobY9.d.mts} +2 -2
- package/dist/{client-nsiMwuC1.d.ts → client-Dqg2mc-7.d.ts} +2 -2
- package/dist/{index-DpmnI__D.d.mts → index-C8uDqLwJ.d.ts} +14 -4
- package/dist/{index-nEyXWIyR.d.ts → index-e2y6AK70.d.mts} +14 -4
- package/dist/index.d.mts +81 -8
- package/dist/index.d.ts +81 -8
- package/dist/index.js +202 -169
- package/dist/index.mjs +6 -5
- package/dist/link-cuNVYc2s.d.mts +297 -0
- package/dist/link-cuNVYc2s.d.ts +297 -0
- package/dist/mock/cli.mjs +410 -94
- package/dist/mock/library.js +410 -94
- package/dist/mock/library.mjs +410 -94
- package/dist/mock/msw.js +410 -94
- package/dist/mock/msw.mjs +410 -94
- package/dist/{product-Byf0unSy.d.mts → payment-H5LoIvXU.d.mts} +189 -7
- package/dist/{product-Byf0unSy.d.ts → payment-H5LoIvXU.d.ts} +189 -7
- package/dist/{price-CS4E5zLS.d.mts → price-BvePgDXe.d.mts} +1 -1
- package/dist/{price-BstChV9a.d.ts → price-C2RqscMY.d.ts} +1 -1
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +141 -140
- package/dist/react.mjs +5 -4
- package/dist/{server-DqbZh8Bk.d.mts → server-C7FyLdrz.d.mts} +11 -9
- package/dist/{server-Cj40R2ZD.d.ts → server-DoXIpSd7.d.ts} +11 -9
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +11 -10
- package/dist/server.mjs +5 -4
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +4 -3
- package/dist/testing/msw.mjs +3 -2
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +26 -25
- package/dist/testing/suite.mjs +7 -6
- package/dist/testing.d.mts +154 -55
- package/dist/testing.d.ts +154 -55
- package/dist/testing.js +83 -82
- package/dist/testing.mjs +8 -7
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +37 -29
- package/dist/utils.mjs +2 -2
- package/package.json +7 -1
- package/dist/payment-l0rkieEQ.d.mts +0 -113
- package/dist/payment-vzNnIi1n.d.ts +0 -113
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { messagePreview } from './chunk-U4MW6PYU.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { PAYMENT_METHOD } from './chunk-GOHSXBKW.mjs';
|
|
3
|
+
import { ErrorCode } from './chunk-VNPEYLB2.mjs';
|
|
3
4
|
import { __publicField, __privateAdd, __privateSet, __privateGet, __privateMethod, __privateWrapper } from './chunk-3G6RQLXK.mjs';
|
|
4
5
|
|
|
5
6
|
// ../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/compose.js
|
|
@@ -2188,10 +2189,22 @@ function buildV1(deps) {
|
|
|
2188
2189
|
}));
|
|
2189
2190
|
});
|
|
2190
2191
|
app.get("/business", (c) => tryRoute(c, () => deps.business.primary()));
|
|
2191
|
-
app.get(
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2192
|
+
app.get(
|
|
2193
|
+
"/business/by-handle/:handle",
|
|
2194
|
+
(c) => tryRoute(c, () => deps.business.byHandle(c.req.param("handle")))
|
|
2195
|
+
);
|
|
2196
|
+
app.get(
|
|
2197
|
+
"/business/by-domain",
|
|
2198
|
+
(c) => tryRoute(c, () => deps.business.byDomain(c.req.query("domain") ?? ""))
|
|
2199
|
+
);
|
|
2200
|
+
app.get(
|
|
2201
|
+
"/business/settings",
|
|
2202
|
+
(c) => tryRoute(c, () => deps.business.settings(deps.defaultBusinessId))
|
|
2203
|
+
);
|
|
2204
|
+
app.get(
|
|
2205
|
+
"/business/locations",
|
|
2206
|
+
(c) => tryRoute(c, () => deps.business.locations(deps.defaultBusinessId))
|
|
2207
|
+
);
|
|
2195
2208
|
app.get("/business/hours", (c) => tryRoute(c, () => deps.business.hours(deps.defaultBusinessId)));
|
|
2196
2209
|
app.get("/catalogue", (c) => tryRoute(c, () => deps.catalogue.snapshot(deps.defaultBusinessId)));
|
|
2197
2210
|
app.get(
|
|
@@ -2206,57 +2219,165 @@ function buildV1(deps) {
|
|
|
2206
2219
|
})
|
|
2207
2220
|
)
|
|
2208
2221
|
);
|
|
2209
|
-
app.get(
|
|
2210
|
-
|
|
2211
|
-
|
|
2222
|
+
app.get(
|
|
2223
|
+
"/catalogue/products/:product_id",
|
|
2224
|
+
(c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("product_id")))
|
|
2225
|
+
);
|
|
2226
|
+
app.get(
|
|
2227
|
+
"/catalogue/products/:product_id/variants",
|
|
2228
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductVariants(c.req.param("product_id")))
|
|
2229
|
+
);
|
|
2230
|
+
app.get(
|
|
2231
|
+
"/catalogue/products/:product_id/variant-axes",
|
|
2232
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductVariantAxes(c.req.param("product_id")))
|
|
2233
|
+
);
|
|
2212
2234
|
app.get(
|
|
2213
2235
|
"/catalogue/products/:product_id/variants/:variant_id",
|
|
2214
|
-
(c) => tryRoute(
|
|
2236
|
+
(c) => tryRoute(
|
|
2237
|
+
c,
|
|
2238
|
+
() => deps.catalogue.getProductVariantById(c.req.param("product_id"), c.req.param("variant_id"))
|
|
2239
|
+
)
|
|
2215
2240
|
);
|
|
2216
2241
|
app.post("/catalogue/products/:product_id/variants/find", async (c) => {
|
|
2217
2242
|
const body = await c.req.json().catch(() => ({}));
|
|
2218
2243
|
return tryRoute(
|
|
2219
2244
|
c,
|
|
2220
|
-
() => deps.catalogue.findProductVariant(
|
|
2245
|
+
() => deps.catalogue.findProductVariant(
|
|
2246
|
+
c.req.param("product_id"),
|
|
2247
|
+
body.axis_selections ?? body.properties ?? {}
|
|
2248
|
+
)
|
|
2221
2249
|
);
|
|
2222
2250
|
});
|
|
2223
|
-
app.get(
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
app.get(
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
app.get(
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
app.get(
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2251
|
+
app.get(
|
|
2252
|
+
"/catalogue/products/:product_id/add-ons",
|
|
2253
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductAddOns(c.req.param("product_id")))
|
|
2254
|
+
);
|
|
2255
|
+
app.get(
|
|
2256
|
+
"/catalogue/categories",
|
|
2257
|
+
(c) => tryRoute(c, () => deps.catalogue.listCategories(deps.defaultBusinessId))
|
|
2258
|
+
);
|
|
2259
|
+
app.get(
|
|
2260
|
+
"/catalogue/categories/:category_id",
|
|
2261
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategory(c.req.param("category_id")))
|
|
2262
|
+
);
|
|
2263
|
+
app.get(
|
|
2264
|
+
"/catalogue/categories/:category_id/products",
|
|
2265
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryProducts(c.req.param("category_id")))
|
|
2266
|
+
);
|
|
2267
|
+
app.get(
|
|
2268
|
+
"/catalogue/categories/:category_id/attributes",
|
|
2269
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryAttributes(c.req.param("category_id")))
|
|
2270
|
+
);
|
|
2271
|
+
app.get(
|
|
2272
|
+
"/catalogue/categories/:category_id/deals",
|
|
2273
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryDeals(c.req.param("category_id")))
|
|
2274
|
+
);
|
|
2275
|
+
app.get(
|
|
2276
|
+
"/catalogue/collections",
|
|
2277
|
+
(c) => tryRoute(c, () => deps.catalogue.listCollections(deps.defaultBusinessId))
|
|
2278
|
+
);
|
|
2279
|
+
app.get(
|
|
2280
|
+
"/catalogue/collections/:collection_id",
|
|
2281
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollection(c.req.param("collection_id")))
|
|
2282
|
+
);
|
|
2283
|
+
app.get(
|
|
2284
|
+
"/catalogue/collections/:collection_id/products",
|
|
2285
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionProducts(c.req.param("collection_id")))
|
|
2286
|
+
);
|
|
2287
|
+
app.get(
|
|
2288
|
+
"/catalogue/collections/:collection_id/attributes",
|
|
2289
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionAttributes(c.req.param("collection_id")))
|
|
2290
|
+
);
|
|
2291
|
+
app.get(
|
|
2292
|
+
"/catalogue/collections/:collection_id/deals",
|
|
2293
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionDeals(c.req.param("collection_id")))
|
|
2294
|
+
);
|
|
2295
|
+
app.get(
|
|
2296
|
+
"/catalogue/bundles",
|
|
2297
|
+
(c) => tryRoute(c, () => deps.catalogue.listBundles(deps.defaultBusinessId))
|
|
2298
|
+
);
|
|
2299
|
+
app.get(
|
|
2300
|
+
"/catalogue/bundles/:bundle_id",
|
|
2301
|
+
(c) => tryRoute(c, () => deps.catalogue.getBundle(c.req.param("bundle_id")))
|
|
2302
|
+
);
|
|
2303
|
+
app.get(
|
|
2304
|
+
"/catalogue/composites",
|
|
2305
|
+
(c) => tryRoute(c, () => deps.catalogue.listComposites(deps.defaultBusinessId))
|
|
2306
|
+
);
|
|
2307
|
+
app.get(
|
|
2308
|
+
"/catalogue/composites/by-product/:product_id",
|
|
2309
|
+
(c) => tryRoute(c, () => deps.catalogue.getCompositeByProduct(c.req.param("product_id")))
|
|
2310
|
+
);
|
|
2311
|
+
app.get(
|
|
2312
|
+
"/catalogue/composites/:composite_id",
|
|
2313
|
+
(c) => tryRoute(c, () => deps.catalogue.getComposite(c.req.param("composite_id")))
|
|
2314
|
+
);
|
|
2239
2315
|
app.post("/catalogue/composites/:composite_id/calculate-price", async (c) => {
|
|
2240
2316
|
const body = await c.req.json().catch(() => ({}));
|
|
2241
|
-
return tryRoute(
|
|
2317
|
+
return tryRoute(
|
|
2318
|
+
c,
|
|
2319
|
+
() => deps.catalogue.calculateCompositePrice(c.req.param("composite_id"), body)
|
|
2320
|
+
);
|
|
2242
2321
|
});
|
|
2243
|
-
app.get(
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
app.get(
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2322
|
+
app.get(
|
|
2323
|
+
"/catalogue/taxonomies",
|
|
2324
|
+
(c) => tryRoute(c, () => deps.catalogue.listTaxonomies(deps.defaultBusinessId))
|
|
2325
|
+
);
|
|
2326
|
+
app.get(
|
|
2327
|
+
"/catalogue/taxonomies/search",
|
|
2328
|
+
(c) => tryRoute(
|
|
2329
|
+
c,
|
|
2330
|
+
() => deps.catalogue.searchTaxonomies(deps.defaultBusinessId, c.req.query("q") ?? "")
|
|
2331
|
+
)
|
|
2332
|
+
);
|
|
2333
|
+
app.get(
|
|
2334
|
+
"/catalogue/taxonomies/:taxonomy_id",
|
|
2335
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomy(c.req.param("taxonomy_id")))
|
|
2336
|
+
);
|
|
2337
|
+
app.get(
|
|
2338
|
+
"/catalogue/taxonomies/:taxonomy_id/attributes",
|
|
2339
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomyAttributes(c.req.param("taxonomy_id")))
|
|
2340
|
+
);
|
|
2341
|
+
app.get(
|
|
2342
|
+
"/catalogue/taxonomies/:taxonomy_id/path",
|
|
2343
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomyPath(c.req.param("taxonomy_id")))
|
|
2344
|
+
);
|
|
2345
|
+
app.get(
|
|
2346
|
+
"/catalogue/attributes",
|
|
2347
|
+
(c) => tryRoute(c, () => deps.catalogue.listAttributes(deps.defaultBusinessId))
|
|
2348
|
+
);
|
|
2349
|
+
app.get(
|
|
2350
|
+
"/catalogue/properties/facets",
|
|
2351
|
+
(c) => tryRoute(c, () => deps.catalogue.listPropertyFacets(deps.defaultBusinessId))
|
|
2352
|
+
);
|
|
2353
|
+
app.get(
|
|
2354
|
+
"/catalogue/tags",
|
|
2355
|
+
(c) => tryRoute(c, () => deps.catalogue.listTags(deps.defaultBusinessId))
|
|
2356
|
+
);
|
|
2251
2357
|
app.get("/catalogue/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2252
|
-
app.get(
|
|
2253
|
-
|
|
2254
|
-
|
|
2358
|
+
app.get(
|
|
2359
|
+
"/catalogue/menu/categories/:category_id",
|
|
2360
|
+
(c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id")))
|
|
2361
|
+
);
|
|
2362
|
+
app.get(
|
|
2363
|
+
"/catalogue/menu/items/:item_id",
|
|
2364
|
+
(c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("item_id")))
|
|
2365
|
+
);
|
|
2366
|
+
app.get(
|
|
2367
|
+
"/catalogue/knowledge-base/articles",
|
|
2368
|
+
(c) => tryRoute(c, () => ({ articles: deps.catalogue.listKnowledgeArticles(deps.defaultBusinessId) }))
|
|
2369
|
+
);
|
|
2255
2370
|
app.get(
|
|
2256
2371
|
"/catalogue/knowledge-base/search",
|
|
2257
|
-
(c) => tryRoute(c, () => ({
|
|
2372
|
+
(c) => tryRoute(c, () => ({
|
|
2373
|
+
results: deps.catalogue.searchKnowledgeBase(deps.defaultBusinessId, c.req.query("q") ?? ""),
|
|
2374
|
+
query: c.req.query("q") ?? ""
|
|
2375
|
+
}))
|
|
2376
|
+
);
|
|
2377
|
+
app.get(
|
|
2378
|
+
"/catalogue/products/:product_id/attributes",
|
|
2379
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductAttributes(c.req.param("product_id")))
|
|
2258
2380
|
);
|
|
2259
|
-
app.get("/catalogue/products/:product_id/attributes", (c) => tryRoute(c, () => deps.catalogue.getProductAttributes(c.req.param("product_id"))));
|
|
2260
2381
|
app.get(
|
|
2261
2382
|
"/catalogue/products/:product_id/available-now",
|
|
2262
2383
|
(c) => tryRoute(c, () => {
|
|
@@ -2275,22 +2396,45 @@ function buildV1(deps) {
|
|
|
2275
2396
|
"/catalogue/products/:product_id/schedules",
|
|
2276
2397
|
(c) => tryRoute(c, () => {
|
|
2277
2398
|
const p = deps.registry.products.get(c.req.param("product_id"));
|
|
2278
|
-
return {
|
|
2399
|
+
return {
|
|
2400
|
+
schedules: p?.metadata?.["time_profiles"] ?? []
|
|
2401
|
+
};
|
|
2279
2402
|
})
|
|
2280
2403
|
);
|
|
2281
|
-
app.get(
|
|
2282
|
-
|
|
2404
|
+
app.get(
|
|
2405
|
+
"/catalogue/deals",
|
|
2406
|
+
(c) => tryRoute(c, () => deps.catalogue.listDeals(deps.defaultBusinessId))
|
|
2407
|
+
);
|
|
2408
|
+
app.get(
|
|
2409
|
+
"/catalogue/deals/on-sale",
|
|
2410
|
+
(c) => tryRoute(c, () => deps.catalogue.listOnSale(deps.defaultBusinessId))
|
|
2411
|
+
);
|
|
2283
2412
|
app.post("/catalogue/deals/validate", async (c) => {
|
|
2284
2413
|
const body = await c.req.json().catch(() => ({}));
|
|
2285
|
-
return tryRoute(
|
|
2414
|
+
return tryRoute(
|
|
2415
|
+
c,
|
|
2416
|
+
() => deps.catalogue.validateDiscount(
|
|
2417
|
+
body.discount_code ?? body.code ?? "",
|
|
2418
|
+
deps.defaultBusinessId
|
|
2419
|
+
)
|
|
2420
|
+
);
|
|
2286
2421
|
});
|
|
2287
|
-
app.get(
|
|
2422
|
+
app.get(
|
|
2423
|
+
"/catalogue/products/:product_id/deals",
|
|
2424
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductDeals(c.req.param("product_id")))
|
|
2425
|
+
);
|
|
2288
2426
|
app.post("/catalogue/quotes", async (c) => {
|
|
2289
2427
|
const body = await c.req.json().catch(() => ({}));
|
|
2290
2428
|
return tryRoute(c, () => deps.catalogue.createQuote(deps.defaultBusinessId, body));
|
|
2291
2429
|
});
|
|
2292
|
-
app.get(
|
|
2293
|
-
|
|
2430
|
+
app.get(
|
|
2431
|
+
"/catalogue/quotes/:quote_id",
|
|
2432
|
+
(c) => tryRoute(c, () => deps.catalogue.getQuote(c.req.param("quote_id")))
|
|
2433
|
+
);
|
|
2434
|
+
app.post(
|
|
2435
|
+
"/catalogue/quotes/:quote_id/refresh",
|
|
2436
|
+
(c) => tryRoute(c, () => deps.catalogue.refreshQuote(c.req.param("quote_id")))
|
|
2437
|
+
);
|
|
2294
2438
|
app.get("/cart", (c) => tryRoute(c, () => deps.cart.toUICart(deps.cart.get(c.var.session))));
|
|
2295
2439
|
app.delete("/cart", (c) => tryRoute(c, () => deps.cart.clear(c.var.session)));
|
|
2296
2440
|
app.get("/cart/items", (c) => tryRoute(c, () => deps.cart.getItems(c.var.session)));
|
|
@@ -2301,9 +2445,15 @@ function buildV1(deps) {
|
|
|
2301
2445
|
app.patch("/cart/items/:cart_item_id", async (c) => {
|
|
2302
2446
|
const body = await c.req.json().catch(() => ({}));
|
|
2303
2447
|
if (typeof body.quantity !== "number") return fail(c, validation("quantity required"));
|
|
2304
|
-
return tryRoute(
|
|
2448
|
+
return tryRoute(
|
|
2449
|
+
c,
|
|
2450
|
+
() => deps.cart.updateQuantity(c.var.session, c.req.param("cart_item_id"), body.quantity)
|
|
2451
|
+
);
|
|
2305
2452
|
});
|
|
2306
|
-
app.delete(
|
|
2453
|
+
app.delete(
|
|
2454
|
+
"/cart/items/:cart_item_id",
|
|
2455
|
+
(c) => tryRoute(c, () => deps.cart.removeItem(c.var.session, c.req.param("cart_item_id")))
|
|
2456
|
+
);
|
|
2307
2457
|
app.get("/cart/count", (c) => tryRoute(c, () => deps.cart.getCount(c.var.session)));
|
|
2308
2458
|
app.get("/cart/total", (c) => tryRoute(c, () => deps.cart.getTotal(c.var.session)));
|
|
2309
2459
|
app.post("/cart/destination-quote", async (c) => {
|
|
@@ -2314,10 +2464,25 @@ function buildV1(deps) {
|
|
|
2314
2464
|
const body = await c.req.json().catch(() => ({}));
|
|
2315
2465
|
return tryRoute(c, () => deps.cart.applyCoupon(c.var.session, body.coupon_code ?? ""));
|
|
2316
2466
|
});
|
|
2317
|
-
app.delete(
|
|
2318
|
-
|
|
2467
|
+
app.delete(
|
|
2468
|
+
"/cart/coupons/current",
|
|
2469
|
+
(c) => tryRoute(c, () => deps.cart.removeCoupon(c.var.session))
|
|
2470
|
+
);
|
|
2471
|
+
app.get(
|
|
2472
|
+
"/orders",
|
|
2473
|
+
(c) => tryRoute(
|
|
2474
|
+
c,
|
|
2475
|
+
() => deps.orders.list(c.var.session, {
|
|
2476
|
+
limit: getQueryNum(c, "limit"),
|
|
2477
|
+
status: c.req.query("status")
|
|
2478
|
+
})
|
|
2479
|
+
)
|
|
2480
|
+
);
|
|
2319
2481
|
app.get("/orders/:order_id", (c) => tryRoute(c, () => deps.orders.get(c.req.param("order_id"))));
|
|
2320
|
-
app.get(
|
|
2482
|
+
app.get(
|
|
2483
|
+
"/orders/:order_id/payment-status",
|
|
2484
|
+
(c) => tryRoute(c, () => deps.orders.getPaymentStatus(c.req.param("order_id")))
|
|
2485
|
+
);
|
|
2321
2486
|
app.post("/orders/:order_id/cancel", async (c) => {
|
|
2322
2487
|
const body = await c.req.json().catch(() => ({}));
|
|
2323
2488
|
return tryRoute(c, () => deps.orders.cancel(c.req.param("order_id"), body.reason));
|
|
@@ -2326,13 +2491,46 @@ function buildV1(deps) {
|
|
|
2326
2491
|
const body = await c.req.json().catch(() => ({}));
|
|
2327
2492
|
return tryRoute(c, () => deps.orders.updateCustomer(c.req.param("order_id"), body));
|
|
2328
2493
|
});
|
|
2329
|
-
app.post(
|
|
2494
|
+
app.post(
|
|
2495
|
+
"/orders/:order_id/verify-payment",
|
|
2496
|
+
(c) => tryRoute(c, () => deps.orders.verifyPayment(c.req.param("order_id")))
|
|
2497
|
+
);
|
|
2330
2498
|
app.get("/subscriptions", (c) => tryRoute(c, () => deps.subscriptions.list(c.var.session)));
|
|
2331
|
-
app.get(
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
app.post(
|
|
2499
|
+
app.get(
|
|
2500
|
+
"/subscriptions/:subscription_id",
|
|
2501
|
+
(c) => tryRoute(c, () => deps.subscriptions.get(c.req.param("subscription_id")))
|
|
2502
|
+
);
|
|
2503
|
+
app.post(
|
|
2504
|
+
"/subscriptions/:subscription_id/cancel",
|
|
2505
|
+
(c) => tryRoute(c, () => deps.subscriptions.cancel(c.req.param("subscription_id")))
|
|
2506
|
+
);
|
|
2507
|
+
app.post(
|
|
2508
|
+
"/subscriptions/:subscription_id/pause",
|
|
2509
|
+
(c) => tryRoute(c, () => deps.subscriptions.pause(c.req.param("subscription_id")))
|
|
2510
|
+
);
|
|
2511
|
+
app.post(
|
|
2512
|
+
"/subscriptions/:subscription_id/resume",
|
|
2513
|
+
(c) => tryRoute(c, () => deps.subscriptions.resume(c.req.param("subscription_id")))
|
|
2514
|
+
);
|
|
2515
|
+
app.post(
|
|
2516
|
+
"/subscriptions/:subscription_id/skip",
|
|
2517
|
+
(c) => tryRoute(c, () => deps.subscriptions.skipNext(c.req.param("subscription_id")))
|
|
2518
|
+
);
|
|
2519
|
+
app.get("/payments/collection-options", (c) => {
|
|
2520
|
+
const currency = c.req.query("currency")?.trim().toUpperCase();
|
|
2521
|
+
if (!currency || !/^[A-Z]{3}$/.test(currency)) {
|
|
2522
|
+
return fail(c, validation("currency must be a canonical three-letter code"));
|
|
2523
|
+
}
|
|
2524
|
+
return tryRoute(c, () => ({
|
|
2525
|
+
presentment_currency: currency,
|
|
2526
|
+
options: currency === "GHS" ? [
|
|
2527
|
+
{ method: PAYMENT_METHOD.CARD, network: null },
|
|
2528
|
+
{ method: PAYMENT_METHOD.MOBILE_MONEY, network: "mtn" },
|
|
2529
|
+
{ method: PAYMENT_METHOD.MOBILE_MONEY, network: "telecel" },
|
|
2530
|
+
{ method: PAYMENT_METHOD.MOBILE_MONEY, network: "airteltigo" }
|
|
2531
|
+
] : currency === "USD" ? [{ method: PAYMENT_METHOD.CARD, network: null }] : []
|
|
2532
|
+
}));
|
|
2533
|
+
});
|
|
2336
2534
|
app.post("/checkout", async (c) => {
|
|
2337
2535
|
const body = await c.req.json().catch(() => ({}));
|
|
2338
2536
|
return tryRoute(c, () => deps.checkout.process(c.var.session, body));
|
|
@@ -2386,15 +2584,33 @@ function buildV1(deps) {
|
|
|
2386
2584
|
return { success: true, message: "Profile updated successfully" };
|
|
2387
2585
|
});
|
|
2388
2586
|
});
|
|
2389
|
-
app.get(
|
|
2390
|
-
|
|
2587
|
+
app.get(
|
|
2588
|
+
"/inventory/products/:product_id/stock",
|
|
2589
|
+
(c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id")))
|
|
2590
|
+
);
|
|
2591
|
+
app.get(
|
|
2592
|
+
"/inventory/variants/:variant_id/stock",
|
|
2593
|
+
(c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id")))
|
|
2594
|
+
);
|
|
2391
2595
|
app.get(
|
|
2392
2596
|
"/inventory/products/:product_id/availability",
|
|
2393
|
-
(c) => tryRoute(
|
|
2597
|
+
(c) => tryRoute(
|
|
2598
|
+
c,
|
|
2599
|
+
() => deps.inventory.productAvailability(
|
|
2600
|
+
c.req.param("product_id"),
|
|
2601
|
+
getQueryNum(c, "quantity") ?? 1
|
|
2602
|
+
)
|
|
2603
|
+
)
|
|
2394
2604
|
);
|
|
2395
2605
|
app.get(
|
|
2396
2606
|
"/inventory/variants/:variant_id/availability",
|
|
2397
|
-
(c) => tryRoute(
|
|
2607
|
+
(c) => tryRoute(
|
|
2608
|
+
c,
|
|
2609
|
+
() => deps.inventory.variantAvailability(
|
|
2610
|
+
c.req.param("variant_id"),
|
|
2611
|
+
getQueryNum(c, "quantity") ?? 1
|
|
2612
|
+
)
|
|
2613
|
+
)
|
|
2398
2614
|
);
|
|
2399
2615
|
app.get(
|
|
2400
2616
|
"/delivery/fee",
|
|
@@ -2421,35 +2637,75 @@ function buildV1(deps) {
|
|
|
2421
2637
|
);
|
|
2422
2638
|
app.post("/places/autocomplete", async (c) => {
|
|
2423
2639
|
const body = await c.req.json().catch(() => ({}));
|
|
2424
|
-
return tryRoute(
|
|
2640
|
+
return tryRoute(
|
|
2641
|
+
c,
|
|
2642
|
+
() => deps.places.autocomplete({ query: body.input ?? body.query ?? "", country: body.country })
|
|
2643
|
+
);
|
|
2425
2644
|
});
|
|
2426
2645
|
app.post("/places/details", async (c) => {
|
|
2427
2646
|
const body = await c.req.json().catch(() => ({}));
|
|
2428
2647
|
return tryRoute(c, () => deps.places.details({ place_id: body.place_id ?? "" }));
|
|
2429
2648
|
});
|
|
2430
|
-
app.get(
|
|
2431
|
-
|
|
2432
|
-
|
|
2649
|
+
app.get(
|
|
2650
|
+
"/scheduling/services",
|
|
2651
|
+
(c) => tryRoute(c, () => deps.scheduling.listServices(deps.defaultBusinessId))
|
|
2652
|
+
);
|
|
2653
|
+
app.get(
|
|
2654
|
+
"/scheduling/services/:service_id",
|
|
2655
|
+
(c) => tryRoute(c, () => deps.scheduling.getService(c.req.param("service_id")))
|
|
2656
|
+
);
|
|
2657
|
+
app.get(
|
|
2658
|
+
"/scheduling/slots",
|
|
2659
|
+
(c) => tryRoute(
|
|
2660
|
+
c,
|
|
2661
|
+
() => deps.scheduling.getSlots(c.req.query("service_id") ?? "", { date: c.req.query("date") })
|
|
2662
|
+
)
|
|
2663
|
+
);
|
|
2433
2664
|
app.get(
|
|
2434
2665
|
"/scheduling/slots/check",
|
|
2435
|
-
(c) => tryRoute(
|
|
2666
|
+
(c) => tryRoute(
|
|
2667
|
+
c,
|
|
2668
|
+
() => deps.scheduling.checkSlot(
|
|
2669
|
+
c.req.query("service_id") ?? "",
|
|
2670
|
+
c.req.query("start") ?? "",
|
|
2671
|
+
c.req.query("end") ?? ""
|
|
2672
|
+
)
|
|
2673
|
+
)
|
|
2674
|
+
);
|
|
2675
|
+
app.get(
|
|
2676
|
+
"/scheduling/availability",
|
|
2677
|
+
(c) => tryRoute(c, () => deps.scheduling.getServiceAvailability(c.req.query("service_id") ?? ""))
|
|
2678
|
+
);
|
|
2679
|
+
app.get(
|
|
2680
|
+
"/scheduling/bookings",
|
|
2681
|
+
(c) => tryRoute(c, () => deps.scheduling.getCustomerBookings(c.var.session))
|
|
2436
2682
|
);
|
|
2437
|
-
app.get("/scheduling/availability", (c) => tryRoute(c, () => deps.scheduling.getServiceAvailability(c.req.query("service_id") ?? "")));
|
|
2438
|
-
app.get("/scheduling/bookings", (c) => tryRoute(c, () => deps.scheduling.getCustomerBookings(c.var.session)));
|
|
2439
2683
|
app.post("/scheduling/bookings/reschedule", async (c) => {
|
|
2440
2684
|
const body = await c.req.json().catch(() => ({}));
|
|
2441
2685
|
return tryRoute(c, () => deps.scheduling.rescheduleBooking(body));
|
|
2442
2686
|
});
|
|
2443
|
-
app.get(
|
|
2687
|
+
app.get(
|
|
2688
|
+
"/scheduling/bookings/:booking_id",
|
|
2689
|
+
(c) => tryRoute(c, () => deps.scheduling.getBooking(c.req.param("booking_id")))
|
|
2690
|
+
);
|
|
2444
2691
|
app.post("/scheduling/bookings/:booking_id/cancel", async (c) => {
|
|
2445
2692
|
const body = await c.req.json().catch(() => ({}));
|
|
2446
2693
|
return tryRoute(c, () => deps.scheduling.cancelBooking(c.req.param("booking_id"), body.reason));
|
|
2447
2694
|
});
|
|
2448
2695
|
app.get("/lite/bootstrap", (c) => tryRoute(c, () => deps.lite.bootstrap(deps.defaultBusinessId)));
|
|
2449
|
-
app.get(
|
|
2696
|
+
app.get(
|
|
2697
|
+
"/lite/resources/:resource_id",
|
|
2698
|
+
(c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id")))
|
|
2699
|
+
);
|
|
2450
2700
|
app.get("/lite/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2451
|
-
app.get(
|
|
2452
|
-
|
|
2701
|
+
app.get(
|
|
2702
|
+
"/lite/menu/categories/:category_id",
|
|
2703
|
+
(c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id")))
|
|
2704
|
+
);
|
|
2705
|
+
app.get(
|
|
2706
|
+
"/fx/rate",
|
|
2707
|
+
(c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS"))
|
|
2708
|
+
);
|
|
2453
2709
|
app.post("/fx/quotes", async (c) => {
|
|
2454
2710
|
const body = await c.req.json().catch(() => ({}));
|
|
2455
2711
|
return tryRoute(c, () => deps.fx.lockQuote(body));
|
|
@@ -2462,31 +2718,47 @@ function buildV1(deps) {
|
|
|
2462
2718
|
const body = await c.req.json().catch(() => ({}));
|
|
2463
2719
|
return tryRoute(c, () => deps.uploads.confirm(body));
|
|
2464
2720
|
});
|
|
2465
|
-
app.get(
|
|
2466
|
-
"/store-credit/balance",
|
|
2467
|
-
(c) => c.json({ data: { balance: "0.00", currency: "USD" } })
|
|
2468
|
-
);
|
|
2721
|
+
app.get("/store-credit/balance", (c) => c.json({ data: { balance: "0.00", currency: "USD" } }));
|
|
2469
2722
|
app.post("/activity/session", async (c) => {
|
|
2470
2723
|
await c.req.json().catch(() => ({}));
|
|
2471
2724
|
return c.json({ data: { recorded: true } });
|
|
2472
2725
|
});
|
|
2473
2726
|
app.post("/activity/events", async (c) => {
|
|
2474
2727
|
const body = await c.req.json().catch(() => ({}));
|
|
2475
|
-
return tryRoute(
|
|
2728
|
+
return tryRoute(
|
|
2729
|
+
c,
|
|
2730
|
+
() => deps.activity.recordEvents(
|
|
2731
|
+
deps.defaultBusinessId,
|
|
2732
|
+
body.analytics_session_id ?? c.var.session.id,
|
|
2733
|
+
body.events ?? []
|
|
2734
|
+
)
|
|
2735
|
+
);
|
|
2476
2736
|
});
|
|
2477
|
-
app.get(
|
|
2478
|
-
|
|
2737
|
+
app.get(
|
|
2738
|
+
"/activity/state",
|
|
2739
|
+
(c) => tryRoute(c, () => deps.activity.getState(deps.defaultBusinessId, c.var.session.id))
|
|
2740
|
+
);
|
|
2741
|
+
app.get(
|
|
2742
|
+
"/activity/recommendations",
|
|
2743
|
+
(c) => tryRoute(c, () => deps.activity.getRecommendations(deps.defaultBusinessId))
|
|
2744
|
+
);
|
|
2479
2745
|
app.post("/activity/messages/dismiss", async (c) => {
|
|
2480
2746
|
const body = await c.req.json().catch(() => ({}));
|
|
2481
2747
|
return tryRoute(c, () => deps.activity.dismissMessage(body.code ?? body.message_id ?? ""));
|
|
2482
2748
|
});
|
|
2483
2749
|
app.post(
|
|
2484
2750
|
"/support/conversation",
|
|
2485
|
-
(c) => tryRoute(
|
|
2751
|
+
(c) => tryRoute(
|
|
2752
|
+
c,
|
|
2753
|
+
() => deps.support.openConversation(deps.defaultBusinessId, c.var.session.customer_id)
|
|
2754
|
+
)
|
|
2486
2755
|
);
|
|
2487
2756
|
app.get(
|
|
2488
2757
|
"/support/conversation",
|
|
2489
|
-
(c) => tryRoute(
|
|
2758
|
+
(c) => tryRoute(
|
|
2759
|
+
c,
|
|
2760
|
+
() => deps.support.peekConversation(deps.defaultBusinessId, c.var.session.customer_id)
|
|
2761
|
+
)
|
|
2490
2762
|
);
|
|
2491
2763
|
app.post("/support/conversation/messages", async (c) => {
|
|
2492
2764
|
const body = await c.req.json().catch(() => ({}));
|
|
@@ -2502,7 +2774,12 @@ function buildV1(deps) {
|
|
|
2502
2774
|
});
|
|
2503
2775
|
app.get(
|
|
2504
2776
|
"/support/conversation/messages",
|
|
2505
|
-
(c) => tryRoute(
|
|
2777
|
+
(c) => tryRoute(
|
|
2778
|
+
c,
|
|
2779
|
+
() => deps.support.listMessages(c.req.query("conversation_id") ?? "", {
|
|
2780
|
+
limit: getQueryNum(c, "limit")
|
|
2781
|
+
})
|
|
2782
|
+
)
|
|
2506
2783
|
);
|
|
2507
2784
|
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
2508
2785
|
const body = await c.req.json().catch(() => ({}));
|
|
@@ -2523,7 +2800,10 @@ function buildV1(deps) {
|
|
|
2523
2800
|
});
|
|
2524
2801
|
app.get(
|
|
2525
2802
|
"/support/conversation/ws",
|
|
2526
|
-
(c) => c.json(
|
|
2803
|
+
(c) => c.json(
|
|
2804
|
+
{ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false },
|
|
2805
|
+
426
|
|
2806
|
+
)
|
|
2527
2807
|
);
|
|
2528
2808
|
return app;
|
|
2529
2809
|
}
|
|
@@ -4975,9 +5255,11 @@ function createCheckoutService(opts) {
|
|
|
4975
5255
|
if (c.items.length === 0) throw validation("Cart is empty", { code: "CART_EMPTY" });
|
|
4976
5256
|
const orderId = ids.order();
|
|
4977
5257
|
const orderNumber = ids.orderNumber();
|
|
5258
|
+
const paymentId = ids.payment();
|
|
4978
5259
|
const reference = ids.payment();
|
|
4979
5260
|
const requiresAuth = body.payment_method === "mobile_money";
|
|
4980
5261
|
const isCard = body.payment_method === "card" || body.payment_method === "stripe";
|
|
5262
|
+
const cardProvider = body.payment_method === "stripe" || body.pay_currency?.toUpperCase() === "USD" ? "stripe" : "paystack";
|
|
4981
5263
|
const order = {
|
|
4982
5264
|
id: orderId,
|
|
4983
5265
|
business_id: c.business_id,
|
|
@@ -5001,6 +5283,7 @@ function createCheckoutService(opts) {
|
|
|
5001
5283
|
items: c.items,
|
|
5002
5284
|
applied_discount_ids: c.applied_discount_ids,
|
|
5003
5285
|
applied_discount_codes: c.applied_discount_codes,
|
|
5286
|
+
payment_id: paymentId,
|
|
5004
5287
|
payment_reference: reference,
|
|
5005
5288
|
metadata: body.metadata,
|
|
5006
5289
|
created_at: clock.iso(),
|
|
@@ -5017,31 +5300,57 @@ function createCheckoutService(opts) {
|
|
|
5017
5300
|
const result = {
|
|
5018
5301
|
order_id: orderId,
|
|
5019
5302
|
order_number: orderNumber,
|
|
5020
|
-
|
|
5303
|
+
payment_id: paymentId,
|
|
5304
|
+
payment_status: requiresAuth || isCard ? "pending" : "succeeded",
|
|
5021
5305
|
payment_reference: reference,
|
|
5022
5306
|
requires_authorization: requiresAuth,
|
|
5023
5307
|
authorization_type: requiresAuth ? "otp" : void 0,
|
|
5024
|
-
next_action: requiresAuth ? {
|
|
5025
|
-
|
|
5308
|
+
next_action: requiresAuth ? {
|
|
5309
|
+
type: "authorization",
|
|
5310
|
+
authorization_type: "otp",
|
|
5311
|
+
display_text: "Approve on your mobile money app"
|
|
5312
|
+
} : { type: "none" },
|
|
5313
|
+
provider: isCard ? cardProvider : body.payment_method,
|
|
5026
5314
|
bill_token: billToken
|
|
5027
5315
|
};
|
|
5028
5316
|
if (isCard) {
|
|
5029
|
-
result.next_action = { type: "redirect", authorization_url: `https://mock.cimplify.io/pay/${reference}` };
|
|
5030
|
-
result.authorization_url = `https://mock.cimplify.io/pay/${reference}`;
|
|
5031
|
-
result.client_secret = `pi_${orderId.slice(-12)}_secret_${Math.random().toString(36).slice(2, 18)}`;
|
|
5032
5317
|
const proc = globalThis.process;
|
|
5033
|
-
result.
|
|
5318
|
+
result.client_secret = cardProvider === "stripe" ? `pi_${orderId.slice(-12)}_secret_${Math.random().toString(36).slice(2, 18)}` : `access_${reference}`;
|
|
5319
|
+
result.public_key = cardProvider === "stripe" ? proc?.env?.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY ?? "pk_test_mock_stripe" : proc?.env?.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY ?? "pk_test_mock_paystack";
|
|
5320
|
+
result.next_action = {
|
|
5321
|
+
type: "card_popup",
|
|
5322
|
+
provider: cardProvider,
|
|
5323
|
+
client_secret: result.client_secret,
|
|
5324
|
+
public_key: result.public_key
|
|
5325
|
+
};
|
|
5034
5326
|
}
|
|
5035
5327
|
return result;
|
|
5036
5328
|
},
|
|
5037
5329
|
authorize(body) {
|
|
5038
|
-
|
|
5039
|
-
if (!
|
|
5040
|
-
const
|
|
5330
|
+
if (!body.payment_id?.trim()) throw validation("payment_id required");
|
|
5331
|
+
if (!body.authorization) throw validation("authorization required");
|
|
5332
|
+
const order = registry.orders.list(
|
|
5333
|
+
(candidate) => candidate.payment_id === body.payment_id
|
|
5334
|
+
)[0];
|
|
5335
|
+
if (!order) throw notFound(`Payment ${body.payment_id} not found`);
|
|
5336
|
+
const updated = {
|
|
5337
|
+
...order,
|
|
5338
|
+
payment_state: "paid",
|
|
5339
|
+
status: "confirmed",
|
|
5340
|
+
updated_at: clock.iso()
|
|
5341
|
+
};
|
|
5041
5342
|
registry.orders.put(order.id, updated);
|
|
5042
5343
|
bus.emit("order.payment.captured", { order_id: order.id }, order.business_id);
|
|
5043
5344
|
bus.emit("order.confirmed", { order_id: order.id }, order.business_id);
|
|
5044
|
-
return {
|
|
5345
|
+
return {
|
|
5346
|
+
order_id: order.id,
|
|
5347
|
+
order_number: order.user_friendly_id,
|
|
5348
|
+
payment_id: body.payment_id,
|
|
5349
|
+
payment_reference: order.payment_reference,
|
|
5350
|
+
payment_status: "succeeded",
|
|
5351
|
+
requires_authorization: false,
|
|
5352
|
+
next_action: { type: "none" }
|
|
5353
|
+
};
|
|
5045
5354
|
}
|
|
5046
5355
|
};
|
|
5047
5356
|
}
|