@adaptivestone/framework 5.2.2 → 5.3.0

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 (71) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/README.md +10 -0
  3. package/dist/codegen/astConfig.js +2 -2
  4. package/dist/codegen/astConfig.js.map +1 -1
  5. package/dist/codegen/astEmit.js +1 -0
  6. package/dist/codegen/astEmit.js.map +1 -1
  7. package/dist/codegen/astExtract.d.ts +9 -4
  8. package/dist/codegen/astExtract.js +34 -13
  9. package/dist/codegen/astExtract.js.map +1 -1
  10. package/dist/codegen/collectMetadata.d.ts +2 -0
  11. package/dist/codegen/emit.js +6 -0
  12. package/dist/codegen/emit.js.map +1 -1
  13. package/dist/codegen/parser.d.ts +35 -0
  14. package/dist/codegen/parser.js +39 -0
  15. package/dist/codegen/parser.js.map +1 -0
  16. package/dist/controllers/index.js +14 -0
  17. package/dist/controllers/index.js.map +1 -1
  18. package/dist/helpers/appInstance.d.ts +1 -1
  19. package/dist/helpers/appInstance.js +2 -2
  20. package/dist/helpers/appInstance.js.map +1 -1
  21. package/dist/modules/AbstractController.d.ts +8 -0
  22. package/dist/modules/AbstractController.js.map +1 -1
  23. package/dist/modules/BaseModel.d.ts +32 -21
  24. package/dist/modules/BaseModel.js.map +1 -1
  25. package/dist/server.js +7 -9
  26. package/dist/server.js.map +1 -1
  27. package/dist/services/documentation/OpenApiGenerator.js +36 -7
  28. package/dist/services/documentation/OpenApiGenerator.js.map +1 -1
  29. package/dist/services/http/HttpServer.d.ts +1 -0
  30. package/dist/services/http/HttpServer.js.map +1 -1
  31. package/dist/services/http/builtinErrorHandlers.d.ts +20 -0
  32. package/dist/services/http/builtinErrorHandlers.js +78 -0
  33. package/dist/services/http/builtinErrorHandlers.js.map +1 -1
  34. package/dist/services/http/middleware/PrepareAppInfo.js +4 -3
  35. package/dist/services/http/middleware/PrepareAppInfo.js.map +1 -1
  36. package/dist/services/http/routing/RouteNode.d.ts +1 -0
  37. package/dist/services/http/types.d.ts +5 -0
  38. package/dist/tests/assertions.d.ts +42 -0
  39. package/dist/tests/assertions.js +225 -0
  40. package/dist/tests/assertions.js.map +1 -0
  41. package/dist/tests/frameworkNodeTestSetup.d.ts +1 -0
  42. package/dist/tests/frameworkNodeTestSetup.js +13 -0
  43. package/dist/tests/frameworkNodeTestSetup.js.map +1 -0
  44. package/dist/tests/frameworkVitestSetup.js +1 -1
  45. package/dist/tests/frameworkVitestSetup.js.map +1 -1
  46. package/dist/tests/globalSetupNodeTest.js +2 -2
  47. package/dist/tests/globalSetupNodeTest.js.map +1 -1
  48. package/dist/tests/globalSetupVitest.js +2 -8
  49. package/dist/tests/globalSetupVitest.js.map +1 -1
  50. package/dist/tests/mocks.d.ts +17 -0
  51. package/dist/tests/mocks.js +33 -0
  52. package/dist/tests/mocks.js.map +1 -0
  53. package/dist/tests/nodeRunner.node-test.d.ts +3 -3
  54. package/dist/tests/nodeRunner.node-test.js +6 -7
  55. package/dist/tests/nodeRunner.node-test.js.map +1 -1
  56. package/dist/tests/nodeRunnerShared.node-test.d.ts +1 -1
  57. package/dist/tests/nodeRunnerShared.node-test.js +1 -1
  58. package/dist/tests/parameterized.d.ts +4 -0
  59. package/dist/tests/parameterized.js +10 -0
  60. package/dist/tests/parameterized.js.map +1 -0
  61. package/dist/tests/redisAvailability.d.ts +28 -0
  62. package/dist/tests/redisAvailability.js +73 -0
  63. package/dist/tests/redisAvailability.js.map +1 -0
  64. package/dist/tests/setupFramework.d.ts +3 -5
  65. package/dist/tests/setupFramework.js +3 -5
  66. package/dist/tests/setupFramework.js.map +1 -1
  67. package/dist/tests/setupNodeTest.js +26 -13
  68. package/dist/tests/setupNodeTest.js.map +1 -1
  69. package/dist/tests/setupVitest.js +3 -3
  70. package/dist/tests/setupVitest.js.map +1 -1
  71. package/package.json +10 -8
