@proteinjs/db 1.16.0 → 1.17.1

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.
@@ -117,7 +117,8 @@ export class TableWatcherRunner<R extends Record = Record> {
117
117
  async runBeforeDeleteTableWatchers<T extends R>(
118
118
  table: Table<T>,
119
119
  recordsToDelete: T[],
120
- qb: QueryBuilder<T>
120
+ initialQb: QueryBuilder<T>,
121
+ deleteQb: QueryBuilder<T>
121
122
  ): Promise<void> {
122
123
  const tableWatcherMap = TableWatcherRunner.tableWatcherMap[table.name];
123
124
  if (!tableWatcherMap) {
@@ -130,10 +131,10 @@ export class TableWatcherRunner<R extends Record = Record> {
130
131
  }
131
132
 
132
133
  this.logger.info({ message: `(${table.name}) Running before-delete table watchers` });
133
- const qbCopy = QueryBuilder.fromQueryBuilder(qb, table.name);
134
+ const initialQbCopy = QueryBuilder.fromQueryBuilder(initialQb, table.name);
134
135
  for (const tableWatcher of tableWatchers) {
135
136
  this.logger.info({ message: `(${table.name}) Running ${tableWatcher.name()}.beforeDelete` });
136
- await tableWatcher.beforeDelete(recordsToDelete, qbCopy);
137
+ await tableWatcher.beforeDelete(recordsToDelete, initialQbCopy, deleteQb);
137
138
  this.logger.info({ message: `(${table.name}) Finished running ${tableWatcher.name()}.beforeDelete` });
138
139
  }
139
140
  this.logger.info({ message: `(${table.name}) Finished running before-delete table watchers` });
@@ -143,7 +144,8 @@ export class TableWatcherRunner<R extends Record = Record> {
143
144
  table: Table<T>,
144
145
  recordDeleteCount: number,
145
146
  deletedRecords: T[],
146
- qb: QueryBuilder<T>
147
+ initialQb: QueryBuilder<T>,
148
+ deleteQb: QueryBuilder<T>
147
149
  ): Promise<void> {
148
150
  const tableWatcherMap = TableWatcherRunner.tableWatcherMap[table.name];
149
151
  if (!tableWatcherMap) {
@@ -156,10 +158,10 @@ export class TableWatcherRunner<R extends Record = Record> {
156
158
  }
157
159
 
158
160
  this.logger.info({ message: `(${table.name}) Running after-delete table watchers` });
159
- const qbCopy = QueryBuilder.fromQueryBuilder(qb, table.name);
161
+ const initialQbCopy = QueryBuilder.fromQueryBuilder(initialQb, table.name);
160
162
  for (const tableWatcher of tableWatchers) {
161
163
  this.logger.info({ message: `(${table.name}) Running ${tableWatcher.name()}.afterDelete` });
162
- await tableWatcher.afterDelete(recordDeleteCount, deletedRecords, qbCopy);
164
+ await tableWatcher.afterDelete(recordDeleteCount, deletedRecords, initialQbCopy, deleteQb);
163
165
  this.logger.info({ message: `(${table.name}) Finished running ${tableWatcher.name()}.afterDelete` });
164
166
  }
165
167
  this.logger.info({ message: `(${table.name}) Finished running after-delete table watchers` });
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Brent Bahry
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,13 +0,0 @@
1
- import { ThirdPartyLibCustomSerializer } from '@proteinjs/serializer';
2
- import { Graph } from '@proteinjs/util';
3
- type SerializedGraph = {
4
- value: string;
5
- };
6
- export declare class GraphSerializer implements ThirdPartyLibCustomSerializer {
7
- id: string;
8
- matches(obj: any): boolean;
9
- serialize(graph: Graph): SerializedGraph;
10
- deserialize(serializedGraph: SerializedGraph): Graph;
11
- }
12
- export {};
13
- //# sourceMappingURL=GraphSerializer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GraphSerializer.d.ts","sourceRoot":"","sources":["../../../src/serializers/GraphSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAmB,KAAK,EAAgB,MAAM,iBAAiB,CAAC;AAEvE,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,eAAgB,YAAW,6BAA6B;IACnE,EAAE,SAA2C;IAE7C,OAAO,CAAC,GAAG,EAAE,GAAG;IAIhB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe;IAIxC,WAAW,CAAC,eAAe,EAAE,eAAe,GAAG,KAAK;CAGrD"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraphSerializer = void 0;
4
- var util_1 = require("@proteinjs/util");
5
- var GraphSerializer = /** @class */ (function () {
6
- function GraphSerializer() {
7
- this.id = '@proteinjs/serializer/GraphSerializer';
8
- }
9
- GraphSerializer.prototype.matches = function (obj) {
10
- return (0, util_1.isInstanceOf)(obj, util_1.Graph);
11
- };
12
- GraphSerializer.prototype.serialize = function (graph) {
13
- return { value: util_1.graphSerializer.serialize(graph) };
14
- };
15
- GraphSerializer.prototype.deserialize = function (serializedGraph) {
16
- return util_1.graphSerializer.deserialize(serializedGraph.value);
17
- };
18
- return GraphSerializer;
19
- }());
20
- exports.GraphSerializer = GraphSerializer;
21
- //# sourceMappingURL=GraphSerializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GraphSerializer.js","sourceRoot":"","sources":["../../../src/serializers/GraphSerializer.ts"],"names":[],"mappings":";;;AACA,wCAAuE;AAMvE;IAAA;QACE,OAAE,GAAG,uCAAuC,CAAC;IAa/C,CAAC;IAXC,iCAAO,GAAP,UAAQ,GAAQ;QACd,OAAO,IAAA,mBAAY,EAAC,GAAG,EAAE,YAAK,CAAC,CAAC;IAClC,CAAC;IAED,mCAAS,GAAT,UAAU,KAAY;QACpB,OAAO,EAAE,KAAK,EAAE,sBAAe,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;IACrD,CAAC;IAED,qCAAW,GAAX,UAAY,eAAgC;QAC1C,OAAO,sBAAe,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IACH,sBAAC;AAAD,CAAC,AAdD,IAcC;AAdY,0CAAe"}
@@ -1,19 +0,0 @@
1
- import { CustomSerializer } from '@proteinjs/serializer';
2
- import { Graph } from '@proteinjs/util';
3
- import { QueryBuilder } from '@proteinjs/db-query';
4
- type SerializedQueryBuilder = {
5
- tableName: string;
6
- graph: Graph;
7
- idCounter: number;
8
- rootId: string;
9
- currentContextIds: string[];
10
- paginationNodeId?: string;
11
- };
12
- export declare const QueryBuilderSerializerId = "@proteinjs/db/QueryBuilderSerializer";
13
- export declare class QueryBuilderSerializer implements CustomSerializer {
14
- id: string;
15
- serialize(qb: QueryBuilder<any>): SerializedQueryBuilder;
16
- deserialize(serializedQb: SerializedQueryBuilder): QueryBuilder<any>;
17
- }
18
- export {};
19
- //# sourceMappingURL=QueryBuilderSerializer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryBuilderSerializer.d.ts","sourceRoot":"","sources":["../../../src/serializers/QueryBuilderSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,wBAAwB,yCAAyC,CAAC;AAE/E,qBAAa,sBAAuB,YAAW,gBAAgB;IAC7D,EAAE,SAA4B;IAE9B,SAAS,CAAC,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,sBAAsB;IAWxD,WAAW,CAAC,YAAY,EAAE,sBAAsB,GAAG,YAAY,CAAC,GAAG,CAAC;CASrE"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryBuilderSerializer = exports.QueryBuilderSerializerId = void 0;
4
- var db_query_1 = require("@proteinjs/db-query");
5
- exports.QueryBuilderSerializerId = '@proteinjs/db/QueryBuilderSerializer';
6
- var QueryBuilderSerializer = /** @class */ (function () {
7
- function QueryBuilderSerializer() {
8
- this.id = exports.QueryBuilderSerializerId;
9
- }
10
- QueryBuilderSerializer.prototype.serialize = function (qb) {
11
- return {
12
- tableName: qb.tableName,
13
- graph: qb.graph,
14
- idCounter: qb.idCounter,
15
- rootId: qb.rootId,
16
- currentContextIds: qb.currentContextIds,
17
- paginationNodeId: qb.paginationNodeId,
18
- };
19
- };
20
- QueryBuilderSerializer.prototype.deserialize = function (serializedQb) {
21
- var qb = new db_query_1.QueryBuilder(serializedQb.tableName);
22
- qb.graph = serializedQb.graph;
23
- qb.idCounter = serializedQb.idCounter;
24
- qb.rootId = serializedQb.rootId;
25
- qb.currentContextIds = serializedQb.currentContextIds;
26
- qb.paginationNodeId = serializedQb.paginationNodeId;
27
- return qb;
28
- };
29
- return QueryBuilderSerializer;
30
- }());
31
- exports.QueryBuilderSerializer = QueryBuilderSerializer;
32
- //# sourceMappingURL=QueryBuilderSerializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryBuilderSerializer.js","sourceRoot":"","sources":["../../../src/serializers/QueryBuilderSerializer.ts"],"names":[],"mappings":";;;AAEA,gDAAmD;AAWtC,QAAA,wBAAwB,GAAG,sCAAsC,CAAC;AAE/E;IAAA;QACE,OAAE,GAAG,gCAAwB,CAAC;IAsBhC,CAAC;IApBC,0CAAS,GAAT,UAAU,EAAqB;QAC7B,OAAO;YACL,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,MAAM,EAAE,EAAE,CAAC,MAAM;YACjB,iBAAiB,EAAE,EAAE,CAAC,iBAAiB;YACvC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB;SACtC,CAAC;IACJ,CAAC;IAED,4CAAW,GAAX,UAAY,YAAoC;QAC9C,IAAM,EAAE,GAAG,IAAI,uBAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACpD,EAAE,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QAC9B,EAAE,CAAC,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC;QACtC,EAAE,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;QAChC,EAAE,CAAC,iBAAiB,GAAG,YAAY,CAAC,iBAAiB,CAAC;QACtD,EAAE,CAAC,gBAAgB,GAAG,YAAY,CAAC,gBAAgB,CAAC;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,6BAAC;AAAD,CAAC,AAvBD,IAuBC;AAvBY,wDAAsB"}
@@ -1,22 +0,0 @@
1
- import { ThirdPartyLibCustomSerializer } from '@proteinjs/serializer';
2
- import { graphSerializer, Graph, isInstanceOf } from '@proteinjs/util';
3
-
4
- type SerializedGraph = {
5
- value: string;
6
- };
7
-
8
- export class GraphSerializer implements ThirdPartyLibCustomSerializer {
9
- id = '@proteinjs/serializer/GraphSerializer';
10
-
11
- matches(obj: any) {
12
- return isInstanceOf(obj, Graph);
13
- }
14
-
15
- serialize(graph: Graph): SerializedGraph {
16
- return { value: graphSerializer.serialize(graph) };
17
- }
18
-
19
- deserialize(serializedGraph: SerializedGraph): Graph {
20
- return graphSerializer.deserialize(serializedGraph.value);
21
- }
22
- }
@@ -1,39 +0,0 @@
1
- import { CustomSerializer } from '@proteinjs/serializer';
2
- import { Graph } from '@proteinjs/util';
3
- import { QueryBuilder } from '@proteinjs/db-query';
4
-
5
- type SerializedQueryBuilder = {
6
- tableName: string;
7
- graph: Graph;
8
- idCounter: number;
9
- rootId: string;
10
- currentContextIds: string[];
11
- paginationNodeId?: string;
12
- };
13
-
14
- export const QueryBuilderSerializerId = '@proteinjs/db/QueryBuilderSerializer';
15
-
16
- export class QueryBuilderSerializer implements CustomSerializer {
17
- id = QueryBuilderSerializerId;
18
-
19
- serialize(qb: QueryBuilder<any>): SerializedQueryBuilder {
20
- return {
21
- tableName: qb.tableName,
22
- graph: qb.graph,
23
- idCounter: qb.idCounter,
24
- rootId: qb.rootId,
25
- currentContextIds: qb.currentContextIds,
26
- paginationNodeId: qb.paginationNodeId,
27
- };
28
- }
29
-
30
- deserialize(serializedQb: SerializedQueryBuilder): QueryBuilder<any> {
31
- const qb = new QueryBuilder(serializedQb.tableName);
32
- qb.graph = serializedQb.graph;
33
- qb.idCounter = serializedQb.idCounter;
34
- qb.rootId = serializedQb.rootId;
35
- qb.currentContextIds = serializedQb.currentContextIds;
36
- qb.paginationNodeId = serializedQb.paginationNodeId;
37
- return qb;
38
- }
39
- }