@verdant-web/common 1.15.3-next.0 → 1.15.3
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 +42 -42
- package/dist/cjs/batching.js +91 -91
- package/dist/cjs/files.d.ts +19 -19
- package/dist/cjs/files.js +18 -18
- package/dist/cjs/index.d.ts +19 -19
- package/dist/cjs/index.js +41 -41
- package/dist/cjs/indexes.d.ts +17 -17
- package/dist/cjs/indexes.js +142 -142
- package/dist/cjs/indexes.test.d.ts +1 -1
- package/dist/cjs/indexes.test.js +127 -127
- package/dist/cjs/migration.d.ts +172 -172
- package/dist/cjs/migration.js +301 -301
- package/dist/cjs/oids.d.ts +100 -100
- package/dist/cjs/oids.js +457 -457
- package/dist/cjs/oids.test.d.ts +1 -1
- package/dist/cjs/oids.test.js +348 -348
- package/dist/cjs/operation.d.ts +139 -139
- package/dist/cjs/operation.js +545 -545
- package/dist/cjs/operation.test.d.ts +1 -1
- package/dist/cjs/operation.test.js +529 -529
- package/dist/cjs/patch.d.ts +26 -26
- package/dist/cjs/patch.js +226 -226
- 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 +7 -7
- package/dist/cjs/refs.js +29 -29
- package/dist/cjs/replica.d.ts +28 -28
- package/dist/cjs/replica.js +28 -28
- package/dist/cjs/schema/defaults.test.d.ts +1 -1
- package/dist/cjs/schema/defaults.test.js +20 -20
- package/dist/cjs/schema/fields.d.ts +9 -9
- package/dist/cjs/schema/fields.js +144 -144
- package/dist/cjs/schema/index.d.ts +8 -8
- package/dist/cjs/schema/index.js +51 -51
- 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 +23 -23
- package/dist/cjs/schema/types/collection.js +2 -2
- package/dist/cjs/schema/types/compounds.d.ts +11 -11
- package/dist/cjs/schema/types/compounds.js +2 -2
- package/dist/cjs/schema/types/fields.d.ts +75 -75
- 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 +37 -37
- 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/schema/validation.d.ts +3 -3
- package/dist/cjs/schema/validation.js +86 -86
- package/dist/cjs/timestamp.d.ts +50 -50
- package/dist/cjs/timestamp.js +251 -251
- package/dist/cjs/timestamp.test.d.ts +1 -1
- package/dist/cjs/timestamp.test.js +104 -104
- package/dist/cjs/undo.d.ts +3 -3
- package/dist/cjs/undo.js +198 -198
- package/dist/cjs/utils.d.ts +20 -20
- package/dist/cjs/utils.js +145 -145
- 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 +42 -42
- package/dist/esm/batching.js +86 -86
- package/dist/esm/files.d.ts +19 -19
- package/dist/esm/files.js +12 -12
- package/dist/esm/index.d.ts +19 -19
- package/dist/esm/index.js +16 -16
- package/dist/esm/indexes.d.ts +17 -17
- package/dist/esm/indexes.js +130 -130
- package/dist/esm/indexes.test.d.ts +1 -1
- package/dist/esm/indexes.test.js +125 -125
- package/dist/esm/migration.d.ts +172 -172
- package/dist/esm/migration.js +294 -294
- package/dist/esm/oids.d.ts +100 -100
- package/dist/esm/oids.js +422 -422
- package/dist/esm/oids.test.d.ts +1 -1
- package/dist/esm/oids.test.js +346 -346
- package/dist/esm/operation.d.ts +139 -139
- package/dist/esm/operation.js +530 -530
- package/dist/esm/operation.test.d.ts +1 -1
- package/dist/esm/operation.test.js +527 -527
- package/dist/esm/patch.d.ts +26 -26
- package/dist/esm/patch.js +222 -222
- 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 +7 -7
- package/dist/esm/refs.js +22 -22
- package/dist/esm/replica.d.ts +28 -28
- package/dist/esm/replica.js +25 -25
- package/dist/esm/schema/defaults.test.d.ts +1 -1
- package/dist/esm/schema/defaults.test.js +18 -18
- package/dist/esm/schema/fields.d.ts +9 -9
- package/dist/esm/schema/fields.js +133 -133
- package/dist/esm/schema/index.d.ts +8 -8
- package/dist/esm/schema/index.js +32 -32
- 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 +23 -23
- package/dist/esm/schema/types/collection.js +1 -1
- package/dist/esm/schema/types/compounds.d.ts +11 -11
- package/dist/esm/schema/types/compounds.js +1 -1
- package/dist/esm/schema/types/fields.d.ts +75 -75
- 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 +37 -37
- 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/schema/validation.d.ts +3 -3
- package/dist/esm/schema/validation.js +81 -81
- package/dist/esm/timestamp.d.ts +50 -50
- package/dist/esm/timestamp.js +234 -234
- package/dist/esm/timestamp.test.d.ts +1 -1
- package/dist/esm/timestamp.test.js +102 -102
- package/dist/esm/undo.d.ts +3 -3
- package/dist/esm/undo.js +194 -194
- package/dist/esm/utils.d.ts +20 -20
- package/dist/esm/utils.js +127 -127
- 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/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/cjs/schema/defaults.d.ts +0 -4
- package/dist/cjs/schema/defaults.js +0 -72
- package/dist/cjs/schema/defaults.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/esm/schema/defaults.d.ts +0 -4
- package/dist/esm/schema/defaults.js +0 -66
- package/dist/esm/schema/defaults.js.map +0 -1
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
import { LEGACY_OID_KEY, OID_KEY } from '../oids.js';
|
|
2
|
-
import { isObject } from '../utils.js';
|
|
3
|
-
export function isNullable(field) {
|
|
4
|
-
if (field.type === 'any')
|
|
5
|
-
return true;
|
|
6
|
-
if (field.type === 'map')
|
|
7
|
-
return false;
|
|
8
|
-
return field.nullable;
|
|
9
|
-
}
|
|
10
|
-
export function hasDefault(field) {
|
|
11
|
-
if (!field)
|
|
12
|
-
return false;
|
|
13
|
-
if (field.type === 'map')
|
|
14
|
-
return true;
|
|
15
|
-
if (field.type === 'array')
|
|
16
|
-
return true;
|
|
17
|
-
if (field.type === 'file')
|
|
18
|
-
return false;
|
|
19
|
-
if (field.type === 'object')
|
|
20
|
-
return true;
|
|
21
|
-
return field.default !== undefined;
|
|
22
|
-
}
|
|
23
|
-
export function isIndexed(field) {
|
|
24
|
-
if (field.type === 'map')
|
|
25
|
-
return false;
|
|
26
|
-
if (field.type === 'object')
|
|
27
|
-
return false;
|
|
28
|
-
if (field.type === 'array')
|
|
29
|
-
return false;
|
|
30
|
-
if (field.type === 'file')
|
|
31
|
-
return false;
|
|
32
|
-
if (field.type === 'any')
|
|
33
|
-
return false;
|
|
34
|
-
return field.indexed;
|
|
35
|
-
}
|
|
36
|
-
export function addFieldDefaults(collection, value) {
|
|
37
|
-
for (const [key, field] of Object.entries(collection.fields)) {
|
|
38
|
-
const defaultValue = getFieldDefault(field);
|
|
39
|
-
if ((defaultValue !== undefined && value[key] === undefined) ||
|
|
40
|
-
// covers the case where a previously nullable field
|
|
41
|
-
// now has a default during a new migration
|
|
42
|
-
(!isNullable(field) && value[key] === null)) {
|
|
43
|
-
value[key] = defaultValue;
|
|
44
|
-
}
|
|
45
|
-
if (value[key]) {
|
|
46
|
-
traverseCollectionFieldsAndApplyDefaults(value[key], field);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
export function traverseCollectionFieldsAndApplyDefaults(value, field) {
|
|
52
|
-
if (value === undefined || value === null)
|
|
53
|
-
return value;
|
|
54
|
-
if (field.type === 'object') {
|
|
55
|
-
for (const [key, subField] of Object.entries(field.properties)) {
|
|
56
|
-
if (value[key] === undefined) {
|
|
57
|
-
const defaultValue = getFieldDefault(subField);
|
|
58
|
-
if (defaultValue !== undefined) {
|
|
59
|
-
value[key] = defaultValue;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
traverseCollectionFieldsAndApplyDefaults(value[key], subField);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else if (field.type === 'array') {
|
|
66
|
-
for (const item of value) {
|
|
67
|
-
traverseCollectionFieldsAndApplyDefaults(item, field.items);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else if (field.type === 'map') {
|
|
71
|
-
for (const [key, item] of Object.entries(value)) {
|
|
72
|
-
// santiy check to weed out any id field
|
|
73
|
-
if (key === OID_KEY || key === LEGACY_OID_KEY)
|
|
74
|
-
continue;
|
|
75
|
-
traverseCollectionFieldsAndApplyDefaults(item, field.values);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export function getFieldDefault(field) {
|
|
80
|
-
if (field.type === 'string' ||
|
|
81
|
-
field.type === 'number' ||
|
|
82
|
-
field.type === 'boolean' ||
|
|
83
|
-
field.type === 'any') {
|
|
84
|
-
if (field.default && typeof field.default === 'function') {
|
|
85
|
-
return field.default();
|
|
86
|
-
}
|
|
87
|
-
else if (field.default !== undefined) {
|
|
88
|
-
// TODO: structuredClone?
|
|
89
|
-
return JSON.parse(JSON.stringify(field.default));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (field.type === 'array') {
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
95
|
-
if (field.type === 'map') {
|
|
96
|
-
return {};
|
|
97
|
-
}
|
|
98
|
-
if (field.type !== 'any' && field.nullable) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
export function removeExtraProperties(collection, value) {
|
|
104
|
-
for (const [key, fieldValue] of Object.entries(value)) {
|
|
105
|
-
// MUST NOT DELETE THESE!
|
|
106
|
-
if (key === OID_KEY || key === LEGACY_OID_KEY)
|
|
107
|
-
continue;
|
|
108
|
-
if (!collection.fields[key]) {
|
|
109
|
-
delete value[key];
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, collection.fields[key]);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
export function traverseCollectionFieldsAndRemoveExtraProperties(value, field) {
|
|
118
|
-
if (isObject(value) && field.type === 'object') {
|
|
119
|
-
for (const [key, fieldValue] of Object.entries(value)) {
|
|
120
|
-
if (!field.properties[key]) {
|
|
121
|
-
delete value[key];
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, field.properties[key]);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else if (Array.isArray(value) && field.type === 'array') {
|
|
129
|
-
for (const item of value) {
|
|
130
|
-
traverseCollectionFieldsAndRemoveExtraProperties(item, field.items);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
1
|
+
import { LEGACY_OID_KEY, OID_KEY } from '../oids.js';
|
|
2
|
+
import { isObject } from '../utils.js';
|
|
3
|
+
export function isNullable(field) {
|
|
4
|
+
if (field.type === 'any')
|
|
5
|
+
return true;
|
|
6
|
+
if (field.type === 'map')
|
|
7
|
+
return false;
|
|
8
|
+
return field.nullable;
|
|
9
|
+
}
|
|
10
|
+
export function hasDefault(field) {
|
|
11
|
+
if (!field)
|
|
12
|
+
return false;
|
|
13
|
+
if (field.type === 'map')
|
|
14
|
+
return true;
|
|
15
|
+
if (field.type === 'array')
|
|
16
|
+
return true;
|
|
17
|
+
if (field.type === 'file')
|
|
18
|
+
return false;
|
|
19
|
+
if (field.type === 'object')
|
|
20
|
+
return true;
|
|
21
|
+
return field.default !== undefined;
|
|
22
|
+
}
|
|
23
|
+
export function isIndexed(field) {
|
|
24
|
+
if (field.type === 'map')
|
|
25
|
+
return false;
|
|
26
|
+
if (field.type === 'object')
|
|
27
|
+
return false;
|
|
28
|
+
if (field.type === 'array')
|
|
29
|
+
return false;
|
|
30
|
+
if (field.type === 'file')
|
|
31
|
+
return false;
|
|
32
|
+
if (field.type === 'any')
|
|
33
|
+
return false;
|
|
34
|
+
return field.indexed;
|
|
35
|
+
}
|
|
36
|
+
export function addFieldDefaults(collection, value) {
|
|
37
|
+
for (const [key, field] of Object.entries(collection.fields)) {
|
|
38
|
+
const defaultValue = getFieldDefault(field);
|
|
39
|
+
if ((defaultValue !== undefined && value[key] === undefined) ||
|
|
40
|
+
// covers the case where a previously nullable field
|
|
41
|
+
// now has a default during a new migration
|
|
42
|
+
(!isNullable(field) && value[key] === null)) {
|
|
43
|
+
value[key] = defaultValue;
|
|
44
|
+
}
|
|
45
|
+
if (value[key]) {
|
|
46
|
+
traverseCollectionFieldsAndApplyDefaults(value[key], field);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
export function traverseCollectionFieldsAndApplyDefaults(value, field) {
|
|
52
|
+
if (value === undefined || value === null)
|
|
53
|
+
return value;
|
|
54
|
+
if (field.type === 'object') {
|
|
55
|
+
for (const [key, subField] of Object.entries(field.properties)) {
|
|
56
|
+
if (value[key] === undefined) {
|
|
57
|
+
const defaultValue = getFieldDefault(subField);
|
|
58
|
+
if (defaultValue !== undefined) {
|
|
59
|
+
value[key] = defaultValue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
traverseCollectionFieldsAndApplyDefaults(value[key], subField);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (field.type === 'array') {
|
|
66
|
+
for (const item of value) {
|
|
67
|
+
traverseCollectionFieldsAndApplyDefaults(item, field.items);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (field.type === 'map') {
|
|
71
|
+
for (const [key, item] of Object.entries(value)) {
|
|
72
|
+
// santiy check to weed out any id field
|
|
73
|
+
if (key === OID_KEY || key === LEGACY_OID_KEY)
|
|
74
|
+
continue;
|
|
75
|
+
traverseCollectionFieldsAndApplyDefaults(item, field.values);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function getFieldDefault(field) {
|
|
80
|
+
if (field.type === 'string' ||
|
|
81
|
+
field.type === 'number' ||
|
|
82
|
+
field.type === 'boolean' ||
|
|
83
|
+
field.type === 'any') {
|
|
84
|
+
if (field.default && typeof field.default === 'function') {
|
|
85
|
+
return field.default();
|
|
86
|
+
}
|
|
87
|
+
else if (field.default !== undefined) {
|
|
88
|
+
// TODO: structuredClone?
|
|
89
|
+
return JSON.parse(JSON.stringify(field.default));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (field.type === 'array') {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
if (field.type === 'map') {
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
if (field.type !== 'any' && field.nullable) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
export function removeExtraProperties(collection, value) {
|
|
104
|
+
for (const [key, fieldValue] of Object.entries(value)) {
|
|
105
|
+
// MUST NOT DELETE THESE!
|
|
106
|
+
if (key === OID_KEY || key === LEGACY_OID_KEY)
|
|
107
|
+
continue;
|
|
108
|
+
if (!collection.fields[key]) {
|
|
109
|
+
delete value[key];
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, collection.fields[key]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
export function traverseCollectionFieldsAndRemoveExtraProperties(value, field) {
|
|
118
|
+
if (isObject(value) && field.type === 'object') {
|
|
119
|
+
for (const [key, fieldValue] of Object.entries(value)) {
|
|
120
|
+
if (!field.properties[key]) {
|
|
121
|
+
delete value[key];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, field.properties[key]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (Array.isArray(value) && field.type === 'array') {
|
|
129
|
+
for (const item of value) {
|
|
130
|
+
traverseCollectionFieldsAndRemoveExtraProperties(item, field.items);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
134
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CollectionCompoundIndices, StorageCollectionSchema, StorageFieldsSchema, StorageSchema, StorageSyntheticIndices } from './types.js';
|
|
2
|
-
export declare function collection<Fields extends StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields>, Compounds extends CollectionCompoundIndices<Fields, Synthetics>>({ synthetics, indexes, ...input }: StorageCollectionSchema<Fields, Synthetics, Compounds>): StorageCollectionSchema<Fields, Synthetics, Compounds>;
|
|
3
|
-
export declare function schema<Schema extends StorageSchema<{
|
|
4
|
-
[key: string]: StorageCollectionSchema<any, any, any>;
|
|
5
|
-
}>>(input: Schema): StorageSchema;
|
|
6
|
-
export * from './types.js';
|
|
7
|
-
export * from './indexFilters.js';
|
|
8
|
-
export * from './fields.js';
|
|
1
|
+
import { CollectionCompoundIndices, StorageCollectionSchema, StorageFieldsSchema, StorageSchema, StorageSyntheticIndices } from './types.js';
|
|
2
|
+
export declare function collection<Fields extends StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields>, Compounds extends CollectionCompoundIndices<Fields, Synthetics>>({ synthetics, indexes, ...input }: StorageCollectionSchema<Fields, Synthetics, Compounds>): StorageCollectionSchema<Fields, Synthetics, Compounds>;
|
|
3
|
+
export declare function schema<Schema extends StorageSchema<{
|
|
4
|
+
[key: string]: StorageCollectionSchema<any, any, any>;
|
|
5
|
+
}>>(input: Schema): StorageSchema;
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export * from './indexFilters.js';
|
|
8
|
+
export * from './fields.js';
|
package/dist/esm/schema/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { isIndexed } from './fields.js';
|
|
13
|
-
export function collection(_a) {
|
|
14
|
-
var { synthetics, indexes } = _a, input = __rest(_a, ["synthetics", "indexes"]);
|
|
15
|
-
// back compat - copy synthetics in with indexes
|
|
16
|
-
const finalIndexes = Object.assign(Object.assign({}, synthetics), indexes);
|
|
17
|
-
// add all indexed fields into the synthetic indices (back compat)
|
|
18
|
-
for (const [key, field] of Object.entries(input.fields)) {
|
|
19
|
-
if (isIndexed(field)) {
|
|
20
|
-
finalIndexes[key] = {
|
|
21
|
-
field: key,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return Object.assign(Object.assign({}, input), { indexes: finalIndexes });
|
|
26
|
-
}
|
|
27
|
-
export function schema(input) {
|
|
28
|
-
return input;
|
|
29
|
-
}
|
|
30
|
-
export * from './types.js';
|
|
31
|
-
export * from './indexFilters.js';
|
|
32
|
-
export * from './fields.js';
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { isIndexed } from './fields.js';
|
|
13
|
+
export function collection(_a) {
|
|
14
|
+
var { synthetics, indexes } = _a, input = __rest(_a, ["synthetics", "indexes"]);
|
|
15
|
+
// back compat - copy synthetics in with indexes
|
|
16
|
+
const finalIndexes = Object.assign(Object.assign({}, synthetics), indexes);
|
|
17
|
+
// add all indexed fields into the synthetic indices (back compat)
|
|
18
|
+
for (const [key, field] of Object.entries(input.fields)) {
|
|
19
|
+
if (isIndexed(field)) {
|
|
20
|
+
finalIndexes[key] = {
|
|
21
|
+
field: key,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return Object.assign(Object.assign({}, input), { indexes: finalIndexes });
|
|
26
|
+
}
|
|
27
|
+
export function schema(input) {
|
|
28
|
+
return input;
|
|
29
|
+
}
|
|
30
|
+
export * from './types.js';
|
|
31
|
+
export * from './indexFilters.js';
|
|
32
|
+
export * from './fields.js';
|
|
33
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CollectionCompoundIndexFilter, CollectionFilter, MatchCollectionIndexFilter, RangeCollectionIndexFilter, SortIndexFilter, StartsWithIndexFilter } from './types.js';
|
|
2
|
-
export declare function isMatchIndexFilter(filter: CollectionFilter): filter is MatchCollectionIndexFilter;
|
|
3
|
-
export declare function isRangeIndexFilter(filter: CollectionFilter): filter is RangeCollectionIndexFilter;
|
|
4
|
-
export declare function isCompoundIndexFilter(filter: CollectionFilter): filter is CollectionCompoundIndexFilter;
|
|
5
|
-
export declare function isStartsWithIndexFilter(filter: CollectionFilter): filter is StartsWithIndexFilter;
|
|
6
|
-
export declare function isSortIndexFilter(filter: CollectionFilter): filter is SortIndexFilter;
|
|
1
|
+
import { CollectionCompoundIndexFilter, CollectionFilter, MatchCollectionIndexFilter, RangeCollectionIndexFilter, SortIndexFilter, StartsWithIndexFilter } from './types.js';
|
|
2
|
+
export declare function isMatchIndexFilter(filter: CollectionFilter): filter is MatchCollectionIndexFilter;
|
|
3
|
+
export declare function isRangeIndexFilter(filter: CollectionFilter): filter is RangeCollectionIndexFilter;
|
|
4
|
+
export declare function isCompoundIndexFilter(filter: CollectionFilter): filter is CollectionCompoundIndexFilter;
|
|
5
|
+
export declare function isStartsWithIndexFilter(filter: CollectionFilter): filter is StartsWithIndexFilter;
|
|
6
|
+
export declare function isSortIndexFilter(filter: CollectionFilter): filter is SortIndexFilter;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export function isMatchIndexFilter(filter) {
|
|
2
|
-
return filter.equals !== undefined;
|
|
3
|
-
}
|
|
4
|
-
export function isRangeIndexFilter(filter) {
|
|
5
|
-
return (filter.gte !== undefined ||
|
|
6
|
-
filter.lte !== undefined ||
|
|
7
|
-
filter.gt !== undefined ||
|
|
8
|
-
filter.lt !== undefined);
|
|
9
|
-
}
|
|
10
|
-
export function isCompoundIndexFilter(filter) {
|
|
11
|
-
return !!filter.match;
|
|
12
|
-
}
|
|
13
|
-
export function isStartsWithIndexFilter(filter) {
|
|
14
|
-
return filter.startsWith !== undefined;
|
|
15
|
-
}
|
|
16
|
-
export function isSortIndexFilter(filter) {
|
|
17
|
-
return (!isRangeIndexFilter(filter) &&
|
|
18
|
-
!isMatchIndexFilter(filter) &&
|
|
19
|
-
!isCompoundIndexFilter(filter) &&
|
|
20
|
-
!isStartsWithIndexFilter(filter) &&
|
|
21
|
-
filter.order);
|
|
22
|
-
}
|
|
1
|
+
export function isMatchIndexFilter(filter) {
|
|
2
|
+
return filter.equals !== undefined;
|
|
3
|
+
}
|
|
4
|
+
export function isRangeIndexFilter(filter) {
|
|
5
|
+
return (filter.gte !== undefined ||
|
|
6
|
+
filter.lte !== undefined ||
|
|
7
|
+
filter.gt !== undefined ||
|
|
8
|
+
filter.lt !== undefined);
|
|
9
|
+
}
|
|
10
|
+
export function isCompoundIndexFilter(filter) {
|
|
11
|
+
return !!filter.match;
|
|
12
|
+
}
|
|
13
|
+
export function isStartsWithIndexFilter(filter) {
|
|
14
|
+
return filter.startsWith !== undefined;
|
|
15
|
+
}
|
|
16
|
+
export function isSortIndexFilter(filter) {
|
|
17
|
+
return (!isRangeIndexFilter(filter) &&
|
|
18
|
+
!isMatchIndexFilter(filter) &&
|
|
19
|
+
!isCompoundIndexFilter(filter) &&
|
|
20
|
+
!isStartsWithIndexFilter(filter) &&
|
|
21
|
+
filter.order);
|
|
22
|
+
}
|
|
23
23
|
//# sourceMappingURL=indexFilters.js.map
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { CollectionCompoundIndices } from './compounds.js';
|
|
2
|
-
import { StorageFieldsSchema } from './fields.js';
|
|
3
|
-
import { DirectIndexableFieldName, StorageSyntheticIndices } from './synthetics.js';
|
|
4
|
-
/**
|
|
5
|
-
* The main collection schema
|
|
6
|
-
*/
|
|
7
|
-
export declare type StorageCollectionSchema<Fields extends StorageFieldsSchema = StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields> = StorageSyntheticIndices<Fields>, Compounds extends CollectionCompoundIndices<Fields, Synthetics> = CollectionCompoundIndices<Fields, Synthetics>> = {
|
|
8
|
-
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* Your primary key must be a string, number, or boolean field. It must also
|
|
11
|
-
* not be rewritten.
|
|
12
|
-
*/
|
|
13
|
-
primaryKey: DirectIndexableFieldName<Fields>;
|
|
14
|
-
fields: Fields;
|
|
15
|
-
indexes?: Synthetics;
|
|
16
|
-
compounds?: Compounds;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated - plural name is the key used to index this collection in the schema. this field is no longer used.
|
|
19
|
-
*/
|
|
20
|
-
pluralName?: string;
|
|
21
|
-
/** @deprecated - use "indexes" */
|
|
22
|
-
synthetics?: Synthetics;
|
|
23
|
-
};
|
|
1
|
+
import { CollectionCompoundIndices } from './compounds.js';
|
|
2
|
+
import { StorageFieldsSchema } from './fields.js';
|
|
3
|
+
import { DirectIndexableFieldName, StorageSyntheticIndices } from './synthetics.js';
|
|
4
|
+
/**
|
|
5
|
+
* The main collection schema
|
|
6
|
+
*/
|
|
7
|
+
export declare type StorageCollectionSchema<Fields extends StorageFieldsSchema = StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields> = StorageSyntheticIndices<Fields>, Compounds extends CollectionCompoundIndices<Fields, Synthetics> = CollectionCompoundIndices<Fields, Synthetics>> = {
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* Your primary key must be a string, number, or boolean field. It must also
|
|
11
|
+
* not be rewritten.
|
|
12
|
+
*/
|
|
13
|
+
primaryKey: DirectIndexableFieldName<Fields>;
|
|
14
|
+
fields: Fields;
|
|
15
|
+
indexes?: Synthetics;
|
|
16
|
+
compounds?: Compounds;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated - plural name is the key used to index this collection in the schema. this field is no longer used.
|
|
19
|
+
*/
|
|
20
|
+
pluralName?: string;
|
|
21
|
+
/** @deprecated - use "indexes" */
|
|
22
|
+
synthetics?: Synthetics;
|
|
23
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=collection.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { NestedStorageBooleanFieldSchema, NestedStorageNumberFieldSchema, NestedStorageStringFieldSchema, StorageArrayFieldSchema, StorageFieldsSchema } from './fields.js';
|
|
2
|
-
import { DirectIndexableFieldName, StorageSyntheticIndices } from './synthetics.js';
|
|
3
|
-
declare type PrimitiveArrayFields<Fields extends StorageFieldsSchema> = {
|
|
4
|
-
[K in keyof Fields as Fields[K] extends StorageArrayFieldSchema ? Fields[K]['items'] extends NestedStorageStringFieldSchema | NestedStorageNumberFieldSchema | NestedStorageBooleanFieldSchema ? K : never : never]: Fields[K];
|
|
5
|
-
};
|
|
6
|
-
declare type PrimitiveArrayFieldName<Fields extends StorageFieldsSchema> = Extract<keyof PrimitiveArrayFields<Fields>, string>;
|
|
7
|
-
export declare type CollectionCompoundIndex<Fields extends StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields>> = {
|
|
8
|
-
of: (DirectIndexableFieldName<Fields> | PrimitiveArrayFieldName<Fields> | Extract<keyof Synthetics, string>)[];
|
|
9
|
-
};
|
|
10
|
-
export declare type CollectionCompoundIndices<Fields extends StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields>> = Record<string, CollectionCompoundIndex<Fields, Synthetics>>;
|
|
11
|
-
export {};
|
|
1
|
+
import { NestedStorageBooleanFieldSchema, NestedStorageNumberFieldSchema, NestedStorageStringFieldSchema, StorageArrayFieldSchema, StorageFieldsSchema } from './fields.js';
|
|
2
|
+
import { DirectIndexableFieldName, StorageSyntheticIndices } from './synthetics.js';
|
|
3
|
+
declare type PrimitiveArrayFields<Fields extends StorageFieldsSchema> = {
|
|
4
|
+
[K in keyof Fields as Fields[K] extends StorageArrayFieldSchema ? Fields[K]['items'] extends NestedStorageStringFieldSchema | NestedStorageNumberFieldSchema | NestedStorageBooleanFieldSchema ? K : never : never]: Fields[K];
|
|
5
|
+
};
|
|
6
|
+
declare type PrimitiveArrayFieldName<Fields extends StorageFieldsSchema> = Extract<keyof PrimitiveArrayFields<Fields>, string>;
|
|
7
|
+
export declare type CollectionCompoundIndex<Fields extends StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields>> = {
|
|
8
|
+
of: (DirectIndexableFieldName<Fields> | PrimitiveArrayFieldName<Fields> | Extract<keyof Synthetics, string>)[];
|
|
9
|
+
};
|
|
10
|
+
export declare type CollectionCompoundIndices<Fields extends StorageFieldsSchema, Synthetics extends StorageSyntheticIndices<Fields>> = Record<string, CollectionCompoundIndex<Fields, Synthetics>>;
|
|
11
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=compounds.js.map
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
export declare type StorageStringFieldSchema = {
|
|
2
|
-
type: 'string';
|
|
3
|
-
/** @deprecated - add an index to indexes with this field name. */
|
|
4
|
-
indexed?: boolean;
|
|
5
|
-
nullable?: boolean;
|
|
6
|
-
default?: string | (() => string);
|
|
7
|
-
};
|
|
8
|
-
export declare type StorageNumberFieldSchema = {
|
|
9
|
-
type: 'number';
|
|
10
|
-
/** @deprecated - add an index to indexes with this field name. */
|
|
11
|
-
indexed?: boolean;
|
|
12
|
-
nullable?: boolean;
|
|
13
|
-
default?: number | (() => number);
|
|
14
|
-
};
|
|
15
|
-
export declare type StorageBooleanFieldSchema = {
|
|
16
|
-
type: 'boolean';
|
|
17
|
-
nullable?: boolean;
|
|
18
|
-
default?: boolean | (() => boolean);
|
|
19
|
-
/** @deprecated - add an index to indexes with this field name. */
|
|
20
|
-
indexed?: boolean;
|
|
21
|
-
};
|
|
22
|
-
export declare type StorageArrayFieldSchema = {
|
|
23
|
-
type: 'array';
|
|
24
|
-
items: NestedStorageFieldSchema;
|
|
25
|
-
nullable?: boolean;
|
|
26
|
-
};
|
|
27
|
-
export declare type StorageObjectFieldSchema = {
|
|
28
|
-
type: 'object';
|
|
29
|
-
properties: NestedStorageFieldsSchema;
|
|
30
|
-
nullable?: boolean;
|
|
31
|
-
};
|
|
32
|
-
export declare type StorageAnyFieldSchema = {
|
|
33
|
-
type: 'any';
|
|
34
|
-
default?: any;
|
|
35
|
-
};
|
|
36
|
-
export declare type StorageMapFieldSchema<V extends NestedStorageFieldSchema> = {
|
|
37
|
-
type: 'map';
|
|
38
|
-
values: V;
|
|
39
|
-
};
|
|
40
|
-
export declare type StorageFileFieldSchema = {
|
|
41
|
-
type: 'file';
|
|
42
|
-
nullable?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Instructs the client to download synced files to local storage on first request for offline use.
|
|
45
|
-
* Leave this false to save storage space on the client, at the cost of requiring a network
|
|
46
|
-
* connection to use files created by other devices.
|
|
47
|
-
*/
|
|
48
|
-
downloadRemote?: boolean;
|
|
49
|
-
};
|
|
50
|
-
export declare type StorageFieldSchema = StorageStringFieldSchema | StorageNumberFieldSchema | StorageBooleanFieldSchema | StorageArrayFieldSchema | StorageObjectFieldSchema | StorageAnyFieldSchema | StorageMapFieldSchema<any> | StorageFileFieldSchema;
|
|
51
|
-
export declare type NestedStorageStringFieldSchema = {
|
|
52
|
-
type: 'string';
|
|
53
|
-
nullable?: boolean;
|
|
54
|
-
default?: string | (() => string);
|
|
55
|
-
};
|
|
56
|
-
export declare type NestedStorageNumberFieldSchema = {
|
|
57
|
-
type: 'number';
|
|
58
|
-
nullable?: boolean;
|
|
59
|
-
default?: number | (() => number);
|
|
60
|
-
};
|
|
61
|
-
export declare type NestedStorageBooleanFieldSchema = {
|
|
62
|
-
type: 'boolean';
|
|
63
|
-
nullable?: boolean;
|
|
64
|
-
default: boolean | (() => boolean);
|
|
65
|
-
};
|
|
66
|
-
export declare type NestedStorageFieldSchema = NestedStorageStringFieldSchema | NestedStorageNumberFieldSchema | NestedStorageBooleanFieldSchema | StorageArrayFieldSchema | StorageObjectFieldSchema | StorageAnyFieldSchema | StorageMapFieldSchema<any> | StorageFileFieldSchema;
|
|
67
|
-
export declare type StorageFieldsSchema = {
|
|
68
|
-
[key: string]: StorageFieldSchema;
|
|
69
|
-
};
|
|
70
|
-
export declare type NestedStorageFieldsSchema = Record<string, NestedStorageFieldSchema>;
|
|
71
|
-
export declare type StorageIndexableFields<Fields extends StorageFieldsSchema> = {
|
|
72
|
-
[K in keyof Fields]: Fields[K] extends {
|
|
73
|
-
indexed: boolean;
|
|
74
|
-
} ? K : never;
|
|
75
|
-
};
|
|
1
|
+
export declare type StorageStringFieldSchema = {
|
|
2
|
+
type: 'string';
|
|
3
|
+
/** @deprecated - add an index to indexes with this field name. */
|
|
4
|
+
indexed?: boolean;
|
|
5
|
+
nullable?: boolean;
|
|
6
|
+
default?: string | (() => string);
|
|
7
|
+
};
|
|
8
|
+
export declare type StorageNumberFieldSchema = {
|
|
9
|
+
type: 'number';
|
|
10
|
+
/** @deprecated - add an index to indexes with this field name. */
|
|
11
|
+
indexed?: boolean;
|
|
12
|
+
nullable?: boolean;
|
|
13
|
+
default?: number | (() => number);
|
|
14
|
+
};
|
|
15
|
+
export declare type StorageBooleanFieldSchema = {
|
|
16
|
+
type: 'boolean';
|
|
17
|
+
nullable?: boolean;
|
|
18
|
+
default?: boolean | (() => boolean);
|
|
19
|
+
/** @deprecated - add an index to indexes with this field name. */
|
|
20
|
+
indexed?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare type StorageArrayFieldSchema = {
|
|
23
|
+
type: 'array';
|
|
24
|
+
items: NestedStorageFieldSchema;
|
|
25
|
+
nullable?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare type StorageObjectFieldSchema = {
|
|
28
|
+
type: 'object';
|
|
29
|
+
properties: NestedStorageFieldsSchema;
|
|
30
|
+
nullable?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare type StorageAnyFieldSchema = {
|
|
33
|
+
type: 'any';
|
|
34
|
+
default?: any;
|
|
35
|
+
};
|
|
36
|
+
export declare type StorageMapFieldSchema<V extends NestedStorageFieldSchema> = {
|
|
37
|
+
type: 'map';
|
|
38
|
+
values: V;
|
|
39
|
+
};
|
|
40
|
+
export declare type StorageFileFieldSchema = {
|
|
41
|
+
type: 'file';
|
|
42
|
+
nullable?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Instructs the client to download synced files to local storage on first request for offline use.
|
|
45
|
+
* Leave this false to save storage space on the client, at the cost of requiring a network
|
|
46
|
+
* connection to use files created by other devices.
|
|
47
|
+
*/
|
|
48
|
+
downloadRemote?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export declare type StorageFieldSchema = StorageStringFieldSchema | StorageNumberFieldSchema | StorageBooleanFieldSchema | StorageArrayFieldSchema | StorageObjectFieldSchema | StorageAnyFieldSchema | StorageMapFieldSchema<any> | StorageFileFieldSchema;
|
|
51
|
+
export declare type NestedStorageStringFieldSchema = {
|
|
52
|
+
type: 'string';
|
|
53
|
+
nullable?: boolean;
|
|
54
|
+
default?: string | (() => string);
|
|
55
|
+
};
|
|
56
|
+
export declare type NestedStorageNumberFieldSchema = {
|
|
57
|
+
type: 'number';
|
|
58
|
+
nullable?: boolean;
|
|
59
|
+
default?: number | (() => number);
|
|
60
|
+
};
|
|
61
|
+
export declare type NestedStorageBooleanFieldSchema = {
|
|
62
|
+
type: 'boolean';
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
default: boolean | (() => boolean);
|
|
65
|
+
};
|
|
66
|
+
export declare type NestedStorageFieldSchema = NestedStorageStringFieldSchema | NestedStorageNumberFieldSchema | NestedStorageBooleanFieldSchema | StorageArrayFieldSchema | StorageObjectFieldSchema | StorageAnyFieldSchema | StorageMapFieldSchema<any> | StorageFileFieldSchema;
|
|
67
|
+
export declare type StorageFieldsSchema = {
|
|
68
|
+
[key: string]: StorageFieldSchema;
|
|
69
|
+
};
|
|
70
|
+
export declare type NestedStorageFieldsSchema = Record<string, NestedStorageFieldSchema>;
|
|
71
|
+
export declare type StorageIndexableFields<Fields extends StorageFieldsSchema> = {
|
|
72
|
+
[K in keyof Fields]: Fields[K] extends {
|
|
73
|
+
indexed: boolean;
|
|
74
|
+
} ? K : never;
|
|
75
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=fields.js.map
|