@commercengine/pos 0.4.4 → 0.4.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/admin-types.d.mts +531 -258
- package/dist/admin-types.mjs +1 -1
- package/dist/index.d.mts +1565 -775
- package/dist/index.mjs +6 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import createClient from "openapi-fetch";
|
|
2
|
-
|
|
3
2
|
//#region ../sdk-core/dist/index.mjs
|
|
4
3
|
/**
|
|
5
4
|
* Response utilities for debugging and working with Response objects
|
|
@@ -427,7 +426,6 @@ function getPathnameFromUrl(url) {
|
|
|
427
426
|
return url.split("?")[0] || url;
|
|
428
427
|
}
|
|
429
428
|
}
|
|
430
|
-
|
|
431
429
|
//#endregion
|
|
432
430
|
//#region src/lib/utils/jwt.ts
|
|
433
431
|
/**
|
|
@@ -571,7 +569,6 @@ function getRoleFromToken(token) {
|
|
|
571
569
|
function getTenantIdFromToken(token) {
|
|
572
570
|
return extractUserInfoFromToken(token)?.tenantId || null;
|
|
573
571
|
}
|
|
574
|
-
|
|
575
572
|
//#endregion
|
|
576
573
|
//#region src/lib/utils/auth.ts
|
|
577
574
|
/**
|
|
@@ -608,7 +605,6 @@ function isTokenReturningEndpoint(pathname) {
|
|
|
608
605
|
function isLogoutEndpoint(pathname) {
|
|
609
606
|
return pathname.includes("/pos/auth/logout") || pathname.includes("/pos/logout");
|
|
610
607
|
}
|
|
611
|
-
|
|
612
608
|
//#endregion
|
|
613
609
|
//#region src/lib/middleware/auth.ts
|
|
614
610
|
/**
|
|
@@ -820,7 +816,6 @@ function createDefaultPosAuthMiddleware(options) {
|
|
|
820
816
|
onTokensCleared: options.onTokensCleared
|
|
821
817
|
});
|
|
822
818
|
}
|
|
823
|
-
|
|
824
819
|
//#endregion
|
|
825
820
|
//#region src/lib/utils/url.ts
|
|
826
821
|
/**
|
|
@@ -840,13 +835,11 @@ let Environment = /* @__PURE__ */ function(Environment) {
|
|
|
840
835
|
*/
|
|
841
836
|
function buildPosURL(config) {
|
|
842
837
|
if (config.baseUrl) return config.baseUrl.replace(/\/$/, "");
|
|
843
|
-
switch (config.environment ||
|
|
844
|
-
case
|
|
845
|
-
case Environment.Production:
|
|
838
|
+
switch (config.environment || "production") {
|
|
839
|
+
case "staging": return `https://staging.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
846
840
|
default: return `https://prod.api.commercengine.io/api/v1/${config.storeId}/storefront`;
|
|
847
841
|
}
|
|
848
842
|
}
|
|
849
|
-
|
|
850
843
|
//#endregion
|
|
851
844
|
//#region src/lib/client.ts
|
|
852
845
|
/**
|
|
@@ -1020,7 +1013,6 @@ var PosAPIClient = class PosAPIClient extends BaseAPIClient {
|
|
|
1020
1013
|
return this.client;
|
|
1021
1014
|
}
|
|
1022
1015
|
};
|
|
1023
|
-
|
|
1024
1016
|
//#endregion
|
|
1025
1017
|
//#region src/lib/pos.ts
|
|
1026
1018
|
/**
|
|
@@ -2961,7 +2953,6 @@ var PosClient = class extends PosAPIClient {
|
|
|
2961
2953
|
}));
|
|
2962
2954
|
}
|
|
2963
2955
|
};
|
|
2964
|
-
|
|
2965
2956
|
//#endregion
|
|
2966
2957
|
//#region src/index.ts
|
|
2967
2958
|
/**
|
|
@@ -2979,7 +2970,7 @@ var PosSDK = class {
|
|
|
2979
2970
|
* @param options - Configuration options for the SDK
|
|
2980
2971
|
*/
|
|
2981
2972
|
constructor(options) {
|
|
2982
|
-
|
|
2973
|
+
const config = {
|
|
2983
2974
|
storeId: options.storeId,
|
|
2984
2975
|
environment: options.environment,
|
|
2985
2976
|
baseUrl: options.baseUrl,
|
|
@@ -2993,7 +2984,8 @@ var PosSDK = class {
|
|
|
2993
2984
|
defaultHeaders: options.defaultHeaders,
|
|
2994
2985
|
debug: options.debug,
|
|
2995
2986
|
logger: options.logger
|
|
2996
|
-
}
|
|
2987
|
+
};
|
|
2988
|
+
this.pos = new PosClient(config);
|
|
2997
2989
|
}
|
|
2998
2990
|
/**
|
|
2999
2991
|
* Set authentication tokens for the client
|
|
@@ -3120,7 +3112,7 @@ var PosSDK = class {
|
|
|
3120
3112
|
return getTenantIdFromToken(token);
|
|
3121
3113
|
}
|
|
3122
3114
|
};
|
|
3123
|
-
|
|
3124
3115
|
//#endregion
|
|
3125
3116
|
export { BrowserTokenStorage, Environment, MemoryTokenStorage, PosAPIClient, PosClient, PosSDK, PosSDK as default, ResponseUtils };
|
|
3117
|
+
|
|
3126
3118
|
//# sourceMappingURL=index.mjs.map
|