@verdant-web/store 4.1.0 → 4.1.2

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.
@@ -74,16 +74,16 @@ export declare class Client<Presence = any, Profile = any> extends EventSubscrib
74
74
  * a short delay or if they reach a maximum size.
75
75
  */
76
76
  get batch(): ({ undoable, batchName, max, timeout, }?: {
77
- undoable?: boolean | undefined;
78
- batchName?: string | undefined;
79
- max?: number | null | undefined;
80
- timeout?: number | null | undefined;
77
+ undoable?: boolean;
78
+ batchName?: string;
79
+ max?: number | null;
80
+ timeout?: number | null;
81
81
  }) => import("../entities/OperationBatcher.js").OperationBatch;
82
82
  stats: () => Promise<ClientStats>;
83
83
  close: () => Promise<void>;
84
84
  __dangerous__resetLocal: () => Promise<void>;
85
85
  export: ({ downloadRemoteFiles }?: {
86
- downloadRemoteFiles?: boolean | undefined;
86
+ downloadRemoteFiles?: boolean;
87
87
  }) => Promise<ExportedData>;
88
88
  import: ({ data, fileData, files }: ExportedData) => Promise<void>;
89
89
  /**
@@ -110,7 +110,7 @@ export declare class Entity<Init = any, KeyValue extends BaseEntityValue = any,
110
110
  private changeNested;
111
111
  protected deepChange: (target: Entity, ev: EntityChange) => void;
112
112
  private getChild;
113
- subscribeToField: <K extends keyof KeyValue>(key: K, event: 'change', callback: (value: KeyValue[K], info: {
113
+ subscribeToField: <K extends keyof KeyValue>(key: K, event: "change", callback: (value: KeyValue[K], info: {
114
114
  previousValue: KeyValue[K];
115
115
  isLocal?: boolean;
116
116
  }) => void) => () => void;
@@ -166,9 +166,9 @@ export declare class Entity<Init = any, KeyValue extends BaseEntityValue = any,
166
166
  values: () => Exclude<KeyValue[keyof KeyValue], undefined>[];
167
167
  get size(): number;
168
168
  update: (data: any, { merge, replaceSubObjects, preserveUndefined, }?: {
169
- replaceSubObjects?: boolean | undefined;
170
- merge?: boolean | undefined;
171
- preserveUndefined?: boolean | undefined;
169
+ replaceSubObjects?: boolean;
170
+ merge?: boolean;
171
+ preserveUndefined?: boolean;
172
172
  }) => void;
173
173
  get length(): number;
174
174
  push: (value: ListItemInit<Init>) => void;
@@ -209,7 +209,7 @@ export declare class Entity<Init = any, KeyValue extends BaseEntityValue = any,
209
209
  * call delete from there.
210
210
  */
211
211
  deleteSelf: () => void;
212
- __getViewData__: (oid: ObjectIdentifier, type: 'confirmed' | 'pending') => EntityMetadataView;
212
+ __getViewData__: (oid: ObjectIdentifier, type: "confirmed" | "pending") => EntityMetadataView;
213
213
  __getFamilyOids__: () => string[];
214
214
  __discardPendingOperation__: (operation: Operation) => void;
215
215
  }
@@ -54,9 +54,9 @@ export declare class EntityFamilyMetadata {
54
54
  get: (oid: ObjectIdentifier) => EntityMetadata;
55
55
  getAllOids: () => string[];
56
56
  addConfirmedData: ({ baselines, operations, isLocal, }: {
57
- baselines?: DocumentBaseline[] | undefined;
58
- operations?: Record<string, Operation[]> | undefined;
59
- isLocal?: boolean | undefined;
57
+ baselines?: DocumentBaseline[];
58
+ operations?: Record<ObjectIdentifier, Operation[]>;
59
+ isLocal?: boolean;
60
60
  }) => EntityChange[];
61
61
  /**
62
62
  * Adds local, unconfirmed operations to the system.
@@ -65,8 +65,8 @@ export declare class EntityFamilyMetadata {
65
65
  */
66
66
  addPendingData: (operations: Operation[]) => EntityChange[];
67
67
  replaceAllData: ({ operations, baselines, }: {
68
- operations?: Record<string, Operation[]> | undefined;
69
- baselines?: DocumentBaseline[] | undefined;
68
+ operations?: Record<ObjectIdentifier, Operation[]>;
69
+ baselines?: DocumentBaseline[];
70
70
  }) => EntityChange[];
71
71
  discardPendingOperation: (operation: Operation) => void;
72
72
  }
