@verdant-web/store 2.7.10 → 2.8.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/bundle/index.js +13 -13
- package/dist/bundle/index.js.map +4 -4
- package/dist/cjs/entities/DocumentFamiliyCache.d.ts +7 -1
- package/dist/cjs/entities/DocumentFamiliyCache.js +5 -1
- package/dist/cjs/entities/DocumentFamiliyCache.js.map +1 -1
- package/dist/cjs/entities/Entity.d.ts +9 -2
- package/dist/cjs/entities/Entity.js +17 -2
- package/dist/cjs/entities/Entity.js.map +1 -1
- package/dist/cjs/entities/EntityStore.js +3 -3
- package/dist/cjs/entities/EntityStore.js.map +1 -1
- package/dist/cjs/metadata/BaselinesStore.d.ts +4 -0
- package/dist/cjs/metadata/BaselinesStore.js +7 -0
- package/dist/cjs/metadata/BaselinesStore.js.map +1 -1
- package/dist/cjs/metadata/Metadata.d.ts +1 -0
- package/dist/cjs/metadata/Metadata.js +13 -0
- package/dist/cjs/metadata/Metadata.js.map +1 -1
- package/dist/cjs/metadata/OperationsStore.d.ts +6 -0
- package/dist/cjs/metadata/OperationsStore.js +6 -0
- package/dist/cjs/metadata/OperationsStore.js.map +1 -1
- package/dist/cjs/migration/openDatabase.js +20 -9
- package/dist/cjs/migration/openDatabase.js.map +1 -1
- package/dist/esm/entities/DocumentFamiliyCache.d.ts +7 -1
- package/dist/esm/entities/DocumentFamiliyCache.js +5 -1
- package/dist/esm/entities/DocumentFamiliyCache.js.map +1 -1
- package/dist/esm/entities/Entity.d.ts +9 -2
- package/dist/esm/entities/Entity.js +18 -3
- package/dist/esm/entities/Entity.js.map +1 -1
- package/dist/esm/entities/EntityStore.js +3 -3
- package/dist/esm/entities/EntityStore.js.map +1 -1
- package/dist/esm/metadata/BaselinesStore.d.ts +4 -0
- package/dist/esm/metadata/BaselinesStore.js +7 -0
- package/dist/esm/metadata/BaselinesStore.js.map +1 -1
- package/dist/esm/metadata/Metadata.d.ts +1 -0
- package/dist/esm/metadata/Metadata.js +13 -0
- package/dist/esm/metadata/Metadata.js.map +1 -1
- package/dist/esm/metadata/OperationsStore.d.ts +6 -0
- package/dist/esm/metadata/OperationsStore.js +6 -0
- package/dist/esm/metadata/OperationsStore.js.map +1 -1
- package/dist/esm/migration/openDatabase.js +20 -9
- package/dist/esm/migration/openDatabase.js.map +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/entities/DocumentFamiliyCache.ts +16 -6
- package/src/entities/Entity.ts +26 -6
- package/src/entities/EntityStore.ts +3 -3
- package/src/metadata/BaselinesStore.ts +35 -12
- package/src/metadata/Metadata.ts +26 -0
- package/src/metadata/OperationsStore.ts +31 -0
- package/src/migration/openDatabase.ts +23 -6
|
@@ -136,6 +136,37 @@ export class OperationsStore extends IDBService {
|
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
iterateOverAllOperationsForCollection = async (
|
|
140
|
+
collection: string,
|
|
141
|
+
iterator: (patch: StoredClientOperation, store: IDBObjectStore) => void,
|
|
142
|
+
{
|
|
143
|
+
after,
|
|
144
|
+
to,
|
|
145
|
+
mode,
|
|
146
|
+
transaction: providedTx,
|
|
147
|
+
}: {
|
|
148
|
+
after?: string;
|
|
149
|
+
to?: string;
|
|
150
|
+
mode?: 'readwrite' | 'readonly';
|
|
151
|
+
transaction?: IDBTransaction;
|
|
152
|
+
},
|
|
153
|
+
): Promise<void> => {
|
|
154
|
+
const transaction = providedTx || this.db.transaction('operations', mode);
|
|
155
|
+
|
|
156
|
+
return this.iterate(
|
|
157
|
+
'operations',
|
|
158
|
+
(store) => {
|
|
159
|
+
return store.openCursor(
|
|
160
|
+
IDBKeyRange.bound(collection, collection + '\uffff', false, false),
|
|
161
|
+
'next',
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
iterator,
|
|
165
|
+
mode,
|
|
166
|
+
transaction,
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
|
|
139
170
|
iterateOverAllLocalOperations = async (
|
|
140
171
|
iterator: (patch: ClientOperation, store: IDBObjectStore) => void,
|
|
141
172
|
{
|
|
@@ -458,15 +458,16 @@ function getMigrationMutations({
|
|
|
458
458
|
);
|
|
459
459
|
return doc;
|
|
460
460
|
},
|
|
461
|
-
delete: (id: string) => {
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
461
|
+
delete: async (id: string) => {
|
|
462
|
+
const rootOid = createOid(collectionName, id);
|
|
463
|
+
const allOids = await meta.getAllDocumentRelatedOids(rootOid);
|
|
464
|
+
return meta.insertLocalOperation(
|
|
465
|
+
allOids.map((oid) => ({
|
|
465
466
|
oid,
|
|
466
467
|
timestamp: getMigrationNow(),
|
|
467
468
|
data: { op: 'delete' },
|
|
468
|
-
},
|
|
469
|
-
|
|
469
|
+
})),
|
|
470
|
+
);
|
|
470
471
|
},
|
|
471
472
|
};
|
|
472
473
|
return acc;
|
|
@@ -553,10 +554,21 @@ function getMigrationEngine({
|
|
|
553
554
|
newOids,
|
|
554
555
|
meta,
|
|
555
556
|
});
|
|
557
|
+
const deleteCollection = async (collection: string) => {
|
|
558
|
+
const allOids = await meta.getAllCollectionRelatedOids(collection);
|
|
559
|
+
return meta.insertLocalOperation(
|
|
560
|
+
allOids.map((oid) => ({
|
|
561
|
+
oid,
|
|
562
|
+
timestamp: getMigrationNow(),
|
|
563
|
+
data: { op: 'delete' },
|
|
564
|
+
})),
|
|
565
|
+
);
|
|
566
|
+
};
|
|
556
567
|
const awaitables = new Array<Promise<any>>();
|
|
557
568
|
const engine: MigrationEngine = {
|
|
558
569
|
log: context.log,
|
|
559
570
|
newOids,
|
|
571
|
+
deleteCollection,
|
|
560
572
|
migrate: async (collection, strategy) => {
|
|
561
573
|
const docs = await queries[collection].findAll();
|
|
562
574
|
|
|
@@ -632,6 +644,11 @@ function getInitialMigrationEngine({
|
|
|
632
644
|
const engine: MigrationEngine = {
|
|
633
645
|
log: context.log,
|
|
634
646
|
newOids,
|
|
647
|
+
deleteCollection: () => {
|
|
648
|
+
throw new Error(
|
|
649
|
+
'Calling deleteCollection() in initial migrations is not supported! Use initial migrations to seed initial data using mutations.',
|
|
650
|
+
);
|
|
651
|
+
},
|
|
635
652
|
migrate: () => {
|
|
636
653
|
throw new Error(
|
|
637
654
|
'Calling migrate() in initial migrations is not supported! Use initial migrations to seed initial data using mutations.',
|