@cimplify/sdk 0.3.5 → 0.3.6
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 +0 -153
- package/dist/index.d.ts +0 -153
- package/dist/index.js +0 -204
- package/dist/index.mjs +0 -204
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -796,22 +796,6 @@ interface SearchOptions {
|
|
|
796
796
|
limit?: number;
|
|
797
797
|
category?: string;
|
|
798
798
|
}
|
|
799
|
-
/**
|
|
800
|
-
* Catalogue queries with explicit error handling via Result type.
|
|
801
|
-
*
|
|
802
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
803
|
-
*
|
|
804
|
-
* @example
|
|
805
|
-
* ```typescript
|
|
806
|
-
* const result = await client.catalogue.getProducts({ category: "burgers" });
|
|
807
|
-
*
|
|
808
|
-
* if (result.ok) {
|
|
809
|
-
* console.log("Products:", result.value);
|
|
810
|
-
* } else {
|
|
811
|
-
* console.error("Failed:", result.error.code);
|
|
812
|
-
* }
|
|
813
|
-
* ```
|
|
814
|
-
*/
|
|
815
799
|
declare class CatalogueQueries {
|
|
816
800
|
private client;
|
|
817
801
|
constructor(client: CimplifyClient);
|
|
@@ -1333,59 +1317,15 @@ interface CartSummary {
|
|
|
1333
1317
|
currency: string;
|
|
1334
1318
|
}
|
|
1335
1319
|
|
|
1336
|
-
/**
|
|
1337
|
-
* Cart operations with explicit error handling via Result type.
|
|
1338
|
-
*
|
|
1339
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1340
|
-
*
|
|
1341
|
-
* @example
|
|
1342
|
-
* ```typescript
|
|
1343
|
-
* const result = await client.cart.addItem({ item_id: "prod_123" });
|
|
1344
|
-
*
|
|
1345
|
-
* if (result.ok) {
|
|
1346
|
-
* console.log("Added!", result.value);
|
|
1347
|
-
* } else {
|
|
1348
|
-
* console.error("Failed:", result.error.code);
|
|
1349
|
-
* }
|
|
1350
|
-
* ```
|
|
1351
|
-
*/
|
|
1352
1320
|
declare class CartOperations {
|
|
1353
1321
|
private client;
|
|
1354
1322
|
constructor(client: CimplifyClient);
|
|
1355
|
-
/**
|
|
1356
|
-
* Get the enriched cart with product names, images, and details.
|
|
1357
|
-
* This is the main method for storefront display.
|
|
1358
|
-
*/
|
|
1359
1323
|
get(): Promise<Result<UICart, CimplifyError>>;
|
|
1360
1324
|
getRaw(): Promise<Result<Cart, CimplifyError>>;
|
|
1361
1325
|
getItems(): Promise<Result<CartItem[], CimplifyError>>;
|
|
1362
1326
|
getCount(): Promise<Result<number, CimplifyError>>;
|
|
1363
1327
|
getTotal(): Promise<Result<string, CimplifyError>>;
|
|
1364
1328
|
getSummary(): Promise<Result<CartSummary, CimplifyError>>;
|
|
1365
|
-
/**
|
|
1366
|
-
* Add an item to the cart.
|
|
1367
|
-
*
|
|
1368
|
-
* @example
|
|
1369
|
-
* ```typescript
|
|
1370
|
-
* const result = await client.cart.addItem({
|
|
1371
|
-
* item_id: "prod_burger",
|
|
1372
|
-
* quantity: 2,
|
|
1373
|
-
* variant_id: "var_large",
|
|
1374
|
-
* add_on_options: ["addon_cheese", "addon_bacon"],
|
|
1375
|
-
* });
|
|
1376
|
-
*
|
|
1377
|
-
* if (!result.ok) {
|
|
1378
|
-
* switch (result.error.code) {
|
|
1379
|
-
* case ErrorCode.ITEM_UNAVAILABLE:
|
|
1380
|
-
* toast.error("Item no longer available");
|
|
1381
|
-
* break;
|
|
1382
|
-
* case ErrorCode.VARIANT_OUT_OF_STOCK:
|
|
1383
|
-
* toast.error("Selected option is out of stock");
|
|
1384
|
-
* break;
|
|
1385
|
-
* }
|
|
1386
|
-
* }
|
|
1387
|
-
* ```
|
|
1388
|
-
*/
|
|
1389
1329
|
addItem(input: AddToCartInput): Promise<Result<Cart, CimplifyError>>;
|
|
1390
1330
|
updateItem(cartItemId: string, updates: UpdateCartItemInput): Promise<Result<Cart, CimplifyError>>;
|
|
1391
1331
|
updateQuantity(cartItemId: string, quantity: number): Promise<Result<Cart, CimplifyError>>;
|
|
@@ -2064,64 +2004,10 @@ interface CheckoutResult {
|
|
|
2064
2004
|
public_key?: string;
|
|
2065
2005
|
}
|
|
2066
2006
|
|
|
2067
|
-
/**
|
|
2068
|
-
* Generate a cryptographically secure idempotency key.
|
|
2069
|
-
* Uses crypto.randomUUID if available, falls back to timestamp + random.
|
|
2070
|
-
*/
|
|
2071
2007
|
declare function generateIdempotencyKey(): string;
|
|
2072
|
-
/**
|
|
2073
|
-
* Checkout service with explicit error handling via Result type.
|
|
2074
|
-
*
|
|
2075
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2076
|
-
*
|
|
2077
|
-
* @example
|
|
2078
|
-
* ```typescript
|
|
2079
|
-
* const result = await client.checkout.process(formData);
|
|
2080
|
-
*
|
|
2081
|
-
* if (result.ok) {
|
|
2082
|
-
* const checkout = result.value;
|
|
2083
|
-
* if (checkout.requires_authorization) {
|
|
2084
|
-
* // Handle OTP flow
|
|
2085
|
-
* } else if (checkout.client_secret) {
|
|
2086
|
-
* // Open Paystack popup
|
|
2087
|
-
* }
|
|
2088
|
-
* } else {
|
|
2089
|
-
* toast.error(result.error.message);
|
|
2090
|
-
* }
|
|
2091
|
-
* ```
|
|
2092
|
-
*/
|
|
2093
2008
|
declare class CheckoutService {
|
|
2094
2009
|
private client;
|
|
2095
2010
|
constructor(client: CimplifyClient);
|
|
2096
|
-
/**
|
|
2097
|
-
* Process checkout with cart data.
|
|
2098
|
-
*
|
|
2099
|
-
* Automatically generates an idempotency key if not provided to ensure
|
|
2100
|
-
* payment safety. The same key is used across retries, preventing
|
|
2101
|
-
* duplicate charges if a network error occurs after payment processing.
|
|
2102
|
-
*
|
|
2103
|
-
* @example
|
|
2104
|
-
* ```typescript
|
|
2105
|
-
* const result = await client.checkout.process({
|
|
2106
|
-
* cart_id: cart.id,
|
|
2107
|
-
* customer: { name, email, phone, save_details: true },
|
|
2108
|
-
* order_type: "pickup",
|
|
2109
|
-
* payment_method: "mobile_money",
|
|
2110
|
-
* mobile_money_details: { phone_number, provider: "mtn" },
|
|
2111
|
-
* });
|
|
2112
|
-
*
|
|
2113
|
-
* if (!result.ok) {
|
|
2114
|
-
* switch (result.error.code) {
|
|
2115
|
-
* case ErrorCode.CART_EMPTY:
|
|
2116
|
-
* toast.error("Your cart is empty");
|
|
2117
|
-
* break;
|
|
2118
|
-
* case ErrorCode.PAYMENT_FAILED:
|
|
2119
|
-
* toast.error("Payment failed. Please try again.");
|
|
2120
|
-
* break;
|
|
2121
|
-
* }
|
|
2122
|
-
* }
|
|
2123
|
-
* ```
|
|
2124
|
-
*/
|
|
2125
2011
|
process(data: CheckoutFormData): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
2126
2012
|
initializePayment(orderId: string, method: PaymentMethod): Promise<Result<InitializePaymentResult, CimplifyError>>;
|
|
2127
2013
|
submitAuthorization(input: SubmitAuthorizationInput): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
@@ -2228,24 +2114,6 @@ interface ChangePasswordInput {
|
|
|
2228
2114
|
interface SuccessResult$1 {
|
|
2229
2115
|
success: boolean;
|
|
2230
2116
|
}
|
|
2231
|
-
/**
|
|
2232
|
-
* Auth service with explicit error handling via Result type.
|
|
2233
|
-
*
|
|
2234
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2235
|
-
*
|
|
2236
|
-
* @example
|
|
2237
|
-
* ```typescript
|
|
2238
|
-
* const result = await client.auth.verifyOtp("123456");
|
|
2239
|
-
*
|
|
2240
|
-
* if (result.ok) {
|
|
2241
|
-
* console.log("Logged in as:", result.value.customer.name);
|
|
2242
|
-
* } else {
|
|
2243
|
-
* if (result.error.code === "INVALID_OTP") {
|
|
2244
|
-
* toast.error("Invalid code. Please try again.");
|
|
2245
|
-
* }
|
|
2246
|
-
* }
|
|
2247
|
-
* ```
|
|
2248
|
-
*/
|
|
2249
2117
|
declare class AuthService {
|
|
2250
2118
|
private client;
|
|
2251
2119
|
constructor(client: CimplifyClient);
|
|
@@ -2944,7 +2812,6 @@ declare class CimplifyClient {
|
|
|
2944
2812
|
private maxRetries;
|
|
2945
2813
|
private retryDelay;
|
|
2946
2814
|
private hooks;
|
|
2947
|
-
/** In-flight request deduplication map */
|
|
2948
2815
|
private inflightRequests;
|
|
2949
2816
|
private _catalogue?;
|
|
2950
2817
|
private _cart?;
|
|
@@ -2964,30 +2831,10 @@ declare class CimplifyClient {
|
|
|
2964
2831
|
private saveSessionToken;
|
|
2965
2832
|
private getHeaders;
|
|
2966
2833
|
private updateSessionFromResponse;
|
|
2967
|
-
/**
|
|
2968
|
-
* Resilient fetch with timeout, automatic retries, and observability hooks.
|
|
2969
|
-
* Uses exponential backoff: 1s, 2s, 4s between retries.
|
|
2970
|
-
*/
|
|
2971
2834
|
private resilientFetch;
|
|
2972
|
-
/**
|
|
2973
|
-
* Generate a deduplication key for a request.
|
|
2974
|
-
* Same query + variables = same key = deduplicated.
|
|
2975
|
-
*/
|
|
2976
2835
|
private getDedupeKey;
|
|
2977
|
-
/**
|
|
2978
|
-
* Execute a request with deduplication.
|
|
2979
|
-
* If an identical request is already in-flight, return the same promise.
|
|
2980
|
-
* This prevents redundant network calls when multiple components request the same data.
|
|
2981
|
-
*/
|
|
2982
2836
|
private deduplicatedRequest;
|
|
2983
|
-
/**
|
|
2984
|
-
* Execute a query with deduplication.
|
|
2985
|
-
* Multiple identical queries made simultaneously will share a single network request.
|
|
2986
|
-
*/
|
|
2987
2837
|
query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
2988
|
-
/**
|
|
2989
|
-
* Execute a mutation. NOT deduplicated - mutations have side effects.
|
|
2990
|
-
*/
|
|
2991
2838
|
call<T = unknown>(method: string, args?: unknown): Promise<T>;
|
|
2992
2839
|
get<T = unknown>(path: string): Promise<T>;
|
|
2993
2840
|
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
package/dist/index.d.ts
CHANGED
|
@@ -796,22 +796,6 @@ interface SearchOptions {
|
|
|
796
796
|
limit?: number;
|
|
797
797
|
category?: string;
|
|
798
798
|
}
|
|
799
|
-
/**
|
|
800
|
-
* Catalogue queries with explicit error handling via Result type.
|
|
801
|
-
*
|
|
802
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
803
|
-
*
|
|
804
|
-
* @example
|
|
805
|
-
* ```typescript
|
|
806
|
-
* const result = await client.catalogue.getProducts({ category: "burgers" });
|
|
807
|
-
*
|
|
808
|
-
* if (result.ok) {
|
|
809
|
-
* console.log("Products:", result.value);
|
|
810
|
-
* } else {
|
|
811
|
-
* console.error("Failed:", result.error.code);
|
|
812
|
-
* }
|
|
813
|
-
* ```
|
|
814
|
-
*/
|
|
815
799
|
declare class CatalogueQueries {
|
|
816
800
|
private client;
|
|
817
801
|
constructor(client: CimplifyClient);
|
|
@@ -1333,59 +1317,15 @@ interface CartSummary {
|
|
|
1333
1317
|
currency: string;
|
|
1334
1318
|
}
|
|
1335
1319
|
|
|
1336
|
-
/**
|
|
1337
|
-
* Cart operations with explicit error handling via Result type.
|
|
1338
|
-
*
|
|
1339
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
1340
|
-
*
|
|
1341
|
-
* @example
|
|
1342
|
-
* ```typescript
|
|
1343
|
-
* const result = await client.cart.addItem({ item_id: "prod_123" });
|
|
1344
|
-
*
|
|
1345
|
-
* if (result.ok) {
|
|
1346
|
-
* console.log("Added!", result.value);
|
|
1347
|
-
* } else {
|
|
1348
|
-
* console.error("Failed:", result.error.code);
|
|
1349
|
-
* }
|
|
1350
|
-
* ```
|
|
1351
|
-
*/
|
|
1352
1320
|
declare class CartOperations {
|
|
1353
1321
|
private client;
|
|
1354
1322
|
constructor(client: CimplifyClient);
|
|
1355
|
-
/**
|
|
1356
|
-
* Get the enriched cart with product names, images, and details.
|
|
1357
|
-
* This is the main method for storefront display.
|
|
1358
|
-
*/
|
|
1359
1323
|
get(): Promise<Result<UICart, CimplifyError>>;
|
|
1360
1324
|
getRaw(): Promise<Result<Cart, CimplifyError>>;
|
|
1361
1325
|
getItems(): Promise<Result<CartItem[], CimplifyError>>;
|
|
1362
1326
|
getCount(): Promise<Result<number, CimplifyError>>;
|
|
1363
1327
|
getTotal(): Promise<Result<string, CimplifyError>>;
|
|
1364
1328
|
getSummary(): Promise<Result<CartSummary, CimplifyError>>;
|
|
1365
|
-
/**
|
|
1366
|
-
* Add an item to the cart.
|
|
1367
|
-
*
|
|
1368
|
-
* @example
|
|
1369
|
-
* ```typescript
|
|
1370
|
-
* const result = await client.cart.addItem({
|
|
1371
|
-
* item_id: "prod_burger",
|
|
1372
|
-
* quantity: 2,
|
|
1373
|
-
* variant_id: "var_large",
|
|
1374
|
-
* add_on_options: ["addon_cheese", "addon_bacon"],
|
|
1375
|
-
* });
|
|
1376
|
-
*
|
|
1377
|
-
* if (!result.ok) {
|
|
1378
|
-
* switch (result.error.code) {
|
|
1379
|
-
* case ErrorCode.ITEM_UNAVAILABLE:
|
|
1380
|
-
* toast.error("Item no longer available");
|
|
1381
|
-
* break;
|
|
1382
|
-
* case ErrorCode.VARIANT_OUT_OF_STOCK:
|
|
1383
|
-
* toast.error("Selected option is out of stock");
|
|
1384
|
-
* break;
|
|
1385
|
-
* }
|
|
1386
|
-
* }
|
|
1387
|
-
* ```
|
|
1388
|
-
*/
|
|
1389
1329
|
addItem(input: AddToCartInput): Promise<Result<Cart, CimplifyError>>;
|
|
1390
1330
|
updateItem(cartItemId: string, updates: UpdateCartItemInput): Promise<Result<Cart, CimplifyError>>;
|
|
1391
1331
|
updateQuantity(cartItemId: string, quantity: number): Promise<Result<Cart, CimplifyError>>;
|
|
@@ -2064,64 +2004,10 @@ interface CheckoutResult {
|
|
|
2064
2004
|
public_key?: string;
|
|
2065
2005
|
}
|
|
2066
2006
|
|
|
2067
|
-
/**
|
|
2068
|
-
* Generate a cryptographically secure idempotency key.
|
|
2069
|
-
* Uses crypto.randomUUID if available, falls back to timestamp + random.
|
|
2070
|
-
*/
|
|
2071
2007
|
declare function generateIdempotencyKey(): string;
|
|
2072
|
-
/**
|
|
2073
|
-
* Checkout service with explicit error handling via Result type.
|
|
2074
|
-
*
|
|
2075
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2076
|
-
*
|
|
2077
|
-
* @example
|
|
2078
|
-
* ```typescript
|
|
2079
|
-
* const result = await client.checkout.process(formData);
|
|
2080
|
-
*
|
|
2081
|
-
* if (result.ok) {
|
|
2082
|
-
* const checkout = result.value;
|
|
2083
|
-
* if (checkout.requires_authorization) {
|
|
2084
|
-
* // Handle OTP flow
|
|
2085
|
-
* } else if (checkout.client_secret) {
|
|
2086
|
-
* // Open Paystack popup
|
|
2087
|
-
* }
|
|
2088
|
-
* } else {
|
|
2089
|
-
* toast.error(result.error.message);
|
|
2090
|
-
* }
|
|
2091
|
-
* ```
|
|
2092
|
-
*/
|
|
2093
2008
|
declare class CheckoutService {
|
|
2094
2009
|
private client;
|
|
2095
2010
|
constructor(client: CimplifyClient);
|
|
2096
|
-
/**
|
|
2097
|
-
* Process checkout with cart data.
|
|
2098
|
-
*
|
|
2099
|
-
* Automatically generates an idempotency key if not provided to ensure
|
|
2100
|
-
* payment safety. The same key is used across retries, preventing
|
|
2101
|
-
* duplicate charges if a network error occurs after payment processing.
|
|
2102
|
-
*
|
|
2103
|
-
* @example
|
|
2104
|
-
* ```typescript
|
|
2105
|
-
* const result = await client.checkout.process({
|
|
2106
|
-
* cart_id: cart.id,
|
|
2107
|
-
* customer: { name, email, phone, save_details: true },
|
|
2108
|
-
* order_type: "pickup",
|
|
2109
|
-
* payment_method: "mobile_money",
|
|
2110
|
-
* mobile_money_details: { phone_number, provider: "mtn" },
|
|
2111
|
-
* });
|
|
2112
|
-
*
|
|
2113
|
-
* if (!result.ok) {
|
|
2114
|
-
* switch (result.error.code) {
|
|
2115
|
-
* case ErrorCode.CART_EMPTY:
|
|
2116
|
-
* toast.error("Your cart is empty");
|
|
2117
|
-
* break;
|
|
2118
|
-
* case ErrorCode.PAYMENT_FAILED:
|
|
2119
|
-
* toast.error("Payment failed. Please try again.");
|
|
2120
|
-
* break;
|
|
2121
|
-
* }
|
|
2122
|
-
* }
|
|
2123
|
-
* ```
|
|
2124
|
-
*/
|
|
2125
2011
|
process(data: CheckoutFormData): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
2126
2012
|
initializePayment(orderId: string, method: PaymentMethod): Promise<Result<InitializePaymentResult, CimplifyError>>;
|
|
2127
2013
|
submitAuthorization(input: SubmitAuthorizationInput): Promise<Result<CheckoutResult, CimplifyError>>;
|
|
@@ -2228,24 +2114,6 @@ interface ChangePasswordInput {
|
|
|
2228
2114
|
interface SuccessResult$1 {
|
|
2229
2115
|
success: boolean;
|
|
2230
2116
|
}
|
|
2231
|
-
/**
|
|
2232
|
-
* Auth service with explicit error handling via Result type.
|
|
2233
|
-
*
|
|
2234
|
-
* All methods return `Result<T, CimplifyError>` - no exceptions thrown.
|
|
2235
|
-
*
|
|
2236
|
-
* @example
|
|
2237
|
-
* ```typescript
|
|
2238
|
-
* const result = await client.auth.verifyOtp("123456");
|
|
2239
|
-
*
|
|
2240
|
-
* if (result.ok) {
|
|
2241
|
-
* console.log("Logged in as:", result.value.customer.name);
|
|
2242
|
-
* } else {
|
|
2243
|
-
* if (result.error.code === "INVALID_OTP") {
|
|
2244
|
-
* toast.error("Invalid code. Please try again.");
|
|
2245
|
-
* }
|
|
2246
|
-
* }
|
|
2247
|
-
* ```
|
|
2248
|
-
*/
|
|
2249
2117
|
declare class AuthService {
|
|
2250
2118
|
private client;
|
|
2251
2119
|
constructor(client: CimplifyClient);
|
|
@@ -2944,7 +2812,6 @@ declare class CimplifyClient {
|
|
|
2944
2812
|
private maxRetries;
|
|
2945
2813
|
private retryDelay;
|
|
2946
2814
|
private hooks;
|
|
2947
|
-
/** In-flight request deduplication map */
|
|
2948
2815
|
private inflightRequests;
|
|
2949
2816
|
private _catalogue?;
|
|
2950
2817
|
private _cart?;
|
|
@@ -2964,30 +2831,10 @@ declare class CimplifyClient {
|
|
|
2964
2831
|
private saveSessionToken;
|
|
2965
2832
|
private getHeaders;
|
|
2966
2833
|
private updateSessionFromResponse;
|
|
2967
|
-
/**
|
|
2968
|
-
* Resilient fetch with timeout, automatic retries, and observability hooks.
|
|
2969
|
-
* Uses exponential backoff: 1s, 2s, 4s between retries.
|
|
2970
|
-
*/
|
|
2971
2834
|
private resilientFetch;
|
|
2972
|
-
/**
|
|
2973
|
-
* Generate a deduplication key for a request.
|
|
2974
|
-
* Same query + variables = same key = deduplicated.
|
|
2975
|
-
*/
|
|
2976
2835
|
private getDedupeKey;
|
|
2977
|
-
/**
|
|
2978
|
-
* Execute a request with deduplication.
|
|
2979
|
-
* If an identical request is already in-flight, return the same promise.
|
|
2980
|
-
* This prevents redundant network calls when multiple components request the same data.
|
|
2981
|
-
*/
|
|
2982
2836
|
private deduplicatedRequest;
|
|
2983
|
-
/**
|
|
2984
|
-
* Execute a query with deduplication.
|
|
2985
|
-
* Multiple identical queries made simultaneously will share a single network request.
|
|
2986
|
-
*/
|
|
2987
2837
|
query<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
2988
|
-
/**
|
|
2989
|
-
* Execute a mutation. NOT deduplicated - mutations have side effects.
|
|
2990
|
-
*/
|
|
2991
2838
|
call<T = unknown>(method: string, args?: unknown): Promise<T>;
|
|
2992
2839
|
get<T = unknown>(path: string): Promise<T>;
|
|
2993
2840
|
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|