ts-patch-mongoose 2.6.1 → 2.6.3
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/README.md +19 -15
- package/dist/cjs/patch.js +25 -20
- package/dist/cjs/patch.js.map +1 -1
- package/dist/cjs/types/em.d.ts +0 -1
- package/dist/cjs/types/em.d.ts.map +1 -1
- package/dist/cjs/types/helpers.d.ts +0 -25
- package/dist/cjs/types/helpers.d.ts.map +1 -1
- package/dist/cjs/types/hooks/delete-hooks.d.ts +0 -25
- package/dist/cjs/types/hooks/delete-hooks.d.ts.map +1 -1
- package/dist/cjs/types/hooks/save-hooks.d.ts +0 -25
- package/dist/cjs/types/hooks/save-hooks.d.ts.map +1 -1
- package/dist/cjs/types/hooks/update-hooks.d.ts +0 -25
- package/dist/cjs/types/hooks/update-hooks.d.ts.map +1 -1
- package/dist/cjs/types/interfaces/IContext.d.ts +0 -25
- package/dist/cjs/types/interfaces/IContext.d.ts.map +1 -1
- package/dist/cjs/types/interfaces/IEvent.d.ts +0 -25
- package/dist/cjs/types/interfaces/IEvent.d.ts.map +1 -1
- package/dist/cjs/types/interfaces/IHistory.d.ts +0 -25
- package/dist/cjs/types/interfaces/IHistory.d.ts.map +1 -1
- package/dist/cjs/types/interfaces/IHookContext.d.ts +0 -25
- package/dist/cjs/types/interfaces/IHookContext.d.ts.map +1 -1
- package/dist/cjs/types/interfaces/IPluginOptions.d.ts +0 -25
- package/dist/cjs/types/interfaces/IPluginOptions.d.ts.map +1 -1
- package/dist/cjs/types/models/History.d.ts +0 -25
- package/dist/cjs/types/models/History.d.ts.map +1 -1
- package/dist/cjs/types/patch.d.ts +2 -29
- package/dist/cjs/types/patch.d.ts.map +1 -1
- package/dist/cjs/types/plugin.d.ts +12 -38
- package/dist/cjs/types/plugin.d.ts.map +1 -1
- package/dist/esm/patch.js +13 -8
- package/dist/esm/patch.js.map +1 -1
- package/dist/esm/types/em.d.ts +0 -1
- package/dist/esm/types/em.d.ts.map +1 -1
- package/dist/esm/types/helpers.d.ts +0 -25
- package/dist/esm/types/helpers.d.ts.map +1 -1
- package/dist/esm/types/hooks/delete-hooks.d.ts +0 -25
- package/dist/esm/types/hooks/delete-hooks.d.ts.map +1 -1
- package/dist/esm/types/hooks/save-hooks.d.ts +0 -25
- package/dist/esm/types/hooks/save-hooks.d.ts.map +1 -1
- package/dist/esm/types/hooks/update-hooks.d.ts +0 -25
- package/dist/esm/types/hooks/update-hooks.d.ts.map +1 -1
- package/dist/esm/types/interfaces/IContext.d.ts +0 -25
- package/dist/esm/types/interfaces/IContext.d.ts.map +1 -1
- package/dist/esm/types/interfaces/IEvent.d.ts +0 -25
- package/dist/esm/types/interfaces/IEvent.d.ts.map +1 -1
- package/dist/esm/types/interfaces/IHistory.d.ts +0 -25
- package/dist/esm/types/interfaces/IHistory.d.ts.map +1 -1
- package/dist/esm/types/interfaces/IHookContext.d.ts +0 -25
- package/dist/esm/types/interfaces/IHookContext.d.ts.map +1 -1
- package/dist/esm/types/interfaces/IPluginOptions.d.ts +0 -25
- package/dist/esm/types/interfaces/IPluginOptions.d.ts.map +1 -1
- package/dist/esm/types/models/History.d.ts +0 -25
- package/dist/esm/types/models/History.d.ts.map +1 -1
- package/dist/esm/types/patch.d.ts +2 -29
- package/dist/esm/types/patch.d.ts.map +1 -1
- package/dist/esm/types/plugin.d.ts +12 -38
- package/dist/esm/types/plugin.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/patch.ts +16 -8
- package/tests/patch.test.ts +7 -3
- package/tests/plugin-event-deleted.test.ts +1 -1
- package/tests/plugin-global.test.ts +20 -20
- package/tests/plugin-omit-all.test.ts +50 -50
- package/tests/plugin-pre-save.test.ts +53 -0
- package/tests/plugin.test.ts +44 -44
|
@@ -1,37 +1,10 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
-
/// <reference types="mongoose/types/callback" />
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
-
/// <reference types="mongoose/types/session" />
|
|
20
|
-
/// <reference types="mongoose/types/types" />
|
|
21
|
-
/// <reference types="mongoose/types/utility" />
|
|
22
|
-
/// <reference types="mongoose/types/validation" />
|
|
23
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
1
|
import type { HydratedDocument } from 'mongoose';
|
|
27
2
|
import type IEvent from './interfaces/IEvent';
|
|
28
3
|
import type IContext from './interfaces/IContext';
|
|
29
4
|
import type IPluginOptions from './interfaces/IPluginOptions';
|
|
30
5
|
import type { User, Metadata } from './interfaces/IPluginOptions';
|
|
31
|
-
export declare function
|
|
32
|
-
|
|
33
|
-
originalObject: Partial<T>;
|
|
34
|
-
};
|
|
6
|
+
export declare function getJsonOmit<T>(opts: IPluginOptions<T>, doc: HydratedDocument<T>): Partial<T>;
|
|
7
|
+
export declare function getObjectOmit<T>(opts: IPluginOptions<T>, doc: HydratedDocument<T>): Partial<T>;
|
|
35
8
|
export declare function getUser<T>(opts: IPluginOptions<T>): Promise<User | undefined>;
|
|
36
9
|
export declare function getReason<T>(opts: IPluginOptions<T>): Promise<string | undefined>;
|
|
37
10
|
export declare function getMetadata<T>(opts: IPluginOptions<T>): Promise<Metadata | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../src/patch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../src/patch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,UAAU,CAAA;AAEvD,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAA;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AASjE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ5F;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAO9F;AAED,wBAAsB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAKnF;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAKvF;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAK3F;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAExE;AAED,wBAAsB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC,CAU/H;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAInG;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,GAAG,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAwClL;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjG;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAmC9J;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjG"}
|
|
@@ -1,48 +1,22 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="mongoose/types/aggregate" />
|
|
3
|
-
/// <reference types="mongoose/types/callback" />
|
|
4
|
-
/// <reference types="mongoose/types/collection" />
|
|
5
|
-
/// <reference types="mongoose/types/connection" />
|
|
6
|
-
/// <reference types="mongoose/types/cursor" />
|
|
7
|
-
/// <reference types="mongoose/types/document" />
|
|
8
|
-
/// <reference types="mongoose/types/error" />
|
|
9
|
-
/// <reference types="mongoose/types/expressions" />
|
|
10
|
-
/// <reference types="mongoose/types/helpers" />
|
|
11
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
12
|
-
/// <reference types="mongoose/types/indexes" />
|
|
13
|
-
/// <reference types="mongoose/types/models" />
|
|
14
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
15
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
16
|
-
/// <reference types="mongoose/types/populate" />
|
|
17
|
-
/// <reference types="mongoose/types/query" />
|
|
18
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
19
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
20
|
-
/// <reference types="mongoose/types/session" />
|
|
21
|
-
/// <reference types="mongoose/types/types" />
|
|
22
|
-
/// <reference types="mongoose/types/utility" />
|
|
23
|
-
/// <reference types="mongoose/types/validation" />
|
|
24
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
25
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
26
|
-
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
27
1
|
import type { Schema } from 'mongoose';
|
|
28
2
|
import type IPluginOptions from './interfaces/IPluginOptions';
|
|
29
3
|
export declare const patchEventEmitter: {
|
|
30
4
|
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
|
|
31
|
-
addListener<
|
|
32
|
-
on<
|
|
33
|
-
once<
|
|
34
|
-
removeListener<
|
|
35
|
-
off<
|
|
5
|
+
addListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
6
|
+
on<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
7
|
+
once<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
8
|
+
removeListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
9
|
+
off<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
36
10
|
removeAllListeners(eventName?: string | symbol | undefined): any;
|
|
37
11
|
setMaxListeners(n: number): any;
|
|
38
12
|
getMaxListeners(): number;
|
|
39
|
-
listeners<
|
|
40
|
-
rawListeners<
|
|
41
|
-
emit<
|
|
42
|
-
listenerCount<
|
|
43
|
-
prependListener<
|
|
44
|
-
prependOnceListener<
|
|
45
|
-
eventNames(): (string | symbol)
|
|
13
|
+
listeners<K>(eventName: string | symbol): Array<Function>;
|
|
14
|
+
rawListeners<K>(eventName: string | symbol): Array<Function>;
|
|
15
|
+
emit<K>(eventName: string | symbol, ...args: any[]): boolean;
|
|
16
|
+
listenerCount<K>(eventName: string | symbol, listener?: Function | undefined): number;
|
|
17
|
+
prependListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
18
|
+
prependOnceListener<K>(eventName: string | symbol, listener: (...args: any[]) => void): any;
|
|
19
|
+
eventNames(): Array<(string | symbol) & (string | symbol)>;
|
|
46
20
|
};
|
|
47
21
|
export declare const patchHistoryPlugin: <T>(schema: Schema<T>, opts: IPluginOptions<T>) => void;
|
|
48
22
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugin.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAA2B,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAA;AAQ7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAAK,CAAA;AAQnC,eAAO,MAAM,kBAAkB,GAAmB,CAAC,UAAU,MAAM,CAAC,CAAC,CAAC,QAAQ,cAAc,CAAC,CAAC,CAAC,KAAG,IA+CjG,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-patch-mongoose",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "Patch history & events for mongoose models",
|
|
5
5
|
"author": "Alex Eagle",
|
|
6
6
|
"license": "MIT",
|
|
@@ -85,27 +85,27 @@
|
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@shelf/jest-mongodb": "4.3.2",
|
|
88
|
-
"@stylistic/eslint-plugin": "2.
|
|
89
|
-
"@swc/cli": "0.
|
|
90
|
-
"@swc/core": "1.
|
|
88
|
+
"@stylistic/eslint-plugin": "2.3.0",
|
|
89
|
+
"@swc/cli": "0.4.0",
|
|
90
|
+
"@swc/core": "1.6.7",
|
|
91
91
|
"@swc/helpers": "0.5.11",
|
|
92
92
|
"@swc/jest": "0.2.36",
|
|
93
93
|
"@swc/register": "0.1.10",
|
|
94
94
|
"@types/jest": "29.5.12",
|
|
95
|
-
"@types/lodash": "4.17.
|
|
95
|
+
"@types/lodash": "4.17.6",
|
|
96
96
|
"@types/node": "20",
|
|
97
97
|
"@types/semver": "7.5.8",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "7.
|
|
99
|
-
"@typescript-eslint/parser": "7.
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "7.15.0",
|
|
99
|
+
"@typescript-eslint/parser": "7.15.0",
|
|
100
100
|
"eslint": "8.57.0",
|
|
101
|
-
"eslint-plugin-jest": "28.
|
|
101
|
+
"eslint-plugin-jest": "28.6.0",
|
|
102
102
|
"eslint-plugin-jest-formatting": "3.1.0",
|
|
103
103
|
"eslint-plugin-sonarjs": "0.25.1",
|
|
104
104
|
"jest": "29.7.0",
|
|
105
105
|
"merge": "2.1.1",
|
|
106
|
-
"mongoose": "8.4.
|
|
106
|
+
"mongoose": "8.4.5",
|
|
107
107
|
"open-cli": "8.0.0",
|
|
108
|
-
"typescript": "5.
|
|
108
|
+
"typescript": "5.5.3"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
111
|
"mongoose": ">=6.6.0 < 9"
|
package/src/patch.ts
CHANGED
|
@@ -16,16 +16,23 @@ function isPatchHistoryEnabled<T>(opts: IPluginOptions<T>, context: IContext<T>)
|
|
|
16
16
|
return !opts.patchHistoryDisabled && !context.ignorePatchHistory
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function
|
|
20
|
-
|
|
21
|
-
let originalObject = JSON.parse(JSON.stringify(original)) as Partial<T>
|
|
19
|
+
export function getJsonOmit<T>(opts: IPluginOptions<T>, doc: HydratedDocument<T>): Partial<T> {
|
|
20
|
+
const object = JSON.parse(JSON.stringify(doc)) as Partial<T>
|
|
22
21
|
|
|
23
22
|
if (opts.omit) {
|
|
24
|
-
|
|
25
|
-
originalObject = omit(originalObject, opts.omit)
|
|
23
|
+
return omit(object, opts.omit)
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
return
|
|
26
|
+
return object
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getObjectOmit<T>(opts: IPluginOptions<T>, doc: HydratedDocument<T>): Partial<T> {
|
|
30
|
+
if (opts.omit) {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/unbound-method
|
|
32
|
+
return omit(_.isFunction(doc?.toObject) ? doc.toObject() : doc, opts.omit)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return doc
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
export async function getUser<T>(opts: IPluginOptions<T>): Promise<User | undefined> {
|
|
@@ -96,7 +103,7 @@ export async function bulkPatch<T>(opts: IPluginOptions<T>, context: IContext<T>
|
|
|
96
103
|
modelName: context.modelName,
|
|
97
104
|
collectionName: context.collectionName,
|
|
98
105
|
collectionId: doc._id as Types.ObjectId,
|
|
99
|
-
doc,
|
|
106
|
+
doc: getObjectOmit(opts, doc),
|
|
100
107
|
user,
|
|
101
108
|
reason,
|
|
102
109
|
metadata,
|
|
@@ -120,7 +127,8 @@ export async function createPatch<T>(opts: IPluginOptions<T>, context: IContext<
|
|
|
120
127
|
export async function updatePatch<T>(opts: IPluginOptions<T>, context: IContext<T>, current: HydratedDocument<T>, original: HydratedDocument<T>): Promise<void> {
|
|
121
128
|
const history = isPatchHistoryEnabled(opts, context)
|
|
122
129
|
|
|
123
|
-
const
|
|
130
|
+
const currentObject = getJsonOmit(opts, current)
|
|
131
|
+
const originalObject = getJsonOmit(opts, original)
|
|
124
132
|
if (_.isEmpty(originalObject) || _.isEmpty(currentObject)) return
|
|
125
133
|
|
|
126
134
|
const patch = jsonpatch.compare(originalObject, currentObject, true)
|
package/tests/patch.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import mongoose, { model } from 'mongoose'
|
|
2
2
|
|
|
3
|
-
import { getUser, getReason, getMetadata, getData, getValue,
|
|
3
|
+
import { getUser, getReason, getMetadata, getData, getValue, getJsonOmit, bulkPatch, updatePatch } from '../src/patch'
|
|
4
4
|
import { patchHistoryPlugin } from '../src/plugin'
|
|
5
5
|
|
|
6
6
|
import UserSchema from './schemas/UserSchema'
|
|
@@ -53,7 +53,8 @@ describe('patch tests', () => {
|
|
|
53
53
|
omit: ['createdAt'],
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const
|
|
56
|
+
const currentObject = getJsonOmit(pluginOptions, current)
|
|
57
|
+
const originalObject = getJsonOmit(pluginOptions, original)
|
|
57
58
|
|
|
58
59
|
expect(currentObject.name).toBe('John')
|
|
59
60
|
expect(currentObject.role).toBe('admin')
|
|
@@ -68,7 +69,10 @@ describe('patch tests', () => {
|
|
|
68
69
|
const original = await User.create({ name: 'John', role: 'user' })
|
|
69
70
|
const current = await User.create({ name: 'John', role: 'admin' })
|
|
70
71
|
|
|
71
|
-
const
|
|
72
|
+
const pluginOptions = {}
|
|
73
|
+
|
|
74
|
+
const currentObject = getJsonOmit(pluginOptions, current)
|
|
75
|
+
const originalObject = getJsonOmit(pluginOptions, original)
|
|
72
76
|
|
|
73
77
|
expect(currentObject.name).toBe('John')
|
|
74
78
|
expect(currentObject.role).toBe('admin')
|
|
@@ -137,7 +137,7 @@ describe('plugin - event delete & patch history disabled', () => {
|
|
|
137
137
|
|
|
138
138
|
const [john] = users
|
|
139
139
|
|
|
140
|
-
await User.findOneAndDelete({
|
|
140
|
+
await User.findOneAndDelete({ name: 'John' }).exec()
|
|
141
141
|
|
|
142
142
|
const history = await History.find({})
|
|
143
143
|
expect(history).toHaveLength(0)
|
|
@@ -64,8 +64,8 @@ describe('plugin - global', () => {
|
|
|
64
64
|
expect(first.doc).toHaveProperty('_id', product._id)
|
|
65
65
|
expect(first.doc).toHaveProperty('name', 'paper')
|
|
66
66
|
expect(first.doc).toHaveProperty('groups', [])
|
|
67
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
68
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
67
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
68
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
69
69
|
|
|
70
70
|
expect(first.patch).toHaveLength(0)
|
|
71
71
|
|
|
@@ -138,8 +138,8 @@ describe('plugin - global', () => {
|
|
|
138
138
|
expect(first.doc).toHaveProperty('_id', product._id)
|
|
139
139
|
expect(first.doc).toHaveProperty('name', 'paper')
|
|
140
140
|
expect(first.doc).toHaveProperty('groups', [])
|
|
141
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
142
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
141
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
142
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
143
143
|
|
|
144
144
|
expect(first.patch).toHaveLength(0)
|
|
145
145
|
|
|
@@ -210,8 +210,8 @@ describe('plugin - global', () => {
|
|
|
210
210
|
expect(first.doc).toHaveProperty('_id', product._id)
|
|
211
211
|
expect(first.doc).toHaveProperty('name', 'paper')
|
|
212
212
|
expect(first.doc).toHaveProperty('description', { summary: 'test1' })
|
|
213
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
214
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
213
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
214
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
215
215
|
|
|
216
216
|
expect(first.patch).toHaveLength(0)
|
|
217
217
|
|
|
@@ -286,8 +286,8 @@ describe('plugin - global', () => {
|
|
|
286
286
|
expect(first.doc).toHaveProperty('_id', product._id)
|
|
287
287
|
expect(first.doc).toHaveProperty('name', 'paper')
|
|
288
288
|
expect(first.doc).toHaveProperty('description', { summary: 'test1' })
|
|
289
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
290
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
289
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
290
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
291
291
|
|
|
292
292
|
expect(first.patch).toHaveLength(0)
|
|
293
293
|
|
|
@@ -361,8 +361,8 @@ describe('plugin - global', () => {
|
|
|
361
361
|
expect(first.doc).toHaveProperty('_id', john._id)
|
|
362
362
|
expect(first.doc).toHaveProperty('name', 'John')
|
|
363
363
|
expect(first.doc).toHaveProperty('role', 'user')
|
|
364
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
365
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
364
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
365
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
366
366
|
|
|
367
367
|
expect(first.patch).toHaveLength(0)
|
|
368
368
|
|
|
@@ -377,8 +377,8 @@ describe('plugin - global', () => {
|
|
|
377
377
|
expect(second.doc).toHaveProperty('_id', alice._id)
|
|
378
378
|
expect(second.doc).toHaveProperty('name', 'Alice')
|
|
379
379
|
expect(second.doc).toHaveProperty('role', 'user')
|
|
380
|
-
expect(second.doc).toHaveProperty('createdAt')
|
|
381
|
-
expect(second.doc).toHaveProperty('updatedAt')
|
|
380
|
+
expect(second.doc).not.toHaveProperty('createdAt')
|
|
381
|
+
expect(second.doc).not.toHaveProperty('updatedAt')
|
|
382
382
|
|
|
383
383
|
expect(second.patch).toHaveLength(0)
|
|
384
384
|
|
|
@@ -392,8 +392,8 @@ describe('plugin - global', () => {
|
|
|
392
392
|
expect(third.doc).toHaveProperty('_id', product._id)
|
|
393
393
|
expect(third.doc).toHaveProperty('name', 'paper')
|
|
394
394
|
expect(third.doc).toHaveProperty('addedBy', john._id)
|
|
395
|
-
expect(third.doc).toHaveProperty('createdAt')
|
|
396
|
-
expect(third.doc).toHaveProperty('updatedAt')
|
|
395
|
+
expect(third.doc).not.toHaveProperty('createdAt')
|
|
396
|
+
expect(third.doc).not.toHaveProperty('updatedAt')
|
|
397
397
|
|
|
398
398
|
expect(third.patch).toHaveLength(0)
|
|
399
399
|
|
|
@@ -454,8 +454,8 @@ describe('plugin - global', () => {
|
|
|
454
454
|
expect(first.doc).toHaveProperty('_id', john._id)
|
|
455
455
|
expect(first.doc).toHaveProperty('name', 'John')
|
|
456
456
|
expect(first.doc).toHaveProperty('role', 'user')
|
|
457
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
458
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
457
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
458
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
459
459
|
|
|
460
460
|
expect(first.patch).toHaveLength(0)
|
|
461
461
|
|
|
@@ -470,8 +470,8 @@ describe('plugin - global', () => {
|
|
|
470
470
|
expect(second.doc).toHaveProperty('_id', alice._id)
|
|
471
471
|
expect(second.doc).toHaveProperty('name', 'Alice')
|
|
472
472
|
expect(second.doc).toHaveProperty('role', 'user')
|
|
473
|
-
expect(
|
|
474
|
-
expect(
|
|
473
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
474
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
475
475
|
|
|
476
476
|
expect(second.patch).toHaveLength(0)
|
|
477
477
|
|
|
@@ -485,8 +485,8 @@ describe('plugin - global', () => {
|
|
|
485
485
|
expect(third.doc).toHaveProperty('_id', product._id)
|
|
486
486
|
expect(third.doc).toHaveProperty('name', 'paper')
|
|
487
487
|
expect(third.doc).toHaveProperty('addedBy', john._id)
|
|
488
|
-
expect(
|
|
489
|
-
expect(
|
|
488
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
489
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
490
490
|
|
|
491
491
|
expect(third.patch).toHaveLength(0)
|
|
492
492
|
|
|
@@ -58,10 +58,10 @@ describe('plugin - omit all', () => {
|
|
|
58
58
|
expect(first.version).toBe(0)
|
|
59
59
|
expect(first.patch).toHaveLength(0)
|
|
60
60
|
|
|
61
|
-
expect(first.doc).toHaveProperty('name'
|
|
62
|
-
expect(first.doc).toHaveProperty('role'
|
|
63
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
64
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
61
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
62
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
63
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
64
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
65
65
|
expect(first.doc).toHaveProperty('_id', user._id)
|
|
66
66
|
|
|
67
67
|
expect(second.op).toBe('deleteMany')
|
|
@@ -71,10 +71,10 @@ describe('plugin - omit all', () => {
|
|
|
71
71
|
expect(second.version).toBe(0)
|
|
72
72
|
expect(second.patch).toHaveLength(0)
|
|
73
73
|
|
|
74
|
-
expect(second.doc).toHaveProperty('name'
|
|
75
|
-
expect(second.doc).toHaveProperty('role'
|
|
76
|
-
expect(second.doc).toHaveProperty('createdAt')
|
|
77
|
-
expect(second.doc).toHaveProperty('updatedAt')
|
|
74
|
+
expect(second.doc).not.toHaveProperty('name')
|
|
75
|
+
expect(second.doc).not.toHaveProperty('role')
|
|
76
|
+
expect(second.doc).not.toHaveProperty('createdAt')
|
|
77
|
+
expect(second.doc).not.toHaveProperty('updatedAt')
|
|
78
78
|
expect(second.doc).toHaveProperty('_id', user._id)
|
|
79
79
|
|
|
80
80
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -99,10 +99,10 @@ describe('plugin - omit all', () => {
|
|
|
99
99
|
expect(first.version).toBe(0)
|
|
100
100
|
expect(first.patch).toHaveLength(0)
|
|
101
101
|
|
|
102
|
-
expect(first.doc).toHaveProperty('name'
|
|
103
|
-
expect(first.doc).toHaveProperty('role'
|
|
104
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
105
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
102
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
103
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
104
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
105
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
106
106
|
expect(first.doc).toHaveProperty('_id', user._id)
|
|
107
107
|
|
|
108
108
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -126,10 +126,10 @@ describe('plugin - omit all', () => {
|
|
|
126
126
|
expect(first.version).toBe(0)
|
|
127
127
|
expect(first.patch).toHaveLength(0)
|
|
128
128
|
|
|
129
|
-
expect(first.doc).toHaveProperty('name'
|
|
130
|
-
expect(first.doc).toHaveProperty('role'
|
|
131
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
132
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
129
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
130
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
131
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
132
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
133
133
|
expect(first.doc).toHaveProperty('_id', user._id)
|
|
134
134
|
|
|
135
135
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -153,10 +153,10 @@ describe('plugin - omit all', () => {
|
|
|
153
153
|
expect(first.version).toBe(0)
|
|
154
154
|
expect(first.patch).toHaveLength(0)
|
|
155
155
|
|
|
156
|
-
expect(first.doc).toHaveProperty('name'
|
|
157
|
-
expect(first.doc).toHaveProperty('role'
|
|
158
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
159
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
156
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
157
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
158
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
159
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
160
160
|
expect(first.doc).toHaveProperty('_id', user._id)
|
|
161
161
|
|
|
162
162
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -184,10 +184,10 @@ describe('plugin - omit all', () => {
|
|
|
184
184
|
expect(first.version).toBe(0)
|
|
185
185
|
expect(first.patch).toHaveLength(0)
|
|
186
186
|
|
|
187
|
-
expect(first.doc).toHaveProperty('name'
|
|
188
|
-
expect(first.doc).toHaveProperty('role'
|
|
189
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
190
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
187
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
188
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
189
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
190
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
191
191
|
expect(first.doc).toHaveProperty('_id', user._id)
|
|
192
192
|
|
|
193
193
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -217,10 +217,10 @@ describe('plugin - omit all', () => {
|
|
|
217
217
|
expect(first.version).toBe(0)
|
|
218
218
|
expect(first.patch).toHaveLength(0)
|
|
219
219
|
|
|
220
|
-
expect(first.doc).toHaveProperty('name'
|
|
221
|
-
expect(first.doc).toHaveProperty('role'
|
|
222
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
223
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
220
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
221
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
222
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
223
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
224
224
|
expect(first.doc).toHaveProperty('_id', john._id)
|
|
225
225
|
|
|
226
226
|
expect(second.op).toBe('create')
|
|
@@ -230,10 +230,10 @@ describe('plugin - omit all', () => {
|
|
|
230
230
|
expect(second.version).toBe(0)
|
|
231
231
|
expect(second.patch).toHaveLength(0)
|
|
232
232
|
|
|
233
|
-
expect(second.doc).toHaveProperty('name'
|
|
234
|
-
expect(second.doc).toHaveProperty('role'
|
|
235
|
-
expect(second.doc).toHaveProperty('createdAt')
|
|
236
|
-
expect(second.doc).toHaveProperty('updatedAt')
|
|
233
|
+
expect(second.doc).not.toHaveProperty('name')
|
|
234
|
+
expect(second.doc).not.toHaveProperty('role')
|
|
235
|
+
expect(second.doc).not.toHaveProperty('createdAt')
|
|
236
|
+
expect(second.doc).not.toHaveProperty('updatedAt')
|
|
237
237
|
expect(second.doc).toHaveProperty('_id', alice._id)
|
|
238
238
|
|
|
239
239
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -255,10 +255,10 @@ describe('plugin - omit all', () => {
|
|
|
255
255
|
expect(first.version).toBe(0)
|
|
256
256
|
expect(first.patch).toHaveLength(0)
|
|
257
257
|
|
|
258
|
-
expect(first.doc).toHaveProperty('name'
|
|
259
|
-
expect(first.doc).toHaveProperty('role'
|
|
260
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
261
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
258
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
259
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
260
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
261
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
262
262
|
expect(first.doc).toHaveProperty('_id')
|
|
263
263
|
|
|
264
264
|
expect(second.op).toBe('create')
|
|
@@ -268,10 +268,10 @@ describe('plugin - omit all', () => {
|
|
|
268
268
|
expect(second.version).toBe(0)
|
|
269
269
|
expect(second.patch).toHaveLength(0)
|
|
270
270
|
|
|
271
|
-
expect(second.doc).toHaveProperty('name'
|
|
272
|
-
expect(second.doc).toHaveProperty('role'
|
|
273
|
-
expect(second.doc).toHaveProperty('createdAt')
|
|
274
|
-
expect(second.doc).toHaveProperty('updatedAt')
|
|
271
|
+
expect(second.doc).not.toHaveProperty('name')
|
|
272
|
+
expect(second.doc).not.toHaveProperty('role')
|
|
273
|
+
expect(second.doc).not.toHaveProperty('createdAt')
|
|
274
|
+
expect(second.doc).not.toHaveProperty('updatedAt')
|
|
275
275
|
expect(second.doc).toHaveProperty('_id')
|
|
276
276
|
|
|
277
277
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -294,8 +294,8 @@ describe('plugin - omit all', () => {
|
|
|
294
294
|
expect(first.version).toBe(0)
|
|
295
295
|
expect(first.patch).toHaveLength(0)
|
|
296
296
|
|
|
297
|
-
expect(first.doc).toHaveProperty('name'
|
|
298
|
-
expect(first.doc).toHaveProperty('role'
|
|
297
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
298
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
299
299
|
expect(first.doc).toHaveProperty('_id')
|
|
300
300
|
|
|
301
301
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -321,10 +321,10 @@ describe('plugin - omit all', () => {
|
|
|
321
321
|
expect(first.version).toBe(0)
|
|
322
322
|
expect(first.patch).toHaveLength(0)
|
|
323
323
|
|
|
324
|
-
expect(first.doc).toHaveProperty('name'
|
|
325
|
-
expect(first.doc).toHaveProperty('role'
|
|
326
|
-
expect(first.doc).toHaveProperty('createdAt')
|
|
327
|
-
expect(first.doc).toHaveProperty('updatedAt')
|
|
324
|
+
expect(first.doc).not.toHaveProperty('name')
|
|
325
|
+
expect(first.doc).not.toHaveProperty('role')
|
|
326
|
+
expect(first.doc).not.toHaveProperty('createdAt')
|
|
327
|
+
expect(first.doc).not.toHaveProperty('updatedAt')
|
|
328
328
|
expect(first.doc).toHaveProperty('_id', john._id)
|
|
329
329
|
|
|
330
330
|
expect(second.op).toBe('create')
|
|
@@ -334,10 +334,10 @@ describe('plugin - omit all', () => {
|
|
|
334
334
|
expect(second.version).toBe(0)
|
|
335
335
|
expect(second.patch).toHaveLength(0)
|
|
336
336
|
|
|
337
|
-
expect(second.doc).toHaveProperty('name'
|
|
338
|
-
expect(second.doc).toHaveProperty('role'
|
|
339
|
-
expect(second.doc).toHaveProperty('createdAt')
|
|
340
|
-
expect(second.doc).toHaveProperty('updatedAt')
|
|
337
|
+
expect(second.doc).not.toHaveProperty('name')
|
|
338
|
+
expect(second.doc).not.toHaveProperty('role')
|
|
339
|
+
expect(second.doc).not.toHaveProperty('createdAt')
|
|
340
|
+
expect(second.doc).not.toHaveProperty('updatedAt')
|
|
341
341
|
expect(second.doc).toHaveProperty('_id', alice._id)
|
|
342
342
|
|
|
343
343
|
expect(em.emit).toHaveBeenCalledTimes(0)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import mongoose, { model } from 'mongoose'
|
|
3
|
+
|
|
4
|
+
import UserSchema from './schemas/UserSchema'
|
|
5
|
+
import { patchHistoryPlugin } from '../src/plugin'
|
|
6
|
+
|
|
7
|
+
import { USER_CREATED } from './constants/events'
|
|
8
|
+
|
|
9
|
+
import em from '../src/em'
|
|
10
|
+
|
|
11
|
+
jest.mock('../src/em', () => {
|
|
12
|
+
return { emit: jest.fn() }
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
describe('plugin - preSave test', () => {
|
|
16
|
+
const uri = `${globalThis.__MONGO_URI__}${globalThis.__MONGO_DB_NAME__}`
|
|
17
|
+
|
|
18
|
+
UserSchema.plugin(patchHistoryPlugin, {
|
|
19
|
+
eventCreated: USER_CREATED,
|
|
20
|
+
omit: ['__v', 'role'],
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const User = model('User', UserSchema)
|
|
24
|
+
|
|
25
|
+
beforeAll(async () => {
|
|
26
|
+
await mongoose.connect(uri)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
afterAll(async () => {
|
|
30
|
+
await mongoose.connection.close()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
await mongoose.connection.collection('users').deleteMany({})
|
|
35
|
+
await mongoose.connection.collection('history').deleteMany({})
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should create a User and execute save, and omit User role in history', async () => {
|
|
39
|
+
const john = await User.create({ name: 'John', role: 'user' })
|
|
40
|
+
const { __v, role, ...doc } = john.toJSON()
|
|
41
|
+
|
|
42
|
+
expect(em.emit).toHaveBeenCalledTimes(1)
|
|
43
|
+
expect(em.emit).toHaveBeenCalledWith(USER_CREATED, { doc })
|
|
44
|
+
|
|
45
|
+
expect(john).toMatchObject({ name: 'John', role: 'user' })
|
|
46
|
+
|
|
47
|
+
const entry = await mongoose.connection.collection('history').findOne({ collectionId: john._id })
|
|
48
|
+
expect(entry).not.toBeNull()
|
|
49
|
+
expect(entry?.doc).toMatchObject({ name: 'John' })
|
|
50
|
+
expect(entry?.doc.role).toBeUndefined()
|
|
51
|
+
expect(entry?.patch).toEqual([])
|
|
52
|
+
})
|
|
53
|
+
})
|