@sprucelabs/data-stores 25.8.1 → 25.9.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.
@@ -323,12 +323,16 @@ export default class AbstractStore extends AbstractMutexer {
323
323
  });
324
324
  }
325
325
  deleteOne(query) {
326
- var _a;
326
+ var _a, _b;
327
327
  return __awaiter(this, void 0, void 0, function* () {
328
+ let q = Object.assign({}, query);
328
329
  for (const plugin of this.plugins) {
329
- yield ((_a = plugin.willDeleteOne) === null || _a === void 0 ? void 0 : _a.call(plugin, query));
330
+ const { query } = (_b = (yield ((_a = plugin.willDeleteOne) === null || _a === void 0 ? void 0 : _a.call(plugin, q)))) !== null && _b !== void 0 ? _b : {};
331
+ if (query) {
332
+ q = query;
333
+ }
330
334
  }
331
- return yield this.db.deleteOne(this.collectionName, query);
335
+ return yield this.db.deleteOne(this.collectionName, q);
332
336
  });
333
337
  }
334
338
  delete(query) {
@@ -42,7 +42,7 @@ export type TestConnect = (connectionString?: string, dbName?: string) => Promis
42
42
  export interface DataStorePlugin {
43
43
  willCreateOne?: (values: Record<string, any>) => Promise<void | DataStorePluginHookResponse>;
44
44
  willUpdateOne?: (query: Record<string, any>, updates: Record<string, any>) => Promise<void | DataStorePluginWillUpdateOneResponse>;
45
- willDeleteOne?: (query: Record<string, any>) => Promise<void>;
45
+ willDeleteOne?: (query: Record<string, any>) => Promise<void | DataStorePluginWillDeleteOneResponse>;
46
46
  getName(): string;
47
47
  }
48
48
  export interface DataStorePluginHookResponse {
@@ -51,3 +51,6 @@ export interface DataStorePluginHookResponse {
51
51
  export interface DataStorePluginWillUpdateOneResponse {
52
52
  query?: Record<string, any>;
53
53
  }
54
+ export interface DataStorePluginWillDeleteOneResponse {
55
+ query?: Record<string, any>;
56
+ }
@@ -316,11 +316,15 @@ class AbstractStore extends AbstractMutexer_1.default {
316
316
  return cleanedValues;
317
317
  }
318
318
  async deleteOne(query) {
319
- var _a;
319
+ var _a, _b;
320
+ let q = Object.assign({}, query);
320
321
  for (const plugin of this.plugins) {
321
- await ((_a = plugin.willDeleteOne) === null || _a === void 0 ? void 0 : _a.call(plugin, query));
322
+ const { query } = (_b = (await ((_a = plugin.willDeleteOne) === null || _a === void 0 ? void 0 : _a.call(plugin, q)))) !== null && _b !== void 0 ? _b : {};
323
+ if (query) {
324
+ q = query;
325
+ }
322
326
  }
323
- return await this.db.deleteOne(this.collectionName, query);
327
+ return await this.db.deleteOne(this.collectionName, q);
324
328
  }
325
329
  async delete(query) {
326
330
  return await this.db.delete(this.collectionName, query);
@@ -42,7 +42,7 @@ export type TestConnect = (connectionString?: string, dbName?: string) => Promis
42
42
  export interface DataStorePlugin {
43
43
  willCreateOne?: (values: Record<string, any>) => Promise<void | DataStorePluginHookResponse>;
44
44
  willUpdateOne?: (query: Record<string, any>, updates: Record<string, any>) => Promise<void | DataStorePluginWillUpdateOneResponse>;
45
- willDeleteOne?: (query: Record<string, any>) => Promise<void>;
45
+ willDeleteOne?: (query: Record<string, any>) => Promise<void | DataStorePluginWillDeleteOneResponse>;
46
46
  getName(): string;
47
47
  }
48
48
  export interface DataStorePluginHookResponse {
@@ -51,3 +51,6 @@ export interface DataStorePluginHookResponse {
51
51
  export interface DataStorePluginWillUpdateOneResponse {
52
52
  query?: Record<string, any>;
53
53
  }
54
+ export interface DataStorePluginWillDeleteOneResponse {
55
+ query?: Record<string, any>;
56
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "25.8.1",
6
+ "version": "25.9.0",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",