@cimplify/sdk 0.2.5 → 0.3.1
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/index.d.mts +510 -152
- package/dist/index.d.ts +510 -152
- package/dist/index.js +661 -251
- package/dist/index.mjs +648 -252
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -64,7 +64,91 @@ function isRetryableError(error) {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
// src/types/result.ts
|
|
68
|
+
function ok(value) {
|
|
69
|
+
return { ok: true, value };
|
|
70
|
+
}
|
|
71
|
+
function err(error) {
|
|
72
|
+
return { ok: false, error };
|
|
73
|
+
}
|
|
74
|
+
function isOk(result) {
|
|
75
|
+
return result.ok === true;
|
|
76
|
+
}
|
|
77
|
+
function isErr(result) {
|
|
78
|
+
return result.ok === false;
|
|
79
|
+
}
|
|
80
|
+
function mapResult(result, fn) {
|
|
81
|
+
return result.ok ? ok(fn(result.value)) : result;
|
|
82
|
+
}
|
|
83
|
+
function mapError(result, fn) {
|
|
84
|
+
return result.ok ? result : err(fn(result.error));
|
|
85
|
+
}
|
|
86
|
+
function flatMap(result, fn) {
|
|
87
|
+
return result.ok ? fn(result.value) : result;
|
|
88
|
+
}
|
|
89
|
+
function getOrElse(result, defaultFn) {
|
|
90
|
+
return result.ok ? result.value : defaultFn();
|
|
91
|
+
}
|
|
92
|
+
function unwrap(result) {
|
|
93
|
+
if (result.ok) {
|
|
94
|
+
return result.value;
|
|
95
|
+
}
|
|
96
|
+
throw result.error;
|
|
97
|
+
}
|
|
98
|
+
function toNullable(result) {
|
|
99
|
+
return result.ok ? result.value : void 0;
|
|
100
|
+
}
|
|
101
|
+
async function fromPromise(promise, mapError2) {
|
|
102
|
+
try {
|
|
103
|
+
const value = await promise;
|
|
104
|
+
return ok(value);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return err(mapError2(error));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function tryCatch(fn, mapError2) {
|
|
110
|
+
try {
|
|
111
|
+
return ok(fn());
|
|
112
|
+
} catch (error) {
|
|
113
|
+
return err(mapError2(error));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function combine(results) {
|
|
117
|
+
const values = [];
|
|
118
|
+
for (const result of results) {
|
|
119
|
+
if (!result.ok) {
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
values.push(result.value);
|
|
123
|
+
}
|
|
124
|
+
return ok(values);
|
|
125
|
+
}
|
|
126
|
+
function combineObject(results) {
|
|
127
|
+
const values = {};
|
|
128
|
+
for (const [key, result] of Object.entries(results)) {
|
|
129
|
+
if (!result.ok) {
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
values[key] = result.value;
|
|
133
|
+
}
|
|
134
|
+
return ok(values);
|
|
135
|
+
}
|
|
136
|
+
|
|
67
137
|
// src/catalogue.ts
|
|
138
|
+
function toCimplifyError(error) {
|
|
139
|
+
if (error instanceof CimplifyError) return error;
|
|
140
|
+
if (error instanceof Error) {
|
|
141
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
142
|
+
}
|
|
143
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
144
|
+
}
|
|
145
|
+
async function safe(promise) {
|
|
146
|
+
try {
|
|
147
|
+
return ok(await promise);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
return err(toCimplifyError(error));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
68
152
|
var CatalogueQueries = class {
|
|
69
153
|
constructor(client) {
|
|
70
154
|
this.client = client;
|
|
@@ -105,111 +189,125 @@ var CatalogueQueries = class {
|
|
|
105
189
|
if (options?.offset) {
|
|
106
190
|
query2 += `#offset(${options.offset})`;
|
|
107
191
|
}
|
|
108
|
-
return this.client.query(query2);
|
|
192
|
+
return safe(this.client.query(query2));
|
|
109
193
|
}
|
|
110
194
|
async getProduct(id) {
|
|
111
|
-
return this.client.query(`products.${id}`);
|
|
195
|
+
return safe(this.client.query(`products.${id}`));
|
|
112
196
|
}
|
|
113
197
|
async getProductBySlug(slug) {
|
|
114
|
-
const
|
|
115
|
-
`products[?(@.slug=='${slug}')]`
|
|
198
|
+
const result = await safe(
|
|
199
|
+
this.client.query(`products[?(@.slug=='${slug}')]`)
|
|
116
200
|
);
|
|
117
|
-
if (!
|
|
118
|
-
|
|
201
|
+
if (!result.ok) return result;
|
|
202
|
+
if (!result.value.length) {
|
|
203
|
+
return err(new CimplifyError("NOT_FOUND", `Product not found: ${slug}`, false));
|
|
119
204
|
}
|
|
120
|
-
return
|
|
205
|
+
return ok(result.value[0]);
|
|
121
206
|
}
|
|
122
207
|
// --------------------------------------------------------------------------
|
|
123
208
|
// VARIANTS
|
|
124
209
|
// --------------------------------------------------------------------------
|
|
125
210
|
async getVariants(productId) {
|
|
126
|
-
return this.client.query(`products.${productId}.variants`);
|
|
211
|
+
return safe(this.client.query(`products.${productId}.variants`));
|
|
127
212
|
}
|
|
128
213
|
async getVariantAxes(productId) {
|
|
129
|
-
return this.client.query(`products.${productId}.variant_axes`);
|
|
214
|
+
return safe(this.client.query(`products.${productId}.variant_axes`));
|
|
130
215
|
}
|
|
131
216
|
/**
|
|
132
217
|
* Find a variant by axis selections (e.g., { "Size": "Large", "Color": "Red" })
|
|
133
218
|
* Returns the matching variant or null if no match found.
|
|
134
219
|
*/
|
|
135
220
|
async getVariantByAxisSelections(productId, selections) {
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
221
|
+
return safe(
|
|
222
|
+
this.client.query(`products.${productId}.variant`, {
|
|
223
|
+
axis_selections: selections
|
|
224
|
+
})
|
|
225
|
+
);
|
|
139
226
|
}
|
|
140
227
|
/**
|
|
141
228
|
* Get a specific variant by its ID
|
|
142
229
|
*/
|
|
143
230
|
async getVariantById(productId, variantId) {
|
|
144
|
-
return this.client.query(`products.${productId}.variant.${variantId}`);
|
|
231
|
+
return safe(this.client.query(`products.${productId}.variant.${variantId}`));
|
|
145
232
|
}
|
|
146
233
|
// --------------------------------------------------------------------------
|
|
147
234
|
// ADD-ONS
|
|
148
235
|
// --------------------------------------------------------------------------
|
|
149
236
|
async getAddOns(productId) {
|
|
150
|
-
return this.client.query(`products.${productId}.add_ons`);
|
|
237
|
+
return safe(this.client.query(`products.${productId}.add_ons`));
|
|
151
238
|
}
|
|
152
239
|
// --------------------------------------------------------------------------
|
|
153
240
|
// CATEGORIES
|
|
154
241
|
// --------------------------------------------------------------------------
|
|
155
242
|
async getCategories() {
|
|
156
|
-
return this.client.query("categories");
|
|
243
|
+
return safe(this.client.query("categories"));
|
|
157
244
|
}
|
|
158
245
|
async getCategory(id) {
|
|
159
|
-
return this.client.query(`categories.${id}`);
|
|
246
|
+
return safe(this.client.query(`categories.${id}`));
|
|
160
247
|
}
|
|
161
248
|
async getCategoryBySlug(slug) {
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
249
|
+
const result = await safe(
|
|
250
|
+
this.client.query(`categories[?(@.slug=='${slug}')]`)
|
|
251
|
+
);
|
|
252
|
+
if (!result.ok) return result;
|
|
253
|
+
if (!result.value.length) {
|
|
254
|
+
return err(new CimplifyError("NOT_FOUND", `Category not found: ${slug}`, false));
|
|
165
255
|
}
|
|
166
|
-
return
|
|
256
|
+
return ok(result.value[0]);
|
|
167
257
|
}
|
|
168
258
|
async getCategoryProducts(categoryId) {
|
|
169
|
-
return this.client.query(`products[?(@.category_id=='${categoryId}')]`);
|
|
259
|
+
return safe(this.client.query(`products[?(@.category_id=='${categoryId}')]`));
|
|
170
260
|
}
|
|
171
261
|
// --------------------------------------------------------------------------
|
|
172
262
|
// COLLECTIONS
|
|
173
263
|
// --------------------------------------------------------------------------
|
|
174
264
|
async getCollections() {
|
|
175
|
-
return this.client.query("collections");
|
|
265
|
+
return safe(this.client.query("collections"));
|
|
176
266
|
}
|
|
177
267
|
async getCollection(id) {
|
|
178
|
-
return this.client.query(`collections.${id}`);
|
|
268
|
+
return safe(this.client.query(`collections.${id}`));
|
|
179
269
|
}
|
|
180
270
|
async getCollectionBySlug(slug) {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
271
|
+
const result = await safe(
|
|
272
|
+
this.client.query(`collections[?(@.slug=='${slug}')]`)
|
|
273
|
+
);
|
|
274
|
+
if (!result.ok) return result;
|
|
275
|
+
if (!result.value.length) {
|
|
276
|
+
return err(new CimplifyError("NOT_FOUND", `Collection not found: ${slug}`, false));
|
|
184
277
|
}
|
|
185
|
-
return
|
|
278
|
+
return ok(result.value[0]);
|
|
186
279
|
}
|
|
187
280
|
async getCollectionProducts(collectionId) {
|
|
188
|
-
return this.client.query(`collections.${collectionId}.products`);
|
|
281
|
+
return safe(this.client.query(`collections.${collectionId}.products`));
|
|
189
282
|
}
|
|
190
283
|
async searchCollections(query2, limit = 20) {
|
|
191
|
-
return
|
|
192
|
-
`collections[?(@.name contains '${query2}')]#limit(${limit})`
|
|
284
|
+
return safe(
|
|
285
|
+
this.client.query(`collections[?(@.name contains '${query2}')]#limit(${limit})`)
|
|
193
286
|
);
|
|
194
287
|
}
|
|
195
288
|
// --------------------------------------------------------------------------
|
|
196
289
|
// BUNDLES
|
|
197
290
|
// --------------------------------------------------------------------------
|
|
198
291
|
async getBundles() {
|
|
199
|
-
return this.client.query("bundles");
|
|
292
|
+
return safe(this.client.query("bundles"));
|
|
200
293
|
}
|
|
201
294
|
async getBundle(id) {
|
|
202
|
-
return this.client.query(`bundles.${id}`);
|
|
295
|
+
return safe(this.client.query(`bundles.${id}`));
|
|
203
296
|
}
|
|
204
297
|
async getBundleBySlug(slug) {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
298
|
+
const result = await safe(
|
|
299
|
+
this.client.query(`bundles[?(@.slug=='${slug}')]`)
|
|
300
|
+
);
|
|
301
|
+
if (!result.ok) return result;
|
|
302
|
+
if (!result.value.length) {
|
|
303
|
+
return err(new CimplifyError("NOT_FOUND", `Bundle not found: ${slug}`, false));
|
|
208
304
|
}
|
|
209
|
-
return
|
|
305
|
+
return ok(result.value[0]);
|
|
210
306
|
}
|
|
211
307
|
async searchBundles(query2, limit = 20) {
|
|
212
|
-
return
|
|
308
|
+
return safe(
|
|
309
|
+
this.client.query(`bundles[?(@.name contains '${query2}')]#limit(${limit})`)
|
|
310
|
+
);
|
|
213
311
|
}
|
|
214
312
|
// --------------------------------------------------------------------------
|
|
215
313
|
// COMPOSITES (Build-Your-Own)
|
|
@@ -219,20 +317,22 @@ var CatalogueQueries = class {
|
|
|
219
317
|
if (options?.limit) {
|
|
220
318
|
query2 += `#limit(${options.limit})`;
|
|
221
319
|
}
|
|
222
|
-
return this.client.query(query2);
|
|
320
|
+
return safe(this.client.query(query2));
|
|
223
321
|
}
|
|
224
322
|
async getComposite(id) {
|
|
225
|
-
return this.client.query(`composites.${id}`);
|
|
323
|
+
return safe(this.client.query(`composites.${id}`));
|
|
226
324
|
}
|
|
227
325
|
async getCompositeByProductId(productId) {
|
|
228
|
-
return this.client.query(`composites.by_product.${productId}`);
|
|
326
|
+
return safe(this.client.query(`composites.by_product.${productId}`));
|
|
229
327
|
}
|
|
230
328
|
async calculateCompositePrice(compositeId, selections, locationId) {
|
|
231
|
-
return
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
329
|
+
return safe(
|
|
330
|
+
this.client.call("composite.calculatePrice", {
|
|
331
|
+
composite_id: compositeId,
|
|
332
|
+
selections,
|
|
333
|
+
location_id: locationId
|
|
334
|
+
})
|
|
335
|
+
);
|
|
236
336
|
}
|
|
237
337
|
// --------------------------------------------------------------------------
|
|
238
338
|
// SEARCH
|
|
@@ -244,14 +344,16 @@ var CatalogueQueries = class {
|
|
|
244
344
|
searchQuery = `products[?(@.name contains '${query2}' && @.category_id=='${options.category}')]`;
|
|
245
345
|
}
|
|
246
346
|
searchQuery += `#limit(${limit})`;
|
|
247
|
-
return this.client.query(searchQuery);
|
|
347
|
+
return safe(this.client.query(searchQuery));
|
|
248
348
|
}
|
|
249
349
|
async searchProducts(query2, options) {
|
|
250
|
-
return
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
350
|
+
return safe(
|
|
351
|
+
this.client.call("catalogue.search", {
|
|
352
|
+
query: query2,
|
|
353
|
+
limit: options?.limit ?? 20,
|
|
354
|
+
category: options?.category
|
|
355
|
+
})
|
|
356
|
+
);
|
|
255
357
|
}
|
|
256
358
|
// --------------------------------------------------------------------------
|
|
257
359
|
// MENU (Restaurant-specific)
|
|
@@ -264,17 +366,31 @@ var CatalogueQueries = class {
|
|
|
264
366
|
if (options?.limit) {
|
|
265
367
|
query2 += `#limit(${options.limit})`;
|
|
266
368
|
}
|
|
267
|
-
return this.client.query(query2);
|
|
369
|
+
return safe(this.client.query(query2));
|
|
268
370
|
}
|
|
269
371
|
async getMenuCategory(categoryId) {
|
|
270
|
-
return this.client.query(`menu.category.${categoryId}`);
|
|
372
|
+
return safe(this.client.query(`menu.category.${categoryId}`));
|
|
271
373
|
}
|
|
272
374
|
async getMenuItem(itemId) {
|
|
273
|
-
return this.client.query(`menu.${itemId}`);
|
|
375
|
+
return safe(this.client.query(`menu.${itemId}`));
|
|
274
376
|
}
|
|
275
377
|
};
|
|
276
378
|
|
|
277
379
|
// src/cart.ts
|
|
380
|
+
function toCimplifyError2(error) {
|
|
381
|
+
if (error instanceof CimplifyError) return error;
|
|
382
|
+
if (error instanceof Error) {
|
|
383
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
384
|
+
}
|
|
385
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
386
|
+
}
|
|
387
|
+
async function safe2(promise) {
|
|
388
|
+
try {
|
|
389
|
+
return ok(await promise);
|
|
390
|
+
} catch (error) {
|
|
391
|
+
return err(toCimplifyError2(error));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
278
394
|
var CartOperations = class {
|
|
279
395
|
constructor(client) {
|
|
280
396
|
this.client = client;
|
|
@@ -287,23 +403,25 @@ var CartOperations = class {
|
|
|
287
403
|
* This is the main method for storefront display.
|
|
288
404
|
*/
|
|
289
405
|
async get() {
|
|
290
|
-
return this.client.query("cart#enriched");
|
|
406
|
+
return safe2(this.client.query("cart#enriched"));
|
|
291
407
|
}
|
|
292
408
|
async getRaw() {
|
|
293
|
-
return this.client.query("cart");
|
|
409
|
+
return safe2(this.client.query("cart"));
|
|
294
410
|
}
|
|
295
411
|
async getItems() {
|
|
296
|
-
return this.client.query("cart_items");
|
|
412
|
+
return safe2(this.client.query("cart_items"));
|
|
297
413
|
}
|
|
298
414
|
async getCount() {
|
|
299
|
-
return this.client.query("cart#count");
|
|
415
|
+
return safe2(this.client.query("cart#count"));
|
|
300
416
|
}
|
|
301
417
|
async getTotal() {
|
|
302
|
-
return this.client.query("cart#total");
|
|
418
|
+
return safe2(this.client.query("cart#total"));
|
|
303
419
|
}
|
|
304
420
|
async getSummary() {
|
|
305
|
-
const
|
|
306
|
-
return
|
|
421
|
+
const cartResult = await this.get();
|
|
422
|
+
if (!cartResult.ok) return cartResult;
|
|
423
|
+
const cart = cartResult.value;
|
|
424
|
+
return ok({
|
|
307
425
|
item_count: cart.items.length,
|
|
308
426
|
total_items: cart.items.reduce((sum, item) => sum + item.quantity, 0),
|
|
309
427
|
subtotal: cart.pricing.subtotal,
|
|
@@ -311,55 +429,89 @@ var CartOperations = class {
|
|
|
311
429
|
tax_amount: cart.pricing.tax_amount,
|
|
312
430
|
total: cart.pricing.total_price,
|
|
313
431
|
currency: cart.pricing.currency
|
|
314
|
-
};
|
|
432
|
+
});
|
|
315
433
|
}
|
|
316
434
|
// --------------------------------------------------------------------------
|
|
317
435
|
// CART MUTATIONS
|
|
318
436
|
// --------------------------------------------------------------------------
|
|
437
|
+
/**
|
|
438
|
+
* Add an item to the cart.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* const result = await client.cart.addItem({
|
|
443
|
+
* item_id: "prod_burger",
|
|
444
|
+
* quantity: 2,
|
|
445
|
+
* variant_id: "var_large",
|
|
446
|
+
* add_on_options: ["addon_cheese", "addon_bacon"],
|
|
447
|
+
* });
|
|
448
|
+
*
|
|
449
|
+
* if (!result.ok) {
|
|
450
|
+
* switch (result.error.code) {
|
|
451
|
+
* case ErrorCode.ITEM_UNAVAILABLE:
|
|
452
|
+
* toast.error("Item no longer available");
|
|
453
|
+
* break;
|
|
454
|
+
* case ErrorCode.VARIANT_OUT_OF_STOCK:
|
|
455
|
+
* toast.error("Selected option is out of stock");
|
|
456
|
+
* break;
|
|
457
|
+
* }
|
|
458
|
+
* }
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
319
461
|
async addItem(input) {
|
|
320
|
-
return this.client.call("cart.addItem", input);
|
|
462
|
+
return safe2(this.client.call("cart.addItem", input));
|
|
321
463
|
}
|
|
322
464
|
async updateItem(cartItemId, updates) {
|
|
323
|
-
return
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
465
|
+
return safe2(
|
|
466
|
+
this.client.call("cart.updateItem", {
|
|
467
|
+
cart_item_id: cartItemId,
|
|
468
|
+
...updates
|
|
469
|
+
})
|
|
470
|
+
);
|
|
327
471
|
}
|
|
328
472
|
async updateQuantity(cartItemId, quantity) {
|
|
329
|
-
return
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
473
|
+
return safe2(
|
|
474
|
+
this.client.call("cart.updateItemQuantity", {
|
|
475
|
+
cart_item_id: cartItemId,
|
|
476
|
+
quantity
|
|
477
|
+
})
|
|
478
|
+
);
|
|
333
479
|
}
|
|
334
480
|
async removeItem(cartItemId) {
|
|
335
|
-
return
|
|
336
|
-
|
|
337
|
-
|
|
481
|
+
return safe2(
|
|
482
|
+
this.client.call("cart.removeItem", {
|
|
483
|
+
cart_item_id: cartItemId
|
|
484
|
+
})
|
|
485
|
+
);
|
|
338
486
|
}
|
|
339
487
|
async clear() {
|
|
340
|
-
return this.client.call("cart.clearCart");
|
|
488
|
+
return safe2(this.client.call("cart.clearCart"));
|
|
341
489
|
}
|
|
342
490
|
// --------------------------------------------------------------------------
|
|
343
491
|
// COUPONS & DISCOUNTS
|
|
344
492
|
// --------------------------------------------------------------------------
|
|
345
493
|
async applyCoupon(code) {
|
|
346
|
-
return
|
|
347
|
-
|
|
348
|
-
|
|
494
|
+
return safe2(
|
|
495
|
+
this.client.call("cart.applyCoupon", {
|
|
496
|
+
coupon_code: code
|
|
497
|
+
})
|
|
498
|
+
);
|
|
349
499
|
}
|
|
350
500
|
async removeCoupon() {
|
|
351
|
-
return this.client.call("cart.removeCoupon");
|
|
501
|
+
return safe2(this.client.call("cart.removeCoupon"));
|
|
352
502
|
}
|
|
353
503
|
// --------------------------------------------------------------------------
|
|
354
504
|
// CONVENIENCE METHODS
|
|
355
505
|
// --------------------------------------------------------------------------
|
|
356
506
|
async isEmpty() {
|
|
357
|
-
const
|
|
358
|
-
|
|
507
|
+
const countResult = await this.getCount();
|
|
508
|
+
if (!countResult.ok) return countResult;
|
|
509
|
+
return ok(countResult.value === 0);
|
|
359
510
|
}
|
|
360
511
|
async hasItem(productId, variantId) {
|
|
361
|
-
const
|
|
362
|
-
|
|
512
|
+
const itemsResult = await this.getItems();
|
|
513
|
+
if (!itemsResult.ok) return itemsResult;
|
|
514
|
+
const found = itemsResult.value.some((item) => {
|
|
363
515
|
const matchesProduct = item.item_id === productId;
|
|
364
516
|
if (!variantId) return matchesProduct;
|
|
365
517
|
const config = item.configuration;
|
|
@@ -368,10 +520,12 @@ var CartOperations = class {
|
|
|
368
520
|
}
|
|
369
521
|
return matchesProduct;
|
|
370
522
|
});
|
|
523
|
+
return ok(found);
|
|
371
524
|
}
|
|
372
525
|
async findItem(productId, variantId) {
|
|
373
|
-
const
|
|
374
|
-
|
|
526
|
+
const itemsResult = await this.getItems();
|
|
527
|
+
if (!itemsResult.ok) return itemsResult;
|
|
528
|
+
const found = itemsResult.value.find((item) => {
|
|
375
529
|
const matchesProduct = item.item_id === productId;
|
|
376
530
|
if (!variantId) return matchesProduct;
|
|
377
531
|
const config = item.configuration;
|
|
@@ -380,6 +534,7 @@ var CartOperations = class {
|
|
|
380
534
|
}
|
|
381
535
|
return matchesProduct;
|
|
382
536
|
});
|
|
537
|
+
return ok(found);
|
|
383
538
|
}
|
|
384
539
|
};
|
|
385
540
|
|
|
@@ -474,41 +629,106 @@ var DEFAULT_CURRENCY = "GHS";
|
|
|
474
629
|
var DEFAULT_COUNTRY = "GHA";
|
|
475
630
|
|
|
476
631
|
// src/checkout.ts
|
|
632
|
+
function toCimplifyError3(error) {
|
|
633
|
+
if (error instanceof CimplifyError) return error;
|
|
634
|
+
if (error instanceof Error) {
|
|
635
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
636
|
+
}
|
|
637
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
638
|
+
}
|
|
639
|
+
async function safe3(promise) {
|
|
640
|
+
try {
|
|
641
|
+
return ok(await promise);
|
|
642
|
+
} catch (error) {
|
|
643
|
+
return err(toCimplifyError3(error));
|
|
644
|
+
}
|
|
645
|
+
}
|
|
477
646
|
var CheckoutService = class {
|
|
478
647
|
constructor(client) {
|
|
479
648
|
this.client = client;
|
|
480
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* Process checkout with cart data.
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* ```typescript
|
|
655
|
+
* const result = await client.checkout.process({
|
|
656
|
+
* cart_id: cart.id,
|
|
657
|
+
* customer: { name, email, phone, save_details: true },
|
|
658
|
+
* order_type: "pickup",
|
|
659
|
+
* payment_method: "mobile_money",
|
|
660
|
+
* mobile_money_details: { phone_number, provider: "mtn" },
|
|
661
|
+
* });
|
|
662
|
+
*
|
|
663
|
+
* if (!result.ok) {
|
|
664
|
+
* switch (result.error.code) {
|
|
665
|
+
* case ErrorCode.CART_EMPTY:
|
|
666
|
+
* toast.error("Your cart is empty");
|
|
667
|
+
* break;
|
|
668
|
+
* case ErrorCode.PAYMENT_FAILED:
|
|
669
|
+
* toast.error("Payment failed. Please try again.");
|
|
670
|
+
* break;
|
|
671
|
+
* }
|
|
672
|
+
* }
|
|
673
|
+
* ```
|
|
674
|
+
*/
|
|
481
675
|
async process(data) {
|
|
482
|
-
return
|
|
483
|
-
|
|
484
|
-
|
|
676
|
+
return safe3(
|
|
677
|
+
this.client.call(CHECKOUT_MUTATION.PROCESS, {
|
|
678
|
+
checkout_data: data
|
|
679
|
+
})
|
|
680
|
+
);
|
|
485
681
|
}
|
|
486
682
|
async initializePayment(orderId, method) {
|
|
487
|
-
return
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
683
|
+
return safe3(
|
|
684
|
+
this.client.call("order.initializePayment", {
|
|
685
|
+
order_id: orderId,
|
|
686
|
+
payment_method: method
|
|
687
|
+
})
|
|
688
|
+
);
|
|
491
689
|
}
|
|
492
690
|
async submitAuthorization(input) {
|
|
493
|
-
return
|
|
691
|
+
return safe3(
|
|
692
|
+
this.client.call(PAYMENT_MUTATION.SUBMIT_AUTHORIZATION, input)
|
|
693
|
+
);
|
|
494
694
|
}
|
|
495
695
|
async pollPaymentStatus(orderId) {
|
|
496
|
-
return
|
|
696
|
+
return safe3(
|
|
697
|
+
this.client.call(PAYMENT_MUTATION.CHECK_STATUS, orderId)
|
|
698
|
+
);
|
|
497
699
|
}
|
|
498
700
|
async updateOrderCustomer(orderId, customer) {
|
|
499
|
-
return
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
701
|
+
return safe3(
|
|
702
|
+
this.client.call(ORDER_MUTATION.UPDATE_CUSTOMER, {
|
|
703
|
+
order_id: orderId,
|
|
704
|
+
...customer
|
|
705
|
+
})
|
|
706
|
+
);
|
|
503
707
|
}
|
|
504
708
|
async verifyPayment(orderId) {
|
|
505
|
-
return
|
|
506
|
-
|
|
507
|
-
|
|
709
|
+
return safe3(
|
|
710
|
+
this.client.call("order.verifyPayment", {
|
|
711
|
+
order_id: orderId
|
|
712
|
+
})
|
|
713
|
+
);
|
|
508
714
|
}
|
|
509
715
|
};
|
|
510
716
|
|
|
511
717
|
// src/orders.ts
|
|
718
|
+
function toCimplifyError4(error) {
|
|
719
|
+
if (error instanceof CimplifyError) return error;
|
|
720
|
+
if (error instanceof Error) {
|
|
721
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
722
|
+
}
|
|
723
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
724
|
+
}
|
|
725
|
+
async function safe4(promise) {
|
|
726
|
+
try {
|
|
727
|
+
return ok(await promise);
|
|
728
|
+
} catch (error) {
|
|
729
|
+
return err(toCimplifyError4(error));
|
|
730
|
+
}
|
|
731
|
+
}
|
|
512
732
|
var OrderQueries = class {
|
|
513
733
|
constructor(client) {
|
|
514
734
|
this.client = client;
|
|
@@ -525,141 +745,213 @@ var OrderQueries = class {
|
|
|
525
745
|
if (options?.offset) {
|
|
526
746
|
query2 += `#offset(${options.offset})`;
|
|
527
747
|
}
|
|
528
|
-
return this.client.query(query2);
|
|
748
|
+
return safe4(this.client.query(query2));
|
|
529
749
|
}
|
|
530
750
|
async get(orderId) {
|
|
531
|
-
return this.client.query(`orders.${orderId}`);
|
|
751
|
+
return safe4(this.client.query(`orders.${orderId}`));
|
|
532
752
|
}
|
|
533
753
|
async getRecent(limit = 5) {
|
|
534
|
-
return this.client.query(`orders#sort(created_at,desc)#limit(${limit})`);
|
|
754
|
+
return safe4(this.client.query(`orders#sort(created_at,desc)#limit(${limit})`));
|
|
535
755
|
}
|
|
536
756
|
async getByStatus(status) {
|
|
537
|
-
return this.client.query(`orders[?(@.status=='${status}')]`);
|
|
757
|
+
return safe4(this.client.query(`orders[?(@.status=='${status}')]`));
|
|
538
758
|
}
|
|
539
759
|
async cancel(orderId, reason) {
|
|
540
|
-
return
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
760
|
+
return safe4(
|
|
761
|
+
this.client.call("order.cancelOrder", {
|
|
762
|
+
order_id: orderId,
|
|
763
|
+
reason
|
|
764
|
+
})
|
|
765
|
+
);
|
|
544
766
|
}
|
|
545
767
|
};
|
|
546
768
|
|
|
547
769
|
// src/link.ts
|
|
770
|
+
function toCimplifyError5(error) {
|
|
771
|
+
if (error instanceof CimplifyError) return error;
|
|
772
|
+
if (error instanceof Error) {
|
|
773
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
774
|
+
}
|
|
775
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
776
|
+
}
|
|
777
|
+
async function safe5(promise) {
|
|
778
|
+
try {
|
|
779
|
+
return ok(await promise);
|
|
780
|
+
} catch (error) {
|
|
781
|
+
return err(toCimplifyError5(error));
|
|
782
|
+
}
|
|
783
|
+
}
|
|
548
784
|
var LinkService = class {
|
|
549
785
|
constructor(client) {
|
|
550
786
|
this.client = client;
|
|
551
787
|
}
|
|
788
|
+
// --------------------------------------------------------------------------
|
|
789
|
+
// AUTHENTICATION
|
|
790
|
+
// --------------------------------------------------------------------------
|
|
552
791
|
async requestOtp(input) {
|
|
553
|
-
return this.client.linkPost("/v1/link/auth/request-otp", input);
|
|
792
|
+
return safe5(this.client.linkPost("/v1/link/auth/request-otp", input));
|
|
554
793
|
}
|
|
555
794
|
async verifyOtp(input) {
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
|
|
795
|
+
const result = await safe5(
|
|
796
|
+
this.client.linkPost("/v1/link/auth/verify-otp", input)
|
|
797
|
+
);
|
|
798
|
+
if (result.ok && result.value.session_token) {
|
|
799
|
+
this.client.setSessionToken(result.value.session_token);
|
|
559
800
|
}
|
|
560
|
-
return
|
|
801
|
+
return result;
|
|
561
802
|
}
|
|
562
803
|
async logout() {
|
|
563
|
-
const result = await this.client.linkPost("/v1/link/auth/logout");
|
|
564
|
-
|
|
804
|
+
const result = await safe5(this.client.linkPost("/v1/link/auth/logout"));
|
|
805
|
+
if (result.ok) {
|
|
806
|
+
this.client.clearSession();
|
|
807
|
+
}
|
|
565
808
|
return result;
|
|
566
809
|
}
|
|
810
|
+
// --------------------------------------------------------------------------
|
|
811
|
+
// STATUS & DATA
|
|
812
|
+
// --------------------------------------------------------------------------
|
|
567
813
|
async checkStatus(contact) {
|
|
568
|
-
return
|
|
569
|
-
|
|
570
|
-
|
|
814
|
+
return safe5(
|
|
815
|
+
this.client.call(LINK_MUTATION.CHECK_STATUS, {
|
|
816
|
+
contact
|
|
817
|
+
})
|
|
818
|
+
);
|
|
571
819
|
}
|
|
572
820
|
async getLinkData() {
|
|
573
|
-
return this.client.query(LINK_QUERY.DATA);
|
|
821
|
+
return safe5(this.client.query(LINK_QUERY.DATA));
|
|
574
822
|
}
|
|
575
823
|
async getAddresses() {
|
|
576
|
-
return this.client.query(LINK_QUERY.ADDRESSES);
|
|
824
|
+
return safe5(this.client.query(LINK_QUERY.ADDRESSES));
|
|
577
825
|
}
|
|
578
826
|
async getMobileMoney() {
|
|
579
|
-
return this.client.query(LINK_QUERY.MOBILE_MONEY);
|
|
827
|
+
return safe5(this.client.query(LINK_QUERY.MOBILE_MONEY));
|
|
580
828
|
}
|
|
581
829
|
async getPreferences() {
|
|
582
|
-
return this.client.query(LINK_QUERY.PREFERENCES);
|
|
830
|
+
return safe5(this.client.query(LINK_QUERY.PREFERENCES));
|
|
583
831
|
}
|
|
832
|
+
// --------------------------------------------------------------------------
|
|
833
|
+
// ENROLLMENT
|
|
834
|
+
// --------------------------------------------------------------------------
|
|
584
835
|
async enroll(data) {
|
|
585
|
-
return this.client.call(LINK_MUTATION.ENROLL, data);
|
|
836
|
+
return safe5(this.client.call(LINK_MUTATION.ENROLL, data));
|
|
586
837
|
}
|
|
587
838
|
async enrollAndLinkOrder(data) {
|
|
588
|
-
return
|
|
839
|
+
return safe5(
|
|
840
|
+
this.client.call(LINK_MUTATION.ENROLL_AND_LINK_ORDER, data)
|
|
841
|
+
);
|
|
589
842
|
}
|
|
843
|
+
// --------------------------------------------------------------------------
|
|
844
|
+
// PREFERENCES
|
|
845
|
+
// --------------------------------------------------------------------------
|
|
590
846
|
async updatePreferences(preferences) {
|
|
591
|
-
return this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences);
|
|
847
|
+
return safe5(this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences));
|
|
592
848
|
}
|
|
849
|
+
// --------------------------------------------------------------------------
|
|
850
|
+
// ADDRESSES
|
|
851
|
+
// --------------------------------------------------------------------------
|
|
593
852
|
async createAddress(input) {
|
|
594
|
-
return this.client.call(LINK_MUTATION.CREATE_ADDRESS, input);
|
|
853
|
+
return safe5(this.client.call(LINK_MUTATION.CREATE_ADDRESS, input));
|
|
595
854
|
}
|
|
596
855
|
async updateAddress(input) {
|
|
597
|
-
return this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input);
|
|
856
|
+
return safe5(this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input));
|
|
598
857
|
}
|
|
599
858
|
async deleteAddress(addressId) {
|
|
600
|
-
return this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId);
|
|
859
|
+
return safe5(this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId));
|
|
601
860
|
}
|
|
602
861
|
async setDefaultAddress(addressId) {
|
|
603
|
-
return this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId);
|
|
862
|
+
return safe5(this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId));
|
|
604
863
|
}
|
|
605
864
|
async trackAddressUsage(addressId) {
|
|
606
|
-
return
|
|
607
|
-
|
|
608
|
-
|
|
865
|
+
return safe5(
|
|
866
|
+
this.client.call(LINK_MUTATION.TRACK_ADDRESS_USAGE, {
|
|
867
|
+
address_id: addressId
|
|
868
|
+
})
|
|
869
|
+
);
|
|
609
870
|
}
|
|
871
|
+
// --------------------------------------------------------------------------
|
|
872
|
+
// MOBILE MONEY
|
|
873
|
+
// --------------------------------------------------------------------------
|
|
610
874
|
async createMobileMoney(input) {
|
|
611
|
-
return this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input);
|
|
875
|
+
return safe5(this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input));
|
|
612
876
|
}
|
|
613
877
|
async deleteMobileMoney(mobileMoneyId) {
|
|
614
|
-
return this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId);
|
|
878
|
+
return safe5(this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId));
|
|
615
879
|
}
|
|
616
880
|
async setDefaultMobileMoney(mobileMoneyId) {
|
|
617
|
-
return
|
|
881
|
+
return safe5(
|
|
882
|
+
this.client.call(LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY, mobileMoneyId)
|
|
883
|
+
);
|
|
618
884
|
}
|
|
619
885
|
async trackMobileMoneyUsage(mobileMoneyId) {
|
|
620
|
-
return
|
|
621
|
-
|
|
622
|
-
|
|
886
|
+
return safe5(
|
|
887
|
+
this.client.call(LINK_MUTATION.TRACK_MOBILE_MONEY_USAGE, {
|
|
888
|
+
mobile_money_id: mobileMoneyId
|
|
889
|
+
})
|
|
890
|
+
);
|
|
623
891
|
}
|
|
624
892
|
async verifyMobileMoney(mobileMoneyId) {
|
|
625
|
-
return
|
|
893
|
+
return safe5(
|
|
894
|
+
this.client.call(LINK_MUTATION.VERIFY_MOBILE_MONEY, mobileMoneyId)
|
|
895
|
+
);
|
|
626
896
|
}
|
|
897
|
+
// --------------------------------------------------------------------------
|
|
898
|
+
// SESSIONS
|
|
899
|
+
// --------------------------------------------------------------------------
|
|
627
900
|
async getSessions() {
|
|
628
|
-
return this.client.linkGet("/v1/link/sessions");
|
|
901
|
+
return safe5(this.client.linkGet("/v1/link/sessions"));
|
|
629
902
|
}
|
|
630
903
|
async revokeSession(sessionId) {
|
|
631
|
-
return this.client.linkDelete(`/v1/link/sessions/${sessionId}`);
|
|
904
|
+
return safe5(this.client.linkDelete(`/v1/link/sessions/${sessionId}`));
|
|
632
905
|
}
|
|
633
906
|
async revokeAllSessions() {
|
|
634
|
-
return this.client.linkDelete("/v1/link/sessions");
|
|
907
|
+
return safe5(this.client.linkDelete("/v1/link/sessions"));
|
|
635
908
|
}
|
|
909
|
+
// --------------------------------------------------------------------------
|
|
910
|
+
// REST ALTERNATIVES (for direct API access)
|
|
911
|
+
// --------------------------------------------------------------------------
|
|
636
912
|
async getAddressesRest() {
|
|
637
|
-
return this.client.linkGet("/v1/link/addresses");
|
|
913
|
+
return safe5(this.client.linkGet("/v1/link/addresses"));
|
|
638
914
|
}
|
|
639
915
|
async createAddressRest(input) {
|
|
640
|
-
return this.client.linkPost("/v1/link/addresses", input);
|
|
916
|
+
return safe5(this.client.linkPost("/v1/link/addresses", input));
|
|
641
917
|
}
|
|
642
918
|
async deleteAddressRest(addressId) {
|
|
643
|
-
return this.client.linkDelete(`/v1/link/addresses/${addressId}`);
|
|
919
|
+
return safe5(this.client.linkDelete(`/v1/link/addresses/${addressId}`));
|
|
644
920
|
}
|
|
645
921
|
async setDefaultAddressRest(addressId) {
|
|
646
|
-
return this.client.linkPost(`/v1/link/addresses/${addressId}/default`);
|
|
922
|
+
return safe5(this.client.linkPost(`/v1/link/addresses/${addressId}/default`));
|
|
647
923
|
}
|
|
648
924
|
async getMobileMoneyRest() {
|
|
649
|
-
return this.client.linkGet("/v1/link/mobile-money");
|
|
925
|
+
return safe5(this.client.linkGet("/v1/link/mobile-money"));
|
|
650
926
|
}
|
|
651
927
|
async createMobileMoneyRest(input) {
|
|
652
|
-
return this.client.linkPost("/v1/link/mobile-money", input);
|
|
928
|
+
return safe5(this.client.linkPost("/v1/link/mobile-money", input));
|
|
653
929
|
}
|
|
654
930
|
async deleteMobileMoneyRest(mobileMoneyId) {
|
|
655
|
-
return this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`);
|
|
931
|
+
return safe5(this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`));
|
|
656
932
|
}
|
|
657
933
|
async setDefaultMobileMoneyRest(mobileMoneyId) {
|
|
658
|
-
return
|
|
934
|
+
return safe5(
|
|
935
|
+
this.client.linkPost(`/v1/link/mobile-money/${mobileMoneyId}/default`)
|
|
936
|
+
);
|
|
659
937
|
}
|
|
660
938
|
};
|
|
661
939
|
|
|
662
940
|
// src/auth.ts
|
|
941
|
+
function toCimplifyError6(error) {
|
|
942
|
+
if (error instanceof CimplifyError) return error;
|
|
943
|
+
if (error instanceof Error) {
|
|
944
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
945
|
+
}
|
|
946
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
947
|
+
}
|
|
948
|
+
async function safe6(promise) {
|
|
949
|
+
try {
|
|
950
|
+
return ok(await promise);
|
|
951
|
+
} catch (error) {
|
|
952
|
+
return err(toCimplifyError6(error));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
663
955
|
var AuthService = class {
|
|
664
956
|
constructor(client) {
|
|
665
957
|
this.client = client;
|
|
@@ -668,52 +960,72 @@ var AuthService = class {
|
|
|
668
960
|
// STATUS & USER
|
|
669
961
|
// --------------------------------------------------------------------------
|
|
670
962
|
async getStatus() {
|
|
671
|
-
return this.client.query("auth");
|
|
963
|
+
return safe6(this.client.query("auth"));
|
|
672
964
|
}
|
|
673
965
|
async getCurrentUser() {
|
|
674
|
-
const
|
|
675
|
-
|
|
966
|
+
const result = await this.getStatus();
|
|
967
|
+
if (!result.ok) return result;
|
|
968
|
+
return ok(result.value.customer || null);
|
|
676
969
|
}
|
|
677
970
|
async isAuthenticated() {
|
|
678
|
-
const
|
|
679
|
-
return
|
|
971
|
+
const result = await this.getStatus();
|
|
972
|
+
if (!result.ok) return result;
|
|
973
|
+
return ok(result.value.is_authenticated);
|
|
680
974
|
}
|
|
681
975
|
// --------------------------------------------------------------------------
|
|
682
976
|
// OTP AUTHENTICATION
|
|
683
977
|
// --------------------------------------------------------------------------
|
|
684
978
|
async requestOtp(contact, contactType) {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
979
|
+
return safe6(
|
|
980
|
+
this.client.call(AUTH_MUTATION.REQUEST_OTP, {
|
|
981
|
+
contact,
|
|
982
|
+
contact_type: contactType
|
|
983
|
+
})
|
|
984
|
+
);
|
|
689
985
|
}
|
|
690
986
|
async verifyOtp(code, contact) {
|
|
691
|
-
return
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
987
|
+
return safe6(
|
|
988
|
+
this.client.call(AUTH_MUTATION.VERIFY_OTP, {
|
|
989
|
+
otp_code: code,
|
|
990
|
+
contact
|
|
991
|
+
})
|
|
992
|
+
);
|
|
695
993
|
}
|
|
696
994
|
// --------------------------------------------------------------------------
|
|
697
995
|
// SESSION MANAGEMENT
|
|
698
996
|
// --------------------------------------------------------------------------
|
|
699
997
|
async logout() {
|
|
700
|
-
return this.client.call("auth.logout");
|
|
998
|
+
return safe6(this.client.call("auth.logout"));
|
|
701
999
|
}
|
|
702
1000
|
// --------------------------------------------------------------------------
|
|
703
1001
|
// PROFILE MANAGEMENT
|
|
704
1002
|
// --------------------------------------------------------------------------
|
|
705
1003
|
async updateProfile(input) {
|
|
706
|
-
return this.client.call("auth.update_profile", input);
|
|
1004
|
+
return safe6(this.client.call("auth.update_profile", input));
|
|
707
1005
|
}
|
|
708
1006
|
async changePassword(input) {
|
|
709
|
-
return this.client.call("auth.change_password", input);
|
|
1007
|
+
return safe6(this.client.call("auth.change_password", input));
|
|
710
1008
|
}
|
|
711
1009
|
async resetPassword(email) {
|
|
712
|
-
return this.client.call("auth.reset_password", { email });
|
|
1010
|
+
return safe6(this.client.call("auth.reset_password", { email }));
|
|
713
1011
|
}
|
|
714
1012
|
};
|
|
715
1013
|
|
|
716
1014
|
// src/business.ts
|
|
1015
|
+
function toCimplifyError7(error) {
|
|
1016
|
+
if (error instanceof CimplifyError) return error;
|
|
1017
|
+
if (error instanceof Error) {
|
|
1018
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
1019
|
+
}
|
|
1020
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
1021
|
+
}
|
|
1022
|
+
async function safe7(promise) {
|
|
1023
|
+
try {
|
|
1024
|
+
return ok(await promise);
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
return err(toCimplifyError7(error));
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
717
1029
|
var BusinessService = class {
|
|
718
1030
|
constructor(client) {
|
|
719
1031
|
this.client = client;
|
|
@@ -722,49 +1034,55 @@ var BusinessService = class {
|
|
|
722
1034
|
// BUSINESS INFO
|
|
723
1035
|
// --------------------------------------------------------------------------
|
|
724
1036
|
async getInfo() {
|
|
725
|
-
return this.client.query("business.info");
|
|
1037
|
+
return safe7(this.client.query("business.info"));
|
|
726
1038
|
}
|
|
727
1039
|
async getByHandle(handle) {
|
|
728
|
-
return this.client.query(`business.handle.${handle}`);
|
|
1040
|
+
return safe7(this.client.query(`business.handle.${handle}`));
|
|
729
1041
|
}
|
|
730
1042
|
async getByDomain(domain) {
|
|
731
|
-
return this.client.query("business.domain", { domain });
|
|
1043
|
+
return safe7(this.client.query("business.domain", { domain }));
|
|
732
1044
|
}
|
|
733
1045
|
async getSettings() {
|
|
734
|
-
return this.client.query("business.settings");
|
|
1046
|
+
return safe7(this.client.query("business.settings"));
|
|
735
1047
|
}
|
|
736
1048
|
async getTheme() {
|
|
737
|
-
return this.client.query("business.theme");
|
|
1049
|
+
return safe7(this.client.query("business.theme"));
|
|
738
1050
|
}
|
|
739
1051
|
// --------------------------------------------------------------------------
|
|
740
1052
|
// LOCATIONS
|
|
741
1053
|
// --------------------------------------------------------------------------
|
|
742
1054
|
async getLocations() {
|
|
743
|
-
return this.client.query("business.locations");
|
|
1055
|
+
return safe7(this.client.query("business.locations"));
|
|
744
1056
|
}
|
|
745
1057
|
async getLocation(locationId) {
|
|
746
|
-
return this.client.query(`business.locations.${locationId}`);
|
|
1058
|
+
return safe7(this.client.query(`business.locations.${locationId}`));
|
|
747
1059
|
}
|
|
748
1060
|
// --------------------------------------------------------------------------
|
|
749
1061
|
// HOURS
|
|
750
1062
|
// --------------------------------------------------------------------------
|
|
751
1063
|
async getHours() {
|
|
752
|
-
return this.client.query("business.hours");
|
|
1064
|
+
return safe7(this.client.query("business.hours"));
|
|
753
1065
|
}
|
|
754
1066
|
async getLocationHours(locationId) {
|
|
755
|
-
return this.client.query(`business.locations.${locationId}.hours`);
|
|
1067
|
+
return safe7(this.client.query(`business.locations.${locationId}.hours`));
|
|
756
1068
|
}
|
|
757
1069
|
// --------------------------------------------------------------------------
|
|
758
1070
|
// BOOTSTRAP (for storefront initialization)
|
|
759
1071
|
// --------------------------------------------------------------------------
|
|
760
1072
|
async getBootstrap() {
|
|
761
|
-
const [
|
|
1073
|
+
const [businessResult, locationsResult, categoriesResult] = await Promise.all([
|
|
762
1074
|
this.getInfo(),
|
|
763
1075
|
this.getLocations(),
|
|
764
|
-
this.client.query("categories#select(id,name,slug)")
|
|
1076
|
+
safe7(this.client.query("categories#select(id,name,slug)"))
|
|
765
1077
|
]);
|
|
1078
|
+
if (!businessResult.ok) return businessResult;
|
|
1079
|
+
if (!locationsResult.ok) return locationsResult;
|
|
1080
|
+
if (!categoriesResult.ok) return categoriesResult;
|
|
1081
|
+
const business = businessResult.value;
|
|
1082
|
+
const locations = locationsResult.value;
|
|
1083
|
+
const categories = categoriesResult.value;
|
|
766
1084
|
const defaultLocation = locations[0];
|
|
767
|
-
return {
|
|
1085
|
+
return ok({
|
|
768
1086
|
business,
|
|
769
1087
|
location: defaultLocation,
|
|
770
1088
|
locations,
|
|
@@ -772,11 +1090,25 @@ var BusinessService = class {
|
|
|
772
1090
|
currency: business.default_currency,
|
|
773
1091
|
is_open: defaultLocation?.accepts_online_orders ?? false,
|
|
774
1092
|
accepts_orders: defaultLocation?.accepts_online_orders ?? false
|
|
775
|
-
};
|
|
1093
|
+
});
|
|
776
1094
|
}
|
|
777
1095
|
};
|
|
778
1096
|
|
|
779
1097
|
// src/inventory.ts
|
|
1098
|
+
function toCimplifyError8(error) {
|
|
1099
|
+
if (error instanceof CimplifyError) return error;
|
|
1100
|
+
if (error instanceof Error) {
|
|
1101
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
1102
|
+
}
|
|
1103
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
1104
|
+
}
|
|
1105
|
+
async function safe8(promise) {
|
|
1106
|
+
try {
|
|
1107
|
+
return ok(await promise);
|
|
1108
|
+
} catch (error) {
|
|
1109
|
+
return err(toCimplifyError8(error));
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
780
1112
|
var InventoryService = class {
|
|
781
1113
|
constructor(client) {
|
|
782
1114
|
this.client = client;
|
|
@@ -785,41 +1117,51 @@ var InventoryService = class {
|
|
|
785
1117
|
// STOCK QUERIES
|
|
786
1118
|
// --------------------------------------------------------------------------
|
|
787
1119
|
async getStockLevels() {
|
|
788
|
-
return this.client.query("inventory.stock_levels");
|
|
1120
|
+
return safe8(this.client.query("inventory.stock_levels"));
|
|
789
1121
|
}
|
|
790
1122
|
async getProductStock(productId, locationId) {
|
|
791
1123
|
if (locationId) {
|
|
792
|
-
return
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
1124
|
+
return safe8(
|
|
1125
|
+
this.client.query("inventory.product", {
|
|
1126
|
+
product_id: productId,
|
|
1127
|
+
location_id: locationId
|
|
1128
|
+
})
|
|
1129
|
+
);
|
|
796
1130
|
}
|
|
797
|
-
return
|
|
798
|
-
|
|
799
|
-
|
|
1131
|
+
return safe8(
|
|
1132
|
+
this.client.query("inventory.product", {
|
|
1133
|
+
product_id: productId
|
|
1134
|
+
})
|
|
1135
|
+
);
|
|
800
1136
|
}
|
|
801
1137
|
async getVariantStock(variantId, locationId) {
|
|
802
|
-
return
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1138
|
+
return safe8(
|
|
1139
|
+
this.client.query("inventory.variant", {
|
|
1140
|
+
variant_id: variantId,
|
|
1141
|
+
location_id: locationId
|
|
1142
|
+
})
|
|
1143
|
+
);
|
|
806
1144
|
}
|
|
807
1145
|
// --------------------------------------------------------------------------
|
|
808
1146
|
// AVAILABILITY CHECKS
|
|
809
1147
|
// --------------------------------------------------------------------------
|
|
810
1148
|
async checkProductAvailability(productId, quantity, locationId) {
|
|
811
|
-
return
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
1149
|
+
return safe8(
|
|
1150
|
+
this.client.query("inventory.check_availability", {
|
|
1151
|
+
product_id: productId,
|
|
1152
|
+
quantity,
|
|
1153
|
+
location_id: locationId
|
|
1154
|
+
})
|
|
1155
|
+
);
|
|
816
1156
|
}
|
|
817
1157
|
async checkVariantAvailability(variantId, quantity, locationId) {
|
|
818
|
-
return
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1158
|
+
return safe8(
|
|
1159
|
+
this.client.query("inventory.check_availability", {
|
|
1160
|
+
variant_id: variantId,
|
|
1161
|
+
quantity,
|
|
1162
|
+
location_id: locationId
|
|
1163
|
+
})
|
|
1164
|
+
);
|
|
823
1165
|
}
|
|
824
1166
|
async checkMultipleAvailability(items, locationId) {
|
|
825
1167
|
const results = await Promise.all(
|
|
@@ -827,28 +1169,47 @@ var InventoryService = class {
|
|
|
827
1169
|
(item) => item.variant_id ? this.checkVariantAvailability(item.variant_id, item.quantity, locationId) : this.checkProductAvailability(item.product_id, item.quantity, locationId)
|
|
828
1170
|
)
|
|
829
1171
|
);
|
|
830
|
-
|
|
1172
|
+
for (const result of results) {
|
|
1173
|
+
if (!result.ok) return result;
|
|
1174
|
+
}
|
|
1175
|
+
return ok(results.map((r) => r.value));
|
|
831
1176
|
}
|
|
832
1177
|
// --------------------------------------------------------------------------
|
|
833
1178
|
// SUMMARY
|
|
834
1179
|
// --------------------------------------------------------------------------
|
|
835
1180
|
async getSummary() {
|
|
836
|
-
return this.client.query("inventory.summary");
|
|
1181
|
+
return safe8(this.client.query("inventory.summary"));
|
|
837
1182
|
}
|
|
838
1183
|
// --------------------------------------------------------------------------
|
|
839
1184
|
// CONVENIENCE METHODS
|
|
840
1185
|
// --------------------------------------------------------------------------
|
|
841
1186
|
async isInStock(productId, locationId) {
|
|
842
1187
|
const result = await this.checkProductAvailability(productId, 1, locationId);
|
|
843
|
-
return result
|
|
1188
|
+
if (!result.ok) return result;
|
|
1189
|
+
return ok(result.value.is_available);
|
|
844
1190
|
}
|
|
845
1191
|
async getAvailableQuantity(productId, locationId) {
|
|
846
|
-
const
|
|
847
|
-
return
|
|
1192
|
+
const result = await this.getProductStock(productId, locationId);
|
|
1193
|
+
if (!result.ok) return result;
|
|
1194
|
+
return ok(result.value.available_quantity);
|
|
848
1195
|
}
|
|
849
1196
|
};
|
|
850
1197
|
|
|
851
1198
|
// src/scheduling.ts
|
|
1199
|
+
function toCimplifyError9(error) {
|
|
1200
|
+
if (error instanceof CimplifyError) return error;
|
|
1201
|
+
if (error instanceof Error) {
|
|
1202
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
1203
|
+
}
|
|
1204
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
1205
|
+
}
|
|
1206
|
+
async function safe9(promise) {
|
|
1207
|
+
try {
|
|
1208
|
+
return ok(await promise);
|
|
1209
|
+
} catch (error) {
|
|
1210
|
+
return err(toCimplifyError9(error));
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
852
1213
|
var SchedulingService = class {
|
|
853
1214
|
constructor(client) {
|
|
854
1215
|
this.client = client;
|
|
@@ -857,86 +1218,113 @@ var SchedulingService = class {
|
|
|
857
1218
|
// SERVICES
|
|
858
1219
|
// --------------------------------------------------------------------------
|
|
859
1220
|
async getServices() {
|
|
860
|
-
return this.client.query("scheduling.services");
|
|
1221
|
+
return safe9(this.client.query("scheduling.services"));
|
|
861
1222
|
}
|
|
862
1223
|
/**
|
|
863
1224
|
* Get a specific service by ID
|
|
864
1225
|
* Note: Filters from all services client-side (no single-service endpoint)
|
|
865
1226
|
*/
|
|
866
1227
|
async getService(serviceId) {
|
|
867
|
-
const
|
|
868
|
-
|
|
1228
|
+
const result = await this.getServices();
|
|
1229
|
+
if (!result.ok) return result;
|
|
1230
|
+
return ok(result.value.find((s) => s.id === serviceId) || null);
|
|
869
1231
|
}
|
|
870
1232
|
// --------------------------------------------------------------------------
|
|
871
1233
|
// AVAILABILITY
|
|
872
1234
|
// --------------------------------------------------------------------------
|
|
873
1235
|
async getAvailableSlots(input) {
|
|
874
|
-
return
|
|
875
|
-
|
|
876
|
-
|
|
1236
|
+
return safe9(
|
|
1237
|
+
this.client.query(
|
|
1238
|
+
"scheduling.slots",
|
|
1239
|
+
input
|
|
1240
|
+
)
|
|
877
1241
|
);
|
|
878
1242
|
}
|
|
879
1243
|
async checkSlotAvailability(input) {
|
|
880
|
-
return
|
|
881
|
-
|
|
882
|
-
|
|
1244
|
+
return safe9(
|
|
1245
|
+
this.client.query(
|
|
1246
|
+
"scheduling.check_availability",
|
|
1247
|
+
input
|
|
1248
|
+
)
|
|
883
1249
|
);
|
|
884
1250
|
}
|
|
885
1251
|
async getServiceAvailability(params) {
|
|
886
|
-
return
|
|
887
|
-
|
|
888
|
-
|
|
1252
|
+
return safe9(
|
|
1253
|
+
this.client.query(
|
|
1254
|
+
"scheduling.availability",
|
|
1255
|
+
params
|
|
1256
|
+
)
|
|
889
1257
|
);
|
|
890
1258
|
}
|
|
891
1259
|
// --------------------------------------------------------------------------
|
|
892
1260
|
// BOOKINGS
|
|
893
1261
|
// --------------------------------------------------------------------------
|
|
894
1262
|
async getBooking(bookingId) {
|
|
895
|
-
return this.client.query(`scheduling.${bookingId}`);
|
|
1263
|
+
return safe9(this.client.query(`scheduling.${bookingId}`));
|
|
896
1264
|
}
|
|
897
1265
|
async getCustomerBookings() {
|
|
898
|
-
return this.client.query("scheduling");
|
|
1266
|
+
return safe9(this.client.query("scheduling"));
|
|
899
1267
|
}
|
|
900
1268
|
async getUpcomingBookings() {
|
|
901
|
-
return
|
|
902
|
-
|
|
1269
|
+
return safe9(
|
|
1270
|
+
this.client.query(
|
|
1271
|
+
"scheduling[?(@.status!='completed' && @.status!='cancelled')]#sort(start_time,asc)"
|
|
1272
|
+
)
|
|
903
1273
|
);
|
|
904
1274
|
}
|
|
905
1275
|
async getPastBookings(limit = 10) {
|
|
906
|
-
return
|
|
907
|
-
|
|
1276
|
+
return safe9(
|
|
1277
|
+
this.client.query(
|
|
1278
|
+
`scheduling[?(@.status=='completed')]#sort(start_time,desc)#limit(${limit})`
|
|
1279
|
+
)
|
|
908
1280
|
);
|
|
909
1281
|
}
|
|
910
1282
|
// --------------------------------------------------------------------------
|
|
911
1283
|
// BOOKING MANAGEMENT
|
|
912
1284
|
// --------------------------------------------------------------------------
|
|
913
1285
|
async cancelBooking(input) {
|
|
914
|
-
return this.client.call("scheduling.cancel_booking", input);
|
|
1286
|
+
return safe9(this.client.call("scheduling.cancel_booking", input));
|
|
915
1287
|
}
|
|
916
1288
|
async rescheduleBooking(input) {
|
|
917
|
-
return this.client.call("scheduling.reschedule_booking", input);
|
|
1289
|
+
return safe9(this.client.call("scheduling.reschedule_booking", input));
|
|
918
1290
|
}
|
|
919
1291
|
// --------------------------------------------------------------------------
|
|
920
1292
|
// CONVENIENCE METHODS
|
|
921
1293
|
// --------------------------------------------------------------------------
|
|
922
1294
|
async getNextAvailableSlot(serviceId, fromDate) {
|
|
923
1295
|
const date = fromDate || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
924
|
-
const
|
|
1296
|
+
const result = await this.getAvailableSlots({
|
|
925
1297
|
service_id: serviceId,
|
|
926
1298
|
date
|
|
927
1299
|
});
|
|
928
|
-
|
|
1300
|
+
if (!result.ok) return result;
|
|
1301
|
+
return ok(result.value.find((slot) => slot.is_available) || null);
|
|
929
1302
|
}
|
|
930
1303
|
async hasAvailabilityOn(serviceId, date) {
|
|
931
|
-
const
|
|
1304
|
+
const result = await this.getAvailableSlots({
|
|
932
1305
|
service_id: serviceId,
|
|
933
1306
|
date
|
|
934
1307
|
});
|
|
935
|
-
|
|
1308
|
+
if (!result.ok) return result;
|
|
1309
|
+
return ok(result.value.some((slot) => slot.is_available));
|
|
936
1310
|
}
|
|
937
1311
|
};
|
|
938
1312
|
|
|
939
1313
|
// src/lite.ts
|
|
1314
|
+
function toCimplifyError10(error) {
|
|
1315
|
+
if (error instanceof CimplifyError) return error;
|
|
1316
|
+
if (error instanceof Error) {
|
|
1317
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
1318
|
+
}
|
|
1319
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
1320
|
+
}
|
|
1321
|
+
async function safe10(promise) {
|
|
1322
|
+
try {
|
|
1323
|
+
return ok(await promise);
|
|
1324
|
+
} catch (error) {
|
|
1325
|
+
return err(toCimplifyError10(error));
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
940
1328
|
var LiteService = class {
|
|
941
1329
|
constructor(client) {
|
|
942
1330
|
this.client = client;
|
|
@@ -945,48 +1333,56 @@ var LiteService = class {
|
|
|
945
1333
|
// BOOTSTRAP
|
|
946
1334
|
// --------------------------------------------------------------------------
|
|
947
1335
|
async getBootstrap() {
|
|
948
|
-
return this.client.query("lite.bootstrap");
|
|
1336
|
+
return safe10(this.client.query("lite.bootstrap"));
|
|
949
1337
|
}
|
|
950
1338
|
// --------------------------------------------------------------------------
|
|
951
1339
|
// TABLE MANAGEMENT
|
|
952
1340
|
// --------------------------------------------------------------------------
|
|
953
1341
|
async getTable(tableId) {
|
|
954
|
-
return this.client.query(`lite.table.${tableId}`);
|
|
1342
|
+
return safe10(this.client.query(`lite.table.${tableId}`));
|
|
955
1343
|
}
|
|
956
1344
|
async getTableByNumber(tableNumber, locationId) {
|
|
957
|
-
return
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1345
|
+
return safe10(
|
|
1346
|
+
this.client.query("lite.table_by_number", {
|
|
1347
|
+
table_number: tableNumber,
|
|
1348
|
+
location_id: locationId
|
|
1349
|
+
})
|
|
1350
|
+
);
|
|
961
1351
|
}
|
|
962
1352
|
// --------------------------------------------------------------------------
|
|
963
1353
|
// KITCHEN ORDERS
|
|
964
1354
|
// --------------------------------------------------------------------------
|
|
965
1355
|
async sendToKitchen(tableId, items) {
|
|
966
|
-
return
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1356
|
+
return safe10(
|
|
1357
|
+
this.client.call("lite.send_to_kitchen", {
|
|
1358
|
+
table_id: tableId,
|
|
1359
|
+
items
|
|
1360
|
+
})
|
|
1361
|
+
);
|
|
970
1362
|
}
|
|
971
1363
|
async callWaiter(tableId, reason) {
|
|
972
|
-
return
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1364
|
+
return safe10(
|
|
1365
|
+
this.client.call("lite.call_waiter", {
|
|
1366
|
+
table_id: tableId,
|
|
1367
|
+
reason
|
|
1368
|
+
})
|
|
1369
|
+
);
|
|
976
1370
|
}
|
|
977
1371
|
async requestBill(tableId) {
|
|
978
|
-
return
|
|
979
|
-
|
|
980
|
-
|
|
1372
|
+
return safe10(
|
|
1373
|
+
this.client.call("lite.request_bill", {
|
|
1374
|
+
table_id: tableId
|
|
1375
|
+
})
|
|
1376
|
+
);
|
|
981
1377
|
}
|
|
982
1378
|
// --------------------------------------------------------------------------
|
|
983
1379
|
// MENU (optimized for lite/QR experience)
|
|
984
1380
|
// --------------------------------------------------------------------------
|
|
985
1381
|
async getMenu() {
|
|
986
|
-
return this.client.query("lite.menu");
|
|
1382
|
+
return safe10(this.client.query("lite.menu"));
|
|
987
1383
|
}
|
|
988
1384
|
async getMenuByCategory(categoryId) {
|
|
989
|
-
return this.client.query(`lite.menu.category.${categoryId}`);
|
|
1385
|
+
return safe10(this.client.query(`lite.menu.category.${categoryId}`));
|
|
990
1386
|
}
|
|
991
1387
|
};
|
|
992
1388
|
|
|
@@ -1782,4 +2178,4 @@ function detectMobileMoneyProvider(phoneNumber) {
|
|
|
1782
2178
|
return null;
|
|
1783
2179
|
}
|
|
1784
2180
|
|
|
1785
|
-
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, ErrorCode, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, createCimplifyClient, detectMobileMoneyProvider, extractPriceInfo, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, isCimplifyError, isOnSale, isRetryableError, normalizePaymentResponse, normalizeStatusResponse, parsePrice, parsePricePath, parsedPriceToPriceInfo, query };
|
|
2181
|
+
export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, ErrorCode, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, combine, combineObject, createCimplifyClient, detectMobileMoneyProvider, err, extractPriceInfo, flatMap, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, fromPromise, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getOrElse, getProductCurrency, isCimplifyError, isErr, isOk, isOnSale, isRetryableError, mapError, mapResult, normalizePaymentResponse, normalizeStatusResponse, ok, parsePrice, parsePricePath, parsedPriceToPriceInfo, query, toNullable, tryCatch, unwrap };
|