@commercengine/pos 0.3.5 → 0.3.7
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/admin-types.d.ts +1981 -0
- package/dist/admin-types.js +1 -0
- package/dist/index.d.ts +171 -25
- package/dist/index.js +57 -35
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.d.ts
CHANGED
|
@@ -207,6 +207,26 @@ interface paths {
|
|
|
207
207
|
patch?: never;
|
|
208
208
|
trace?: never;
|
|
209
209
|
};
|
|
210
|
+
"/pos/carts/users/{user_id}": {
|
|
211
|
+
parameters: {
|
|
212
|
+
query?: never;
|
|
213
|
+
header?: never;
|
|
214
|
+
path?: never;
|
|
215
|
+
cookie?: never;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Retrieve cart using user id
|
|
219
|
+
* @description Retrieve cart detail using user id
|
|
220
|
+
*/
|
|
221
|
+
get: operations["pos-get-user-cart"];
|
|
222
|
+
put?: never;
|
|
223
|
+
post?: never;
|
|
224
|
+
delete?: never;
|
|
225
|
+
options?: never;
|
|
226
|
+
head?: never;
|
|
227
|
+
patch?: never;
|
|
228
|
+
trace?: never;
|
|
229
|
+
};
|
|
210
230
|
"/pos/carts/{id}": {
|
|
211
231
|
parameters: {
|
|
212
232
|
query?: never;
|
|
@@ -1224,8 +1244,6 @@ interface components {
|
|
|
1224
1244
|
stock_available: boolean;
|
|
1225
1245
|
/** @description Indicates whether the item is being fulfilled as a backorder. When true, the item is not currently in stock and will ship later once inventory is available. This may result in the order being split into multiple shipments, with delays for the backordered portion. */
|
|
1226
1246
|
backorder: boolean;
|
|
1227
|
-
/** @description Indicates whether the product is currently on offer. */
|
|
1228
|
-
on_offer: boolean;
|
|
1229
1247
|
/** @description Indicates whether the product is currently on a subscription. */
|
|
1230
1248
|
on_subscription: boolean;
|
|
1231
1249
|
/** @description Indicates whether the product is part of a promotion. */
|
|
@@ -1623,8 +1641,6 @@ interface components {
|
|
|
1623
1641
|
stock_available: boolean;
|
|
1624
1642
|
/** @description Indicates whether the item is being fulfilled as a backorder. When true, the item is not currently in stock and will ship later once inventory is available. This may result in the order being split into multiple shipments, with delays for the backordered portion. */
|
|
1625
1643
|
backorder?: boolean;
|
|
1626
|
-
/** @description Indicates whether this item is associated with any active (product-specific) coupons */
|
|
1627
|
-
on_offer: boolean;
|
|
1628
1644
|
on_subscription: boolean;
|
|
1629
1645
|
on_promotion: boolean;
|
|
1630
1646
|
category_ids: string[];
|
|
@@ -1833,12 +1849,10 @@ interface components {
|
|
|
1833
1849
|
slug: string;
|
|
1834
1850
|
variant_id: string | null;
|
|
1835
1851
|
variant_name: string | null;
|
|
1836
|
-
/** @description
|
|
1837
|
-
* backorder
|
|
1852
|
+
/** @description backorder
|
|
1838
1853
|
*
|
|
1839
1854
|
* Indicates whether the item is being fulfilled as a backorder. When true, the item is not currently in stock and will ship later once inventory is available. This may result in the order being split into multiple shipments, with delays for the backordered portion. */
|
|
1840
1855
|
backorder: boolean;
|
|
1841
|
-
on_offer: boolean;
|
|
1842
1856
|
on_promotion: boolean;
|
|
1843
1857
|
on_subscription: boolean;
|
|
1844
1858
|
subscription_plan: string | null;
|
|
@@ -2072,8 +2086,8 @@ interface components {
|
|
|
2072
2086
|
/** PosDevice */
|
|
2073
2087
|
PosDevice: {
|
|
2074
2088
|
readonly id: string;
|
|
2075
|
-
|
|
2076
|
-
/** @enum {
|
|
2089
|
+
name: string;
|
|
2090
|
+
/** @enum {string} */
|
|
2077
2091
|
device_type: "pos-terminal";
|
|
2078
2092
|
/** @description A Device ID shared by POS device provider. */
|
|
2079
2093
|
readonly external_device_id: string;
|
|
@@ -2082,9 +2096,20 @@ interface components {
|
|
|
2082
2096
|
mac_address: string | null;
|
|
2083
2097
|
location_id: string;
|
|
2084
2098
|
readonly location_name: string;
|
|
2085
|
-
/** @
|
|
2099
|
+
/** @description Returns a user object if the device is claimed, otherwise returns null. */
|
|
2100
|
+
claimed_by: components["schemas"]["PosDeviceClaimedUser"] | null;
|
|
2101
|
+
/** @enum {string} */
|
|
2086
2102
|
readonly status: "available" | "claimed" | "offline";
|
|
2087
|
-
is_busy: boolean;
|
|
2103
|
+
readonly is_busy: boolean;
|
|
2104
|
+
};
|
|
2105
|
+
/** PosDeviceClaimedUser */
|
|
2106
|
+
PosDeviceClaimedUser: {
|
|
2107
|
+
readonly id: string;
|
|
2108
|
+
first_name: string;
|
|
2109
|
+
last_name: string | null;
|
|
2110
|
+
phone: string;
|
|
2111
|
+
/** Format: email */
|
|
2112
|
+
email: string;
|
|
2088
2113
|
};
|
|
2089
2114
|
/** PosLocation */
|
|
2090
2115
|
PosLocation: {
|
|
@@ -2197,8 +2222,6 @@ interface components {
|
|
|
2197
2222
|
readonly stock_available: boolean;
|
|
2198
2223
|
/** @description Indicates whether the item is being fulfilled as a backorder. When true, the item is not currently in stock and will ship later once inventory is available. This may result in the order being split into multiple shipments, with delays for the backordered portion. */
|
|
2199
2224
|
backorder?: boolean;
|
|
2200
|
-
/** @description Indicates whether this item is associated with any active (product-specific) coupons */
|
|
2201
|
-
readonly on_offer: boolean;
|
|
2202
2225
|
/** @description Indicates whether the product has any subscription plans avaialble */
|
|
2203
2226
|
readonly on_subscription: boolean;
|
|
2204
2227
|
/** @description Indicates whether the product is currently on promotion. When true, the `ProductPromotion` object will contain details of the promotion */
|
|
@@ -2536,8 +2559,6 @@ interface components {
|
|
|
2536
2559
|
readonly stock_available: boolean;
|
|
2537
2560
|
/** @description Indicates whether the item is being fulfilled as a backorder. When true, the item is not currently in stock and will ship later once inventory is available. This may result in the order being split into multiple shipments, with delays for the backordered portion. */
|
|
2538
2561
|
backorder?: boolean;
|
|
2539
|
-
/** @description Indicates whether this item is associated with any active (product-specific) coupons */
|
|
2540
|
-
readonly on_offer: boolean;
|
|
2541
2562
|
readonly on_promotion: boolean;
|
|
2542
2563
|
readonly on_subscription: boolean;
|
|
2543
2564
|
/** @description Indicates whether a variant is marked as the default variant for a product */
|
|
@@ -2704,6 +2725,8 @@ interface components {
|
|
|
2704
2725
|
parameters: {
|
|
2705
2726
|
/** @description This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned. */
|
|
2706
2727
|
CustomerGroupId: string;
|
|
2728
|
+
/** @description This param is used to enable debug mode. If debug mode is enabled, the API will return OTP as well. This is only for development and testing purposes. */
|
|
2729
|
+
DebugMode: boolean;
|
|
2707
2730
|
/** @description no of rows per page */
|
|
2708
2731
|
pageLimitParam: number;
|
|
2709
2732
|
/** @description page number of pagination list */
|
|
@@ -2721,7 +2744,10 @@ interface operations {
|
|
|
2721
2744
|
"login-pos-device-with-email": {
|
|
2722
2745
|
parameters: {
|
|
2723
2746
|
query?: never;
|
|
2724
|
-
header?:
|
|
2747
|
+
header?: {
|
|
2748
|
+
/** @description This param is used to enable debug mode. If debug mode is enabled, the API will return OTP as well. This is only for development and testing purposes. */
|
|
2749
|
+
"x-debug-mode"?: components["parameters"]["DebugMode"];
|
|
2750
|
+
};
|
|
2725
2751
|
path?: never;
|
|
2726
2752
|
cookie?: never;
|
|
2727
2753
|
};
|
|
@@ -2758,7 +2784,10 @@ interface operations {
|
|
|
2758
2784
|
"login-pos-device-with-phone": {
|
|
2759
2785
|
parameters: {
|
|
2760
2786
|
query?: never;
|
|
2761
|
-
header?:
|
|
2787
|
+
header?: {
|
|
2788
|
+
/** @description This param is used to enable debug mode. If debug mode is enabled, the API will return OTP as well. This is only for development and testing purposes. */
|
|
2789
|
+
"x-debug-mode"?: components["parameters"]["DebugMode"];
|
|
2790
|
+
};
|
|
2762
2791
|
path?: never;
|
|
2763
2792
|
cookie?: never;
|
|
2764
2793
|
};
|
|
@@ -2801,7 +2830,10 @@ interface operations {
|
|
|
2801
2830
|
"login-pos-device-with-whatsapp": {
|
|
2802
2831
|
parameters: {
|
|
2803
2832
|
query?: never;
|
|
2804
|
-
header?:
|
|
2833
|
+
header?: {
|
|
2834
|
+
/** @description This param is used to enable debug mode. If debug mode is enabled, the API will return OTP as well. This is only for development and testing purposes. */
|
|
2835
|
+
"x-debug-mode"?: components["parameters"]["DebugMode"];
|
|
2836
|
+
};
|
|
2805
2837
|
path?: never;
|
|
2806
2838
|
cookie?: never;
|
|
2807
2839
|
};
|
|
@@ -3077,6 +3109,38 @@ interface operations {
|
|
|
3077
3109
|
401: components["responses"]["Unauthorized"];
|
|
3078
3110
|
};
|
|
3079
3111
|
};
|
|
3112
|
+
"pos-get-user-cart": {
|
|
3113
|
+
parameters: {
|
|
3114
|
+
query?: never;
|
|
3115
|
+
header?: never;
|
|
3116
|
+
path: {
|
|
3117
|
+
/** @description User ID */
|
|
3118
|
+
user_id: string;
|
|
3119
|
+
};
|
|
3120
|
+
cookie?: never;
|
|
3121
|
+
};
|
|
3122
|
+
requestBody?: never;
|
|
3123
|
+
responses: {
|
|
3124
|
+
/** @description OK */
|
|
3125
|
+
200: {
|
|
3126
|
+
headers: {
|
|
3127
|
+
[name: string]: unknown;
|
|
3128
|
+
};
|
|
3129
|
+
content: {
|
|
3130
|
+
"application/json": {
|
|
3131
|
+
/** @example cart details */
|
|
3132
|
+
readonly message: string;
|
|
3133
|
+
readonly success: boolean;
|
|
3134
|
+
content: {
|
|
3135
|
+
cart: components["schemas"]["Cart"];
|
|
3136
|
+
};
|
|
3137
|
+
};
|
|
3138
|
+
};
|
|
3139
|
+
};
|
|
3140
|
+
401: components["responses"]["Unauthorized"];
|
|
3141
|
+
404: components["responses"]["NotFound"];
|
|
3142
|
+
};
|
|
3143
|
+
};
|
|
3080
3144
|
"pos-get-cart": {
|
|
3081
3145
|
parameters: {
|
|
3082
3146
|
query?: never;
|
|
@@ -4093,6 +4157,9 @@ interface operations {
|
|
|
4093
4157
|
"application/json": {
|
|
4094
4158
|
message: string;
|
|
4095
4159
|
success: boolean;
|
|
4160
|
+
content: {
|
|
4161
|
+
user: components["schemas"]["PosUser"];
|
|
4162
|
+
};
|
|
4096
4163
|
};
|
|
4097
4164
|
};
|
|
4098
4165
|
};
|
|
@@ -4121,6 +4188,9 @@ interface operations {
|
|
|
4121
4188
|
"application/json": {
|
|
4122
4189
|
message: string;
|
|
4123
4190
|
success: boolean;
|
|
4191
|
+
content: {
|
|
4192
|
+
user: components["schemas"]["PosUser"];
|
|
4193
|
+
};
|
|
4124
4194
|
};
|
|
4125
4195
|
};
|
|
4126
4196
|
};
|
|
@@ -5296,6 +5366,50 @@ interface components$1 {
|
|
|
5296
5366
|
* */
|
|
5297
5367
|
newsletter?: components$1["schemas"]["NotificationChannelPreferences"];
|
|
5298
5368
|
};
|
|
5369
|
+
OpeningHours: {
|
|
5370
|
+
monday: {
|
|
5371
|
+
/** Format: time */
|
|
5372
|
+
opening_time: string;
|
|
5373
|
+
/** Format: time */
|
|
5374
|
+
closing_time: string;
|
|
5375
|
+
} | null;
|
|
5376
|
+
tuesday: {
|
|
5377
|
+
/** Format: time */
|
|
5378
|
+
opening_time: string;
|
|
5379
|
+
/** Format: time */
|
|
5380
|
+
closing_time: string;
|
|
5381
|
+
} | null;
|
|
5382
|
+
wednesday: {
|
|
5383
|
+
/** Format: time */
|
|
5384
|
+
opening_time: string;
|
|
5385
|
+
/** Format: time */
|
|
5386
|
+
closing_time: string;
|
|
5387
|
+
} | null;
|
|
5388
|
+
thursday: {
|
|
5389
|
+
/** Format: time */
|
|
5390
|
+
opening_time: string;
|
|
5391
|
+
/** Format: time */
|
|
5392
|
+
closing_time: string;
|
|
5393
|
+
} | null;
|
|
5394
|
+
friday: {
|
|
5395
|
+
/** Format: time */
|
|
5396
|
+
opening_time: string;
|
|
5397
|
+
/** Format: time */
|
|
5398
|
+
closing_time: string;
|
|
5399
|
+
} | null;
|
|
5400
|
+
saturday: {
|
|
5401
|
+
/** Format: time */
|
|
5402
|
+
opening_time: string;
|
|
5403
|
+
/** Format: time */
|
|
5404
|
+
closing_time: string;
|
|
5405
|
+
} | null;
|
|
5406
|
+
sunday: {
|
|
5407
|
+
/** Format: time */
|
|
5408
|
+
opening_time: string;
|
|
5409
|
+
/** Format: time */
|
|
5410
|
+
closing_time: string;
|
|
5411
|
+
} | null;
|
|
5412
|
+
};
|
|
5299
5413
|
/** Order */
|
|
5300
5414
|
Order: {
|
|
5301
5415
|
order_number?: string;
|
|
@@ -5795,7 +5909,7 @@ interface components$1 {
|
|
|
5795
5909
|
/** @description this field will be always true for warehouse_type = retail-store. */
|
|
5796
5910
|
is_checkout_point: boolean;
|
|
5797
5911
|
accepts_returns: boolean;
|
|
5798
|
-
opening_hours?:
|
|
5912
|
+
opening_hours?: components$1["schemas"]["OpeningHours"];
|
|
5799
5913
|
};
|
|
5800
5914
|
/** WarehouseBasicDetail */
|
|
5801
5915
|
WarehouseBasicDetail: {
|
|
@@ -6946,6 +7060,7 @@ type PayuPaymentGatewayParams = components["schemas"]["PayuPaymentGatewayParams"
|
|
|
6946
7060
|
type PercentageDiscountRule = components["schemas"]["PercentageDiscountRule"];
|
|
6947
7061
|
type PincodeServiceability = components["schemas"]["PincodeServiceability"];
|
|
6948
7062
|
type PosDevice = components["schemas"]["PosDevice"];
|
|
7063
|
+
type PosDeviceClaimedUser = components["schemas"]["PosDeviceClaimedUser"];
|
|
6949
7064
|
type PosLocation = components["schemas"]["PosLocation"];
|
|
6950
7065
|
type PosUpdateCustomerWithEmail = components["schemas"]["PosUpdateCustomerWithEmail"];
|
|
6951
7066
|
type PosUpdateCustomerWithId = components["schemas"]["PosUpdateCustomerWithId"];
|
|
@@ -6982,12 +7097,15 @@ type VolumeBasedRule = components["schemas"]["VolumeBasedRule"];
|
|
|
6982
7097
|
type WalletPayment = components["schemas"]["WalletPayment"];
|
|
6983
7098
|
type LoginPosDeviceWithEmailResponse = paths["/pos/auth/login/email"]["post"]["responses"][200]["content"]["application/json"];
|
|
6984
7099
|
type LoginPosDeviceWithEmailContent = LoginPosDeviceWithEmailResponse["content"];
|
|
7100
|
+
type LoginPosDeviceWithEmailHeaderParams = paths["/pos/auth/login/email"]["post"]["parameters"]["header"];
|
|
6985
7101
|
type LoginPosDeviceWithEmailBody = NonNullable<paths["/pos/auth/login/email"]["post"]["requestBody"]>["content"]["application/json"];
|
|
6986
7102
|
type LoginPosDeviceWithPhoneResponse = paths["/pos/auth/login/phone"]["post"]["responses"][200]["content"]["application/json"];
|
|
6987
7103
|
type LoginPosDeviceWithPhoneContent = LoginPosDeviceWithPhoneResponse["content"];
|
|
7104
|
+
type LoginPosDeviceWithPhoneHeaderParams = paths["/pos/auth/login/phone"]["post"]["parameters"]["header"];
|
|
6988
7105
|
type LoginPosDeviceWithPhoneBody = NonNullable<paths["/pos/auth/login/phone"]["post"]["requestBody"]>["content"]["application/json"];
|
|
6989
7106
|
type LoginPosDeviceWithWhatsappResponse = paths["/pos/auth/login/whatsapp"]["post"]["responses"][200]["content"]["application/json"];
|
|
6990
7107
|
type LoginPosDeviceWithWhatsappContent = LoginPosDeviceWithWhatsappResponse["content"];
|
|
7108
|
+
type LoginPosDeviceWithWhatsappHeaderParams = paths["/pos/auth/login/whatsapp"]["post"]["parameters"]["header"];
|
|
6991
7109
|
type LoginPosDeviceWithWhatsappBody = NonNullable<paths["/pos/auth/login/whatsapp"]["post"]["requestBody"]>["content"]["application/json"];
|
|
6992
7110
|
type LogoutFromPosDeviceResponse = paths["/pos/auth/logout"]["post"]["responses"][200]["content"]["application/json"];
|
|
6993
7111
|
type PairPosDeviceResponse = paths["/pos/auth/pair-device"]["post"]["responses"][200]["content"]["application/json"];
|
|
@@ -7008,6 +7126,9 @@ type PosListCouponsHeaderParams = paths["/pos/carts/available-coupons"]["get"]["
|
|
|
7008
7126
|
type PosListPromotionsResponse = paths["/pos/carts/available-promotions"]["get"]["responses"][200]["content"]["application/json"];
|
|
7009
7127
|
type PosListPromotionsContent = PosListPromotionsResponse["content"];
|
|
7010
7128
|
type PosListPromotionsHeaderParams = paths["/pos/carts/available-promotions"]["get"]["parameters"]["header"];
|
|
7129
|
+
type PosGetUserCartResponse = paths["/pos/carts/users/{user_id}"]["get"]["responses"][200]["content"]["application/json"];
|
|
7130
|
+
type PosGetUserCartContent = PosGetUserCartResponse["content"];
|
|
7131
|
+
type PosGetUserCartPathParams = paths["/pos/carts/users/{user_id}"]["get"]["parameters"]["path"];
|
|
7011
7132
|
type PosGetCartResponse = paths["/pos/carts/{id}"]["get"]["responses"][200]["content"]["application/json"];
|
|
7012
7133
|
type PosGetCartContent = PosGetCartResponse["content"];
|
|
7013
7134
|
type PosGetCartPathParams = paths["/pos/carts/{id}"]["get"]["parameters"]["path"];
|
|
@@ -7104,8 +7225,10 @@ type PosListSkusHeaderParams = paths["/pos/catalog/skus"]["get"]["parameters"]["
|
|
|
7104
7225
|
type ListPosDevicesResponse = paths["/pos/devices"]["get"]["responses"][200]["content"]["application/json"];
|
|
7105
7226
|
type ListPosDevicesContent = ListPosDevicesResponse["content"];
|
|
7106
7227
|
type ClaimPosDeviceResponse = paths["/pos/devices/{id}/claim"]["post"]["responses"][200]["content"]["application/json"];
|
|
7228
|
+
type ClaimPosDeviceContent = ClaimPosDeviceResponse["content"];
|
|
7107
7229
|
type ClaimPosDevicePathParams = paths["/pos/devices/{id}/claim"]["post"]["parameters"]["path"];
|
|
7108
7230
|
type UnclaimPosDeviceResponse = paths["/pos/devices/{id}/unclaim"]["post"]["responses"][200]["content"]["application/json"];
|
|
7231
|
+
type UnclaimPosDeviceContent = UnclaimPosDeviceResponse["content"];
|
|
7109
7232
|
type UnclaimPosDevicePathParams = paths["/pos/devices/{id}/unclaim"]["post"]["parameters"]["path"];
|
|
7110
7233
|
type GetPosFulfillmentOptionsResponse = paths["/pos/fulfillment-options"]["post"]["responses"][200]["content"]["application/json"];
|
|
7111
7234
|
type GetPosFulfillmentOptionsContent = GetPosFulfillmentOptionsResponse["content"];
|
|
@@ -7207,7 +7330,7 @@ declare class PosClient extends PosAPIClient {
|
|
|
7207
7330
|
* }
|
|
7208
7331
|
* ```
|
|
7209
7332
|
*/
|
|
7210
|
-
loginWithEmail(body: LoginPosDeviceWithEmailBody): Promise<ApiResult<LoginPosDeviceWithEmailContent>>;
|
|
7333
|
+
loginWithEmail(headers: LoginPosDeviceWithEmailHeaderParams, body: LoginPosDeviceWithEmailBody): Promise<ApiResult<LoginPosDeviceWithEmailContent>>;
|
|
7211
7334
|
/**
|
|
7212
7335
|
* Login with phone number
|
|
7213
7336
|
* @param body - Login credentials containing location ID and phone
|
|
@@ -7229,7 +7352,7 @@ declare class PosClient extends PosAPIClient {
|
|
|
7229
7352
|
* }
|
|
7230
7353
|
* ```
|
|
7231
7354
|
*/
|
|
7232
|
-
loginWithPhone(body: LoginPosDeviceWithPhoneBody): Promise<ApiResult<LoginPosDeviceWithPhoneContent>>;
|
|
7355
|
+
loginWithPhone(headers: LoginPosDeviceWithPhoneHeaderParams, body: LoginPosDeviceWithPhoneBody): Promise<ApiResult<LoginPosDeviceWithPhoneContent>>;
|
|
7233
7356
|
/**
|
|
7234
7357
|
* Login with WhatsApp
|
|
7235
7358
|
* @param body - Login credentials containing location ID and phone
|
|
@@ -7251,7 +7374,7 @@ declare class PosClient extends PosAPIClient {
|
|
|
7251
7374
|
* }
|
|
7252
7375
|
* ```
|
|
7253
7376
|
*/
|
|
7254
|
-
loginWithWhatsapp(body: LoginPosDeviceWithWhatsappBody): Promise<ApiResult<LoginPosDeviceWithWhatsappContent>>;
|
|
7377
|
+
loginWithWhatsapp(headers: LoginPosDeviceWithWhatsappHeaderParams, body: LoginPosDeviceWithWhatsappBody): Promise<ApiResult<LoginPosDeviceWithWhatsappContent>>;
|
|
7255
7378
|
/**
|
|
7256
7379
|
* Verify OTP
|
|
7257
7380
|
* @param body - OTP verification data
|
|
@@ -7395,7 +7518,7 @@ declare class PosClient extends PosAPIClient {
|
|
|
7395
7518
|
* }
|
|
7396
7519
|
* ```
|
|
7397
7520
|
*/
|
|
7398
|
-
unclaimDevice(pathParams: UnclaimPosDevicePathParams): Promise<ApiResult<
|
|
7521
|
+
unclaimDevice(pathParams: UnclaimPosDevicePathParams): Promise<ApiResult<UnclaimPosDeviceContent>>;
|
|
7399
7522
|
/**
|
|
7400
7523
|
* Claim POS device - Links a device to the user session
|
|
7401
7524
|
* @param pathParams - Device ID
|
|
@@ -7413,7 +7536,7 @@ declare class PosClient extends PosAPIClient {
|
|
|
7413
7536
|
* }
|
|
7414
7537
|
* ```
|
|
7415
7538
|
*/
|
|
7416
|
-
claimDevice(pathParams: ClaimPosDevicePathParams): Promise<ApiResult<
|
|
7539
|
+
claimDevice(pathParams: ClaimPosDevicePathParams): Promise<ApiResult<ClaimPosDeviceContent>>;
|
|
7417
7540
|
/**
|
|
7418
7541
|
* Create a new cart
|
|
7419
7542
|
* @param body - Cart creation data with items
|
|
@@ -7468,6 +7591,25 @@ declare class PosClient extends PosAPIClient {
|
|
|
7468
7591
|
* ```
|
|
7469
7592
|
*/
|
|
7470
7593
|
getCart(pathParams: PosGetCartPathParams): Promise<ApiResult<PosGetCartContent>>;
|
|
7594
|
+
/**
|
|
7595
|
+
* Get cart details by user ID
|
|
7596
|
+
* @param pathParams - User ID
|
|
7597
|
+
* @returns Promise with cart details
|
|
7598
|
+
* @example
|
|
7599
|
+
* ```typescript
|
|
7600
|
+
* const { data, error } = await pos.getUserCart({
|
|
7601
|
+
* user_id: "01H9CART12345ABCDE"
|
|
7602
|
+
* });
|
|
7603
|
+
*
|
|
7604
|
+
* if (error) {
|
|
7605
|
+
* console.error("Failed to get user cart:", error.message);
|
|
7606
|
+
* } else {
|
|
7607
|
+
* console.log("User cart ID:", data.cart.id);
|
|
7608
|
+
* console.log("Cart value:", data.cart.subtotal_amount);
|
|
7609
|
+
* }
|
|
7610
|
+
* ```
|
|
7611
|
+
*/
|
|
7612
|
+
getUserCart(pathParams: PosGetUserCartPathParams): Promise<ApiResult<PosGetUserCartContent>>;
|
|
7471
7613
|
/**
|
|
7472
7614
|
* Delete cart (remove all items)
|
|
7473
7615
|
* @param pathParams - Cart ID
|
|
@@ -8943,6 +9085,10 @@ interface SupportedDefaultHeaders {
|
|
|
8943
9085
|
* Customer group ID used for pricing and promotions
|
|
8944
9086
|
*/
|
|
8945
9087
|
customer_group_id?: string;
|
|
9088
|
+
/**
|
|
9089
|
+
* Debug mode header
|
|
9090
|
+
*/
|
|
9091
|
+
debug_mode?: boolean;
|
|
8946
9092
|
}
|
|
8947
9093
|
/**
|
|
8948
9094
|
* SDK initialization options for the POS API
|
|
@@ -9099,5 +9245,5 @@ declare class PosSDK {
|
|
|
9099
9245
|
getTenantId(): Promise<string | null>;
|
|
9100
9246
|
}
|
|
9101
9247
|
//#endregion
|
|
9102
|
-
export { AcceleratedRewardCouponPromotion, AcceleratedRewardRule, AdditionalProductDetails, ApiErrorResponse, ApiResult, ApplicableCoupon, ApplicablePromotion, AppliedCoupon, AppliedPromotion, AssociatedOption, AutoScaleBasedOnAmount, AutoScaleBasedOnQuantity, BankTransfer, BaseAPIClient, BaseSDKOptions, BooleanAttribute, BrowserTokenStorage, BuyXGetYCouponPromotion, BuyXGetYRule, BuyXGetYRuleBasedOnAmount, BuyXGetYRuleBasedOnQuantity, CardPayment, Cart, CartBasedServiceabilityCheck, CartItem, Category, ClaimPosDevicePathParams, ClaimPosDeviceResponse, CollectInStore, CollectInStoreFulfillment, ColorAttribute, ColorOption, Coupon, CouponPromotionCommonDetail, CouponType, CreatePosOrderBody, CreatePosOrderContent, CreatePosOrderResponse, Currency, CustomSlabsBasedOnAmount, CustomSlabsBasedOnQuantity, CustomerAddress, DateAttribute, DebugLogger, DebugLoggerFn, DeliveryFulfillment, DiscountBasedPromotion, DiscountCouponPromotion, DiscountRule, Environment, FixedAmountDiscountRule, FixedPriceCouponPromotion, FixedPricePromotion, FixedPriceRule, FixedPriceRuleBasedAmount, FixedPriceRuleBasedQuantity, FreeGoodCouponPromotion, FreeGoodsPromotion, FreeGoodsRule, FreeShipingCouponPromotion, GetPosFulfillmentOptionsBody, GetPosFulfillmentOptionsContent, GetPosFulfillmentOptionsResponse, GetPosUserContent, GetPosUserPathParams, GetPosUserResponse, HeaderConfig, InapplicableCoupon, InapplicablePromotion, Item, JuspayPaymentGatewayParams, ListPosDevicesContent, ListPosDevicesResponse, ListPosLocationsContent, ListPosLocationsResponse, LoginPosDeviceWithEmailBody, LoginPosDeviceWithEmailContent, LoginPosDeviceWithEmailResponse, LoginPosDeviceWithPhoneBody, LoginPosDeviceWithPhoneContent, LoginPosDeviceWithPhoneResponse, LoginPosDeviceWithWhatsappBody, LoginPosDeviceWithWhatsappContent, LoginPosDeviceWithWhatsappResponse, LogoutFromPosDeviceResponse, LotBatchDetail, MemoryTokenStorage, MultiSelectAttribute, NetbankingPayment, NumberAttribute, Order, OrderDetail, OrderItem, OrderPayment, OrderRefund, OrderShipment, Pagination, PairPosDeviceBody, PairPosDeviceContent, PairPosDeviceResponse, PartialCollectAndDelivery, PayWithCard, PayWithCash, PayWithPaymentGateway, PayWithUpi, PaymentGateway, PaymentGatewayParams, PaymentInfo, PayuPaymentGatewayParams, PercentageDiscountRule, PincodeServiceability, PosAPIClient, PosApplyCouponBody, PosApplyCouponContent, PosApplyCouponPathParams, PosApplyCouponResponse, PosClient, PosCreateCartAddressBody, PosCreateCartAddressContent, PosCreateCartAddressPathParams, PosCreateCartAddressResponse, PosCreateCartBody, PosCreateCartContent, PosCreateCartResponse, PosDeleteCartPathParams, PosDeleteCartResponse, PosDevice, PosEvaluateCouponsContent, PosEvaluateCouponsPathParams, PosEvaluateCouponsResponse, PosEvaluatePromotionsContent, PosEvaluatePromotionsPathParams, PosEvaluatePromotionsResponse, PosGetCartContent, PosGetCartPathParams, PosGetCartResponse, PosGetPaymentStatusContent, PosGetPaymentStatusPathParams, PosGetPaymentStatusResponse, PosGetProductDetailContent, PosGetProductDetailHeaderParams, PosGetProductDetailPathParams, PosGetProductDetailQuery, PosGetProductDetailResponse, PosGetVariantDetailContent, PosGetVariantDetailHeaderParams, PosGetVariantDetailPathParams, PosGetVariantDetailQuery, PosGetVariantDetailResponse, PosListCategoriesContent, PosListCategoriesQuery, PosListCategoriesResponse, PosListCouponsContent, PosListCouponsHeaderParams, PosListCouponsResponse, PosListCrosssellProductsContent, PosListCrosssellProductsHeaderParams, PosListCrosssellProductsQuery, PosListCrosssellProductsResponse, PosListPaymentOptionsContent, PosListPaymentOptionsResponse, PosListProductReviewsContent, PosListProductReviewsPathParams, PosListProductReviewsQuery, PosListProductReviewsResponse, PosListProductVariantsContent, PosListProductVariantsHeaderParams, PosListProductVariantsPathParams, PosListProductVariantsQuery, PosListProductVariantsResponse, PosListProductsContent, PosListProductsHeaderParams, PosListProductsQuery, PosListProductsResponse, PosListPromotionsContent, PosListPromotionsHeaderParams, PosListPromotionsResponse, PosListSimilarProductsContent, PosListSimilarProductsHeaderParams, PosListSimilarProductsQuery, PosListSimilarProductsResponse, PosListSkusContent, PosListSkusHeaderParams, PosListSkusQuery, PosListSkusResponse, PosListUpsellProductsContent, PosListUpsellProductsHeaderParams, PosListUpsellProductsQuery, PosListUpsellProductsResponse, PosLocation, PosRedeemCreditBalanceBody, PosRedeemCreditBalanceContent, PosRedeemCreditBalancePathParams, PosRedeemCreditBalanceResponse, PosRedeemLoyaltyPointsBody, PosRedeemLoyaltyPointsContent, PosRedeemLoyaltyPointsPathParams, PosRedeemLoyaltyPointsResponse, PosRemoveCouponContent, PosRemoveCouponPathParams, PosRemoveCouponResponse, PosRemoveCreditBalanceContent, PosRemoveCreditBalancePathParams, PosRemoveCreditBalanceResponse, PosRemoveLoyaltyPointsContent, PosRemoveLoyaltyPointsPathParams, PosRemoveLoyaltyPointsResponse, PosSDK, PosSDK as default, PosSDKOptions, PosSearchProductsBody, PosSearchProductsContent, PosSearchProductsHeaderParams, PosSearchProductsResponse, PosUpdateCartBody, PosUpdateCartContent, PosUpdateCartPathParams, PosUpdateCartResponse, PosUpdateCustomerWithEmail, PosUpdateCustomerWithId, PosUpdateCustomerWithPhone, PosUpdateFulfillmentPreferenceBody, PosUpdateFulfillmentPreferencePathParams, PosUpdateFulfillmentPreferenceResponse, PosUser, Product, ProductAttribute, ProductBundleItem, ProductCategory, ProductDetail, ProductImage, ProductPricing, ProductPromotion, ProductReview, ProductShipping, ProductSubscription, ProductVideo, Promotion, PromotionType, RefreshPosAccessTokenBody, RefreshPosAccessTokenContent, RefreshPosAccessTokenResponse, ResponseUtils, SearchProduct, Seo, ShipmentItem, SingleSelectAttribute, SingleSelectOption, SupportedDefaultHeaders, TextAttribute, type TokenStorage, UnclaimPosDevicePathParams, UnclaimPosDeviceResponse, UpdateCartItem, UpdatePosCartCustomerBody, UpdatePosCartCustomerContent, UpdatePosCartCustomerPathParams, UpdatePosCartCustomerResponse, UpiPayment, type UserInfo, Variant, VariantDetail, VariantOption, VerifyPosLoginOtpBody, VerifyPosLoginOtpContent, VerifyPosLoginOtpResponse, VolumeBasedCouponPromotion, VolumeBasedPromotion, VolumeBasedRule, WalletPayment, type components, createDebugMiddleware, createTimeoutMiddleware, executeRequest, extractRequestBody, getPathnameFromUrl, mergeAndTransformHeaders, mergeHeaders, type operations, type paths, transformHeaders };
|
|
9248
|
+
export { AcceleratedRewardCouponPromotion, AcceleratedRewardRule, AdditionalProductDetails, ApiErrorResponse, ApiResult, ApplicableCoupon, ApplicablePromotion, AppliedCoupon, AppliedPromotion, AssociatedOption, AutoScaleBasedOnAmount, AutoScaleBasedOnQuantity, BankTransfer, BaseAPIClient, BaseSDKOptions, BooleanAttribute, BrowserTokenStorage, BuyXGetYCouponPromotion, BuyXGetYRule, BuyXGetYRuleBasedOnAmount, BuyXGetYRuleBasedOnQuantity, CardPayment, Cart, CartBasedServiceabilityCheck, CartItem, Category, ClaimPosDeviceContent, ClaimPosDevicePathParams, ClaimPosDeviceResponse, CollectInStore, CollectInStoreFulfillment, ColorAttribute, ColorOption, Coupon, CouponPromotionCommonDetail, CouponType, CreatePosOrderBody, CreatePosOrderContent, CreatePosOrderResponse, Currency, CustomSlabsBasedOnAmount, CustomSlabsBasedOnQuantity, CustomerAddress, DateAttribute, DebugLogger, DebugLoggerFn, DeliveryFulfillment, DiscountBasedPromotion, DiscountCouponPromotion, DiscountRule, Environment, FixedAmountDiscountRule, FixedPriceCouponPromotion, FixedPricePromotion, FixedPriceRule, FixedPriceRuleBasedAmount, FixedPriceRuleBasedQuantity, FreeGoodCouponPromotion, FreeGoodsPromotion, FreeGoodsRule, FreeShipingCouponPromotion, GetPosFulfillmentOptionsBody, GetPosFulfillmentOptionsContent, GetPosFulfillmentOptionsResponse, GetPosUserContent, GetPosUserPathParams, GetPosUserResponse, HeaderConfig, InapplicableCoupon, InapplicablePromotion, Item, JuspayPaymentGatewayParams, ListPosDevicesContent, ListPosDevicesResponse, ListPosLocationsContent, ListPosLocationsResponse, LoginPosDeviceWithEmailBody, LoginPosDeviceWithEmailContent, LoginPosDeviceWithEmailHeaderParams, LoginPosDeviceWithEmailResponse, LoginPosDeviceWithPhoneBody, LoginPosDeviceWithPhoneContent, LoginPosDeviceWithPhoneHeaderParams, LoginPosDeviceWithPhoneResponse, LoginPosDeviceWithWhatsappBody, LoginPosDeviceWithWhatsappContent, LoginPosDeviceWithWhatsappHeaderParams, LoginPosDeviceWithWhatsappResponse, LogoutFromPosDeviceResponse, LotBatchDetail, MemoryTokenStorage, MultiSelectAttribute, NetbankingPayment, NumberAttribute, Order, OrderDetail, OrderItem, OrderPayment, OrderRefund, OrderShipment, Pagination, PairPosDeviceBody, PairPosDeviceContent, PairPosDeviceResponse, PartialCollectAndDelivery, PayWithCard, PayWithCash, PayWithPaymentGateway, PayWithUpi, PaymentGateway, PaymentGatewayParams, PaymentInfo, PayuPaymentGatewayParams, PercentageDiscountRule, PincodeServiceability, PosAPIClient, PosApplyCouponBody, PosApplyCouponContent, PosApplyCouponPathParams, PosApplyCouponResponse, PosClient, PosCreateCartAddressBody, PosCreateCartAddressContent, PosCreateCartAddressPathParams, PosCreateCartAddressResponse, PosCreateCartBody, PosCreateCartContent, PosCreateCartResponse, PosDeleteCartPathParams, PosDeleteCartResponse, PosDevice, PosDeviceClaimedUser, PosEvaluateCouponsContent, PosEvaluateCouponsPathParams, PosEvaluateCouponsResponse, PosEvaluatePromotionsContent, PosEvaluatePromotionsPathParams, PosEvaluatePromotionsResponse, PosGetCartContent, PosGetCartPathParams, PosGetCartResponse, PosGetPaymentStatusContent, PosGetPaymentStatusPathParams, PosGetPaymentStatusResponse, PosGetProductDetailContent, PosGetProductDetailHeaderParams, PosGetProductDetailPathParams, PosGetProductDetailQuery, PosGetProductDetailResponse, PosGetUserCartContent, PosGetUserCartPathParams, PosGetUserCartResponse, PosGetVariantDetailContent, PosGetVariantDetailHeaderParams, PosGetVariantDetailPathParams, PosGetVariantDetailQuery, PosGetVariantDetailResponse, PosListCategoriesContent, PosListCategoriesQuery, PosListCategoriesResponse, PosListCouponsContent, PosListCouponsHeaderParams, PosListCouponsResponse, PosListCrosssellProductsContent, PosListCrosssellProductsHeaderParams, PosListCrosssellProductsQuery, PosListCrosssellProductsResponse, PosListPaymentOptionsContent, PosListPaymentOptionsResponse, PosListProductReviewsContent, PosListProductReviewsPathParams, PosListProductReviewsQuery, PosListProductReviewsResponse, PosListProductVariantsContent, PosListProductVariantsHeaderParams, PosListProductVariantsPathParams, PosListProductVariantsQuery, PosListProductVariantsResponse, PosListProductsContent, PosListProductsHeaderParams, PosListProductsQuery, PosListProductsResponse, PosListPromotionsContent, PosListPromotionsHeaderParams, PosListPromotionsResponse, PosListSimilarProductsContent, PosListSimilarProductsHeaderParams, PosListSimilarProductsQuery, PosListSimilarProductsResponse, PosListSkusContent, PosListSkusHeaderParams, PosListSkusQuery, PosListSkusResponse, PosListUpsellProductsContent, PosListUpsellProductsHeaderParams, PosListUpsellProductsQuery, PosListUpsellProductsResponse, PosLocation, PosRedeemCreditBalanceBody, PosRedeemCreditBalanceContent, PosRedeemCreditBalancePathParams, PosRedeemCreditBalanceResponse, PosRedeemLoyaltyPointsBody, PosRedeemLoyaltyPointsContent, PosRedeemLoyaltyPointsPathParams, PosRedeemLoyaltyPointsResponse, PosRemoveCouponContent, PosRemoveCouponPathParams, PosRemoveCouponResponse, PosRemoveCreditBalanceContent, PosRemoveCreditBalancePathParams, PosRemoveCreditBalanceResponse, PosRemoveLoyaltyPointsContent, PosRemoveLoyaltyPointsPathParams, PosRemoveLoyaltyPointsResponse, PosSDK, PosSDK as default, PosSDKOptions, PosSearchProductsBody, PosSearchProductsContent, PosSearchProductsHeaderParams, PosSearchProductsResponse, PosUpdateCartBody, PosUpdateCartContent, PosUpdateCartPathParams, PosUpdateCartResponse, PosUpdateCustomerWithEmail, PosUpdateCustomerWithId, PosUpdateCustomerWithPhone, PosUpdateFulfillmentPreferenceBody, PosUpdateFulfillmentPreferencePathParams, PosUpdateFulfillmentPreferenceResponse, PosUser, Product, ProductAttribute, ProductBundleItem, ProductCategory, ProductDetail, ProductImage, ProductPricing, ProductPromotion, ProductReview, ProductShipping, ProductSubscription, ProductVideo, Promotion, PromotionType, RefreshPosAccessTokenBody, RefreshPosAccessTokenContent, RefreshPosAccessTokenResponse, ResponseUtils, SearchProduct, Seo, ShipmentItem, SingleSelectAttribute, SingleSelectOption, SupportedDefaultHeaders, TextAttribute, type TokenStorage, UnclaimPosDeviceContent, UnclaimPosDevicePathParams, UnclaimPosDeviceResponse, UpdateCartItem, UpdatePosCartCustomerBody, UpdatePosCartCustomerContent, UpdatePosCartCustomerPathParams, UpdatePosCartCustomerResponse, UpiPayment, type UserInfo, Variant, VariantDetail, VariantOption, VerifyPosLoginOtpBody, VerifyPosLoginOtpContent, VerifyPosLoginOtpResponse, VolumeBasedCouponPromotion, VolumeBasedPromotion, VolumeBasedRule, WalletPayment, type components, createDebugMiddleware, createTimeoutMiddleware, executeRequest, extractRequestBody, getPathnameFromUrl, mergeAndTransformHeaders, mergeHeaders, type operations, type paths, transformHeaders };
|
|
9103
9249
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -43,16 +43,14 @@ var ResponseUtils = class {
|
|
|
43
43
|
* Note: This can only be called once per response
|
|
44
44
|
*/
|
|
45
45
|
static async getText(response) {
|
|
46
|
-
|
|
47
|
-
return await cloned.text();
|
|
46
|
+
return await response.clone().text();
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* Clone and read response as JSON (useful for debugging)
|
|
51
50
|
* Note: This can only be called once per response
|
|
52
51
|
*/
|
|
53
52
|
static async getJSON(response) {
|
|
54
|
-
|
|
55
|
-
return await cloned.json();
|
|
53
|
+
return await response.clone().json();
|
|
56
54
|
}
|
|
57
55
|
/**
|
|
58
56
|
* Format response information for debugging
|
|
@@ -297,7 +295,7 @@ async function executeRequest(apiCall) {
|
|
|
297
295
|
status: 0,
|
|
298
296
|
statusText: "Network Error"
|
|
299
297
|
});
|
|
300
|
-
|
|
298
|
+
return {
|
|
301
299
|
data: null,
|
|
302
300
|
error: {
|
|
303
301
|
success: false,
|
|
@@ -307,7 +305,6 @@ async function executeRequest(apiCall) {
|
|
|
307
305
|
},
|
|
308
306
|
response: mockResponse
|
|
309
307
|
};
|
|
310
|
-
return errorResult;
|
|
311
308
|
}
|
|
312
309
|
}
|
|
313
310
|
/**
|
|
@@ -414,8 +411,7 @@ var BaseAPIClient = class {
|
|
|
414
411
|
*/
|
|
415
412
|
function getPathnameFromUrl(url) {
|
|
416
413
|
try {
|
|
417
|
-
|
|
418
|
-
return urlObj.pathname;
|
|
414
|
+
return new URL(url).pathname;
|
|
419
415
|
} catch {
|
|
420
416
|
return url.split("?")[0] || url;
|
|
421
417
|
}
|
|
@@ -492,8 +488,7 @@ function isTokenExpired(token, bufferSeconds = 30) {
|
|
|
492
488
|
* @returns User ID (ulid) or null if token is invalid
|
|
493
489
|
*/
|
|
494
490
|
function getUserIdFromToken(token) {
|
|
495
|
-
|
|
496
|
-
return userInfo?.id || null;
|
|
491
|
+
return extractUserInfoFromToken(token)?.id || null;
|
|
497
492
|
}
|
|
498
493
|
/**
|
|
499
494
|
* Check if user is logged in based on JWT token
|
|
@@ -502,8 +497,7 @@ function getUserIdFromToken(token) {
|
|
|
502
497
|
* @returns True if user is logged in, false otherwise
|
|
503
498
|
*/
|
|
504
499
|
function isUserLoggedIn(token) {
|
|
505
|
-
|
|
506
|
-
return userInfo?.isLoggedIn || false;
|
|
500
|
+
return extractUserInfoFromToken(token)?.isLoggedIn || false;
|
|
507
501
|
}
|
|
508
502
|
/**
|
|
509
503
|
* Check if user is authenticated (has valid POS token)
|
|
@@ -513,8 +507,7 @@ function isUserLoggedIn(token) {
|
|
|
513
507
|
* @returns True if user is authenticated with valid POS access
|
|
514
508
|
*/
|
|
515
509
|
function isUserAuthenticated(token) {
|
|
516
|
-
|
|
517
|
-
return !!userInfo?.isLoggedIn;
|
|
510
|
+
return !!extractUserInfoFromToken(token)?.isLoggedIn;
|
|
518
511
|
}
|
|
519
512
|
/**
|
|
520
513
|
* Get the location ID from a POS JWT token
|
|
@@ -523,8 +516,7 @@ function isUserAuthenticated(token) {
|
|
|
523
516
|
* @returns Location ID or null if token is invalid
|
|
524
517
|
*/
|
|
525
518
|
function getLocationIdFromToken(token) {
|
|
526
|
-
|
|
527
|
-
return userInfo?.location?.id || null;
|
|
519
|
+
return extractUserInfoFromToken(token)?.location?.id || null;
|
|
528
520
|
}
|
|
529
521
|
/**
|
|
530
522
|
* Get the role information from a POS JWT token for the current location
|
|
@@ -535,8 +527,7 @@ function getLocationIdFromToken(token) {
|
|
|
535
527
|
function getRoleFromToken(token) {
|
|
536
528
|
const userInfo = extractUserInfoFromToken(token);
|
|
537
529
|
if (!userInfo?.roles || userInfo.roles.length === 0) return null;
|
|
538
|
-
|
|
539
|
-
return currentLocationRole || userInfo.roles[0] || null;
|
|
530
|
+
return userInfo.roles.find((role) => role.locationId === userInfo.location.id) || userInfo.roles[0] || null;
|
|
540
531
|
}
|
|
541
532
|
/**
|
|
542
533
|
* Get the tenant ID from a POS JWT token
|
|
@@ -545,8 +536,7 @@ function getRoleFromToken(token) {
|
|
|
545
536
|
* @returns Tenant ID or null if token is invalid
|
|
546
537
|
*/
|
|
547
538
|
function getTenantIdFromToken(token) {
|
|
548
|
-
|
|
549
|
-
return userInfo?.tenantId || null;
|
|
539
|
+
return extractUserInfoFromToken(token)?.tenantId || null;
|
|
550
540
|
}
|
|
551
541
|
|
|
552
542
|
//#endregion
|
|
@@ -561,15 +551,14 @@ function getTenantIdFromToken(token) {
|
|
|
561
551
|
* - /pos/auth/verify-otp
|
|
562
552
|
*/
|
|
563
553
|
function isApiKeyEndpoint(pathname) {
|
|
564
|
-
|
|
554
|
+
return [
|
|
565
555
|
"/pos/auth/login/email",
|
|
566
556
|
"/pos/auth/login/phone",
|
|
567
557
|
"/pos/auth/login/whatsapp",
|
|
568
558
|
"/pos/auth/pair-device",
|
|
569
559
|
"/pos/auth/verify-otp",
|
|
570
560
|
"/pos/locations"
|
|
571
|
-
];
|
|
572
|
-
return apiKeyEndpoints.some((endpoint) => pathname.includes(endpoint));
|
|
561
|
+
].some((endpoint) => pathname.includes(endpoint));
|
|
573
562
|
}
|
|
574
563
|
/**
|
|
575
564
|
* Check if a URL path is a POS endpoint that returns tokens
|
|
@@ -578,8 +567,7 @@ function isApiKeyEndpoint(pathname) {
|
|
|
578
567
|
* - /pos/auth/refresh-token
|
|
579
568
|
*/
|
|
580
569
|
function isTokenReturningEndpoint(pathname) {
|
|
581
|
-
|
|
582
|
-
return tokenEndpoints.some((endpoint) => pathname.includes(endpoint));
|
|
570
|
+
return ["/pos/auth/verify-otp", "/pos/auth/refresh-token"].some((endpoint) => pathname.includes(endpoint));
|
|
583
571
|
}
|
|
584
572
|
/**
|
|
585
573
|
* Check if a URL path is a POS logout endpoint
|
|
@@ -815,8 +803,7 @@ let Environment = /* @__PURE__ */ function(Environment$1) {
|
|
|
815
803
|
*/
|
|
816
804
|
function buildPosURL(config) {
|
|
817
805
|
if (config.baseUrl) return config.baseUrl.replace(/\/$/, "");
|
|
818
|
-
|
|
819
|
-
switch (env) {
|
|
806
|
+
switch (config.environment || Environment.Production) {
|
|
820
807
|
case Environment.Staging: return `https://staging.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
821
808
|
case Environment.Production:
|
|
822
809
|
default: return `https://prod.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
@@ -873,14 +860,16 @@ var PosAPIClient = class PosAPIClient extends BaseAPIClient {
|
|
|
873
860
|
environment: config.environment,
|
|
874
861
|
baseUrl: config.baseUrl
|
|
875
862
|
});
|
|
876
|
-
const headerTransformations = { customer_group_id: "x-customer-group-id" };
|
|
877
863
|
super({
|
|
878
864
|
baseUrl,
|
|
879
865
|
timeout: config.timeout,
|
|
880
866
|
defaultHeaders: config.defaultHeaders,
|
|
881
867
|
debug: config.debug,
|
|
882
868
|
logger: config.logger
|
|
883
|
-
}, baseUrl,
|
|
869
|
+
}, baseUrl, {
|
|
870
|
+
customer_group_id: "x-customer-group-id",
|
|
871
|
+
debug_mode: "x-debug-mode"
|
|
872
|
+
});
|
|
884
873
|
this.config = { ...config };
|
|
885
874
|
this.setupPosAuth();
|
|
886
875
|
}
|
|
@@ -1023,8 +1012,12 @@ var PosClient = class extends PosAPIClient {
|
|
|
1023
1012
|
* }
|
|
1024
1013
|
* ```
|
|
1025
1014
|
*/
|
|
1026
|
-
async loginWithEmail(body) {
|
|
1027
|
-
|
|
1015
|
+
async loginWithEmail(headers, body) {
|
|
1016
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
1017
|
+
return this.executeRequest(() => this.client.POST("/pos/auth/login/email", {
|
|
1018
|
+
body,
|
|
1019
|
+
params: { header: mergedHeaders }
|
|
1020
|
+
}));
|
|
1028
1021
|
}
|
|
1029
1022
|
/**
|
|
1030
1023
|
* Login with phone number
|
|
@@ -1047,8 +1040,12 @@ var PosClient = class extends PosAPIClient {
|
|
|
1047
1040
|
* }
|
|
1048
1041
|
* ```
|
|
1049
1042
|
*/
|
|
1050
|
-
async loginWithPhone(body) {
|
|
1051
|
-
|
|
1043
|
+
async loginWithPhone(headers, body) {
|
|
1044
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
1045
|
+
return this.executeRequest(() => this.client.POST("/pos/auth/login/phone", {
|
|
1046
|
+
body,
|
|
1047
|
+
params: { header: mergedHeaders }
|
|
1048
|
+
}));
|
|
1052
1049
|
}
|
|
1053
1050
|
/**
|
|
1054
1051
|
* Login with WhatsApp
|
|
@@ -1071,8 +1068,12 @@ var PosClient = class extends PosAPIClient {
|
|
|
1071
1068
|
* }
|
|
1072
1069
|
* ```
|
|
1073
1070
|
*/
|
|
1074
|
-
async loginWithWhatsapp(body) {
|
|
1075
|
-
|
|
1071
|
+
async loginWithWhatsapp(headers, body) {
|
|
1072
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
1073
|
+
return this.executeRequest(() => this.client.POST("/pos/auth/login/whatsapp", {
|
|
1074
|
+
body,
|
|
1075
|
+
params: { header: mergedHeaders }
|
|
1076
|
+
}));
|
|
1076
1077
|
}
|
|
1077
1078
|
/**
|
|
1078
1079
|
* Verify OTP
|
|
@@ -1313,6 +1314,27 @@ var PosClient = class extends PosAPIClient {
|
|
|
1313
1314
|
return this.executeRequest(() => this.client.GET("/pos/carts/{id}", { params: { path: pathParams } }));
|
|
1314
1315
|
}
|
|
1315
1316
|
/**
|
|
1317
|
+
* Get cart details by user ID
|
|
1318
|
+
* @param pathParams - User ID
|
|
1319
|
+
* @returns Promise with cart details
|
|
1320
|
+
* @example
|
|
1321
|
+
* ```typescript
|
|
1322
|
+
* const { data, error } = await pos.getUserCart({
|
|
1323
|
+
* user_id: "01H9CART12345ABCDE"
|
|
1324
|
+
* });
|
|
1325
|
+
*
|
|
1326
|
+
* if (error) {
|
|
1327
|
+
* console.error("Failed to get user cart:", error.message);
|
|
1328
|
+
* } else {
|
|
1329
|
+
* console.log("User cart ID:", data.cart.id);
|
|
1330
|
+
* console.log("Cart value:", data.cart.subtotal_amount);
|
|
1331
|
+
* }
|
|
1332
|
+
* ```
|
|
1333
|
+
*/
|
|
1334
|
+
async getUserCart(pathParams) {
|
|
1335
|
+
return this.executeRequest(() => this.client.GET("/pos/carts/users/{user_id}", { params: { path: pathParams } }));
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1316
1338
|
* Delete cart (remove all items)
|
|
1317
1339
|
* @param pathParams - Cart ID
|
|
1318
1340
|
* @returns Promise with deletion confirmation
|