@verdant-web/common 1.11.0 → 1.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/dist/cjs/EventSubscriber.d.ts +17 -17
- package/dist/cjs/EventSubscriber.js +66 -66
- package/dist/cjs/baseline.d.ts +5 -5
- package/dist/cjs/baseline.js +2 -2
- package/dist/cjs/batching.d.ts +41 -41
- package/dist/cjs/batching.js +88 -88
- package/dist/cjs/files.d.ts +19 -19
- package/dist/cjs/files.js +18 -18
- package/dist/cjs/index.d.ts +18 -18
- package/dist/cjs/index.js +35 -35
- package/dist/cjs/indexes.d.ts +14 -14
- package/dist/cjs/indexes.js +115 -115
- package/dist/cjs/indexes.test.d.ts +1 -1
- package/dist/cjs/indexes.test.js +127 -127
- package/dist/cjs/migration.d.ts +98 -98
- package/dist/cjs/migration.js +127 -127
- package/dist/cjs/oids.d.ts +85 -87
- package/dist/cjs/oids.js +363 -374
- package/dist/cjs/oids.js.map +1 -1
- package/dist/cjs/oids.test.d.ts +1 -1
- package/dist/cjs/oids.test.js +269 -251
- package/dist/cjs/oids.test.js.map +1 -1
- package/dist/cjs/operation.d.ts +139 -139
- package/dist/cjs/operation.js +532 -532
- package/dist/cjs/operation.js.map +1 -1
- package/dist/cjs/operation.test.d.ts +1 -1
- package/dist/cjs/operation.test.js +505 -505
- package/dist/cjs/operation.test.js.map +1 -1
- package/dist/cjs/patch.d.ts +26 -26
- package/dist/cjs/patch.js +226 -226
- package/dist/cjs/patch.js.map +1 -1
- package/dist/cjs/presence.d.ts +27 -27
- package/dist/cjs/presence.js +2 -2
- package/dist/cjs/protocol.d.ts +145 -145
- package/dist/cjs/protocol.js +3 -3
- package/dist/cjs/refs.d.ts +5 -5
- package/dist/cjs/refs.js +21 -21
- package/dist/cjs/replica.d.ts +28 -28
- package/dist/cjs/replica.js +28 -28
- package/dist/cjs/schema/defaults.d.ts +4 -4
- package/dist/cjs/schema/defaults.js +71 -71
- package/dist/cjs/schema/defaults.test.d.ts +1 -1
- package/dist/cjs/schema/defaults.test.js +20 -20
- package/dist/cjs/schema/defaults.test.js.map +1 -1
- package/dist/cjs/schema/index.d.ts +8 -8
- package/dist/cjs/schema/index.js +28 -28
- package/dist/cjs/schema/indexFilters.d.ts +6 -6
- package/dist/cjs/schema/indexFilters.js +30 -30
- package/dist/cjs/schema/types/collection.d.ts +51 -51
- package/dist/cjs/schema/types/collection.js +2 -2
- package/dist/cjs/schema/types/compounds.d.ts +12 -12
- package/dist/cjs/schema/types/compounds.js +2 -2
- package/dist/cjs/schema/types/fields.d.ts +59 -59
- package/dist/cjs/schema/types/fields.js +2 -2
- package/dist/cjs/schema/types/filters.d.ts +29 -29
- package/dist/cjs/schema/types/filters.js +2 -2
- package/dist/cjs/schema/types/shapes.d.ts +21 -21
- package/dist/cjs/schema/types/shapes.js +2 -2
- package/dist/cjs/schema/types/synthetics.d.ts +28 -28
- package/dist/cjs/schema/types/synthetics.js +2 -2
- package/dist/cjs/schema/types.d.ts +18 -18
- package/dist/cjs/schema/types.js +22 -22
- package/dist/cjs/timestamp.d.ts +48 -48
- package/dist/cjs/timestamp.js +243 -243
- package/dist/cjs/timestamp.test.d.ts +1 -1
- package/dist/cjs/timestamp.test.js +93 -93
- package/dist/cjs/undo.d.ts +3 -3
- package/dist/cjs/undo.js +198 -198
- package/dist/cjs/utils.d.ts +15 -15
- package/dist/cjs/utils.js +127 -127
- package/dist/cjs/utils.test.d.ts +1 -1
- package/dist/cjs/utils.test.js +36 -36
- package/dist/esm/EventSubscriber.d.ts +17 -17
- package/dist/esm/EventSubscriber.js +62 -62
- package/dist/esm/baseline.d.ts +5 -5
- package/dist/esm/baseline.js +1 -1
- package/dist/esm/batching.d.ts +41 -41
- package/dist/esm/batching.js +83 -83
- package/dist/esm/files.d.ts +19 -19
- package/dist/esm/files.js +12 -12
- package/dist/esm/index.d.ts +18 -18
- package/dist/esm/index.js +15 -15
- package/dist/esm/indexes.d.ts +14 -14
- package/dist/esm/indexes.js +105 -105
- package/dist/esm/indexes.test.d.ts +1 -1
- package/dist/esm/indexes.test.js +125 -125
- package/dist/esm/migration.d.ts +98 -98
- package/dist/esm/migration.js +121 -121
- package/dist/esm/oids.d.ts +85 -87
- package/dist/esm/oids.js +336 -347
- package/dist/esm/oids.js.map +1 -1
- package/dist/esm/oids.test.d.ts +1 -1
- package/dist/esm/oids.test.js +267 -249
- package/dist/esm/oids.test.js.map +1 -1
- package/dist/esm/operation.d.ts +139 -139
- package/dist/esm/operation.js +517 -517
- package/dist/esm/operation.js.map +1 -1
- package/dist/esm/operation.test.d.ts +1 -1
- package/dist/esm/operation.test.js +503 -503
- package/dist/esm/operation.test.js.map +1 -1
- package/dist/esm/patch.d.ts +26 -26
- package/dist/esm/patch.js +222 -222
- package/dist/esm/patch.js.map +1 -1
- package/dist/esm/presence.d.ts +27 -27
- package/dist/esm/presence.js +1 -1
- package/dist/esm/protocol.d.ts +145 -145
- package/dist/esm/protocol.js +2 -2
- package/dist/esm/refs.d.ts +5 -5
- package/dist/esm/refs.js +16 -16
- package/dist/esm/replica.d.ts +28 -28
- package/dist/esm/replica.js +25 -25
- package/dist/esm/schema/defaults.d.ts +4 -4
- package/dist/esm/schema/defaults.js +65 -65
- package/dist/esm/schema/defaults.test.d.ts +1 -1
- package/dist/esm/schema/defaults.test.js +18 -18
- package/dist/esm/schema/defaults.test.js.map +1 -1
- package/dist/esm/schema/index.d.ts +8 -8
- package/dist/esm/schema/index.js +9 -9
- package/dist/esm/schema/indexFilters.d.ts +6 -6
- package/dist/esm/schema/indexFilters.js +22 -22
- package/dist/esm/schema/types/collection.d.ts +51 -51
- package/dist/esm/schema/types/collection.js +1 -1
- package/dist/esm/schema/types/compounds.d.ts +12 -12
- package/dist/esm/schema/types/compounds.js +1 -1
- package/dist/esm/schema/types/fields.d.ts +59 -59
- package/dist/esm/schema/types/fields.js +1 -1
- package/dist/esm/schema/types/filters.d.ts +29 -29
- package/dist/esm/schema/types/filters.js +1 -1
- package/dist/esm/schema/types/shapes.d.ts +21 -21
- package/dist/esm/schema/types/shapes.js +1 -1
- package/dist/esm/schema/types/synthetics.d.ts +28 -28
- package/dist/esm/schema/types/synthetics.js +1 -1
- package/dist/esm/schema/types.d.ts +18 -18
- package/dist/esm/schema/types.js +6 -6
- package/dist/esm/timestamp.d.ts +48 -48
- package/dist/esm/timestamp.js +228 -228
- package/dist/esm/timestamp.test.d.ts +1 -1
- package/dist/esm/timestamp.test.js +91 -91
- package/dist/esm/undo.d.ts +3 -3
- package/dist/esm/undo.js +194 -194
- package/dist/esm/utils.d.ts +15 -15
- package/dist/esm/utils.js +113 -113
- package/dist/esm/utils.test.d.ts +1 -1
- package/dist/esm/utils.test.js +34 -34
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/oids.test.ts +62 -51
- package/src/oids.ts +7 -26
- package/src/operation.test.ts +32 -40
- package/src/operation.ts +4 -16
- package/src/patch.ts +5 -15
- package/src/schema/defaults.test.ts +1 -1
- package/dist/cjs/files.test.d.ts +0 -1
- package/dist/cjs/files.test.js +0 -81
- package/dist/cjs/files.test.js.map +0 -1
- package/dist/esm/files.test.d.ts +0 -1
- package/dist/esm/files.test.js +0 -79
- package/dist/esm/files.test.js.map +0 -1
package/dist/cjs/indexes.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { StorageCollectionSchema } from './index.js';
|
|
2
|
-
export declare const COMPOUND_INDEX_SEPARATOR = "\uFFFFFE";
|
|
3
|
-
export declare const COMPOUND_INDEX_LOWER_BOUND_SEPARATOR = "\0";
|
|
4
|
-
export declare const COMPOUND_INDEX_UPPER_BOUND_SEPARATOR = "\uFFFFFF";
|
|
5
|
-
declare type IndexableFieldValue = string | number | boolean | any[];
|
|
6
|
-
export declare type CompoundIndexValue = string | string[];
|
|
7
|
-
export declare function createCompoundIndexValue(...fields: IndexableFieldValue[]): CompoundIndexValue;
|
|
8
|
-
export declare function createUpperBoundIndexValue(...fields: IndexableFieldValue[]): string;
|
|
9
|
-
export declare function createLowerBoundIndexValue(...fields: IndexableFieldValue[]): string;
|
|
10
|
-
export declare function computeSynthetics(schema: StorageCollectionSchema, obj: any): Record<string, any>;
|
|
11
|
-
export declare function computeCompoundIndices(schema: StorageCollectionSchema<any, any, any>, doc: any): any;
|
|
12
|
-
export declare function assignIndexValues(schema: StorageCollectionSchema<any, any, any>, doc: any): any;
|
|
13
|
-
export declare function sanitizeIndexValue(value: unknown): string | number | (string | number)[];
|
|
14
|
-
export {};
|
|
1
|
+
import { StorageCollectionSchema } from './index.js';
|
|
2
|
+
export declare const COMPOUND_INDEX_SEPARATOR = "\uFFFFFE";
|
|
3
|
+
export declare const COMPOUND_INDEX_LOWER_BOUND_SEPARATOR = "\0";
|
|
4
|
+
export declare const COMPOUND_INDEX_UPPER_BOUND_SEPARATOR = "\uFFFFFF";
|
|
5
|
+
declare type IndexableFieldValue = string | number | boolean | any[];
|
|
6
|
+
export declare type CompoundIndexValue = string | string[];
|
|
7
|
+
export declare function createCompoundIndexValue(...fields: IndexableFieldValue[]): CompoundIndexValue;
|
|
8
|
+
export declare function createUpperBoundIndexValue(...fields: IndexableFieldValue[]): string;
|
|
9
|
+
export declare function createLowerBoundIndexValue(...fields: IndexableFieldValue[]): string;
|
|
10
|
+
export declare function computeSynthetics(schema: StorageCollectionSchema, obj: any): Record<string, any>;
|
|
11
|
+
export declare function computeCompoundIndices(schema: StorageCollectionSchema<any, any, any>, doc: any): any;
|
|
12
|
+
export declare function assignIndexValues(schema: StorageCollectionSchema<any, any, any>, doc: any): any;
|
|
13
|
+
export declare function sanitizeIndexValue(value: unknown): string | number | (string | number)[];
|
|
14
|
+
export {};
|
package/dist/cjs/indexes.js
CHANGED
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeIndexValue = exports.assignIndexValues = exports.computeCompoundIndices = exports.computeSynthetics = exports.createLowerBoundIndexValue = exports.createUpperBoundIndexValue = exports.createCompoundIndexValue = exports.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR = exports.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR = exports.COMPOUND_INDEX_SEPARATOR = void 0;
|
|
4
|
-
// unlikely to be used unicode character
|
|
5
|
-
exports.COMPOUND_INDEX_SEPARATOR = '\uFFFFFE';
|
|
6
|
-
// 1 lower than separator
|
|
7
|
-
exports.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR = '\u0000';
|
|
8
|
-
// 1 higher than separator
|
|
9
|
-
exports.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR = '\uFFFFFF';
|
|
10
|
-
function createCompoundIndexValue(...fields) {
|
|
11
|
-
const value = expandArrayIndex(fields);
|
|
12
|
-
if (value.length === 1) {
|
|
13
|
-
return value[0];
|
|
14
|
-
}
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
exports.createCompoundIndexValue = createCompoundIndexValue;
|
|
18
|
-
function createUpperBoundIndexValue(...fields) {
|
|
19
|
-
return (fields.join(exports.COMPOUND_INDEX_SEPARATOR) +
|
|
20
|
-
`${exports.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR}`);
|
|
21
|
-
}
|
|
22
|
-
exports.createUpperBoundIndexValue = createUpperBoundIndexValue;
|
|
23
|
-
function createLowerBoundIndexValue(...fields) {
|
|
24
|
-
return (fields.join(exports.COMPOUND_INDEX_SEPARATOR) +
|
|
25
|
-
`${exports.COMPOUND_INDEX_SEPARATOR}${exports.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR}`);
|
|
26
|
-
}
|
|
27
|
-
exports.createLowerBoundIndexValue = createLowerBoundIndexValue;
|
|
28
|
-
/**
|
|
29
|
-
* Whenever an array value is included in a compound index, we have to expand
|
|
30
|
-
* the value to include all permutations of values in the array.
|
|
31
|
-
* For example if we had an index id + tags on a document
|
|
32
|
-
*
|
|
33
|
-
* {
|
|
34
|
-
* id: '1',
|
|
35
|
-
* tags: ['a', 'b']
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
38
|
-
* we want to create an index:
|
|
39
|
-
*
|
|
40
|
-
* id_tags: ['1#a', '1#b']
|
|
41
|
-
*
|
|
42
|
-
* If multiple arrays are indexed we have to exponentially expand...
|
|
43
|
-
*
|
|
44
|
-
* id_tags_tags2: ['1#a#a', '1#a#b', '1#b#a', '1#b#b']
|
|
45
|
-
*
|
|
46
|
-
* To generalize this we construct a 2-level array of strings.
|
|
47
|
-
* Iterating over indexed values, we expand each item into N items if
|
|
48
|
-
* the current value is an array.
|
|
49
|
-
*
|
|
50
|
-
* Then we combine all nested arrays into compound index values.
|
|
51
|
-
* This will produce an array of 1 element if none of the indexed values
|
|
52
|
-
* were arrays. The caller should unwrap that.
|
|
53
|
-
*
|
|
54
|
-
* This function also deduplicates values.
|
|
55
|
-
*/
|
|
56
|
-
function expandArrayIndex(fields) {
|
|
57
|
-
let value = [[]];
|
|
58
|
-
for (const field of fields) {
|
|
59
|
-
if (Array.isArray(field)) {
|
|
60
|
-
const newValue = [];
|
|
61
|
-
for (const previousValue of value) {
|
|
62
|
-
for (const fieldValue of field) {
|
|
63
|
-
newValue.push(previousValue.concat(fieldValue));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
value = newValue;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
for (const item of value) {
|
|
70
|
-
item.push(`${field}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return Array.from(new Set(value.map((item) => {
|
|
75
|
-
return item.join(exports.COMPOUND_INDEX_SEPARATOR);
|
|
76
|
-
})));
|
|
77
|
-
}
|
|
78
|
-
function computeSynthetics(schema, obj) {
|
|
79
|
-
const result = {};
|
|
80
|
-
for (const [name, property] of Object.entries(schema.synthetics || {})) {
|
|
81
|
-
result[name] = sanitizeIndexValue(property.compute(obj));
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
exports.computeSynthetics = computeSynthetics;
|
|
86
|
-
function computeCompoundIndices(schema, doc) {
|
|
87
|
-
return Object.entries(schema.compounds || {}).reduce((acc, [indexKey, index]) => {
|
|
88
|
-
acc[indexKey] = createCompoundIndexValue(...index.of.map((key) => doc[key]));
|
|
89
|
-
return acc;
|
|
90
|
-
}, {});
|
|
91
|
-
}
|
|
92
|
-
exports.computeCompoundIndices = computeCompoundIndices;
|
|
93
|
-
function assignIndexValues(schema, doc) {
|
|
94
|
-
Object.assign(doc, computeSynthetics(schema, doc));
|
|
95
|
-
Object.assign(doc, computeCompoundIndices(schema, doc));
|
|
96
|
-
return doc;
|
|
97
|
-
}
|
|
98
|
-
exports.assignIndexValues = assignIndexValues;
|
|
99
|
-
function sanitizeIndexValue(value) {
|
|
100
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
if (typeof value === 'boolean' || value === null) {
|
|
104
|
-
return `${value}`;
|
|
105
|
-
}
|
|
106
|
-
if (value === undefined) {
|
|
107
|
-
// this shouldn't happen ,but for resiliency...
|
|
108
|
-
return 'undefined';
|
|
109
|
-
}
|
|
110
|
-
if (Array.isArray(value)) {
|
|
111
|
-
return value.map(sanitizeIndexValue);
|
|
112
|
-
}
|
|
113
|
-
throw new Error(`Unsupported index value: ${value}`);
|
|
114
|
-
}
|
|
115
|
-
exports.sanitizeIndexValue = sanitizeIndexValue;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeIndexValue = exports.assignIndexValues = exports.computeCompoundIndices = exports.computeSynthetics = exports.createLowerBoundIndexValue = exports.createUpperBoundIndexValue = exports.createCompoundIndexValue = exports.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR = exports.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR = exports.COMPOUND_INDEX_SEPARATOR = void 0;
|
|
4
|
+
// unlikely to be used unicode character
|
|
5
|
+
exports.COMPOUND_INDEX_SEPARATOR = '\uFFFFFE';
|
|
6
|
+
// 1 lower than separator
|
|
7
|
+
exports.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR = '\u0000';
|
|
8
|
+
// 1 higher than separator
|
|
9
|
+
exports.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR = '\uFFFFFF';
|
|
10
|
+
function createCompoundIndexValue(...fields) {
|
|
11
|
+
const value = expandArrayIndex(fields);
|
|
12
|
+
if (value.length === 1) {
|
|
13
|
+
return value[0];
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
exports.createCompoundIndexValue = createCompoundIndexValue;
|
|
18
|
+
function createUpperBoundIndexValue(...fields) {
|
|
19
|
+
return (fields.join(exports.COMPOUND_INDEX_SEPARATOR) +
|
|
20
|
+
`${exports.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR}`);
|
|
21
|
+
}
|
|
22
|
+
exports.createUpperBoundIndexValue = createUpperBoundIndexValue;
|
|
23
|
+
function createLowerBoundIndexValue(...fields) {
|
|
24
|
+
return (fields.join(exports.COMPOUND_INDEX_SEPARATOR) +
|
|
25
|
+
`${exports.COMPOUND_INDEX_SEPARATOR}${exports.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR}`);
|
|
26
|
+
}
|
|
27
|
+
exports.createLowerBoundIndexValue = createLowerBoundIndexValue;
|
|
28
|
+
/**
|
|
29
|
+
* Whenever an array value is included in a compound index, we have to expand
|
|
30
|
+
* the value to include all permutations of values in the array.
|
|
31
|
+
* For example if we had an index id + tags on a document
|
|
32
|
+
*
|
|
33
|
+
* {
|
|
34
|
+
* id: '1',
|
|
35
|
+
* tags: ['a', 'b']
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* we want to create an index:
|
|
39
|
+
*
|
|
40
|
+
* id_tags: ['1#a', '1#b']
|
|
41
|
+
*
|
|
42
|
+
* If multiple arrays are indexed we have to exponentially expand...
|
|
43
|
+
*
|
|
44
|
+
* id_tags_tags2: ['1#a#a', '1#a#b', '1#b#a', '1#b#b']
|
|
45
|
+
*
|
|
46
|
+
* To generalize this we construct a 2-level array of strings.
|
|
47
|
+
* Iterating over indexed values, we expand each item into N items if
|
|
48
|
+
* the current value is an array.
|
|
49
|
+
*
|
|
50
|
+
* Then we combine all nested arrays into compound index values.
|
|
51
|
+
* This will produce an array of 1 element if none of the indexed values
|
|
52
|
+
* were arrays. The caller should unwrap that.
|
|
53
|
+
*
|
|
54
|
+
* This function also deduplicates values.
|
|
55
|
+
*/
|
|
56
|
+
function expandArrayIndex(fields) {
|
|
57
|
+
let value = [[]];
|
|
58
|
+
for (const field of fields) {
|
|
59
|
+
if (Array.isArray(field)) {
|
|
60
|
+
const newValue = [];
|
|
61
|
+
for (const previousValue of value) {
|
|
62
|
+
for (const fieldValue of field) {
|
|
63
|
+
newValue.push(previousValue.concat(fieldValue));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
value = newValue;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
for (const item of value) {
|
|
70
|
+
item.push(`${field}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return Array.from(new Set(value.map((item) => {
|
|
75
|
+
return item.join(exports.COMPOUND_INDEX_SEPARATOR);
|
|
76
|
+
})));
|
|
77
|
+
}
|
|
78
|
+
function computeSynthetics(schema, obj) {
|
|
79
|
+
const result = {};
|
|
80
|
+
for (const [name, property] of Object.entries(schema.synthetics || {})) {
|
|
81
|
+
result[name] = sanitizeIndexValue(property.compute(obj));
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
exports.computeSynthetics = computeSynthetics;
|
|
86
|
+
function computeCompoundIndices(schema, doc) {
|
|
87
|
+
return Object.entries(schema.compounds || {}).reduce((acc, [indexKey, index]) => {
|
|
88
|
+
acc[indexKey] = createCompoundIndexValue(...index.of.map((key) => doc[key]));
|
|
89
|
+
return acc;
|
|
90
|
+
}, {});
|
|
91
|
+
}
|
|
92
|
+
exports.computeCompoundIndices = computeCompoundIndices;
|
|
93
|
+
function assignIndexValues(schema, doc) {
|
|
94
|
+
Object.assign(doc, computeSynthetics(schema, doc));
|
|
95
|
+
Object.assign(doc, computeCompoundIndices(schema, doc));
|
|
96
|
+
return doc;
|
|
97
|
+
}
|
|
98
|
+
exports.assignIndexValues = assignIndexValues;
|
|
99
|
+
function sanitizeIndexValue(value) {
|
|
100
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
if (typeof value === 'boolean' || value === null) {
|
|
104
|
+
return `${value}`;
|
|
105
|
+
}
|
|
106
|
+
if (value === undefined) {
|
|
107
|
+
// this shouldn't happen ,but for resiliency...
|
|
108
|
+
return 'undefined';
|
|
109
|
+
}
|
|
110
|
+
if (Array.isArray(value)) {
|
|
111
|
+
return value.map(sanitizeIndexValue);
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Unsupported index value: ${value}`);
|
|
114
|
+
}
|
|
115
|
+
exports.sanitizeIndexValue = sanitizeIndexValue;
|
|
116
116
|
//# sourceMappingURL=indexes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/dist/cjs/indexes.test.js
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const indexes_js_1 = require("./indexes.js");
|
|
5
|
-
(0, vitest_1.describe)('compound indexes', () => {
|
|
6
|
-
(0, vitest_1.it)('can be created from two string values', () => {
|
|
7
|
-
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)('a', 'b')).toEqual(`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`);
|
|
8
|
-
});
|
|
9
|
-
(0, vitest_1.it)('can be created from two number values', () => {
|
|
10
|
-
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(1, 2)).toEqual(`1${indexes_js_1.COMPOUND_INDEX_SEPARATOR}2`);
|
|
11
|
-
});
|
|
12
|
-
(0, vitest_1.it)('can be created from an array and string value', () => {
|
|
13
|
-
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(['a', 'b'], 'c')).toEqual([
|
|
14
|
-
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
15
|
-
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
16
|
-
]);
|
|
17
|
-
});
|
|
18
|
-
(0, vitest_1.it)('can be created from a string and array of numbers', () => {
|
|
19
|
-
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)('a', [1, 2])).toEqual([
|
|
20
|
-
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}1`,
|
|
21
|
-
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}2`,
|
|
22
|
-
]);
|
|
23
|
-
});
|
|
24
|
-
(0, vitest_1.it)('can be created from an array of strings and an array of booleans', () => {
|
|
25
|
-
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(['a', 'b'], [true, false])).toEqual([
|
|
26
|
-
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
27
|
-
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
28
|
-
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
29
|
-
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
30
|
-
]);
|
|
31
|
-
});
|
|
32
|
-
(0, vitest_1.it)('remove duplicate array compound index values', () => {
|
|
33
|
-
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(['a', 'b', 'b'], [true, false, true])).toEqual([
|
|
34
|
-
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
35
|
-
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
36
|
-
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
37
|
-
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
38
|
-
]);
|
|
39
|
-
});
|
|
40
|
-
(0, vitest_1.it)('creates lower bound value for multi-value indexes', () => {
|
|
41
|
-
(0, vitest_1.expect)((0, indexes_js_1.createLowerBoundIndexValue)('a', 'b')).toEqual(`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}${indexes_js_1.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR}`);
|
|
42
|
-
});
|
|
43
|
-
(0, vitest_1.it)('creates upper bound value for multi-value indexes', () => {
|
|
44
|
-
(0, vitest_1.expect)((0, indexes_js_1.createUpperBoundIndexValue)('a', 'b')).toEqual(`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b${indexes_js_1.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR}`);
|
|
45
|
-
}),
|
|
46
|
-
(0, vitest_1.it)('will always be grouped by the first item', () => {
|
|
47
|
-
(0, vitest_1.expect)([
|
|
48
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'b'),
|
|
49
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'c'),
|
|
50
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'd'),
|
|
51
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'e'),
|
|
52
|
-
// extra nefarious!
|
|
53
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaaaaaa', 'no!'),
|
|
54
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa ', 'no!'),
|
|
55
|
-
(0, indexes_js_1.createCompoundIndexValue)(`aaaaaa😎`, 'no!'),
|
|
56
|
-
(0, indexes_js_1.createCompoundIndexValue)(`aaaaaa😎😎`, 'no!'),
|
|
57
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaa', 'no!'),
|
|
58
|
-
(0, indexes_js_1.createCompoundIndexValue)(`aaaaaaa😎no!`, 'no!'),
|
|
59
|
-
].sort()).toEqual([
|
|
60
|
-
`aaaaaa ${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
61
|
-
`aaaaaaa😎no!${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
62
|
-
`aaaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
63
|
-
`aaaaaa😎😎${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
64
|
-
`aaaaaa😎${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
65
|
-
// this is the contiguous block of relevant values
|
|
66
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`,
|
|
67
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
68
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}d`,
|
|
69
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}e`,
|
|
70
|
-
// here ends the block
|
|
71
|
-
`aaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
(0, vitest_1.it)('will be bounded by upper and lower bound values', () => {
|
|
75
|
-
const match = 'aaaaaa';
|
|
76
|
-
const sorted = [
|
|
77
|
-
(0, indexes_js_1.createCompoundIndexValue)(match, 'b'),
|
|
78
|
-
(0, indexes_js_1.createCompoundIndexValue)(match, 'c'),
|
|
79
|
-
(0, indexes_js_1.createCompoundIndexValue)(match, 'd'),
|
|
80
|
-
(0, indexes_js_1.createCompoundIndexValue)(match, 'e'),
|
|
81
|
-
// extra nefarious!
|
|
82
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match}a`, 'no!'),
|
|
83
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match} `, 'no!'),
|
|
84
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match}😎`, 'no!'),
|
|
85
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match}😎😎`, 'no!'),
|
|
86
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaa', 'no!'),
|
|
87
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match}a😎no!`, 'no!'),
|
|
88
|
-
].sort();
|
|
89
|
-
const boundedBlock = sorted.filter((value) => value > (0, indexes_js_1.createLowerBoundIndexValue)(match) &&
|
|
90
|
-
value < (0, indexes_js_1.createUpperBoundIndexValue)(match));
|
|
91
|
-
(0, vitest_1.expect)(boundedBlock).toEqual([
|
|
92
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`,
|
|
93
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
94
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}d`,
|
|
95
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}e`,
|
|
96
|
-
]);
|
|
97
|
-
});
|
|
98
|
-
(0, vitest_1.it)('will be bounded by upper and lower bounds when matching multiple sections', () => {
|
|
99
|
-
const match1 = 'aaaaaa';
|
|
100
|
-
const match2 = 'bbbbbb';
|
|
101
|
-
const sorted = [
|
|
102
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'b'),
|
|
103
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'c'),
|
|
104
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'd'),
|
|
105
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'e'),
|
|
106
|
-
// extra nefarious!
|
|
107
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match1}a`, match2, 'no!'),
|
|
108
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match1} `, match2, 'no!'),
|
|
109
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match1}😎`, match2, 'no!'),
|
|
110
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match1}😎😎`, match2, 'no!'),
|
|
111
|
-
(0, indexes_js_1.createCompoundIndexValue)('aaa', match2, 'no!'),
|
|
112
|
-
(0, indexes_js_1.createCompoundIndexValue)(`${match1}a😎no!`, match2, 'no!'),
|
|
113
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, `${match2}a😎no!`, 'no!'),
|
|
114
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, `${match2} `, 'no!'),
|
|
115
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, ' ', 'no!'),
|
|
116
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, '\u00001', 'no!'),
|
|
117
|
-
(0, indexes_js_1.createCompoundIndexValue)(match1, '\uE007f', 'no!'),
|
|
118
|
-
].sort();
|
|
119
|
-
(0, vitest_1.expect)(sorted.filter((value) => value > (0, indexes_js_1.createLowerBoundIndexValue)(match1, match2) &&
|
|
120
|
-
value < (0, indexes_js_1.createUpperBoundIndexValue)(match1, match2))).toEqual([
|
|
121
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`,
|
|
122
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
123
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}d`,
|
|
124
|
-
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}e`,
|
|
125
|
-
]);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const indexes_js_1 = require("./indexes.js");
|
|
5
|
+
(0, vitest_1.describe)('compound indexes', () => {
|
|
6
|
+
(0, vitest_1.it)('can be created from two string values', () => {
|
|
7
|
+
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)('a', 'b')).toEqual(`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`);
|
|
8
|
+
});
|
|
9
|
+
(0, vitest_1.it)('can be created from two number values', () => {
|
|
10
|
+
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(1, 2)).toEqual(`1${indexes_js_1.COMPOUND_INDEX_SEPARATOR}2`);
|
|
11
|
+
});
|
|
12
|
+
(0, vitest_1.it)('can be created from an array and string value', () => {
|
|
13
|
+
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(['a', 'b'], 'c')).toEqual([
|
|
14
|
+
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
15
|
+
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)('can be created from a string and array of numbers', () => {
|
|
19
|
+
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)('a', [1, 2])).toEqual([
|
|
20
|
+
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}1`,
|
|
21
|
+
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}2`,
|
|
22
|
+
]);
|
|
23
|
+
});
|
|
24
|
+
(0, vitest_1.it)('can be created from an array of strings and an array of booleans', () => {
|
|
25
|
+
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(['a', 'b'], [true, false])).toEqual([
|
|
26
|
+
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
27
|
+
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
28
|
+
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
29
|
+
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.it)('remove duplicate array compound index values', () => {
|
|
33
|
+
(0, vitest_1.expect)((0, indexes_js_1.createCompoundIndexValue)(['a', 'b', 'b'], [true, false, true])).toEqual([
|
|
34
|
+
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
35
|
+
`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
36
|
+
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}true`,
|
|
37
|
+
`b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}false`,
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.it)('creates lower bound value for multi-value indexes', () => {
|
|
41
|
+
(0, vitest_1.expect)((0, indexes_js_1.createLowerBoundIndexValue)('a', 'b')).toEqual(`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b${indexes_js_1.COMPOUND_INDEX_SEPARATOR}${indexes_js_1.COMPOUND_INDEX_LOWER_BOUND_SEPARATOR}`);
|
|
42
|
+
});
|
|
43
|
+
(0, vitest_1.it)('creates upper bound value for multi-value indexes', () => {
|
|
44
|
+
(0, vitest_1.expect)((0, indexes_js_1.createUpperBoundIndexValue)('a', 'b')).toEqual(`a${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b${indexes_js_1.COMPOUND_INDEX_UPPER_BOUND_SEPARATOR}`);
|
|
45
|
+
}),
|
|
46
|
+
(0, vitest_1.it)('will always be grouped by the first item', () => {
|
|
47
|
+
(0, vitest_1.expect)([
|
|
48
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'b'),
|
|
49
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'c'),
|
|
50
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'd'),
|
|
51
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa', 'e'),
|
|
52
|
+
// extra nefarious!
|
|
53
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaaaaaa', 'no!'),
|
|
54
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaaaaa ', 'no!'),
|
|
55
|
+
(0, indexes_js_1.createCompoundIndexValue)(`aaaaaa😎`, 'no!'),
|
|
56
|
+
(0, indexes_js_1.createCompoundIndexValue)(`aaaaaa😎😎`, 'no!'),
|
|
57
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaa', 'no!'),
|
|
58
|
+
(0, indexes_js_1.createCompoundIndexValue)(`aaaaaaa😎no!`, 'no!'),
|
|
59
|
+
].sort()).toEqual([
|
|
60
|
+
`aaaaaa ${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
61
|
+
`aaaaaaa😎no!${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
62
|
+
`aaaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
63
|
+
`aaaaaa😎😎${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
64
|
+
`aaaaaa😎${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
65
|
+
// this is the contiguous block of relevant values
|
|
66
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`,
|
|
67
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
68
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}d`,
|
|
69
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}e`,
|
|
70
|
+
// here ends the block
|
|
71
|
+
`aaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}no!`,
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.it)('will be bounded by upper and lower bound values', () => {
|
|
75
|
+
const match = 'aaaaaa';
|
|
76
|
+
const sorted = [
|
|
77
|
+
(0, indexes_js_1.createCompoundIndexValue)(match, 'b'),
|
|
78
|
+
(0, indexes_js_1.createCompoundIndexValue)(match, 'c'),
|
|
79
|
+
(0, indexes_js_1.createCompoundIndexValue)(match, 'd'),
|
|
80
|
+
(0, indexes_js_1.createCompoundIndexValue)(match, 'e'),
|
|
81
|
+
// extra nefarious!
|
|
82
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match}a`, 'no!'),
|
|
83
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match} `, 'no!'),
|
|
84
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match}😎`, 'no!'),
|
|
85
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match}😎😎`, 'no!'),
|
|
86
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaa', 'no!'),
|
|
87
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match}a😎no!`, 'no!'),
|
|
88
|
+
].sort();
|
|
89
|
+
const boundedBlock = sorted.filter((value) => value > (0, indexes_js_1.createLowerBoundIndexValue)(match) &&
|
|
90
|
+
value < (0, indexes_js_1.createUpperBoundIndexValue)(match));
|
|
91
|
+
(0, vitest_1.expect)(boundedBlock).toEqual([
|
|
92
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`,
|
|
93
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
94
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}d`,
|
|
95
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}e`,
|
|
96
|
+
]);
|
|
97
|
+
});
|
|
98
|
+
(0, vitest_1.it)('will be bounded by upper and lower bounds when matching multiple sections', () => {
|
|
99
|
+
const match1 = 'aaaaaa';
|
|
100
|
+
const match2 = 'bbbbbb';
|
|
101
|
+
const sorted = [
|
|
102
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'b'),
|
|
103
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'c'),
|
|
104
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'd'),
|
|
105
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, match2, 'e'),
|
|
106
|
+
// extra nefarious!
|
|
107
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match1}a`, match2, 'no!'),
|
|
108
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match1} `, match2, 'no!'),
|
|
109
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match1}😎`, match2, 'no!'),
|
|
110
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match1}😎😎`, match2, 'no!'),
|
|
111
|
+
(0, indexes_js_1.createCompoundIndexValue)('aaa', match2, 'no!'),
|
|
112
|
+
(0, indexes_js_1.createCompoundIndexValue)(`${match1}a😎no!`, match2, 'no!'),
|
|
113
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, `${match2}a😎no!`, 'no!'),
|
|
114
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, `${match2} `, 'no!'),
|
|
115
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, ' ', 'no!'),
|
|
116
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, '\u00001', 'no!'),
|
|
117
|
+
(0, indexes_js_1.createCompoundIndexValue)(match1, '\uE007f', 'no!'),
|
|
118
|
+
].sort();
|
|
119
|
+
(0, vitest_1.expect)(sorted.filter((value) => value > (0, indexes_js_1.createLowerBoundIndexValue)(match1, match2) &&
|
|
120
|
+
value < (0, indexes_js_1.createUpperBoundIndexValue)(match1, match2))).toEqual([
|
|
121
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}b`,
|
|
122
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}c`,
|
|
123
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}d`,
|
|
124
|
+
`aaaaaa${indexes_js_1.COMPOUND_INDEX_SEPARATOR}bbbbbb${indexes_js_1.COMPOUND_INDEX_SEPARATOR}e`,
|
|
125
|
+
]);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
128
|
//# sourceMappingURL=indexes.test.js.map
|