@verdant-web/common 1.15.2 → 1.15.3-next.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.
Files changed (163) 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/files.test.d.ts +1 -0
  10. package/dist/cjs/files.test.js +81 -0
  11. package/dist/cjs/files.test.js.map +1 -0
  12. package/dist/cjs/index.d.ts +19 -18
  13. package/dist/cjs/index.js +41 -36
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/indexes.d.ts +17 -17
  16. package/dist/cjs/indexes.js +142 -142
  17. package/dist/cjs/indexes.test.d.ts +1 -1
  18. package/dist/cjs/indexes.test.js +127 -127
  19. package/dist/cjs/migration.d.ts +172 -172
  20. package/dist/cjs/migration.js +301 -301
  21. package/dist/cjs/oids.d.ts +100 -96
  22. package/dist/cjs/oids.js +457 -439
  23. package/dist/cjs/oids.js.map +1 -1
  24. package/dist/cjs/oids.test.d.ts +1 -1
  25. package/dist/cjs/oids.test.js +348 -272
  26. package/dist/cjs/oids.test.js.map +1 -1
  27. package/dist/cjs/operation.d.ts +139 -139
  28. package/dist/cjs/operation.js +545 -545
  29. package/dist/cjs/operation.test.d.ts +1 -1
  30. package/dist/cjs/operation.test.js +529 -529
  31. package/dist/cjs/patch.d.ts +26 -26
  32. package/dist/cjs/patch.js +226 -226
  33. package/dist/cjs/presence.d.ts +27 -27
  34. package/dist/cjs/presence.js +2 -2
  35. package/dist/cjs/protocol.d.ts +145 -145
  36. package/dist/cjs/protocol.js +3 -3
  37. package/dist/cjs/refs.d.ts +7 -5
  38. package/dist/cjs/refs.js +29 -21
  39. package/dist/cjs/refs.js.map +1 -1
  40. package/dist/cjs/replica.d.ts +28 -28
  41. package/dist/cjs/replica.js +28 -28
  42. package/dist/cjs/schema/defaults.d.ts +4 -0
  43. package/dist/cjs/schema/defaults.js +72 -0
  44. package/dist/cjs/schema/defaults.js.map +1 -0
  45. package/dist/cjs/schema/defaults.test.d.ts +1 -1
  46. package/dist/cjs/schema/defaults.test.js +20 -20
  47. package/dist/cjs/schema/fields.d.ts +9 -9
  48. package/dist/cjs/schema/fields.js +144 -144
  49. package/dist/cjs/schema/index.d.ts +8 -8
  50. package/dist/cjs/schema/index.js +51 -51
  51. package/dist/cjs/schema/indexFilters.d.ts +6 -6
  52. package/dist/cjs/schema/indexFilters.js +30 -30
  53. package/dist/cjs/schema/types/collection.d.ts +23 -23
  54. package/dist/cjs/schema/types/collection.js +2 -2
  55. package/dist/cjs/schema/types/compounds.d.ts +11 -11
  56. package/dist/cjs/schema/types/compounds.js +2 -2
  57. package/dist/cjs/schema/types/fields.d.ts +75 -75
  58. package/dist/cjs/schema/types/fields.js +2 -2
  59. package/dist/cjs/schema/types/filters.d.ts +29 -29
  60. package/dist/cjs/schema/types/filters.js +2 -2
  61. package/dist/cjs/schema/types/shapes.d.ts +21 -21
  62. package/dist/cjs/schema/types/shapes.js +2 -2
  63. package/dist/cjs/schema/types/synthetics.d.ts +37 -37
  64. package/dist/cjs/schema/types/synthetics.js +2 -2
  65. package/dist/cjs/schema/types.d.ts +18 -18
  66. package/dist/cjs/schema/types.js +22 -22
  67. package/dist/cjs/schema/validation.d.ts +3 -3
  68. package/dist/cjs/schema/validation.js +86 -86
  69. package/dist/cjs/timestamp.d.ts +50 -50
  70. package/dist/cjs/timestamp.js +251 -251
  71. package/dist/cjs/timestamp.test.d.ts +1 -1
  72. package/dist/cjs/timestamp.test.js +104 -104
  73. package/dist/cjs/undo.d.ts +3 -3
  74. package/dist/cjs/undo.js +198 -198
  75. package/dist/cjs/utils.d.ts +20 -20
  76. package/dist/cjs/utils.js +145 -145
  77. package/dist/cjs/utils.test.d.ts +1 -1
  78. package/dist/cjs/utils.test.js +36 -36
  79. package/dist/esm/EventSubscriber.d.ts +17 -17
  80. package/dist/esm/EventSubscriber.js +62 -62
  81. package/dist/esm/baseline.d.ts +5 -5
  82. package/dist/esm/baseline.js +1 -1
  83. package/dist/esm/batching.d.ts +42 -42
  84. package/dist/esm/batching.js +86 -86
  85. package/dist/esm/files.d.ts +19 -19
  86. package/dist/esm/files.js +12 -12
  87. package/dist/esm/files.test.d.ts +1 -0
  88. package/dist/esm/files.test.js +79 -0
  89. package/dist/esm/files.test.js.map +1 -0
  90. package/dist/esm/index.d.ts +19 -18
  91. package/dist/esm/index.js +16 -15
  92. package/dist/esm/index.js.map +1 -1
  93. package/dist/esm/indexes.d.ts +17 -17
  94. package/dist/esm/indexes.js +130 -130
  95. package/dist/esm/indexes.test.d.ts +1 -1
  96. package/dist/esm/indexes.test.js +125 -125
  97. package/dist/esm/migration.d.ts +172 -172
  98. package/dist/esm/migration.js +294 -294
  99. package/dist/esm/oids.d.ts +100 -96
  100. package/dist/esm/oids.js +422 -407
  101. package/dist/esm/oids.js.map +1 -1
  102. package/dist/esm/oids.test.d.ts +1 -1
  103. package/dist/esm/oids.test.js +346 -270
  104. package/dist/esm/oids.test.js.map +1 -1
  105. package/dist/esm/operation.d.ts +139 -139
  106. package/dist/esm/operation.js +530 -530
  107. package/dist/esm/operation.test.d.ts +1 -1
  108. package/dist/esm/operation.test.js +527 -527
  109. package/dist/esm/patch.d.ts +26 -26
  110. package/dist/esm/patch.js +222 -222
  111. package/dist/esm/presence.d.ts +27 -27
  112. package/dist/esm/presence.js +1 -1
  113. package/dist/esm/protocol.d.ts +145 -145
  114. package/dist/esm/protocol.js +2 -2
  115. package/dist/esm/refs.d.ts +7 -5
  116. package/dist/esm/refs.js +22 -16
  117. package/dist/esm/refs.js.map +1 -1
  118. package/dist/esm/replica.d.ts +28 -28
  119. package/dist/esm/replica.js +25 -25
  120. package/dist/esm/schema/defaults.d.ts +4 -0
  121. package/dist/esm/schema/defaults.js +66 -0
  122. package/dist/esm/schema/defaults.js.map +1 -0
  123. package/dist/esm/schema/defaults.test.d.ts +1 -1
  124. package/dist/esm/schema/defaults.test.js +18 -18
  125. package/dist/esm/schema/fields.d.ts +9 -9
  126. package/dist/esm/schema/fields.js +133 -133
  127. package/dist/esm/schema/index.d.ts +8 -8
  128. package/dist/esm/schema/index.js +32 -32
  129. package/dist/esm/schema/indexFilters.d.ts +6 -6
  130. package/dist/esm/schema/indexFilters.js +22 -22
  131. package/dist/esm/schema/types/collection.d.ts +23 -23
  132. package/dist/esm/schema/types/collection.js +1 -1
  133. package/dist/esm/schema/types/compounds.d.ts +11 -11
  134. package/dist/esm/schema/types/compounds.js +1 -1
  135. package/dist/esm/schema/types/fields.d.ts +75 -75
  136. package/dist/esm/schema/types/fields.js +1 -1
  137. package/dist/esm/schema/types/filters.d.ts +29 -29
  138. package/dist/esm/schema/types/filters.js +1 -1
  139. package/dist/esm/schema/types/shapes.d.ts +21 -21
  140. package/dist/esm/schema/types/shapes.js +1 -1
  141. package/dist/esm/schema/types/synthetics.d.ts +37 -37
  142. package/dist/esm/schema/types/synthetics.js +1 -1
  143. package/dist/esm/schema/types.d.ts +18 -18
  144. package/dist/esm/schema/types.js +6 -6
  145. package/dist/esm/schema/validation.d.ts +3 -3
  146. package/dist/esm/schema/validation.js +81 -81
  147. package/dist/esm/timestamp.d.ts +50 -50
  148. package/dist/esm/timestamp.js +234 -234
  149. package/dist/esm/timestamp.test.d.ts +1 -1
  150. package/dist/esm/timestamp.test.js +102 -102
  151. package/dist/esm/undo.d.ts +3 -3
  152. package/dist/esm/undo.js +194 -194
  153. package/dist/esm/utils.d.ts +20 -20
  154. package/dist/esm/utils.js +127 -127
  155. package/dist/esm/utils.test.d.ts +1 -1
  156. package/dist/esm/utils.test.js +34 -34
  157. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  158. package/dist/tsconfig.tsbuildinfo +1 -1
  159. package/package.json +1 -1
  160. package/src/index.ts +1 -0
  161. package/src/oids.test.ts +82 -0
  162. package/src/oids.ts +17 -0
  163. package/src/refs.ts +8 -0
