@sprucelabs/data-stores 25.12.0 → 25.13.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.
@@ -259,10 +259,14 @@ export default class AbstractStore extends AbstractMutexer {
259
259
  return __awaiter(this, void 0, void 0, function* () {
260
260
  const { ops, updates: initialUpdates } = this.pluckOperations(updates);
261
261
  let q = query;
262
+ let shouldUpdate = true;
262
263
  try {
263
264
  const isScrambled = this.isScrambled(initialUpdates);
264
265
  for (const plugin of this.plugins) {
265
266
  const results = yield ((_a = plugin.willUpdateOne) === null || _a === void 0 ? void 0 : _a.call(plugin, q, initialUpdates));
267
+ if ((results === null || results === void 0 ? void 0 : results.shouldUpdate) === false) {
268
+ shouldUpdate = false;
269
+ }
266
270
  if (results === null || results === void 0 ? void 0 : results.query) {
267
271
  q = results.query;
268
272
  }
@@ -281,6 +285,9 @@ export default class AbstractStore extends AbstractMutexer {
281
285
  //@ts-ignore
282
286
  validateSchemaValues(this.updateSchema, initialUpdates);
283
287
  }
288
+ if (!shouldUpdate) {
289
+ return current;
290
+ }
284
291
  const cleanedUpdates = !isScrambled && this.willUpdate
285
292
  ? yield this.willUpdate(initialUpdates, current)
286
293
  : initialUpdates;
@@ -55,6 +55,7 @@ export interface DataStorePluginWillCreateOneResponse {
55
55
  }
56
56
  export interface DataStorePluginWillUpdateOneResponse {
57
57
  query?: Record<string, any>;
58
+ shouldUpdate?: boolean;
58
59
  }
59
60
  export interface DataStorePluginWillDeleteOneResponse {
60
61
  query?: Record<string, any>;
@@ -251,10 +251,14 @@ class AbstractStore extends AbstractMutexer_1.default {
251
251
  var _a, _b;
252
252
  const { ops, updates: initialUpdates } = this.pluckOperations(updates);
253
253
  let q = query;
254
+ let shouldUpdate = true;
254
255
  try {
255
256
  const isScrambled = this.isScrambled(initialUpdates);
256
257
  for (const plugin of this.plugins) {
257
258
  const results = await ((_a = plugin.willUpdateOne) === null || _a === void 0 ? void 0 : _a.call(plugin, q, initialUpdates));
259
+ if ((results === null || results === void 0 ? void 0 : results.shouldUpdate) === false) {
260
+ shouldUpdate = false;
261
+ }
258
262
  if (results === null || results === void 0 ? void 0 : results.query) {
259
263
  q = results.query;
260
264
  }
@@ -273,6 +277,9 @@ class AbstractStore extends AbstractMutexer_1.default {
273
277
  //@ts-ignore
274
278
  (0, schema_1.validateSchemaValues)(this.updateSchema, initialUpdates);
275
279
  }
280
+ if (!shouldUpdate) {
281
+ return current;
282
+ }
276
283
  const cleanedUpdates = !isScrambled && this.willUpdate
277
284
  ? await this.willUpdate(initialUpdates, current)
278
285
  : initialUpdates;
@@ -55,6 +55,7 @@ export interface DataStorePluginWillCreateOneResponse {
55
55
  }
56
56
  export interface DataStorePluginWillUpdateOneResponse {
57
57
  query?: Record<string, any>;
58
+ shouldUpdate?: boolean;
58
59
  }
59
60
  export interface DataStorePluginWillDeleteOneResponse {
60
61
  query?: Record<string, any>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "25.12.0",
6
+ "version": "25.13.0",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",