@zmdb/web 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +49 -0
  3. package/dist/app/bridge.d.ts +12 -0
  4. package/dist/app/bridge.d.ts.map +1 -0
  5. package/dist/app/bridge.js +16 -0
  6. package/dist/app/bridge.js.map +1 -0
  7. package/dist/app/index.d.ts +23 -0
  8. package/dist/app/index.d.ts.map +1 -0
  9. package/dist/app/index.js +47 -0
  10. package/dist/app/index.js.map +1 -0
  11. package/dist/bench/index.d.ts +68 -0
  12. package/dist/bench/index.d.ts.map +1 -0
  13. package/dist/bench/index.js +250 -0
  14. package/dist/bench/index.js.map +1 -0
  15. package/dist/compression/index.d.ts +13 -0
  16. package/dist/compression/index.d.ts.map +1 -0
  17. package/dist/compression/index.js +211 -0
  18. package/dist/compression/index.js.map +1 -0
  19. package/dist/context/index.d.ts +74 -0
  20. package/dist/context/index.d.ts.map +1 -0
  21. package/dist/context/index.js +118 -0
  22. package/dist/context/index.js.map +1 -0
  23. package/dist/contract/__fixtures__/http-client.generated.d.ts +70 -0
  24. package/dist/contract/__fixtures__/http-client.generated.d.ts.map +1 -0
  25. package/dist/contract/__fixtures__/http-client.generated.js +86 -0
  26. package/dist/contract/__fixtures__/http-client.generated.js.map +1 -0
  27. package/dist/contract/__fixtures__/http-convergence.d.ts +396 -0
  28. package/dist/contract/__fixtures__/http-convergence.d.ts.map +1 -0
  29. package/dist/contract/__fixtures__/http-convergence.js +425 -0
  30. package/dist/contract/__fixtures__/http-convergence.js.map +1 -0
  31. package/dist/contract/compiler/client.d.ts +12 -0
  32. package/dist/contract/compiler/client.d.ts.map +1 -0
  33. package/dist/contract/compiler/client.js +1293 -0
  34. package/dist/contract/compiler/client.js.map +1 -0
  35. package/dist/contract/compiler/index.d.ts +18 -0
  36. package/dist/contract/compiler/index.d.ts.map +1 -0
  37. package/dist/contract/compiler/index.js +1058 -0
  38. package/dist/contract/compiler/index.js.map +1 -0
  39. package/dist/contract/index.d.ts +237 -0
  40. package/dist/contract/index.d.ts.map +1 -0
  41. package/dist/contract/index.js +22 -0
  42. package/dist/contract/index.js.map +1 -0
  43. package/dist/csrf/index.d.ts +15 -0
  44. package/dist/csrf/index.d.ts.map +1 -0
  45. package/dist/csrf/index.js +218 -0
  46. package/dist/csrf/index.js.map +1 -0
  47. package/dist/data/index.d.ts +35 -0
  48. package/dist/data/index.d.ts.map +1 -0
  49. package/dist/data/index.js +58 -0
  50. package/dist/data/index.js.map +1 -0
  51. package/dist/devtools/index.d.ts +74 -0
  52. package/dist/devtools/index.d.ts.map +1 -0
  53. package/dist/devtools/index.js +552 -0
  54. package/dist/devtools/index.js.map +1 -0
  55. package/dist/dto-pipes/index.d.ts +45 -0
  56. package/dist/dto-pipes/index.d.ts.map +1 -0
  57. package/dist/dto-pipes/index.js +78 -0
  58. package/dist/dto-pipes/index.js.map +1 -0
  59. package/dist/gateways/index.d.ts +31 -0
  60. package/dist/gateways/index.d.ts.map +1 -0
  61. package/dist/gateways/index.js +138 -0
  62. package/dist/gateways/index.js.map +1 -0
  63. package/dist/health/index.d.ts +20 -0
  64. package/dist/health/index.d.ts.map +1 -0
  65. package/dist/health/index.js +148 -0
  66. package/dist/health/index.js.map +1 -0
  67. package/dist/http-token.d.ts +2 -0
  68. package/dist/http-token.d.ts.map +1 -0
  69. package/dist/http-token.js +21 -0
  70. package/dist/http-token.js.map +1 -0
  71. package/dist/index.d.ts +18 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +40 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/integrations/index.d.ts +11 -0
  76. package/dist/integrations/index.d.ts.map +1 -0
  77. package/dist/integrations/index.js +39 -0
  78. package/dist/integrations/index.js.map +1 -0
  79. package/dist/middleware/errors.d.ts +14 -0
  80. package/dist/middleware/errors.d.ts.map +1 -0
  81. package/dist/middleware/errors.js +18 -0
  82. package/dist/middleware/errors.js.map +1 -0
  83. package/dist/middleware/index.d.ts +46 -0
  84. package/dist/middleware/index.d.ts.map +1 -0
  85. package/dist/middleware/index.js +64 -0
  86. package/dist/middleware/index.js.map +1 -0
  87. package/dist/modules/__fixtures__/large-graph.d.ts +239 -0
  88. package/dist/modules/__fixtures__/large-graph.d.ts.map +1 -0
  89. package/dist/modules/__fixtures__/large-graph.js +483 -0
  90. package/dist/modules/__fixtures__/large-graph.js.map +1 -0
  91. package/dist/openapi/__fixtures__/entities.d.ts +8 -0
  92. package/dist/openapi/__fixtures__/entities.d.ts.map +1 -0
  93. package/dist/openapi/__fixtures__/entities.js +4 -0
  94. package/dist/openapi/__fixtures__/entities.js.map +1 -0
  95. package/dist/openapi/__fixtures__/openapi-tools.fixture.d.ts +38 -0
  96. package/dist/openapi/__fixtures__/openapi-tools.fixture.d.ts.map +1 -0
  97. package/dist/openapi/__fixtures__/openapi-tools.fixture.js +172 -0
  98. package/dist/openapi/__fixtures__/openapi-tools.fixture.js.map +1 -0
  99. package/dist/openapi/__fixtures__/route-schemas.d.ts +2 -0
  100. package/dist/openapi/__fixtures__/route-schemas.d.ts.map +1 -0
  101. package/dist/openapi/__fixtures__/route-schemas.js +17 -0
  102. package/dist/openapi/__fixtures__/route-schemas.js.map +1 -0
  103. package/dist/openapi/index.d.ts +61 -0
  104. package/dist/openapi/index.d.ts.map +1 -0
  105. package/dist/openapi/index.js +314 -0
  106. package/dist/openapi/index.js.map +1 -0
  107. package/dist/pipeline/guards.d.ts +9 -0
  108. package/dist/pipeline/guards.d.ts.map +1 -0
  109. package/dist/pipeline/guards.js +11 -0
  110. package/dist/pipeline/guards.js.map +1 -0
  111. package/dist/pipeline/index.d.ts +141 -0
  112. package/dist/pipeline/index.d.ts.map +1 -0
  113. package/dist/pipeline/index.js +1624 -0
  114. package/dist/pipeline/index.js.map +1 -0
  115. package/dist/routing/index.d.ts +40 -0
  116. package/dist/routing/index.d.ts.map +1 -0
  117. package/dist/routing/index.js +162 -0
  118. package/dist/routing/index.js.map +1 -0
  119. package/dist/static/index.d.ts +14 -0
  120. package/dist/static/index.d.ts.map +1 -0
  121. package/dist/static/index.js +348 -0
  122. package/dist/static/index.js.map +1 -0
  123. package/dist/testing/index.d.ts +20 -0
  124. package/dist/testing/index.d.ts.map +1 -0
  125. package/dist/testing/index.js +32 -0
  126. package/dist/testing/index.js.map +1 -0
  127. package/dist/traced-router.d.ts +5 -0
  128. package/dist/traced-router.d.ts.map +1 -0
  129. package/dist/traced-router.js +6 -0
  130. package/dist/traced-router.js.map +1 -0
  131. package/dist/upload/index.d.ts +28 -0
  132. package/dist/upload/index.d.ts.map +1 -0
  133. package/dist/upload/index.js +410 -0
  134. package/dist/upload/index.js.map +1 -0
  135. package/dist/versioning/index.d.ts +35 -0
  136. package/dist/versioning/index.d.ts.map +1 -0
  137. package/dist/versioning/index.js +66 -0
  138. package/dist/versioning/index.js.map +1 -0
  139. package/dist/versioning/runtime.d.ts +5 -0
  140. package/dist/versioning/runtime.d.ts.map +1 -0
  141. package/dist/versioning/runtime.js +34 -0
  142. package/dist/versioning/runtime.js.map +1 -0
  143. package/package.json +143 -0
  144. package/src/app/bridge.ts +39 -0
  145. package/src/app/index.ts +76 -0
  146. package/src/bench/index.ts +329 -0
  147. package/src/compression/index.ts +255 -0
  148. package/src/context/index.ts +181 -0
  149. package/src/contract/__fixtures__/http-client.generated.ts +73 -0
  150. package/src/contract/__fixtures__/http-client.generated.ts.map +1 -0
  151. package/src/contract/__fixtures__/http-convergence.ts +564 -0
  152. package/src/contract/compiler/client.ts +1518 -0
  153. package/src/contract/compiler/index.ts +1457 -0
  154. package/src/contract/index.ts +266 -0
  155. package/src/csrf/index.ts +264 -0
  156. package/src/data/index.ts +65 -0
  157. package/src/devtools/index.ts +727 -0
  158. package/src/dto-pipes/index.ts +93 -0
  159. package/src/gateways/index.ts +180 -0
  160. package/src/health/index.ts +198 -0
  161. package/src/http-token.ts +22 -0
  162. package/src/index.ts +167 -0
  163. package/src/integrations/index.ts +50 -0
  164. package/src/middleware/errors.ts +17 -0
  165. package/src/middleware/index.ts +108 -0
  166. package/src/modules/__fixtures__/large-graph.ts +540 -0
  167. package/src/openapi/__fixtures__/entities.ts +19 -0
  168. package/src/openapi/__fixtures__/openapi-tools.fixture.ts +212 -0
  169. package/src/openapi/__fixtures__/route-schemas.ts +27 -0
  170. package/src/openapi/index.ts +483 -0
  171. package/src/pipeline/guards.ts +23 -0
  172. package/src/pipeline/index.ts +2041 -0
  173. package/src/routing/index.ts +201 -0
  174. package/src/static/index.ts +443 -0
  175. package/src/testing/index.ts +58 -0
  176. package/src/traced-router.ts +8 -0
  177. package/src/upload/index.ts +489 -0
  178. package/src/versioning/index.ts +106 -0
  179. package/src/versioning/runtime.ts +38 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/middleware/errors.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAI1C;CACF;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;CAAG"}
