@adaptivestone/framework 5.0.0-beta.44 → 5.0.0-beta.47
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/CHANGELOG.md +30 -2
- package/dist/codegen/appTypes.d.ts +19 -0
- package/dist/codegen/appTypes.js +49 -0
- package/dist/codegen/appTypes.js.map +1 -0
- package/dist/codegen/collectMetadata.d.ts +37 -0
- package/dist/codegen/collectMetadata.js +51 -0
- package/dist/codegen/collectMetadata.js.map +1 -0
- package/dist/codegen/emit.d.ts +29 -0
- package/dist/codegen/emit.js +214 -0
- package/dist/codegen/emit.js.map +1 -0
- package/dist/codegen/index.d.ts +16 -0
- package/dist/codegen/index.js +18 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/routeTypes.d.ts +13 -0
- package/dist/codegen/routeTypes.js +126 -0
- package/dist/codegen/routeTypes.js.map +1 -0
- package/dist/commands/GenerateTypes.d.ts +0 -4
- package/dist/commands/GenerateTypes.js +4 -42
- package/dist/commands/GenerateTypes.js.map +1 -1
- package/dist/controllers/Auth.d.ts +15 -124
- package/dist/controllers/Auth.js.map +1 -1
- package/dist/controllers/Auth.routes.gen.d.ts +57 -0
- package/dist/controllers/Auth.routes.gen.js +10 -0
- package/dist/controllers/Auth.routes.gen.js.map +1 -0
- package/dist/controllers/Home.routes.gen.d.ts +14 -0
- package/dist/controllers/Home.routes.gen.js +10 -0
- package/dist/controllers/Home.routes.gen.js.map +1 -0
- package/dist/controllers/index.d.ts +23 -3
- package/dist/controllers/index.js +355 -8
- package/dist/controllers/index.js.map +1 -1
- package/dist/helpers/files.js +2 -0
- package/dist/helpers/files.js.map +1 -1
- package/dist/helpers/logger.d.ts +1 -1
- package/dist/helpers/logger.js +1 -1
- package/dist/helpers/logger.js.map +1 -1
- package/dist/models/Lock.js +1 -1
- package/dist/models/Lock.js.map +1 -1
- package/dist/models/Sequence.js +1 -1
- package/dist/models/Sequence.js.map +1 -1
- package/dist/models/User.d.ts +28 -28
- package/dist/models/UserOld.d.ts +16 -6
- package/dist/modules/AbstractController.d.ts +10 -31
- package/dist/modules/AbstractController.js +1 -253
- package/dist/modules/AbstractController.js.map +1 -1
- package/dist/modules/BaseCli.d.ts +1 -1
- package/dist/modules/BaseCli.js +1 -0
- package/dist/modules/BaseCli.js.map +1 -1
- package/dist/server.d.ts +2 -3
- package/dist/server.js +11 -1
- package/dist/server.js.map +1 -1
- package/dist/services/cache/Cache.d.ts +1 -1
- package/dist/services/cache/Cache.js +9 -8
- package/dist/services/cache/Cache.js.map +1 -1
- package/dist/services/http/HttpServer.d.ts +9 -0
- package/dist/services/http/HttpServer.js +20 -9
- package/dist/services/http/HttpServer.js.map +1 -1
- package/dist/services/http/middleware/AbstractMiddleware.d.ts +19 -4
- package/dist/services/http/middleware/AbstractMiddleware.js +16 -5
- package/dist/services/http/middleware/AbstractMiddleware.js.map +1 -1
- package/dist/services/http/middleware/GetUserByToken.d.ts +9 -0
- package/dist/services/http/middleware/GetUserByToken.js +9 -0
- package/dist/services/http/middleware/GetUserByToken.js.map +1 -1
- package/dist/services/http/routing/ExpressAdapter.d.ts +12 -0
- package/dist/services/http/routing/ExpressAdapter.js +93 -0
- package/dist/services/http/routing/ExpressAdapter.js.map +1 -0
- package/dist/services/http/routing/RouteNode.d.ts +99 -0
- package/dist/services/http/routing/RouteNode.js +21 -0
- package/dist/services/http/routing/RouteNode.js.map +1 -0
- package/dist/services/http/routing/RouteRegistry.d.ts +37 -0
- package/dist/services/http/routing/RouteRegistry.js +207 -0
- package/dist/services/http/routing/RouteRegistry.js.map +1 -0
- package/dist/services/http/routing/formatTree.d.ts +23 -0
- package/dist/services/http/routing/formatTree.js +158 -0
- package/dist/services/http/routing/formatTree.js.map +1 -0
- package/dist/services/http/routing/match.d.ts +30 -0
- package/dist/services/http/routing/match.js +128 -0
- package/dist/services/http/routing/match.js.map +1 -0
- package/dist/services/http/routing/middlewareNormalization.d.ts +16 -0
- package/dist/services/http/routing/middlewareNormalization.js +28 -0
- package/dist/services/http/routing/middlewareNormalization.js.map +1 -0
- package/dist/services/http/types.d.ts +74 -0
- package/dist/services/http/types.js +8 -0
- package/dist/services/http/types.js.map +1 -0
- package/dist/services/logging/SentryTransport.js +2 -2
- package/dist/services/logging/SentryTransport.js.map +1 -1
- package/dist/services/validate/ValidateService.d.ts +46 -23
- package/dist/services/validate/ValidateService.js +101 -74
- package/dist/services/validate/ValidateService.js.map +1 -1
- package/dist/services/validate/ValidationError.d.ts +35 -0
- package/dist/services/validate/ValidationError.js +77 -0
- package/dist/services/validate/ValidationError.js.map +1 -0
- package/dist/services/validate/drivers/StandardSchemaDriver.d.ts +15 -0
- package/dist/services/validate/drivers/StandardSchemaDriver.js +34 -0
- package/dist/services/validate/drivers/StandardSchemaDriver.js.map +1 -0
- package/dist/services/validate/drivers/YupDriver.d.ts +21 -0
- package/dist/services/validate/drivers/YupDriver.js +66 -0
- package/dist/services/validate/drivers/YupDriver.js.map +1 -0
- package/dist/services/validate/types.d.ts +104 -0
- package/dist/services/validate/types.js +11 -0
- package/dist/services/validate/types.js.map +1 -0
- package/dist/tests/setupVitest.js +4 -1
- package/dist/tests/setupVitest.js.map +1 -1
- package/dist/tests/testHelpers.d.ts +18 -16
- package/package.json +19 -10
- package/dist/commands/Documentation.d.ts +0 -5
- package/dist/commands/Documentation.js +0 -15
- package/dist/commands/Documentation.js.map +0 -1
- package/dist/commands/GetOpenApiJson.d.ts +0 -17
- package/dist/commands/GetOpenApiJson.js +0 -272
- package/dist/commands/GetOpenApiJson.js.map +0 -1
- package/dist/services/documentation/DocumentationGenerator.d.ts +0 -11
- package/dist/services/documentation/DocumentationGenerator.js +0 -130
- package/dist/services/documentation/DocumentationGenerator.js.map +0 -1
- package/dist/services/validate/drivers/AbstractValidator.d.ts +0 -14
- package/dist/services/validate/drivers/AbstractValidator.js +0 -29
- package/dist/services/validate/drivers/AbstractValidator.js.map +0 -1
- package/dist/services/validate/drivers/CustomValidator.d.ts +0 -14
- package/dist/services/validate/drivers/CustomValidator.js +0 -48
- package/dist/services/validate/drivers/CustomValidator.js.map +0 -1
- package/dist/services/validate/drivers/YupValidator.d.ts +0 -13
- package/dist/services/validate/drivers/YupValidator.js +0 -86
- package/dist/services/validate/drivers/YupValidator.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ValidationIssue } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The wire shape that goes out via `res.json({ errors: err.message })`.
|
|
4
|
+
*
|
|
5
|
+
* Each key is a field path. Each value is either a single message string
|
|
6
|
+
* or an array of messages. Both forms are preserved as-given — no
|
|
7
|
+
* normalization — so consumers see the same response bytes regardless
|
|
8
|
+
* of which validator produced the error.
|
|
9
|
+
*/
|
|
10
|
+
export type ValidationErrorPayload = Record<string, string | string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Framework-owned validation error. Replaces yup's `ValidationError` at the
|
|
13
|
+
* framework layer.
|
|
14
|
+
*
|
|
15
|
+
* Wire compatibility note — `.message` is the path-keyed payload object,
|
|
16
|
+
* NOT a string. This mirrors yup's hack: `res.json({ errors: err.message })`
|
|
17
|
+
* in `AbstractController.ts:222` serializes the object directly to produce
|
|
18
|
+
* `{ "errors": { "fieldName": [...] | "...", ... } }`. Existing user
|
|
19
|
+
* catch-blocks that read `err.message` keep working unchanged.
|
|
20
|
+
*
|
|
21
|
+
* `.issues` is the canonical list (one entry per field/message pair) that
|
|
22
|
+
* non-wire consumers (logging, observability) should iterate.
|
|
23
|
+
*/
|
|
24
|
+
export declare class ValidationError extends Error {
|
|
25
|
+
issues: ValidationIssue[];
|
|
26
|
+
message: ValidationErrorPayload;
|
|
27
|
+
constructor(payload: ValidationErrorPayload | ReadonlyArray<ValidationIssue>);
|
|
28
|
+
/**
|
|
29
|
+
* Cross-realm-safe duck check. Mirrors `yup.ValidationError.isError`.
|
|
30
|
+
* Use this in framework code instead of `instanceof` when the error
|
|
31
|
+
* may have crossed a module-graph boundary.
|
|
32
|
+
*/
|
|
33
|
+
static isValidationError(err: unknown): err is ValidationError;
|
|
34
|
+
}
|
|
35
|
+
export declare function issuesToPayload(issues: ReadonlyArray<ValidationIssue>): ValidationErrorPayload;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-owned validation error. Replaces yup's `ValidationError` at the
|
|
3
|
+
* framework layer.
|
|
4
|
+
*
|
|
5
|
+
* Wire compatibility note — `.message` is the path-keyed payload object,
|
|
6
|
+
* NOT a string. This mirrors yup's hack: `res.json({ errors: err.message })`
|
|
7
|
+
* in `AbstractController.ts:222` serializes the object directly to produce
|
|
8
|
+
* `{ "errors": { "fieldName": [...] | "...", ... } }`. Existing user
|
|
9
|
+
* catch-blocks that read `err.message` keep working unchanged.
|
|
10
|
+
*
|
|
11
|
+
* `.issues` is the canonical list (one entry per field/message pair) that
|
|
12
|
+
* non-wire consumers (logging, observability) should iterate.
|
|
13
|
+
*/
|
|
14
|
+
export class ValidationError extends Error {
|
|
15
|
+
issues;
|
|
16
|
+
constructor(payload) {
|
|
17
|
+
super();
|
|
18
|
+
this.name = 'ValidationError';
|
|
19
|
+
if (Array.isArray(payload)) {
|
|
20
|
+
const issues = [...payload];
|
|
21
|
+
this.issues = issues;
|
|
22
|
+
this.message = issuesToPayload(issues);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const obj = { ...payload };
|
|
26
|
+
this.issues = payloadToIssues(obj);
|
|
27
|
+
// Normalize: even when constructed from a string-valued payload,
|
|
28
|
+
// canonical .message is always-array.
|
|
29
|
+
this.message = issuesToPayload(this.issues);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Cross-realm-safe duck check. Mirrors `yup.ValidationError.isError`.
|
|
34
|
+
* Use this in framework code instead of `instanceof` when the error
|
|
35
|
+
* may have crossed a module-graph boundary.
|
|
36
|
+
*/
|
|
37
|
+
static isValidationError(err) {
|
|
38
|
+
return (err instanceof Error &&
|
|
39
|
+
err.name === 'ValidationError');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function payloadToIssues(payload) {
|
|
43
|
+
const issues = [];
|
|
44
|
+
for (const [path, value] of Object.entries(payload)) {
|
|
45
|
+
const messages = Array.isArray(value) ? value : [value];
|
|
46
|
+
for (const message of messages) {
|
|
47
|
+
issues.push({ message, path: path === '' ? undefined : [path] });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return issues;
|
|
51
|
+
}
|
|
52
|
+
export function issuesToPayload(issues) {
|
|
53
|
+
// Always emit arrays per path, matching the existing yup-pipeline wire
|
|
54
|
+
// shape: `{path: ["msg"]}` even for a single error. Single-string form
|
|
55
|
+
// is still accepted as constructor input, but the canonical output is
|
|
56
|
+
// always an array.
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const issue of issues) {
|
|
59
|
+
const path = pathToString(issue.path);
|
|
60
|
+
if (!out[path]) {
|
|
61
|
+
out[path] = [];
|
|
62
|
+
}
|
|
63
|
+
out[path].push(issue.message);
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
function pathToString(path) {
|
|
68
|
+
if (!path || path.length === 0) {
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
return path
|
|
72
|
+
.map((segment) => typeof segment === 'object' && segment !== null && 'key' in segment
|
|
73
|
+
? String(segment.key)
|
|
74
|
+
: String(segment))
|
|
75
|
+
.join('.');
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationError.js","sourceRoot":"","sources":["../../../src/services/validate/ValidationError.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,MAAM,CAAoB;IAQ1B,YACE,OAAgE;QAEhE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAE9B,IAA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C,uEAAuE;IACvE,uEAAuE;IACvE,sEAAsE;IACtE,mBAAmB;IACnB,MAAM,GAAG,GAA6B,EAAE,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACf,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACjB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,YAAY,CAAC,IAAyC;IAC7D,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACf,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,KAAK,IAAI,OAAO;QACjE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB;SACA,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ValidatorDriver } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Generic Standard Schema driver. Handles any validator that implements
|
|
4
|
+
* the `~standard` interface (zod ≥3.24, valibot, arktype, custom user
|
|
5
|
+
* Standard-Schema-conformant shapes — and yup, when no more-specific
|
|
6
|
+
* driver is registered).
|
|
7
|
+
*
|
|
8
|
+
* Most popular libs strip unknown fields by default in their Standard
|
|
9
|
+
* Schema validate (zod, valibot, arktype). Yup is the outlier — see
|
|
10
|
+
* `YupDriver.ts` for the strip-preserving fast path.
|
|
11
|
+
*
|
|
12
|
+
* `toJsonSchema` returns null here; per-vendor drivers can override
|
|
13
|
+
* with their own native exporters when OpenAPI export is needed.
|
|
14
|
+
*/
|
|
15
|
+
export declare const standardSchemaDriver: ValidatorDriver;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ValidationError } from "../ValidationError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generic Standard Schema driver. Handles any validator that implements
|
|
4
|
+
* the `~standard` interface (zod ≥3.24, valibot, arktype, custom user
|
|
5
|
+
* Standard-Schema-conformant shapes — and yup, when no more-specific
|
|
6
|
+
* driver is registered).
|
|
7
|
+
*
|
|
8
|
+
* Most popular libs strip unknown fields by default in their Standard
|
|
9
|
+
* Schema validate (zod, valibot, arktype). Yup is the outlier — see
|
|
10
|
+
* `YupDriver.ts` for the strip-preserving fast path.
|
|
11
|
+
*
|
|
12
|
+
* `toJsonSchema` returns null here; per-vendor drivers can override
|
|
13
|
+
* with their own native exporters when OpenAPI export is needed.
|
|
14
|
+
*/
|
|
15
|
+
export const standardSchemaDriver = {
|
|
16
|
+
canHandle(body) {
|
|
17
|
+
return (typeof body === 'object' &&
|
|
18
|
+
body !== null &&
|
|
19
|
+
'~standard' in body &&
|
|
20
|
+
typeof body['~standard'] === 'object');
|
|
21
|
+
},
|
|
22
|
+
async validate(body, data) {
|
|
23
|
+
const std = body['~standard'];
|
|
24
|
+
const result = await std.validate(data);
|
|
25
|
+
if (result.issues) {
|
|
26
|
+
throw new ValidationError(result.issues);
|
|
27
|
+
}
|
|
28
|
+
return result.value;
|
|
29
|
+
},
|
|
30
|
+
toJsonSchema() {
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=StandardSchemaDriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StandardSchemaDriver.js","sourceRoot":"","sources":["../../../../src/services/validate/drivers/StandardSchemaDriver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAoB;IACnD,SAAS,CAAC,IAAa;QACrB,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,IAAI;YACb,WAAW,IAAI,IAAI;YACnB,OAAQ,IAAkC,CAAC,WAAW,CAAC,KAAK,QAAQ,CACrE,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAa,EAAE,IAAa;QACzC,MAAM,GAAG,GAAI,IAAyB,CAAC,WAAW,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ValidatorDriver } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Yup-vendor driver. Handles `body['~standard'].vendor === 'yup'`.
|
|
4
|
+
*
|
|
5
|
+
* Two yup-specific behaviors that the generic Standard Schema driver
|
|
6
|
+
* doesn't cover:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Strip unknown.** Yup's `~standard.validate(data)` does NOT strip
|
|
9
|
+
* unknown fields. Today's framework calls `cast(data, {stripUnknown: true})`
|
|
10
|
+
* explicitly. To preserve that behavior — and avoid a security
|
|
11
|
+
* regression in handlers that spread `req.appInfo.request` into
|
|
12
|
+
* `Model.create(...)` — this driver calls yup's native validate with
|
|
13
|
+
* `{ stripUnknown: true, abortEarly: false }` directly. One call:
|
|
14
|
+
* validates + casts + strips, throws on issues.
|
|
15
|
+
*
|
|
16
|
+
* 2. **Error translation.** Yup throws its own `ValidationError` with
|
|
17
|
+
* `.inner[]` (one entry per failed field) and `.errors[]` (messages).
|
|
18
|
+
* We translate to the framework's `ValidationError` via duck-typing
|
|
19
|
+
* (no top-level yup import — keeps the framework runtime decoupled).
|
|
20
|
+
*/
|
|
21
|
+
export declare const yupDriver: ValidatorDriver;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ValidationError } from "../ValidationError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Yup-vendor driver. Handles `body['~standard'].vendor === 'yup'`.
|
|
4
|
+
*
|
|
5
|
+
* Two yup-specific behaviors that the generic Standard Schema driver
|
|
6
|
+
* doesn't cover:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Strip unknown.** Yup's `~standard.validate(data)` does NOT strip
|
|
9
|
+
* unknown fields. Today's framework calls `cast(data, {stripUnknown: true})`
|
|
10
|
+
* explicitly. To preserve that behavior — and avoid a security
|
|
11
|
+
* regression in handlers that spread `req.appInfo.request` into
|
|
12
|
+
* `Model.create(...)` — this driver calls yup's native validate with
|
|
13
|
+
* `{ stripUnknown: true, abortEarly: false }` directly. One call:
|
|
14
|
+
* validates + casts + strips, throws on issues.
|
|
15
|
+
*
|
|
16
|
+
* 2. **Error translation.** Yup throws its own `ValidationError` with
|
|
17
|
+
* `.inner[]` (one entry per failed field) and `.errors[]` (messages).
|
|
18
|
+
* We translate to the framework's `ValidationError` via duck-typing
|
|
19
|
+
* (no top-level yup import — keeps the framework runtime decoupled).
|
|
20
|
+
*/
|
|
21
|
+
export const yupDriver = {
|
|
22
|
+
canHandle(body) {
|
|
23
|
+
return (typeof body === 'object' &&
|
|
24
|
+
body !== null &&
|
|
25
|
+
'~standard' in body &&
|
|
26
|
+
body['~standard']?.vendor === 'yup');
|
|
27
|
+
},
|
|
28
|
+
async validate(body, data) {
|
|
29
|
+
try {
|
|
30
|
+
return await body.validate(data, {
|
|
31
|
+
stripUnknown: true,
|
|
32
|
+
abortEarly: false,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
if (isYupValidationError(e)) {
|
|
37
|
+
throw fromYupError(e);
|
|
38
|
+
}
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
toJsonSchema() {
|
|
43
|
+
return null;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
function isYupValidationError(e) {
|
|
47
|
+
return (typeof e === 'object' &&
|
|
48
|
+
e !== null &&
|
|
49
|
+
e.name === 'ValidationError' &&
|
|
50
|
+
Array.isArray(e.inner));
|
|
51
|
+
}
|
|
52
|
+
function fromYupError(e) {
|
|
53
|
+
const issues = [];
|
|
54
|
+
const inners = Array.isArray(e.inner) && e.inner.length > 0 ? e.inner : [e];
|
|
55
|
+
for (const inner of inners) {
|
|
56
|
+
const path = inner.path ? [inner.path] : undefined;
|
|
57
|
+
const messages = Array.isArray(inner.errors)
|
|
58
|
+
? inner.errors
|
|
59
|
+
: [inner.message];
|
|
60
|
+
for (const message of messages) {
|
|
61
|
+
issues.push({ message, path, params: inner.params });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return new ValidationError(issues);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=YupDriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YupDriver.js","sourceRoot":"","sources":["../../../../src/services/validate/drivers/YupDriver.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoB;IACxC,SAAS,CAAC,IAAa;QACrB,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,IAAI;YACb,WAAW,IAAI,IAAI;YAClB,IAAyB,CAAC,WAAW,CAAC,EAAE,MAAM,KAAK,KAAK,CAC1D,CAAC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AAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validator type contracts.
|
|
3
|
+
*
|
|
4
|
+
* Standard Schema v1 spec types are inlined from https://standardschema.dev to
|
|
5
|
+
* avoid a runtime dependency. Any conforming schema (yup ≥1.7, zod ≥3.24,
|
|
6
|
+
* valibot, arktype, ...) plugs in as a route's `request` or `query` schema.
|
|
7
|
+
*
|
|
8
|
+
* If the upstream spec evolves, mirror it here.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Spec interface implemented by Standard Schema-compliant validators.
|
|
12
|
+
*/
|
|
13
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
14
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
15
|
+
}
|
|
16
|
+
export declare namespace StandardSchemaV1 {
|
|
17
|
+
interface Props<Input = unknown, Output = Input> {
|
|
18
|
+
readonly version: 1;
|
|
19
|
+
readonly vendor: string;
|
|
20
|
+
readonly validate: (value: unknown, options?: Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
21
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface Options {
|
|
24
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
25
|
+
}
|
|
26
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
27
|
+
interface SuccessResult<Output> {
|
|
28
|
+
readonly value: Output;
|
|
29
|
+
readonly issues?: undefined;
|
|
30
|
+
}
|
|
31
|
+
interface FailureResult {
|
|
32
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
33
|
+
}
|
|
34
|
+
interface Issue {
|
|
35
|
+
readonly message: string;
|
|
36
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
37
|
+
}
|
|
38
|
+
interface PathSegment {
|
|
39
|
+
readonly key: PropertyKey;
|
|
40
|
+
}
|
|
41
|
+
interface Types<Input = unknown, Output = Input> {
|
|
42
|
+
readonly input: Input;
|
|
43
|
+
readonly output: Output;
|
|
44
|
+
}
|
|
45
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
46
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* One validation issue surfaced to the consumer. Shape mirrors
|
|
50
|
+
* `StandardSchemaV1.Issue` so iterating issues from a `ValidationError`
|
|
51
|
+
* works the same regardless of the underlying validator.
|
|
52
|
+
*/
|
|
53
|
+
export interface ValidationIssue {
|
|
54
|
+
readonly message: string;
|
|
55
|
+
readonly path?: ReadonlyArray<PropertyKey | {
|
|
56
|
+
readonly key: PropertyKey;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Extra context for message interpolation (e.g., yup populates `min`,
|
|
60
|
+
* `max`, `length` for those validators). Passed to `t(message, fallback,
|
|
61
|
+
* params)` when the framework auto-translates so i18n placeholders
|
|
62
|
+
* like `{{min}}` resolve to actual values.
|
|
63
|
+
*/
|
|
64
|
+
readonly params?: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Framework-owned validation error contract. The runtime class is in
|
|
68
|
+
* `./ValidationError.ts`. This interface is what handler catch-blocks
|
|
69
|
+
* (and the top-level error boundary) read to surface field-keyed
|
|
70
|
+
* messages back to the client.
|
|
71
|
+
*/
|
|
72
|
+
export interface ValidationError extends Error {
|
|
73
|
+
readonly name: 'ValidationError';
|
|
74
|
+
readonly issues: ReadonlyArray<ValidationIssue>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* JSON Schema document. Loose typing; downstream consumers (e.g., an
|
|
78
|
+
* OpenAPI generator) refine to a stricter shape.
|
|
79
|
+
*/
|
|
80
|
+
export type JsonSchema = Record<string, unknown>;
|
|
81
|
+
/**
|
|
82
|
+
* A pluggable validator driver. The framework dispatches one driver
|
|
83
|
+
* per route schema; drivers handle vendor-specific quirks (yup's
|
|
84
|
+
* `stripUnknown` post-process, native JSON Schema export, etc.).
|
|
85
|
+
*
|
|
86
|
+
* Built-in drivers live in `./drivers/`. Users register their own via
|
|
87
|
+
* `ValidateService.register(driver)` to support non-Standard-Schema
|
|
88
|
+
* validators (raw Joi, custom shapes, ...).
|
|
89
|
+
*
|
|
90
|
+
* Concerns:
|
|
91
|
+
* - Runtime validation + cast → `validate`
|
|
92
|
+
* - JSON Schema for OpenAPI → `toJsonSchema?` (optional)
|
|
93
|
+
* - Compile-time TS types → schema-side, not driver — see `StandardSchemaV1.InferOutput`
|
|
94
|
+
*/
|
|
95
|
+
export interface ValidatorDriver {
|
|
96
|
+
/** Sync dispatch; should be a fast property check. */
|
|
97
|
+
canHandle(body: unknown): boolean;
|
|
98
|
+
/** Validate + cast. Returns the cast value on success; throws `ValidationError` on failure. */
|
|
99
|
+
validate(body: unknown, data: unknown): Promise<unknown>;
|
|
100
|
+
/** Optional: emit JSON Schema. Returns null when introspection isn't supported. */
|
|
101
|
+
toJsonSchema?(body: unknown, opts?: {
|
|
102
|
+
target?: 'openapi-3.0' | 'draft-07' | 'draft-2020-12';
|
|
103
|
+
}): JsonSchema | null;
|
|
104
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validator type contracts.
|
|
3
|
+
*
|
|
4
|
+
* Standard Schema v1 spec types are inlined from https://standardschema.dev to
|
|
5
|
+
* avoid a runtime dependency. Any conforming schema (yup ≥1.7, zod ≥3.24,
|
|
6
|
+
* valibot, arktype, ...) plugs in as a route's `request` or `query` schema.
|
|
7
|
+
*
|
|
8
|
+
* If the upstream spec evolves, mirror it here.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/validate/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -5,6 +5,7 @@ import mongoose from 'mongoose'; // we do not need create indexes on tests
|
|
|
5
5
|
import { afterAll, afterEach, beforeAll, beforeEach } from 'vitest';
|
|
6
6
|
import { clearNamespace } from "../helpers/redis/clearNamespace.js";
|
|
7
7
|
import Server from "../server.js";
|
|
8
|
+
import SomeController from "./fixtures/controllers/SomeController.js";
|
|
8
9
|
import { serverInstance, setServerInstance } from "./testHelpers.js";
|
|
9
10
|
mongoose.set('autoIndex', false);
|
|
10
11
|
const basePath = new URL('.', import.meta.url).pathname;
|
|
@@ -48,7 +49,9 @@ beforeAll(async () => {
|
|
|
48
49
|
// if (typeof global.testSetup.beforeAll === 'function') {
|
|
49
50
|
// await global.testSetup.beforeAll();
|
|
50
51
|
// }
|
|
51
|
-
await server.startServer()
|
|
52
|
+
await server.startServer(async () => {
|
|
53
|
+
server.app.controllerManager?.registerController(SomeController, 'test');
|
|
54
|
+
});
|
|
52
55
|
});
|
|
53
56
|
beforeEach(() => {
|
|
54
57
|
if (serverInstance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupVitest.js","sourceRoot":"","sources":["../../src/tests/setupVitest.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,QAAQ,MAAM,UAAU,CAAC,CAAC,yCAAyC;AAC1E,OAAO,EAAE,QAAQ,EAAE,SA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AAC,UAAU,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|
|
@@ -12,13 +12,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
12
12
|
user: import("mongoose").Document<unknown, object, {
|
|
13
13
|
isVerified: boolean;
|
|
14
14
|
locale: string;
|
|
15
|
+
createdAt?: NativeDate | null | undefined;
|
|
16
|
+
updatedAt?: NativeDate | null | undefined;
|
|
15
17
|
name?: {
|
|
16
18
|
first?: string | null | undefined;
|
|
17
19
|
last?: string | null | undefined;
|
|
18
20
|
nick?: string | null | undefined;
|
|
19
21
|
} | null | undefined;
|
|
20
|
-
createdAt?: NativeDate | null | undefined;
|
|
21
|
-
updatedAt?: NativeDate | null | undefined;
|
|
22
22
|
avatar?: string | null | undefined;
|
|
23
23
|
password?: string | null | undefined;
|
|
24
24
|
email?: string | null | undefined;
|
|
@@ -48,13 +48,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
48
48
|
}, {}, import("mongoose").DefaultSchemaOptions> & Omit<{
|
|
49
49
|
isVerified: boolean;
|
|
50
50
|
locale: string;
|
|
51
|
+
createdAt?: NativeDate | null | undefined;
|
|
52
|
+
updatedAt?: NativeDate | null | undefined;
|
|
51
53
|
name?: {
|
|
52
54
|
first?: string | null | undefined;
|
|
53
55
|
last?: string | null | undefined;
|
|
54
56
|
nick?: string | null | undefined;
|
|
55
57
|
} | null | undefined;
|
|
56
|
-
createdAt?: NativeDate | null | undefined;
|
|
57
|
-
updatedAt?: NativeDate | null | undefined;
|
|
58
58
|
avatar?: string | null | undefined;
|
|
59
59
|
password?: string | null | undefined;
|
|
60
60
|
email?: string | null | undefined;
|
|
@@ -100,13 +100,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
100
100
|
readonly sendPasswordRecoveryEmail: (this: import("mongoose").Document<unknown, {}, {
|
|
101
101
|
isVerified: boolean;
|
|
102
102
|
locale: string;
|
|
103
|
+
createdAt?: NativeDate | null | undefined;
|
|
104
|
+
updatedAt?: NativeDate | null | undefined;
|
|
103
105
|
name?: {
|
|
104
106
|
first?: string | null | undefined;
|
|
105
107
|
last?: string | null | undefined;
|
|
106
108
|
nick?: string | null | undefined;
|
|
107
109
|
} | null | undefined;
|
|
108
|
-
createdAt?: NativeDate | null | undefined;
|
|
109
|
-
updatedAt?: NativeDate | null | undefined;
|
|
110
110
|
avatar?: string | null | undefined;
|
|
111
111
|
password?: string | null | undefined;
|
|
112
112
|
email?: string | null | undefined;
|
|
@@ -136,13 +136,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
136
136
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
137
137
|
isVerified: boolean;
|
|
138
138
|
locale: string;
|
|
139
|
+
createdAt?: NativeDate | null | undefined;
|
|
140
|
+
updatedAt?: NativeDate | null | undefined;
|
|
139
141
|
name?: {
|
|
140
142
|
first?: string | null | undefined;
|
|
141
143
|
last?: string | null | undefined;
|
|
142
144
|
nick?: string | null | undefined;
|
|
143
145
|
} | null | undefined;
|
|
144
|
-
createdAt?: NativeDate | null | undefined;
|
|
145
|
-
updatedAt?: NativeDate | null | undefined;
|
|
146
146
|
avatar?: string | null | undefined;
|
|
147
147
|
password?: string | null | undefined;
|
|
148
148
|
email?: string | null | undefined;
|
|
@@ -182,13 +182,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
182
182
|
readonly sendVerificationEmail: (this: import("mongoose").Document<unknown, {}, {
|
|
183
183
|
isVerified: boolean;
|
|
184
184
|
locale: string;
|
|
185
|
+
createdAt?: NativeDate | null | undefined;
|
|
186
|
+
updatedAt?: NativeDate | null | undefined;
|
|
185
187
|
name?: {
|
|
186
188
|
first?: string | null | undefined;
|
|
187
189
|
last?: string | null | undefined;
|
|
188
190
|
nick?: string | null | undefined;
|
|
189
191
|
} | null | undefined;
|
|
190
|
-
createdAt?: NativeDate | null | undefined;
|
|
191
|
-
updatedAt?: NativeDate | null | undefined;
|
|
192
192
|
avatar?: string | null | undefined;
|
|
193
193
|
password?: string | null | undefined;
|
|
194
194
|
email?: string | null | undefined;
|
|
@@ -218,13 +218,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
218
218
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
219
219
|
isVerified: boolean;
|
|
220
220
|
locale: string;
|
|
221
|
+
createdAt?: NativeDate | null | undefined;
|
|
222
|
+
updatedAt?: NativeDate | null | undefined;
|
|
221
223
|
name?: {
|
|
222
224
|
first?: string | null | undefined;
|
|
223
225
|
last?: string | null | undefined;
|
|
224
226
|
nick?: string | null | undefined;
|
|
225
227
|
} | null | undefined;
|
|
226
|
-
createdAt?: NativeDate | null | undefined;
|
|
227
|
-
updatedAt?: NativeDate | null | undefined;
|
|
228
228
|
avatar?: string | null | undefined;
|
|
229
229
|
password?: string | null | undefined;
|
|
230
230
|
email?: string | null | undefined;
|
|
@@ -264,13 +264,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
264
264
|
readonly getPublic: (this: import("mongoose").Document<unknown, {}, {
|
|
265
265
|
isVerified: boolean;
|
|
266
266
|
locale: string;
|
|
267
|
+
createdAt?: NativeDate | null | undefined;
|
|
268
|
+
updatedAt?: NativeDate | null | undefined;
|
|
267
269
|
name?: {
|
|
268
270
|
first?: string | null | undefined;
|
|
269
271
|
last?: string | null | undefined;
|
|
270
272
|
nick?: string | null | undefined;
|
|
271
273
|
} | null | undefined;
|
|
272
|
-
createdAt?: NativeDate | null | undefined;
|
|
273
|
-
updatedAt?: NativeDate | null | undefined;
|
|
274
274
|
avatar?: string | null | undefined;
|
|
275
275
|
password?: string | null | undefined;
|
|
276
276
|
email?: string | null | undefined;
|
|
@@ -300,13 +300,13 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
300
300
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
301
301
|
isVerified: boolean;
|
|
302
302
|
locale: string;
|
|
303
|
+
createdAt?: NativeDate | null | undefined;
|
|
304
|
+
updatedAt?: NativeDate | null | undefined;
|
|
303
305
|
name?: {
|
|
304
306
|
first?: string | null | undefined;
|
|
305
307
|
last?: string | null | undefined;
|
|
306
308
|
nick?: string | null | undefined;
|
|
307
309
|
} | null | undefined;
|
|
308
|
-
createdAt?: NativeDate | null | undefined;
|
|
309
|
-
updatedAt?: NativeDate | null | undefined;
|
|
310
310
|
avatar?: string | null | undefined;
|
|
311
311
|
password?: string | null | undefined;
|
|
312
312
|
email?: string | null | undefined;
|
|
@@ -354,6 +354,8 @@ export declare const createDefaultTestUser: () => Promise<false | {
|
|
|
354
354
|
};
|
|
355
355
|
} & {
|
|
356
356
|
id: string;
|
|
357
|
+
} & {
|
|
358
|
+
id: string;
|
|
357
359
|
};
|
|
358
360
|
token: string;
|
|
359
361
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptivestone/framework",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.47",
|
|
4
4
|
"description": "Adaptive stone node js framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -18,22 +18,26 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "rm -rf dist && tsc",
|
|
20
20
|
"postbuild": "cp -R ./src/migrations ./dist/migrations",
|
|
21
|
-
"check:types": "tsc --noEmit",
|
|
21
|
+
"check:types": "npm run gen && tsc --noEmit",
|
|
22
|
+
"check:types:raw": "tsc --noEmit",
|
|
22
23
|
"dev": "node --watch ./src/index.ts",
|
|
23
24
|
"prod": "node --watch ./src/cluster.ts",
|
|
24
25
|
"test": "vitest run",
|
|
25
26
|
"t": "vitest --coverage=false --reporter=default",
|
|
26
27
|
"format": "biome format",
|
|
27
28
|
"format:fix": "biome format --write",
|
|
28
|
-
"knip": "knip",
|
|
29
29
|
"lint": "biome lint",
|
|
30
30
|
"lint:fix": "biome lint --write",
|
|
31
31
|
"check": "biome check",
|
|
32
32
|
"check:fix": "biome check --write",
|
|
33
|
-
"prepublishOnly": "npm run build",
|
|
33
|
+
"prepublishOnly": "npm run gen && npm run build",
|
|
34
34
|
"cli": "node cliCommand.ts",
|
|
35
|
+
"gen": "node cliCommand.ts generatetypes",
|
|
36
|
+
"dev:bench:realistic": "node ./benchmark/fixtures/realistic.ts",
|
|
35
37
|
"benchmark": "h2load -n 10000 -c 50 -p 'http/1.1' http://localhost:3300/",
|
|
36
38
|
"benchmark2": "h2load -n 10000 -c 50 https://localhost:3300/",
|
|
39
|
+
"benchmark:plaintext": "h2load -n 10000 -c 50 -p 'http/1.1' http://localhost:3300/bench/plaintext",
|
|
40
|
+
"benchmark:realistic": "h2load -n 10000 -c 50 -p 'http/1.1' 'http://localhost:3300/bench/echo?name=Alice'",
|
|
37
41
|
"redis:docker": "docker run --rm -p 6379:6379 redis"
|
|
38
42
|
},
|
|
39
43
|
"author": "Andrei Lahunou",
|
|
@@ -43,13 +47,13 @@
|
|
|
43
47
|
"deepmerge": "^4.2.2",
|
|
44
48
|
"express": "^5.0.1",
|
|
45
49
|
"formidable": "^3.5.1",
|
|
46
|
-
"i18next": "^
|
|
50
|
+
"i18next": "^26.0.1",
|
|
47
51
|
"i18next-fs-backend": "^2.0.0",
|
|
48
52
|
"mongoose": "^9.0.0",
|
|
49
|
-
"rate-limiter-flexible": "^
|
|
53
|
+
"rate-limiter-flexible": "^11.0.0",
|
|
50
54
|
"winston": "^3.3.3",
|
|
51
55
|
"winston-transport": "^4.9.0",
|
|
52
|
-
"yup": "^1.
|
|
56
|
+
"yup": "^1.7.0"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
59
|
"@biomejs/biome": "^2.0.6",
|
|
@@ -61,13 +65,15 @@
|
|
|
61
65
|
"@vitest/coverage-v8": "^4.0.0",
|
|
62
66
|
"lefthook": "^2.0.0",
|
|
63
67
|
"mongodb-memory-server": "^11.0.0",
|
|
64
|
-
"typescript": "^
|
|
65
|
-
"vitest": "^4.0.0"
|
|
68
|
+
"typescript": "^6.0.0",
|
|
69
|
+
"vitest": "^4.0.0",
|
|
70
|
+
"zod": "^4.0.0"
|
|
66
71
|
},
|
|
67
72
|
"peerDependencies": {
|
|
68
73
|
"@adaptivestone/framework-module-email": "^1.0.0",
|
|
69
74
|
"@sentry/core": "^10.34.0",
|
|
70
|
-
"@sentry/node": "^10.34.0"
|
|
75
|
+
"@sentry/node": "^10.34.0",
|
|
76
|
+
"zod": "^3.24.0 || ^4.0.0"
|
|
71
77
|
},
|
|
72
78
|
"peerDependenciesMeta": {
|
|
73
79
|
"@adaptivestone/framework-module-email": {
|
|
@@ -78,6 +84,9 @@
|
|
|
78
84
|
},
|
|
79
85
|
"@sentry/node": {
|
|
80
86
|
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"zod": {
|
|
89
|
+
"optional": true
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
}
|