@gradientedge/commercetools-utils 4.11.2 → 4.11.3
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/ge-commercetools-utils-browser.cjs.js +2 -0
- package/dist/ge-commercetools-utils-browser.cjs.js.map +1 -0
- package/dist/ge-commercetools-utils-browser.esm.js +2 -0
- package/dist/ge-commercetools-utils-browser.esm.js.map +1 -0
- package/dist/ge-commercetools-utils-node.cjs.js +2 -0
- package/dist/ge-commercetools-utils-node.cjs.js.map +1 -0
- package/dist/ge-commercetools-utils-node.esm.js +1 -0
- package/dist/typings/api/CommercetoolsApi.d.ts +436 -0
- package/dist/{api → typings/api}/index.d.ts +0 -1
- package/dist/typings/api/types.d.ts +12 -0
- package/dist/typings/auth/CommercetoolsAuth.d.ts +22 -0
- package/dist/typings/auth/CommercetoolsAuthApi.d.ts +21 -0
- package/dist/typings/auth/CommercetoolsGrant.d.ts +13 -0
- package/dist/{auth → typings/auth}/constants.d.ts +0 -4
- package/dist/{auth → typings/auth}/index.d.ts +0 -1
- package/dist/typings/auth/scopes.d.ts +2 -0
- package/dist/typings/auth/types.d.ts +43 -0
- package/dist/{auth → typings/auth}/utils.d.ts +0 -1
- package/dist/typings/constants.d.ts +1 -0
- package/dist/typings/error/CommercetoolsError.d.ts +16 -0
- package/dist/{error → typings/error}/index.d.ts +0 -1
- package/dist/{index.d.ts → typings/index.d.ts} +0 -1
- package/dist/typings/types.d.ts +21 -0
- package/dist/typings/utils/format.d.ts +1 -0
- package/dist/{utils → typings/utils}/index.d.ts +0 -2
- package/dist/typings/utils/mask.d.ts +6 -0
- package/dist/typings/utils/useragent.d.ts +1 -0
- package/package.json +23 -7
- package/dist/api/CommercetoolsApi.d.ts +0 -1096
- package/dist/api/CommercetoolsApi.d.ts.map +0 -1
- package/dist/api/CommercetoolsApi.js +0 -1425
- package/dist/api/CommercetoolsApi.js.map +0 -1
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -15
- package/dist/api/index.js.map +0 -1
- package/dist/api/types.d.ts +0 -33
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -3
- package/dist/api/types.js.map +0 -1
- package/dist/auth/CommercetoolsAuth.d.ts +0 -182
- package/dist/auth/CommercetoolsAuth.d.ts.map +0 -1
- package/dist/auth/CommercetoolsAuth.js +0 -326
- package/dist/auth/CommercetoolsAuth.js.map +0 -1
- package/dist/auth/CommercetoolsAuthApi.d.ts +0 -74
- package/dist/auth/CommercetoolsAuthApi.d.ts.map +0 -1
- package/dist/auth/CommercetoolsAuthApi.js +0 -248
- package/dist/auth/CommercetoolsAuthApi.js.map +0 -1
- package/dist/auth/CommercetoolsGrant.d.ts +0 -66
- package/dist/auth/CommercetoolsGrant.d.ts.map +0 -1
- package/dist/auth/CommercetoolsGrant.js +0 -82
- package/dist/auth/CommercetoolsGrant.js.map +0 -1
- package/dist/auth/constants.d.ts.map +0 -1
- package/dist/auth/constants.js +0 -32
- package/dist/auth/constants.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -15
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/scopes.d.ts +0 -11
- package/dist/auth/scopes.d.ts.map +0 -1
- package/dist/auth/scopes.js +0 -30
- package/dist/auth/scopes.js.map +0 -1
- package/dist/auth/types.d.ts +0 -120
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js +0 -28
- package/dist/auth/types.js.map +0 -1
- package/dist/auth/utils.d.ts.map +0 -1
- package/dist/auth/utils.js +0 -15
- package/dist/auth/utils.js.map +0 -1
- package/dist/constants.d.ts +0 -6
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -9
- package/dist/constants.js.map +0 -1
- package/dist/error/CommercetoolsError.d.ts +0 -38
- package/dist/error/CommercetoolsError.d.ts.map +0 -1
- package/dist/error/CommercetoolsError.js +0 -117
- package/dist/error/CommercetoolsError.js.map +0 -1
- package/dist/error/index.d.ts.map +0 -1
- package/dist/error/index.js +0 -14
- package/dist/error/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -44
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -16
- package/dist/types.js.map +0 -1
- package/dist/utils/format.d.ts +0 -11
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js +0 -48
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -17
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/isNode.d.ts +0 -2
- package/dist/utils/isNode.d.ts.map +0 -1
- package/dist/utils/isNode.js +0 -12
- package/dist/utils/isNode.js.map +0 -1
- package/dist/utils/mask.d.ts +0 -28
- package/dist/utils/mask.d.ts.map +0 -1
- package/dist/utils/mask.js +0 -56
- package/dist/utils/mask.js.map +0 -1
- package/dist/utils/useragent.d.ts +0 -10
- package/dist/utils/useragent.d.ts.map +0 -1
- package/dist/utils/useragent.js +0 -20
- package/dist/utils/useragent.js.map +0 -1
package/dist/auth/types.d.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { CommercetoolsBaseConfig, Region } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Configuration for {@see CommercetoolsAuth}
|
|
4
|
-
*/
|
|
5
|
-
export interface CommercetoolsAuthConfig extends CommercetoolsBaseConfig {
|
|
6
|
-
refreshIfWithinSecs?: number;
|
|
7
|
-
customerScopes?: string[];
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Configuration for {@see CommercetoolsAuthApi}
|
|
11
|
-
*/
|
|
12
|
-
export interface CommercetoolsAuthApiConfig {
|
|
13
|
-
projectKey: string;
|
|
14
|
-
clientId: string;
|
|
15
|
-
clientSecret: string;
|
|
16
|
-
region: Region;
|
|
17
|
-
timeoutMs?: number;
|
|
18
|
-
systemIdentifier?: string;
|
|
19
|
-
storeKey?: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The object structure that we receive back from commercetools
|
|
23
|
-
* on a successful call to get a new grant, or refresh an existing one.
|
|
24
|
-
*/
|
|
25
|
-
export interface CommercetoolsGrantResponse {
|
|
26
|
-
access_token: string;
|
|
27
|
-
refresh_token?: string;
|
|
28
|
-
expires_in: number;
|
|
29
|
-
scope: string;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* This is the LoginOptions description
|
|
33
|
-
*/
|
|
34
|
-
export interface LoginOptions {
|
|
35
|
-
/**
|
|
36
|
-
* The customer's username (email address)
|
|
37
|
-
*/
|
|
38
|
-
username: string;
|
|
39
|
-
/**
|
|
40
|
-
* The customer's password
|
|
41
|
-
*/
|
|
42
|
-
password: string;
|
|
43
|
-
/**
|
|
44
|
-
* The scopes to which you want to restrict the customer grant. Note that
|
|
45
|
-
* these must be a subset of the scopes associated with the client grant.
|
|
46
|
-
*/
|
|
47
|
-
scopes?: string[];
|
|
48
|
-
/**
|
|
49
|
-
* The key of the store to login to
|
|
50
|
-
*/
|
|
51
|
-
storeKey?: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* RevokeTokenOptions
|
|
55
|
-
*/
|
|
56
|
-
export interface RevokeTokenOptions {
|
|
57
|
-
/**
|
|
58
|
-
* The type of token to be revoked
|
|
59
|
-
*/
|
|
60
|
-
tokenType: 'access_token' | 'refresh_token';
|
|
61
|
-
/**
|
|
62
|
-
* The value of the token to be revoked
|
|
63
|
-
*/
|
|
64
|
-
tokenValue: string;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* LogoutOptions
|
|
68
|
-
*/
|
|
69
|
-
export interface LogoutOptions {
|
|
70
|
-
/**
|
|
71
|
-
* The customer's access token
|
|
72
|
-
*/
|
|
73
|
-
accessToken: string;
|
|
74
|
-
/**
|
|
75
|
-
* The customer's refresh token
|
|
76
|
-
*/
|
|
77
|
-
refreshToken: string;
|
|
78
|
-
}
|
|
79
|
-
export interface AnonymousGrantOptions {
|
|
80
|
-
/**
|
|
81
|
-
* The scopes of the anonymous customer must be less than or equal to
|
|
82
|
-
* the scopes of the client API key (ideally, less). If you don't specify
|
|
83
|
-
* the scopes using this property, then the code will check for the scopes
|
|
84
|
-
* defined on {@link CommercetoolsAuthConfig.customerScopes}. If scopes
|
|
85
|
-
* aren't defined there either, than an error will be thrown when a call
|
|
86
|
-
* is made to {@link CommercetoolsAuth.getAnonymousGrant}
|
|
87
|
-
*/
|
|
88
|
-
scopes?: string[];
|
|
89
|
-
/**
|
|
90
|
-
* If you specify this, you need to be sure that the value does not
|
|
91
|
-
* already exist as an anonymous customer id in the commercetools system
|
|
92
|
-
* under your project key. If it does, an error will be thrown when
|
|
93
|
-
* trying to create the access token.
|
|
94
|
-
*/
|
|
95
|
-
anonymousId?: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Authentication grant types.
|
|
99
|
-
* These are used when populating the 'grant_type' parameter.
|
|
100
|
-
*/
|
|
101
|
-
export declare enum GrantType {
|
|
102
|
-
/**
|
|
103
|
-
* Used when either requesting a client grant or an
|
|
104
|
-
* anonymous customer access token:
|
|
105
|
-
* https://docs.commercetools.com/api/authorization#client-credentials-flow
|
|
106
|
-
* https://docs.commercetools.com/api/authorization#tokens-for-anonymous-sessions
|
|
107
|
-
*/
|
|
108
|
-
CLIENT_CREDENTIALS = "client_credentials",
|
|
109
|
-
/**
|
|
110
|
-
* Used when refreshing any existing access token (whether client or customer):
|
|
111
|
-
* https://docs.commercetools.com/api/authorization#refresh-token-flow
|
|
112
|
-
*/
|
|
113
|
-
REFRESH_TOKEN = "refresh_token",
|
|
114
|
-
/**
|
|
115
|
-
* Used when attempting to login a customer:
|
|
116
|
-
* https://docs.commercetools.com/api/authorization#password-flow
|
|
117
|
-
*/
|
|
118
|
-
PASSWORD = "password"
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/auth/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAE1D;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,uBAAuB;IACtE,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,EAAE,cAAc,GAAG,eAAe,CAAA;IAE3C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,oBAAY,SAAS;IACnB;;;;;OAKG;IACH,kBAAkB,uBAAuB;IACzC;;;OAGG;IACH,aAAa,kBAAkB;IAC/B;;;OAGG;IACH,QAAQ,aAAa;CACtB"}
|
package/dist/auth/types.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GrantType = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Authentication grant types.
|
|
6
|
-
* These are used when populating the 'grant_type' parameter.
|
|
7
|
-
*/
|
|
8
|
-
var GrantType;
|
|
9
|
-
(function (GrantType) {
|
|
10
|
-
/**
|
|
11
|
-
* Used when either requesting a client grant or an
|
|
12
|
-
* anonymous customer access token:
|
|
13
|
-
* https://docs.commercetools.com/api/authorization#client-credentials-flow
|
|
14
|
-
* https://docs.commercetools.com/api/authorization#tokens-for-anonymous-sessions
|
|
15
|
-
*/
|
|
16
|
-
GrantType["CLIENT_CREDENTIALS"] = "client_credentials";
|
|
17
|
-
/**
|
|
18
|
-
* Used when refreshing any existing access token (whether client or customer):
|
|
19
|
-
* https://docs.commercetools.com/api/authorization#refresh-token-flow
|
|
20
|
-
*/
|
|
21
|
-
GrantType["REFRESH_TOKEN"] = "refresh_token";
|
|
22
|
-
/**
|
|
23
|
-
* Used when attempting to login a customer:
|
|
24
|
-
* https://docs.commercetools.com/api/authorization#password-flow
|
|
25
|
-
*/
|
|
26
|
-
GrantType["PASSWORD"] = "password";
|
|
27
|
-
})(GrantType = exports.GrantType || (exports.GrantType = {}));
|
|
28
|
-
//# sourceMappingURL=types.js.map
|
package/dist/auth/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/auth/types.ts"],"names":[],"mappings":";;;AA6GA;;;GAGG;AACH,IAAY,SAkBX;AAlBD,WAAY,SAAS;IACnB;;;;;OAKG;IACH,sDAAyC,CAAA;IACzC;;;OAGG;IACH,4CAA+B,CAAA;IAC/B;;;OAGG;IACH,kCAAqB,CAAA;AACvB,CAAC,EAlBW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAkBpB"}
|
package/dist/auth/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/auth/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAO1E"}
|
package/dist/auth/utils.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.base64EncodeForBasicAuth = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
function base64EncodeForBasicAuth(username, password) {
|
|
6
|
-
var toEncode = "".concat(username, ":").concat(password);
|
|
7
|
-
if ((0, utils_1.isNode)()) {
|
|
8
|
-
return Buffer.from(toEncode).toString('base64');
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return btoa(toEncode);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.base64EncodeForBasicAuth = base64EncodeForBasicAuth;
|
|
15
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/auth/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/auth/utils.ts"],"names":[],"mappings":";;;AAAA,kCAAiC;AAEjC,SAAgB,wBAAwB,CAAC,QAAgB,EAAE,QAAgB;IACzE,IAAM,QAAQ,GAAG,UAAG,QAAQ,cAAI,QAAQ,CAAE,CAAA;IAC1C,IAAI,IAAA,cAAM,GAAE,EAAE;QACZ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;KAChD;SAAM;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAA;KACtB;AACH,CAAC;AAPD,4DAOC"}
|
package/dist/constants.d.ts
DELETED
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/lib/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAA"}
|
package/dist/constants.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_REQUEST_TIMEOUT_MS = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The standard request timeout value (in milliseconds). We pass
|
|
6
|
-
* this to `axios` when making the request to commercetools.
|
|
7
|
-
*/
|
|
8
|
-
exports.DEFAULT_REQUEST_TIMEOUT_MS = 5000;
|
|
9
|
-
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/lib/constants.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,0BAA0B,GAAG,IAAI,CAAA"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { AxiosError, AxiosRequestConfig } from 'axios';
|
|
2
|
-
/**
|
|
3
|
-
* The error class thrown by any of the utility classes.
|
|
4
|
-
*/
|
|
5
|
-
export declare class CommercetoolsError extends Error {
|
|
6
|
-
/**
|
|
7
|
-
* The data passed in to the error class. This could be anything,
|
|
8
|
-
* but is most likely to be the response from a commercetools request.
|
|
9
|
-
*/
|
|
10
|
-
readonly data?: any;
|
|
11
|
-
/**
|
|
12
|
-
* If available, this is the status code of the request received
|
|
13
|
-
* back from commercetools: https://docs.commercetools.com/api/errors
|
|
14
|
-
*/
|
|
15
|
-
readonly status: number | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Convenience mechanism for identifying that the error that's
|
|
18
|
-
* just been caught is a CommercetoolsError.
|
|
19
|
-
*/
|
|
20
|
-
readonly isCommercetoolsError = true;
|
|
21
|
-
constructor(message: string, data?: any, status?: number);
|
|
22
|
-
/**
|
|
23
|
-
* Utility for converting an AxiosError in to a CommercetoolsError.
|
|
24
|
-
*/
|
|
25
|
-
static fromAxiosError(e: AxiosError): CommercetoolsError;
|
|
26
|
-
/**
|
|
27
|
-
* Parse the JSON string back in to an object for easier viewing
|
|
28
|
-
*/
|
|
29
|
-
static parseRequestData(config: AxiosRequestConfig): any;
|
|
30
|
-
toJSON(): {
|
|
31
|
-
status: number | undefined;
|
|
32
|
-
message: string;
|
|
33
|
-
data: any;
|
|
34
|
-
isCommercetoolsError: boolean;
|
|
35
|
-
};
|
|
36
|
-
toString(): string;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=CommercetoolsError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommercetoolsError.d.ts","sourceRoot":"","sources":["../../src/lib/error/CommercetoolsError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAGtD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C;;;OAGG;IACH,SAAgB,IAAI,CAAC,EAAE,GAAG,CAAA;IAE1B;;;OAGG;IACH,SAAgB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAE1C;;;OAGG;IACH,SAAgB,oBAAoB,QAAO;gBAE/B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM;IASxD;;OAEG;WACW,cAAc,CAAC,CAAC,EAAE,UAAU;IAsB1C;;OAEG;WACW,gBAAgB,CAAC,MAAM,EAAE,kBAAkB;IAgCzD,MAAM;;;;;;IASN,QAAQ;CAGT"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CommercetoolsError = void 0;
|
|
22
|
-
var json_stringify_safe_1 = __importDefault(require("json-stringify-safe"));
|
|
23
|
-
var utils_1 = require("../utils");
|
|
24
|
-
/**
|
|
25
|
-
* The error class thrown by any of the utility classes.
|
|
26
|
-
*/
|
|
27
|
-
var CommercetoolsError = /** @class */ (function (_super) {
|
|
28
|
-
__extends(CommercetoolsError, _super);
|
|
29
|
-
function CommercetoolsError(message, data, status) {
|
|
30
|
-
var _this = _super.call(this, message) || this;
|
|
31
|
-
/**
|
|
32
|
-
* Convenience mechanism for identifying that the error that's
|
|
33
|
-
* just been caught is a CommercetoolsError.
|
|
34
|
-
*/
|
|
35
|
-
_this.isCommercetoolsError = true;
|
|
36
|
-
_this.data = data;
|
|
37
|
-
_this.status = status;
|
|
38
|
-
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
39
|
-
Object.setPrototypeOf(_this, CommercetoolsError.prototype);
|
|
40
|
-
return _this;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Utility for converting an AxiosError in to a CommercetoolsError.
|
|
44
|
-
*/
|
|
45
|
-
CommercetoolsError.fromAxiosError = function (e) {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
47
|
-
return new CommercetoolsError(e.message, {
|
|
48
|
-
code: e.code,
|
|
49
|
-
request: {
|
|
50
|
-
url: (_a = e.config) === null || _a === void 0 ? void 0 : _a.url,
|
|
51
|
-
method: (_b = e.config) === null || _b === void 0 ? void 0 : _b.method,
|
|
52
|
-
headers: (0, utils_1.maskSensitiveHeaders)((_c = e.config) === null || _c === void 0 ? void 0 : _c.headers),
|
|
53
|
-
params: (0, utils_1.maskSensitiveInput)((_d = e.config) === null || _d === void 0 ? void 0 : _d.params),
|
|
54
|
-
data: (0, utils_1.maskSensitiveInput)(this.parseRequestData(e.config)),
|
|
55
|
-
},
|
|
56
|
-
response: {
|
|
57
|
-
status: (_e = e.response) === null || _e === void 0 ? void 0 : _e.status,
|
|
58
|
-
data: (0, utils_1.maskSensitiveInput)((_f = e.response) === null || _f === void 0 ? void 0 : _f.data),
|
|
59
|
-
headers: (_g = e.response) === null || _g === void 0 ? void 0 : _g.headers,
|
|
60
|
-
},
|
|
61
|
-
}, (_h = e.response) === null || _h === void 0 ? void 0 : _h.status);
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Parse the JSON string back in to an object for easier viewing
|
|
65
|
-
*/
|
|
66
|
-
CommercetoolsError.parseRequestData = function (config) {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
var data = config === null || config === void 0 ? void 0 : config.data;
|
|
69
|
-
if (typeof data === 'string' && data) {
|
|
70
|
-
var contentType = '';
|
|
71
|
-
if (typeof ((_a = config === null || config === void 0 ? void 0 : config.headers) === null || _a === void 0 ? void 0 : _a['Content-Type']) === 'string') {
|
|
72
|
-
contentType = (_b = config === null || config === void 0 ? void 0 : config.headers) === null || _b === void 0 ? void 0 : _b['Content-Type'];
|
|
73
|
-
}
|
|
74
|
-
if (contentType.substring(0, 16) === 'application/json') {
|
|
75
|
-
try {
|
|
76
|
-
data = JSON.parse(config.data);
|
|
77
|
-
}
|
|
78
|
-
catch (e) { }
|
|
79
|
-
}
|
|
80
|
-
else if (contentType.substring(0, 33) === 'application/x-www-form-urlencoded') {
|
|
81
|
-
try {
|
|
82
|
-
var searchParams = new URLSearchParams(config.data);
|
|
83
|
-
var paramsObj_1 = {};
|
|
84
|
-
searchParams.forEach(function (value, key, searchParams) {
|
|
85
|
-
var values = searchParams.getAll(key);
|
|
86
|
-
if (values.length === 0) {
|
|
87
|
-
paramsObj_1[key] = '';
|
|
88
|
-
}
|
|
89
|
-
else if (values.length === 1) {
|
|
90
|
-
paramsObj_1[key] = values[0];
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
paramsObj_1[key] = values;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
data = paramsObj_1;
|
|
97
|
-
}
|
|
98
|
-
catch (e) { }
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return data;
|
|
102
|
-
};
|
|
103
|
-
CommercetoolsError.prototype.toJSON = function () {
|
|
104
|
-
return {
|
|
105
|
-
status: this.status,
|
|
106
|
-
message: this.message,
|
|
107
|
-
data: this.data,
|
|
108
|
-
isCommercetoolsError: true,
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
CommercetoolsError.prototype.toString = function () {
|
|
112
|
-
return (0, json_stringify_safe_1.default)(this.toJSON());
|
|
113
|
-
};
|
|
114
|
-
return CommercetoolsError;
|
|
115
|
-
}(Error));
|
|
116
|
-
exports.CommercetoolsError = CommercetoolsError;
|
|
117
|
-
//# sourceMappingURL=CommercetoolsError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommercetoolsError.js","sourceRoot":"","sources":["../../src/lib/error/CommercetoolsError.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/error/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
|
package/dist/error/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./CommercetoolsError"), exports);
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
package/dist/error/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAoC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AACtD,cAAc,SAAS,CAAA;AAEvB,cAAc,6BAA6B,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.Region = void 0;
|
|
14
|
-
__exportStar(require("./error"), exports);
|
|
15
|
-
__exportStar(require("./auth"), exports);
|
|
16
|
-
__exportStar(require("./api"), exports);
|
|
17
|
-
var types_1 = require("./types");
|
|
18
|
-
Object.defineProperty(exports, "Region", { enumerable: true, get: function () { return types_1.Region; } });
|
|
19
|
-
__exportStar(require("./utils"), exports);
|
|
20
|
-
__exportStar(require("@commercetools/platform-sdk"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0CAAuB;AACvB,yCAAsB;AACtB,wCAAqB;AACrB,iCAAsD;AAA7C,+FAAA,MAAM,OAAA;AACf,0CAAuB;AAEvB,8DAA2C"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The commercetools region that your API client id/secret relate to.
|
|
3
|
-
* This is used to determine the authentication endpoint.
|
|
4
|
-
*/
|
|
5
|
-
export declare enum Region {
|
|
6
|
-
NORTH_AMERICA_GCP = "north_america_gcp",
|
|
7
|
-
NORTH_AMERICA_AWS = "north_america_aws",
|
|
8
|
-
EUROPE_GCP = "europe_gcp",
|
|
9
|
-
EUROPE_AWS = "europe_aws",
|
|
10
|
-
AUSTRALIA_GCP = "australia_gcp"
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The Authentication and API endpoints for a particular region
|
|
14
|
-
*/
|
|
15
|
-
export interface RegionEndpoints {
|
|
16
|
-
/**
|
|
17
|
-
* The url to the commercetools auth endpoint for the region
|
|
18
|
-
*/
|
|
19
|
-
auth: string;
|
|
20
|
-
/**
|
|
21
|
-
* The url to the commercetools API endpoint for the region
|
|
22
|
-
*/
|
|
23
|
-
api: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Provides a base configuration definition from which other class
|
|
27
|
-
* specific configurations can be extended.
|
|
28
|
-
*/
|
|
29
|
-
export interface CommercetoolsBaseConfig {
|
|
30
|
-
projectKey: string;
|
|
31
|
-
storeKey?: string;
|
|
32
|
-
clientId: string;
|
|
33
|
-
clientSecret: string;
|
|
34
|
-
region: Region;
|
|
35
|
-
clientScopes: string[];
|
|
36
|
-
timeoutMs?: number;
|
|
37
|
-
/**
|
|
38
|
-
* If provided, will be passed across to commercetools in the
|
|
39
|
-
* 'User-Agent' HTTP header, in order to help commercetools
|
|
40
|
-
* identify the source of incoming requests.
|
|
41
|
-
*/
|
|
42
|
-
systemIdentifier?: string;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,MAAM;IAChB,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,aAAa,kBAAkB;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B"}
|
package/dist/types.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Region = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The commercetools region that your API client id/secret relate to.
|
|
6
|
-
* This is used to determine the authentication endpoint.
|
|
7
|
-
*/
|
|
8
|
-
var Region;
|
|
9
|
-
(function (Region) {
|
|
10
|
-
Region["NORTH_AMERICA_GCP"] = "north_america_gcp";
|
|
11
|
-
Region["NORTH_AMERICA_AWS"] = "north_america_aws";
|
|
12
|
-
Region["EUROPE_GCP"] = "europe_gcp";
|
|
13
|
-
Region["EUROPE_AWS"] = "europe_aws";
|
|
14
|
-
Region["AUSTRALIA_GCP"] = "australia_gcp";
|
|
15
|
-
})(Region = exports.Region || (exports.Region = {}));
|
|
16
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/lib/types.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,MAMX;AAND,WAAY,MAAM;IAChB,iDAAuC,CAAA;IACvC,iDAAuC,CAAA;IACvC,mCAAyB,CAAA;IACzB,mCAAyB,CAAA;IACzB,yCAA+B,CAAA;AACjC,CAAC,EANW,MAAM,GAAN,cAAM,KAAN,cAAM,QAMjB"}
|
package/dist/utils/format.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a string for use as a key.
|
|
3
|
-
*
|
|
4
|
-
* Keys may only contain alphanumeric characters, underscores and hyphens
|
|
5
|
-
* and must have a minimum length of 2 characters and maximum length of
|
|
6
|
-
* 256 characters.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} input The string that you want to format as a key
|
|
9
|
-
*/
|
|
10
|
-
export declare function formatAsKey(input: unknown): string;
|
|
11
|
-
//# sourceMappingURL=format.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/lib/utils/format.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,UAoCzC"}
|
package/dist/utils/format.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatAsKey = void 0;
|
|
4
|
-
var error_1 = require("../error");
|
|
5
|
-
/**
|
|
6
|
-
* Format a string for use as a key.
|
|
7
|
-
*
|
|
8
|
-
* Keys may only contain alphanumeric characters, underscores and hyphens
|
|
9
|
-
* and must have a minimum length of 2 characters and maximum length of
|
|
10
|
-
* 256 characters.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} input The string that you want to format as a key
|
|
13
|
-
*/
|
|
14
|
-
function formatAsKey(input) {
|
|
15
|
-
var output = '';
|
|
16
|
-
if (typeof input !== 'string') {
|
|
17
|
-
throw new error_1.CommercetoolsError("The [input] parameter must be a string");
|
|
18
|
-
}
|
|
19
|
-
// Trim and make lowercase
|
|
20
|
-
output = input.trim().toLowerCase();
|
|
21
|
-
// Replace any instance of more than one space, with a single space
|
|
22
|
-
output = output.replace(/ {2,}/g, '');
|
|
23
|
-
// Replacing '&' for 'and'
|
|
24
|
-
output = output.replace(/&/g, 'and');
|
|
25
|
-
// Replace spaces for hyphen or underscore
|
|
26
|
-
output = output.replace(/[ _]/g, '-');
|
|
27
|
-
// Remove any non-alphanumeric characters (except for hyphens)
|
|
28
|
-
output = output.replace(/[^0-9a-z-]+/g, '');
|
|
29
|
-
// Replace any instance of more than one hyphen, with a single hyphen
|
|
30
|
-
output = output.replace(/-{2,}/g, '-');
|
|
31
|
-
// Remove any leading hyphen
|
|
32
|
-
if (output.length && output[0] === '-') {
|
|
33
|
-
output = output.slice(1);
|
|
34
|
-
}
|
|
35
|
-
// Remove any trailing hyphen
|
|
36
|
-
if (output.length && output[output.length - 1] === '-') {
|
|
37
|
-
output = output.slice(0, -1);
|
|
38
|
-
}
|
|
39
|
-
if (output.length < 2) {
|
|
40
|
-
throw new error_1.CommercetoolsError("Formatted key did not meet minimum length of 2 characters: ".concat(output));
|
|
41
|
-
}
|
|
42
|
-
if (output.length > 256) {
|
|
43
|
-
throw new error_1.CommercetoolsError("Formatted key exceeds the maximum length of 256 characters: ".concat(output));
|
|
44
|
-
}
|
|
45
|
-
return output;
|
|
46
|
-
}
|
|
47
|
-
exports.formatAsKey = formatAsKey;
|
|
48
|
-
//# sourceMappingURL=format.js.map
|
package/dist/utils/format.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/lib/utils/format.ts"],"names":[],"mappings":";;;AAAA,kCAA6C;AAE7C;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,IAAI,MAAM,GAAG,EAAE,CAAA;IAEf,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,IAAI,0BAAkB,CAAC,wCAAwC,CAAC,CAAA;KACvE;IAED,0BAA0B;IAC1B,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACnC,mEAAmE;IACnE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IACrC,0BAA0B;IAC1B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACpC,0CAA0C;IAC1C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IACrC,8DAA8D;IAC9D,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;IAC3C,qEAAqE;IACrE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACtC,4BAA4B;IAC5B,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KACzB;IACD,6BAA6B;IAC7B,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;QACtD,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;KAC7B;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,0BAAkB,CAAC,qEAA8D,MAAM,CAAE,CAAC,CAAA;KACrG;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;QACvB,MAAM,IAAI,0BAAkB,CAAC,sEAA+D,MAAM,CAAE,CAAC,CAAA;KACtG;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AApCD,kCAoCC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
|
package/dist/utils/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./format"), exports);
|
|
14
|
-
__exportStar(require("./useragent"), exports);
|
|
15
|
-
__exportStar(require("./mask"), exports);
|
|
16
|
-
__exportStar(require("./isNode"), exports);
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwB;AACxB,8CAA2B;AAC3B,yCAAsB;AACtB,2CAAwB"}
|
package/dist/utils/isNode.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isNode.d.ts","sourceRoot":"","sources":["../../src/lib/utils/isNode.ts"],"names":[],"mappings":"AACA,wBAAgB,MAAM,YAKrB"}
|
package/dist/utils/isNode.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNode = void 0;
|
|
4
|
-
var _isNode;
|
|
5
|
-
function isNode() {
|
|
6
|
-
if (typeof _isNode === 'undefined') {
|
|
7
|
-
_isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]';
|
|
8
|
-
}
|
|
9
|
-
return _isNode;
|
|
10
|
-
}
|
|
11
|
-
exports.isNode = isNode;
|
|
12
|
-
//# sourceMappingURL=isNode.js.map
|
package/dist/utils/isNode.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isNode.js","sourceRoot":"","sources":["../../src/lib/utils/isNode.ts"],"names":[],"mappings":";;;AAAA,IAAI,OAAgB,CAAA;AACpB,SAAgB,MAAM;IACpB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;QAClC,OAAO,GAAG,OAAO,OAAO,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,kBAAkB,CAAA;KAC3G;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AALD,wBAKC"}
|