@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.
- 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/files.test.d.ts +1 -0
- package/dist/cjs/files.test.js +81 -0
- package/dist/cjs/files.test.js.map +1 -0
- package/dist/cjs/index.d.ts +19 -18
- package/dist/cjs/index.js +41 -36
- package/dist/cjs/index.js.map +1 -1
- 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 -96
- package/dist/cjs/oids.js +457 -439
- package/dist/cjs/oids.js.map +1 -1
- package/dist/cjs/oids.test.d.ts +1 -1
- package/dist/cjs/oids.test.js +348 -272
- package/dist/cjs/oids.test.js.map +1 -1
- 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 -5
- package/dist/cjs/refs.js +29 -21
- package/dist/cjs/refs.js.map +1 -1
- package/dist/cjs/replica.d.ts +28 -28
- package/dist/cjs/replica.js +28 -28
- package/dist/cjs/schema/defaults.d.ts +4 -0
- package/dist/cjs/schema/defaults.js +72 -0
- package/dist/cjs/schema/defaults.js.map +1 -0
- 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/files.test.d.ts +1 -0
- package/dist/esm/files.test.js +79 -0
- package/dist/esm/files.test.js.map +1 -0
- package/dist/esm/index.d.ts +19 -18
- package/dist/esm/index.js +16 -15
- package/dist/esm/index.js.map +1 -1
- 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 -96
- package/dist/esm/oids.js +422 -407
- package/dist/esm/oids.js.map +1 -1
- package/dist/esm/oids.test.d.ts +1 -1
- package/dist/esm/oids.test.js +346 -270
- package/dist/esm/oids.test.js.map +1 -1
- 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 -5
- package/dist/esm/refs.js +22 -16
- package/dist/esm/refs.js.map +1 -1
- package/dist/esm/replica.d.ts +28 -28
- package/dist/esm/replica.js +25 -25
- package/dist/esm/schema/defaults.d.ts +4 -0
- package/dist/esm/schema/defaults.js +66 -0
- package/dist/esm/schema/defaults.js.map +1 -0
- 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/src/index.ts +1 -0
- package/src/oids.test.ts +82 -0
- package/src/oids.ts +17 -0
- package/src/refs.ts +8 -0
package/dist/esm/oids.d.ts
CHANGED
|
@@ -1,96 +1,100 @@
|
|
|
1
|
-
import { ObjectRef } from './operation.js';
|
|
2
|
-
/**
|
|
3
|
-
* OIDs
|
|
4
|
-
*
|
|
5
|
-
* OIDs are used to identify objects in the document. They also encode
|
|
6
|
-
* information about the object useful to identifying an object found
|
|
7
|
-
* on its own and associating it back to its parent.
|
|
8
|
-
*
|
|
9
|
-
* An OID is structured as such:
|
|
10
|
-
* <collection>/<root id>[/<key paths>]:<random>
|
|
11
|
-
*
|
|
12
|
-
* OIDs have a few characteristics:
|
|
13
|
-
* - They include the collection name of the parent document
|
|
14
|
-
* - They include the primary key of the parent document
|
|
15
|
-
* - They include the key path of the object within the document
|
|
16
|
-
* - They include a random sequence to identify different objects which
|
|
17
|
-
* exist at the same key path
|
|
18
|
-
*
|
|
19
|
-
* Collection name and document key are used to link any isolated
|
|
20
|
-
* object back to its parent document.
|
|
21
|
-
*
|
|
22
|
-
* The key path is used for authorization - to associate the object
|
|
23
|
-
* (or an operation related to it by OID) with the field it inhabits
|
|
24
|
-
* to utilize authorization rules from that field in the schema.
|
|
25
|
-
*
|
|
26
|
-
* The random sequence allows the application to encode different
|
|
27
|
-
* identities for objects at the same position in a document for
|
|
28
|
-
* conflict resolution purposes
|
|
29
|
-
*/
|
|
30
|
-
export declare type ObjectIdentifier = string;
|
|
31
|
-
export declare const LEGACY_OID_KEY = "__@@oid_do_not_use";
|
|
32
|
-
export declare const OID_KEY = "@@id";
|
|
33
|
-
export declare function getOid(obj: any): string;
|
|
34
|
-
export declare function maybeGetOid(obj: any): ObjectIdentifier | undefined;
|
|
35
|
-
export declare function assignOid(obj: any, oid: ObjectIdentifier): any;
|
|
36
|
-
export declare function hasOid(obj: any): boolean;
|
|
37
|
-
export declare function removeOid(obj: any): any;
|
|
38
|
-
export declare function isOidKey(key: string): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* For sub-objects, assign a random sub-OID if no OID
|
|
41
|
-
* is already assigned.
|
|
42
|
-
*/
|
|
43
|
-
export declare function ensureOid(obj: any, rootOid: ObjectIdentifier, createSubId?: () => string): string;
|
|
44
|
-
export declare function ensureCompatibleOid(obj: any, rootOid: ObjectIdentifier, createSubId?: () => string): string;
|
|
45
|
-
export declare function createOid(collection: string, documentId: string, subId?: string): string;
|
|
46
|
-
export declare function createSubOid(root: ObjectIdentifier, createSubId?: () => string): string;
|
|
47
|
-
export declare function decomposeOid(oid: ObjectIdentifier): {
|
|
48
|
-
collection: string;
|
|
49
|
-
id: string;
|
|
50
|
-
subId?: string;
|
|
51
|
-
};
|
|
52
|
-
export declare function assertAllLevelsHaveOids(obj: any, root?: any): void;
|
|
53
|
-
export declare function assignOidsToAllSubObjects(obj: any, createSubId?: () => string): void;
|
|
54
|
-
export declare function assignOidProperty(obj: any, oid: ObjectIdentifier): any;
|
|
55
|
-
export declare function maybeGetOidProperty(obj: any): any;
|
|
56
|
-
/**
|
|
57
|
-
* Assigns a special property to all objects in the given object
|
|
58
|
-
* which have an OID
|
|
59
|
-
*/
|
|
60
|
-
export declare function assignOidPropertiesToAllSubObjects(obj: any): void;
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
* Removes the special property from all objects in the given object
|
|
64
|
-
* which have an OID, transferring the OID from the property to the OID
|
|
65
|
-
* system in-memory.
|
|
66
|
-
*/
|
|
67
|
-
export declare function removeOidPropertiesFromAllSubObjects(obj: any): void;
|
|
68
|
-
export declare function removeOidsFromAllSubObjects(obj: any): void;
|
|
69
|
-
export declare function createOidSubId(): string;
|
|
70
|
-
export declare function createRef(oid: ObjectIdentifier): ObjectRef;
|
|
71
|
-
export declare function normalize(obj: any, refs?: Map<ObjectIdentifier, any>): Map<ObjectIdentifier, any>;
|
|
72
|
-
/**
|
|
73
|
-
* Only normalizes direct children. The created map
|
|
74
|
-
* of objects will still have nested objects.
|
|
75
|
-
*/
|
|
76
|
-
export declare function normalizeFirstLevel(obj: any): {
|
|
77
|
-
refs: Map<string, any>;
|
|
78
|
-
oidKeyPairs: Map<string, string | number>;
|
|
79
|
-
};
|
|
80
|
-
export declare function getOidRoot(oid: ObjectIdentifier): string;
|
|
81
|
-
/**
|
|
82
|
-
* Returns an inclusive range of OIDs that represent
|
|
83
|
-
* all of an OID's possible sub-objects.
|
|
84
|
-
*/
|
|
85
|
-
export declare function getOidSubIdRange(oid: ObjectIdentifier): string[];
|
|
86
|
-
export declare function getLegacyDotOidSubIdRange(oid: ObjectIdentifier): string[];
|
|
87
|
-
export declare function getRoots(oids: ObjectIdentifier[]): string[];
|
|
88
|
-
export declare function areOidsRelated(oidA: ObjectIdentifier, oidB: ObjectIdentifier): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Recursively rewrites any OIDs in an object which are 'foreign' -
|
|
91
|
-
* i.e. relate to some other object/entity - to be local to the
|
|
92
|
-
* current object. This is deterministic, so it can be done
|
|
93
|
-
* on multiple clients independently with predictable results.
|
|
94
|
-
*/
|
|
95
|
-
export declare function fixForeignOids(obj: any): void;
|
|
96
|
-
export declare function isLegacyDotOid(oid: ObjectIdentifier): boolean;
|
|
1
|
+
import { ObjectRef } from './operation.js';
|
|
2
|
+
/**
|
|
3
|
+
* OIDs
|
|
4
|
+
*
|
|
5
|
+
* OIDs are used to identify objects in the document. They also encode
|
|
6
|
+
* information about the object useful to identifying an object found
|
|
7
|
+
* on its own and associating it back to its parent.
|
|
8
|
+
*
|
|
9
|
+
* An OID is structured as such:
|
|
10
|
+
* <collection>/<root id>[/<key paths>]:<random>
|
|
11
|
+
*
|
|
12
|
+
* OIDs have a few characteristics:
|
|
13
|
+
* - They include the collection name of the parent document
|
|
14
|
+
* - They include the primary key of the parent document
|
|
15
|
+
* - They include the key path of the object within the document
|
|
16
|
+
* - They include a random sequence to identify different objects which
|
|
17
|
+
* exist at the same key path
|
|
18
|
+
*
|
|
19
|
+
* Collection name and document key are used to link any isolated
|
|
20
|
+
* object back to its parent document.
|
|
21
|
+
*
|
|
22
|
+
* The key path is used for authorization - to associate the object
|
|
23
|
+
* (or an operation related to it by OID) with the field it inhabits
|
|
24
|
+
* to utilize authorization rules from that field in the schema.
|
|
25
|
+
*
|
|
26
|
+
* The random sequence allows the application to encode different
|
|
27
|
+
* identities for objects at the same position in a document for
|
|
28
|
+
* conflict resolution purposes
|
|
29
|
+
*/
|
|
30
|
+
export declare type ObjectIdentifier = string;
|
|
31
|
+
export declare const LEGACY_OID_KEY = "__@@oid_do_not_use";
|
|
32
|
+
export declare const OID_KEY = "@@id";
|
|
33
|
+
export declare function getOid(obj: any): string;
|
|
34
|
+
export declare function maybeGetOid(obj: any): ObjectIdentifier | undefined;
|
|
35
|
+
export declare function assignOid(obj: any, oid: ObjectIdentifier): any;
|
|
36
|
+
export declare function hasOid(obj: any): boolean;
|
|
37
|
+
export declare function removeOid(obj: any): any;
|
|
38
|
+
export declare function isOidKey(key: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* For sub-objects, assign a random sub-OID if no OID
|
|
41
|
+
* is already assigned.
|
|
42
|
+
*/
|
|
43
|
+
export declare function ensureOid(obj: any, rootOid: ObjectIdentifier, createSubId?: () => string): string;
|
|
44
|
+
export declare function ensureCompatibleOid(obj: any, rootOid: ObjectIdentifier, createSubId?: () => string): string;
|
|
45
|
+
export declare function createOid(collection: string, documentId: string, subId?: string): string;
|
|
46
|
+
export declare function createSubOid(root: ObjectIdentifier, createSubId?: () => string): string;
|
|
47
|
+
export declare function decomposeOid(oid: ObjectIdentifier): {
|
|
48
|
+
collection: string;
|
|
49
|
+
id: string;
|
|
50
|
+
subId?: string;
|
|
51
|
+
};
|
|
52
|
+
export declare function assertAllLevelsHaveOids(obj: any, root?: any): void;
|
|
53
|
+
export declare function assignOidsToAllSubObjects(obj: any, createSubId?: () => string): void;
|
|
54
|
+
export declare function assignOidProperty(obj: any, oid: ObjectIdentifier): any;
|
|
55
|
+
export declare function maybeGetOidProperty(obj: any): any;
|
|
56
|
+
/**
|
|
57
|
+
* Assigns a special property to all objects in the given object
|
|
58
|
+
* which have an OID
|
|
59
|
+
*/
|
|
60
|
+
export declare function assignOidPropertiesToAllSubObjects(obj: any): void;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* Removes the special property from all objects in the given object
|
|
64
|
+
* which have an OID, transferring the OID from the property to the OID
|
|
65
|
+
* system in-memory.
|
|
66
|
+
*/
|
|
67
|
+
export declare function removeOidPropertiesFromAllSubObjects(obj: any): void;
|
|
68
|
+
export declare function removeOidsFromAllSubObjects(obj: any): void;
|
|
69
|
+
export declare function createOidSubId(): string;
|
|
70
|
+
export declare function createRef(oid: ObjectIdentifier): ObjectRef;
|
|
71
|
+
export declare function normalize(obj: any, refs?: Map<ObjectIdentifier, any>): Map<ObjectIdentifier, any>;
|
|
72
|
+
/**
|
|
73
|
+
* Only normalizes direct children. The created map
|
|
74
|
+
* of objects will still have nested objects.
|
|
75
|
+
*/
|
|
76
|
+
export declare function normalizeFirstLevel(obj: any): {
|
|
77
|
+
refs: Map<string, any>;
|
|
78
|
+
oidKeyPairs: Map<string, string | number>;
|
|
79
|
+
};
|
|
80
|
+
export declare function getOidRoot(oid: ObjectIdentifier): string;
|
|
81
|
+
/**
|
|
82
|
+
* Returns an inclusive range of OIDs that represent
|
|
83
|
+
* all of an OID's possible sub-objects.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getOidSubIdRange(oid: ObjectIdentifier): string[];
|
|
86
|
+
export declare function getLegacyDotOidSubIdRange(oid: ObjectIdentifier): string[];
|
|
87
|
+
export declare function getRoots(oids: ObjectIdentifier[]): string[];
|
|
88
|
+
export declare function areOidsRelated(oidA: ObjectIdentifier, oidB: ObjectIdentifier): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Recursively rewrites any OIDs in an object which are 'foreign' -
|
|
91
|
+
* i.e. relate to some other object/entity - to be local to the
|
|
92
|
+
* current object. This is deterministic, so it can be done
|
|
93
|
+
* on multiple clients independently with predictable results.
|
|
94
|
+
*/
|
|
95
|
+
export declare function fixForeignOids(obj: any): void;
|
|
96
|
+
export declare function isLegacyDotOid(oid: ObjectIdentifier): boolean;
|
|
97
|
+
export declare function convertLegacyOid(oid: ObjectIdentifier): string;
|
|
98
|
+
export declare const MATCH_LEGACY_OID_JSON_STRING: RegExp;
|
|
99
|
+
export declare function replaceLegacyOidsInJsonString(string: string): string;
|
|
100
|
+
export declare function replaceLegacyOidsInObject(obj: any): any;
|