@cimplify/sdk 0.38.0 → 0.38.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mock/cli.mjs +238 -63
- package/dist/mock/library.js +238 -63
- package/dist/mock/library.mjs +238 -63
- package/dist/mock/msw.js +238 -63
- package/dist/mock/msw.mjs +238 -63
- package/dist/react.js +12 -2
- package/dist/react.mjs +12 -2
- package/package.json +1 -1
- package/templates/storefront/package.json +3 -1
- package/templates/storefront/src/App.tsx +44 -8
- package/templates/storefront/src/main.tsx +9 -2
- package/templates/storefront/src/styles.css +7 -1
- package/templates/storefront/vite.config.ts +3 -5
package/dist/mock/library.js
CHANGED
|
@@ -3327,6 +3327,15 @@ function percent(a, pct) {
|
|
|
3327
3327
|
function createCatalogueService(opts) {
|
|
3328
3328
|
const { registry, clock, ids } = opts;
|
|
3329
3329
|
const productsForBusiness = (businessId) => registry.products.list((p) => p.business_id === businessId);
|
|
3330
|
+
const defaultPriceInfo = (price, currency) => ({
|
|
3331
|
+
base_price: price,
|
|
3332
|
+
final_price: price,
|
|
3333
|
+
markup_percentage: "0.00",
|
|
3334
|
+
markup_amount: "0.00",
|
|
3335
|
+
markup_discount_percentage: "0.00",
|
|
3336
|
+
markup_discount_amount: "0.00",
|
|
3337
|
+
currency
|
|
3338
|
+
});
|
|
3330
3339
|
const toApiProduct = (p) => ({
|
|
3331
3340
|
id: p.id,
|
|
3332
3341
|
business_id: p.business_id,
|
|
@@ -3335,10 +3344,15 @@ function createCatalogueService(opts) {
|
|
|
3335
3344
|
description: p.description ?? "",
|
|
3336
3345
|
product_type: p.product_type,
|
|
3337
3346
|
base_price: p.base_price,
|
|
3347
|
+
default_price: p.base_price,
|
|
3348
|
+
default_price_info: defaultPriceInfo(p.base_price, p.currency),
|
|
3349
|
+
price_info: defaultPriceInfo(p.base_price, p.currency),
|
|
3338
3350
|
currency: p.currency,
|
|
3339
3351
|
image: p.image,
|
|
3352
|
+
image_url: p.image,
|
|
3340
3353
|
images: p.images,
|
|
3341
3354
|
is_available: p.is_available,
|
|
3355
|
+
category_id: p.category_ids[0],
|
|
3342
3356
|
category_ids: p.category_ids,
|
|
3343
3357
|
collection_ids: p.collection_ids,
|
|
3344
3358
|
add_on_ids: p.add_on_ids,
|
|
@@ -3348,6 +3362,7 @@ function createCatalogueService(opts) {
|
|
|
3348
3362
|
custom_attributes: [],
|
|
3349
3363
|
properties: [],
|
|
3350
3364
|
has_variants: p.variant_ids.length > 0,
|
|
3365
|
+
type: p.product_type,
|
|
3351
3366
|
render_hint: "general"
|
|
3352
3367
|
});
|
|
3353
3368
|
const variantsForProduct = (productId) => registry.variants.list((v) => v.product_id === productId);
|
|
@@ -4614,26 +4629,26 @@ function createLiteService(opts) {
|
|
|
4614
4629
|
// src/mock/seeds/default.ts
|
|
4615
4630
|
var ISO = "2026-01-01T00:00:00.000Z";
|
|
4616
4631
|
var PRODUCTS = [
|
|
4617
|
-
{ name: "Sourdough Loaf", slug: "sourdough-loaf", price: "25.00", category: "breads", description: "Artisanal 24-hour fermented sourdough.", image: "
|
|
4618
|
-
{ name: "Whole Wheat Bread", slug: "whole-wheat", price: "20.00", category: "breads", description: "Hearty whole wheat with seeds.", image: "
|
|
4619
|
-
{ name: "Baguette", slug: "baguette", price: "15.00", category: "breads", description: "Crispy crust, soft inside.", image: "
|
|
4620
|
-
{ name: "Focaccia", slug: "focaccia", price: "30.00", category: "breads", description: "Olive oil and rosemary focaccia.", image: "
|
|
4621
|
-
{ name: "Croissant", slug: "croissant", price: "12.00", category: "pastries", description: "Buttery French croissant.", image: "
|
|
4622
|
-
{ name: "Pain au Chocolat", slug: "pain-au-chocolat", price: "14.00", category: "pastries", description: "Croissant with dark chocolate.", image: "
|
|
4623
|
-
{ name: "Almond Danish", slug: "almond-danish", price: "16.00", category: "pastries", description: "Flaky pastry with almond cream.", image: "
|
|
4624
|
-
{ name: "Cinnamon Roll", slug: "cinnamon-roll", price: "13.00", category: "pastries", description: "Soft roll with cinnamon glaze.", image: "
|
|
4625
|
-
{ name: "Chocolate Cake (Slice)", slug: "chocolate-cake", price: "22.00", category: "cakes", description: "Rich dark chocolate cake.", image: "
|
|
4626
|
-
{ name: "Red Velvet (Slice)", slug: "red-velvet", price: "22.00", category: "cakes", description: "Classic red velvet with cream cheese.", image: "
|
|
4627
|
-
{ name: "Carrot Cake (Slice)", slug: "carrot-cake", price: "20.00", category: "cakes", description: "Spiced carrot cake with walnut.", image: "
|
|
4628
|
-
{ name: "Cheesecake (Slice)", slug: "cheesecake", price: "24.00", category: "cakes", description: "New York style cheesecake.", image: "
|
|
4629
|
-
{ name: "Coffee", slug: "coffee", price: "10.00", category: "drinks", description: "Locally roasted Arabica.", image: "
|
|
4630
|
-
{ name: "Tea", slug: "tea", price: "8.00", category: "drinks", description: "Black, green, or herbal.", image: "
|
|
4631
|
-
{ name: "Hibiscus Tea (Sobolo)", slug: "sobolo", price: "12.00", category: "drinks", description: "Iced hibiscus drink.", image: "
|
|
4632
|
-
{ name: "Fresh Orange Juice", slug: "orange-juice", price: "15.00", category: "drinks", description: "Cold-pressed orange juice.", image: "
|
|
4633
|
-
{ name: "Banana Bread", slug: "banana-bread", price: "18.00", category: "breads", description: "Moist banana loaf.", image: "
|
|
4634
|
-
{ name: "Brownie", slug: "brownie", price: "12.00", category: "pastries", description: "Fudgy chocolate brownie.", image: "
|
|
4635
|
-
{ name: "Macaron Box (6)", slug: "macaron-box", price: "60.00", category: "pastries", description: "Six assorted macarons.", image: "
|
|
4636
|
-
{ name: "Custom Birthday Cake", slug: "birthday-cake", price: "250.00", category: "cakes", description: "Made-to-order. Min 48h notice.", image: "
|
|
4632
|
+
{ name: "Sourdough Loaf", slug: "sourdough-loaf", price: "25.00", category: "breads", description: "Artisanal 24-hour fermented sourdough.", image: "/img/sourdough.jpg" },
|
|
4633
|
+
{ name: "Whole Wheat Bread", slug: "whole-wheat", price: "20.00", category: "breads", description: "Hearty whole wheat with seeds.", image: "/img/wheat.jpg" },
|
|
4634
|
+
{ name: "Baguette", slug: "baguette", price: "15.00", category: "breads", description: "Crispy crust, soft inside.", image: "/img/baguette.jpg" },
|
|
4635
|
+
{ name: "Focaccia", slug: "focaccia", price: "30.00", category: "breads", description: "Olive oil and rosemary focaccia.", image: "/img/focaccia.jpg" },
|
|
4636
|
+
{ name: "Croissant", slug: "croissant", price: "12.00", category: "pastries", description: "Buttery French croissant.", image: "/img/croissant.jpg" },
|
|
4637
|
+
{ name: "Pain au Chocolat", slug: "pain-au-chocolat", price: "14.00", category: "pastries", description: "Croissant with dark chocolate.", image: "/img/pac.jpg" },
|
|
4638
|
+
{ name: "Almond Danish", slug: "almond-danish", price: "16.00", category: "pastries", description: "Flaky pastry with almond cream.", image: "/img/danish.jpg" },
|
|
4639
|
+
{ name: "Cinnamon Roll", slug: "cinnamon-roll", price: "13.00", category: "pastries", description: "Soft roll with cinnamon glaze.", image: "/img/cinnamon.jpg" },
|
|
4640
|
+
{ name: "Chocolate Cake (Slice)", slug: "chocolate-cake", price: "22.00", category: "cakes", description: "Rich dark chocolate cake.", image: "/img/choc-cake.jpg" },
|
|
4641
|
+
{ name: "Red Velvet (Slice)", slug: "red-velvet", price: "22.00", category: "cakes", description: "Classic red velvet with cream cheese.", image: "/img/red-velvet.jpg" },
|
|
4642
|
+
{ name: "Carrot Cake (Slice)", slug: "carrot-cake", price: "20.00", category: "cakes", description: "Spiced carrot cake with walnut.", image: "/img/carrot.jpg" },
|
|
4643
|
+
{ name: "Cheesecake (Slice)", slug: "cheesecake", price: "24.00", category: "cakes", description: "New York style cheesecake.", image: "/img/cheesecake.jpg" },
|
|
4644
|
+
{ name: "Coffee", slug: "coffee", price: "10.00", category: "drinks", description: "Locally roasted Arabica.", image: "/img/coffee.jpg" },
|
|
4645
|
+
{ name: "Tea", slug: "tea", price: "8.00", category: "drinks", description: "Black, green, or herbal.", image: "/img/tea.jpg" },
|
|
4646
|
+
{ name: "Hibiscus Tea (Sobolo)", slug: "sobolo", price: "12.00", category: "drinks", description: "Iced hibiscus drink.", image: "/img/sobolo.jpg" },
|
|
4647
|
+
{ name: "Fresh Orange Juice", slug: "orange-juice", price: "15.00", category: "drinks", description: "Cold-pressed orange juice.", image: "/img/oj.jpg" },
|
|
4648
|
+
{ name: "Banana Bread", slug: "banana-bread", price: "18.00", category: "breads", description: "Moist banana loaf.", image: "/img/banana.jpg" },
|
|
4649
|
+
{ name: "Brownie", slug: "brownie", price: "12.00", category: "pastries", description: "Fudgy chocolate brownie.", image: "/img/brownie.jpg" },
|
|
4650
|
+
{ name: "Macaron Box (6)", slug: "macaron-box", price: "60.00", category: "pastries", description: "Six assorted macarons.", image: "/img/macaron.jpg" },
|
|
4651
|
+
{ name: "Custom Birthday Cake", slug: "birthday-cake", price: "250.00", category: "cakes", description: "Made-to-order. Min 48h notice.", image: "/img/birthday.jpg" }
|
|
4637
4652
|
];
|
|
4638
4653
|
var CATEGORIES = [
|
|
4639
4654
|
{ slug: "breads", name: "Breads", description: "Sourdough, baguettes, focaccia." },
|
|
@@ -4654,7 +4669,7 @@ function seedDefault(registry) {
|
|
|
4654
4669
|
default_address: "12 Independence Ave, Accra",
|
|
4655
4670
|
default_offers_table_service: true,
|
|
4656
4671
|
default_accepts_online_orders: true,
|
|
4657
|
-
image: "
|
|
4672
|
+
image: "/img/akua-logo.png",
|
|
4658
4673
|
status: "active",
|
|
4659
4674
|
created_at: ISO,
|
|
4660
4675
|
updated_at: ISO,
|
|
@@ -4914,8 +4929,8 @@ function seedDefault(registry) {
|
|
|
4914
4929
|
product_type: "bundle",
|
|
4915
4930
|
base_price: "30.00",
|
|
4916
4931
|
currency: "GHS",
|
|
4917
|
-
image: "
|
|
4918
|
-
images: ["
|
|
4932
|
+
image: "/img/breakfast-box.jpg",
|
|
4933
|
+
images: ["/img/breakfast-box.jpg"],
|
|
4919
4934
|
is_available: true,
|
|
4920
4935
|
category_ids: [categoryIdsBySlug.get("pastries")],
|
|
4921
4936
|
collection_ids: [],
|
|
@@ -4955,8 +4970,8 @@ function seedDefault(registry) {
|
|
|
4955
4970
|
product_type: "composite",
|
|
4956
4971
|
base_price: "60.00",
|
|
4957
4972
|
currency: "GHS",
|
|
4958
|
-
image: "
|
|
4959
|
-
images: ["
|
|
4973
|
+
image: "/img/pastry-box.jpg",
|
|
4974
|
+
images: ["/img/pastry-box.jpg"],
|
|
4960
4975
|
is_available: true,
|
|
4961
4976
|
category_ids: [categoryIdsBySlug.get("pastries")],
|
|
4962
4977
|
collection_ids: [],
|
|
@@ -5142,7 +5157,7 @@ function seedReesa(registry) {
|
|
|
5142
5157
|
default_address: "5 Allen Avenue, Ikeja, Lagos",
|
|
5143
5158
|
default_offers_table_service: false,
|
|
5144
5159
|
default_accepts_online_orders: true,
|
|
5145
|
-
image: "
|
|
5160
|
+
image: "/img/reesa-logo.png",
|
|
5146
5161
|
status: "active",
|
|
5147
5162
|
created_at: ISO3,
|
|
5148
5163
|
updated_at: ISO3,
|
|
@@ -5198,8 +5213,8 @@ function seedReesa(registry) {
|
|
|
5198
5213
|
product_type: "product",
|
|
5199
5214
|
base_price: p.price,
|
|
5200
5215
|
currency: "NGN",
|
|
5201
|
-
image:
|
|
5202
|
-
images: [
|
|
5216
|
+
image: `/img/reesa/${p.slug}.jpg`,
|
|
5217
|
+
images: [`/img/reesa/${p.slug}.jpg`],
|
|
5203
5218
|
is_available: true,
|
|
5204
5219
|
category_ids: [catId],
|
|
5205
5220
|
collection_ids: [],
|
|
@@ -5422,8 +5437,8 @@ function seedReesa(registry) {
|
|
|
5422
5437
|
product_type: "bundle",
|
|
5423
5438
|
base_price: "55000.00",
|
|
5424
5439
|
currency: "NGN",
|
|
5425
|
-
image: "
|
|
5426
|
-
images: ["
|
|
5440
|
+
image: "/img/reesa/owambe.jpg",
|
|
5441
|
+
images: ["/img/reesa/owambe.jpg"],
|
|
5427
5442
|
is_available: true,
|
|
5428
5443
|
category_ids: [catIdsBySlug.get("apparel")],
|
|
5429
5444
|
collection_ids: [],
|
|
@@ -5554,7 +5569,7 @@ function seedRestaurant(registry) {
|
|
|
5554
5569
|
default_address: "8 Ring Road, East Legon, Accra",
|
|
5555
5570
|
default_offers_table_service: true,
|
|
5556
5571
|
default_accepts_online_orders: true,
|
|
5557
|
-
image: "
|
|
5572
|
+
image: "/img/mamas-logo.png",
|
|
5558
5573
|
status: "active",
|
|
5559
5574
|
created_at: ISO4,
|
|
5560
5575
|
updated_at: ISO4,
|
|
@@ -5625,8 +5640,8 @@ function seedRestaurant(registry) {
|
|
|
5625
5640
|
product_type: "product",
|
|
5626
5641
|
base_price: p.price,
|
|
5627
5642
|
currency: "GHS",
|
|
5628
|
-
image:
|
|
5629
|
-
images: [
|
|
5643
|
+
image: `/img/mamas/${p.slug}.jpg`,
|
|
5644
|
+
images: [`/img/mamas/${p.slug}.jpg`],
|
|
5630
5645
|
is_available: true,
|
|
5631
5646
|
category_ids: [catId],
|
|
5632
5647
|
collection_ids: [],
|
|
@@ -5864,8 +5879,8 @@ function seedRestaurant(registry) {
|
|
|
5864
5879
|
product_type: "bundle",
|
|
5865
5880
|
base_price: "180.00",
|
|
5866
5881
|
currency: "GHS",
|
|
5867
|
-
image: "
|
|
5868
|
-
images: ["
|
|
5882
|
+
image: "/img/mamas/feast.jpg",
|
|
5883
|
+
images: ["/img/mamas/feast.jpg"],
|
|
5869
5884
|
is_available: true,
|
|
5870
5885
|
category_ids: [catIds.get("mains")],
|
|
5871
5886
|
collection_ids: [],
|
|
@@ -5900,8 +5915,8 @@ function seedRestaurant(registry) {
|
|
|
5900
5915
|
product_type: "composite",
|
|
5901
5916
|
base_price: "0.00",
|
|
5902
5917
|
currency: "GHS",
|
|
5903
|
-
image: "
|
|
5904
|
-
images: ["
|
|
5918
|
+
image: "/img/mamas/byo.jpg",
|
|
5919
|
+
images: ["/img/mamas/byo.jpg"],
|
|
5905
5920
|
is_available: true,
|
|
5906
5921
|
category_ids: [catIds.get("mains")],
|
|
5907
5922
|
collection_ids: [],
|
|
@@ -6013,7 +6028,7 @@ function seedRetail(registry) {
|
|
|
6013
6028
|
default_address: "Atomic Junction, Accra",
|
|
6014
6029
|
default_offers_table_service: false,
|
|
6015
6030
|
default_accepts_online_orders: true,
|
|
6016
|
-
image: "
|
|
6031
|
+
image: "/img/currents-logo.png",
|
|
6017
6032
|
status: "active",
|
|
6018
6033
|
created_at: ISO5,
|
|
6019
6034
|
updated_at: ISO5,
|
|
@@ -6083,8 +6098,8 @@ function seedRetail(registry) {
|
|
|
6083
6098
|
product_type: "product",
|
|
6084
6099
|
base_price: p.price,
|
|
6085
6100
|
currency: "GHS",
|
|
6086
|
-
image:
|
|
6087
|
-
images: [
|
|
6101
|
+
image: `/img/currents/${p.slug}.jpg`,
|
|
6102
|
+
images: [`/img/currents/${p.slug}.jpg`],
|
|
6088
6103
|
is_available: true,
|
|
6089
6104
|
category_ids: [catId],
|
|
6090
6105
|
collection_ids: [],
|
|
@@ -6347,8 +6362,8 @@ function seedRetail(registry) {
|
|
|
6347
6362
|
product_type: "bundle",
|
|
6348
6363
|
base_price: "11910.00",
|
|
6349
6364
|
currency: "GHS",
|
|
6350
|
-
image: "
|
|
6351
|
-
images: ["
|
|
6365
|
+
image: "/img/currents/wfh.jpg",
|
|
6366
|
+
images: ["/img/currents/wfh.jpg"],
|
|
6352
6367
|
is_available: true,
|
|
6353
6368
|
category_ids: [catIds.get("laptops")],
|
|
6354
6369
|
collection_ids: [],
|
|
@@ -6381,8 +6396,8 @@ function seedRetail(registry) {
|
|
|
6381
6396
|
product_type: "bundle",
|
|
6382
6397
|
base_price: "4200.00",
|
|
6383
6398
|
currency: "GHS",
|
|
6384
|
-
image: "
|
|
6385
|
-
images: ["
|
|
6399
|
+
image: "/img/currents/game-pack.jpg",
|
|
6400
|
+
images: ["/img/currents/game-pack.jpg"],
|
|
6386
6401
|
is_available: true,
|
|
6387
6402
|
category_ids: [catIds.get("gaming")],
|
|
6388
6403
|
collection_ids: [],
|
|
@@ -6485,7 +6500,7 @@ function seedServices(registry) {
|
|
|
6485
6500
|
default_address: "12 Cantonments Road, Accra",
|
|
6486
6501
|
default_offers_table_service: false,
|
|
6487
6502
|
default_accepts_online_orders: true,
|
|
6488
|
-
image: "
|
|
6503
|
+
image: "/img/serene-logo.png",
|
|
6489
6504
|
status: "active",
|
|
6490
6505
|
created_at: ISO6,
|
|
6491
6506
|
updated_at: ISO6,
|
|
@@ -6553,8 +6568,8 @@ function seedServices(registry) {
|
|
|
6553
6568
|
product_type: "service",
|
|
6554
6569
|
base_price: s.price,
|
|
6555
6570
|
currency: "GHS",
|
|
6556
|
-
image:
|
|
6557
|
-
images: [
|
|
6571
|
+
image: `/img/serene/${s.slug}.jpg`,
|
|
6572
|
+
images: [`/img/serene/${s.slug}.jpg`],
|
|
6558
6573
|
is_available: true,
|
|
6559
6574
|
category_ids: [catId],
|
|
6560
6575
|
collection_ids: [],
|
|
@@ -6690,8 +6705,8 @@ function seedServices(registry) {
|
|
|
6690
6705
|
product_type: "bundle",
|
|
6691
6706
|
base_price: "480.00",
|
|
6692
6707
|
currency: "GHS",
|
|
6693
|
-
image: "
|
|
6694
|
-
images: ["
|
|
6708
|
+
image: "/img/serene/spa-day.jpg",
|
|
6709
|
+
images: ["/img/serene/spa-day.jpg"],
|
|
6695
6710
|
is_available: true,
|
|
6696
6711
|
category_ids: [catIds.get("wellness")],
|
|
6697
6712
|
collection_ids: [],
|
|
@@ -6724,8 +6739,8 @@ function seedServices(registry) {
|
|
|
6724
6739
|
product_type: "bundle",
|
|
6725
6740
|
base_price: "850.50",
|
|
6726
6741
|
currency: "GHS",
|
|
6727
|
-
image: "
|
|
6728
|
-
images: ["
|
|
6742
|
+
image: "/img/serene/couples.jpg",
|
|
6743
|
+
images: ["/img/serene/couples.jpg"],
|
|
6729
6744
|
is_available: true,
|
|
6730
6745
|
category_ids: [catIds.get("wellness")],
|
|
6731
6746
|
collection_ids: [],
|
|
@@ -6760,8 +6775,8 @@ function seedServices(registry) {
|
|
|
6760
6775
|
product_type: "composite",
|
|
6761
6776
|
base_price: "0.00",
|
|
6762
6777
|
currency: "GHS",
|
|
6763
|
-
image: "
|
|
6764
|
-
images: ["
|
|
6778
|
+
image: "/img/serene/custom.jpg",
|
|
6779
|
+
images: ["/img/serene/custom.jpg"],
|
|
6765
6780
|
is_available: true,
|
|
6766
6781
|
category_ids: [catIds.get("wellness")],
|
|
6767
6782
|
collection_ids: [],
|
|
@@ -6864,7 +6879,7 @@ function seedGrocery(registry) {
|
|
|
6864
6879
|
default_address: "Spintex Road, Accra",
|
|
6865
6880
|
default_offers_table_service: false,
|
|
6866
6881
|
default_accepts_online_orders: true,
|
|
6867
|
-
image: "
|
|
6882
|
+
image: "/img/freshmart-logo.png",
|
|
6868
6883
|
status: "active",
|
|
6869
6884
|
created_at: ISO7,
|
|
6870
6885
|
updated_at: ISO7,
|
|
@@ -6939,8 +6954,8 @@ function seedGrocery(registry) {
|
|
|
6939
6954
|
product_type: "product",
|
|
6940
6955
|
base_price: p.price,
|
|
6941
6956
|
currency: "GHS",
|
|
6942
|
-
image:
|
|
6943
|
-
images: [
|
|
6957
|
+
image: `/img/freshmart/${p.slug}.jpg`,
|
|
6958
|
+
images: [`/img/freshmart/${p.slug}.jpg`],
|
|
6944
6959
|
is_available: true,
|
|
6945
6960
|
category_ids: [catId],
|
|
6946
6961
|
collection_ids: [],
|
|
@@ -7023,8 +7038,8 @@ function seedGrocery(registry) {
|
|
|
7023
7038
|
product_type: "bundle",
|
|
7024
7039
|
base_price: "199.50",
|
|
7025
7040
|
currency: "GHS",
|
|
7026
|
-
image: "
|
|
7027
|
-
images: ["
|
|
7041
|
+
image: "/img/freshmart/essentials.jpg",
|
|
7042
|
+
images: ["/img/freshmart/essentials.jpg"],
|
|
7028
7043
|
is_available: true,
|
|
7029
7044
|
category_ids: [catIds.get("pantry")],
|
|
7030
7045
|
collection_ids: [],
|
|
@@ -7207,11 +7222,19 @@ function createMockApp(options = {}) {
|
|
|
7207
7222
|
app.use("*", async (c, next) => {
|
|
7208
7223
|
const origin = c.req.header("origin") ?? "";
|
|
7209
7224
|
const allow = corsOrigins === "*" ? "*" : corsOrigins.includes(origin) ? origin : corsOrigins[0] ?? "*";
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7225
|
+
const headers = {
|
|
7226
|
+
"Access-Control-Allow-Origin": allow,
|
|
7227
|
+
"Access-Control-Allow-Credentials": "true",
|
|
7228
|
+
"Access-Control-Allow-Headers": c.req.header("access-control-request-headers") ?? "content-type,authorization,x-session-token,idempotency-key",
|
|
7229
|
+
"Access-Control-Allow-Methods": "GET,POST,PATCH,DELETE,OPTIONS",
|
|
7230
|
+
"Access-Control-Expose-Headers": "x-session-token",
|
|
7231
|
+
"Access-Control-Max-Age": "86400",
|
|
7232
|
+
Vary: "Origin"
|
|
7233
|
+
};
|
|
7234
|
+
if (c.req.method === "OPTIONS") {
|
|
7235
|
+
return new Response(null, { status: 204, headers });
|
|
7236
|
+
}
|
|
7237
|
+
for (const [k, v] of Object.entries(headers)) c.header(k, v);
|
|
7215
7238
|
await next();
|
|
7216
7239
|
});
|
|
7217
7240
|
}
|
|
@@ -7228,6 +7251,158 @@ function createMockApp(options = {}) {
|
|
|
7228
7251
|
})
|
|
7229
7252
|
);
|
|
7230
7253
|
app.get("/healthz", (c) => c.json({ ok: true, time: deps.clock.iso() }));
|
|
7254
|
+
const UNSPLASH_PHOTOS = {
|
|
7255
|
+
// Akua's Bakery (default seed)
|
|
7256
|
+
sourdough: "1509440159596-0249088772ff",
|
|
7257
|
+
wheat: "1486887396153-fa416526c108",
|
|
7258
|
+
baguette: "1568471173242-461f0a730452",
|
|
7259
|
+
focaccia: "1573472635068-fd9b1abdd8e5",
|
|
7260
|
+
croissant: "1555507036-ab1f4038808a",
|
|
7261
|
+
pac: "1530610476181-d83430b64dcd",
|
|
7262
|
+
danish: "1517433367423-c7e5b0f35086",
|
|
7263
|
+
cinnamon: "1583527976767-50068e72b7a3",
|
|
7264
|
+
"choc-cake": "1565958011703-44f9829ba187",
|
|
7265
|
+
"red-velvet": "1586788680434-30d324b2d46f",
|
|
7266
|
+
carrot: "1568827999250-3f6afff96e66",
|
|
7267
|
+
cheesecake: "1567306226416-28f0efdc88ce",
|
|
7268
|
+
coffee: "1495474472287-4d71bcdd2085",
|
|
7269
|
+
tea: "1576092768241-dec231879fc3",
|
|
7270
|
+
sobolo: "1556679343-c7306c1976bc",
|
|
7271
|
+
oj: "1600271886742-f049b969dc7a",
|
|
7272
|
+
banana: "1632931057819-4eefffa8e007",
|
|
7273
|
+
brownie: "1551024506-0bccd828d307",
|
|
7274
|
+
macaron: "1558326567-98ae2405596b",
|
|
7275
|
+
birthday: "1535254973040-607b474cb50d",
|
|
7276
|
+
"breakfast-box": "1533089860892-a7c6f0a88666",
|
|
7277
|
+
"pastry-box": "1486427944299-d1955d23e34d",
|
|
7278
|
+
// Mama's Kitchen (restaurant seed)
|
|
7279
|
+
kelewele: "1585536830049-aedf5c1b98a4",
|
|
7280
|
+
"spring-rolls": "1606755962773-d324e0a13086",
|
|
7281
|
+
"soup-of-the-day": "1547592180-85f173990554",
|
|
7282
|
+
"jollof-rice": "1604329760661-e71dc83f8f26",
|
|
7283
|
+
"banku-tilapia": "1559847844-5315695dadae",
|
|
7284
|
+
"fufu-light-soup": "1547928576-b822bcced36e",
|
|
7285
|
+
waakye: "1604329760661-e71dc83f8f26",
|
|
7286
|
+
"grilled-chicken": "1532550907401-a500c9a57435",
|
|
7287
|
+
burger: "1568901346375-23c9450c58cd",
|
|
7288
|
+
"yam-fries": "1573080496219-bb080dd4f877",
|
|
7289
|
+
"fried-plantain": "1604329760661-e71dc83f8f26",
|
|
7290
|
+
salad: "1512621776951-a57141f2eefd",
|
|
7291
|
+
"ice-cream": "1497034825429-c343d7c6a68f",
|
|
7292
|
+
"cake-slice": "1565958011703-44f9829ba187",
|
|
7293
|
+
"fruit-bowl": "1490474418585-ba9bad8fd0ea",
|
|
7294
|
+
"soft-drink": "1497534446932-c925b458314e",
|
|
7295
|
+
"fresh-juice": "1622597467836-f3285f2131b8",
|
|
7296
|
+
water: "1548839140-29a749e1cf4d",
|
|
7297
|
+
feast: "1546069901-ba9599a7e63c",
|
|
7298
|
+
byo: "1546069901-ba9599a7e63c",
|
|
7299
|
+
// Currents Electronics
|
|
7300
|
+
"android-flagship": "1511707171634-5f897ff02aa9",
|
|
7301
|
+
"android-mid": "1592899677977-9c10ca588bbd",
|
|
7302
|
+
"phone-budget": "1574944985070-8f3ebc6b79d2",
|
|
7303
|
+
"laptop-pro": "1496181133206-80ce9b88a853",
|
|
7304
|
+
"laptop-air": "1517336714731-489689fd1ca8",
|
|
7305
|
+
"laptop-budget": "1541807084-5c52b6b3adef",
|
|
7306
|
+
"headphones-anc": "1583394838336-acd977736f90",
|
|
7307
|
+
"earbuds-pro": "1606220945770-b5b6c2c55bf1",
|
|
7308
|
+
"speaker-bt": "1608043152269-423dbba4e7e1",
|
|
7309
|
+
"phone-case": "1601593346740-925612772716",
|
|
7310
|
+
"screen-protector": "1592890288564-76628a30a657",
|
|
7311
|
+
"fast-charger": "1583394838336-acd977736f90",
|
|
7312
|
+
"laptop-sleeve": "1525547719571-a2d4ac8945e2",
|
|
7313
|
+
"wireless-mouse": "1527864550417-7fd91fc51a46",
|
|
7314
|
+
"mech-keyboard": "1587829741301-dc798b83add3",
|
|
7315
|
+
"gaming-controller": "1592840496694-26d035b52b48",
|
|
7316
|
+
"gaming-headset": "1591105327764-407a4a06e768",
|
|
7317
|
+
"console-handheld": "1606144042614-b2417e99c4e3",
|
|
7318
|
+
wfh: "1593642632559-0c6d3fc62b89",
|
|
7319
|
+
"game-pack": "1606144042614-b2417e99c4e3",
|
|
7320
|
+
// Reesa apparel
|
|
7321
|
+
"ankara-shirt": "1591047139829-d91aecb6caea",
|
|
7322
|
+
"agbada-set": "1605497788044-5a32c7078486",
|
|
7323
|
+
kaftan: "1554412933-514a83d2f3c8",
|
|
7324
|
+
"leather-tote": "1584917865442-de89df76afd3",
|
|
7325
|
+
sandals: "1543163521-1bf539c55dd2",
|
|
7326
|
+
"beaded-bracelet": "1611591437281-460bfbe1220a",
|
|
7327
|
+
owambe: "1605497788044-5a32c7078486",
|
|
7328
|
+
// FreshMart
|
|
7329
|
+
"tomatoes-1kg": "1546470427-227f1c75a9ef",
|
|
7330
|
+
"onions-1kg": "1620574387735-3624d75b2dbc",
|
|
7331
|
+
"ginger-200g": "1606937330526-f5e6a2a83555",
|
|
7332
|
+
"bananas-bunch": "1571771894821-ce9b6c11b08e",
|
|
7333
|
+
pineapple: "1550258987-190a2d41a8ba",
|
|
7334
|
+
"spinach-bunch": "1576045057995-568f588f82fb",
|
|
7335
|
+
"milk-1l": "1550583724-b2692b85b150",
|
|
7336
|
+
"yogurt-500g": "1571212515416-fef01fc43637",
|
|
7337
|
+
"eggs-12": "1582722872445-44dc5f7e3c8f",
|
|
7338
|
+
"cheese-200g": "1486297678162-eb2a19b0a32d",
|
|
7339
|
+
"chicken-1kg": "1604503468506-a8da13d82791",
|
|
7340
|
+
"beef-mince-500g": "1607623814075-e51df1bdc82f",
|
|
7341
|
+
"tilapia-each": "1546069901-ba9599a7e63c",
|
|
7342
|
+
"rice-5kg": "1586201375761-83865001e31c",
|
|
7343
|
+
"garri-2kg": "1604329760661-e71dc83f8f26",
|
|
7344
|
+
"palm-oil-1l": "1474979266404-7eaacbcd87c5",
|
|
7345
|
+
"vegetable-oil-1l": "1474979266404-7eaacbcd87c5",
|
|
7346
|
+
"salt-1kg": "1612531386530-97286d97c2d2",
|
|
7347
|
+
"sugar-1kg": "1581281697996-3aef0c3b9b12",
|
|
7348
|
+
"tomato-paste": "1546470427-227f1c75a9ef",
|
|
7349
|
+
"soap-bar": "1583912267550-d6c2ac3196c0",
|
|
7350
|
+
"detergent-1kg": "1583912267550-d6c2ac3196c0",
|
|
7351
|
+
"tissue-pack": "1610557892470-55d9e80c0bce",
|
|
7352
|
+
"trash-bags": "1583912267550-d6c2ac3196c0",
|
|
7353
|
+
essentials: "1542838132-92c53300491e",
|
|
7354
|
+
// Serene Spa services
|
|
7355
|
+
"swedish-massage-60": "1544161515-4ab6ce6db874",
|
|
7356
|
+
"swedish-massage-90": "1544161515-4ab6ce6db874",
|
|
7357
|
+
"deep-tissue-60": "1600334129128-685c5582fd35",
|
|
7358
|
+
"couples-massage": "1540555700478-4be289fbecef",
|
|
7359
|
+
"hot-stone-90": "1600334129128-685c5582fd35",
|
|
7360
|
+
"facial-classic": "1570172619644-dfd03ed5d881",
|
|
7361
|
+
"facial-anti-aging": "1571019613454-1cb2f99b2d8b",
|
|
7362
|
+
"facial-acne": "1571019613454-1cb2f99b2d8b",
|
|
7363
|
+
manicure: "1604654894610-df63bc536371",
|
|
7364
|
+
pedicure: "1610701596007-11502861dcfa",
|
|
7365
|
+
"gel-manicure": "1604654894610-df63bc536371",
|
|
7366
|
+
haircut: "1562322140-8baeececf3df",
|
|
7367
|
+
"hair-treatment": "1522337360788-8b13dee7a37e",
|
|
7368
|
+
color: "1562322140-8baeececf3df",
|
|
7369
|
+
"yoga-session": "1545205597-3d9d02c29597",
|
|
7370
|
+
meditation: "1545389336-cf090694435e",
|
|
7371
|
+
"spa-day": "1540555700478-4be289fbecef",
|
|
7372
|
+
"couples-retreat": "1540555700478-4be289fbecef",
|
|
7373
|
+
"custom-experience": "1545389336-cf090694435e"
|
|
7374
|
+
};
|
|
7375
|
+
app.get("/img/*", (c) => {
|
|
7376
|
+
const path = c.req.path.replace(/^\/img\//, "").replace(/\.[a-z0-9]+$/i, "");
|
|
7377
|
+
const slug = path.split("/").pop() ?? "";
|
|
7378
|
+
const photoId = UNSPLASH_PHOTOS[slug];
|
|
7379
|
+
if (photoId) {
|
|
7380
|
+
return c.redirect(`https://images.unsplash.com/photo-${photoId}?w=600&h=600&fit=crop&auto=format&q=80`, 302);
|
|
7381
|
+
}
|
|
7382
|
+
const label = slug.replace(/[-_]+/g, " ").trim() || "product";
|
|
7383
|
+
let hash = 0;
|
|
7384
|
+
for (let i = 0; i < slug.length; i++) hash = hash * 31 + slug.charCodeAt(i) >>> 0;
|
|
7385
|
+
const hue = hash % 360;
|
|
7386
|
+
const display = label.length > 20 ? label.slice(0, 20) + "\u2026" : label;
|
|
7387
|
+
const svg = `<?xml version="1.0" encoding="UTF-8"?>
|
|
7388
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400">
|
|
7389
|
+
<defs>
|
|
7390
|
+
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
|
7391
|
+
<stop offset="0%" stop-color="hsl(${hue}, 65%, 65%)"/>
|
|
7392
|
+
<stop offset="100%" stop-color="hsl(${(hue + 40) % 360}, 70%, 45%)"/>
|
|
7393
|
+
</linearGradient>
|
|
7394
|
+
</defs>
|
|
7395
|
+
<rect width="400" height="400" fill="url(#g)"/>
|
|
7396
|
+
<text x="200" y="210" font-family="-apple-system, BlinkMacSystemFont, Inter, sans-serif" font-size="22" font-weight="600" fill="white" text-anchor="middle" dominant-baseline="middle" style="text-transform: capitalize">${display.replace(/[<>&]/g, "")}</text>
|
|
7397
|
+
</svg>`;
|
|
7398
|
+
return new Response(svg, {
|
|
7399
|
+
headers: {
|
|
7400
|
+
"Content-Type": "image/svg+xml; charset=utf-8",
|
|
7401
|
+
"Cache-Control": "public, max-age=3600",
|
|
7402
|
+
"Access-Control-Allow-Origin": "*"
|
|
7403
|
+
}
|
|
7404
|
+
});
|
|
7405
|
+
});
|
|
7231
7406
|
app.route("/api/v1", buildV1(deps));
|
|
7232
7407
|
app.route("/_mock", buildAdmin(deps));
|
|
7233
7408
|
app.route("/elements", buildElements(deps));
|