ts-patch-mongoose 1.0.9 → 1.1.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.
Files changed (60) hide show
  1. package/dist/cjs/types/em.d.ts.map +1 -0
  2. package/dist/cjs/types/interfaces/IContext.d.ts.map +1 -0
  3. package/dist/cjs/types/interfaces/IHistory.d.ts.map +1 -0
  4. package/dist/cjs/types/interfaces/IHookContext.d.ts.map +1 -0
  5. package/dist/cjs/types/interfaces/IPluginOptions.d.ts.map +1 -0
  6. package/dist/cjs/types/models/History.d.ts.map +1 -0
  7. package/dist/cjs/types/plugin.d.ts.map +1 -0
  8. package/dist/esm/types/em.d.ts.map +1 -0
  9. package/dist/esm/types/interfaces/IContext.d.ts.map +1 -0
  10. package/dist/esm/types/interfaces/IHistory.d.ts.map +1 -0
  11. package/dist/esm/types/interfaces/IHookContext.d.ts.map +1 -0
  12. package/dist/esm/types/interfaces/IPluginOptions.d.ts.map +1 -0
  13. package/dist/esm/types/models/History.d.ts.map +1 -0
  14. package/dist/esm/types/plugin.d.ts.map +1 -0
  15. package/package.json +20 -10
  16. package/tests/plugin-event-updated.test.ts +83 -0
  17. package/dist/cjs/em.d.ts.map +0 -1
  18. package/dist/cjs/interfaces/IContext.d.ts.map +0 -1
  19. package/dist/cjs/interfaces/IHistory.d.ts.map +0 -1
  20. package/dist/cjs/interfaces/IHookContext.d.ts.map +0 -1
  21. package/dist/cjs/interfaces/IPluginOptions.d.ts.map +0 -1
  22. package/dist/cjs/models/History.d.ts.map +0 -1
  23. package/dist/cjs/plugin.d.ts.map +0 -1
  24. package/dist/esm/em.d.ts.map +0 -1
  25. package/dist/esm/interfaces/IContext.d.ts.map +0 -1
  26. package/dist/esm/interfaces/IHistory.d.ts.map +0 -1
  27. package/dist/esm/interfaces/IHookContext.d.ts.map +0 -1
  28. package/dist/esm/interfaces/IPluginOptions.d.ts.map +0 -1
  29. package/dist/esm/models/History.d.ts.map +0 -1
  30. package/dist/esm/plugin.d.ts.map +0 -1
  31. package/dist/types/em.d.ts +0 -7
  32. package/dist/types/em.d.ts.map +0 -1
  33. package/dist/types/interfaces/IContext.d.ts +0 -11
  34. package/dist/types/interfaces/IContext.d.ts.map +0 -1
  35. package/dist/types/interfaces/IHistory.d.ts +0 -13
  36. package/dist/types/interfaces/IHistory.d.ts.map +0 -1
  37. package/dist/types/interfaces/IHookContext.d.ts +0 -8
  38. package/dist/types/interfaces/IHookContext.d.ts.map +0 -1
  39. package/dist/types/interfaces/IPluginOptions.d.ts +0 -13
  40. package/dist/types/interfaces/IPluginOptions.d.ts.map +0 -1
  41. package/dist/types/models/History.d.ts +0 -29
  42. package/dist/types/models/History.d.ts.map +0 -1
  43. package/dist/types/plugin.d.ts +0 -45
  44. package/dist/types/plugin.d.ts.map +0 -1
  45. /package/dist/cjs/{em.d.ts → types/em.d.ts} +0 -0
  46. /package/dist/cjs/{interfaces → types/interfaces}/IContext.d.ts +0 -0
  47. /package/dist/cjs/{interfaces → types/interfaces}/IHistory.d.ts +0 -0
  48. /package/dist/cjs/{interfaces → types/interfaces}/IHookContext.d.ts +0 -0
  49. /package/dist/cjs/{interfaces → types/interfaces}/IPluginOptions.d.ts +0 -0
  50. /package/dist/cjs/{models → types/models}/History.d.ts +0 -0
  51. /package/dist/cjs/{plugin.d.ts → types/plugin.d.ts} +0 -0
  52. /package/dist/esm/{plugin.js → plugin.mjs} +0 -0
  53. /package/dist/esm/{em.d.ts → types/em.d.ts} +0 -0
  54. /package/dist/esm/{interfaces → types/interfaces}/IContext.d.ts +0 -0
  55. /package/dist/esm/{interfaces → types/interfaces}/IHistory.d.ts +0 -0
  56. /package/dist/esm/{interfaces → types/interfaces}/IHookContext.d.ts +0 -0
  57. /package/dist/esm/{interfaces → types/interfaces}/IPluginOptions.d.ts +0 -0
  58. /package/dist/esm/{models → types/models}/History.d.ts +0 -0
  59. /package/dist/esm/{plugin.d.ts → types/plugin.d.ts} +0 -0
  60. /package/tests/{plugin-event-created..test.ts → plugin-event-created.test.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"em.d.ts","sourceRoot":"","sources":["../../../src/em.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,cAAM,iBAAkB,SAAQ,YAAY;CAAG;AAC/C,QAAA,MAAM,EAAE,mBAA0B,CAAA;AAElC,eAAe,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IContext.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,QAAQ,CAAC,CAAC;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;CACpC;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IHistory.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IHistory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;CACpB;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IHookContext.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IHookContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAEtC,KAAK,YAAY,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,CAAA;AAE1E,eAAe,YAAY,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPluginOptions.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IPluginOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,cAAc,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../../src/models/History.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAExC,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAkClD,QAAA,MAAM,OAAO,6LAA6C,CAAA;AAE1D,eAAe,OAAO,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,KAAK,EAAmC,KAAK,EAAiB,MAAM,EAAS,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAA;AA2G7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;CAAK,CAAA;AAQnC,eAAO,MAAM,kBAAkB,oOAAoE,IA2JlG,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"em.d.ts","sourceRoot":"","sources":["../../../src/em.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,cAAM,iBAAkB,SAAQ,YAAY;CAAG;AAC/C,QAAA,MAAM,EAAE,mBAA0B,CAAA;AAElC,eAAe,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IContext.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,QAAQ,CAAC,CAAC;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;CACpC;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IHistory.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IHistory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;CACpB;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IHookContext.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IHookContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAEtC,KAAK,YAAY,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,CAAA;AAE1E,eAAe,YAAY,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPluginOptions.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/IPluginOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,cAAc,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../../src/models/History.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAExC,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAkClD,QAAA,MAAM,OAAO,6LAA6C,CAAA;AAE1D,eAAe,OAAO,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,KAAK,EAAmC,KAAK,EAAiB,MAAM,EAAS,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAA;AA2G7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;CAAK,CAAA;AAQnC,eAAO,MAAM,kBAAkB,oOAAoE,IA2JlG,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-patch-mongoose",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "Patch history & events for mongoose models",
5
5
  "author": "Alex Eagle",
6
6
  "license": "MIT",
@@ -49,20 +49,30 @@
49
49
  ".eslintrc",
50
50
  ".eslintignore"
51
51
  ],
52
+ "exports": {
53
+ ".": {
54
+ "import": {
55
+ "types": "./dist/esm/types/plugin.d.ts",
56
+ "default": "./dist/esm/plugin.mjs"
57
+ },
58
+ "require": {
59
+ "types": "./dist/cjs/types/plugin.d.ts",
60
+ "default": "./dist/cjs/plugin.js"
61
+ }
62
+ }
63
+ },
52
64
  "main": "dist/cjs/plugin.js",
53
- "module": "dist/esm/plugin.js",
54
- "types": "dist/types/plugin.d.js",
65
+ "types": "dist/cjs/types/plugin.d.ts",
55
66
  "scripts": {
56
67
  "lint": "eslint . --ext .js,.ts",
57
68
  "lint:fix": "eslint . --fix --ext .js,.ts",
58
- "cleanup": "node -r @swc/register tools/cleanup.ts",
59
- "build": "npm run build:cjs && npm run build:esm && npm run build:types",
60
- "build:cjs": "npm run cleanup cjs && tsc -p config/tsconfig.cjs.json",
61
- "build:esm": "npm run cleanup esm && tsc -p config/tsconfig.esm.json",
62
- "build:types": "npm run cleanup types && tsc -p config/tsconfig.types.json",
63
- "package": "npm run build && npm pack",
64
69
  "test": "jest --config jest.config.ts --detectOpenHandles --coverage",
65
- "test:open": "npm run test && open-cli coverage/lcov-report/index.html"
70
+ "test:open": "npm run test && open-cli coverage/lcov-report/index.html",
71
+ "clean": "rm -rf ./dist",
72
+ "build": "npm run clean && npm run build:cjs && npm run build:esm",
73
+ "build:cjs": "tsc -p config/tsconfig.cjs.json",
74
+ "build:esm": "tsc -p config/tsconfig.esm.json && mv ./dist/esm/plugin.js ./dist/esm/plugin.mjs",
75
+ "release": "npm run lint && npm run build && np"
66
76
  },
67
77
  "dependencies": {
68
78
  "fast-json-patch": "^3.1.1",
@@ -0,0 +1,83 @@
1
+ import mongoose, { model } from 'mongoose'
2
+
3
+ import UserSchema from './schemas/UserSchema'
4
+ import { patchHistoryPlugin } from '../src/plugin'
5
+ import History from '../src/models/History'
6
+
7
+ import em from '../src/em'
8
+ import { USER_UPDATED } from './constants/events'
9
+
10
+ jest.mock('../src/em', () => {
11
+ return {
12
+ emit: jest.fn((name, data) => console.log('emit', name, data))
13
+ }
14
+ })
15
+
16
+ describe('plugin - event updated & patch history disabled', () => {
17
+ const uri = `${globalThis.__MONGO_URI__}${globalThis.__MONGO_DB_NAME__}`
18
+
19
+ UserSchema.plugin(patchHistoryPlugin, {
20
+ eventUpdated: USER_UPDATED,
21
+ patchHistoryDisabled: true,
22
+ omit: ['createdAt', 'updatedAt']
23
+ })
24
+
25
+ const User = model('User', UserSchema)
26
+
27
+ beforeAll(async () => {
28
+ await mongoose.connect(uri)
29
+ })
30
+
31
+ afterAll(async () => {
32
+ await mongoose.connection.close()
33
+ })
34
+
35
+ beforeEach(async () => {
36
+ await mongoose.connection.collection('users').deleteMany({})
37
+ await mongoose.connection.collection('history').deleteMany({})
38
+ })
39
+
40
+ it('should save/save and emit one update event', async () => {
41
+ const user = new User({ name: 'John', role: 'user' })
42
+ const created = await user.save()
43
+
44
+ user.name = 'John Doe'
45
+ const updated = await user.save()
46
+
47
+ const history = await History.find({})
48
+ expect(history).toHaveLength(0)
49
+
50
+ expect(em.emit).toHaveBeenCalledTimes(1)
51
+
52
+ expect(em.emit).toHaveBeenCalledWith(USER_UPDATED, {
53
+ oldDoc: expect.objectContaining({
54
+ __v: 0,
55
+ _id: created._id,
56
+ name: 'John',
57
+ role: 'user',
58
+ createdAt: created.createdAt,
59
+ updatedAt: created.createdAt
60
+ }),
61
+ doc: expect.objectContaining({
62
+ __v: 0,
63
+ _id: updated._id,
64
+ name: 'John Doe',
65
+ role: 'user',
66
+ createdAt: created.createdAt,
67
+ updatedAt: updated.updatedAt
68
+ }),
69
+ patch: expect.arrayContaining([
70
+ {
71
+ op: 'test',
72
+ path: '/name',
73
+ value: 'John'
74
+ },
75
+ {
76
+ op: 'replace',
77
+ path: '/name',
78
+ value: 'John Doe'
79
+ }
80
+ ])
81
+ })
82
+ })
83
+ })
@@ -1 +0,0 @@
1
- {"version":3,"file":"em.d.ts","sourceRoot":"","sources":["../../src/em.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,cAAM,iBAAkB,SAAQ,YAAY;CAAG;AAC/C,QAAA,MAAM,EAAE,mBAA0B,CAAA;AAElC,eAAe,EAAE,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContext.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,QAAQ,CAAC,CAAC;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;CACpC;AAED,eAAe,QAAQ,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHistory.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IHistory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;CACpB;AAED,eAAe,QAAQ,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHookContext.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IHookContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAEtC,KAAK,YAAY,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,CAAA;AAE1E,eAAe,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IPluginOptions.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IPluginOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,cAAc,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,eAAe,cAAc,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../src/models/History.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAExC,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAkClD,QAAA,MAAM,OAAO,6LAA6C,CAAA;AAE1D,eAAe,OAAO,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,KAAK,EAAmC,KAAK,EAAiB,MAAM,EAAS,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAA;AA2G7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;CAAK,CAAA;AAQnC,eAAO,MAAM,kBAAkB,oOAAoE,IA2JlG,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"em.d.ts","sourceRoot":"","sources":["../../src/em.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,cAAM,iBAAkB,SAAQ,YAAY;CAAG;AAC/C,QAAA,MAAM,EAAE,mBAA0B,CAAA;AAElC,eAAe,EAAE,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContext.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,QAAQ,CAAC,CAAC;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;CACpC;AAED,eAAe,QAAQ,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHistory.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IHistory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;CACpB;AAED,eAAe,QAAQ,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHookContext.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IHookContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAEtC,KAAK,YAAY,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,CAAA;AAE1E,eAAe,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IPluginOptions.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IPluginOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,cAAc,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,eAAe,cAAc,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../src/models/History.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAExC,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAkClD,QAAA,MAAM,OAAO,6LAA6C,CAAA;AAE1D,eAAe,OAAO,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,KAAK,EAAmC,KAAK,EAAiB,MAAM,EAAS,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAA;AA2G7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;CAAK,CAAA;AAQnC,eAAO,MAAM,kBAAkB,oOAAoE,IA2JlG,CAAA"}
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from 'events';
3
- declare class PatchEventEmitter extends EventEmitter {
4
- }
5
- declare const em: PatchEventEmitter;
6
- export default em;
7
- //# sourceMappingURL=em.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"em.d.ts","sourceRoot":"","sources":["../../src/em.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,cAAM,iBAAkB,SAAQ,YAAY;CAAG;AAC/C,QAAA,MAAM,EAAE,mBAA0B,CAAA;AAElC,eAAe,EAAE,CAAA"}
@@ -1,11 +0,0 @@
1
- import type { HydratedDocument } from 'mongoose';
2
- interface IContext<T> {
3
- op: string;
4
- modelName: string;
5
- collectionName: string;
6
- isNew?: boolean;
7
- createdDocs?: HydratedDocument<T>[];
8
- deletedDocs?: HydratedDocument<T>[];
9
- }
10
- export default IContext;
11
- //# sourceMappingURL=IContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IContext.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,QAAQ,CAAC,CAAC;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;CACpC;AAED,eAAe,QAAQ,CAAA"}
@@ -1,13 +0,0 @@
1
- import type { Types } from 'mongoose';
2
- import type { Operation } from 'fast-json-patch';
3
- interface IHistory {
4
- op: string;
5
- modelName: string;
6
- collectionName: string;
7
- collectionId: Types.ObjectId;
8
- version: number;
9
- doc?: object;
10
- patch?: Operation[];
11
- }
12
- export default IHistory;
13
- //# sourceMappingURL=IHistory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHistory.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IHistory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;CACpB;AAED,eAAe,QAAQ,CAAA"}
@@ -1,8 +0,0 @@
1
- import type { Query } from 'mongoose';
2
- import type IContext from './IContext';
3
- type IHookContext<T> = Query<T, T> & {
4
- op: string;
5
- _context: IContext<T>;
6
- };
7
- export default IHookContext;
8
- //# sourceMappingURL=IHookContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHookContext.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IHookContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAEtC,KAAK,YAAY,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,CAAA;AAE1E,eAAe,YAAY,CAAA"}
@@ -1,13 +0,0 @@
1
- import type { HydratedDocument } from 'mongoose';
2
- interface IPluginOptions<T> {
3
- modelName?: string;
4
- collectionName?: string;
5
- eventUpdated?: string;
6
- eventCreated?: string;
7
- eventDeleted?: string;
8
- patchHistoryDisabled?: boolean;
9
- preDeleteManyCallback?: (docs: HydratedDocument<T>[]) => Promise<void>;
10
- omit?: string[];
11
- }
12
- export default IPluginOptions;
13
- //# sourceMappingURL=IPluginOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IPluginOptions.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IPluginOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,UAAU,cAAc,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,eAAe,cAAc,CAAA"}
@@ -1,29 +0,0 @@
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
- import { Schema } from 'mongoose';
26
- import type IHistory from '../interfaces/IHistory';
27
- declare const History: import("mongoose").Model<IHistory, {}, {}, {}, Schema<IHistory, import("mongoose").Model<IHistory, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IHistory>>;
28
- export default History;
29
- //# sourceMappingURL=History.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../src/models/History.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAS,MAAM,UAAU,CAAA;AAExC,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAkClD,QAAA,MAAM,OAAO,6LAA6C,CAAA;AAE1D,eAAe,OAAO,CAAA"}
@@ -1,45 +0,0 @@
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
- import type { Model, Schema } from 'mongoose';
26
- import type IPluginOptions from './interfaces/IPluginOptions';
27
- export declare const patchEventEmitter: {
28
- addListener(eventName: string | symbol, listener: (...args: any[]) => void): any;
29
- on(eventName: string | symbol, listener: (...args: any[]) => void): any;
30
- once(eventName: string | symbol, listener: (...args: any[]) => void): any;
31
- removeListener(eventName: string | symbol, listener: (...args: any[]) => void): any;
32
- off(eventName: string | symbol, listener: (...args: any[]) => void): any;
33
- removeAllListeners(event?: string | symbol | undefined): any;
34
- setMaxListeners(n: number): any;
35
- getMaxListeners(): number;
36
- listeners(eventName: string | symbol): Function[];
37
- rawListeners(eventName: string | symbol): Function[];
38
- emit(eventName: string | symbol, ...args: any[]): boolean;
39
- listenerCount(eventName: string | symbol): number;
40
- prependListener(eventName: string | symbol, listener: (...args: any[]) => void): any;
41
- prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): any;
42
- eventNames(): (string | symbol)[];
43
- };
44
- export declare const patchHistoryPlugin: <T>(schema: Schema<T, Model<T, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, import("mongoose").ObtainDocumentType<any, T, import("mongoose").DefaultSchemaOptions>>, opts: IPluginOptions<T>) => void;
45
- //# sourceMappingURL=plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,KAAK,EAAmC,KAAK,EAAiB,MAAM,EAAS,MAAM,UAAU,CAAA;AAEpG,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAA;AA2G7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;CAAK,CAAA;AAQnC,eAAO,MAAM,kBAAkB,oOAAoE,IA2JlG,CAAA"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes