ts-patch-mongoose 2.9.4 → 2.9.6
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/biome.json +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +16 -16
- package/package.json +18 -14
- package/src/hooks/delete-hooks.ts +3 -2
- package/src/hooks/update-hooks.ts +7 -6
- package/src/index.ts +2 -1
- package/src/patch.ts +10 -9
package/biome.json
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var isEmpty = require('lodash/isEmpty');
|
|
3
|
+
var isEmpty = require('lodash/isEmpty.js');
|
|
4
4
|
var ms = require('ms');
|
|
5
5
|
var mongoose = require('mongoose');
|
|
6
|
-
var isArray = require('lodash/isArray');
|
|
6
|
+
var isArray = require('lodash/isArray.js');
|
|
7
7
|
var jsonpatch = require('fast-json-patch');
|
|
8
|
-
var chunk = require('lodash/chunk');
|
|
9
|
-
var isFunction = require('lodash/isFunction');
|
|
8
|
+
var chunk = require('lodash/chunk.js');
|
|
9
|
+
var isFunction = require('lodash/isFunction.js');
|
|
10
10
|
var omit = require('omit-deep');
|
|
11
11
|
var EventEmitter = require('node:events');
|
|
12
|
-
var cloneDeep = require('lodash/cloneDeep');
|
|
13
|
-
var forEach = require('lodash/forEach');
|
|
14
|
-
var isObjectLike = require('lodash/isObjectLike');
|
|
15
|
-
var keys = require('lodash/keys');
|
|
12
|
+
var cloneDeep = require('lodash/cloneDeep.js');
|
|
13
|
+
var forEach = require('lodash/forEach.js');
|
|
14
|
+
var isObjectLike = require('lodash/isObjectLike.js');
|
|
15
|
+
var keys = require('lodash/keys.js');
|
|
16
16
|
var powerAssign = require('power-assign');
|
|
17
17
|
var semver = require('semver');
|
|
18
18
|
|
|
@@ -167,10 +167,10 @@ async function bulkPatch(opts, context, eventKey, docsKey) {
|
|
|
167
167
|
collectionName: context.collectionName,
|
|
168
168
|
collectionId: doc._id,
|
|
169
169
|
doc: getObjectOmit(opts, doc),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
version: 0,
|
|
171
|
+
...user !== void 0 && { user },
|
|
172
|
+
...reason !== void 0 && { reason },
|
|
173
|
+
...metadata !== void 0 && { metadata }
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
});
|
|
@@ -207,10 +207,10 @@ async function updatePatch(opts, context, current, original) {
|
|
|
207
207
|
collectionName: context.collectionName,
|
|
208
208
|
collectionId: original._id,
|
|
209
209
|
patch,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
version,
|
|
211
|
+
...user !== void 0 && { user },
|
|
212
|
+
...reason !== void 0 && { reason },
|
|
213
|
+
...metadata !== void 0 && { metadata }
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Types, Query, HydratedDocument, Schema } from 'mongoose';
|
|
2
2
|
import { Operation } from 'fast-json-patch';
|
|
3
3
|
import EventEmitter from 'node:events';
|
|
4
4
|
import ms from 'ms';
|
|
@@ -60,3 +60,4 @@ declare const patchHistoryPlugin: <T>(schema: Schema<T>, opts: PluginOptions<T>)
|
|
|
60
60
|
|
|
61
61
|
export { em as patchEventEmitter, patchHistoryPlugin, setPatchHistoryTTL };
|
|
62
62
|
export type { History, HookContext, Metadata, PatchContext, PatchEvent, PluginOptions, User };
|
|
63
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sources":["../src/types.ts","../src/em.ts","../src/helpers.ts","../src/index.ts"],"mappings":";;;;;AAGM,UAAW,OAAO;;;;kBAIR,KAAK,CAAC,QAAQ;;;;;;YAMpB,SAAS;;AAGb,UAAW,UAAU;aAChB,gBAAgB;UACnB,gBAAgB;YACd,SAAS;;AAGb,UAAW,YAAY;;;;;kBAKb,gBAAgB;kBAChB,gBAAgB;;;;AAK1B,KAAM,WAAW,MAAM,KAAK;;cAAiC,YAAY;;AAEzE,KAAM,IAAI,GAAG,MAAM;AAEnB,KAAM,QAAQ,GAAG,MAAM;AAEvB,UAAW,aAAa;;;;;;oBAMZ,gBAAgB,QAAQ,OAAO,CAAC,IAAI,IAAI,IAAI;sBAC1C,gBAAgB,QAAQ,OAAO;wBAC7B,gBAAgB,QAAQ,OAAO,CAAC,QAAQ,IAAI,QAAQ;;;uBAGrD,gBAAgB,UAAU,OAAO;;;AChDtD,cAAM,iBAAkB,SAAQ,YAAY;;AAC5C,cAAM,EAAE,mBAA0B;;ACWlC,cAAa,kBAAkB,iBAAwB,EAAE,CAAC,WAAW,KAAG,OAAO;;ACiB/E,cAAa,kBAAkB,cAA8B,MAAM,WAAW,aAAa","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Types, Query, HydratedDocument, Schema } from 'mongoose';
|
|
2
2
|
import { Operation } from 'fast-json-patch';
|
|
3
3
|
import EventEmitter from 'node:events';
|
|
4
4
|
import ms from 'ms';
|
|
@@ -60,3 +60,4 @@ declare const patchHistoryPlugin: <T>(schema: Schema<T>, opts: PluginOptions<T>)
|
|
|
60
60
|
|
|
61
61
|
export { em as patchEventEmitter, patchHistoryPlugin, setPatchHistoryTTL };
|
|
62
62
|
export type { History, HookContext, Metadata, PatchContext, PatchEvent, PluginOptions, User };
|
|
63
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sources":["../src/types.ts","../src/em.ts","../src/helpers.ts","../src/index.ts"],"mappings":";;;;;AAGM,UAAW,OAAO;;;;kBAIR,KAAK,CAAC,QAAQ;;;;;;YAMpB,SAAS;;AAGb,UAAW,UAAU;aAChB,gBAAgB;UACnB,gBAAgB;YACd,SAAS;;AAGb,UAAW,YAAY;;;;;kBAKb,gBAAgB;kBAChB,gBAAgB;;;;AAK1B,KAAM,WAAW,MAAM,KAAK;;cAAiC,YAAY;;AAEzE,KAAM,IAAI,GAAG,MAAM;AAEnB,KAAM,QAAQ,GAAG,MAAM;AAEvB,UAAW,aAAa;;;;;;oBAMZ,gBAAgB,QAAQ,OAAO,CAAC,IAAI,IAAI,IAAI;sBAC1C,gBAAgB,QAAQ,OAAO;wBAC7B,gBAAgB,QAAQ,OAAO,CAAC,QAAQ,IAAI,QAAQ;;;uBAGrD,gBAAgB,UAAU,OAAO;;;AChDtD,cAAM,iBAAkB,SAAQ,YAAY;;AAC5C,cAAM,EAAE,mBAA0B;;ACWlC,cAAa,kBAAkB,iBAAwB,EAAE,CAAC,WAAW,KAAG,OAAO;;ACiB/E,cAAa,kBAAkB,cAA8B,MAAM,WAAW,aAAa","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty';
|
|
1
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
2
2
|
import ms from 'ms';
|
|
3
3
|
import mongoose, { Schema, model } from 'mongoose';
|
|
4
|
-
import isArray from 'lodash/isArray';
|
|
4
|
+
import isArray from 'lodash/isArray.js';
|
|
5
5
|
import jsonpatch from 'fast-json-patch';
|
|
6
|
-
import chunk from 'lodash/chunk';
|
|
7
|
-
import isFunction from 'lodash/isFunction';
|
|
6
|
+
import chunk from 'lodash/chunk.js';
|
|
7
|
+
import isFunction from 'lodash/isFunction.js';
|
|
8
8
|
import omit from 'omit-deep';
|
|
9
9
|
import EventEmitter from 'node:events';
|
|
10
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
11
|
-
import forEach from 'lodash/forEach';
|
|
12
|
-
import isObjectLike from 'lodash/isObjectLike';
|
|
13
|
-
import keys from 'lodash/keys';
|
|
10
|
+
import cloneDeep from 'lodash/cloneDeep.js';
|
|
11
|
+
import forEach from 'lodash/forEach.js';
|
|
12
|
+
import isObjectLike from 'lodash/isObjectLike.js';
|
|
13
|
+
import keys from 'lodash/keys.js';
|
|
14
14
|
import { assign } from 'power-assign';
|
|
15
15
|
import { satisfies } from 'semver';
|
|
16
16
|
|
|
@@ -165,10 +165,10 @@ async function bulkPatch(opts, context, eventKey, docsKey) {
|
|
|
165
165
|
collectionName: context.collectionName,
|
|
166
166
|
collectionId: doc._id,
|
|
167
167
|
doc: getObjectOmit(opts, doc),
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
version: 0,
|
|
169
|
+
...user !== void 0 && { user },
|
|
170
|
+
...reason !== void 0 && { reason },
|
|
171
|
+
...metadata !== void 0 && { metadata }
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
});
|
|
@@ -205,10 +205,10 @@ async function updatePatch(opts, context, current, original) {
|
|
|
205
205
|
collectionName: context.collectionName,
|
|
206
206
|
collectionId: original._id,
|
|
207
207
|
patch,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
version,
|
|
209
|
+
...user !== void 0 && { user },
|
|
210
|
+
...reason !== void 0 && { reason },
|
|
211
|
+
...metadata !== void 0 && { metadata }
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-patch-mongoose",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.6",
|
|
4
4
|
"description": "Patch history & events for mongoose models",
|
|
5
5
|
"author": "ilovepixelart",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git://github.com/ilovepixelart/ts-patch-mongoose.git"
|
|
9
|
+
"url": "git+https://github.com/ilovepixelart/ts-patch-mongoose.git"
|
|
10
10
|
},
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ilovepixelart/ts-patch-mongoose/issues"
|
|
@@ -68,38 +68,42 @@
|
|
|
68
68
|
"test:open": "vitest run --coverage && open-cli coverage/lcov-report/index.html",
|
|
69
69
|
"type:check": "tsc --noEmit",
|
|
70
70
|
"build": "pkgroll --clean-dist",
|
|
71
|
-
"release": "npm install && npm run biome && npm run type:check && npm run build && np"
|
|
71
|
+
"release": "npm install && npm run biome && npm run type:check && npm run build && np --no-publish"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@types/lodash": "4.17.
|
|
74
|
+
"@types/lodash": "4.17.24",
|
|
75
75
|
"@types/ms": "2.1.0",
|
|
76
76
|
"@types/semver": "7.7.1",
|
|
77
77
|
"fast-json-patch": "3.1.1",
|
|
78
|
-
"lodash": "4.17.
|
|
78
|
+
"lodash": "4.17.23",
|
|
79
79
|
"ms": "2.1.3",
|
|
80
80
|
"omit-deep": "0.3.0",
|
|
81
81
|
"power-assign": "0.2.10",
|
|
82
|
-
"semver": "7.7.
|
|
82
|
+
"semver": "7.7.4"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@biomejs/biome": "2.
|
|
86
|
-
"@types/node": "
|
|
87
|
-
"@vitest/coverage-v8": "4.0.
|
|
88
|
-
"mongodb-memory-server": "
|
|
89
|
-
"mongoose": "
|
|
85
|
+
"@biomejs/biome": "2.4.4",
|
|
86
|
+
"@types/node": "25.3.0",
|
|
87
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
88
|
+
"mongodb-memory-server": "11.0.1",
|
|
89
|
+
"mongoose": "9.2.2",
|
|
90
90
|
"open-cli": "8.0.0",
|
|
91
|
-
"pkgroll": "2.
|
|
91
|
+
"pkgroll": "2.26.3",
|
|
92
92
|
"simple-git-hooks": "2.13.1",
|
|
93
93
|
"typescript": "5.9.3",
|
|
94
|
-
"vitest": "4.0.
|
|
94
|
+
"vitest": "4.0.18",
|
|
95
|
+
"np": "11.0.2"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
|
-
"mongoose": ">=6.6.0 <
|
|
98
|
+
"mongoose": ">=6.6.0 < 10"
|
|
98
99
|
},
|
|
99
100
|
"simple-git-hooks": {
|
|
100
101
|
"pre-commit": "npm run type:check",
|
|
101
102
|
"pre-push": "npm run biome:fix"
|
|
102
103
|
},
|
|
104
|
+
"np": {
|
|
105
|
+
"publish": false
|
|
106
|
+
},
|
|
103
107
|
"overrides": {
|
|
104
108
|
"esbuild": "0.25.0"
|
|
105
109
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
// Using CJS lodash with .js extensions for ESM compatibility
|
|
2
|
+
import isArray from 'lodash/isArray.js'
|
|
3
|
+
import isEmpty from 'lodash/isEmpty.js'
|
|
3
4
|
import { isHookIgnored } from '../helpers'
|
|
4
5
|
import { deletePatch } from '../patch'
|
|
5
6
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
// Using CJS lodash with .js extensions for ESM compatibility
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep.js'
|
|
3
|
+
import forEach from 'lodash/forEach.js'
|
|
4
|
+
import isArray from 'lodash/isArray.js'
|
|
5
|
+
import isEmpty from 'lodash/isEmpty.js'
|
|
6
|
+
import isObjectLike from 'lodash/isObjectLike.js'
|
|
7
|
+
import keys from 'lodash/keys.js'
|
|
7
8
|
import { assign } from 'power-assign'
|
|
8
9
|
import { isHookIgnored, toObjectOptions } from '../helpers'
|
|
9
10
|
import { createPatch, updatePatch } from '../patch'
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// Using CJS lodash with .js extension for ESM compatibility
|
|
2
|
+
import isEmpty from 'lodash/isEmpty.js'
|
|
2
3
|
import { toObjectOptions } from './helpers'
|
|
3
4
|
import { deleteHooksInitialize } from './hooks/delete-hooks'
|
|
4
5
|
import { saveHooksInitialize } from './hooks/save-hooks'
|
package/src/patch.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import jsonpatch from 'fast-json-patch'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
// Using CJS lodash with .js extensions for ESM compatibility
|
|
3
|
+
import chunk from 'lodash/chunk.js'
|
|
4
|
+
import isEmpty from 'lodash/isEmpty.js'
|
|
5
|
+
import isFunction from 'lodash/isFunction.js'
|
|
5
6
|
import omit from 'omit-deep'
|
|
6
7
|
import em from './em'
|
|
7
8
|
import { HistoryModel } from './model'
|
|
@@ -93,10 +94,10 @@ export async function bulkPatch<T>(opts: PluginOptions<T>, context: PatchContext
|
|
|
93
94
|
collectionName: context.collectionName,
|
|
94
95
|
collectionId: doc._id as Types.ObjectId,
|
|
95
96
|
doc: getObjectOmit(opts, doc),
|
|
96
|
-
user,
|
|
97
|
-
reason,
|
|
98
|
-
metadata,
|
|
99
97
|
version: 0,
|
|
98
|
+
...(user !== undefined && { user }),
|
|
99
|
+
...(reason !== undefined && { reason }),
|
|
100
|
+
...(metadata !== undefined && { metadata }),
|
|
100
101
|
},
|
|
101
102
|
},
|
|
102
103
|
})
|
|
@@ -145,10 +146,10 @@ export async function updatePatch<T>(opts: PluginOptions<T>, context: PatchConte
|
|
|
145
146
|
collectionName: context.collectionName,
|
|
146
147
|
collectionId: original._id as Types.ObjectId,
|
|
147
148
|
patch,
|
|
148
|
-
user,
|
|
149
|
-
reason,
|
|
150
|
-
metadata,
|
|
151
149
|
version,
|
|
150
|
+
...(user !== undefined && { user }),
|
|
151
|
+
...(reason !== undefined && { reason }),
|
|
152
|
+
...(metadata !== undefined && { metadata }),
|
|
152
153
|
})
|
|
153
154
|
}
|
|
154
155
|
}
|