@enonic-types/lib-grid 0.1.0 → 7.11.0-B1

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.
Files changed (2) hide show
  1. package/grid.d.ts +78 -71
  2. package/package.json +1 -5
package/grid.d.ts CHANGED
@@ -1,71 +1,78 @@
1
- declare global {
2
- interface XpLibraries {
3
- '/lib/xp/grid': typeof import('./grid');
4
- }
5
- }
6
- export declare type SharedMapValueType = string | number | boolean | object | null;
7
- export declare type SharedMapModifierFn = (oldValue: SharedMapValueType) => SharedMapValueType;
8
- export interface SetParams {
9
- key: string;
10
- value: SharedMapValueType;
11
- ttlSeconds?: number;
12
- }
13
- export interface ModifyParams {
14
- key: string;
15
- func: SharedMapModifierFn;
16
- ttlSeconds?: number;
17
- }
18
- export declare class SharedMap {
19
- private map;
20
- /**
21
- * Creates an instance of SharedMap which are shared across all applications and even cluster nodes.
22
- *
23
- * WARNING: Due to distributed nature of the Shared Map not all types of keys and values can be used. Strings, numbers, and pure JSON objects are supported. There is no runtime check for type compatibility due to performance reasons. The developer is also responsible for not modifying shared objects (keys and values) in place.
24
- *
25
- * @param mapId - map identifier
26
- * @constructor
27
- */
28
- constructor(mapId: string);
29
- /**
30
- * Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
31
- *
32
- * @param {string} key - key the key whose associated value is to be returned
33
- * @returns {string|number|boolean|JSON|null} the value to which the specified key is mapped, or null if this map contains no mapping for the key
34
- */
35
- get(key: string): SharedMapValueType;
36
- /**
37
- * Puts an entry into this map with a given time to live (TTL).
38
- * If value is null, the existing entry will be removed.
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 SharedMapModifierFn = (oldValue: SharedMapValueType) => SharedMapValueType;
16
+ export interface SetParams {
17
+ key: string;
18
+ value: SharedMapValueType;
19
+ ttlSeconds?: number;
20
+ }
21
+ export interface ModifyParams {
22
+ key: string;
23
+ func: SharedMapModifierFn;
24
+ ttlSeconds?: number;
25
+ }
26
+ /**
27
+ * Shared Map is similar to other Map, but its instances are shared across all applications and even cluster nodes.
28
+
29
+ WARNING: Due to distributed nature of the Shared Map not all types of keys and values can be used. Strings, numbers, and pure JSON objects are supported. There is no runtime check for type compatibility due to performance reasons. The developer is also responsible for not modifying shared objects (keys and values) in place.
30
+ * @param mapId - map identifier
31
+ * @constructor
32
+ */
33
+ export declare class SharedMap {
34
+ private map;
35
+ constructor(mapId: string);
36
+ /**
37
+ * Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
38
+ *
39
+ * @param {string} key - key the key whose associated value is to be returned
40
+ * @returns {string|number|boolean|JSON|null} the value to which the specified key is mapped, or null if this map contains no mapping for the key
41
+ */
42
+ get(key: string): SharedMapValueType;
43
+ /**
44
+ * Puts an entry into this map with a given time to live (TTL).
45
+ * If value is null, the existing entry will be removed.
46
+ *
47
+ * @param {object} params JSON with the parameters.
48
+ * @param {string} params.key key of the entry
49
+ * @param {string|number|boolean|JSON|null} params.value value of the entry
50
+ * @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)
51
+ */
52
+ set(params: SetParams): void;
53
+ /**
54
+ * Attempts to compute a mapping for the specified key and its current mapped value.
55
+ *
56
+ * @param {object} params JSON with the parameters.
57
+ * @param {string} params.key key of the entry
58
+ * @param {function} params.func mapping function that accepts the existing mapped value (or null, if there is no associated mapping).
59
+ * The returned value replaces the existing mapped value for the specified key.
60
+ * If returned value is null then the value is removed from the map
61
+ * @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)
62
+ * @returns the new value to which the specified key is mapped, or null if this map no longer contains mapping for the key
63
+ */
64
+ modify(params: ModifyParams): SharedMapValueType;
65
+ /**
66
+ * Removes the mapping for the key from this map if it is present.
67
+ *
68
+ * @param {string} key the key whose associated value is to be removed
69
+ */
70
+ delete(key: string): void;
71
+ }
72
+ /**
73
+ * Returns an instance of SharedMap by the specified map identifier.
74
+ *
75
+ * @param {string} mapId map identifier
76
+ * @returns {SharedMap} an instance of SharedMap
77
+ */
78
+ export declare function getMap(mapId: string): SharedMap;
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "@enonic-types/lib-grid",
3
- "version": "0.1.0",
3
+ "version": "7.11.0-B1",
4
4
  "description": "Type definitions for lib-grid.",
5
5
  "types": "grid.d.ts",
6
6
  "files": [
7
7
  "grid.d.ts"
8
8
  ],
9
- "scripts": {
10
- "pre": "npm run --prefix ../ pre",
11
- "packlist": "npx npm-packlist"
12
- },
13
9
  "repository": {
14
10
  "type": "git",
15
11
  "url": "git+https://github.com/enonic/xp.git#master"