@@ -101,6 +101,17 @@ function safeValidationMessage(error) {
101
101
  * defect, and the developer needs every detail.
102
102
  */
103
103
  export function toLoggableError(err) {
104
+ // A standalone `CastError` ("Cast to ObjectId failed for value \"<input>\"")
105
+ // embeds the rejected value in its message exactly like a ValidationError, and
106
+ // a path param can carry PII (an email, a token) just as a body field can.
107
+ // Rebuild it value-free, keeping the model path — the resolved branch logs at
108
+ // `warn` into Sentry/retention, and the developer still needs to know WHICH
109
+ // path failed to cast, which is safe (a field name, never input).
110
+ if (err instanceof mongoose.Error.CastError) {
111
+ const sanitized = new Error(`Cast failed at path "${err.path}" (safety net, sanitized): ${safeValidationMessage(err)}`);
112
+ sanitized.name = 'CastError';
113
+ return sanitized;
114
+ }
104
115
  if (!(err instanceof mongoose.Error.ValidationError)) {
105
116
  return err;
106
117
  }
@@ -150,6 +161,59 @@ export function matchedClientValidationErrors(err, req) {
150
161
  }
151
162
  return errors;
152
163
  }
164
+ /** Is this a primitive we can compare by value? Objects/null are never matched
165
+ * (`String({})` collapses every object to the same text). Path params, query
166
+ * values and JSON scalars are all primitives, so nothing real is lost. */
167
+ function isComparablePrimitive(value) {
168
+ return value !== null && value !== undefined && typeof value !== 'object';
169
+ }
170
+ /**
171
+ * Client-supplied inputs keyed by the name the CLIENT knows them under: path
172
+ * params (public — they appear in the route's own URL pattern), plus the
173
+ * validated body and query keys. The framework-injected `contentType`
174
+ * discriminant is excluded, as in {@link matchedClientValidationErrors}.
175
+ */
176
+ function clientInputEntries(req) {
177
+ const out = [];
178
+ for (const source of [req.params, req.appInfo?.request, req.appInfo?.query]) {
179
+ if (!source) {
180
+ continue;
181
+ }
182
+ for (const [key, value] of Object.entries(source)) {
183
+ if (key !== 'contentType') {
184
+ out.push([key, value]);
185
+ }
186
+ }
187
+ }
188
+ return out;
189
+ }
190
+ /**
191
+ * Safety net for a STANDALONE Mongoose `CastError` — the shape a path param
192
+ * produces (`findById(req.params.id)` with a malformed id). A `CastError` is a
193
+ * sibling of `ValidationError`, not a subclass, so
194
+ * {@link matchedClientValidationErrors} structurally cannot see it, and its
195
+ * failing path is an internal model field (`_id`) that must never be echoed.
196
+ *
197
+ * Returns `{ <clientKey>: message }` only when the rejected value is one the
198
+ * client actually supplied — matched by VALUE against the path params and the
199
+ * validated body/query, then reported under that public input name. A cast
200
+ * failure on a server-computed value matches nothing and returns `null`, so a
201
+ * genuine server-side defect keeps its honest 500 instead of being blamed on
202
+ * the caller. The message comes from {@link safeValidationMessage}, so the
203
+ * rejected value never rides into the response.
204
+ */
205
+ export function matchedClientCastError(err, req) {
206
+ if (!isComparablePrimitive(err.value)) {
207
+ return null;
208
+ }
209
+ const rejected = String(err.value);
210
+ for (const [key, candidate] of clientInputEntries(req)) {
211
+ if (isComparablePrimitive(candidate) && String(candidate) === rejected) {
212
+ return { [key]: safeValidationMessage(err) };
213
+ }
214
+ }
215
+ return null;
216
+ }
153
217
  /**
154
218
  * Framework built-in registry entries, checked AFTER any consumer-registered
155
219
  * handlers ("yours win"):
@@ -157,6 +221,10 @@ export function matchedClientValidationErrors(err, req) {
157
221
  * (deliberate control flow, not a defect).
158
222
  * 2. Escaped Mongoose `ValidationError` → the safety net above; `warn`
159
223
  * (signals a route schema missing a constraint the model enforces).
224
+ * 3. Standalone Mongoose `CastError` → {@link matchedClientCastError}; `warn`
225
+ * (signals a path param or input reaching the model unvalidated). Declaring
226
+ * a route `params:` schema turns the same failure into a 400 earlier, with
227
+ * a message you control.
160
228
  */
161
229
  export function builtInErrorHandlers() {
162
230
  return [
@@ -183,6 +251,16 @@ export function builtInErrorHandlers() {
183
251
  },
184
252
  logLevel: 'warn',
185
253
  },
254
+ {
255
+ errorClass: mongoose.Error.CastError,
256
+ handler: (err, req) => {
257
+ const clientErrors = matchedClientCastError(err, req);
258
+ return clientErrors
259
+ ? { status: 400, body: { errors: clientErrors } }
260
+ : null;
261
+ },
262
+ logLevel: 'warn',
263
+ },
186
264
  ];
187
265
  }
