@lwrjs/shared-utils 0.12.0-alpha.16 → 0.12.0-alpha.18
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/build/cjs/env.cjs +28 -1
- package/build/es/env.d.ts +4 -1
- package/build/es/env.js +25 -0
- package/package.json +4 -4
package/build/cjs/env.cjs
CHANGED
|
@@ -8,8 +8,11 @@ var __export = (target, all) => {
|
|
|
8
8
|
// packages/@lwrjs/shared-utils/src/env.ts
|
|
9
9
|
__markAsModule(exports);
|
|
10
10
|
__export(exports, {
|
|
11
|
+
REQUEST_DEPTH_HEADER: () => REQUEST_DEPTH_HEADER,
|
|
12
|
+
REQUEST_DEPTH_KEY: () => REQUEST_DEPTH_KEY,
|
|
11
13
|
buildEnvironmentContext: () => buildEnvironmentContext,
|
|
12
|
-
getFeatureFlags: () => getFeatureFlags
|
|
14
|
+
getFeatureFlags: () => getFeatureFlags,
|
|
15
|
+
parseRequestDepthHeader: () => parseRequestDepthHeader
|
|
13
16
|
});
|
|
14
17
|
function getFeatureFlags() {
|
|
15
18
|
return {
|
|
@@ -34,3 +37,27 @@ function buildEnvironmentContext(runtimeParams) {
|
|
|
34
37
|
uiBasePath
|
|
35
38
|
};
|
|
36
39
|
}
|
|
40
|
+
var REQUEST_DEPTH_HEADER = "X-SFDC-Request-Depth";
|
|
41
|
+
var REQUEST_DEPTH_KEY = REQUEST_DEPTH_HEADER.toLowerCase();
|
|
42
|
+
function parseRequestDepthHeader(headers = {}) {
|
|
43
|
+
let maxDepth = 0;
|
|
44
|
+
const value = headers && headers[REQUEST_DEPTH_KEY];
|
|
45
|
+
if (value) {
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
for (const depth of value) {
|
|
48
|
+
if (typeof depth === "string") {
|
|
49
|
+
const depthValue = parseInt(depth, 10);
|
|
50
|
+
if (!isNaN(depthValue) && depthValue > maxDepth) {
|
|
51
|
+
maxDepth = depthValue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} else if (typeof value === "string") {
|
|
56
|
+
const depth = parseInt(value, 10);
|
|
57
|
+
if (!isNaN(depth) && depth > maxDepth) {
|
|
58
|
+
maxDepth = depth;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return maxDepth;
|
|
63
|
+
}
|
package/build/es/env.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { EnvironmentContext, FeatureFlags, RuntimeParams } from '@lwrjs/types';
|
|
1
|
+
import type { EnvironmentContext, FeatureFlags, Headers, RuntimeParams } from '@lwrjs/types';
|
|
2
2
|
export declare function getFeatureFlags(): FeatureFlags;
|
|
3
3
|
/**
|
|
4
4
|
* Create a serializable context for the lwr/environment variable
|
|
5
5
|
*/
|
|
6
6
|
export declare function buildEnvironmentContext(runtimeParams: RuntimeParams): EnvironmentContext;
|
|
7
|
+
export declare const REQUEST_DEPTH_HEADER = "X-SFDC-Request-Depth";
|
|
8
|
+
export declare const REQUEST_DEPTH_KEY: string;
|
|
9
|
+
export declare function parseRequestDepthHeader(headers?: Headers): number;
|
|
7
10
|
//# sourceMappingURL=env.d.ts.map
|
package/build/es/env.js
CHANGED
|
@@ -54,4 +54,29 @@ export function buildEnvironmentContext(runtimeParams) {
|
|
|
54
54
|
uiBasePath,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
export const REQUEST_DEPTH_HEADER = 'X-SFDC-Request-Depth';
|
|
58
|
+
export const REQUEST_DEPTH_KEY = REQUEST_DEPTH_HEADER.toLowerCase();
|
|
59
|
+
export function parseRequestDepthHeader(headers = {}) {
|
|
60
|
+
let maxDepth = 0;
|
|
61
|
+
const value = headers && headers[REQUEST_DEPTH_KEY];
|
|
62
|
+
if (value) {
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
for (const depth of value) {
|
|
65
|
+
if (typeof depth === 'string') {
|
|
66
|
+
const depthValue = parseInt(depth, 10);
|
|
67
|
+
if (!isNaN(depthValue) && depthValue > maxDepth) {
|
|
68
|
+
maxDepth = depthValue;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (typeof value === 'string') {
|
|
74
|
+
const depth = parseInt(value, 10);
|
|
75
|
+
if (!isNaN(depth) && depth > maxDepth) {
|
|
76
|
+
maxDepth = depth;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return maxDepth;
|
|
81
|
+
}
|
|
57
82
|
//# sourceMappingURL=env.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.12.0-alpha.
|
|
7
|
+
"version": "0.12.0-alpha.18",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build/**/*.d.ts"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@lwrjs/diagnostics": "0.12.0-alpha.
|
|
40
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.18",
|
|
41
41
|
"es-module-lexer": "^1.3.0",
|
|
42
42
|
"fast-json-stable-stringify": "^2.1.0",
|
|
43
43
|
"magic-string": "^0.30.7",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"slugify": "^1.4.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@lwrjs/types": "0.12.0-alpha.
|
|
53
|
+
"@lwrjs/types": "0.12.0-alpha.18",
|
|
54
54
|
"@types/mime-types": "2.1.1",
|
|
55
55
|
"@types/path-to-regexp": "^1.7.0"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=18.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "3771f90b20af174012680ea95d1d84aa3c39b5fc"
|
|
61
61
|
}
|