@verdant-web/common 1.15.3-next.0 → 1.15.4

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 (154) hide show
  1. package/dist/cjs/EventSubscriber.d.ts +17 -17
  2. package/dist/cjs/EventSubscriber.js +66 -66
  3. package/dist/cjs/baseline.d.ts +5 -5
  4. package/dist/cjs/baseline.js +2 -2
  5. package/dist/cjs/batching.d.ts +42 -42
  6. package/dist/cjs/batching.js +91 -91
  7. package/dist/cjs/files.d.ts +19 -19
  8. package/dist/cjs/files.js +18 -18
  9. package/dist/cjs/index.d.ts +19 -19
  10. package/dist/cjs/index.js +41 -41
  11. package/dist/cjs/indexes.d.ts +17 -17
  12. package/dist/cjs/indexes.js +142 -142
  13. package/dist/cjs/indexes.test.d.ts +1 -1
  14. package/dist/cjs/indexes.test.js +127 -127
  15. package/dist/cjs/migration.d.ts +172 -172
  16. package/dist/cjs/migration.js +301 -301
  17. package/dist/cjs/oids.d.ts +100 -100
  18. package/dist/cjs/oids.js +461 -457
  19. package/dist/cjs/oids.js.map +1 -1
  20. package/dist/cjs/oids.test.d.ts +1 -1
  21. package/dist/cjs/oids.test.js +348 -348
  22. package/dist/cjs/operation.d.ts +139 -139
  23. package/dist/cjs/operation.js +545 -545
  24. package/dist/cjs/operation.test.d.ts +1 -1
  25. package/dist/cjs/operation.test.js +529 -529
  26. package/dist/cjs/patch.d.ts +26 -26
  27. package/dist/cjs/patch.js +226 -226
  28. package/dist/cjs/presence.d.ts +27 -27
  29. package/dist/cjs/presence.js +2 -2
  30. package/dist/cjs/protocol.d.ts +145 -145
  31. package/dist/cjs/protocol.js +3 -3
  32. package/dist/cjs/refs.d.ts +7 -7
  33. package/dist/cjs/refs.js +29 -29
  34. package/dist/cjs/replica.d.ts +28 -28
  35. package/dist/cjs/replica.js +28 -28
  36. package/dist/cjs/schema/defaults.test.d.ts +1 -1
  37. package/dist/cjs/schema/defaults.test.js +20 -20
  38. package/dist/cjs/schema/fields.d.ts +9 -9
  39. package/dist/cjs/schema/fields.js +144 -144
  40. package/dist/cjs/schema/index.d.ts +8 -8
  41. package/dist/cjs/schema/index.js +51 -51
  42. package/dist/cjs/schema/indexFilters.d.ts +6 -6
  43. package/dist/cjs/schema/indexFilters.js +30 -30
  44. package/dist/cjs/schema/types/collection.d.ts +23 -23
  45. package/dist/cjs/schema/types/collection.js +2 -2
  46. package/dist/cjs/schema/types/compounds.d.ts +11 -11
  47. package/dist/cjs/schema/types/compounds.js +2 -2
  48. package/dist/cjs/schema/types/fields.d.ts +75 -75
  49. package/dist/cjs/schema/types/fields.js +2 -2
  50. package/dist/cjs/schema/types/filters.d.ts +29 -29
  51. package/dist/cjs/schema/types/filters.js +2 -2
  52. package/dist/cjs/schema/types/shapes.d.ts +21 -21
  53. package/dist/cjs/schema/types/shapes.js +2 -2
  54. package/dist/cjs/schema/types/synthetics.d.ts +37 -37
  55. package/dist/cjs/schema/types/synthetics.js +2 -2
  56. package/dist/cjs/schema/types.d.ts +18 -18
  57. package/dist/cjs/schema/types.js +22 -22
  58. package/dist/cjs/schema/validation.d.ts +3 -3
  59. package/dist/cjs/schema/validation.js +86 -86
  60. package/dist/cjs/timestamp.d.ts +50 -50
  61. package/dist/cjs/timestamp.js +251 -251
  62. package/dist/cjs/timestamp.test.d.ts +1 -1
  63. package/dist/cjs/timestamp.test.js +104 -104
  64. package/dist/cjs/undo.d.ts +3 -3
  65. package/dist/cjs/undo.js +198 -198
  66. package/dist/cjs/utils.d.ts +20 -20
  67. package/dist/cjs/utils.js +145 -145
  68. package/dist/cjs/utils.test.d.ts +1 -1
  69. package/dist/cjs/utils.test.js +36 -36
  70. package/dist/esm/EventSubscriber.d.ts +17 -17
  71. package/dist/esm/EventSubscriber.js +62 -62
  72. package/dist/esm/baseline.d.ts +5 -5
  73. package/dist/esm/baseline.js +1 -1
  74. package/dist/esm/batching.d.ts +42 -42
  75. package/dist/esm/batching.js +86 -86
  76. package/dist/esm/files.d.ts +19 -19
  77. package/dist/esm/files.js +12 -12
  78. package/dist/esm/index.d.ts +19 -19
  79. package/dist/esm/index.js +16 -16
  80. package/dist/esm/indexes.d.ts +17 -17
  81. package/dist/esm/indexes.js +130 -130
  82. package/dist/esm/indexes.test.d.ts +1 -1
  83. package/dist/esm/indexes.test.js +125 -125
  84. package/dist/esm/migration.d.ts +172 -172
  85. package/dist/esm/migration.js +294 -294
  86. package/dist/esm/oids.d.ts +100 -100
  87. package/dist/esm/oids.js +426 -422
  88. package/dist/esm/oids.js.map +1 -1
  89. package/dist/esm/oids.test.d.ts +1 -1
  90. package/dist/esm/oids.test.js +346 -346
  91. package/dist/esm/operation.d.ts +139 -139
  92. package/dist/esm/operation.js +530 -530
  93. package/dist/esm/operation.test.d.ts +1 -1
  94. package/dist/esm/operation.test.js +527 -527
  95. package/dist/esm/patch.d.ts +26 -26
  96. package/dist/esm/patch.js +222 -222
  97. package/dist/esm/presence.d.ts +27 -27
  98. package/dist/esm/presence.js +1 -1
  99. package/dist/esm/protocol.d.ts +145 -145
  100. package/dist/esm/protocol.js +2 -2
  101. package/dist/esm/refs.d.ts +7 -7
  102. package/dist/esm/refs.js +22 -22
  103. package/dist/esm/replica.d.ts +28 -28
  104. package/dist/esm/replica.js +25 -25
  105. package/dist/esm/schema/defaults.test.d.ts +1 -1
  106. package/dist/esm/schema/defaults.test.js +18 -18
  107. package/dist/esm/schema/fields.d.ts +9 -9
  108. package/dist/esm/schema/fields.js +133 -133
  109. package/dist/esm/schema/index.d.ts +8 -8
  110. package/dist/esm/schema/index.js +32 -32
  111. package/dist/esm/schema/indexFilters.d.ts +6 -6
  112. package/dist/esm/schema/indexFilters.js +22 -22
  113. package/dist/esm/schema/types/collection.d.ts +23 -23
  114. package/dist/esm/schema/types/collection.js +1 -1
  115. package/dist/esm/schema/types/compounds.d.ts +11 -11
  116. package/dist/esm/schema/types/compounds.js +1 -1
  117. package/dist/esm/schema/types/fields.d.ts +75 -75
  118. package/dist/esm/schema/types/fields.js +1 -1
  119. package/dist/esm/schema/types/filters.d.ts +29 -29
  120. package/dist/esm/schema/types/filters.js +1 -1
  121. package/dist/esm/schema/types/shapes.d.ts +21 -21
  122. package/dist/esm/schema/types/shapes.js +1 -1
  123. package/dist/esm/schema/types/synthetics.d.ts +37 -37
  124. package/dist/esm/schema/types/synthetics.js +1 -1
  125. package/dist/esm/schema/types.d.ts +18 -18
  126. package/dist/esm/schema/types.js +6 -6
  127. package/dist/esm/schema/validation.d.ts +3 -3
  128. package/dist/esm/schema/validation.js +81 -81
  129. package/dist/esm/timestamp.d.ts +50 -50
  130. package/dist/esm/timestamp.js +234 -234
  131. package/dist/esm/timestamp.test.d.ts +1 -1
  132. package/dist/esm/timestamp.test.js +102 -102
  133. package/dist/esm/undo.d.ts +3 -3
  134. package/dist/esm/undo.js +194 -194
  135. package/dist/esm/utils.d.ts +20 -20
  136. package/dist/esm/utils.js +127 -127
  137. package/dist/esm/utils.test.d.ts +1 -1
  138. package/dist/esm/utils.test.js +34 -34
  139. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  140. package/dist/tsconfig.tsbuildinfo +1 -1
  141. package/package.json +1 -1
  142. package/src/oids.ts +5 -1
  143. package/dist/cjs/files.test.d.ts +0 -1
  144. package/dist/cjs/files.test.js +0 -81
  145. package/dist/cjs/files.test.js.map +0 -1
  146. package/dist/cjs/schema/defaults.d.ts +0 -4
  147. package/dist/cjs/schema/defaults.js +0 -72
  148. package/dist/cjs/schema/defaults.js.map +0 -1
  149. package/dist/esm/files.test.d.ts +0 -1
  150. package/dist/esm/files.test.js +0 -79
  151. package/dist/esm/files.test.js.map +0 -1
  152. package/dist/esm/schema/defaults.d.ts +0 -4
  153. package/dist/esm/schema/defaults.js +0 -66
  154. package/dist/esm/schema/defaults.js.map +0 -1