188
266
  //# sourceMappingURL=builtinErrorHandlers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builtinErrorHandlers.js","sourceRoot":"","sources":["../../../src/services/http/built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,CAAC;IAC1C,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,CAAC,WAAW,CAAC,GAAG,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL;YACE,UAAU,EAAE,SAAS;YACrB,oEAAoE;YACpE,sDAAsD;YACtD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACf,MAAM,OAAO,GAAG,GAAgB,CAAC;gBACjC,OAAO;oBACL,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;iBACnD,CAAC;YACJ,CAAC;YACD,QAAQ,EAAE,SAAS;SACpB;QACD;YACE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,eAAe;YAC1C,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBACpB,MAAM,YAAY,GAAG,6BAA6B,CAChD,GAAqC,EACrC,GAAG,CACJ,CAAC;gBACF,OAAO,YAAY;oBACjB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;oBACjD,CAAC,CAAC,IAAI,CAAC;YACX,CAAC;YACD,QAAQ,EAAE,MAAM;SACjB;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"builtinErrorHandlers.js","sourceRoot":"","sources":["../../../src/services/http/builtinErrorHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ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;gBACpB,MAAM,YAAY,GAAG,6BAA6B,CAChD,GAAqC,EACrC,GAAG,CACJ,CAAC;gBACF,OAAO,YAAY;oBACjB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;oBACjD,CAAC,CAAC,IAAI,CAAC;YACX,CAAC;YACD,QAAQ,EAAE,MAAM;SACjB;QACD;YACE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;YACpC,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBACpB,MAAM,YAAY,GAAG,sBAAsB,CACzC,GAA+B,EAC/B,GAAG,CACJ,CAAC;gBACF,OAAO,YAAY;oBACjB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;oBACjD,CAAC,CAAC,IAAI,CAAC;YACX,CAAC;YACD,QAAQ,EAAE,MAAM;SACjB;KACF,CAAC;AACJ,CAAC"}
@@ -5,15 +5,16 @@ class PrepareAppInfo extends AbstractMiddleware {
5
5
  }
