@soleil-se/app-util 5.11.0 → 5.12.0
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/CHANGELOG.md +4 -0
- package/client/index.d.ts +3 -3
- package/package.json +2 -2
- package/server/app-data/index.d.ts +84 -84
- package/server/global-app-data/index.d.ts +84 -84
- package/server/index.d.ts +52 -6
- package/server/index.js +62 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ All notable changes to this project will be documented in this file.
|
|
|
7
7
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
8
8
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
9
9
|
|
|
10
|
+
## [5.12.0] - 2025-10-09
|
|
11
|
+
|
|
12
|
+
- Add `iteratorToArray`, `nodeIteratorToArray`, `listToArray` and `setToArray` utility functions to convert these data structures into arrays.
|
|
13
|
+
|
|
10
14
|
## [5.11.0] - 2025-09-04
|
|
11
15
|
|
|
12
16
|
- Add type-safe wrapper for `@sitevision/api/server/appData` and `@sitevision/api/server/globalAppData`.
|
package/client/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as preventDefault } from "./prevent-default";
|
|
2
|
-
export { getUrlParam, getUrlParams, setUrlParams, updateUrlParams, clearUrlParams } from "./url-params";
|
|
3
|
-
export { default as fetchJson, FetchError } from "./fetch-json";
|
|
1
|
+
export { default as preventDefault } from "./prevent-default";
|
|
2
|
+
export { getUrlParam, getUrlParams, setUrlParams, updateUrlParams, clearUrlParams } from "./url-params";
|
|
3
|
+
export { default as fetchJson, FetchError } from "./fetch-json";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/app-util",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "Utility functions for WebApps, RESTApps and Widgets in Sitevision.",
|
|
5
5
|
"main": "./common/index.js",
|
|
6
6
|
"author": "Soleil AB",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"create-type-definitions": "node ../../utils/createTypeDefinitions.js ./common/index.js ./client/index.js ./client/svelte/index.js ./client/svelte/3/index.js ./client/svelte/4/index.js ./client/svelte/5/index.js ./server/index.js ./server/svelte/index.js ./server/svelte/3/index.js ./server/svelte/4/index.js ./server/svelte/5/index.js ./server/app-data/index.js ./server/global-app-data/index.js"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "b307141c40e0116c6f2f2c3354656904d9fedb79"
|
|
29
29
|
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
export default appData;
|
|
2
|
-
declare namespace appData {
|
|
3
|
-
/**
|
|
4
|
-
* Get a value from app data, same as get in \@sitevision/api/server/appData.
|
|
5
|
-
* @param {string} key - The key of app data to retrieve.
|
|
6
|
-
* @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
|
|
7
|
-
* @returns {unknown} The value of the app data or a properties of a JCR Node.
|
|
8
|
-
*/
|
|
9
|
-
function get(key: string, ...properties?: string[]): unknown;
|
|
10
|
-
/**
|
|
11
|
-
* Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
|
|
12
|
-
* @param {string} key - The key of app data to retrieve.
|
|
13
|
-
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
|
|
14
|
-
* Nodes for list components or value wrapped in an array for single type components.
|
|
15
|
-
*/
|
|
16
|
-
function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
17
|
-
/**
|
|
18
|
-
* Get a string value from app data.
|
|
19
|
-
* @param {string} key - The key of app data to retrieve.
|
|
20
|
-
* @returns {string | undefined} The string value or undefined if not set.
|
|
21
|
-
*/
|
|
22
|
-
function getString(key: string): string | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Get a boolean value from app data.
|
|
25
|
-
* @param {string} key - The key of app data to retrieve.
|
|
26
|
-
* @returns {boolean | undefined} The boolean value or undefined if not set.
|
|
27
|
-
*/
|
|
28
|
-
function getBoolean(key: string): boolean | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Get a number value from app data.
|
|
31
|
-
* @param {string} key - The key of app data to retrieve.
|
|
32
|
-
* @returns {number | undefined} The number value, undefined if not set or not a number.
|
|
33
|
-
*/
|
|
34
|
-
function getNumber(key: string): number | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Get an array of nodes from app data.
|
|
37
|
-
* @param {string} key - The key of app data to retrieve.
|
|
38
|
-
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
|
|
39
|
-
* empty array if not set.
|
|
40
|
-
*/
|
|
41
|
-
function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
42
|
-
/**
|
|
43
|
-
* Get an array of strings from app data.
|
|
44
|
-
* @param {string} key - The key of app data to retrieve.
|
|
45
|
-
* @returns {string[]} The array of strings or an empty array if not set.
|
|
46
|
-
*/
|
|
47
|
-
function getStrings(key: string): string[];
|
|
48
|
-
/**
|
|
49
|
-
* Get a JCR Node from app data.
|
|
50
|
-
* @param {string} key - The key of the property to retrieve.
|
|
51
|
-
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
|
|
52
|
-
* undefined if not set.
|
|
53
|
-
*/
|
|
54
|
-
function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
|
|
55
|
-
/**
|
|
56
|
-
* Get a string property from a JCR Node referenced in app data.
|
|
57
|
-
* @param {string} key - The key of the app data value.
|
|
58
|
-
* @param {string} property - The property to retrieve from the node.
|
|
59
|
-
* @returns {string | undefined} The string property value or undefined if not set.
|
|
60
|
-
*/
|
|
61
|
-
function getStringProperty(key: string, property: string): string | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Get a string array property or a single string wrapped in an array from a JCR Node referenced
|
|
64
|
-
* in app data.
|
|
65
|
-
* @param {string} key - The key of app data to retrieve.
|
|
66
|
-
* @param {string} property - The property to retrieve from the node.
|
|
67
|
-
* @returns {string[]} The array of strings or an empty array if not set.
|
|
68
|
-
*/
|
|
69
|
-
function getStringsProperty(key: string, property: string): string[];
|
|
70
|
-
/**
|
|
71
|
-
* Get a boolean property from a JCR Node referenced in app data.
|
|
72
|
-
* @param {string} key - The key of the app data value.
|
|
73
|
-
* @param {string} property - The property to retrieve from the node.
|
|
74
|
-
* @returns {boolean | undefined} The boolean property value or undefined if not set.
|
|
75
|
-
*/
|
|
76
|
-
function getBooleanProperty(key: string, property: string): boolean | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Get a number property from a JCR Node referenced in app data.
|
|
79
|
-
* @param {string} key - The key of the app data value.
|
|
80
|
-
* @param {string} property - The property to retrieve from the node.
|
|
81
|
-
* @returns {number | undefined} The number property value, undefined if not set or not a number.
|
|
82
|
-
*/
|
|
83
|
-
function getNumberProperty(key: string, property: string): number | undefined;
|
|
84
|
-
}
|
|
1
|
+
export default appData;
|
|
2
|
+
declare namespace appData {
|
|
3
|
+
/**
|
|
4
|
+
* Get a value from app data, same as get in \@sitevision/api/server/appData.
|
|
5
|
+
* @param {string} key - The key of app data to retrieve.
|
|
6
|
+
* @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
|
|
7
|
+
* @returns {unknown} The value of the app data or a properties of a JCR Node.
|
|
8
|
+
*/
|
|
9
|
+
function get(key: string, ...properties?: string[]): unknown;
|
|
10
|
+
/**
|
|
11
|
+
* Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
|
|
12
|
+
* @param {string} key - The key of app data to retrieve.
|
|
13
|
+
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
|
|
14
|
+
* Nodes for list components or value wrapped in an array for single type components.
|
|
15
|
+
*/
|
|
16
|
+
function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
17
|
+
/**
|
|
18
|
+
* Get a string value from app data.
|
|
19
|
+
* @param {string} key - The key of app data to retrieve.
|
|
20
|
+
* @returns {string | undefined} The string value or undefined if not set.
|
|
21
|
+
*/
|
|
22
|
+
function getString(key: string): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get a boolean value from app data.
|
|
25
|
+
* @param {string} key - The key of app data to retrieve.
|
|
26
|
+
* @returns {boolean | undefined} The boolean value or undefined if not set.
|
|
27
|
+
*/
|
|
28
|
+
function getBoolean(key: string): boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get a number value from app data.
|
|
31
|
+
* @param {string} key - The key of app data to retrieve.
|
|
32
|
+
* @returns {number | undefined} The number value, undefined if not set or not a number.
|
|
33
|
+
*/
|
|
34
|
+
function getNumber(key: string): number | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Get an array of nodes from app data.
|
|
37
|
+
* @param {string} key - The key of app data to retrieve.
|
|
38
|
+
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
|
|
39
|
+
* empty array if not set.
|
|
40
|
+
*/
|
|
41
|
+
function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
42
|
+
/**
|
|
43
|
+
* Get an array of strings from app data.
|
|
44
|
+
* @param {string} key - The key of app data to retrieve.
|
|
45
|
+
* @returns {string[]} The array of strings or an empty array if not set.
|
|
46
|
+
*/
|
|
47
|
+
function getStrings(key: string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Get a JCR Node from app data.
|
|
50
|
+
* @param {string} key - The key of the property to retrieve.
|
|
51
|
+
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
|
|
52
|
+
* undefined if not set.
|
|
53
|
+
*/
|
|
54
|
+
function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
|
|
55
|
+
/**
|
|
56
|
+
* Get a string property from a JCR Node referenced in app data.
|
|
57
|
+
* @param {string} key - The key of the app data value.
|
|
58
|
+
* @param {string} property - The property to retrieve from the node.
|
|
59
|
+
* @returns {string | undefined} The string property value or undefined if not set.
|
|
60
|
+
*/
|
|
61
|
+
function getStringProperty(key: string, property: string): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Get a string array property or a single string wrapped in an array from a JCR Node referenced
|
|
64
|
+
* in app data.
|
|
65
|
+
* @param {string} key - The key of app data to retrieve.
|
|
66
|
+
* @param {string} property - The property to retrieve from the node.
|
|
67
|
+
* @returns {string[]} The array of strings or an empty array if not set.
|
|
68
|
+
*/
|
|
69
|
+
function getStringsProperty(key: string, property: string): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Get a boolean property from a JCR Node referenced in app data.
|
|
72
|
+
* @param {string} key - The key of the app data value.
|
|
73
|
+
* @param {string} property - The property to retrieve from the node.
|
|
74
|
+
* @returns {boolean | undefined} The boolean property value or undefined if not set.
|
|
75
|
+
*/
|
|
76
|
+
function getBooleanProperty(key: string, property: string): boolean | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Get a number property from a JCR Node referenced in app data.
|
|
79
|
+
* @param {string} key - The key of the app data value.
|
|
80
|
+
* @param {string} property - The property to retrieve from the node.
|
|
81
|
+
* @returns {number | undefined} The number property value, undefined if not set or not a number.
|
|
82
|
+
*/
|
|
83
|
+
function getNumberProperty(key: string, property: string): number | undefined;
|
|
84
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
export default globalAppData;
|
|
2
|
-
declare namespace globalAppData {
|
|
3
|
-
/**
|
|
4
|
-
* Get a value from app data, same as get in \@sitevision/api/server/appData.
|
|
5
|
-
* @param {string} key - The key of app data to retrieve.
|
|
6
|
-
* @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
|
|
7
|
-
* @returns {unknown} The value of the app data or a properties of a JCR Node.
|
|
8
|
-
*/
|
|
9
|
-
function get(key: string, ...properties?: string[]): unknown;
|
|
10
|
-
/**
|
|
11
|
-
* Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
|
|
12
|
-
* @param {string} key - The key of app data to retrieve.
|
|
13
|
-
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
|
|
14
|
-
* Nodes for list components or value wrapped in an array for single type components.
|
|
15
|
-
*/
|
|
16
|
-
function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
17
|
-
/**
|
|
18
|
-
* Get a string value from app data.
|
|
19
|
-
* @param {string} key - The key of app data to retrieve.
|
|
20
|
-
* @returns {string | undefined} The string value or undefined if not set.
|
|
21
|
-
*/
|
|
22
|
-
function getString(key: string): string | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Get a boolean value from app data.
|
|
25
|
-
* @param {string} key - The key of app data to retrieve.
|
|
26
|
-
* @returns {boolean | undefined} The boolean value or undefined if not set.
|
|
27
|
-
*/
|
|
28
|
-
function getBoolean(key: string): boolean | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Get a number value from app data.
|
|
31
|
-
* @param {string} key - The key of app data to retrieve.
|
|
32
|
-
* @returns {number | undefined} The number value, undefined if not set or not a number.
|
|
33
|
-
*/
|
|
34
|
-
function getNumber(key: string): number | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Get an array of nodes from app data.
|
|
37
|
-
* @param {string} key - The key of app data to retrieve.
|
|
38
|
-
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
|
|
39
|
-
* empty array if not set.
|
|
40
|
-
*/
|
|
41
|
-
function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
42
|
-
/**
|
|
43
|
-
* Get an array of strings from app data.
|
|
44
|
-
* @param {string} key - The key of app data to retrieve.
|
|
45
|
-
* @returns {string[]} The array of strings or an empty array if not set.
|
|
46
|
-
*/
|
|
47
|
-
function getStrings(key: string): string[];
|
|
48
|
-
/**
|
|
49
|
-
* Get a JCR Node from app data.
|
|
50
|
-
* @param {string} key - The key of the property to retrieve.
|
|
51
|
-
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
|
|
52
|
-
* undefined if not set.
|
|
53
|
-
*/
|
|
54
|
-
function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
|
|
55
|
-
/**
|
|
56
|
-
* Get a string property from a JCR Node referenced in app data.
|
|
57
|
-
* @param {string} key - The key of the app data value.
|
|
58
|
-
* @param {string} property - The property to retrieve from the node.
|
|
59
|
-
* @returns {string | undefined} The string property value or undefined if not set.
|
|
60
|
-
*/
|
|
61
|
-
function getStringProperty(key: string, property: string): string | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Get a string array property or a single string wrapped in an array from a JCR Node referenced
|
|
64
|
-
* in app data.
|
|
65
|
-
* @param {string} key - The key of app data to retrieve.
|
|
66
|
-
* @param {string} property - The property to retrieve from the node.
|
|
67
|
-
* @returns {string[]} The array of strings or an empty array if not set.
|
|
68
|
-
*/
|
|
69
|
-
function getStringsProperty(key: string, property: string): string[];
|
|
70
|
-
/**
|
|
71
|
-
* Get a boolean property from a JCR Node referenced in app data.
|
|
72
|
-
* @param {string} key - The key of the app data value.
|
|
73
|
-
* @param {string} property - The property to retrieve from the node.
|
|
74
|
-
* @returns {boolean | undefined} The boolean property value or undefined if not set.
|
|
75
|
-
*/
|
|
76
|
-
function getBooleanProperty(key: string, property: string): boolean | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Get a number property from a JCR Node referenced in app data.
|
|
79
|
-
* @param {string} key - The key of the app data value.
|
|
80
|
-
* @param {string} property - The property to retrieve from the node.
|
|
81
|
-
* @returns {number | undefined} The number property value, undefined if not set or not a number.
|
|
82
|
-
*/
|
|
83
|
-
function getNumberProperty(key: string, property: string): number | undefined;
|
|
84
|
-
}
|
|
1
|
+
export default globalAppData;
|
|
2
|
+
declare namespace globalAppData {
|
|
3
|
+
/**
|
|
4
|
+
* Get a value from app data, same as get in \@sitevision/api/server/appData.
|
|
5
|
+
* @param {string} key - The key of app data to retrieve.
|
|
6
|
+
* @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
|
|
7
|
+
* @returns {unknown} The value of the app data or a properties of a JCR Node.
|
|
8
|
+
*/
|
|
9
|
+
function get(key: string, ...properties?: string[]): unknown;
|
|
10
|
+
/**
|
|
11
|
+
* Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
|
|
12
|
+
* @param {string} key - The key of app data to retrieve.
|
|
13
|
+
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
|
|
14
|
+
* Nodes for list components or value wrapped in an array for single type components.
|
|
15
|
+
*/
|
|
16
|
+
function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
17
|
+
/**
|
|
18
|
+
* Get a string value from app data.
|
|
19
|
+
* @param {string} key - The key of app data to retrieve.
|
|
20
|
+
* @returns {string | undefined} The string value or undefined if not set.
|
|
21
|
+
*/
|
|
22
|
+
function getString(key: string): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get a boolean value from app data.
|
|
25
|
+
* @param {string} key - The key of app data to retrieve.
|
|
26
|
+
* @returns {boolean | undefined} The boolean value or undefined if not set.
|
|
27
|
+
*/
|
|
28
|
+
function getBoolean(key: string): boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get a number value from app data.
|
|
31
|
+
* @param {string} key - The key of app data to retrieve.
|
|
32
|
+
* @returns {number | undefined} The number value, undefined if not set or not a number.
|
|
33
|
+
*/
|
|
34
|
+
function getNumber(key: string): number | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Get an array of nodes from app data.
|
|
37
|
+
* @param {string} key - The key of app data to retrieve.
|
|
38
|
+
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
|
|
39
|
+
* empty array if not set.
|
|
40
|
+
*/
|
|
41
|
+
function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
|
|
42
|
+
/**
|
|
43
|
+
* Get an array of strings from app data.
|
|
44
|
+
* @param {string} key - The key of app data to retrieve.
|
|
45
|
+
* @returns {string[]} The array of strings or an empty array if not set.
|
|
46
|
+
*/
|
|
47
|
+
function getStrings(key: string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Get a JCR Node from app data.
|
|
50
|
+
* @param {string} key - The key of the property to retrieve.
|
|
51
|
+
* @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
|
|
52
|
+
* undefined if not set.
|
|
53
|
+
*/
|
|
54
|
+
function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
|
|
55
|
+
/**
|
|
56
|
+
* Get a string property from a JCR Node referenced in app data.
|
|
57
|
+
* @param {string} key - The key of the app data value.
|
|
58
|
+
* @param {string} property - The property to retrieve from the node.
|
|
59
|
+
* @returns {string | undefined} The string property value or undefined if not set.
|
|
60
|
+
*/
|
|
61
|
+
function getStringProperty(key: string, property: string): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Get a string array property or a single string wrapped in an array from a JCR Node referenced
|
|
64
|
+
* in app data.
|
|
65
|
+
* @param {string} key - The key of app data to retrieve.
|
|
66
|
+
* @param {string} property - The property to retrieve from the node.
|
|
67
|
+
* @returns {string[]} The array of strings or an empty array if not set.
|
|
68
|
+
*/
|
|
69
|
+
function getStringsProperty(key: string, property: string): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Get a boolean property from a JCR Node referenced in app data.
|
|
72
|
+
* @param {string} key - The key of the app data value.
|
|
73
|
+
* @param {string} property - The property to retrieve from the node.
|
|
74
|
+
* @returns {boolean | undefined} The boolean property value or undefined if not set.
|
|
75
|
+
*/
|
|
76
|
+
function getBooleanProperty(key: string, property: string): boolean | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Get a number property from a JCR Node referenced in app data.
|
|
79
|
+
* @param {string} key - The key of the app data value.
|
|
80
|
+
* @param {string} property - The property to retrieve from the node.
|
|
81
|
+
* @returns {number | undefined} The number property value, undefined if not set or not a number.
|
|
82
|
+
*/
|
|
83
|
+
function getNumberProperty(key: string, property: string): number | undefined;
|
|
84
|
+
}
|
package/server/index.d.ts
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Require a module natively.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Require a module natively, bypassing Webpack bundling.
|
|
3
|
+
* This function behaves like CommonJS require() and is used to import
|
|
4
|
+
* system packages in the Rhino runtime environment where Webpack bundling interferes
|
|
5
|
+
* with native module resolution.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} module - The module identifier
|
|
8
|
+
* @returns {any} The exported module
|
|
9
|
+
* @example
|
|
10
|
+
* // Import a Sitevision API package
|
|
11
|
+
* const PortletContextUtil = nativeRequire('PortletContextUtil');
|
|
12
|
+
*/
|
|
13
|
+
export function nativeRequire(module: string): any;
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {import('@sitevision/api/types/javax/jcr/Node').Node} Node
|
|
16
|
+
* @typedef {import('@sitevision/api/types/javax/jcr/NodeIterator').NodeIterator} NodeIterator
|
|
17
|
+
* @typedef {import('@sitevision/api/types/java/util/Iterator').Iterator} Iterator
|
|
18
|
+
* @typedef {import('@sitevision/api/types/java/util/List').List} List
|
|
19
|
+
* @typedef {import('@sitevision/api/types/java/util/Set').Set} Set
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Converts an Iterator to an array
|
|
23
|
+
* @template T
|
|
24
|
+
* @param {Iterator} iterator - The Iterator to convert
|
|
25
|
+
* @returns {T[]} Array containing all items from the iterator
|
|
26
|
+
*/
|
|
27
|
+
export function iteratorToArray<T>(iterator: Iterator): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Converts a NodeIterator to an array of Nodes
|
|
30
|
+
* @param {NodeIterator} nodeIterator - The NodeIterator to convert
|
|
31
|
+
* @returns {Node[]} Array containing all nodes from the iterator
|
|
32
|
+
*/
|
|
33
|
+
export function nodeIteratorToArray(nodeIterator: NodeIterator): Node[];
|
|
34
|
+
/**
|
|
35
|
+
* Converts a List to an array
|
|
36
|
+
* @template T
|
|
37
|
+
* @param {List} list - The List to convert
|
|
38
|
+
* @returns {T[]} Array containing all items from the list
|
|
39
|
+
*/
|
|
40
|
+
export function listToArray<T>(list: List): T[];
|
|
41
|
+
/**
|
|
42
|
+
* Converts a Set to an array
|
|
43
|
+
* @template T
|
|
44
|
+
* @param {Set} set - The Set to convert
|
|
45
|
+
* @returns {T[]} Array containing all items from the set
|
|
46
|
+
*/
|
|
47
|
+
export function setToArray<T>(set: Set): T[];
|
|
48
|
+
export type Node = import('@sitevision/api/types/javax/jcr/Node').Node;
|
|
49
|
+
export type NodeIterator = import('@sitevision/api/types/javax/jcr/NodeIterator').NodeIterator;
|
|
50
|
+
export type Iterator = import('@sitevision/api/types/java/util/Iterator').Iterator;
|
|
51
|
+
export type List = import('@sitevision/api/types/java/util/List').List;
|
|
52
|
+
export type Set = import('@sitevision/api/types/java/util/Set').Set;
|
package/server/index.js
CHANGED
|
@@ -1,12 +1,71 @@
|
|
|
1
1
|
/* Make native requires work with @sitevision/sitevision-scripts that uses Webpack */
|
|
2
2
|
/* eslint-disable camelcase, no-undef, import/no-dynamic-require, global-require */
|
|
3
3
|
/**
|
|
4
|
-
* Require a module natively.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Require a module natively, bypassing Webpack bundling.
|
|
5
|
+
* This function behaves like CommonJS require() and is used to import
|
|
6
|
+
* system packages in the Rhino runtime environment where Webpack bundling interferes
|
|
7
|
+
* with native module resolution.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} module - The module identifier
|
|
10
|
+
* @returns {any} The exported module
|
|
11
|
+
* @example
|
|
12
|
+
* // Import a Sitevision API package
|
|
13
|
+
* const PortletContextUtil = nativeRequire('PortletContextUtil');
|
|
7
14
|
*/
|
|
8
15
|
export function nativeRequire(module) {
|
|
9
16
|
if (typeof __non_webpack_require__ !== 'undefined') return __non_webpack_require__(module);
|
|
10
17
|
return require(module);
|
|
11
18
|
}
|
|
12
19
|
/* eslint-enable camelcase, no-undef, import/no-dynamic-require, global-require */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import('@sitevision/api/types/javax/jcr/Node').Node} Node
|
|
23
|
+
* @typedef {import('@sitevision/api/types/javax/jcr/NodeIterator').NodeIterator} NodeIterator
|
|
24
|
+
* @typedef {import('@sitevision/api/types/java/util/Iterator').Iterator} Iterator
|
|
25
|
+
* @typedef {import('@sitevision/api/types/java/util/List').List} List
|
|
26
|
+
* @typedef {import('@sitevision/api/types/java/util/Set').Set} Set
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Converts an Iterator to an array
|
|
31
|
+
* @template T
|
|
32
|
+
* @param {Iterator} iterator - The Iterator to convert
|
|
33
|
+
* @returns {T[]} Array containing all items from the iterator
|
|
34
|
+
*/
|
|
35
|
+
export function iteratorToArray(iterator) {
|
|
36
|
+
const array = [];
|
|
37
|
+
if (!iterator) return array;
|
|
38
|
+
while (iterator?.hasNext()) {
|
|
39
|
+
array.push(iterator?.next());
|
|
40
|
+
}
|
|
41
|
+
return array;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Converts a NodeIterator to an array of Nodes
|
|
46
|
+
* @param {NodeIterator} nodeIterator - The NodeIterator to convert
|
|
47
|
+
* @returns {Node[]} Array containing all nodes from the iterator
|
|
48
|
+
*/
|
|
49
|
+
export function nodeIteratorToArray(nodeIterator) {
|
|
50
|
+
return iteratorToArray(nodeIterator);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Converts a List to an array
|
|
55
|
+
* @template T
|
|
56
|
+
* @param {List} list - The List to convert
|
|
57
|
+
* @returns {T[]} Array containing all items from the list
|
|
58
|
+
*/
|
|
59
|
+
export function listToArray(list) {
|
|
60
|
+
return iteratorToArray(list?.iterator());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Converts a Set to an array
|
|
65
|
+
* @template T
|
|
66
|
+
* @param {Set} set - The Set to convert
|
|
67
|
+
* @returns {T[]} Array containing all items from the set
|
|
68
|
+
*/
|
|
69
|
+
export function setToArray(set) {
|
|
70
|
+
return iteratorToArray(set?.iterator());
|
|
71
|
+
}
|