@@ -0,0 +1,18 @@
1
+ /** An error carrying an HTTP status, thrown when a middleware chain short-circuits. */
2
+ export class ChainError extends Error {
3
+ status;
4
+ constructor(status, message) {
5
+ super(message);
6
+ this.name = 'ChainError';
7
+ this.status = status;
8
+ }
9
+ }
10
+ /**
11
+ * Internal boundary error whose status is already the framework's decision.
12
+ *
13
+ * Ordinary user-thrown pipe errors still become ChainError(400). Built-in
14
+ * boundary parsers use this subclass when 400 and 413 have distinct meanings.
15
+ */
16
+ export class BoundaryStatusError extends ChainError {
17
+ }
18
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/middleware/errors.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,MAAM,CAAS;IACxB,YAAY,MAAc,EAAE,OAAe;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;CAAG"}
@@ -0,0 +1,46 @@
1
+ import type { Ctx, QueryValues } from '../context/index.js';
2
+ import type { WebResponse } from '../pipeline/index.js';
3
+ export { ChainError } from './errors.js';
4
+ export type AnyCtx = Ctx<Record<string, string>, unknown, QueryValues>;
5
+ /** Authorization gate: a `false` short-circuits the request (403). */
6
+ export interface Guard {
7
+ canActivate(ctx: AnyCtx): boolean | Promise<boolean>;
8
+ }
9
+ /** A guard that declares the OpenAPI security scheme and scopes it enforces. */
10
+ export interface SecurityAwareGuard extends Guard {
11
+ readonly enforces: {
12
+ readonly scheme: string;
13
+ readonly scopes: readonly string[];
14
+ };
15
+ }
16
+ /** Transform/validate a value; ordinary throws yield 400. */
17
+ export interface Pipe<In = unknown, Out = unknown> {
18
+ transform(value: In, ctx: AnyCtx): Out | Promise<Out>;
19
+ }
20
+ /** Wrap the rest of the chain (handler) with pre/post behavior. */
21
+ export interface Interceptor {
22
+ intercept(ctx: AnyCtx, next: () => Promise<unknown>): Promise<unknown>;
23
+ }
24
+ /** Map a thrown error to a response. */
25
+ export interface ExceptionFilter {
26
+ catch(error: unknown, ctx: AnyCtx): WebResponse | undefined;
27
+ }
28
+ /** A composed middleware chain for a route. */
29
+ export interface Chain {
30
+ readonly guards: readonly Guard[];
31
+ readonly pipes: readonly Pipe[];
32
+ readonly interceptors: readonly Interceptor[];
33
+ readonly filters: readonly ExceptionFilter[];
34
+ }
35
+ /** A handler invoked with the (piped) ctx. */
36
+ export type ChainHandler = (ctx: AnyCtx) => unknown;
37
+ /**
38
+ * Run a middleware chain around `handler` for `ctx`. Order: guards → pipes (fold
39
+ * the body) → interceptors (nested) → handler. A guard returning false throws
40
+ * ChainError(403); an ordinary throwing pipe throws ChainError(400), while a
41
+ * built-in boundary pipe can preserve its framework-selected status; a thrown
42
+ * handler is offered to the exception filters — a matching filter's response is
43
+ * returned, otherwise the error rethrows for the pipeline to serialize.
44
+ */
45
+ export declare function runChain(chain: Chain, ctx: AnyCtx, handler: ChainHandler): Promise<unknown>;
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AAEvE,sEAAsE;AACtE,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD;AAED,gFAAgF;AAChF,MAAM,WAAW,kBAAmB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CACpF;AAED,6DAA6D;AAC7D,MAAM,WAAW,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO;IAC/C,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACvD;AAED,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;CAC7D;AAED,+CAA+C;AAC/C,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAEpD;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CA+CjG"}
@@ -0,0 +1,64 @@
1
+ // @zmdb/web — guards, pipes, interceptors & exception filters (epic #287, spec
2
+ // ./SPEC.md). A Chain composes middleware around a handler in deterministic
3
+ // order. Static composition, no reflection, no `as` on the consumer surface.
4
+ import { BoundaryStatusError, ChainError } from './errors.js';
5
+ export { ChainError } from './errors.js';
6
+ /**
7
+ * Run a middleware chain around `handler` for `ctx`. Order: guards → pipes (fold
8
+ * the body) → interceptors (nested) → handler. A guard returning false throws
9
+ * ChainError(403); an ordinary throwing pipe throws ChainError(400), while a
10
+ * built-in boundary pipe can preserve its framework-selected status; a thrown
11
+ * handler is offered to the exception filters — a matching filter's response is
12
+ * returned, otherwise the error rethrows for the pipeline to serialize.
13
+ */
14
+ export async function runChain(chain, ctx, handler) {
15
+ // 1) guards
16
+ for (const guard of chain.guards) {
17
+ const allowed = await guard.canActivate(ctx);
18
+ if (!allowed) {
19
+ throw new ChainError(403, 'forbidden');
20
+ }
21
+ }
22
+ // 2) pipes — fold over the body, producing a new ctx the handler sees.
23
+ let body = ctx.body;
24
+ for (const pipe of chain.pipes) {
25
+ try {
26
+ body = await pipe.transform(body, ctx);
27
+ }
28
+ catch (error) {
29
+ if (error instanceof BoundaryStatusError) {
30
+ throw error;
31
+ }
32
+ throw new ChainError(400, messageOf(error));
33
+ }
34
+ }
35
+ const pipedCtx = { ...ctx, body };
36
+ // 3) interceptors — nest right-to-left so the first listed runs outermost.
37
+ const invokeHandler = () => Promise.resolve(handler(pipedCtx));
38
+ let next = invokeHandler;
39
+ for (let i = chain.interceptors.length - 1; i >= 0; i -= 1) {
40
+ const interceptor = chain.interceptors[i];
41
+ if (interceptor === undefined) {
42
+ continue;
43
+ }
44
+ const downstream = next;
45
+ next = () => interceptor.intercept(pipedCtx, downstream);
46
+ }
47
+ // 4) handler (via the interceptor chain); 5) exception filters on throw.
48
+ try {
49
+ return await next();
50
+ }
51
+ catch (error) {
52
+ for (const filter of chain.filters) {
53
+ const response = filter.catch(error, pipedCtx);
54
+ if (response !== undefined) {
55
+ return response;
56
+ }
57
+ }
58
+ throw error;
59
+ }
60
+ }
61
+ function messageOf(error) {
62
+ return error instanceof Error ? error.message : String(error);
63
+ }
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAI7E,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwCzC;;;;;;;GAOG;AACH,MAAM,CAAC,K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B,SAAS;QACX,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC;QACxB,IAAI,GAAG,GAAqB,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC7E,CAAC;IAED,yEAAyE;IACzE,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC/C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,239 @@
1
+ import { type Token } from '@zmdb/app/di';
2
+ export declare const CONFIG: Token<{
3
+ readonly url: string;
4
+ }>;
5
+ export declare const CLOCK: Token<{
6
+ now(): number;
7
+ }>;
8
+ export declare const REQUEST_ID: Token<{
9
+ readonly id: number;
10
+ }>;
11
+ /** A space and a `#` in one description — `../../devtools/SPEC.md` §11.9's DOT quoting case. */
12
+ export declare const USER_CACHE: Token<Map<string, string>>;
13
+ export declare const POOL: Token<{
14
+ readonly dsn: string;
15
+ }>;
16
+ export declare const USERS_REPOSITORY: Token<{
17
+ find(id: string): string;
18
+ }>;
19
+ export declare const INVOICES: Token<{
20
+ total(): number;
21
+ }>;
22
+ export declare const SEARCH_INDEX: Token<{
23
+ readonly size: number;
24
+ }>;
25
+ export declare const ADMIN_POOL: Token<{
26
+ readonly dsn: string;
27
+ }>;
28
+ /** Every factory call the fixture makes, so a test can say which ran and how often. */
29
+ export declare const factoryCalls: string[];
30
+ /** Every lifecycle hook the fixture runs, in order, so a test can say which ran and when. */
31
+ export declare const hookLog: string[];
32
+ export declare function resetFactoryCalls(): void;
33
+ /** A promise a test resolves by hand, so a load can be held in flight across an `await`. */
34
+ export declare function gate(): {
35
+ readonly promise: Promise<void>;
36
+ open(): void;
37
+ };
38
+ export declare class CoreModule {
39
+ }
40
+ export declare class DataModule {
41
+ }
42
+ export declare class UsersController {
43
+ repository: {
44
+ find(id: string): string;
45
+ };
46
+ config: {
47
+ readonly url: string;
48
+ };
49
+ byId(): string;
50
+ me(): string;
51
+ create(): string;
52
+ }
53
+ export declare class UsersModule {
54
+ }
55
+ export declare class BillingController {
56
+ repository: {
57
+ find(id: string): string;
58
+ };
59
+ invoices: {
60
+ total(): number;
61
+ };
62
+ byId(): string;
63
+ }
64
+ export declare class BillingModule {
65
+ }
66
+ export declare class SearchController {
67
+ index: {
68
+ readonly size: number;
69
+ };
70
+ query(): string;
71
+ }
72
+ export declare class SearchModule {
73
+ }
74
+ /** The lazily imported module's controller. It carries all three hooks, for §L12.8 and §L12.11. */
75
+ export declare class AdminController {
76
+ pool: {
77
+ readonly dsn: string;
78
+ };
79
+ onModuleInit(): void;
80
+ onApplicationBootstrap(): void;
81
+ onShutdown(): void;
82
+ list(): string;
83
+ remove(): string;
84
+ }
85
+ export declare class AdminModule {
86
+ }
87
+ /** The eager controller the lazy one has to tear down before (§L12.11). */
88
+ export declare class HealthController {
89
+ clock: {
90
+ now(): number;
91
+ };
92
+ onModuleInit(): void;
93
+ onApplicationBootstrap(): void;
94
+ onShutdown(): void;
95
+ check(): string;
96
+ }
97
+ /** The fixture root: three eager subtrees, one lazy one, and a controller of its own. */
98
+ export declare class AppModule {
99
+ }
100
+ export declare class CycleUsersModule {
101
+ }
102
+ export declare class CycleBillingModule {
103
+ }
104
+ export declare class CycleAppModule {
105
+ }
106
+ export declare class UninitialisedImportModule {
107
+ }
108
+ /** Two controllers registering `GET /reports/:id`. The first declared wins; §5's `shadowed-route`. */
109
+ export declare class ReportsController {
110
+ byId(): string;
111
+ }
112
+ export declare class ArchivedReportsController {
113
+ byId(): string;
114
+ }
115
+ export declare class ShadowedRouteAppModule {
116
+ }
117
+ /** Two modules registering `CONFIG`; §5's `duplicate-provider` finding and startup refusal. */
118
+ export declare class FirstConfigModule {
119
+ }
120
+ export declare class SecondConfigModule {
121
+ }
122
+ export declare class DuplicateProviderAppModule {
123
+ }
124
+ /** Two distinct tokens with one description. `createToken` derives no identity from it; §5's warning. */
125
+ export declare const DB_PRIMARY: Token<string>;
126
+ export declare const DB_REPLICA: Token<string>;
127
+ export declare class AmbiguousTokenAppModule {
128
+ }
129
+ /** A controller injecting a token no module registers; §5's `unresolved-token`. */
130
+ export declare const NEVER_REGISTERED: Token<string>;
131
+ export declare class NeedsMissingController {
132
+ missing: string;
133
+ read(): string;
134
+ }
135
+ export declare class UnresolvedTokenAppModule {
136
+ }
137
+ /**
138
+ * The unresolved-token variant with a provider that *would* run first, so a test can say whether
139
+ * anything was constructed before the refusal (§L12.6: "before any provider is constructed").
140
+ */
141
+ export declare class WarmModule {
142
+ }
143
+ export declare class UnresolvedAfterWarmAppModule {
144
+ }
145
+ /** An eager controller injecting a token only the lazily imported module provides; §L3's last row. */
146
+ export declare class EagerNeedsAdminController {
147
+ pool: {
148
+ readonly dsn: string;
149
+ };
150
+ read(): string;
151
+ }
152
+ export declare class EagerDependsOnLazyAppModule {
153
+ }
154
+ /** `Shared` reached lazily from one importer and eagerly from another; §L3 makes it eager. */
155
+ export declare const SHARED: Token<{
156
+ readonly n: number;
157
+ }>;
158
+ export declare class SharedModule {
159
+ }
160
+ export declare class LazyImporterModule {
161
+ }
162
+ export declare class EagerImporterModule {
163
+ }
164
+ export declare class LazyThenEagerAppModule {
165
+ }
166
+ export declare class EagerThenLazyAppModule {
167
+ }
168
+ /**
169
+ * A lazy subtree whose `useFactory` throws — §L7's terminal failure, §L12.9 and §L12.10.
170
+ *
171
+ * The throw is in a factory rather than a constructor because a factory is the case §L7 argues
172
+ * from (the socket that is already open when the next line throws), and because `factoryCalls`
173
+ * makes "ran exactly once" a countable claim rather than an inference.
174
+ */
175
+ export declare const BROKEN_POOL: Token<{
176
+ readonly dsn: string;
177
+ }>;
178
+ export declare class BrokenController {
179
+ pool: {
180
+ readonly dsn: string;
181
+ };
182
+ read(): string;
183
+ }
184
+ export declare class BrokenModule {
185
+ }
186
+ export declare class BrokenLazyAppModule {
187
+ }
188
+ /**
189
+ * A lazy subtree whose load cannot finish until a test opens the gate, so `status` can be observed
190
+ * at `'loading'` and `[Symbol.asyncDispose]` can be called mid-load (§L8, §L12.11).
191
+ *
192
+ * The gate is in `onModuleInit` and not in the factory on purpose: §L5 freezes wiring as one
193
+ * synchronous region with the hooks as the only `await`, so a hook is the only place a load is
194
+ * legitimately suspendable. A gate in a `useFactory` would be testing a shape the spec forbids.
195
+ */
196
+ export declare const slowGate: {
197
+ readonly promise: Promise<void>;
198
+ open(): void;
199
+ };
200
+ export declare class SlowController {
201
+ onModuleInit(): Promise<void>;
202
+ read(): string;
203
+ }
204
+ export declare class SlowModule {
205
+ }
206
+ export declare class SlowLazyAppModule {
207
+ }
208
+ /** A root with no `lazy()` anywhere, for the "costs nothing when unused" half of §L12.5. */
209
+ export declare class EagerOnlyAppModule {
210
+ }
211
+ /** A module whose `name` is empty, standing in for a minified build; §5's `anonymous-class` warning. */
212
+ export declare class MangledModule {
213
+ }
214
+ /**
215
+ * Sixty value providers from one array, which is the fixture `--providers` has to refuse
216
+ * unfiltered (`../../devtools/SPEC.md` §8's fifty-node threshold). Providers are data, so the
217
+ * count needs no sixty class declarations.
218
+ */
219
+ export declare const bulkTokens: readonly Token<number>[];
220
+ export declare class WideModule {
221
+ }
222
+ export declare class WideAppModule {
223
+ }
224
+ /** A controller subclassing a controller — `../../devtools/SPEC.md` §4's prototype-aliasing case. */
225
+ export declare class BaseInjectController {
226
+ config: {
227
+ readonly url: string;
228
+ };
229
+ a(): string;
230
+ }
231
+ export declare class DerivedInjectController extends BaseInjectController {
232
+ clock: {
233
+ now(): number;
234
+ };
235
+ b(): string;
236
+ }
237
+ export declare class SubclassedControllerAppModule {
238
+ }
239
+ //# sourceMappingURL=large-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"large-graph.d.ts","sourceRoot":"","sources":["../../../src/modules/__fixtures__/large-graph.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAuC,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAS/E,eAAO,MAAM,MAAM;kBAA+B,MAAM;EAAa,CAAC;AACtE,eAAO,MAAM,KAAK;WAAwB,MAAM;EAAY,CAAC;AAC7D,eAAO,MAAM,UAAU;iBAA8B,MAAM;EAAiB,CAAC;AAC7E,gGAAgG;AAChG,eAAO,MAAM,UAAU,4BAAoD,CAAC;AAC5E,eAAO,MAAM,IAAI;kBAA+B,MAAM;EAAW,CAAC;AAClE,eAAO,MAAM,gBAAgB;aAA0B,MAAM,GAAG,MAAM;EAAuB,CAAC;AAC9F,eAAO,MAAM,QAAQ;aAA0B,MAAM;EAAe,CAAC;AACrE,eAAO,MAAM,YAAY;mBAAgC,MAAM;EAAmB,CAAC;AACnF,eAAO,MAAM,UAAU;kBAA+B,MAAM;EAAiB,CAAC;AAE9E,uFAAuF;AACvF,eAAO,MAAM,YAAY,EAAE,MAAM,EAAO,CAAC;AAEzC,6FAA6F;AAC7F,eAAO,MAAM,OAAO,EAAE,MAAM,EAAO,CAAC;AAEpC,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED,4FAA4F;AAC5F,wBAAgB,IAAI,IAAI;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,IAAI,IAAI,IAAI,CAAA;CAAE,CAMxE;AAMD,qBAsBa,UAAU;CAAG;AAE1B,qBAuBa,UAAU;CAAG;AAE1B,qBACa,eAAe;IAE1B,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