@@ -1,145 +1,145 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.traverseCollectionFieldsAndRemoveExtraProperties = exports.removeExtraProperties = exports.getFieldDefault = exports.traverseCollectionFieldsAndApplyDefaults = exports.addFieldDefaults = exports.isIndexed = exports.hasDefault = exports.isNullable = void 0;
4
- const oids_js_1 = require("../oids.js");
5
- const utils_js_1 = require("../utils.js");
6
- function isNullable(field) {
7
- if (field.type === 'any')
8
- return true;
9
- if (field.type === 'map')
10
- return false;
11
- return field.nullable;
12
- }
13
- exports.isNullable = isNullable;
14
- function hasDefault(field) {
15
- if (!field)
16
- return false;
17
- if (field.type === 'map')
18
- return true;
19
- if (field.type === 'array')
20
- return true;
21
- if (field.type === 'file')
22
- return false;
23
- if (field.type === 'object')
24
- return true;
25
- return field.default !== undefined;
26
- }
27
- exports.hasDefault = hasDefault;
28
- function isIndexed(field) {
29
- if (field.type === 'map')
30
- return false;
31
- if (field.type === 'object')
32
- return false;
33
- if (field.type === 'array')
34
- return false;
35
- if (field.type === 'file')
36
- return false;
37
- if (field.type === 'any')
38
- return false;
39
- return field.indexed;
40
- }
41
- exports.isIndexed = isIndexed;
42
- function addFieldDefaults(collection, value) {
43
- for (const [key, field] of Object.entries(collection.fields)) {
44
- const defaultValue = getFieldDefault(field);
45
- if ((defaultValue !== undefined && value[key] === undefined) ||
46
- // covers the case where a previously nullable field
47
- // now has a default during a new migration
48
- (!isNullable(field) && value[key] === null)) {
49
- value[key] = defaultValue;
50
- }
51
- if (value[key]) {
52
- traverseCollectionFieldsAndApplyDefaults(value[key], field);
53
- }
54
- }
55
- return value;
56
- }
57
- exports.addFieldDefaults = addFieldDefaults;
58
- function traverseCollectionFieldsAndApplyDefaults(value, field) {
59
- if (value === undefined || value === null)
60
- return value;
61
- if (field.type === 'object') {
62
- for (const [key, subField] of Object.entries(field.properties)) {
63
- if (value[key] === undefined) {
64
- const defaultValue = getFieldDefault(subField);
65
- if (defaultValue !== undefined) {
66
- value[key] = defaultValue;
67
- }
68
- }
69
- traverseCollectionFieldsAndApplyDefaults(value[key], subField);
70
- }
71
- }
72
- else if (field.type === 'array') {
73
- for (const item of value) {
74
- traverseCollectionFieldsAndApplyDefaults(item, field.items);
75
- }
76
- }
77
- else if (field.type === 'map') {
78
- for (const [key, item] of Object.entries(value)) {
79
- // santiy check to weed out any id field
80
- if (key === oids_js_1.OID_KEY || key === oids_js_1.LEGACY_OID_KEY)
81
- continue;
82
- traverseCollectionFieldsAndApplyDefaults(item, field.values);
83
- }
84
- }
85
- }
86
- exports.traverseCollectionFieldsAndApplyDefaults = traverseCollectionFieldsAndApplyDefaults;
87
- function getFieldDefault(field) {
88
- if (field.type === 'string' ||
89
- field.type === 'number' ||
90
- field.type === 'boolean' ||
91
- field.type === 'any') {
92
- if (field.default && typeof field.default === 'function') {
93
- return field.default();
94
- }
95
- else if (field.default !== undefined) {
96
- // TODO: structuredClone?
97
- return JSON.parse(JSON.stringify(field.default));
98
- }
99
- }
100
- if (field.type === 'array') {
101
- return [];
102
- }
103
- if (field.type === 'map') {
104
- return {};
105
- }
106
- if (field.type !== 'any' && field.nullable) {
107
- return null;
108
- }
109
- return undefined;
110
- }
111
- exports.getFieldDefault = getFieldDefault;
112
- function removeExtraProperties(collection, value) {
113
- for (const [key, fieldValue] of Object.entries(value)) {
114
- // MUST NOT DELETE THESE!
115
- if (key === oids_js_1.OID_KEY || key === oids_js_1.LEGACY_OID_KEY)
116
- continue;
117
- if (!collection.fields[key]) {
118
- delete value[key];
119
- }
120
- else {
121
- traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, collection.fields[key]);
122
- }
123
- }
124
- return value;
125
- }
126
- exports.removeExtraProperties = removeExtraProperties;
127
- function traverseCollectionFieldsAndRemoveExtraProperties(value, field) {
128
- if ((0, utils_js_1.isObject)(value) && field.type === 'object') {
129
- for (const [key, fieldValue] of Object.entries(value)) {
130
- if (!field.properties[key]) {
131
- delete value[key];
132
- }
133
- else {
134
- traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, field.properties[key]);
135
- }
136
- }
137
- }
138
- else if (Array.isArray(value) && field.type === 'array') {
139
- for (const item of value) {
140
- traverseCollectionFieldsAndRemoveExtraProperties(item, field.items);
141
- }
142
- }
143
- }
144
- exports.traverseCollectionFieldsAndRemoveExtraProperties = traverseCollectionFieldsAndRemoveExtraProperties;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.traverseCollectionFieldsAndRemoveExtraProperties = exports.removeExtraProperties = exports.getFieldDefault = exports.traverseCollectionFieldsAndApplyDefaults = exports.addFieldDefaults = exports.isIndexed = exports.hasDefault = exports.isNullable = void 0;
4
+ const oids_js_1 = require("../oids.js");
5
+ const utils_js_1 = require("../utils.js");
6
+ function isNullable(field) {
7
+ if (field.type === 'any')
8
+ return true;
9
+ if (field.type === 'map')
10
+ return false;
11
+ return field.nullable;
12
+ }
13
+ exports.isNullable = isNullable;
14
+ function hasDefault(field) {
15
+ if (!field)
16
+ return false;
17
+ if (field.type === 'map')
18
+ return true;
19
+ if (field.type === 'array')
20
+ return true;
21
+ if (field.type === 'file')
22
+ return false;
23
+ if (field.type === 'object')
24
+ return true;
25
+ return field.default !== undefined;
26
+ }
27
+ exports.hasDefault = hasDefault;
28
+ function isIndexed(field) {
29
+ if (field.type === 'map')
30
+ return false;
31
+ if (field.type === 'object')
32
+ return false;
33
+ if (field.type === 'array')
34
+ return false;
35
+ if (field.type === 'file')
36
+ return false;
37
+ if (field.type === 'any')
38
+ return false;
39
+ return field.indexed;
40
+ }
41
+ exports.isIndexed = isIndexed;
42
+ function addFieldDefaults(collection, value) {
43
+ for (const [key, field] of Object.entries(collection.fields)) {
44
+ const defaultValue = getFieldDefault(field);
45
+ if ((defaultValue !== undefined && value[key] === undefined) ||
46
+ // covers the case where a previously nullable field
47
+ // now has a default during a new migration
48
+ (!isNullable(field) && value[key] === null)) {
49
+ value[key] = defaultValue;
50
+ }
51
+ if (value[key]) {
52
+ traverseCollectionFieldsAndApplyDefaults(value[key], field);
53
+ }
54
+ }
55
+ return value;
56
+ }
57
+ exports.addFieldDefaults = addFieldDefaults;
58
+ function traverseCollectionFieldsAndApplyDefaults(value, field) {
59
+ if (value === undefined || value === null)
60
+ return value;
61
+ if (field.type === 'object') {
62
+ for (const [key, subField] of Object.entries(field.properties)) {
63
+ if (value[key] === undefined) {
64
+ const defaultValue = getFieldDefault(subField);
65
+ if (defaultValue !== undefined) {
66
+ value[key] = defaultValue;
67
+ }
68
+ }
69
+ traverseCollectionFieldsAndApplyDefaults(value[key], subField);
70
+ }
71
+ }
72
+ else if (field.type === 'array') {
73
+ for (const item of value) {
74
+ traverseCollectionFieldsAndApplyDefaults(item, field.items);
75
+ }
76
+ }
77
+ else if (field.type === 'map') {
78
+ for (const [key, item] of Object.entries(value)) {
79
+ // santiy check to weed out any id field
80
+ if (key === oids_js_1.OID_KEY || key === oids_js_1.LEGACY_OID_KEY)
81
+ continue;
82
+ traverseCollectionFieldsAndApplyDefaults(item, field.values);
83
+ }
84
+ }
85
+ }
86
+ exports.traverseCollectionFieldsAndApplyDefaults = traverseCollectionFieldsAndApplyDefaults;
87
+ function getFieldDefault(field) {
88
+ if (field.type === 'string' ||
89
+ field.type === 'number' ||
90
+ field.type === 'boolean' ||
91
+ field.type === 'any') {
92
+ if (field.default && typeof field.default === 'function') {
93
+ return field.default();
94
+ }
95
+ else if (field.default !== undefined) {
96
+ // TODO: structuredClone?
97
+ return JSON.parse(JSON.stringify(field.default));
98
+ }
99
+ }
100
+ if (field.type === 'array') {
101
+ return [];
102
+ }
103
+ if (field.type === 'map') {
104
+ return {};
105
+ }
106
+ if (field.type !== 'any' && field.nullable) {
107
+ return null;
108
+ }
109
+ return undefined;
110
+ }
111
+ exports.getFieldDefault = getFieldDefault;
112
+ function removeExtraProperties(collection, value) {
113
+ for (const [key, fieldValue] of Object.entries(value)) {
114
+ // MUST NOT DELETE THESE!
115
+ if (key === oids_js_1.OID_KEY || key === oids_js_1.LEGACY_OID_KEY)
116
+ continue;
117
+ if (!collection.fields[key]) {
118
+ delete value[key];
119
+ }
120
+ else {
121
+ traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, collection.fields[key]);
122
+ }
123
+ }
124
+ return value;
125
+ }
126
+ exports.removeExtraProperties = removeExtraProperties;
127
+ function traverseCollectionFieldsAndRemoveExtraProperties(value, field) {
128
+ if ((0, utils_js_1.isObject)(value) && field.type === 'object') {
129
+ for (const [key, fieldValue] of Object.entries(value)) {
130
+ if (!field.properties[key]) {
131
+ delete value[key];
132
+ }
133
+ else {
134
+ traverseCollectionFieldsAndRemoveExtraProperties(fieldValue, field.properties[key]);
135
+ }
136
+ }
137
+ }
138
+ else if (Array.isArray(value) && field.type === 'array') {
139
+ for (const item of value) {
140
+ traverseCollectionFieldsAndRemoveExtraProperties(item, field.items);
141
+ }
142
+ }
143
+ }
144
+ exports.traverseCollectionFieldsAndRemoveExtraProperties = traverseCollectionFieldsAndRemoveExtraProperties;
145
145
  //# 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';
