@treatwell/moleculer-essentials 2.1.1-beta.2 → 2.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.
- package/README.md +1 -0
- package/dist/{index-8Cv0B4uH.mjs → index-BMLRFTWF.mjs} +18 -14
- package/dist/{index-lmnhNH-8.cjs → index-CbFCa8NT.cjs} +18 -14
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/mixins/database.mixin.cjs +1 -1
- package/dist/mixins/database.mixin.d.cts +1 -1
- package/dist/mixins/database.mixin.d.mts +1 -1
- package/dist/mixins/database.mixin.mjs +1 -1
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -216,25 +216,29 @@ function zodToOpenAPISchema(schema, extractor) {
|
|
|
216
216
|
}
|
|
217
217
|
return res;
|
|
218
218
|
}
|
|
219
|
-
const zodDate = z.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
const zodDate = z.nonoptional(
|
|
220
|
+
z.transform((val) => {
|
|
221
|
+
if (typeof val === "string") {
|
|
222
|
+
const date = parseISO(val);
|
|
223
|
+
if (!Number.isNaN(date.getTime())) {
|
|
224
|
+
return date;
|
|
225
|
+
}
|
|
224
226
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
return val;
|
|
228
|
+
}).pipe(z.date())
|
|
229
|
+
);
|
|
228
230
|
const OBJECT_ID_PATTERN = /^[a-f\d]{24}$/i;
|
|
229
231
|
function isObjectId(val) {
|
|
230
232
|
return val instanceof ObjectId;
|
|
231
233
|
}
|
|
232
|
-
const zodObjectId = z.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
const zodObjectId = z.nonoptional(
|
|
235
|
+
z.transform((val) => {
|
|
236
|
+
if (typeof val === "string" && OBJECT_ID_PATTERN.test(val)) {
|
|
237
|
+
return new ObjectId(val);
|
|
238
|
+
}
|
|
239
|
+
return val;
|
|
240
|
+
}).pipe(z.custom(isObjectId, { abort: true })).meta({ id: "ObjectId" })
|
|
241
|
+
);
|
|
238
242
|
function zodCoerceArray(element, params) {
|
|
239
243
|
return z.transform((val) => !Array.isArray(val) && val !== void 0 ? [val] : val).pipe(z.array(element, params));
|
|
240
244
|
}
|
|
@@ -218,25 +218,29 @@ function zodToOpenAPISchema(schema, extractor) {
|
|
|
218
218
|
}
|
|
219
219
|
return res;
|
|
220
220
|
}
|
|
221
|
-
const zodDate = v4.z.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
221
|
+
const zodDate = v4.z.nonoptional(
|
|
222
|
+
v4.z.transform((val) => {
|
|
223
|
+
if (typeof val === "string") {
|
|
224
|
+
const date = dateFns.parseISO(val);
|
|
225
|
+
if (!Number.isNaN(date.getTime())) {
|
|
226
|
+
return date;
|
|
227
|
+
}
|
|
226
228
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
return val;
|
|
230
|
+
}).pipe(v4.z.date())
|
|
231
|
+
);
|
|
230
232
|
const OBJECT_ID_PATTERN = /^[a-f\d]{24}$/i;
|
|
231
233
|
function isObjectId(val) {
|
|
232
234
|
return val instanceof bson.ObjectId;
|
|
233
235
|
}
|
|
234
|
-
const zodObjectId = v4.z.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
const zodObjectId = v4.z.nonoptional(
|
|
237
|
+
v4.z.transform((val) => {
|
|
238
|
+
if (typeof val === "string" && OBJECT_ID_PATTERN.test(val)) {
|
|
239
|
+
return new bson.ObjectId(val);
|
|
240
|
+
}
|
|
241
|
+
return val;
|
|
242
|
+
}).pipe(v4.z.custom(isObjectId, { abort: true })).meta({ id: "ObjectId" })
|
|
243
|
+
);
|
|
240
244
|
function zodCoerceArray(element, params) {
|
|
241
245
|
return v4.z.transform((val) => !Array.isArray(val) && val !== void 0 ? [val] : val).pipe(v4.z.array(element, params));
|
|
242
246
|
}
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -173,8 +173,8 @@ declare function createOpenAPIResponses(model: OpenAPIResponses, description?: s
|
|
|
173
173
|
* For this, you should use helpers provided by this package.
|
|
174
174
|
*/
|
|
175
175
|
declare function zodToOpenAPISchema(schema: ZodType, extractor: OpenAPIExtractor): SchemaObject | ReferenceObject;
|
|
176
|
-
declare const zodDate: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate
|
|
177
|
-
declare const zodObjectId: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCustom<ObjectId, ObjectId
|
|
176
|
+
declare const zodDate: z.ZodNonOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate>>;
|
|
177
|
+
declare const zodObjectId: z.ZodNonOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCustom<ObjectId, ObjectId>>>;
|
|
178
178
|
declare function zodCoerceArray<T extends ZodType>(element: T, params?: Parameters<typeof z.array>[1]): z.ZodPipe<z.ZodTransform<any[] | undefined, unknown>, z.ZodArray<T>>;
|
|
179
179
|
declare function isZodSchema<S extends z.ZodType>(schema: unknown, type?: S['type']): schema is S;
|
|
180
180
|
|
package/dist/index.d.mts
CHANGED
|
@@ -173,8 +173,8 @@ declare function createOpenAPIResponses(model: OpenAPIResponses, description?: s
|
|
|
173
173
|
* For this, you should use helpers provided by this package.
|
|
174
174
|
*/
|
|
175
175
|
declare function zodToOpenAPISchema(schema: ZodType, extractor: OpenAPIExtractor): SchemaObject | ReferenceObject;
|
|
176
|
-
declare const zodDate: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate
|
|
177
|
-
declare const zodObjectId: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCustom<ObjectId, ObjectId
|
|
176
|
+
declare const zodDate: z.ZodNonOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodDate>>;
|
|
177
|
+
declare const zodObjectId: z.ZodNonOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCustom<ObjectId, ObjectId>>>;
|
|
178
178
|
declare function zodCoerceArray<T extends ZodType>(element: T, params?: Parameters<typeof z.array>[1]): z.ZodPipe<z.ZodTransform<any[] | undefined, unknown>, z.ZodArray<T>>;
|
|
179
179
|
declare function isZodSchema<S extends z.ZodType>(schema: unknown, type?: S['type']): schema is S;
|
|
180
180
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SCHEMA_REF_NAME, i as isZodSchema, z as zodToOpenAPISchema, o as omitFields, G as GetOpenApiParamsSchema, V as ValidationErrorSchema, F as FileTooBigSchema, a as FileNotExistSchema, U as UnauthorizedErrorSchema, b as ServerErrorSchema, C as COERCE_ARRAY_ATTRIBUTE } from './index-
|
|
2
|
-
export { D as DATE_TYPE, E as EMPTY_OBJECT_SCHEMA, O as OBJECTID_TYPE, c as addFieldsToSchema, d as composeSchemas, e as createOpenAPIResponses, f as optionalExceptFields, g as optionalFields, p as pickFields, t as toPartialSchema, h as zodCoerceArray, j as zodDate, k as zodObjectId } from './index-
|
|
1
|
+
import { S as SCHEMA_REF_NAME, i as isZodSchema, z as zodToOpenAPISchema, o as omitFields, G as GetOpenApiParamsSchema, V as ValidationErrorSchema, F as FileTooBigSchema, a as FileNotExistSchema, U as UnauthorizedErrorSchema, b as ServerErrorSchema, C as COERCE_ARRAY_ATTRIBUTE } from './index-BMLRFTWF.mjs';
|
|
2
|
+
export { D as DATE_TYPE, E as EMPTY_OBJECT_SCHEMA, O as OBJECTID_TYPE, c as addFieldsToSchema, d as composeSchemas, e as createOpenAPIResponses, f as optionalExceptFields, g as optionalFields, p as pickFields, t as toPartialSchema, h as zodCoerceArray, j as zodDate, k as zodObjectId } from './index-BMLRFTWF.mjs';
|
|
3
3
|
import { Ajv2019 } from 'ajv/dist/2019.js';
|
|
4
4
|
import { Validators, Errors, Context, ServiceBroker, Service, TracerExporters, MetricReporters } from 'moleculer';
|
|
5
5
|
import addFormats from 'ajv-formats';
|
|
@@ -839,7 +839,7 @@ declare function optimizeQuery<T extends Record<string, unknown>>(query: Filter<
|
|
|
839
839
|
* Return an object with each list item as key and 1/0/-1 as value
|
|
840
840
|
* to be used in mongo projection or sort.
|
|
841
841
|
*/
|
|
842
|
-
declare function getQueryFromList<T extends 'sort' | 'projection', NotOp extends T extends 'sort' ? -1 : 0>(type: T, list?: string[]): Record<string, 1 | NotOp> | undefined;
|
|
842
|
+
declare function getQueryFromList<T extends 'sort' | 'projection', NotOp extends (T extends 'sort' ? -1 : 0)>(type: T, list?: string[]): Record<string, 1 | NotOp> | undefined;
|
|
843
843
|
|
|
844
844
|
declare function DatabaseMethodsMixin<TSchema extends Document & {
|
|
845
845
|
_id: ObjectId | string;
|
|
@@ -839,7 +839,7 @@ declare function optimizeQuery<T extends Record<string, unknown>>(query: Filter<
|
|
|
839
839
|
* Return an object with each list item as key and 1/0/-1 as value
|
|
840
840
|
* to be used in mongo projection or sort.
|
|
841
841
|
*/
|
|
842
|
-
declare function getQueryFromList<T extends 'sort' | 'projection', NotOp extends T extends 'sort' ? -1 : 0>(type: T, list?: string[]): Record<string, 1 | NotOp> | undefined;
|
|
842
|
+
declare function getQueryFromList<T extends 'sort' | 'projection', NotOp extends (T extends 'sort' ? -1 : 0)>(type: T, list?: string[]): Record<string, 1 | NotOp> | undefined;
|
|
843
843
|
|
|
844
844
|
declare function DatabaseMethodsMixin<TSchema extends Document & {
|
|
845
845
|
_id: ObjectId | string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as optionalFields, o as omitFields, S as SCHEMA_REF_NAME, O as OBJECTID_TYPE, C as COERCE_ARRAY_ATTRIBUTE, i as isZodSchema, k as zodObjectId, h as zodCoerceArray, e as createOpenAPIResponses } from '../index-
|
|
1
|
+
import { g as optionalFields, o as omitFields, S as SCHEMA_REF_NAME, O as OBJECTID_TYPE, C as COERCE_ARRAY_ATTRIBUTE, i as isZodSchema, k as zodObjectId, h as zodCoerceArray, e as createOpenAPIResponses } from '../index-BMLRFTWF.mjs';
|
|
2
2
|
import { Errors } from 'moleculer';
|
|
3
3
|
import { isEqual as isEqual$1 } from 'es-toolkit';
|
|
4
4
|
import { z } from 'zod/v4';
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/treatwell/moleculer-essentials"
|
|
8
8
|
},
|
|
9
|
-
"version": "2.1.1
|
|
9
|
+
"version": "2.1.1",
|
|
10
10
|
"main": "./dist/index.cjs",
|
|
11
11
|
"module": "./dist/index.mjs",
|
|
12
12
|
"types": "./dist/index.d.cts",
|
|
@@ -113,11 +113,11 @@
|
|
|
113
113
|
"pino-pretty": "^13.1.3"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
|
-
"@aws-crypto/client-node": "^4.2.1",
|
|
116
|
+
"@aws-crypto/client-node": "^4.2.1 || ^5.0.0",
|
|
117
117
|
"bullmq": "^5.12.10",
|
|
118
118
|
"ioredis": "^5.2.3",
|
|
119
119
|
"jsonwebtoken": "^9.0.2",
|
|
120
|
-
"jwks-rsa": "^3.0.1",
|
|
120
|
+
"jwks-rsa": "^3.0.1 || ^4.0.1",
|
|
121
121
|
"moleculer": "^0.15.0",
|
|
122
122
|
"mongodb": "^6.15.0 || ^7.1.0",
|
|
123
123
|
"redlock": "^4.2.0",
|
|
@@ -149,32 +149,32 @@
|
|
|
149
149
|
"devDependencies": {
|
|
150
150
|
"@aws-crypto/client-node": "^4.2.2",
|
|
151
151
|
"@eslint/js": "^10.0.1",
|
|
152
|
-
"@treatwell/eslint-plugin-moleculer": "^1.1.
|
|
152
|
+
"@treatwell/eslint-plugin-moleculer": "^1.1.4",
|
|
153
153
|
"@tsconfig/node-lts": "^24.0.0",
|
|
154
154
|
"@types/jsonwebtoken": "^9.0.10",
|
|
155
|
-
"@types/node": "^24.
|
|
155
|
+
"@types/node": "^24.13.3",
|
|
156
156
|
"@types/redlock": "^4.0.8",
|
|
157
157
|
"bullmq": "^5.71.1",
|
|
158
|
-
"eslint": "^10.1
|
|
158
|
+
"eslint": "^10.8.1",
|
|
159
159
|
"eslint-config-prettier": "^10.1.8",
|
|
160
|
-
"eslint-import-resolver-typescript": "^4.4.
|
|
160
|
+
"eslint-import-resolver-typescript": "^4.4.5",
|
|
161
161
|
"eslint-plugin-import": "^2.32.0",
|
|
162
|
-
"eslint-plugin-prettier": "^5.5.
|
|
162
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
163
163
|
"ioredis": "^5.10.1",
|
|
164
|
-
"jiti": "^2.
|
|
164
|
+
"jiti": "^2.7.0",
|
|
165
165
|
"jsonwebtoken": "^9.0.3",
|
|
166
166
|
"jwks-rsa": "^4.0.1",
|
|
167
|
-
"moleculer": "^0.15.
|
|
168
|
-
"mongodb": "^7.
|
|
169
|
-
"mongodb-memory-server": "^11.0
|
|
170
|
-
"pkgroll": "2.27.
|
|
171
|
-
"prettier": "^3.
|
|
167
|
+
"moleculer": "^0.15.1",
|
|
168
|
+
"mongodb": "^7.5.0",
|
|
169
|
+
"mongodb-memory-server": "^11.2.0",
|
|
170
|
+
"pkgroll": "2.27.1",
|
|
171
|
+
"prettier": "^3.9.6",
|
|
172
172
|
"redlock": "^4.2.0",
|
|
173
|
-
"semantic-release": "^25.0.
|
|
173
|
+
"semantic-release": "^25.0.9",
|
|
174
174
|
"typescript": "~5.9.3",
|
|
175
|
-
"typescript-eslint": "^8.
|
|
176
|
-
"vitest": "^4.1.
|
|
177
|
-
"zod": "^4.3
|
|
175
|
+
"typescript-eslint": "^8.67.0",
|
|
176
|
+
"vitest": "^4.1.10",
|
|
177
|
+
"zod": "^4.4.3"
|
|
178
178
|
},
|
|
179
179
|
"files": [
|
|
180
180
|
"dist"
|
|
@@ -182,5 +182,5 @@
|
|
|
182
182
|
"publishConfig": {
|
|
183
183
|
"access": "public"
|
|
184
184
|
},
|
|
185
|
-
"packageManager": "yarn@4.
|
|
185
|
+
"packageManager": "yarn@4.18.0"
|
|
186
186
|
}
|