@enonic-types/lib-grid 0.1.1 → 7.11.0-B3
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/README.md +4 -4
- package/grid.d.ts +39 -71
- package/package.json +33 -32
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i --save-dev @enonic/lib-grid
|
|
8
|
+
npm i --save-dev @enonic-types/lib-grid
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Use
|
|
@@ -26,8 +26,8 @@ Add the corresponding types to your `tsconfig.json` file that is used for applic
|
|
|
26
26
|
|
|
27
27
|
### Require and custom imports
|
|
28
28
|
|
|
29
|
-
To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
30
|
-
objects, e.g. `log`, `app`, `__`, etc, requiring library by the default path will return typed object.
|
|
29
|
+
To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
|
|
30
|
+
global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
|
|
31
31
|
|
|
32
32
|
`tsconfig.json`
|
|
33
33
|
|
|
@@ -49,7 +49,7 @@ const {getMap} = require('/lib/xp/grid');
|
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
More detailed explanation on how it works and how to type custom import function can be
|
|
52
|
-
found [here](https://
|
|
52
|
+
found [here](https://developer.enonic.com/docs/xp/stable/api).
|
|
53
53
|
|
|
54
54
|
### ES6-style import
|
|
55
55
|
|
package/grid.d.ts
CHANGED
|
@@ -1,71 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @param {object} params JSON with the parameters.
|
|
41
|
-
* @param {string} params.key key of the entry
|
|
42
|
-
* @param {string|number|boolean|JSON|null} params.value value of the entry
|
|
43
|
-
* @param {number} [params.ttlSeconds] maximum time to live in seconds for this entry to stay in the map. (0 means infinite, negative means map config default or infinite if map config is not available)
|
|
44
|
-
*/
|
|
45
|
-
set(params: SetParams): void;
|
|
46
|
-
/**
|
|
47
|
-
* Attempts to compute a mapping for the specified key and its current mapped value.
|
|
48
|
-
*
|
|
49
|
-
* @param {object} params JSON with the parameters.
|
|
50
|
-
* @param {string} params.key key of the entry
|
|
51
|
-
* @param {function} params.func mapping function that accepts the existing mapped value (or null, if there is no associated mapping).
|
|
52
|
-
* The returned value replaces the existing mapped value for the specified key.
|
|
53
|
-
* If returned value is null then the value is removed from the map
|
|
54
|
-
* @param {number} [params.ttlSeconds] maximum time to live in seconds for this entry to stay in the map. (0 means infinite, negative means map config default or infinite if map config is not available)
|
|
55
|
-
* @returns the new value to which the specified key is mapped, or null if this map no longer contains mapping for the key
|
|
56
|
-
*/
|
|
57
|
-
modify(params: ModifyParams): SharedMapValueType;
|
|
58
|
-
/**
|
|
59
|
-
* Removes the mapping for the key from this map if it is present.
|
|
60
|
-
*
|
|
61
|
-
* @param {string} key the key whose associated value is to be removed
|
|
62
|
-
*/
|
|
63
|
-
delete(key: string): void;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Returns an instance of SharedMap by the specified map identifier.
|
|
67
|
-
*
|
|
68
|
-
* @param {string} mapId map identifier
|
|
69
|
-
* @returns {SharedMap} an instance of SharedMap
|
|
70
|
-
*/
|
|
71
|
-
export declare function getMap(mapId: string): SharedMap;
|
|
1
|
+
/**
|
|
2
|
+
* Grid related functions.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* var gridLib = require('/lib/xp/grid');
|
|
6
|
+
*
|
|
7
|
+
* @module grid
|
|
8
|
+
*/
|
|
9
|
+
declare global {
|
|
10
|
+
interface XpLibraries {
|
|
11
|
+
'/lib/xp/grid': typeof import('./grid');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare type SharedMapValueType = string | number | boolean | object | null;
|
|
15
|
+
export declare type GridMap = Record<string, SharedMapValueType>;
|
|
16
|
+
export declare type SharedMapModifierFn<Map extends GridMap, Key extends keyof Map> = (value: Map[Key] | null) => SharedMapValueType | Record<string, unknown> | object[];
|
|
17
|
+
export interface SetParams<Map extends GridMap, Key extends keyof Map> {
|
|
18
|
+
key: Key;
|
|
19
|
+
value: Map[Key] | null;
|
|
20
|
+
ttlSeconds?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ModifyParams<Map extends GridMap, Key extends keyof Map> {
|
|
23
|
+
key: Key;
|
|
24
|
+
func: SharedMapModifierFn<Map, Key>;
|
|
25
|
+
ttlSeconds?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface SharedMap<Map extends GridMap> {
|
|
28
|
+
get<Key extends keyof Map>(key: Key): Map[Key];
|
|
29
|
+
set<Key extends keyof Map>(params: SetParams<Map, Key>): void;
|
|
30
|
+
modify<Key extends keyof Map>(params: ModifyParams<Map, Key>): Map[Key];
|
|
31
|
+
delete(key: keyof Map): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns an instance of SharedMap by the specified map identifier.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} mapId map identifier
|
|
37
|
+
* @returns {SharedMap} an instance of SharedMap
|
|
38
|
+
*/
|
|
39
|
+
export declare function getMap<Map extends GridMap>(mapId: string): SharedMap<Map>;
|
package/package.json
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@enonic-types/lib-grid",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Type definitions for lib-grid.",
|
|
5
|
-
"types": "grid.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"grid.d.ts"
|
|
8
|
-
],
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"enonic",
|
|
15
|
-
"enonic-xp",
|
|
16
|
-
"lib-grid",
|
|
17
|
-
"grid",
|
|
18
|
-
"types",
|
|
19
|
-
"typescript"
|
|
20
|
-
],
|
|
21
|
-
"contributors": [
|
|
22
|
-
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
-
],
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@enonic-types/lib-grid",
|
|
3
|
+
"version": "7.11.0-B3",
|
|
4
|
+
"description": "Type definitions for lib-grid.",
|
|
5
|
+
"types": "grid.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"grid.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/enonic/xp.git#master"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"enonic",
|
|
15
|
+
"enonic-xp",
|
|
16
|
+
"lib-grid",
|
|
17
|
+
"grid",
|
|
18
|
+
"types",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"contributors": [
|
|
22
|
+
"Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
|
|
23
|
+
],
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/enonic/xp/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/enonic/xp/tree/master#readme",
|
|
29
|
+
"dependencies": {},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|