@karmaniverous/entity-manager 6.1.0-5 → 6.1.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/dist/cjs/{src/EntityManager.js → EntityManager.js} +4 -4
- package/dist/cjs/{src/EntityManagerClient.js → EntityManagerClient.js} +6 -6
- package/dist/cjs/{src/ParsedConfig.js → ParsedConfig.js} +52 -52
- package/dist/cjs/{src/addKeys.js → addKeys.js} +2 -2
- package/dist/cjs/{src/decodeGeneratedProperty.js → decodeGeneratedProperty.js} +2 -2
- package/dist/cjs/{src/encodeGeneratedProperty.js → encodeGeneratedProperty.js} +2 -2
- package/dist/cjs/{src/getHashKeySpace.js → getHashKeySpace.js} +2 -2
- package/dist/cjs/{src/query.js → query.js} +7 -9
- package/dist/cjs/{src/rehydrateIndexItem.js → rehydrateIndexItem.js} +2 -3
- package/dist/cjs/{src/rehydratePageKeyMap.js → rehydratePageKeyMap.js} +4 -5
- package/dist/cjs/{src/unwrapIndex.js → unwrapIndex.js} +2 -2
- package/dist/cjs/{src/updateItemHashKey.js → updateItemHashKey.js} +5 -5
- package/dist/cjs/{src/updateItemRangeKey.js → updateItemRangeKey.js} +2 -2
- package/dist/mjs/{src/EntityManager.js → EntityManager.js} +1 -1
- package/dist/mjs/{src/EntityManagerClient.js → EntityManagerClient.js} +2 -2
- package/dist/mjs/{src/ParsedConfig.js → ParsedConfig.js} +3 -3
- package/dist/mjs/{src/addKeys.js → addKeys.js} +1 -1
- package/dist/mjs/{src/decodeGeneratedProperty.js → decodeGeneratedProperty.js} +1 -1
- package/dist/mjs/{src/encodeGeneratedProperty.js → encodeGeneratedProperty.js} +1 -1
- package/dist/mjs/{src/getHashKeySpace.js → getHashKeySpace.js} +1 -1
- package/dist/mjs/{src/query.js → query.js} +3 -5
- package/dist/mjs/{src/rehydrateIndexItem.js → rehydrateIndexItem.js} +1 -2
- package/dist/mjs/{src/rehydratePageKeyMap.js → rehydratePageKeyMap.js} +1 -2
- package/dist/mjs/{src/unwrapIndex.js → unwrapIndex.js} +1 -1
- package/dist/mjs/{src/updateItemHashKey.js → updateItemHashKey.js} +2 -2
- package/dist/mjs/{src/updateItemRangeKey.js → updateItemRangeKey.js} +1 -1
- package/package.json +6 -6
- package/dist/cjs/_virtual/_commonjsHelpers.js +0 -7
- package/dist/cjs/_virtual/index.js +0 -9
- package/dist/cjs/_virtual/lz-string.js +0 -9
- package/dist/cjs/_virtual/lz-string2.js +0 -5
- package/dist/cjs/node_modules/@karmaniverous/entity-tools/dist/mjs/Nil.js +0 -14
- package/dist/cjs/node_modules/@karmaniverous/entity-tools/dist/mjs/defaultTranscodes.js +0 -94
- package/dist/cjs/node_modules/@karmaniverous/entity-tools/dist/mjs/sort.js +0 -52
- package/dist/cjs/node_modules/lz-string/libs/lz-string.js +0 -520
- package/dist/cjs/node_modules/radash/dist/esm/array.js +0 -90
- package/dist/cjs/node_modules/radash/dist/esm/async.js +0 -62
- package/dist/cjs/node_modules/radash/dist/esm/object.js +0 -25
- package/dist/cjs/node_modules/radash/dist/esm/typed.js +0 -35
- package/dist/cjs/node_modules/string-hash/index.js +0 -28
- package/dist/cjs/node_modules/tslib/tslib.es6.js +0 -39
- package/dist/cjs/node_modules/zod/lib/index.js +0 -4342
- package/dist/mjs/_virtual/_commonjsHelpers.js +0 -5
- package/dist/mjs/_virtual/index.js +0 -7
- package/dist/mjs/_virtual/lz-string.js +0 -7
- package/dist/mjs/_virtual/lz-string2.js +0 -3
- package/dist/mjs/node_modules/@karmaniverous/entity-tools/dist/mjs/Nil.js +0 -12
- package/dist/mjs/node_modules/@karmaniverous/entity-tools/dist/mjs/defaultTranscodes.js +0 -92
- package/dist/mjs/node_modules/@karmaniverous/entity-tools/dist/mjs/sort.js +0 -50
- package/dist/mjs/node_modules/lz-string/libs/lz-string.js +0 -518
- package/dist/mjs/node_modules/radash/dist/esm/array.js +0 -80
- package/dist/mjs/node_modules/radash/dist/esm/async.js +0 -58
- package/dist/mjs/node_modules/radash/dist/esm/object.js +0 -22
- package/dist/mjs/node_modules/radash/dist/esm/typed.js +0 -28
- package/dist/mjs/node_modules/string-hash/index.js +0 -26
- package/dist/mjs/node_modules/tslib/tslib.es6.js +0 -36
- package/dist/mjs/node_modules/zod/lib/index.js +0 -4233
- /package/dist/cjs/{src/conditionalize.js → conditionalize.js} +0 -0
- /package/dist/cjs/{src/decodeEntityElement.js → decodeEntityElement.js} +0 -0
- /package/dist/cjs/{src/dehydrateIndexItem.js → dehydrateIndexItem.js} +0 -0
- /package/dist/cjs/{src/dehydratePageKeyMap.js → dehydratePageKeyMap.js} +0 -0
- /package/dist/cjs/{src/encodeEntityElement.js → encodeEntityElement.js} +0 -0
- /package/dist/cjs/{src/getShardBump.js → getShardBump.js} +0 -0
- /package/dist/cjs/{src/index.js → index.js} +0 -0
- /package/dist/cjs/{src/removeKeys.js → removeKeys.js} +0 -0
- /package/dist/cjs/{src/validateEntityGeneratedProperty.js → validateEntityGeneratedProperty.js} +0 -0
- /package/dist/cjs/{src/validateEntityIndexToken.js → validateEntityIndexToken.js} +0 -0
- /package/dist/cjs/{src/validateEntityToken.js → validateEntityToken.js} +0 -0
- /package/dist/mjs/{src/conditionalize.js → conditionalize.js} +0 -0
- /package/dist/mjs/{src/decodeEntityElement.js → decodeEntityElement.js} +0 -0
- /package/dist/mjs/{src/dehydrateIndexItem.js → dehydrateIndexItem.js} +0 -0
- /package/dist/mjs/{src/dehydratePageKeyMap.js → dehydratePageKeyMap.js} +0 -0
- /package/dist/mjs/{src/encodeEntityElement.js → encodeEntityElement.js} +0 -0
- /package/dist/mjs/{src/getShardBump.js → getShardBump.js} +0 -0
- /package/dist/mjs/{src/index.js → index.js} +0 -0
- /package/dist/mjs/{src/removeKeys.js → removeKeys.js} +0 -0
- /package/dist/mjs/{src/validateEntityGeneratedProperty.js → validateEntityGeneratedProperty.js} +0 -0
- /package/dist/mjs/{src/validateEntityIndexToken.js → validateEntityIndexToken.js} +0 -0
- /package/dist/mjs/{src/validateEntityToken.js → validateEntityToken.js} +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { shake, zipToObject } from 'radash';
|
|
1
2
|
import { decodeEntityElement } from './decodeEntityElement.js';
|
|
2
3
|
import { unwrapIndex } from './unwrapIndex.js';
|
|
3
4
|
import { validateEntityIndexToken } from './validateEntityIndexToken.js';
|
|
4
|
-
import { shake } from '../node_modules/radash/dist/esm/object.js';
|
|
5
|
-
import { zipToObject } from '../node_modules/radash/dist/esm/array.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Convert a delimited string into a partial {@link ItemMap | `ItemMap`} object representing the ungenerated component elements of a Config entity index.
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { range, mapValues, zipToObject, cluster } from 'radash';
|
|
1
2
|
import { encodeGeneratedProperty } from './encodeGeneratedProperty.js';
|
|
2
3
|
import { getHashKeySpace } from './getHashKeySpace.js';
|
|
3
4
|
import { rehydrateIndexItem } from './rehydrateIndexItem.js';
|
|
4
5
|
import { updateItemRangeKey } from './updateItemRangeKey.js';
|
|
5
6
|
import { validateEntityIndexToken } from './validateEntityIndexToken.js';
|
|
6
|
-
import { range, zipToObject, cluster } from '../node_modules/radash/dist/esm/array.js';
|
|
7
|
-
import { mapValues } from '../node_modules/radash/dist/esm/object.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Rehydrate an array of dehydrated page keys into a {@link PageKeyMap | `PageKeyMap`} object.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { shake } from 'radash';
|
|
1
2
|
import { validateEntityIndexToken } from './validateEntityIndexToken.js';
|
|
2
|
-
import { shake } from '../node_modules/radash/dist/esm/object.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Unwraps an {@link ConfigEntity.indexes | Entity index} into deduped, sorted, ungenerated index component elements.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isNil } from '
|
|
2
|
-
import stringHash from '
|
|
1
|
+
import { isNil } from '@karmaniverous/entity-tools';
|
|
2
|
+
import stringHash from 'string-hash';
|
|
3
3
|
import { getShardBump } from './getShardBump.js';
|
|
4
4
|
import { validateEntityToken } from './validateEntityToken.js';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/karmaniverous/entity-manager/issues"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@karmaniverous/entity-tools": "^0.2.
|
|
7
|
+
"@karmaniverous/entity-tools": "^0.2.5",
|
|
8
8
|
"@karmaniverous/string-utilities": "^0.2.1",
|
|
9
9
|
"jsonschema": "^1.4.1",
|
|
10
10
|
"lz-string": "^1.5.0",
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
".": {
|
|
64
64
|
"import": {
|
|
65
65
|
"types": "./dist/index.d.ts",
|
|
66
|
-
"default": "./dist/mjs/
|
|
66
|
+
"default": "./dist/mjs/index.js"
|
|
67
67
|
},
|
|
68
68
|
"require": {
|
|
69
69
|
"types": "./dist/index.d.ts",
|
|
70
|
-
"default": "./dist/cjs/
|
|
70
|
+
"default": "./dist/cjs/index.js"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
},
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"sharding"
|
|
81
81
|
],
|
|
82
82
|
"license": "BSD-3-Clause",
|
|
83
|
-
"main": "dist/cjs/
|
|
84
|
-
"module": "dist/mjs/
|
|
83
|
+
"main": "dist/cjs/index.js",
|
|
84
|
+
"module": "dist/mjs/index.js",
|
|
85
85
|
"name": "@karmaniverous/entity-manager",
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
},
|
|
133
133
|
"type": "module",
|
|
134
134
|
"types": "dist/index.d.ts",
|
|
135
|
-
"version": "6.1.0
|
|
135
|
+
"version": "6.1.0"
|
|
136
136
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _commonjsHelpers = require('./_commonjsHelpers.js');
|
|
4
|
-
var index = require('../node_modules/string-hash/index.js');
|
|
5
|
-
|
|
6
|
-
var stringHashExports = index.__require();
|
|
7
|
-
var stringHash = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(stringHashExports);
|
|
8
|
-
|
|
9
|
-
module.exports = stringHash;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _commonjsHelpers = require('./_commonjsHelpers.js');
|
|
4
|
-
var lzString$1 = require('../node_modules/lz-string/libs/lz-string.js');
|
|
5
|
-
|
|
6
|
-
var lzStringExports = lzString$1.__require();
|
|
7
|
-
var lzString = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(lzStringExports);
|
|
8
|
-
|
|
9
|
-
module.exports = lzString;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Tests whether a value is {@link Nil | `Nil`}.
|
|
5
|
-
*
|
|
6
|
-
* @param value - Value.
|
|
7
|
-
*
|
|
8
|
-
* @returns true if `value` is `null` or `undefined`.
|
|
9
|
-
*
|
|
10
|
-
* @category Utilities
|
|
11
|
-
*/
|
|
12
|
-
const isNil = (value) => value === null || value === undefined;
|
|
13
|
-
|
|
14
|
-
exports.isNil = isNil;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var typed = require('../../../../radash/dist/esm/typed.js');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* {@link Transcodes | `Transcodes`} for {@link DefaultTranscodeMap | `DefaultTranscodeMap`}.
|
|
7
|
-
*
|
|
8
|
-
* See {@link https://github.com/karmaniverous/entity-tools/blob/main/src/defaultTranscodes.ts | implementation details}.
|
|
9
|
-
*
|
|
10
|
-
* @category Transcoding
|
|
11
|
-
*/
|
|
12
|
-
const defaultTranscodes = {
|
|
13
|
-
bigint20: {
|
|
14
|
-
encode: (value) => {
|
|
15
|
-
if (typeof value !== 'bigint' ||
|
|
16
|
-
value > 99999999999999999999n ||
|
|
17
|
-
value < -99999999999999999999n)
|
|
18
|
-
throw new Error('invalid bigint20');
|
|
19
|
-
const [prefix, abs] = value < 0n ? ['n', -value] : ['p', value];
|
|
20
|
-
return `${prefix}${abs.toString().padStart(20, '0')}`;
|
|
21
|
-
},
|
|
22
|
-
decode: (value) => {
|
|
23
|
-
if (!typed.isString(value) || !/^[np][0-9]{20}$/.test(value))
|
|
24
|
-
throw new Error('invalid encoded bigint20');
|
|
25
|
-
return (value.startsWith('n') ? -1n : 1n) * BigInt(value.slice(1));
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
boolean: {
|
|
29
|
-
encode: (value) => {
|
|
30
|
-
if (typeof value !== 'boolean')
|
|
31
|
-
throw new Error('invalid boolean');
|
|
32
|
-
return value.toString();
|
|
33
|
-
},
|
|
34
|
-
decode: (value) => {
|
|
35
|
-
if (!typed.isString(value) || !/^(true|false)$/.test(value))
|
|
36
|
-
throw new Error('invalid encoded boolean');
|
|
37
|
-
return value === 'true';
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
fix6: {
|
|
41
|
-
encode: (value) => {
|
|
42
|
-
if (!typed.isNumber(value) ||
|
|
43
|
-
value > Number.MAX_SAFE_INTEGER / 1000000 ||
|
|
44
|
-
value < Number.MIN_SAFE_INTEGER / 1000000)
|
|
45
|
-
throw new Error('invalid fix6');
|
|
46
|
-
const [prefix, abs] = value < 0 ? ['n', -value] : ['p', value];
|
|
47
|
-
return `${prefix}${abs.toFixed(6).padStart(17, '0')}`;
|
|
48
|
-
},
|
|
49
|
-
decode: (value) => {
|
|
50
|
-
if (!typed.isString(value) || !/^[np][0-9]{10}\.[0-9]{6}$/.test(value))
|
|
51
|
-
throw new Error('invalid encoded fix6');
|
|
52
|
-
return (value.startsWith('n') ? -1 : 1) * Number(value.slice(1));
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
int: {
|
|
56
|
-
encode: (value) => {
|
|
57
|
-
if (!typed.isInt(value))
|
|
58
|
-
throw new Error('invalid int');
|
|
59
|
-
const [prefix, abs] = value < 0 ? ['n', -value] : ['p', value];
|
|
60
|
-
return `${prefix}${abs.toString().padStart(16, '0')}`;
|
|
61
|
-
},
|
|
62
|
-
decode: (value) => {
|
|
63
|
-
if (!typed.isString(value) || !/^[np][0-9]{16}$/.test(value))
|
|
64
|
-
throw new Error('invalid encoded int');
|
|
65
|
-
return (value.startsWith('n') ? -1 : 1) * Number(value.slice(1));
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
string: {
|
|
69
|
-
encode: (value) => {
|
|
70
|
-
if (!typed.isString(value))
|
|
71
|
-
throw new Error('invalid string');
|
|
72
|
-
return value;
|
|
73
|
-
},
|
|
74
|
-
decode: (value) => {
|
|
75
|
-
if (!typed.isString(value))
|
|
76
|
-
throw new Error('invalid encoded string');
|
|
77
|
-
return value;
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
timestamp: {
|
|
81
|
-
encode: (value) => {
|
|
82
|
-
if (!typed.isInt(value) || value < 0 || value > 9999999999999)
|
|
83
|
-
throw new Error('invalid timestamp');
|
|
84
|
-
return value.toString().padStart(13, '0');
|
|
85
|
-
},
|
|
86
|
-
decode: (value) => {
|
|
87
|
-
if (!typed.isString(value) || !/^[0-9]{13}$/.test(value))
|
|
88
|
-
throw new Error('invalid encoded timestamp');
|
|
89
|
-
return Number(value);
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
exports.defaultTranscodes = defaultTranscodes;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Nil = require('./Nil.js');
|
|
4
|
-
var typed = require('../../../../radash/dist/esm/typed.js');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Sort an array of `Item` progressively by `sort`.
|
|
8
|
-
*
|
|
9
|
-
* @typeParam Item - Item type. Must extend {@link Entity | `Entity`}.
|
|
10
|
-
*
|
|
11
|
-
* @param items - Array of `Item`.
|
|
12
|
-
* @param sortOrder - {@link SortOrder | `SortOrder`} array.
|
|
13
|
-
*
|
|
14
|
-
* @returns Sorted `items`.
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* Sorts `items` progresively by the elements of `sortOrder`, passing to the next element if values at the current element are equal.
|
|
18
|
-
*
|
|
19
|
-
* Comparisons are made as expected for `number`, `string`, and `bigint` types.
|
|
20
|
-
*
|
|
21
|
-
* `null` and `undefined` values are considered equivalent and less than any other value.
|
|
22
|
-
*
|
|
23
|
-
* Other types are compared by truthiness, where truthy is greater than falsy.
|
|
24
|
-
*
|
|
25
|
-
* @category Sort
|
|
26
|
-
*/
|
|
27
|
-
const sort = (items = [], sortOrder = []) => [...items].sort((a, b) => {
|
|
28
|
-
let comp = 0;
|
|
29
|
-
for (const { property, desc } of sortOrder) {
|
|
30
|
-
if (typed.isNumber(a[property]) && typed.isNumber(b[property]))
|
|
31
|
-
comp = a[property] - b[property];
|
|
32
|
-
else if (typed.isString(a[property]) && typed.isString(b[property]))
|
|
33
|
-
comp = a[property].localeCompare(b[property]);
|
|
34
|
-
else if (typeof a[property] === 'bigint' &&
|
|
35
|
-
typeof b[property] === 'bigint')
|
|
36
|
-
comp =
|
|
37
|
-
a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;
|
|
38
|
-
else if (!Nil.isNil(a[property]) && Nil.isNil(b[property]))
|
|
39
|
-
comp = 1;
|
|
40
|
-
else if (Nil.isNil(a[property]) && !Nil.isNil(b[property]))
|
|
41
|
-
comp = -1;
|
|
42
|
-
else if (a[property] && !b[property])
|
|
43
|
-
comp = 1;
|
|
44
|
-
else if (!a[property] && b[property])
|
|
45
|
-
comp = -1;
|
|
46
|
-
if (comp)
|
|
47
|
-
return desc ? -comp : comp;
|
|
48
|
-
}
|
|
49
|
-
return comp;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
exports.sort = sort;
|