@@ -1,29 +1,29 @@
1
- export declare type MatchCollectionIndexFilter = {
2
- where: string;
3
- equals: any;
4
- order?: 'asc' | 'desc';
5
- };
6
- export declare type RangeCollectionIndexFilter = {
7
- where: string;
8
- gte?: any;
9
- lte?: any;
10
- gt?: any;
11
- lt?: any;
12
- order?: 'asc' | 'desc';
13
- };
14
- export declare type CollectionCompoundIndexFilter = {
15
- where: string;
16
- match: Record<string, any>;
17
- order: 'asc' | 'desc';
18
- };
19
- export declare type SortIndexFilter = {
20
- where: string;
21
- order: 'asc' | 'desc';
22
- };
23
- export declare type StartsWithIndexFilter = {
24
- where: string;
25
- startsWith: string;
26
- order?: 'asc' | 'desc';
27
- };
28
- export declare type CollectionIndexFilter = MatchCollectionIndexFilter | RangeCollectionIndexFilter | CollectionCompoundIndexFilter | StartsWithIndexFilter | SortIndexFilter;
29
- export declare type CollectionFilter = CollectionIndexFilter;
1
+ export declare type MatchCollectionIndexFilter = {
2
+ where: string;
3
+ equals: any;
4
+ order?: 'asc' | 'desc';
5
+ };
6
+ export declare type RangeCollectionIndexFilter = {
7
+ where: string;
8
+ gte?: any;
9
+ lte?: any;
10
+ gt?: any;
11
+ lt?: any;
12
+ order?: 'asc' | 'desc';
13
+ };
14
+ export declare type CollectionCompoundIndexFilter = {
15
+ where: string;
16
+ match: Record<string, any>;
17
+ order: 'asc' | 'desc';
18
+ };
19
+ export declare type SortIndexFilter = {
20
+ where: string;
21
+ order: 'asc' | 'desc';
22
+ };
23
+ export declare type StartsWithIndexFilter = {
24
+ where: string;
25
+ startsWith: string;
26
+ order?: 'asc' | 'desc';
27
+ };
28
+ export declare type CollectionIndexFilter = MatchCollectionIndexFilter | RangeCollectionIndexFilter | CollectionCompoundIndexFilter | StartsWithIndexFilter | SortIndexFilter;
29
+ export declare type CollectionFilter = CollectionIndexFilter;
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=filters.js.map
@@ -1,21 +1,21 @@
1
- import { StorageCollectionSchema } from './collection.js';
2
- import { NestedStorageFieldsSchema, StorageArrayFieldSchema, StorageFieldSchema, StorageFieldsSchema, StorageMapFieldSchema, StorageObjectFieldSchema } from './fields.js';
3
- declare type StoragePropertyIsNullable<T extends StorageFieldSchema> = T extends {
4
- nullable?: boolean;
5
- } ? T['nullable'] extends boolean ? true : false : T['type'] extends 'any' ? true : false;
6
- export declare type BaseShapeFromProperty<T extends StorageFieldSchema> = T['type'] extends 'string' ? string : T['type'] extends 'number' ? number : T['type'] extends 'boolean' ? boolean : T extends StorageArrayFieldSchema ? ShapeFromProperty<T['items']>[] : T extends StorageObjectFieldSchema ? ShapeFromFields<T['properties']> : T extends StorageMapFieldSchema<any> ? Record<string, ShapeFromProperty<T['values']>> : T['type'] extends 'any' ? any : T['type'] extends 'file' ? File : never;
7
- export declare type ShapeFromProperty<T extends StorageFieldSchema> = StoragePropertyIsNullable<T> extends true ? BaseShapeFromProperty<T> | null : BaseShapeFromProperty<T>;
8
- export declare type ShapeFromFields<T extends StorageFieldsSchema | NestedStorageFieldsSchema> = {
9
- [K in keyof T]: ShapeFromProperty<T[K]>;
10
- };
11
- export declare type StorageDocument<Collection extends StorageCollectionSchema<any, any, any>> = ShapeFromFields<Collection['fields']>;
12
- declare type StoragePropertyIsOptional<T extends StorageFieldSchema> = StoragePropertyIsNullable<T> extends true ? true : T extends {
13
- default?: any;
14
- } ? true : T['type'] extends 'any' ? true : T['type'] extends 'array' ? true : T['type'] extends 'map' ? true : false;
15
- declare type ShapeFromFieldsWithDefaults<T extends StorageFieldsSchema | NestedStorageFieldsSchema> = {
16
- [K in keyof T as StoragePropertyIsOptional<T[K]> extends true ? K : never]?: ShapeFromProperty<T[K]>;
17
- } & {
18
- [K in keyof T as StoragePropertyIsOptional<T[K]> extends true ? never : K]: ShapeFromProperty<T[K]>;
19
- };
20
- export declare type StorageDocumentInit<Collection extends StorageCollectionSchema<any, any, any>> = ShapeFromFieldsWithDefaults<Collection['fields']>;
21
- export {};
1
+ import { StorageCollectionSchema } from './collection.js';
2
+ import { NestedStorageFieldsSchema, StorageArrayFieldSchema, StorageFieldSchema, StorageFieldsSchema, StorageMapFieldSchema, StorageObjectFieldSchema } from './fields.js';
3
+ declare type StoragePropertyIsNullable<T extends StorageFieldSchema> = T extends {
4
+ nullable?: boolean;
5
+ } ? T['nullable'] extends boolean ? true : false : T['type'] extends 'any' ? true : false;
6
+ export declare type BaseShapeFromProperty<T extends StorageFieldSchema> = T['type'] extends 'string' ? string : T['type'] extends 'number' ? number : T['type'] extends 'boolean' ? boolean : T extends StorageArrayFieldSchema ? ShapeFromProperty<T['items']>[] : T extends StorageObjectFieldSchema ? ShapeFromFields<T['properties']> : T extends StorageMapFieldSchema<any> ? Record<string, ShapeFromProperty<T['values']>> : T['type'] extends 'any' ? any : T['type'] extends 'file' ? File : never;
7
+ export declare type ShapeFromProperty<T extends StorageFieldSchema> = StoragePropertyIsNullable<T> extends true ? BaseShapeFromProperty<T> | null : BaseShapeFromProperty<T>;
8
+ export declare type ShapeFromFields<T extends StorageFieldsSchema | NestedStorageFieldsSchema> = {
9
+ [K in keyof T]: ShapeFromProperty<T[K]>;
10
+ };
11
+ export declare type StorageDocument<Collection extends StorageCollectionSchema<any, any, any>> = ShapeFromFields<Collection['fields']>;
12
+ declare type StoragePropertyIsOptional<T extends StorageFieldSchema> = StoragePropertyIsNullable<T> extends true ? true : T extends {
13
+ default?: any;
14
+ } ? true : T['type'] extends 'any' ? true : T['type'] extends 'array' ? true : T['type'] extends 'map' ? true : false;
15
+ declare type ShapeFromFieldsWithDefaults<T extends StorageFieldsSchema | NestedStorageFieldsSchema> = {
16
+ [K in keyof T as StoragePropertyIsOptional<T[K]> extends true ? K : never]?: ShapeFromProperty<T[K]>;
17
+ } & {
18
+ [K in keyof T as StoragePropertyIsOptional<T[K]> extends true ? never : K]: ShapeFromProperty<T[K]>;
19
+ };
20
+ export declare type StorageDocumentInit<Collection extends StorageCollectionSchema<any, any, any>> = ShapeFromFieldsWithDefaults<Collection['fields']>;
21
+ export {};
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=shapes.js.map
@@ -1,37 +1,37 @@
1
- import { StorageBooleanFieldSchema, StorageFieldsSchema, StorageNumberFieldSchema, StorageStringFieldSchema } from './fields.js';
2
- import { ShapeFromFields } from './shapes.js';
3
- export declare type StorageStringSyntheticSchema<Fields extends StorageFieldsSchema> = {
4
- type: 'string';
5
- compute: (value: ShapeFromFields<Fields>) => string | null;
6
- };
7
- export declare type StorageNumberSyntheticSchema<Fields extends StorageFieldsSchema> = {
8
- type: 'number';
9
- compute: (value: ShapeFromFields<Fields>) => number | null;
10
- };
11
- export declare type StorageBooleanSyntheticSchema<Fields extends StorageFieldsSchema> = {
12
- type: 'boolean';
13
- compute: (value: ShapeFromFields<Fields>) => boolean | null;
14
- };
15
- export declare type StorageStringArraySyntheticSchema<Fields extends StorageFieldsSchema> = {
16
- type: 'string[]';
17
- compute: (value: ShapeFromFields<Fields>) => string[];
18
- };
19
- export declare type StorageNumberArraySyntheticSchema<Fields extends StorageFieldsSchema> = {
20
- type: 'number[]';
21
- compute: (value: ShapeFromFields<Fields>) => number[];
22
- };
23
- export declare type StorageBooleanArraySyntheticSchema<Fields extends StorageFieldsSchema> = {
24
- type: 'boolean[]';
25
- compute: (value: ShapeFromFields<Fields>) => boolean[];
26
- };
27
- export declare type StorageDirectSyntheticSchema<Fields extends StorageFieldsSchema> = {
28
- field: DirectIndexableFieldName<Fields>;
29
- };
30
- declare type DirectIndexableFields<Fields extends StorageFieldsSchema> = {
31
- [K in keyof Fields as Fields[K] extends StorageStringFieldSchema ? K : Fields[K] extends StorageNumberFieldSchema ? K : Fields[K] extends StorageBooleanFieldSchema ? K : never]: any;
32
- };
33
- export declare type DirectIndexableFieldName<Fields extends StorageFieldsSchema> = keyof DirectIndexableFields<Fields> extends never ? string : keyof DirectIndexableFields<Fields>;
34
- export declare type StorageSyntheticIndices<Fields extends StorageFieldsSchema> = Record<string, StorageSyntheticIndexSchema<Fields>>;
35
- export declare type StorageSyntheticIndexSchema<Fields extends StorageFieldsSchema> = StorageStringSyntheticSchema<Fields> | StorageNumberSyntheticSchema<Fields> | StorageBooleanSyntheticSchema<Fields> | StorageStringArraySyntheticSchema<Fields> | StorageNumberArraySyntheticSchema<Fields> | StorageBooleanArraySyntheticSchema<Fields> | StorageDirectSyntheticSchema<Fields>;
36
- export declare type IndexValueTag = Exclude<StorageSyntheticIndexSchema<any>, StorageDirectSyntheticSchema<any>>['type'];
37
- export {};
1
+ import { StorageBooleanFieldSchema, StorageFieldsSchema, StorageNumberFieldSchema, StorageStringFieldSchema } from './fields.js';
2
+ import { ShapeFromFields } from './shapes.js';
3
+ export declare type StorageStringSyntheticSchema<Fields extends StorageFieldsSchema> = {
4
+ type: 'string';
5
+ compute: (value: ShapeFromFields<Fields>) => string | null;
6
+ };
7
+ export declare type StorageNumberSyntheticSchema<Fields extends StorageFieldsSchema> = {
8
+ type: 'number';
9
+ compute: (value: ShapeFromFields<Fields>) => number | null;
10
+ };
11
+ export declare type StorageBooleanSyntheticSchema<Fields extends StorageFieldsSchema> = {
12
+ type: 'boolean';
13
+ compute: (value: ShapeFromFields<Fields>) => boolean | null;
14
+ };
15
+ export declare type StorageStringArraySyntheticSchema<Fields extends StorageFieldsSchema> = {
16
+ type: 'string[]';
17
+ compute: (value: ShapeFromFields<Fields>) => string[];
18
+ };
19
+ export declare type StorageNumberArraySyntheticSchema<Fields extends StorageFieldsSchema> = {
20
+ type: 'number[]';
21
+ compute: (value: ShapeFromFields<Fields>) => number[];
22
+ };
23
+ export declare type StorageBooleanArraySyntheticSchema<Fields extends StorageFieldsSchema> = {
24
+ type: 'boolean[]';
25
+ compute: (value: ShapeFromFields<Fields>) => boolean[];
26
+ };
27
+ export declare type StorageDirectSyntheticSchema<Fields extends StorageFieldsSchema> = {
28
+ field: DirectIndexableFieldName<Fields>;
29
+ };
30
+ declare type DirectIndexableFields<Fields extends StorageFieldsSchema> = {
31
+ [K in keyof Fields as Fields[K] extends StorageStringFieldSchema ? K : Fields[K] extends StorageNumberFieldSchema ? K : Fields[K] extends StorageBooleanFieldSchema ? K : never]: any;
32
+ };
33
+ export declare type DirectIndexableFieldName<Fields extends StorageFieldsSchema> = keyof DirectIndexableFields<Fields> extends never ? string : keyof DirectIndexableFields<Fields>;
34
+ export declare type StorageSyntheticIndices<Fields extends StorageFieldsSchema> = Record<string, StorageSyntheticIndexSchema<Fields>>;
35
+ export declare type StorageSyntheticIndexSchema<Fields extends StorageFieldsSchema> = StorageStringSyntheticSchema<Fields> | StorageNumberSyntheticSchema<Fields> | StorageBooleanSyntheticSchema<Fields> | StorageStringArraySyntheticSchema<Fields> | StorageNumberArraySyntheticSchema<Fields> | StorageBooleanArraySyntheticSchema<Fields> | StorageDirectSyntheticSchema<Fields>;
36
+ export declare type IndexValueTag = Exclude<StorageSyntheticIndexSchema<any>, StorageDirectSyntheticSchema<any>>['type'];
37
+ export {};
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=synthetics.js.map
@@ -1,18 +1,18 @@
1
- import { StorageCollectionSchema } from './types/collection.js';
2
- export * from './types/collection.js';
3
- export * from './types/compounds.js';
4
- export * from './types/fields.js';
5
- export * from './types/filters.js';
6
- export * from './types/shapes.js';
7
- export * from './types/synthetics.js';
8
- export declare type StorageSchema<Collections extends {
9
- [k: string]: StorageCollectionSchema;
10
- } = {
11
- [k: string]: StorageCollectionSchema;
12
- }> = {
13
- version: number;
14
- wip?: true;
15
- collections: Collections;
16
- };
17
- export declare type SchemaCollectionName<Schema extends StorageSchema<any>> = Schema extends StorageSchema<infer Cs> ? Exclude<keyof Cs, number | symbol> : never;
18
- export declare type SchemaCollection<Schema extends StorageSchema<any>, Name extends SchemaCollectionName<Schema>> = Schema extends StorageSchema<infer Cs> ? Cs[Name] : never;
1
+ import { StorageCollectionSchema } from './types/collection.js';
2
+ export * from './types/collection.js';
3
+ export * from './types/compounds.js';
4
+ export * from './types/fields.js';
5
+ export * from './types/filters.js';
6
+ export * from './types/shapes.js';
7
+ export * from './types/synthetics.js';
8
+ export declare type StorageSchema<Collections extends {
9
+ [k: string]: StorageCollectionSchema;
10
+ } = {
11
+ [k: string]: StorageCollectionSchema;
12
+ }> = {
13
+ version: number;
14
+ wip?: true;
15
+ collections: Collections;
16
+ };
17
+ export declare type SchemaCollectionName<Schema extends StorageSchema<any>> = Schema extends StorageSchema<infer Cs> ? Exclude<keyof Cs, number | symbol> : never;
18
+ export declare type SchemaCollection<Schema extends StorageSchema<any>, Name extends SchemaCollectionName<Schema>> = Schema extends StorageSchema<infer Cs> ? Cs[Name] : never;
@@ -1,7 +1,7 @@
1
- export * from './types/collection.js';
2
- export * from './types/compounds.js';
3
- export * from './types/fields.js';
4
- export * from './types/filters.js';
5
- export * from './types/shapes.js';
6
- export * from './types/synthetics.js';
1
+ export * from './types/collection.js';
2
+ export * from './types/compounds.js';
3
+ export * from './types/fields.js';
4
+ export * from './types/filters.js';
5
+ export * from './types/shapes.js';
6
+ export * from './types/synthetics.js';
7
7
  //# sourceMappingURL=types.js.map