6
6
  async middleware(req, _res, next) {
7
7
  if (!req.appInfo) {
8
- // `request`/`query` are declared non-optional; seed both so a schema-less
9
- // route's handler can read them. The validation wrapper overwrites
10
- // (assigns, not merges) when a route/middleware declares schemas, so
8
+ // `request`/`query`/`params` are declared non-optional; seed all three so
9
+ // a schema-less route's handler can read them. The validation wrapper
10
+ // overwrites (assigns, not merges) when a route declares schemas, so
11
11
  // these defaults never leak stale keys. `ip`/`i18n` are optional and set
12
12
  // by later middleware.
13
13
  req.appInfo = {
14
14
  app: this.app,
15
15
  request: {},
16
16
  query: {},
17
+ params: {},
17
18
  };
18
19
  }
19
20
  next();
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareAppInfo.js","sourceRoot":"","sources":["../../../../src/services/http/middleware/PrepareAppInfo.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD,MAAM,cAAe,SAAQ,kBAAkB;IAC7C,MAAM,KAAK,WAAW;QACpB,OAAO,oDAAoD,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAqB,EAAE,IAAc,EAAE,IAAkB;QACxE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACjB,0EAA0E;YAC1E,mEAAmE;YACnE,qEAAqE;YACrE,yEAAyE;YACzE,uBAAuB;YACvB,GAAG,CAAC,OAAO,GAAG;gBACZ,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,OAAO,EAAE,EAAE;gBACX,KAAK,EAAE,EAAE;aACV,CAAC;QACJ,CAAC;QACD,IAAI,EAAE,CAAC;IACT,CAAC;CACF;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"PrepareAppInfo.js","sourceRoot":"","sources":["../../../../src/services/http/middleware/PrepareAppInfo.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AAEzD,MAAM,cAAe,SAAQ,kBAAkB;IAC7C,MAAM,KAAK,WAAW;QACpB,OAAO,oDAAoD,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAqB,EAAE,IAAc,EAAE,IAAkB;QACxE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACjB,0EAA0E;YAC1E,sEAAsE;YACtE,qEAAqE;YACrE,yEAAyE;YACzE,uBAAuB;YACvB,GAAG,CAAC,OAAO,GAAG;gBACZ,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,OAAO,EAAE,EAAE;gBACX,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC;QACD,IAAI,EAAE,CAAC;IACT,CAAC;CACF;AAED,eAAe,cAAc,CAAC"}
@@ -49,6 +49,7 @@ export interface HandlerEntry {
49
49
  handler: Function;
50
50
  request?: StandardSchemaV1 | RequestContentTypeMap;
51
51
  query?: StandardSchemaV1;
52
+ params?: StandardSchemaV1;
52
53
  middlewares?: MiddlewareEntry[];
53
54
  bodyParsing?: BodyParsingMode;
54
55
  paramNames?: string[];
@@ -42,6 +42,11 @@ export interface BaseAppInfo {
42
42
  };
43
43
  request: Record<string, unknown>;
44
44
  query: Record<string, unknown>;
45
+ /**
46
+ * Validated, coerced path params — populated only when the route declares a
47
+ * `params:` schema; `{}` otherwise. Raw Express strings stay on `req.params`.
48
+ */
49
+ params: Record<string, unknown>;
45
50
  }
46
51
  /**
47
52
  * Default request context handlers see when no per-route `Request<M, P>` is
@@ -0,0 +1,42 @@
1
+ declare const asymmetricMatcher: unique symbol;
2
+ type Matcher = {
3
+ [asymmetricMatcher]: (actual: unknown) => boolean;
4
+ description: string;
5
+ };
6
+ type FunctionLike = ((...args: never[]) => unknown) & {
7
+ readonly name: string;
8
+ };
9
+ export declare const pattern: {
10
+ any(type: FunctionLike): Matcher;
11
+ anything(): Matcher;
12
+ arrayContaining(expected: readonly unknown[]): Matcher;
13
+ objectContaining(expected: Record<PropertyKey, unknown>): Matcher;
14
+ stringContaining(expected: string): Matcher;
15
+ stringMatching(expected: string | RegExp): Matcher;
16
+ };
17
+ export declare function assertMatches(actual: unknown, expected: unknown): void;
18
+ export declare function assertNotMatches(actual: unknown, expected: unknown): void;
19
+ export declare function assertMatchObject(actual: unknown, expected: unknown): void;
20
+ export declare function assertContainEqual(actual: readonly unknown[], expected: unknown): void;
21
+ export declare function assertTextMatch(actual: string, expected: string | RegExp, message?: string): void;
22
+ export declare function assertTextNotMatch(actual: string, expected: string | RegExp): void;
23
+ export declare function assertHasProperty(actual: object, property: PropertyKey, expected?: unknown): void;
24
+ export declare function assertThrowsLike(fn: () => unknown, expected?: string | RegExp | FunctionLike | Error): void;
25
+ export declare function assertRejectsLike(value: Promise<unknown> | (() => Promise<unknown>), expected?: string | RegExp | FunctionLike | Error): Promise<void>;
26
+ export declare function assertRejectsValue(value: Promise<unknown> | (() => Promise<unknown>), expected: unknown): Promise<void>;
27
+ type MockCall = readonly unknown[] | {
28
+ arguments: readonly unknown[];
29
+ };
30
+ type MockLike = {
31
+ mock?: {
32
+ calls?: readonly MockCall[];
33
+ callCount?: () => number;
34
+ };
35
+ };
36
+ export declare function assertCalled(value: MockLike): void;
37
+ export declare function assertNotCalled(value: MockLike): void;
38
+ export declare function assertCalledTimes(value: MockLike, expected: number): void;
39
+ export declare function assertCalledWith(value: MockLike, ...expected: readonly unknown[]): void;
40
+ export declare function assertNotCalledWith(value: MockLike, ...expected: readonly unknown[]): void;
41
+ export declare function assertNthCalledWith(value: MockLike, nth: number, ...expected: readonly unknown[]): void;
42
+ export {};
@@ -0,0 +1,225 @@
1
+ import assert from 'node:assert/strict';
2
+ import { isDeepStrictEqual } from 'node:util';
3
+ const asymmetricMatcher = Symbol('asymmetricMatcher');
4
+ function matcher(description, predicate) {
5
+ return { [asymmetricMatcher]: predicate, description };
6
+ }
7
+ function isMatcher(value) {
8
+ return (typeof value === 'object' && value !== null && asymmetricMatcher in value);
9
+ }
10
+ function valueMatches(actual, expected) {
11
+ if (isMatcher(expected)) {
12
+ return expected[asymmetricMatcher](actual);
13
+ }
14
+ if (Array.isArray(expected)) {
15
+ return (Array.isArray(actual) &&
16
+ actual.length === expected.length &&
17
+ expected.every((value, index) => valueMatches(actual[index], value)));
18
+ }
19
+ if (typeof expected === 'object' &&
20
+ expected !== null &&
21
+ typeof actual === 'object' &&
22
+ actual !== null) {
23
+ const expectedRecord = expected;
24
+ const actualRecord = actual;
25
+ const expectedKeys = Reflect.ownKeys(expectedRecord);
26
+ const actualKeys = Reflect.ownKeys(actualRecord);
27
+ return (expectedKeys.length === actualKeys.length &&
28
+ expectedKeys.every((key) => Object.hasOwn(actualRecord, key) &&
29
+ valueMatches(actualRecord[key], expectedRecord[key])));
30
+ }
31
+ return isDeepStrictEqual(actual, expected);
32
+ }
33
+ function partialMatches(actual, expected) {
34
+ if (isMatcher(expected)) {
35
+ return expected[asymmetricMatcher](actual);
36
+ }
37
+ if (Array.isArray(expected)) {
38
+ return (Array.isArray(actual) &&
39
+ expected.every((value, index) => partialMatches(actual[index], value)));
40
+ }
41
+ if (typeof expected === 'object' && expected !== null) {
42
+ if (typeof actual !== 'object' || actual === null) {
43
+ return false;
44
+ }
45
+ const expectedRecord = expected;
46
+ const actualRecord = actual;
47
+ return Reflect.ownKeys(expectedRecord).every((key) => Object.hasOwn(actualRecord, key) &&
48
+ partialMatches(actualRecord[key], expectedRecord[key]));
49
+ }
50
+ return isDeepStrictEqual(actual, expected);
51
+ }
52
+ function describeExpected(expected) {
53
+ return isMatcher(expected) ? expected.description : String(expected);
54
+ }
55
+ export const pattern = {
56
+ any(type) {
57
+ return matcher(`any ${type.name}`, (actual) => {
58
+ if (type === String) {
59
+ return typeof actual === 'string';
60
+ }
61
+ if (type === Number) {
62
+ return typeof actual === 'number';
63
+ }
64
+ if (type === Boolean) {
65
+ return typeof actual === 'boolean';
66
+ }
67
+ if (type === BigInt) {
68
+ return typeof actual === 'bigint';
69
+ }
70
+ if (type === Symbol) {
71
+ return typeof actual === 'symbol';
72
+ }
73
+ return actual instanceof type;
74
+ });
75
+ },
76
+ anything() {
77
+ return matcher('anything except null or undefined', (actual) => actual != null);
78
+ },
79
+ arrayContaining(expected) {
80
+ return matcher('an array containing the expected values', (actual) => Array.isArray(actual)
81
+ ? expected.every((value) => actual.some((candidate) => valueMatches(candidate, value)))
82
+ : false);
83
+ },
84
+ objectContaining(expected) {
85
+ return matcher('an object containing the expected properties', (actual) => partialMatches(actual, expected));
86
+ },
87
+ stringContaining(expected) {
88
+ return matcher(`a string containing ${expected}`, (actual) => typeof actual === 'string' ? actual.includes(expected) : false);
89
+ },
90
+ stringMatching(expected) {
91
+ return matcher(`a string matching ${expected}`, (actual) => typeof actual === 'string'
92
+ ? typeof expected === 'string'
93
+ ? actual.includes(expected)
94
+ : expected.test(actual)
95
+ : false);
96
+ },
97
+ };
98
+ export function assertMatches(actual, expected) {
99
+ assert.ok(valueMatches(actual, expected), `Expected value to match ${describeExpected(expected)}`);
100
+ }
101
+ export function assertNotMatches(actual, expected) {
102
+ assert.ok(!valueMatches(actual, expected), `Expected value not to match ${describeExpected(expected)}`);
103
+ }
104
+ export function assertMatchObject(actual, expected) {
105
+ assert.ok(partialMatches(actual, expected), 'Expected object to contain shape');
106
+ }
107
+ export function assertContainEqual(actual, expected) {
108
+ assert.ok(actual.some((candidate) => valueMatches(candidate, expected)), 'Expected array to contain an equal value');
109
+ }
110
+ export function assertTextMatch(actual, expected, message) {
111
+ if (typeof expected === 'string') {
112
+ if (message) {
113
+ assert.ok(actual.includes(expected), message);
114
+ }
115
+ else {
116
+ assert.ok(actual.includes(expected));
117
+ }
118
+ }
119
+ else {
120
+ if (message) {
121
+ assert.match(actual, expected, message);
122
+ }
123
+ else {
124
+ assert.match(actual, expected);
125
+ }
126
+ }
127
+ }
128
+ export function assertTextNotMatch(actual, expected) {
129
+ if (typeof expected === 'string') {
130
+ assert.ok(!actual.includes(expected));
131
+ }
132
+ else {
133
+ assert.doesNotMatch(actual, expected);
134
+ }
135
+ }
136
+ export function assertHasProperty(actual, property, expected) {
137
+ assert.ok(property in actual);
138
+ if (expected !== undefined) {
139
+ assert.deepStrictEqual(actual[property], expected);
140
+ }
141
+ }
142
+ export function assertThrowsLike(fn, expected) {
143
+ let didThrow = false;
144
+ let error;
145
+ try {
146
+ fn();
147
+ }
148
+ catch (caught) {
149
+ didThrow = true;
150
+ error = caught;
151
+ }
152
+ assert.ok(didThrow, 'Expected function to throw');
153
+ assertErrorMatches(error, expected);
154
+ }
155
+ export async function assertRejectsLike(value, expected) {
156
+ let didReject = false;
157
+ let error;
158
+ try {
159
+ await (typeof value === 'function' ? value() : value);
160
+ }
161
+ catch (caught) {
162
+ didReject = true;
163
+ error = caught;
164
+ }
165
+ assert.ok(didReject, 'Expected promise to reject');
166
+ assertErrorMatches(error, expected);
167
+ }
168
+ export async function assertRejectsValue(value, expected) {
169
+ let didReject = false;
170
+ let error;
171
+ try {
172
+ await (typeof value === 'function' ? value() : value);
173
+ }
174
+ catch (caught) {
175
+ didReject = true;
176
+ error = caught;
177
+ }
178
+ assert.ok(didReject, 'Expected promise to reject');
179
+ assert.deepStrictEqual(error, expected);
180
+ }
181
+ function assertErrorMatches(error, expected) {
182
+ if (expected === undefined) {
183
+ return;
184
+ }
185
+ if (typeof expected === 'string') {
186
+ assert.ok(error instanceof Error);
187
+ assert.ok(error.message.includes(expected));
188
+ }
189
+ else if (expected instanceof RegExp) {
190
+ assert.ok(error instanceof Error);
191
+ assert.match(error.message, expected);
192
+ }
193
+ else if (typeof expected === 'function') {
194
+ assert.ok(error instanceof
195
+ expected);
196
+ }
197
+ else {
198
+ assert.deepStrictEqual(error, expected);
199
+ }
200
+ }
201
+ function callsOf(value) {
202
+ const calls = value.mock?.calls ?? [];
203
+ return calls.map((call) => 'arguments' in call ? call.arguments : call);
204
+ }
205
+ export function assertCalled(value) {
206
+ assert.ok(callsOf(value).length > 0, 'Expected mock to have been called');
207
+ }
208
+ export function assertNotCalled(value) {
209
+ assert.strictEqual(callsOf(value).length, 0);
210
+ }
211
+ export function assertCalledTimes(value, expected) {
212
+ assert.strictEqual(value.mock?.callCount?.() ?? callsOf(value).length, expected);
213
+ }
214
+ export function assertCalledWith(value, ...expected) {
215
+ assert.ok(callsOf(value).some((call) => valueMatches(call, expected)), 'Expected mock to have been called with the provided arguments');
216
+ }
217
+ export function assertNotCalledWith(value, ...expected) {
218
+ assert.ok(callsOf(value).every((call) => !valueMatches(call, expected)), 'Expected mock not to have been called with the provided arguments');
219
+ }
220
+ export function assertNthCalledWith(value, nth, ...expected) {
221
+ const call = callsOf(value)[nth - 1];
222
+ assert.ok(call, `Expected mock to have at least ${nth} calls`);
223
+ assertMatches(call, expected);
224
+ }
225
+ //# sourceMappingURL=assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../src/tests/assertions.ts"],"names":[],"mappings":"AAAA,OAAO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,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EAC7D,mEAAmE,CACpE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,KAAe,EACf,GAAW,EACX,GAAG,QAA4B;IAE/B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,kCAAkC,GAAG,QAAQ,CAAC,CAAC;IAC/D,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ // Framework-repository-only setup. Consumer projects should create their own
2
+ // fixture user from project hooks when their suites need one.
3
+ import { before } from 'node:test';
4
+ import { createDefaultTestUser, ensureTestServerReady } from './testHelpers.js';
5
+ const isFrameworkSetupSkipped = process.argv.some((argument) => argument.endsWith('/cluster.test.ts'));
6
+ before(async () => {
7
+ if (isFrameworkSetupSkipped) {
8
+ return;
9
+ }
10
+ await ensureTestServerReady();
11
+ await createDefaultTestUser();
12
+ });
13
+ //# sourceMappingURL=frameworkNodeTestSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frameworkNodeTestSetup.js","sourceRoot":"","sources":["../../src/tests/frameworkNodeTestSetup.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8DAA8D;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC7D,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CACtC,CAAC;AAEF,MAAM,CAAC,KAAK,IAAI,EAAE;IAChB,IAAI,uBAAuB,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IACD,MAAM,qBAAqB,EAAE,CAAC;IAC9B,MAAM,qBAAqB,EAAE,CAAC;AAChC,CAAC,CAAC,CAAC"}
@@ -4,6 +4,6 @@ beforeAll(async () => {
4
4
  await createDefaultTestUser();
5
5
  });
6
6
  afterAll(async () => {
7
- // do seomthing
7
+ // Reserved for framework-only Vitest compatibility teardown.
8
8
  });
9
9
  //# sourceMappingURL=frameworkVitestSetup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"frameworkVitestSetup.js","sourceRoot":"","sources":["../../src/tests/frameworkVitestSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,qBAAqB,EAAE,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,KAAK,IAAI,EAAE;IAClB,eAAe;AACjB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"frameworkVitestSetup.js","sourceRoot":"","sources":["../../src/tests/frameworkVitestSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,qBAAqB,EAAE,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,KAAK,IAAI,EAAE;IAClB,6DAA6D;AAC/D,CAAC,CAAC,CAAC"}
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * node:test global setup/teardown — the `--test-global-setup` entry module.
3
3
  *
4
- * Runs ONCE before/after the entire test run: node:test's equivalent of vitest's
5
- * `globalSetup` (see `globalSetupVitest.ts`). It boots the in-memory Mongo and
4
+ * Runs ONCE before/after the entire test run. It boots the in-memory Mongo and
6
5
  * publishes `TEST_MONGO_URI`; the child test processes inherit it. This is the
7
6
  * single entry point for the node:test suite — no per-file Mongo init, no manual
8
7
  * process spawning.
@@ -15,6 +14,7 @@
15
14
  */
16
15
  import { startTestMongo, stopTestMongo } from './setupFramework.js';
17
16
  export async function globalSetup() {
17
+ process.env.FRAMEWORK_TEST = '1';
18
18
  await startTestMongo(); // publishes process.env.TEST_MONGO_URI for child processes
19
19
  }
20
20
  export async function globalTeardown() {
@@ -1 +1 @@
1
- {"version":3,"file":"globalSetupNodeTest.js","sourceRoot":"","sources":["../../src/tests/globalSetupNodeTest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,cAAc,EAAE,CAAC,CAAC,2DAA2D;AACrF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,aAAa,EAAE,CAAC;AACxB,CAAC"}
1
+ {"version":3,"file":"globalSetupNodeTest.js","sourceRoot":"","sources":["../../src/tests/globalSetupNodeTest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC;IACjC,MAAM,cAAc,EAAE,CAAC,CAAC,2DAA2D;AACrF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,aAAa,EAAE,CAAC;AACxB,CAAC"}
@@ -1,22 +1,16 @@
1
- // vitest globalSetup: runs once per test run. Delegates the in-memory Mongo
2
- // lifecycle to the runner-agnostic `setupFramework.ts`.
1
+ // Vitest global setup delegates to the runner-agnostic Mongo lifecycle.
3
2
  import { startTestMongo, stopTestMongo } from './setupFramework.js';
4
3
  let isTeardown = false;
5
4
  const setup = async () => {
6
- console.log('GLOBAL SETUP PREPARE RUNNING...');
7
- console.time('GLOBAL TEST PREPARE. DONE');
5
+ process.env.FRAMEWORK_TEST = '1';
8
6
  await startTestMongo();
9
- console.timeEnd('GLOBAL TEST PREPARE. DONE');
10
7
  };
11
8
  const teardown = async () => {
12
9
  if (isTeardown) {
13
10
  throw new Error('teardown called twice');
14
11
  }
15
12
  isTeardown = true;
16
- console.log('GLOBAL TEARDOWN RUNNING...');
17
- console.time('GLOBAL TEARDOWN RUNNING. DONE');
18
13
  await stopTestMongo();
19
- console.timeEnd('GLOBAL TEARDOWN RUNNING. DONE');
20
14
  };
21
15
  export { setup, teardown };
22
16
  //# sourceMappingURL=globalSetupVitest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"globalSetupVitest.js","sourceRoot":"","sources":["../../src/tests/globalSetupVitest.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wDAAwD;AACxD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpE,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;IACvB,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC1C,MAAM,cAAc,EAAE,CAAC;IACvB,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;IAC1B,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,UAAU,GAAG,IAAI,CAAC;IAClB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC9C,MAAM,aAAa,EAAE,CAAC;IACtB,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"globalSetupVitest.js","sourceRoot":"","sources":["../../src/tests/globalSetupVitest.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpE,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;IACvB,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC;IACjC,MAAM,cAAc,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;IAC1B,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,UAAU,GAAG,IAAI,CAAC;IAClB,MAAM,aAAa,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ type AnyFunction = (...args: never[]) => unknown;
2
+ type ConfigurableMock = {
3
+ mock: {
4
+ callCount(): number;
5
+ mockImplementation(implementation: AnyFunction): void;
6
+ mockImplementationOnce(implementation: AnyFunction, onCall?: number): void;
7
+ };
8
+ };
9
+ export declare function mockImplementation<T extends ConfigurableMock>(value: T, implementation: AnyFunction): T;
10
+ export declare function mockImplementationOnce<T extends ConfigurableMock>(value: T, implementation: AnyFunction): T;
11
+ export declare function mockReturnValue<T extends ConfigurableMock>(value: T, result: unknown): T;
12
+ export declare function mockReturnValueOnce<T extends ConfigurableMock>(value: T, result: unknown): T;
13
+ export declare function mockResolvedValue<T extends ConfigurableMock>(value: T, result: unknown): T;
14
+ export declare function mockResolvedValueOnce<T extends ConfigurableMock>(value: T, result: unknown): T;
15
+ export declare function mockRejectedValue<T extends ConfigurableMock>(value: T, error: unknown): T;
16
+ export declare function mockRejectedValueOnce<T extends ConfigurableMock>(value: T, error: unknown): T;
17
+ export {};
@@ -0,0 +1,33 @@
1
+ const nextOnceCall = new WeakMap();
2
+ function onceIndex(value) {
3
+ const index = nextOnceCall.get(value) ?? value.mock.callCount();
4
+ nextOnceCall.set(value, index + 1);
5
+ return index;
6
+ }
7
+ export function mockImplementation(value, implementation) {
8
+ value.mock.mockImplementation(implementation);
9
+ return value;
10
+ }
11
+ export function mockImplementationOnce(value, implementation) {
12
+ value.mock.mockImplementationOnce(implementation, onceIndex(value));
13
+ return value;
14
+ }
15
+ export function mockReturnValue(value, result) {
16
+ return mockImplementation(value, () => result);
17
+ }
18
+ export function mockReturnValueOnce(value, result) {
19
+ return mockImplementationOnce(value, () => result);
20
+ }
21
+ export function mockResolvedValue(value, result) {
22
+ return mockImplementation(value, () => Promise.resolve(result));
23
+ }
24
+ export function mockResolvedValueOnce(value, result) {
25
+ return mockImplementationOnce(value, () => Promise.resolve(result));
26
+ }
27
+ export function mockRejectedValue(value, error) {
28
+ return mockImplementation(value, () => Promise.reject(error));
29
+ }
30
+ export function mockRejectedValueOnce(value, error) {
31
+ return mockImplementationOnce(value, () => Promise.reject(error));
32
+ }
33
+ //# sourceMappingURL=mocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAUA,MAAM,YAAY,GAAG,IAAI,OAAO,EAAkB,CAAC;AAEnD,SAAS,SAAS,CAAC,KAAuB;IACxC,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IAChE,YAAY,CAAC,GAAG,CAAC,K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OAAO,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACpE,CAAC"}
@@ -3,12 +3,12 @@
3
3
  *
4
4
  * Mongo is started ONCE by the global-setup entry module
5
5
  * (`globalSetupNodeTest.ts`, wired via `--test-global-setup` — see the
6
- * `test:node` script). This file never touches Mongo init; it only boots a
6
+ * native test script). This file never touches Mongo init; it only boots a
7
7
  * per-suite `Server` against the shared instance (via the shipped
8
8
  * `setupNodeTest.ts` glue) and exercises the full stack: a live HTTP request and
9
9
  * a Mongo write/read round-trip.
10
10
  *
11
- * Runs as part of `npm run test:node` (it shares one Mongo with the other
12
- * `*.node-test.ts` files). The `.node-test.ts` suffix keeps vitest's glob away.
11
+ * Runs as part of the native suite and shares one Mongo with the other
12
+ * `*.node-test.ts` files.
13
13
  */
14
14
  import './setupNodeTest.ts';