@imtbl/config 2.0.0-alpha.6 → 2.0.0-alpha.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/browser/index.js +57 -2
- package/dist/node/index.cjs +60 -5
- package/dist/node/index.js +57 -2
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import { setEnvironment, track, setPublishableApiKey } from '@imtbl/metrics';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/index.ts
|
|
4
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
5
|
+
Environment2["PRODUCTION"] = "production";
|
|
6
|
+
Environment2["SANDBOX"] = "sandbox";
|
|
7
|
+
return Environment2;
|
|
8
|
+
})(Environment || {});
|
|
9
|
+
var KeyHeaders = /* @__PURE__ */ ((KeyHeaders2) => {
|
|
10
|
+
KeyHeaders2["API_KEY"] = "x-immutable-api-key";
|
|
11
|
+
KeyHeaders2["PUBLISHABLE_KEY"] = "x-immutable-publishable-key";
|
|
12
|
+
KeyHeaders2["RATE_LIMITING_KEY"] = "x-api-key";
|
|
13
|
+
return KeyHeaders2;
|
|
14
|
+
})(KeyHeaders || {});
|
|
15
|
+
var ImmutableConfiguration = class {
|
|
16
|
+
environment;
|
|
17
|
+
rateLimitingKey;
|
|
18
|
+
apiKey;
|
|
19
|
+
publishableKey;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.environment = options.environment;
|
|
22
|
+
this.publishableKey = options.publishableKey;
|
|
23
|
+
this.apiKey = options.apiKey;
|
|
24
|
+
this.rateLimitingKey = options.rateLimitingKey;
|
|
25
|
+
setEnvironment(options.environment);
|
|
26
|
+
track("config", "created_imtbl_config");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
30
|
+
if (!baseConfig || !baseConfig.apiKey && !baseConfig.publishableKey && !baseConfig.rateLimitingKey) {
|
|
31
|
+
return overrides;
|
|
32
|
+
}
|
|
33
|
+
const newHeaders = {};
|
|
34
|
+
if (baseConfig.apiKey) {
|
|
35
|
+
newHeaders["x-immutable-api-key" /* API_KEY */] = baseConfig.apiKey;
|
|
36
|
+
}
|
|
37
|
+
if (baseConfig.publishableKey) {
|
|
38
|
+
newHeaders["x-immutable-publishable-key" /* PUBLISHABLE_KEY */] = baseConfig.publishableKey;
|
|
39
|
+
setPublishableApiKey(baseConfig.publishableKey);
|
|
40
|
+
}
|
|
41
|
+
if (baseConfig.rateLimitingKey) {
|
|
42
|
+
newHeaders["x-api-key" /* RATE_LIMITING_KEY */] = baseConfig.rateLimitingKey;
|
|
43
|
+
}
|
|
44
|
+
if (overrides && overrides.headers) {
|
|
45
|
+
return {
|
|
46
|
+
...overrides,
|
|
47
|
+
headers: {
|
|
48
|
+
...newHeaders,
|
|
49
|
+
// Add newHeaders first so that the existing keys in overrides.headers can override them
|
|
50
|
+
...overrides.headers
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...overrides,
|
|
56
|
+
headers: newHeaders
|
|
57
|
+
};
|
|
58
|
+
};
|
|
4
59
|
|
|
5
|
-
export {
|
|
60
|
+
export { Environment, ImmutableConfiguration, KeyHeaders, addKeysToHeadersOverride };
|
package/dist/node/index.cjs
CHANGED
|
@@ -2,9 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
var metrics = require('@imtbl/metrics');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/index.ts
|
|
6
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
7
|
+
Environment2["PRODUCTION"] = "production";
|
|
8
|
+
Environment2["SANDBOX"] = "sandbox";
|
|
9
|
+
return Environment2;
|
|
10
|
+
})(Environment || {});
|
|
11
|
+
var KeyHeaders = /* @__PURE__ */ ((KeyHeaders2) => {
|
|
12
|
+
KeyHeaders2["API_KEY"] = "x-immutable-api-key";
|
|
13
|
+
KeyHeaders2["PUBLISHABLE_KEY"] = "x-immutable-publishable-key";
|
|
14
|
+
KeyHeaders2["RATE_LIMITING_KEY"] = "x-api-key";
|
|
15
|
+
return KeyHeaders2;
|
|
16
|
+
})(KeyHeaders || {});
|
|
17
|
+
var ImmutableConfiguration = class {
|
|
18
|
+
environment;
|
|
19
|
+
rateLimitingKey;
|
|
20
|
+
apiKey;
|
|
21
|
+
publishableKey;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.environment = options.environment;
|
|
24
|
+
this.publishableKey = options.publishableKey;
|
|
25
|
+
this.apiKey = options.apiKey;
|
|
26
|
+
this.rateLimitingKey = options.rateLimitingKey;
|
|
27
|
+
metrics.setEnvironment(options.environment);
|
|
28
|
+
metrics.track("config", "created_imtbl_config");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
32
|
+
if (!baseConfig || !baseConfig.apiKey && !baseConfig.publishableKey && !baseConfig.rateLimitingKey) {
|
|
33
|
+
return overrides;
|
|
34
|
+
}
|
|
35
|
+
const newHeaders = {};
|
|
36
|
+
if (baseConfig.apiKey) {
|
|
37
|
+
newHeaders["x-immutable-api-key" /* API_KEY */] = baseConfig.apiKey;
|
|
38
|
+
}
|
|
39
|
+
if (baseConfig.publishableKey) {
|
|
40
|
+
newHeaders["x-immutable-publishable-key" /* PUBLISHABLE_KEY */] = baseConfig.publishableKey;
|
|
41
|
+
metrics.setPublishableApiKey(baseConfig.publishableKey);
|
|
42
|
+
}
|
|
43
|
+
if (baseConfig.rateLimitingKey) {
|
|
44
|
+
newHeaders["x-api-key" /* RATE_LIMITING_KEY */] = baseConfig.rateLimitingKey;
|
|
45
|
+
}
|
|
46
|
+
if (overrides && overrides.headers) {
|
|
47
|
+
return {
|
|
48
|
+
...overrides,
|
|
49
|
+
headers: {
|
|
50
|
+
...newHeaders,
|
|
51
|
+
// Add newHeaders first so that the existing keys in overrides.headers can override them
|
|
52
|
+
...overrides.headers
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
...overrides,
|
|
58
|
+
headers: newHeaders
|
|
59
|
+
};
|
|
60
|
+
};
|
|
6
61
|
|
|
7
|
-
exports.Environment =
|
|
8
|
-
exports.ImmutableConfiguration =
|
|
9
|
-
exports.KeyHeaders =
|
|
10
|
-
exports.addKeysToHeadersOverride =
|
|
62
|
+
exports.Environment = Environment;
|
|
63
|
+
exports.ImmutableConfiguration = ImmutableConfiguration;
|
|
64
|
+
exports.KeyHeaders = KeyHeaders;
|
|
65
|
+
exports.addKeysToHeadersOverride = addKeysToHeadersOverride;
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import { setEnvironment, track, setPublishableApiKey } from '@imtbl/metrics';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/index.ts
|
|
4
|
+
var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
5
|
+
Environment2["PRODUCTION"] = "production";
|
|
6
|
+
Environment2["SANDBOX"] = "sandbox";
|
|
7
|
+
return Environment2;
|
|
8
|
+
})(Environment || {});
|
|
9
|
+
var KeyHeaders = /* @__PURE__ */ ((KeyHeaders2) => {
|
|
10
|
+
KeyHeaders2["API_KEY"] = "x-immutable-api-key";
|
|
11
|
+
KeyHeaders2["PUBLISHABLE_KEY"] = "x-immutable-publishable-key";
|
|
12
|
+
KeyHeaders2["RATE_LIMITING_KEY"] = "x-api-key";
|
|
13
|
+
return KeyHeaders2;
|
|
14
|
+
})(KeyHeaders || {});
|
|
15
|
+
var ImmutableConfiguration = class {
|
|
16
|
+
environment;
|
|
17
|
+
rateLimitingKey;
|
|
18
|
+
apiKey;
|
|
19
|
+
publishableKey;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.environment = options.environment;
|
|
22
|
+
this.publishableKey = options.publishableKey;
|
|
23
|
+
this.apiKey = options.apiKey;
|
|
24
|
+
this.rateLimitingKey = options.rateLimitingKey;
|
|
25
|
+
setEnvironment(options.environment);
|
|
26
|
+
track("config", "created_imtbl_config");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var addKeysToHeadersOverride = (baseConfig, overrides) => {
|
|
30
|
+
if (!baseConfig || !baseConfig.apiKey && !baseConfig.publishableKey && !baseConfig.rateLimitingKey) {
|
|
31
|
+
return overrides;
|
|
32
|
+
}
|
|
33
|
+
const newHeaders = {};
|
|
34
|
+
if (baseConfig.apiKey) {
|
|
35
|
+
newHeaders["x-immutable-api-key" /* API_KEY */] = baseConfig.apiKey;
|
|
36
|
+
}
|
|
37
|
+
if (baseConfig.publishableKey) {
|
|
38
|
+
newHeaders["x-immutable-publishable-key" /* PUBLISHABLE_KEY */] = baseConfig.publishableKey;
|
|
39
|
+
setPublishableApiKey(baseConfig.publishableKey);
|
|
40
|
+
}
|
|
41
|
+
if (baseConfig.rateLimitingKey) {
|
|
42
|
+
newHeaders["x-api-key" /* RATE_LIMITING_KEY */] = baseConfig.rateLimitingKey;
|
|
43
|
+
}
|
|
44
|
+
if (overrides && overrides.headers) {
|
|
45
|
+
return {
|
|
46
|
+
...overrides,
|
|
47
|
+
headers: {
|
|
48
|
+
...newHeaders,
|
|
49
|
+
// Add newHeaders first so that the existing keys in overrides.headers can override them
|
|
50
|
+
...overrides.headers
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...overrides,
|
|
56
|
+
headers: newHeaders
|
|
57
|
+
};
|
|
58
|
+
};
|
|
4
59
|
|
|
5
|
-
export {
|
|
60
|
+
export { Environment, ImmutableConfiguration, KeyHeaders, addKeysToHeadersOverride };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/config",
|
|
3
3
|
"description": "Config for Immutable SDK",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.7",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@imtbl/metrics": "2.0.0-alpha.
|
|
8
|
+
"@imtbl/metrics": "2.0.0-alpha.7"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@swc/core": "^1.3.36",
|