@@ -1,52 +1,52 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __rest = (this && this.__rest) || function (s, e) {
17
- var t = {};
18
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
- t[p] = s[p];
20
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
- t[p[i]] = s[p[i]];
24
- }
25
- return t;
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.schema = exports.collection = void 0;
29
- const fields_js_1 = require("./fields.js");
30
- function collection(_a) {
31
- var { synthetics, indexes } = _a, input = __rest(_a, ["synthetics", "indexes"]);
32
- // back compat - copy synthetics in with indexes
33
- const finalIndexes = Object.assign(Object.assign({}, synthetics), indexes);
34
- // add all indexed fields into the synthetic indices (back compat)
35
- for (const [key, field] of Object.entries(input.fields)) {
36
- if ((0, fields_js_1.isIndexed)(field)) {
37
- finalIndexes[key] = {
38
- field: key,
39
- };
40
- }
41
- }
42
- return Object.assign(Object.assign({}, input), { indexes: finalIndexes });
43
- }
44
- exports.collection = collection;
45
- function schema(input) {
46
- return input;
47
- }
48
- exports.schema = schema;
49
- __exportStar(require("./types.js"), exports);
50
- __exportStar(require("./indexFilters.js"), exports);
51
- __exportStar(require("./fields.js"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __rest = (this && this.__rest) || function (s, e) {
17
+ var t = {};
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
+ t[p] = s[p];
20
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
+ t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.schema = exports.collection = void 0;
29
+ const fields_js_1 = require("./fields.js");
30
+ function collection(_a) {
31
+ var { synthetics, indexes } = _a, input = __rest(_a, ["synthetics", "indexes"]);
32
+ // back compat - copy synthetics in with indexes
33
+ const finalIndexes = Object.assign(Object.assign({}, synthetics), indexes);
34
+ // add all indexed fields into the synthetic indices (back compat)
35
+ for (const [key, field] of Object.entries(input.fields)) {
36
+ if ((0, fields_js_1.isIndexed)(field)) {
37
+ finalIndexes[key] = {
38
+ field: key,
39
+ };
40
+ }
41
+ }
42
+ return Object.assign(Object.assign({}, input), { indexes: finalIndexes });
43
+ }
44
+ exports.collection = collection;
45
+ function schema(input) {
46
+ return input;
47
+ }
48
+ exports.schema = schema;
49
+ __exportStar(require("./types.js"), exports);
50
+ __exportStar(require("./indexFilters.js"), exports);
51
+ __exportStar(require("./fields.js"), exports);
52
52
  //# 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,31 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSortIndexFilter = exports.isStartsWithIndexFilter = exports.isCompoundIndexFilter = exports.isRangeIndexFilter = exports.isMatchIndexFilter = void 0;
4
- function isMatchIndexFilter(filter) {
5
- return filter.equals !== undefined;
6
- }
7
- exports.isMatchIndexFilter = isMatchIndexFilter;
8
- function isRangeIndexFilter(filter) {
9
- return (filter.gte !== undefined ||
10
- filter.lte !== undefined ||
11
- filter.gt !== undefined ||
12
- filter.lt !== undefined);
13
- }
14
- exports.isRangeIndexFilter = isRangeIndexFilter;
15
- function isCompoundIndexFilter(filter) {
16
- return !!filter.match;
17
- }
18
- exports.isCompoundIndexFilter = isCompoundIndexFilter;
19
- function isStartsWithIndexFilter(filter) {
20
- return filter.startsWith !== undefined;
21
- }
22
- exports.isStartsWithIndexFilter = isStartsWithIndexFilter;
23
- function isSortIndexFilter(filter) {
24
- return (!isRangeIndexFilter(filter) &&
25
- !isMatchIndexFilter(filter) &&
26
- !isCompoundIndexFilter(filter) &&
27
- !isStartsWithIndexFilter(filter) &&
28
- filter.order);
29
- }
30
- exports.isSortIndexFilter = isSortIndexFilter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSortIndexFilter = exports.isStartsWithIndexFilter = exports.isCompoundIndexFilter = exports.isRangeIndexFilter = exports.isMatchIndexFilter = void 0;
4
+ function isMatchIndexFilter(filter) {
5
+ return filter.equals !== undefined;
6
+ }
7
+ exports.isMatchIndexFilter = isMatchIndexFilter;
8
+ function isRangeIndexFilter(filter) {
9
+ return (filter.gte !== undefined ||
10
+ filter.lte !== undefined ||
11
+ filter.gt !== undefined ||
12
+ filter.lt !== undefined);
13
+ }
14
+ exports.isRangeIndexFilter = isRangeIndexFilter;
15
+ function isCompoundIndexFilter(filter) {
16
+ return !!filter.match;
17
+ }
18
+ exports.isCompoundIndexFilter = isCompoundIndexFilter;
19
+ function isStartsWithIndexFilter(filter) {
20
+ return filter.startsWith !== undefined;
21
+ }
22
+ exports.isStartsWithIndexFilter = isStartsWithIndexFilter;
23
+ function isSortIndexFilter(filter) {
24
+ return (!isRangeIndexFilter(filter) &&
25
+ !isMatchIndexFilter(filter) &&
26
+ !isCompoundIndexFilter(filter) &&
27
+ !isStartsWithIndexFilter(filter) &&
28
+ filter.order);
29
+ }
30
+ exports.isSortIndexFilter = isSortIndexFilter;
31
31
  //# 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,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# 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,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=compounds.js.map