@@ -1,3 +1,3 @@
1
- import { StorageCollectionSchema, StorageFieldSchema } from './types.js';
2
- export declare function validateEntity(schema: StorageCollectionSchema, entity: any): void;
3
- export declare function validateEntityField(field: StorageFieldSchema, value: any, fieldPath?: string[]): void;
1
+ import { StorageCollectionSchema, StorageFieldSchema } from './types.js';
2
+ export declare function validateEntity(schema: StorageCollectionSchema, entity: any): void;
3
+ export declare function validateEntityField(field: StorageFieldSchema, value: any, fieldPath?: string[]): void;
@@ -1,82 +1,82 @@
1
- import { LEGACY_OID_KEY, OID_KEY } from '../oids.js';
2
- import { isObject } from '../utils.js';
3
- export function validateEntity(schema, entity) {
4
- for (const [key, value] of Object.entries(entity)) {
5
- if (!schema.fields[key]) {
6
- throw new Error(`Invalid field "${key}"`);
7
- }
8
- if (value) {
9
- validateEntityField(schema.fields[key], value);
10
- }
11
- }
12
- }
13
- export function validateEntityField(field, value, fieldPath = []) {
14
- if (field.type === 'object') {
15
- if (!isObject(value)) {
16
- if (value === null && field.nullable)
17
- return;
18
- throw new Error(`Expected object${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
19
- }
20
- for (const [key, subField] of Object.entries(field.properties)) {
21
- if (value[key]) {
22
- validateEntityField(subField, value[key]);
23
- }
24
- }
25
- for (const key of Object.keys(value)) {
26
- if (!field.properties[key]) {
27
- throw new Error(`Invalid field "${key}" on value ${formatField(fieldPath)}`);
28
- }
29
- }
30
- }
31
- else if (field.type === 'array') {
32
- if (!Array.isArray(value)) {
33
- if (value === null && field.nullable)
34
- return;
35
- throw new Error(`Expected array${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
36
- }
37
- for (const item of value) {
38
- validateEntityField(field.items, item);
39
- }
40
- }
41
- else if (field.type === 'map') {
42
- if (!isObject(value)) {
43
- throw new Error(`Expected map for field ${formatField(fieldPath)}}`);
44
- }
45
- for (const [key, item] of Object.entries(value)) {
46
- // santiy check to weed out any id field
47
- if (key === OID_KEY || key === LEGACY_OID_KEY)
48
- continue;
49
- validateEntityField(field.values, item);
50
- }
51
- }
52
- else if (field.type === 'string') {
53
- if (typeof value !== 'string') {
54
- if (value === null && field.nullable)
55
- return;
56
- throw new Error(`Expected string ${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
57
- }
58
- }
59
- else if (field.type === 'boolean') {
60
- if (typeof value !== 'boolean') {
61
- if (value === null && field.nullable)
62
- return;
63
- throw new Error(`Expected boolean ${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
64
- }
65
- }
66
- else if (field.type === 'number') {
67
- if (typeof value !== 'number') {
68
- if (value === null && field.nullable)
69
- return;
70
- throw new Error(`Expected number ${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
71
- }
72
- }
73
- else if (field.type === 'file') {
74
- if (value === null && !field.nullable) {
75
- throw new Error(`Expected file for field ${formatField(fieldPath)}}`);
76
- }
77
- }
78
- }
79
- function formatField(fieldPath) {
80
- return fieldPath.join('.');
81
- }
1
+ import { LEGACY_OID_KEY, OID_KEY } from '../oids.js';
2
+ import { isObject } from '../utils.js';
3
+ export function validateEntity(schema, entity) {
4
+ for (const [key, value] of Object.entries(entity)) {
5
+ if (!schema.fields[key]) {
6
+ throw new Error(`Invalid field "${key}"`);
7
+ }
8
+ if (value) {
9
+ validateEntityField(schema.fields[key], value);
10
+ }
11
+ }
12
+ }
13
+ export function validateEntityField(field, value, fieldPath = []) {
14
+ if (field.type === 'object') {
15
+ if (!isObject(value)) {
16
+ if (value === null && field.nullable)
17
+ return;
18
+ throw new Error(`Expected object${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
19
+ }
20
+ for (const [key, subField] of Object.entries(field.properties)) {
21
+ if (value[key]) {
22
+ validateEntityField(subField, value[key]);
23
+ }
24
+ }
25
+ for (const key of Object.keys(value)) {
26
+ if (!field.properties[key]) {
27
+ throw new Error(`Invalid field "${key}" on value ${formatField(fieldPath)}`);
28
+ }
29
+ }
30
+ }
31
+ else if (field.type === 'array') {
32
+ if (!Array.isArray(value)) {
33
+ if (value === null && field.nullable)
34
+ return;
35
+ throw new Error(`Expected array${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
36
+ }
37
+ for (const item of value) {
38
+ validateEntityField(field.items, item);
39
+ }
40
+ }
41
+ else if (field.type === 'map') {
42
+ if (!isObject(value)) {
43
+ throw new Error(`Expected map for field ${formatField(fieldPath)}}`);
44
+ }
45
+ for (const [key, item] of Object.entries(value)) {
46
+ // santiy check to weed out any id field
47
+ if (key === OID_KEY || key === LEGACY_OID_KEY)
48
+ continue;
49
+ validateEntityField(field.values, item);
50
+ }
51
+ }
52
+ else if (field.type === 'string') {
53
+ if (typeof value !== 'string') {
54
+ if (value === null && field.nullable)
55
+ return;
56
+ throw new Error(`Expected string ${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
57
+ }
58
+ }
59
+ else if (field.type === 'boolean') {
60
+ if (typeof value !== 'boolean') {
61
+ if (value === null && field.nullable)
62
+ return;
63
+ throw new Error(`Expected boolean ${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
64
+ }
65
+ }
66
+ else if (field.type === 'number') {
67
+ if (typeof value !== 'number') {
68
+ if (value === null && field.nullable)
69
+ return;
70
+ throw new Error(`Expected number ${field.nullable ? ' or null' : ''} for field ${formatField(fieldPath)}}`);
71
+ }
72
+ }
73
+ else if (field.type === 'file') {
74
+ if (value === null && !field.nullable) {
75
+ throw new Error(`Expected file for field ${formatField(fieldPath)}}`);
76
+ }
77
+ }
78
+ }
79
+ function formatField(fieldPath) {
80
+ return fieldPath.join('.');
81
+ }
82
82
  //# sourceMappingURL=validation.js.map
@@ -1,50 +1,50 @@
1
- export interface TimestampProvider {
2
- now(version: number): string;
3
- update(remoteTimestamp: string): void;
4
- zero(version: number): string;
5
- getWallClockTime(timestamp: string): number;
6
- }
7
- export declare function encodeVersion(version: number | string): string;
8
- export declare function OLD_encodeVersion(version: number | string): string;
9
- export declare class NaiveTimestampProvider implements TimestampProvider {
10
- counter: number;
11
- now: (version: number | string) => string;
12
- update: () => void;
13
- zero: (version: number | string) => string;
14
- getWallClockTime: (timestamp: string) => number;
15
- }
16
- export declare class HybridLogicalClockTimestampProvider implements TimestampProvider {
17
- private latest;
18
- private zeroCounter;
19
- now: (version: string | number) => string;
20
- /**
21
- * @deprecated - use now() instead and update to latest format
22
- */
23
- OLD_now: (version: string | number) => string;
24
- /** Get the current timer state. Does not increment counter. */
25
- timerState: () => HLCTimestamp;
26
- update: (remoteTimestamp: string) => void;
27
- get: (version: string | number, raw: HLCTimestamp) => string;
28
- zero: (version: string | number) => string;
29
- getWallClockTime: (timestamp: string) => number;
30
- }
31
- interface HLCTimestamp {
32
- time: number;
33
- counter: number;
34
- node: string;
35
- }
36
- export declare function serializeHlcTimestamp(ts: HLCTimestamp): string;
37
- export declare function deserializeHlcTimestamp(clock: string): HLCTimestamp;
38
- /**
39
- * Below, converters for old-style timestamps are defined.
40
- * These are for migrating older clients to the new format.
41
- */
42
- /**
43
- * Converts a timestamp from the old format to the new format.
44
- */
45
- export declare function convertOldHlcTimestamp(ts: string): string;
46
- export declare function OLD_serializeHlcTimestamp(ts: HLCTimestamp): string;
47
- export declare function OLD_deserializeHlcTimestamp(clock: string): HLCTimestamp;
48
- export declare function getTimestampSchemaVersion(timestamp: string): number;
49
- export declare function compareTimestampSchemaVersions(a: string, b: string): number;
50
- export {};
1
+ export interface TimestampProvider {
2
+ now(version: number): string;
3
+ update(remoteTimestamp: string): void;
4
+ zero(version: number): string;
5
+ getWallClockTime(timestamp: string): number;
6
+ }
7
+ export declare function encodeVersion(version: number | string): string;
8
+ export declare function OLD_encodeVersion(version: number | string): string;
9
+ export declare class NaiveTimestampProvider implements TimestampProvider {
10
+ counter: number;
11
+ now: (version: number | string) => string;
12
+ update: () => void;
13
+ zero: (version: number | string) => string;
14
+ getWallClockTime: (timestamp: string) => number;
15
+ }
16
+ export declare class HybridLogicalClockTimestampProvider implements TimestampProvider {
17
+ private latest;
18
+ private zeroCounter;
19
+ now: (version: string | number) => string;
20
+ /**
21
+ * @deprecated - use now() instead and update to latest format
22
+ */
23
+ OLD_now: (version: string | number) => string;
24
+ /** Get the current timer state. Does not increment counter. */
25
+ timerState: () => HLCTimestamp;
26
+ update: (remoteTimestamp: string) => void;
27
+ get: (version: string | number, raw: HLCTimestamp) => string;
28
+ zero: (version: string | number) => string;
29
+ getWallClockTime: (timestamp: string) => number;
30
+ }
31
+ interface HLCTimestamp {
32
+ time: number;
33
+ counter: number;
34
+ node: string;
35
+ }
36
+ export declare function serializeHlcTimestamp(ts: HLCTimestamp): string;
37
+ export declare function deserializeHlcTimestamp(clock: string): HLCTimestamp;
38
+ /**
39
+ * Below, converters for old-style timestamps are defined.
40
+ * These are for migrating older clients to the new format.
41
+ */
42
+ /**
43
+ * Converts a timestamp from the old format to the new format.
44
+ */
45
+ export declare function convertOldHlcTimestamp(ts: string): string;
46
+ export declare function OLD_serializeHlcTimestamp(ts: HLCTimestamp): string;
47
+ export declare function OLD_deserializeHlcTimestamp(clock: string): HLCTimestamp;
48
+ export declare function getTimestampSchemaVersion(timestamp: string): number;
49
+ export declare function compareTimestampSchemaVersions(a: string, b: string): number;
50
+ export {};