@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.d.ts
CHANGED
|
@@ -536,6 +536,156 @@ interface ProductTimeProfile {
|
|
|
536
536
|
metadata?: Record<string, unknown>;
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
+
/**
|
|
540
|
+
* A Result type that makes errors explicit in the type system.
|
|
541
|
+
* Inspired by Rust's Result and fp-ts Either.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```typescript
|
|
545
|
+
* const result = await client.cart.addItemSafe({ item_id: "prod_123" });
|
|
546
|
+
*
|
|
547
|
+
* if (result.ok) {
|
|
548
|
+
* console.log(result.value); // Cart
|
|
549
|
+
* } else {
|
|
550
|
+
* console.log(result.error); // CimplifyError
|
|
551
|
+
* }
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
type Result<T, E = Error> = Ok<T> | Err<E>;
|
|
555
|
+
interface Ok<T> {
|
|
556
|
+
readonly ok: true;
|
|
557
|
+
readonly value: T;
|
|
558
|
+
}
|
|
559
|
+
interface Err<E> {
|
|
560
|
+
readonly ok: false;
|
|
561
|
+
readonly error: E;
|
|
562
|
+
}
|
|
563
|
+
/** Create a successful Result */
|
|
564
|
+
declare function ok<T>(value: T): Ok<T>;
|
|
565
|
+
/** Create a failed Result */
|
|
566
|
+
declare function err<E>(error: E): Err<E>;
|
|
567
|
+
/** Check if Result is Ok */
|
|
568
|
+
declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
|
|
569
|
+
/** Check if Result is Err */
|
|
570
|
+
declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
|
|
571
|
+
/**
|
|
572
|
+
* Transform the success value of a Result.
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```typescript
|
|
576
|
+
* const result = ok(5);
|
|
577
|
+
* const doubled = mapResult(result, (n) => n * 2);
|
|
578
|
+
* // doubled = { ok: true, value: 10 }
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
declare function mapResult<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
|
|
582
|
+
/**
|
|
583
|
+
* Transform the error value of a Result.
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```typescript
|
|
587
|
+
* const result = err(new Error("oops"));
|
|
588
|
+
* const mapped = mapError(result, (e) => new CustomError(e.message));
|
|
589
|
+
* ```
|
|
590
|
+
*/
|
|
591
|
+
declare function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
|
|
592
|
+
/**
|
|
593
|
+
* Chain Results together. If the first Result is Ok, apply the function.
|
|
594
|
+
* If it's Err, propagate the error.
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```typescript
|
|
598
|
+
* const getUser = (id: string): Result<User, Error> => { ... }
|
|
599
|
+
* const getOrders = (user: User): Result<Order[], Error> => { ... }
|
|
600
|
+
*
|
|
601
|
+
* const result = flatMap(getUser("123"), (user) => getOrders(user));
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
declare function flatMap<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
|
|
605
|
+
/**
|
|
606
|
+
* Get the value or a default if the Result is Err.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```typescript
|
|
610
|
+
* const result = err(new Error("failed"));
|
|
611
|
+
* const value = getOrElse(result, () => defaultCart);
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
declare function getOrElse<T, E>(result: Result<T, E>, defaultFn: () => T): T;
|
|
615
|
+
/**
|
|
616
|
+
* Get the value or throw the error.
|
|
617
|
+
* Use sparingly - defeats the purpose of Result!
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```typescript
|
|
621
|
+
* const cart = unwrap(result); // throws if Err
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
625
|
+
/**
|
|
626
|
+
* Get the value or undefined if Err.
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* const cart = toNullable(result); // Cart | undefined
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
633
|
+
declare function toNullable<T, E>(result: Result<T, E>): T | undefined;
|
|
634
|
+
/**
|
|
635
|
+
* Convert a Promise that might throw into a Result.
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```typescript
|
|
639
|
+
* const result = await fromPromise(
|
|
640
|
+
* fetch("/api/data"),
|
|
641
|
+
* (error) => new NetworkError(error.message)
|
|
642
|
+
* );
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
declare function fromPromise<T, E>(promise: Promise<T>, mapError: (error: unknown) => E): Promise<Result<T, E>>;
|
|
646
|
+
/**
|
|
647
|
+
* Convert a function that might throw into one that returns Result.
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* ```typescript
|
|
651
|
+
* const safeParse = tryCatch(
|
|
652
|
+
* () => JSON.parse(input),
|
|
653
|
+
* (e) => new ParseError(e.message)
|
|
654
|
+
* );
|
|
655
|
+
* ```
|
|
656
|
+
*/
|
|
657
|
+
declare function tryCatch<T, E>(fn: () => T, mapError: (error: unknown) => E): Result<T, E>;
|
|
658
|
+
/**
|
|
659
|
+
* Combine multiple Results. Returns Ok with array of values if all succeed,
|
|
660
|
+
* or the first Err encountered.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```typescript
|
|
664
|
+
* const results = await Promise.all([
|
|
665
|
+
* client.cart.getSafe(),
|
|
666
|
+
* client.business.getSafe(),
|
|
667
|
+
* ]);
|
|
668
|
+
* const combined = combine(results);
|
|
669
|
+
* // Result<[Cart, Business], CimplifyError>
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
672
|
+
declare function combine<T, E>(results: Result<T, E>[]): Result<T[], E>;
|
|
673
|
+
/**
|
|
674
|
+
* Like combine, but for an object of Results.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```typescript
|
|
678
|
+
* const data = combineObject({
|
|
679
|
+
* cart: await client.cart.getSafe(),
|
|
680
|
+
* business: await client.business.getSafe(),
|
|
681
|
+
* });
|
|
682
|
+
* // Result<{ cart: Cart, business: Business }, CimplifyError>
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
declare function combineObject<T extends Record<string, Result<unknown, unknown>>>(results: T): Result<{
|
|
686
|
+
[K in keyof T]: T[K] extends Result<infer V, unknown> ? V : never;
|
|
687
|
+
}, T[keyof T] extends Result<unknown, infer E> ? E : never>;
|
|
688
|
+
|
|
539
689
|
interface GetProductsOptions {
|
|
540
690
|
category?: string;
|
|
541
691
|
collection?: string;
|
|
@@ -554,51 +704,67 @@ interface SearchOptions {
|
|
|
554
704
|
limit?: number;
|
|
555
705
|
category?: string;
|
|
556
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* Catalogue queries with explicit error handling via Result type.
|
|
709
|
+
*
|
|
710
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* ```typescript
|
|
714
|
+
* const result = await client.catalogue.getProducts({ category: "burgers" });
|
|
715
|
+
*
|
|
716
|
+
* if (result.ok) {
|
|
717
|
+
* console.log("Products:", result.value);
|
|
718
|
+
* } else {
|
|
719
|
+
* console.error("Failed:", result.error.code);
|
|
720
|
+
* }
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
557
723
|
declare class CatalogueQueries {
|
|
558
724
|
private client;
|
|
559
725
|
constructor(client: CimplifyClient);
|
|
560
|
-
getProducts(options?: GetProductsOptions): Promise<Product[]
|
|
561
|
-
getProduct(id: string): Promise<ProductWithDetails
|
|
562
|
-
getProductBySlug(slug: string): Promise<ProductWithDetails
|
|
563
|
-
getVariants(productId: string): Promise<ProductVariant[]
|
|
564
|
-
getVariantAxes(productId: string): Promise<VariantAxis[]
|
|
726
|
+
getProducts(options?: GetProductsOptions): Promise<Result<Product[], CimplifyError>>;
|
|
727
|
+
getProduct(id: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
728
|
+
getProductBySlug(slug: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
729
|
+
getVariants(productId: string): Promise<Result<ProductVariant[], CimplifyError>>;
|
|
730
|
+
getVariantAxes(productId: string): Promise<Result<VariantAxis[], CimplifyError>>;
|
|
565
731
|
/**
|
|
566
732
|
* Find a variant by axis selections (e.g., { "Size": "Large", "Color": "Red" })
|
|
567
733
|
* Returns the matching variant or null if no match found.
|
|
568
734
|
*/
|
|
569
|
-
getVariantByAxisSelections(productId: string, selections: VariantAxisSelection): Promise<ProductVariant | null
|
|
735
|
+
getVariantByAxisSelections(productId: string, selections: VariantAxisSelection): Promise<Result<ProductVariant | null, CimplifyError>>;
|
|
570
736
|
/**
|
|
571
737
|
* Get a specific variant by its ID
|
|
572
738
|
*/
|
|
573
|
-
getVariantById(productId: string, variantId: string): Promise<ProductVariant
|
|
574
|
-
getAddOns(productId: string): Promise<AddOn[]
|
|
575
|
-
getCategories(): Promise<Category[]
|
|
576
|
-
getCategory(id: string): Promise<Category
|
|
577
|
-
getCategoryBySlug(slug: string): Promise<Category
|
|
578
|
-
getCategoryProducts(categoryId: string): Promise<Product[]
|
|
579
|
-
getCollections(): Promise<Collection[]
|
|
580
|
-
getCollection(id: string): Promise<Collection
|
|
581
|
-
getCollectionBySlug(slug: string): Promise<Collection
|
|
582
|
-
getCollectionProducts(collectionId: string): Promise<Product[]
|
|
583
|
-
searchCollections(query: string, limit?: number): Promise<Collection[]
|
|
584
|
-
getBundles(): Promise<Bundle[]
|
|
585
|
-
getBundle(id: string): Promise<BundleWithDetails
|
|
586
|
-
getBundleBySlug(slug: string): Promise<BundleWithDetails
|
|
587
|
-
searchBundles(query: string, limit?: number): Promise<Bundle[]
|
|
739
|
+
getVariantById(productId: string, variantId: string): Promise<Result<ProductVariant, CimplifyError>>;
|
|
740
|
+
getAddOns(productId: string): Promise<Result<AddOn[], CimplifyError>>;
|
|
741
|
+
getCategories(): Promise<Result<Category[], CimplifyError>>;
|
|
742
|
+
getCategory(id: string): Promise<Result<Category, CimplifyError>>;
|
|
743
|
+
getCategoryBySlug(slug: string): Promise<Result<Category, CimplifyError>>;
|
|
744
|
+
getCategoryProducts(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
745
|
+
getCollections(): Promise<Result<Collection[], CimplifyError>>;
|
|
746
|
+
getCollection(id: string): Promise<Result<Collection, CimplifyError>>;
|
|
747
|
+
getCollectionBySlug(slug: string): Promise<Result<Collection, CimplifyError>>;
|
|
748
|
+
getCollectionProducts(collectionId: string): Promise<Result<Product[], CimplifyError>>;
|
|
749
|
+
searchCollections(query: string, limit?: number): Promise<Result<Collection[], CimplifyError>>;
|
|
750
|
+
getBundles(): Promise<Result<Bundle[], CimplifyError>>;
|
|
751
|
+
getBundle(id: string): Promise<Result<BundleWithDetails, CimplifyError>>;
|
|
752
|
+
getBundleBySlug(slug: string): Promise<Result<BundleWithDetails, CimplifyError>>;
|
|
753
|
+
searchBundles(query: string, limit?: number): Promise<Result<Bundle[], CimplifyError>>;
|
|
588
754
|
getComposites(options?: {
|
|
589
755
|
limit?: number;
|
|
590
|
-
}): Promise<Composite[]
|
|
591
|
-
getComposite(id: string): Promise<CompositeWithDetails
|
|
592
|
-
getCompositeByProductId(productId: string): Promise<CompositeWithDetails
|
|
593
|
-
calculateCompositePrice(compositeId: string, selections: ComponentSelectionInput[], locationId?: string): Promise<CompositePriceResult
|
|
594
|
-
search(query: string, options?: SearchOptions): Promise<Product[]
|
|
595
|
-
searchProducts(query: string, options?: SearchOptions): Promise<Product[]
|
|
756
|
+
}): Promise<Result<Composite[], CimplifyError>>;
|
|
757
|
+
getComposite(id: string): Promise<Result<CompositeWithDetails, CimplifyError>>;
|
|
758
|
+
getCompositeByProductId(productId: string): Promise<Result<CompositeWithDetails, CimplifyError>>;
|
|
759
|
+
calculateCompositePrice(compositeId: string, selections: ComponentSelectionInput[], locationId?: string): Promise<Result<CompositePriceResult, CimplifyError>>;
|
|
760
|
+
search(query: string, options?: SearchOptions): Promise<Result<Product[], CimplifyError>>;
|
|
761
|
+
searchProducts(query: string, options?: SearchOptions): Promise<Result<Product[], CimplifyError>>;
|
|
596
762
|
getMenu(options?: {
|
|
597
763
|
category?: string;
|
|
598
764
|
limit?: number;
|
|
599
|
-
}): Promise<Product[]
|
|
600
|
-
getMenuCategory(categoryId: string): Promise<Product[]
|
|
601
|
-
getMenuItem(itemId: string): Promise<ProductWithDetails
|
|
765
|
+
}): Promise<Result<Product[], CimplifyError>>;
|
|
766
|
+
getMenuCategory(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
767
|
+
getMenuItem(itemId: string): Promise<Result<ProductWithDetails, CimplifyError>>;
|
|
602
768
|
}
|
|
603
769
|
|
|
604
770
|
type CartStatus = "active" | "converting" | "converted" | "expired" | "abandoned";
|
|
@@ -1075,6 +1241,22 @@ interface CartSummary {
|
|
|
1075
1241
|
currency: string;
|
|
1076
1242
|
}
|
|
1077
1243
|
|
|
1244
|
+
/**
|
|
1245
|
+
* Cart operations with explicit error handling via Result type.
|
|
1246
|
+
*
|
|
1247
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```typescript
|
|
1251
|
+
* const result = await client.cart.addItem({ item_id: "prod_123" });
|
|
1252
|
+
*
|
|
1253
|
+
* if (result.ok) {
|
|
1254
|
+
* console.log("Added!", result.value);
|
|
1255
|
+
* } else {
|
|
1256
|
+
* console.error("Failed:", result.error.code);
|
|
1257
|
+
* }
|
|
1258
|
+
* ```
|
|
1259
|
+
*/
|
|
1078
1260
|
declare class CartOperations {
|
|
1079
1261
|
private client;
|
|
1080
1262
|
constructor(client: CimplifyClient);
|
|
@@ -1082,22 +1264,46 @@ declare class CartOperations {
|
|
|
1082
1264
|
* Get the enriched cart with product names, images, and details.
|
|
1083
1265
|
* This is the main method for storefront display.
|
|
1084
1266
|
*/
|
|
1085
|
-
get(): Promise<UICart
|
|
1086
|
-
getRaw(): Promise<Cart
|
|
1087
|
-
getItems(): Promise<CartItem[]
|
|
1088
|
-
getCount(): Promise<number
|
|
1089
|
-
getTotal(): Promise<string
|
|
1090
|
-
getSummary(): Promise<CartSummary
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1267
|
+
get(): Promise<Result<UICart, CimplifyError>>;
|
|
1268
|
+
getRaw(): Promise<Result<Cart, CimplifyError>>;
|
|
1269
|
+
getItems(): Promise<Result<CartItem[], CimplifyError>>;
|
|
1270
|
+
getCount(): Promise<Result<number, CimplifyError>>;
|
|
1271
|
+
getTotal(): Promise<Result<string, CimplifyError>>;
|
|
1272
|
+
getSummary(): Promise<Result<CartSummary, CimplifyError>>;
|
|
1273
|
+
/**
|
|
1274
|
+
* Add an item to the cart.
|
|
1275
|
+
*
|
|
1276
|
+
* @example
|
|
1277
|
+
* ```typescript
|
|
1278
|
+
* const result = await client.cart.addItem({
|
|
1279
|
+
* item_id: "prod_burger",
|
|
1280
|
+
* quantity: 2,
|
|
1281
|
+
* variant_id: "var_large",
|
|
1282
|
+
* add_on_options: ["addon_cheese", "addon_bacon"],
|
|
1283
|
+
* });
|
|
1284
|
+
*
|
|
1285
|
+
* if (!result.ok) {
|
|
1286
|
+
* switch (result.error.code) {
|
|
1287
|
+
* case ErrorCode.ITEM_UNAVAILABLE:
|
|
1288
|
+
* toast.error("Item no longer available");
|
|
1289
|
+
* break;
|
|
1290
|
+
* case ErrorCode.VARIANT_OUT_OF_STOCK:
|
|
1291
|
+
* toast.error("Selected option is out of stock");
|
|
1292
|
+
* break;
|
|
1293
|
+
* }
|
|
1294
|
+
* }
|
|
1295
|
+
* ```
|
|
1296
|
+
*/
|
|
1297
|
+
addItem(input: AddToCartInput): Promise<Result<Cart, CimplifyError>>;
|
|
1298
|
+
updateItem(cartItemId: string, updates: UpdateCartItemInput): Promise<Result<Cart, CimplifyError>>;
|
|
1299
|
+
updateQuantity(cartItemId: string, quantity: number): Promise<Result<Cart, CimplifyError>>;
|
|
1300
|
+
removeItem(cartItemId: string): Promise<Result<Cart, CimplifyError>>;
|
|
1301
|
+
clear(): Promise<Result<Cart, CimplifyError>>;
|
|
1302
|
+
applyCoupon(code: string): Promise<Result<Cart, CimplifyError>>;
|
|
1303
|
+
removeCoupon(): Promise<Result<Cart, CimplifyError>>;
|
|
1304
|
+
isEmpty(): Promise<Result<boolean, CimplifyError>>;
|
|
1305
|
+
hasItem(productId: string, variantId?: string): Promise<Result<boolean, CimplifyError>>;
|
|
1306
|
+
findItem(productId: string, variantId?: string): Promise<Result<CartItem | undefined, CimplifyError>>;
|
|
1101
1307
|
}
|
|
1102
1308
|
|
|
1103
1309
|
type OrderStatus = "pending" | "created" | "confirmed" | "in_preparation" | "ready_to_serve" | "partially_served" | "served" | "delivered" | "picked_up" | "completed" | "cancelled" | "refunded";
|
|
@@ -1766,15 +1972,61 @@ interface CheckoutResult {
|
|
|
1766
1972
|
public_key?: string;
|
|
1767
1973
|
}
|
|
1768
1974
|
|
|
1975
|
+
/**
|
|
1976
|
+
* Checkout service with explicit error handling via Result type.
|
|
1977
|
+
*
|
|
1978
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1979
|
+
*
|
|
1980
|
+
* @example
|
|
1981
|
+
* ```typescript
|
|
1982
|
+
* const result = await client.checkout.process(formData);
|
|
1983
|
+
*
|
|
1984
|
+
* if (result.ok) {
|
|
1985
|
+
* const checkout = result.value;
|
|
1986
|
+
* if (checkout.requires_authorization) {
|
|
1987
|
+
* // Handle OTP flow
|
|
1988
|
+
* } else if (checkout.client_secret) {
|
|
1989
|
+
* // Open Paystack popup
|
|
1990
|
+
* }
|
|
1991
|
+
* } else {
|
|
1992
|
+
* toast.error(result.error.message);
|
|
1993
|
+
* }
|
|
1994
|
+
* ```
|
|
1995
|
+
*/
|
|
1769
1996
|
declare class CheckoutService {
|
|
1770
1997
|
private client;
|
|
1771
1998
|
constructor(client: CimplifyClient);
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1999
|
+
/**
|
|
2000
|
+
* Process checkout with cart data.
|
|
2001
|
+
*
|
|
2002
|
+
* @example
|
|
2003
|
+
* ```typescript
|
|
2004
|
+
* const result = await client.checkout.process({
|
|
2005
|
+
* cart_id: cart.id,
|
|
2006
|
+
* customer: { name, email, phone, save_details: true },
|
|
2007
|
+
* order_type: "pickup",
|
|
2008
|
+
* payment_method: "mobile_money",
|
|
2009
|
+
* mobile_money_details: { phone_number, provider: "mtn" },
|
|
2010
|
+
* });
|
|
2011
|
+
*
|
|
2012
|
+
* if (!result.ok) {
|
|
2013
|
+
* switch (result.error.code) {
|
|
2014
|
+
* case ErrorCode.CART_EMPTY:
|
|
2015
|
+
* toast.error("Your cart is empty");
|
|
2016
|
+
* break;
|
|
2017
|
+
* case ErrorCode.PAYMENT_FAILED:
|
|
2018
|
+
* toast.error("Payment failed. Please try again.");
|
|
2019
|
+
* break;
|
|
2020
|
+
* }
|
|
2021
|
+
* }
|
|
2022
|
+
* ```
|
|
2023
|
+
*/
|
|
2024
|
+
process(data: CheckoutFormData): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
2025
|
+
initializePayment(orderId: string, method: PaymentMethod): Promise<Result<InitializePaymentResult, CimplifyError>>;
|
|
2026
|
+
submitAuthorization(input: SubmitAuthorizationInput): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
2027
|
+
pollPaymentStatus(orderId: string): Promise<Result<PaymentStatusResponse, CimplifyError>>;
|
|
2028
|
+
updateOrderCustomer(orderId: string, customer: CheckoutCustomerInfo): Promise<Result<Order, CimplifyError>>;
|
|
2029
|
+
verifyPayment(orderId: string): Promise<Result<Order, CimplifyError>>;
|
|
1778
2030
|
}
|
|
1779
2031
|
|
|
1780
2032
|
interface GetOrdersOptions {
|
|
@@ -1782,55 +2034,76 @@ interface GetOrdersOptions {
|
|
|
1782
2034
|
limit?: number;
|
|
1783
2035
|
offset?: number;
|
|
1784
2036
|
}
|
|
2037
|
+
/**
|
|
2038
|
+
* Order queries with explicit error handling via Result type.
|
|
2039
|
+
*
|
|
2040
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2041
|
+
*
|
|
2042
|
+
* @example
|
|
2043
|
+
* ```typescript
|
|
2044
|
+
* const result = await client.orders.list({ status: "pending" });
|
|
2045
|
+
*
|
|
2046
|
+
* if (result.ok) {
|
|
2047
|
+
* console.log("Orders:", result.value);
|
|
2048
|
+
* } else {
|
|
2049
|
+
* console.error("Failed:", result.error.code);
|
|
2050
|
+
* }
|
|
2051
|
+
* ```
|
|
2052
|
+
*/
|
|
1785
2053
|
declare class OrderQueries {
|
|
1786
2054
|
private client;
|
|
1787
2055
|
constructor(client: CimplifyClient);
|
|
1788
|
-
list(options?: GetOrdersOptions): Promise<Order[]
|
|
1789
|
-
get(orderId: string): Promise<Order
|
|
1790
|
-
getRecent(limit?: number): Promise<Order[]
|
|
1791
|
-
getByStatus(status: OrderStatus): Promise<Order[]
|
|
1792
|
-
cancel(orderId: string, reason?: string): Promise<Order
|
|
2056
|
+
list(options?: GetOrdersOptions): Promise<Result<Order[], CimplifyError>>;
|
|
2057
|
+
get(orderId: string): Promise<Result<Order, CimplifyError>>;
|
|
2058
|
+
getRecent(limit?: number): Promise<Result<Order[], CimplifyError>>;
|
|
2059
|
+
getByStatus(status: OrderStatus): Promise<Result<Order[], CimplifyError>>;
|
|
2060
|
+
cancel(orderId: string, reason?: string): Promise<Result<Order, CimplifyError>>;
|
|
1793
2061
|
}
|
|
1794
2062
|
|
|
1795
|
-
interface SuccessResult {
|
|
2063
|
+
interface SuccessResult$2 {
|
|
1796
2064
|
success: boolean;
|
|
1797
2065
|
message?: string;
|
|
1798
2066
|
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Cimplify Link service for express checkout with saved customer data.
|
|
2069
|
+
*
|
|
2070
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2071
|
+
*/
|
|
1799
2072
|
declare class LinkService {
|
|
1800
2073
|
private client;
|
|
1801
2074
|
constructor(client: CimplifyClient);
|
|
1802
|
-
requestOtp(input: RequestOtpInput): Promise<SuccessResult
|
|
1803
|
-
verifyOtp(input: VerifyOtpInput): Promise<AuthResponse
|
|
1804
|
-
logout(): Promise<SuccessResult
|
|
1805
|
-
checkStatus(contact: string): Promise<LinkStatusResult
|
|
1806
|
-
getLinkData(): Promise<LinkData
|
|
1807
|
-
getAddresses(): Promise<CustomerAddress[]
|
|
1808
|
-
getMobileMoney(): Promise<CustomerMobileMoney[]
|
|
1809
|
-
getPreferences(): Promise<CustomerLinkPreferences
|
|
1810
|
-
enroll(data: EnrollmentData): Promise<LinkEnrollResult
|
|
1811
|
-
enrollAndLinkOrder(data: EnrollAndLinkOrderInput): Promise<EnrollAndLinkOrderResult
|
|
1812
|
-
updatePreferences(preferences: Partial<CustomerLinkPreferences>): Promise<SuccessResult
|
|
1813
|
-
createAddress(input: CreateAddressInput): Promise<CustomerAddress
|
|
1814
|
-
updateAddress(input: UpdateAddressInput): Promise<SuccessResult
|
|
1815
|
-
deleteAddress(addressId: string): Promise<SuccessResult
|
|
1816
|
-
setDefaultAddress(addressId: string): Promise<SuccessResult
|
|
1817
|
-
trackAddressUsage(addressId: string): Promise<SuccessResult
|
|
1818
|
-
createMobileMoney(input: CreateMobileMoneyInput): Promise<CustomerMobileMoney
|
|
1819
|
-
deleteMobileMoney(mobileMoneyId: string): Promise<SuccessResult
|
|
1820
|
-
setDefaultMobileMoney(mobileMoneyId: string): Promise<SuccessResult
|
|
1821
|
-
trackMobileMoneyUsage(mobileMoneyId: string): Promise<SuccessResult
|
|
1822
|
-
verifyMobileMoney(mobileMoneyId: string): Promise<SuccessResult
|
|
1823
|
-
getSessions(): Promise<LinkSession[]
|
|
1824
|
-
revokeSession(sessionId: string): Promise<RevokeSessionResult
|
|
1825
|
-
revokeAllSessions(): Promise<RevokeAllSessionsResult
|
|
1826
|
-
getAddressesRest(): Promise<CustomerAddress[]
|
|
1827
|
-
createAddressRest(input: CreateAddressInput): Promise<CustomerAddress
|
|
1828
|
-
deleteAddressRest(addressId: string): Promise<SuccessResult
|
|
1829
|
-
setDefaultAddressRest(addressId: string): Promise<SuccessResult
|
|
1830
|
-
getMobileMoneyRest(): Promise<CustomerMobileMoney[]
|
|
1831
|
-
createMobileMoneyRest(input: CreateMobileMoneyInput): Promise<CustomerMobileMoney
|
|
1832
|
-
deleteMobileMoneyRest(mobileMoneyId: string): Promise<SuccessResult
|
|
1833
|
-
setDefaultMobileMoneyRest(mobileMoneyId: string): Promise<SuccessResult
|
|
2075
|
+
requestOtp(input: RequestOtpInput): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2076
|
+
verifyOtp(input: VerifyOtpInput): Promise<Result<AuthResponse, CimplifyError>>;
|
|
2077
|
+
logout(): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2078
|
+
checkStatus(contact: string): Promise<Result<LinkStatusResult, CimplifyError>>;
|
|
2079
|
+
getLinkData(): Promise<Result<LinkData, CimplifyError>>;
|
|
2080
|
+
getAddresses(): Promise<Result<CustomerAddress[], CimplifyError>>;
|
|
2081
|
+
getMobileMoney(): Promise<Result<CustomerMobileMoney[], CimplifyError>>;
|
|
2082
|
+
getPreferences(): Promise<Result<CustomerLinkPreferences, CimplifyError>>;
|
|
2083
|
+
enroll(data: EnrollmentData): Promise<Result<LinkEnrollResult, CimplifyError>>;
|
|
2084
|
+
enrollAndLinkOrder(data: EnrollAndLinkOrderInput): Promise<Result<EnrollAndLinkOrderResult, CimplifyError>>;
|
|
2085
|
+
updatePreferences(preferences: Partial<CustomerLinkPreferences>): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2086
|
+
createAddress(input: CreateAddressInput): Promise<Result<CustomerAddress, CimplifyError>>;
|
|
2087
|
+
updateAddress(input: UpdateAddressInput): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2088
|
+
deleteAddress(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2089
|
+
setDefaultAddress(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2090
|
+
trackAddressUsage(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2091
|
+
createMobileMoney(input: CreateMobileMoneyInput): Promise<Result<CustomerMobileMoney, CimplifyError>>;
|
|
2092
|
+
deleteMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2093
|
+
setDefaultMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2094
|
+
trackMobileMoneyUsage(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2095
|
+
verifyMobileMoney(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2096
|
+
getSessions(): Promise<Result<LinkSession[], CimplifyError>>;
|
|
2097
|
+
revokeSession(sessionId: string): Promise<Result<RevokeSessionResult, CimplifyError>>;
|
|
2098
|
+
revokeAllSessions(): Promise<Result<RevokeAllSessionsResult, CimplifyError>>;
|
|
2099
|
+
getAddressesRest(): Promise<Result<CustomerAddress[], CimplifyError>>;
|
|
2100
|
+
createAddressRest(input: CreateAddressInput): Promise<Result<CustomerAddress, CimplifyError>>;
|
|
2101
|
+
deleteAddressRest(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2102
|
+
setDefaultAddressRest(addressId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2103
|
+
getMobileMoneyRest(): Promise<Result<CustomerMobileMoney[], CimplifyError>>;
|
|
2104
|
+
createMobileMoneyRest(input: CreateMobileMoneyInput): Promise<Result<CustomerMobileMoney, CimplifyError>>;
|
|
2105
|
+
deleteMobileMoneyRest(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
2106
|
+
setDefaultMobileMoneyRest(mobileMoneyId: string): Promise<Result<SuccessResult$2, CimplifyError>>;
|
|
1834
2107
|
}
|
|
1835
2108
|
|
|
1836
2109
|
interface AuthStatus {
|
|
@@ -1851,24 +2124,39 @@ interface ChangePasswordInput {
|
|
|
1851
2124
|
current_password: string;
|
|
1852
2125
|
new_password: string;
|
|
1853
2126
|
}
|
|
2127
|
+
interface SuccessResult$1 {
|
|
2128
|
+
success: boolean;
|
|
2129
|
+
}
|
|
2130
|
+
/**
|
|
2131
|
+
* Auth service with explicit error handling via Result type.
|
|
2132
|
+
*
|
|
2133
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2134
|
+
*
|
|
2135
|
+
* @example
|
|
2136
|
+
* ```typescript
|
|
2137
|
+
* const result = await client.auth.verifyOtp("123456");
|
|
2138
|
+
*
|
|
2139
|
+
* if (result.ok) {
|
|
2140
|
+
* console.log("Logged in as:", result.value.customer.name);
|
|
2141
|
+
* } else {
|
|
2142
|
+
* if (result.error.code === "INVALID_OTP") {
|
|
2143
|
+
* toast.error("Invalid code. Please try again.");
|
|
2144
|
+
* }
|
|
2145
|
+
* }
|
|
2146
|
+
* ```
|
|
2147
|
+
*/
|
|
1854
2148
|
declare class AuthService {
|
|
1855
2149
|
private client;
|
|
1856
2150
|
constructor(client: CimplifyClient);
|
|
1857
|
-
getStatus(): Promise<AuthStatus
|
|
1858
|
-
getCurrentUser(): Promise<Customer | null
|
|
1859
|
-
isAuthenticated(): Promise<boolean
|
|
1860
|
-
requestOtp(contact: string, contactType?: "phone" | "email"): Promise<void
|
|
1861
|
-
verifyOtp(code: string, contact?: string): Promise<OtpResult
|
|
1862
|
-
logout(): Promise<
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
changePassword(input: ChangePasswordInput): Promise<{
|
|
1867
|
-
success: boolean;
|
|
1868
|
-
}>;
|
|
1869
|
-
resetPassword(email: string): Promise<{
|
|
1870
|
-
success: boolean;
|
|
1871
|
-
}>;
|
|
2151
|
+
getStatus(): Promise<Result<AuthStatus, CimplifyError>>;
|
|
2152
|
+
getCurrentUser(): Promise<Result<Customer | null, CimplifyError>>;
|
|
2153
|
+
isAuthenticated(): Promise<Result<boolean, CimplifyError>>;
|
|
2154
|
+
requestOtp(contact: string, contactType?: "phone" | "email"): Promise<Result<void, CimplifyError>>;
|
|
2155
|
+
verifyOtp(code: string, contact?: string): Promise<Result<OtpResult, CimplifyError>>;
|
|
2156
|
+
logout(): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
2157
|
+
updateProfile(input: UpdateProfileInput): Promise<Result<Customer, CimplifyError>>;
|
|
2158
|
+
changePassword(input: ChangePasswordInput): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
2159
|
+
resetPassword(email: string): Promise<Result<SuccessResult$1, CimplifyError>>;
|
|
1872
2160
|
}
|
|
1873
2161
|
|
|
1874
2162
|
type BusinessType = "eatery" | "retail" | "service" | "other" | "system" | "unset";
|
|
@@ -2029,19 +2317,35 @@ interface CategoryInfo {
|
|
|
2029
2317
|
slug: string;
|
|
2030
2318
|
}
|
|
2031
2319
|
|
|
2320
|
+
/**
|
|
2321
|
+
* Business service with explicit error handling via Result type.
|
|
2322
|
+
*
|
|
2323
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2324
|
+
*
|
|
2325
|
+
* @example
|
|
2326
|
+
* ```typescript
|
|
2327
|
+
* const result = await client.business.getInfo();
|
|
2328
|
+
*
|
|
2329
|
+
* if (result.ok) {
|
|
2330
|
+
* console.log("Business:", result.value.name);
|
|
2331
|
+
* } else {
|
|
2332
|
+
* console.error("Failed:", result.error.code);
|
|
2333
|
+
* }
|
|
2334
|
+
* ```
|
|
2335
|
+
*/
|
|
2032
2336
|
declare class BusinessService {
|
|
2033
2337
|
private client;
|
|
2034
2338
|
constructor(client: CimplifyClient);
|
|
2035
|
-
getInfo(): Promise<Business
|
|
2036
|
-
getByHandle(handle: string): Promise<Business
|
|
2037
|
-
getByDomain(domain: string): Promise<Business
|
|
2038
|
-
getSettings(): Promise<BusinessSettings
|
|
2039
|
-
getTheme(): Promise<Record<string, unknown>>;
|
|
2040
|
-
getLocations(): Promise<Location[]
|
|
2041
|
-
getLocation(locationId: string): Promise<Location
|
|
2042
|
-
getHours(): Promise<BusinessHours[]
|
|
2043
|
-
getLocationHours(locationId: string): Promise<BusinessHours[]
|
|
2044
|
-
getBootstrap(): Promise<StorefrontBootstrap
|
|
2339
|
+
getInfo(): Promise<Result<Business, CimplifyError>>;
|
|
2340
|
+
getByHandle(handle: string): Promise<Result<Business, CimplifyError>>;
|
|
2341
|
+
getByDomain(domain: string): Promise<Result<Business, CimplifyError>>;
|
|
2342
|
+
getSettings(): Promise<Result<BusinessSettings, CimplifyError>>;
|
|
2343
|
+
getTheme(): Promise<Result<Record<string, unknown>, CimplifyError>>;
|
|
2344
|
+
getLocations(): Promise<Result<Location[], CimplifyError>>;
|
|
2345
|
+
getLocation(locationId: string): Promise<Result<Location, CimplifyError>>;
|
|
2346
|
+
getHours(): Promise<Result<BusinessHours[], CimplifyError>>;
|
|
2347
|
+
getLocationHours(locationId: string): Promise<Result<BusinessHours[], CimplifyError>>;
|
|
2348
|
+
getBootstrap(): Promise<Result<StorefrontBootstrap, CimplifyError>>;
|
|
2045
2349
|
}
|
|
2046
2350
|
|
|
2047
2351
|
type StockOwnershipType = "owned" | "consignment" | "dropship";
|
|
@@ -2132,22 +2436,38 @@ interface InventorySummary {
|
|
|
2132
2436
|
total_value?: Money;
|
|
2133
2437
|
}
|
|
2134
2438
|
|
|
2439
|
+
/**
|
|
2440
|
+
* Inventory service with explicit error handling via Result type.
|
|
2441
|
+
*
|
|
2442
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2443
|
+
*
|
|
2444
|
+
* @example
|
|
2445
|
+
* ```typescript
|
|
2446
|
+
* const result = await client.inventory.isInStock("prod_123");
|
|
2447
|
+
*
|
|
2448
|
+
* if (result.ok) {
|
|
2449
|
+
* console.log("In stock:", result.value);
|
|
2450
|
+
* } else {
|
|
2451
|
+
* console.error("Failed:", result.error.code);
|
|
2452
|
+
* }
|
|
2453
|
+
* ```
|
|
2454
|
+
*/
|
|
2135
2455
|
declare class InventoryService {
|
|
2136
2456
|
private client;
|
|
2137
2457
|
constructor(client: CimplifyClient);
|
|
2138
|
-
getStockLevels(): Promise<StockLevel[]
|
|
2139
|
-
getProductStock(productId: string, locationId?: string): Promise<ProductStock
|
|
2140
|
-
getVariantStock(variantId: string, locationId?: string): Promise<StockLevel
|
|
2141
|
-
checkProductAvailability(productId: string, quantity: number, locationId?: string): Promise<AvailabilityResult
|
|
2142
|
-
checkVariantAvailability(variantId: string, quantity: number, locationId?: string): Promise<AvailabilityResult
|
|
2458
|
+
getStockLevels(): Promise<Result<StockLevel[], CimplifyError>>;
|
|
2459
|
+
getProductStock(productId: string, locationId?: string): Promise<Result<ProductStock, CimplifyError>>;
|
|
2460
|
+
getVariantStock(variantId: string, locationId?: string): Promise<Result<StockLevel, CimplifyError>>;
|
|
2461
|
+
checkProductAvailability(productId: string, quantity: number, locationId?: string): Promise<Result<AvailabilityResult, CimplifyError>>;
|
|
2462
|
+
checkVariantAvailability(variantId: string, quantity: number, locationId?: string): Promise<Result<AvailabilityResult, CimplifyError>>;
|
|
2143
2463
|
checkMultipleAvailability(items: {
|
|
2144
2464
|
product_id: string;
|
|
2145
2465
|
variant_id?: string;
|
|
2146
2466
|
quantity: number;
|
|
2147
|
-
}[], locationId?: string): Promise<AvailabilityResult[]
|
|
2148
|
-
getSummary(): Promise<InventorySummary
|
|
2149
|
-
isInStock(productId: string, locationId?: string): Promise<boolean
|
|
2150
|
-
getAvailableQuantity(productId: string, locationId?: string): Promise<number
|
|
2467
|
+
}[], locationId?: string): Promise<Result<AvailabilityResult[], CimplifyError>>;
|
|
2468
|
+
getSummary(): Promise<Result<InventorySummary, CimplifyError>>;
|
|
2469
|
+
isInStock(productId: string, locationId?: string): Promise<Result<boolean, CimplifyError>>;
|
|
2470
|
+
getAvailableQuantity(productId: string, locationId?: string): Promise<Result<number, CimplifyError>>;
|
|
2151
2471
|
}
|
|
2152
2472
|
|
|
2153
2473
|
interface ServiceAvailabilityRule {
|
|
@@ -2390,29 +2710,48 @@ interface ServiceAvailabilityResult {
|
|
|
2390
2710
|
days: DayAvailability[];
|
|
2391
2711
|
}
|
|
2392
2712
|
|
|
2713
|
+
/**
|
|
2714
|
+
* Scheduling service with explicit error handling via Result type.
|
|
2715
|
+
*
|
|
2716
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2717
|
+
*
|
|
2718
|
+
* @example
|
|
2719
|
+
* ```typescript
|
|
2720
|
+
* const result = await client.scheduling.getAvailableSlots({
|
|
2721
|
+
* service_id: "svc_haircut",
|
|
2722
|
+
* date: "2024-01-15"
|
|
2723
|
+
* });
|
|
2724
|
+
*
|
|
2725
|
+
* if (result.ok) {
|
|
2726
|
+
* console.log("Available slots:", result.value);
|
|
2727
|
+
* } else {
|
|
2728
|
+
* console.error("Failed:", result.error.code);
|
|
2729
|
+
* }
|
|
2730
|
+
* ```
|
|
2731
|
+
*/
|
|
2393
2732
|
declare class SchedulingService {
|
|
2394
2733
|
private client;
|
|
2395
2734
|
constructor(client: CimplifyClient);
|
|
2396
|
-
getServices(): Promise<Service[]
|
|
2735
|
+
getServices(): Promise<Result<Service[], CimplifyError>>;
|
|
2397
2736
|
/**
|
|
2398
2737
|
* Get a specific service by ID
|
|
2399
2738
|
* Note: Filters from all services client-side (no single-service endpoint)
|
|
2400
2739
|
*/
|
|
2401
|
-
getService(serviceId: string): Promise<Service | null
|
|
2402
|
-
getAvailableSlots(input: GetAvailableSlotsInput): Promise<AvailableSlot[]
|
|
2403
|
-
checkSlotAvailability(input: CheckSlotAvailabilityInput): Promise<{
|
|
2740
|
+
getService(serviceId: string): Promise<Result<Service | null, CimplifyError>>;
|
|
2741
|
+
getAvailableSlots(input: GetAvailableSlotsInput): Promise<Result<AvailableSlot[], CimplifyError>>;
|
|
2742
|
+
checkSlotAvailability(input: CheckSlotAvailabilityInput): Promise<Result<{
|
|
2404
2743
|
available: boolean;
|
|
2405
2744
|
reason?: string;
|
|
2406
|
-
}
|
|
2407
|
-
getServiceAvailability(params: ServiceAvailabilityParams): Promise<ServiceAvailabilityResult
|
|
2408
|
-
getBooking(bookingId: string): Promise<BookingWithDetails
|
|
2409
|
-
getCustomerBookings(): Promise<Booking[]
|
|
2410
|
-
getUpcomingBookings(): Promise<Booking[]
|
|
2411
|
-
getPastBookings(limit?: number): Promise<Booking[]
|
|
2412
|
-
cancelBooking(input: CancelBookingInput): Promise<Booking
|
|
2413
|
-
rescheduleBooking(input: RescheduleBookingInput): Promise<Booking
|
|
2414
|
-
getNextAvailableSlot(serviceId: string, fromDate?: string): Promise<AvailableSlot | null
|
|
2415
|
-
hasAvailabilityOn(serviceId: string, date: string): Promise<boolean
|
|
2745
|
+
}, CimplifyError>>;
|
|
2746
|
+
getServiceAvailability(params: ServiceAvailabilityParams): Promise<Result<ServiceAvailabilityResult, CimplifyError>>;
|
|
2747
|
+
getBooking(bookingId: string): Promise<Result<BookingWithDetails, CimplifyError>>;
|
|
2748
|
+
getCustomerBookings(): Promise<Result<Booking[], CimplifyError>>;
|
|
2749
|
+
getUpcomingBookings(): Promise<Result<Booking[], CimplifyError>>;
|
|
2750
|
+
getPastBookings(limit?: number): Promise<Result<Booking[], CimplifyError>>;
|
|
2751
|
+
cancelBooking(input: CancelBookingInput): Promise<Result<Booking, CimplifyError>>;
|
|
2752
|
+
rescheduleBooking(input: RescheduleBookingInput): Promise<Result<Booking, CimplifyError>>;
|
|
2753
|
+
getNextAvailableSlot(serviceId: string, fromDate?: string): Promise<Result<AvailableSlot | null, CimplifyError>>;
|
|
2754
|
+
hasAvailabilityOn(serviceId: string, date: string): Promise<Result<boolean, CimplifyError>>;
|
|
2416
2755
|
}
|
|
2417
2756
|
|
|
2418
2757
|
interface LiteBootstrap {
|
|
@@ -2445,22 +2784,41 @@ interface KitchenOrderResult {
|
|
|
2445
2784
|
order_number: string;
|
|
2446
2785
|
estimated_time_minutes?: number;
|
|
2447
2786
|
}
|
|
2787
|
+
interface SuccessResult {
|
|
2788
|
+
success: boolean;
|
|
2789
|
+
}
|
|
2790
|
+
interface RequestBillResult {
|
|
2791
|
+
success: boolean;
|
|
2792
|
+
order_id: string;
|
|
2793
|
+
}
|
|
2794
|
+
/**
|
|
2795
|
+
* Lite service for QR code ordering with explicit error handling via Result type.
|
|
2796
|
+
*
|
|
2797
|
+
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2798
|
+
*
|
|
2799
|
+
* @example
|
|
2800
|
+
* ```typescript
|
|
2801
|
+
* const result = await client.lite.getBootstrap();
|
|
2802
|
+
*
|
|
2803
|
+
* if (result.ok) {
|
|
2804
|
+
* console.log("Business:", result.value.business.name);
|
|
2805
|
+
* console.log("Table:", result.value.table?.number);
|
|
2806
|
+
* } else {
|
|
2807
|
+
* console.error("Failed:", result.error.code);
|
|
2808
|
+
* }
|
|
2809
|
+
* ```
|
|
2810
|
+
*/
|
|
2448
2811
|
declare class LiteService {
|
|
2449
2812
|
private client;
|
|
2450
2813
|
constructor(client: CimplifyClient);
|
|
2451
|
-
getBootstrap(): Promise<LiteBootstrap
|
|
2452
|
-
getTable(tableId: string): Promise<TableInfo
|
|
2453
|
-
getTableByNumber(tableNumber: string, locationId?: string): Promise<TableInfo
|
|
2454
|
-
sendToKitchen(tableId: string, items: KitchenOrderItem[]): Promise<KitchenOrderResult
|
|
2455
|
-
callWaiter(tableId: string, reason?: string): Promise<
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
success: boolean;
|
|
2460
|
-
order_id: string;
|
|
2461
|
-
}>;
|
|
2462
|
-
getMenu(): Promise<Product[]>;
|
|
2463
|
-
getMenuByCategory(categoryId: string): Promise<Product[]>;
|
|
2814
|
+
getBootstrap(): Promise<Result<LiteBootstrap, CimplifyError>>;
|
|
2815
|
+
getTable(tableId: string): Promise<Result<TableInfo, CimplifyError>>;
|
|
2816
|
+
getTableByNumber(tableNumber: string, locationId?: string): Promise<Result<TableInfo, CimplifyError>>;
|
|
2817
|
+
sendToKitchen(tableId: string, items: KitchenOrderItem[]): Promise<Result<KitchenOrderResult, CimplifyError>>;
|
|
2818
|
+
callWaiter(tableId: string, reason?: string): Promise<Result<SuccessResult, CimplifyError>>;
|
|
2819
|
+
requestBill(tableId: string): Promise<Result<RequestBillResult, CimplifyError>>;
|
|
2820
|
+
getMenu(): Promise<Result<Product[], CimplifyError>>;
|
|
2821
|
+
getMenuByCategory(categoryId: string): Promise<Result<Product[], CimplifyError>>;
|
|
2464
2822
|
}
|
|
2465
2823
|
|
|
2466
2824
|
interface CimplifyConfig {
|
|
@@ -3034,4 +3392,4 @@ interface ApiResponse<T> {
|
|
|
3034
3392
|
metadata?: ResponseMetadata;
|
|
3035
3393
|
}
|
|
3036
3394
|
|
|
3037
|
-
export { AUTHORIZATION_TYPE, AUTH_MUTATION, type AddOn, type AddOnDetails, type AddOnGroupDetails, type AddOnOption, type AddOnOptionDetails, type AddOnOptionPrice, type AddOnWithOptions, type AddToCartInput, type AddressData, type AdjustmentType, type AmountToPay, type ApiError, type ApiResponse, type AppliedDiscount, type AuthResponse, AuthService, type AuthStatus, type AuthorizationType, type AvailabilityCheck, type AvailabilityResult, type AvailableSlot, type BenefitType, type Booking, type BookingRequirementOverride, type BookingStatus, type BookingWithDetails, type BufferTimes, type Bundle, type BundleComponentData, type BundleComponentInfo, type BundlePriceType, type BundleProduct, type BundleSelectionData, type BundleSelectionInput, type BundleStoredSelection, type BundleSummary, type BundleWithDetails, type Business, type BusinessHours, type BusinessPreferences, BusinessService, type BusinessSettings, type BusinessType, type BusinessWithLocations, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CURRENCY_SYMBOLS, type CancelBookingInput, type CancelOrderInput, type CancellationPolicy, type Cart, type CartAddOn, type CartChannel, type CartItem, type CartItemDetails, CartOperations, type CartStatus, type CartSummary, type CartTotals, CatalogueQueries, type Category, type CategoryInfo, type CategorySummary, type ChangePasswordInput, type CheckSlotAvailabilityInput, type CheckoutAddressInfo, type CheckoutCustomerInfo, type CheckoutFormData, type CheckoutInput, type CheckoutMode, CheckoutService as CheckoutOperations, type CheckoutOrderType, type CheckoutPaymentMethod, type CheckoutResult, CheckoutService, type CheckoutStep, type ChosenPrice, CimplifyClient, type CimplifyConfig, CimplifyError, type Collection, type CollectionProduct, type CollectionSummary, type ComponentGroup, type ComponentGroupWithComponents, type ComponentPriceBreakdown, type ComponentSelectionInput, type ComponentSourceType, type Composite, type CompositeComponent, type CompositePriceBreakdown, type CompositePriceResult, type CompositePricingMode, type CompositeSelectionData, type ComponentSelectionInput as CompositeSelectionInput, type CompositeStoredSelection, type CompositeWithDetails, type ContactType, type CreateAddressInput, type CreateMobileMoneyInput, type Currency, type Customer, type CustomerAddress, type CustomerLinkPreferences, type CustomerMobileMoney, type CustomerServicePreferences, DEFAULT_COUNTRY, DEFAULT_CURRENCY, type DayAvailability, type DepositResult, type DepositType, type DeviceType, type DigitalProductType, type DiscountBreakdown, type DiscountDetails, type DisplayAddOn, type DisplayAddOnOption, type DisplayCart, type DisplayCartItem, type EnrollAndLinkOrderInput, type EnrollAndLinkOrderResult, type EnrollmentData, ErrorCode, type ErrorCodeType, type FeeBearerType, type FormatCompactOptions, type FormatPriceOptions, type FulfillmentLink, type FulfillmentStatus, type FulfillmentType, type GetAvailableSlotsInput, type GetOrdersOptions, type GetProductsOptions, type GroupPricingBehavior, type InitializePaymentResult, InventoryService, type InventorySummary, type InventoryType, type KitchenOrderItem, type KitchenOrderResult, LINK_MUTATION, LINK_QUERY, type LineConfiguration, type LineItem, type LineType, type LinkData, type LinkEnrollResult, LinkService, type LinkSession, type LinkStatusResult, type LiteBootstrap, LiteService, type Location, type LocationAppointment, type LocationProductPrice, type LocationStock, type LocationTaxBehavior, type LocationTaxOverrides, type LocationTimeProfile, type LocationWithDetails, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, type MobileMoneyData, type MobileMoneyDetails, type MobileMoneyProvider, type Money, type MutationRequest, ORDER_MUTATION, ORDER_TYPE, type Order, type OrderChannel, type OrderFilter, type OrderFulfillmentSummary, type OrderGroup, type OrderGroupDetails, type OrderGroupPayment, type OrderGroupPaymentState, type OrderGroupPaymentSummary, type OrderHistory, type OrderLineState, type OrderLineStatus, type OrderPaymentEvent, OrderQueries, type OrderSplitDetail, type OrderStatus, type OtpResult, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, type Pagination, type PaginationParams, type ParsedPrice, type Payment, type PaymentErrorDetails, type PaymentMethod, type PaymentMethodType, type PaymentProcessingState, type PaymentProvider, type PaymentResponse, type PaymentState, type PaymentStatus, type PaymentStatusResponse, type PickupTime, type PickupTimeType, type Price, type PriceAdjustment, type PriceDecisionPath, type PriceEntryType, type PriceInfo, type PricePathTaxInfo, type PriceSource, type PricingOverrides, type Product, type ProductAddOn, type ProductAvailability, type ProductStock, type ProductTimeProfile, type ProductType, type ProductVariant, type ProductVariantValue, type ProductWithDetails, type ProductWithPrice, QueryBuilder, type QueryRequest, type RefundOrderInput, type ReminderMethod, type ReminderSettings, type RequestOtpInput, type RescheduleBookingInput, type ResourceAssignment, type ResourceAvailabilityException, type ResourceAvailabilityRule, type ResourceType, type ResponseMetadata, type RevokeAllSessionsResult, type RevokeSessionResult, type Room, type SalesChannel, type SchedulingMetadata, type SchedulingResult, SchedulingService, type SearchOptions, type SelectedAddOnOption, type Service, type ServiceAvailabilityException, type ServiceAvailabilityParams, type ServiceAvailabilityResult, type ServiceAvailabilityRule, type ServiceCharge, type ServiceNotes, type ServiceScheduleRequest, type ServiceStaffRequirement, type ServiceStatus, type ServiceWithStaff, type Staff, type StaffAssignment, type StaffAvailabilityException, type StaffAvailabilityRule, type StaffBookingProfile, type StaffRole, type StaffScheduleItem, type Stock, type StockLevel, type StockOwnershipType, type StockStatus, type StorefrontBootstrap, type SubmitAuthorizationInput, type Table, type TableInfo, type TaxComponent, type TaxInfo, type TaxPathComponent, type TimeRange, type TimeRanges, type TimeSlot, type UICart, type UICartBusiness, type UICartCustomer, type UICartLocation, type UICartPricing, type UpdateAddressInput, type UpdateCartItemInput, type UpdateOrderStatusInput, type UpdateProfileInput, type VariantAxis, type VariantAxisSelection, type VariantAxisValue, type VariantAxisWithValues, type VariantDetails, type VariantDetailsDTO, type VariantDisplayAttribute, type VariantLocationAvailability, type VariantStock, type VariantStrategy, type VerifyOtpInput, 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 };
|
|
3395
|
+
export { AUTHORIZATION_TYPE, AUTH_MUTATION, type AddOn, type AddOnDetails, type AddOnGroupDetails, type AddOnOption, type AddOnOptionDetails, type AddOnOptionPrice, type AddOnWithOptions, type AddToCartInput, type AddressData, type AdjustmentType, type AmountToPay, type ApiError, type ApiResponse, type AppliedDiscount, type AuthResponse, AuthService, type AuthStatus, type AuthorizationType, type AvailabilityCheck, type AvailabilityResult, type AvailableSlot, type BenefitType, type Booking, type BookingRequirementOverride, type BookingStatus, type BookingWithDetails, type BufferTimes, type Bundle, type BundleComponentData, type BundleComponentInfo, type BundlePriceType, type BundleProduct, type BundleSelectionData, type BundleSelectionInput, type BundleStoredSelection, type BundleSummary, type BundleWithDetails, type Business, type BusinessHours, type BusinessPreferences, BusinessService, type BusinessSettings, type BusinessType, type BusinessWithLocations, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CURRENCY_SYMBOLS, type CancelBookingInput, type CancelOrderInput, type CancellationPolicy, type Cart, type CartAddOn, type CartChannel, type CartItem, type CartItemDetails, CartOperations, type CartStatus, type CartSummary, type CartTotals, CatalogueQueries, type Category, type CategoryInfo, type CategorySummary, type ChangePasswordInput, type CheckSlotAvailabilityInput, type CheckoutAddressInfo, type CheckoutCustomerInfo, type CheckoutFormData, type CheckoutInput, type CheckoutMode, CheckoutService as CheckoutOperations, type CheckoutOrderType, type CheckoutPaymentMethod, type CheckoutResult, CheckoutService, type CheckoutStep, type ChosenPrice, CimplifyClient, type CimplifyConfig, CimplifyError, type Collection, type CollectionProduct, type CollectionSummary, type ComponentGroup, type ComponentGroupWithComponents, type ComponentPriceBreakdown, type ComponentSelectionInput, type ComponentSourceType, type Composite, type CompositeComponent, type CompositePriceBreakdown, type CompositePriceResult, type CompositePricingMode, type CompositeSelectionData, type ComponentSelectionInput as CompositeSelectionInput, type CompositeStoredSelection, type CompositeWithDetails, type ContactType, type CreateAddressInput, type CreateMobileMoneyInput, type Currency, type Customer, type CustomerAddress, type CustomerLinkPreferences, type CustomerMobileMoney, type CustomerServicePreferences, DEFAULT_COUNTRY, DEFAULT_CURRENCY, type DayAvailability, type DepositResult, type DepositType, type DeviceType, type DigitalProductType, type DiscountBreakdown, type DiscountDetails, type DisplayAddOn, type DisplayAddOnOption, type DisplayCart, type DisplayCartItem, type EnrollAndLinkOrderInput, type EnrollAndLinkOrderResult, type EnrollmentData, type Err, ErrorCode, type ErrorCodeType, type FeeBearerType, type FormatCompactOptions, type FormatPriceOptions, type FulfillmentLink, type FulfillmentStatus, type FulfillmentType, type GetAvailableSlotsInput, type GetOrdersOptions, type GetProductsOptions, type GroupPricingBehavior, type InitializePaymentResult, InventoryService, type InventorySummary, type InventoryType, type KitchenOrderItem, type KitchenOrderResult, LINK_MUTATION, LINK_QUERY, type LineConfiguration, type LineItem, type LineType, type LinkData, type LinkEnrollResult, LinkService, type LinkSession, type LinkStatusResult, type LiteBootstrap, LiteService, type Location, type LocationAppointment, type LocationProductPrice, type LocationStock, type LocationTaxBehavior, type LocationTaxOverrides, type LocationTimeProfile, type LocationWithDetails, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, type MobileMoneyData, type MobileMoneyDetails, type MobileMoneyProvider, type Money, type MutationRequest, ORDER_MUTATION, ORDER_TYPE, type Ok, type Order, type OrderChannel, type OrderFilter, type OrderFulfillmentSummary, type OrderGroup, type OrderGroupDetails, type OrderGroupPayment, type OrderGroupPaymentState, type OrderGroupPaymentSummary, type OrderHistory, type OrderLineState, type OrderLineStatus, type OrderPaymentEvent, OrderQueries, type OrderSplitDetail, type OrderStatus, type OtpResult, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, type Pagination, type PaginationParams, type ParsedPrice, type Payment, type PaymentErrorDetails, type PaymentMethod, type PaymentMethodType, type PaymentProcessingState, type PaymentProvider, type PaymentResponse, type PaymentState, type PaymentStatus, type PaymentStatusResponse, type PickupTime, type PickupTimeType, type Price, type PriceAdjustment, type PriceDecisionPath, type PriceEntryType, type PriceInfo, type PricePathTaxInfo, type PriceSource, type PricingOverrides, type Product, type ProductAddOn, type ProductAvailability, type ProductStock, type ProductTimeProfile, type ProductType, type ProductVariant, type ProductVariantValue, type ProductWithDetails, type ProductWithPrice, QueryBuilder, type QueryRequest, type RefundOrderInput, type ReminderMethod, type ReminderSettings, type RequestOtpInput, type RescheduleBookingInput, type ResourceAssignment, type ResourceAvailabilityException, type ResourceAvailabilityRule, type ResourceType, type ResponseMetadata, type Result, type RevokeAllSessionsResult, type RevokeSessionResult, type Room, type SalesChannel, type SchedulingMetadata, type SchedulingResult, SchedulingService, type SearchOptions, type SelectedAddOnOption, type Service, type ServiceAvailabilityException, type ServiceAvailabilityParams, type ServiceAvailabilityResult, type ServiceAvailabilityRule, type ServiceCharge, type ServiceNotes, type ServiceScheduleRequest, type ServiceStaffRequirement, type ServiceStatus, type ServiceWithStaff, type Staff, type StaffAssignment, type StaffAvailabilityException, type StaffAvailabilityRule, type StaffBookingProfile, type StaffRole, type StaffScheduleItem, type Stock, type StockLevel, type StockOwnershipType, type StockStatus, type StorefrontBootstrap, type SubmitAuthorizationInput, type Table, type TableInfo, type TaxComponent, type TaxInfo, type TaxPathComponent, type TimeRange, type TimeRanges, type TimeSlot, type UICart, type UICartBusiness, type UICartCustomer, type UICartLocation, type UICartPricing, type UpdateAddressInput, type UpdateCartItemInput, type UpdateOrderStatusInput, type UpdateProfileInput, type VariantAxis, type VariantAxisSelection, type VariantAxisValue, type VariantAxisWithValues, type VariantDetails, type VariantDetailsDTO, type VariantDisplayAttribute, type VariantLocationAvailability, type VariantStock, type VariantStrategy, type VerifyOtpInput, 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 };
|