@@ -40,10 +40,10 @@ export declare class EntityStore extends Disposable {
40
40
  files: FileManager;
41
41
  });
42
42
  get batch(): ({ undoable, batchName, max, timeout, }?: {
43
- undoable?: boolean | undefined;
44
- batchName?: string | undefined;
45
- max?: number | null | undefined;
46
- timeout?: number | null | undefined;
43
+ undoable?: boolean;
44
+ batchName?: string;
45
+ max?: number | null;
46
+ timeout?: number | null;
47
47
  }) => import("./OperationBatcher.js").OperationBatch;
48
48
  get flushAllBatches(): () => Promise<any[]>;
49
49
  addData: (data: IncomingData) => Promise<void>;
@@ -39,7 +39,7 @@ export declare class OperationBatcher {
39
39
  addOperations: (operations: Operation[]) => void;
40
40
  batch: ({ undoable, batchName, max, timeout, }?: {
41
41
  /** Allows turning off undo for this batch, making it 'permanent' */
42
- undoable?: boolean | undefined;
42
+ undoable?: boolean;
43
43
  /**
44
44
  * Provide a stable name to any invocation of .batch() and the changes made
45
45
  * within run() will all be added to the same batch. If a batch hits the max
@@ -52,13 +52,13 @@ export declare class OperationBatcher {
52
52
  * recommended to provide limits in one place and only provide a name
53
53
  * in others.
54
54
  */
55
- batchName?: string | undefined;
55
+ batchName?: string;
56
56
  /**
57
57
  * The maximum number of operations the batch will hold before flushing
58
58
  * automatically. If null, the batch will not flush automatically based
59
59
  * on operation count.
60
60
  */
61
- max?: number | null | undefined;
61
+ max?: number | null;
62
62
  /**
63
63
  * The number of milliseconds to wait before flushing the batch automatically.
64
64
  * If null, the batch will not flush automatically based on time. It is not
@@ -66,7 +66,7 @@ export declare class OperationBatcher {
66
66
  * to storage or sync. If you do require undefined timing in a batch, make sure
67
67
  * to always call .commit() on the batch yourself.
68
68
  */
69
- timeout?: number | null | undefined;
69
+ timeout?: number | null;
70
70
  }) => OperationBatch;
71
71
  flushAll: () => Promise<any[]>;
72
72
  private createUndo;
@@ -7,7 +7,7 @@ export declare class MessageCreator {
7
7
  private meta;
8
8
  private ctx;
9
9
  constructor(db: PersistenceMetadataDb, meta: PersistenceMetadata, ctx: Pick<Context, 'time' | 'schema' | 'log'>);
10
- createOperation: (init: Pick<OperationMessage, 'operations'> & {
10
+ createOperation: (init: Pick<OperationMessage, "operations"> & {
11
11
  timestamp?: string;
12
12
  }) => Promise<OperationMessage>;
13
13
  /**
@@ -25,7 +25,7 @@ export declare class PersistenceFiles {
25
25
  files: File[];
26
26
  }>;
27
27
  import: ({ fileData, files, }: {
28
- fileData: Array<Omit<PersistedFileData, 'file'>>;
28
+ fileData: Array<Omit<PersistedFileData, "file">>;
29
29
  files: File[];
30
30
  }) => Promise<void>;
31
31
  private parseFileExportname;
@@ -44,12 +44,12 @@ export declare class PersistenceMetadata {
44
44
  transaction?: AbstractTransaction;
45
45
  }) => Promise<void>;
46
46
  iterateLocalOperations: (iterator: import("./interfaces.js").Iterator<ClientOperation>, opts?: (CommonQueryOptions<any> & {
47
- before?: string | null | undefined;
48
- after?: string | null | undefined;
47
+ before?: string | null;
48
+ after?: string | null;
49
49
  }) | undefined) => Promise<void>;
50
50
  iterateAllOperations: (iterator: import("./interfaces.js").Iterator<ClientOperation>, opts?: (CommonQueryOptions<any> & {
51
- before?: string | null | undefined;
52
- from?: string | null | undefined;
51
+ before?: string | null;
52
+ from?: string | null;
53
53
  }) | undefined) => Promise<void>;
54
54
  iterateAllBaselines: (iterator: import("./interfaces.js").Iterator<DocumentBaseline>, opts?: CommonQueryOptions<any> | undefined) => Promise<void>;
55
55
  reset: () => Promise<void>;
@@ -15,15 +15,15 @@ export declare class PersistenceDocuments {
15
15
  }) => Promise<void>;
16
16
  findOneOid: (opts: {
17
17
  collection: string;
18
- index?: import("@verdant-web/common").CollectionIndexFilter | undefined;
19
- }) => Promise<string | null>;
18
+ index?: import("@verdant-web/common").CollectionFilter;
19
+ }) => Promise<ObjectIdentifier | null>;
20
20
  findAllOids: (opts: {
21
21
  collection: string;
22
- index?: import("@verdant-web/common").CollectionIndexFilter | undefined;
23
- limit?: number | undefined;
24
- offset?: number | undefined;
22
+ index?: import("@verdant-web/common").CollectionFilter;
23
+ limit?: number;
24
+ offset?: number;
25
25
  }) => Promise<{
26
- result: string[];
26
+ result: ObjectIdentifier[];
27
27
  hasNextPage: boolean;
28
28
  }>;
29
29
  stats: () => Promise<Record<string, {
@@ -8,21 +8,21 @@ export declare class IdbService extends Disposable {
8
8
  log?: Context['log'];
9
9
  });
10
10
  createTransaction: (storeNames: string[], opts?: {
11
- mode?: 'readonly' | 'readwrite';
11
+ mode?: "readonly" | "readwrite";
12
12
  abort?: AbortSignal;
13
13
  }) => IDBTransaction;
14
14
  run: <T = any>(storeName: string, getRequest: (store: IDBObjectStore) => IDBRequest<T>, opts?: {
15
- mode?: 'readonly' | 'readwrite';
15
+ mode?: "readonly" | "readwrite";
16
16
  transaction?: IDBTransaction;
17
17
  abort?: AbortSignal;
18
18
  }) => Promise<T>;
19
19
  runAll: <T>(storeName: string, getRequests: (store: IDBObjectStore) => IDBRequest<T>[], opts?: {
20
- mode?: 'readonly' | 'readwrite';
20
+ mode?: "readonly" | "readwrite";
21
21
  transaction?: IDBTransaction;
22
22
  abort?: AbortSignal;
23
23
  }) => Promise<T[]>;
24
24
  iterate: <T>(storeName: string, getRequest: (store: IDBObjectStore) => IDBRequest<IDBCursorWithValue | null> | IDBRequest<IDBCursorWithValue | null>[], iterator: (value: T, store: IDBObjectStore, cursor: IDBCursorWithValue) => boolean | void, opts?: {
25
- mode?: 'readonly' | 'readwrite';
25
+ mode?: "readonly" | "readwrite";
26
26
  transaction?: IDBTransaction;
27
27
  abort?: AbortSignal;
28
28
  }) => Promise<void>;
@@ -16,7 +16,7 @@ export declare class IdbMetadataDb extends IdbService implements PersistenceMeta
16
16
  private ctx;
17
17
  constructor(db: IDBDatabase, ctx: Pick<Context, 'log' | 'namespace'>);
18
18
  transaction: <T>(opts: {
19
- mode?: 'readwrite' | 'readonly';
19
+ mode?: "readwrite" | "readonly";
20
20
  storeNames: string[];
21
21
  abort?: AbortSignal;
22
22
  }, procedure: (tx: IDBTransaction) => Promise<T>) => Promise<T>;
@@ -49,7 +49,7 @@ export declare class IdbMetadataDb extends IdbService implements PersistenceMeta
49
49
  }) => Promise<void>;
50
50
  addOperations: (ops: StoredClientOperation[], opts?: CommonQueryOptions) => Promise<ObjectIdentifier[]>;
51
51
  reset: ({ clearReplica, transaction, }?: {
52
- clearReplica?: boolean | undefined;
52
+ clearReplica?: boolean;
53
53
  transaction?: AbstractTransaction;
54
54
  }) => Promise<void>;
55
55
  stats: () => Promise<{
@@ -16,9 +16,9 @@ export declare class IdbDocumentDb extends IdbService implements PersistenceDocu
16
16
  }) => Promise<ObjectIdentifier | null>;
17
17
  findAllOids: ({ collection, index, offset, limit, }: {
18
18
  collection: string;
19
- index?: import("@verdant-web/common").CollectionIndexFilter | undefined;
20
- limit?: number | undefined;
21
- offset?: number | undefined;
19
+ index?: CollectionFilter;
20
+ limit?: number;
21
+ offset?: number;
22
22
  }) => Promise<{
23
23
  result: ObjectIdentifier[];
24
24
  hasNextPage: boolean;
@@ -1,7 +1,7 @@
1
1
  import { createOid, decomposeOid, getIndexValues, } from '@verdant-web/common';
2
2
  import { IdbService } from '../IdbService.js';
3
- import { getRange } from './ranges.js';
4
3
  import { closeDatabase, getSizeOfObjectStore, isAbortError } from '../util.js';
4
+ import { getRange } from './ranges.js';
5
5
  export class IdbDocumentDb extends IdbService {
6
6
  constructor(db, context) {
7
7
  super(db, { log: context.log });
@@ -101,7 +101,7 @@ export class IdbDocumentDb extends IdbService {
101
101
  abort: optsAndInfo.abort,
102
102
  }),
103
103
  };
104
- await Promise.all(entities.map(async (e) => {
104
+ const results = await Promise.allSettled(entities.map(async (e) => {
105
105
  const snapshot = e.getSnapshot();
106
106
  try {
107
107
  await this.saveDocument(e.oid, snapshot, options);
@@ -116,6 +116,17 @@ export class IdbDocumentDb extends IdbService {
116
116
  }
117
117
  }
118
118
  }));
119
+ const failures = results.filter((r) => r.status === 'rejected');
120
+ if (failures.length) {
121
+ // in the case of a failure to save a document, it doesn't quite make sense to cancel or rollback whatever is
122
+ // currently happening. when restoring imports, etc, this makes the app stuck. if only a few docs failed, maybe
123
+ // there's some data corruption somewhere, but we can just lose those without affecting the rest of the data.
124
+ if (failures.length === results.length) {
125
+ // but if ALL of them failed, that's trouble...
126
+ throw new Error('Failed to save any documents. Something must be quite wrong.');
127
+ }
128
+ this.ctx.log('error', 'Failed to save documents:', failures, ". See logs above. This only affects querying these documents. Let's hope a future attempt will correct them...");
129
+ }
119
130
  options.transaction.commit();
120
131
  };
121
132
  this.reset = async () => {
@@ -128,23 +139,29 @@ export class IdbDocumentDb extends IdbService {
128
139
  this.saveDocument = async (oid, doc, { transaction }) => {
129
140
  this.ctx.log('debug', `Saving document indexes for querying ${oid}`);
130
141
  const { collection, id } = decomposeOid(oid);
131
- if (!doc) {
132
- await this.run(collection, (store) => store.delete(id), {
133
- mode: 'readwrite',
134
- transaction,
135
- });
136
- this.ctx.log('debug', `Deleted document indexes for querying ${oid}`);
142
+ try {
143
+ if (!doc) {
144
+ await this.run(collection, (store) => store.delete(id), {
145
+ mode: 'readwrite',
146
+ transaction,
147
+ });
148
+ this.ctx.log('debug', `Deleted document indexes for querying ${oid}`);
149
+ }
150
+ else {
151
+ const schema = this.ctx.schema.collections[collection];
152
+ // no need to validate before storing; the entity's snapshot is already validated.
153
+ const indexes = getIndexValues(schema, doc);
154
+ indexes['@@@snapshot'] = JSON.stringify(doc);
155
+ await this.run(collection, (store) => store.put(indexes), {
156
+ mode: 'readwrite',
157
+ transaction,
158
+ });
159
+ this.ctx.log('debug', `Save complete for ${oid}`, indexes);
160
+ }
137
161
  }
138
- else {
139
- const schema = this.ctx.schema.collections[collection];
140
- // no need to validate before storing; the entity's snapshot is already validated.
141
- const indexes = getIndexValues(schema, doc);
142
- indexes['@@@snapshot'] = JSON.stringify(doc);
143
- await this.run(collection, (store) => store.put(indexes), {
144
- mode: 'readwrite',
145
- transaction,
146
- });
147
- this.ctx.log('debug', `Save complete for ${oid}`, indexes);
162
+ catch (err) {
163
+ this.ctx.log('error', `Error saving document ${oid}`, err);
164
+ throw err;
148
165
  }
149
166
  };
150
167
  this.ctx = context;
@@ -1 +1 @@
1
- {"version":3,"file":"IdbDocumentDb.js","sourceRoot":"","sources":["../../../../../src/persistence/idb/queries/IdbDocumentDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,SAAS,EACT,YAAY,EACZ,cAAc,GAEd,MAAM,q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IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;oBACvD,kFAAkF;oBAClF,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;oBAC5C,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;oBAC7C,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;wBACzD,IAAI,EAAE,WAAW;wBACjB,WAAW;qBACX,CAAC,CAAC;oBACH,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAqB,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;gBAC5D,CAAC;YACF,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,yBAAyB,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;gBAC3D,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC,CAAC;QAzND,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC;QACnB,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE;YACpB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,+BAA+B,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC1E,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACJ,CAAC;CAqND"}
@@ -40,22 +40,22 @@ export declare class CollectionQueries<T extends ObjectEntity<any, any>, Init, F
40
40
  private serializeIndex;
41
41
  get: (id: string) => GetQuery<T>;
42
42
  findOne: ({ index, key: providedKey, }?: {
43
- index?: Filter | undefined;
44
- key?: string | undefined;
43
+ index?: Filter;
44
+ key?: string;
45
45
  }) => FindOneQuery<T>;
46
46
  findAll: ({ index, key: providedKey, }?: {
47
- index?: Filter | undefined;
48
- key?: string | undefined;
47
+ index?: Filter;
48
+ key?: string;
49
49
  }) => FindAllQuery<T>;
50
50
  findPage: ({ index, pageSize, page, key: providedKey, }: {
51
- index?: Filter | undefined;
51
+ index?: Filter;
52
52
  pageSize: number;
53
53
  page: number;
54
- key?: string | undefined;
54
+ key?: string;
55
55
  }) => FindPageQuery<T>;
56
56
  findAllInfinite: ({ index, pageSize, key: providedKey, }: {
57
- index?: Filter | undefined;
57
+ index?: Filter;
58
58
  pageSize: number;
59
- key?: string | undefined;
59
+ key?: string;
60
60
  }) => FindInfiniteQuery<T>;
61
61
  }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@verdant-web/store",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "access": "public",
5
5
  "type": "module",
6
+ "main": "dist/esm/index.js",
6
7
  "exports": {
7
8
  ".": {
8
9
  "import": "./dist/esm/index.js",
@@ -29,11 +30,9 @@
29
30
  "src/"
30
31
  ],
31
32
  "dependencies": {
32
- "@a-type/kysely": "^1.0.1",
33
33
  "cuid": "^2.1.8",
34
34
  "jszip": "^3.10.1",
35
35
  "jwt-decode": "^3.1.2",
36
- "kysely": "^0.27.3",
37
36
  "weak-event": "^2.0.5",
38
37
  "@verdant-web/common": "2.7.0"
39
38
  },
@@ -8,8 +8,8 @@ import {
8
8
  import { Context } from '../../../context/context.js';
9
9
  import { PersistenceDocumentDb } from '../../interfaces.js';
10
10
  import { IdbService } from '../IdbService.js';
11
- import { getRange } from './ranges.js';
12
11
  import { closeDatabase, getSizeOfObjectStore, isAbortError } from '../util.js';
12
+ import { getRange } from './ranges.js';
13
13
 
14
14
  export class IdbDocumentDb extends IdbService implements PersistenceDocumentDb {
15
15
  private ctx;
@@ -149,7 +149,7 @@ export class IdbDocumentDb extends IdbService implements PersistenceDocumentDb {
149
149
  }),
150
150
  };
151
151
 
152
- await Promise.all(
152
+ const results = await Promise.allSettled(
153
153
  entities.map(async (e) => {
154
154
  const snapshot = e.getSnapshot();
155
155
  try {
@@ -168,6 +168,26 @@ export class IdbDocumentDb extends IdbService implements PersistenceDocumentDb {
168
168
  }
169
169
  }),
170
170
  );
171
+
172
+ const failures = results.filter((r) => r.status === 'rejected');
173
+ if (failures.length) {
174
+ // in the case of a failure to save a document, it doesn't quite make sense to cancel or rollback whatever is
175
+ // currently happening. when restoring imports, etc, this makes the app stuck. if only a few docs failed, maybe
176
+ // there's some data corruption somewhere, but we can just lose those without affecting the rest of the data.
177
+ if (failures.length === results.length) {
178
+ // but if ALL of them failed, that's trouble...
179
+ throw new Error(
180
+ 'Failed to save any documents. Something must be quite wrong.',
181
+ );
182
+ }
183
+ this.ctx.log(
184
+ 'error',
185
+ 'Failed to save documents:',
186
+ failures,
187
+ ". See logs above. This only affects querying these documents. Let's hope a future attempt will correct them...",
188
+ );
189
+ }
190
+
171
191
  options.transaction.commit();
172
192
  };
173
193
 
@@ -190,22 +210,27 @@ export class IdbDocumentDb extends IdbService implements PersistenceDocumentDb {
190
210
  ) => {
191
211
  this.ctx.log('debug', `Saving document indexes for querying ${oid}`);
192
212
  const { collection, id } = decomposeOid(oid);
193
- if (!doc) {
194
- await this.run(collection, (store) => store.delete(id), {
195
- mode: 'readwrite',
196
- transaction,
197
- });
198
- this.ctx.log('debug', `Deleted document indexes for querying ${oid}`);
199
- } else {
200
- const schema = this.ctx.schema.collections[collection];
201
- // no need to validate before storing; the entity's snapshot is already validated.
202
- const indexes = getIndexValues(schema, doc);
203
- indexes['@@@snapshot'] = JSON.stringify(doc);
204
- await this.run(collection, (store) => store.put(indexes), {
205
- mode: 'readwrite',
206
- transaction,
207
- });
208
- this.ctx.log('debug', `Save complete for ${oid}`, indexes);
213
+ try {
214
+ if (!doc) {
215
+ await this.run(collection, (store) => store.delete(id), {
216
+ mode: 'readwrite',
217
+ transaction,
218
+ });
219
+ this.ctx.log('debug', `Deleted document indexes for querying ${oid}`);
220
+ } else {
221
+ const schema = this.ctx.schema.collections[collection];
222
+ // no need to validate before storing; the entity's snapshot is already validated.
223
+ const indexes = getIndexValues(schema, doc);
224
+ indexes['@@@snapshot'] = JSON.stringify(doc);
225
+ await this.run(collection, (store) => store.put(indexes), {
226
+ mode: 'readwrite',
227
+ transaction,
228
+ });
229
+ this.ctx.log('debug', `Save complete for ${oid}`, indexes);
230
+ }
231
+ } catch (err) {
232
+ this.ctx.log('error', `Error saving document ${oid}`, err);
233
+ throw err;
209
234
  }
210
235
  };
211
236
  }