@nestbridge/unplugin 2.6.1 → 3.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # @nestbridge/unplugin
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 531bf3e: Declare the response shape of any interceptor in an optional `nestbridge.d.ts` or `nestbridge-env.d.ts` at the server `root` (equivalent names, both can be used together), and keep the types of the interceptors around an unsupported one.
8
+
9
+ Export one generic type alias per interceptor, named after the interceptor class (`export type ZodSerializerInterceptor<T> = T;`). `T` is the value coming from inside; an alias with no type parameter is a fixed shape that discards what is inside it. A matching alias wins over local analysis, the package shape-neutral rule and the unsupported diagnostic, and the interceptor is matched by its exported class name even when imported under another name. Only exported `type` aliases with zero or one type parameter are accepted; anything else exported from a file, `declare global` and `declare module` are reported as the new `invalid-interceptor-declaration` diagnostic. NestBridge writes `<outputDir>/<package name>/interceptors.d.ts`, re-exporting every alias with one line per file, and the controller declarations import the aliases they use from it. A name exported by both files is reported and used from neither. Creating, editing or deleting either file regenerates the declarations in watch mode.
10
+
11
+ An unsupported interceptor still reports its diagnostic, but it now contributes `unknown` to its route instead of turning the whole route into `AbortablePromise<unknown>`: the interceptors outside it still apply, so a declared `TransformInterceptor<T> = { data: T; meta: ... }` outside an unsupported interceptor gives `{ data: unknown; meta: ... }`. A route whose outermost result is `unknown` stays `AbortablePromise<unknown>`, and so does a route with a registration that cannot be placed in the chain (a spread `APP_INTERCEPTOR` provider, a `@UseInterceptors` argument that is not a class or `new X()`).
12
+
13
+ `@nestbridge/core` adds `analyzeControllers` option `interceptorDeclarationFilePaths`, the result field `interceptorDeclarations`, `generateInterceptorsDeclaration` (takes the declarations and the output path), the `INTERCEPTOR_DECLARATION_FILE_NAMES` constant and an optional `declaredInterceptors` list on `ResponseWrapperDetection`; `generateControllerDeclaration` takes an options argument with `interceptorsDeclarationFilePath`.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [531bf3e]
18
+ - Updated dependencies [531bf3e]
19
+ - @nestbridge/core@3.1.0
20
+
21
+ ## 3.0.0
22
+
23
+ ### Major Changes
24
+
25
+ - b5009b4: Every server now has one declaration folder, named after the package at its `root`, with the same layout everywhere. Declarations are written to `<outputDir>/<package name>/`, where `outputDir` is the explicit option, the workspace-root `.nestbridge`, or the project-root `.nestbridge` when there is no workspace. Paths inside the folder mirror the files relative to `root`, so `src/items/items.controller.ts` of a package named `http-server` becomes `.nestbridge/http-server/src/items/items.controller.d.ts`. A scoped name nests (`.nestbridge/@acme/api/`). The error body declaration is `error-body.d.ts` in the same folder (it was `nestbridge-error-body.d.ts` next to the client). The `name` option no longer affects any path: it only names the runtime service.
26
+
27
+ `root` must point at the server package, and its `package.json` must have a non-empty `name`; otherwise the build fails with an error that says so.
28
+
29
+ Declarations depend only on the server, so any number of clients of a server write the same files and share one folder. Message methods (`@EventPattern` / `@MessagePattern`) are always written to the declarations; `messagePatterns` now only decides whether the generated client module has the message methods, and whether `unsupported-message-pattern` diagnostics are reported. Every client of a server should state the same `bootstrap` option; when they disagree, the last build wins.
30
+
31
+ Upgrading:
32
+
33
+ 1. Set `root` to the server package (for example `root: '../server'`) and make the globs relative to it (`controllers: 'src/**/*.controller.ts'`). Give the server's `package.json` a `name`.
34
+ 2. Change tsconfig `paths` to `.nestbridge/<server package name>/src/*`, for example `"@server/*": ["../../../.nestbridge/http-server/src/*"]`.
35
+ 3. Change error body imports to `.nestbridge/<server package name>/error-body`.
36
+ 4. Delete the old `.nestbridge/` output.
37
+
38
+ See `MIGRATION.md`.
39
+
40
+ ### Minor Changes
41
+
42
+ - b5009b4: Response-shaping interceptors are now detected per route instead of as one app-wide wrapper, and anything that cannot be read is reported instead of silently ignored.
43
+
44
+ Each JSON route gets its own interceptor chain, outermost first: `APP_INTERCEPTOR` providers (`useClass` only, read from the root module and the modules it imports), then `app.useGlobalInterceptors(new X())`, then the controller's `@UseInterceptors`, then the method's `@UseInterceptors`. `intercept()` may hold any statements before its final `return`; the returned `next.handle()` may be piped through any number of operators. `map` operators compose in order, `tap`, `timeout` and `finalize` are shape-neutral, and a bare `return next.handle()` changes nothing. Shorthand properties (`{ data }`) and `-`, `*`, `/`, `%` arithmetic (typed `number`) are understood in `map` bodies. Message handlers and GraphQL resolvers are not wrapped yet.
45
+
46
+ An interceptor that cannot be analyzed (another operator, a `useFactory` / `useValue` / `useExisting` / spread provider, a class from a package, an unreadable `map` body, a `@UseInterceptors` argument that is not a class or `new X()`) is a new `unsupported-interceptor` diagnostic, reported once per interceptor at its source location. The JSON routes under it are declared as `AbortablePromise<unknown>`. A one-shot build fails on the diagnostic; watch mode warns.
47
+
48
+ Breaking changes to `@nestbridge/core`:
49
+
50
+ - `detectResponseWrapper` is removed. `analyzeControllers(files, { bootstrapFilePath })` now attaches an optional `responseWrapper` to each JSON method of the result and returns `interceptorFiles`, the files that took part in the detection.
51
+ - `generateControllerDeclaration(definition, outputFilePath)` no longer takes a response wrapper argument; it reads each method's own `responseWrapper`. A declaration can now hold several `__NestBridgeWrapped` helper aliases (`__NestBridgeWrapped`, `__NestBridgeWrapped2`, ...), one per distinct shape. Controllers without a response-shaping interceptor produce the same output as before.
52
+
53
+ `@nestbridge/unplugin` passes the bootstrap file to the controller analysis, re-analyzes when a file that contributed to interceptor detection changes, and registers those files and the bootstrap file with the bundler's watcher.
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [b5009b4]
58
+ - @nestbridge/core@3.0.0
59
+
3
60
  ## 2.6.1
4
61
 
5
62
  ### Patch Changes
package/README.md CHANGED
@@ -50,17 +50,18 @@ nestBridgeUnplugin.farm(options); // Farm JsPlugin
50
50
 
51
51
  ```ts
52
52
  interface NestBridgeOptions {
53
- name?: string; // names the server app; required, and unique, when you pass several apps
53
+ name?: string; // names the server app's runtime service; required, and unique, when you pass several apps; does not affect declaration paths
54
54
  controllers: string | string[]; // glob(s), resolved relative to `root`
55
55
  resolvers?: string | string[]; // glob(s) for GraphQL resolvers; defaults to none
56
+ messagePatterns?: boolean; // generates client methods for the @EventPattern/@MessagePattern handlers of `controllers`; needs `name`; defaults to false; declarations always include them
56
57
  baseURL?: string; // origin (or mount path) for this app's REST requests and its default GraphQL endpoint; applied to the runtime automatically
57
58
  bootstrap?: string; // the app's bootstrap file, relative to `root`; skips the `main.ts` search
58
59
  globalPrefix?: string | GlobalPrefixOption | false; // replaces the prefix read from `setGlobalPrefix()`; `false` ignores it
59
60
  versioning?: VersioningOption | false; // replaces the versioning read from `enableVersioning()`; `false` ignores it
60
61
  debug?: boolean; // logs discovery/analysis/watch activity
61
62
  logLevel?: 'info' | 'warn' | 'error' | 'silent'; // how much the plugin logs; defaults to the bundler's own level (Vite's logLevel, webpack's infrastructureLogging.level)
62
- outputDir?: string; // defaults to ".nestbridge" at the workspace root (nearest nx.json / pnpm-workspace.yaml / turbo.json / lerna.json / package.json with "workspaces"), or at the project root when there is no workspace; an explicit value is resolved from the bundler's own root
63
- root?: string; // base for the app's files; relative paths resolve against Vite's root (process.cwd() under webpack), which is also the default
63
+ outputDir?: string; // defaults to ".nestbridge" at the workspace root (nearest nx.json / pnpm-workspace.yaml / turbo.json / lerna.json / package.json with "workspaces"), or at the project root when there is no workspace; an explicit value is resolved from the bundler's own root; either way a server's declarations go into <outputDir>/<its package name>/
64
+ root?: string; // the server package; its package.json needs a "name", which names the declarations folder; base directory for its controllers, resolvers and bootstrap file; relative paths resolve against the bundler's root (process.cwd() under webpack), which is also the default
64
65
  }
65
66
 
66
67
  interface GlobalPrefixOption {
@@ -94,17 +95,28 @@ apps behaves like several single-app builds sharing one plugin.
94
95
 
95
96
  1. On `buildStart`, it globs `controllers`/`resolvers`, runs each file
96
97
  through [`@nestbridge/core`](../core)'s static analysis, and writes the
97
- generated `.d.ts` declarations to `outputDir` — to `<outputDir>/<name>/`
98
- for a named app — so TypeScript sees a client-facing shape instead of the
99
- real file. A file matched by the globs of two apps is an error (a warning
98
+ generated `.d.ts` declarations to `<outputDir>/<package name>/` — one folder
99
+ per server, named after the package at `root`, with each file's path
100
+ mirrored relative to `root` — so TypeScript sees a client-facing shape
101
+ instead of the real file. Message handlers (`@EventPattern` /
102
+ `@MessagePattern`) are always declared; `messagePatterns` only decides
103
+ whether the generated client code has them. The declarations depend only on the server, so every client of it
104
+ writes the same files (when clients disagree on the bootstrap file, the
105
+ last build wins). A `root` without a named `package.json` fails the build. A file matched by the globs of two apps is an error (a warning
100
106
  in watch mode) that names both.
101
107
  2. It also locates the app's bootstrap file — the `bootstrap` option, which
102
108
  must exist, or else the single `main.ts` under `root` — and runs it through
103
- `@nestbridge/core`'s `detectResponseWrapper`, `detectErrorResponseShape`,
104
- `detectGlobalPrefix` and `detectVersioning`. A registered global response
105
- interceptor is reflected directly in the generated controller declarations;
109
+ `@nestbridge/core`'s `detectErrorResponseShape`, `detectGlobalPrefix` and
110
+ `detectVersioning`; the same bootstrap file also feeds the controller
111
+ analysis, which reads the interceptors that apply to each JSON route
112
+ (`APP_INTERCEPTOR` providers, `useGlobalInterceptors` and `@UseInterceptors`).
113
+ Their response shape is reflected directly in the generated controller
114
+ declarations, and an interceptor it cannot read is an
115
+ `unsupported-interceptor` diagnostic;
106
116
  a registered `@Catch` exception filter is written to a fixed
107
- `nestbridge-error-body.d.ts` file next to them. The prefix and versioning
117
+ `error-body.d.ts` file next to them, and the interceptor types declared in an
118
+ optional `nestbridge.d.ts` and `nestbridge-env.d.ts` at `root` are re-exported from `interceptors.d.ts`
119
+ in the same folder. The prefix and versioning
108
120
  are composed into each route's path with `applyApplicationRouting`, unless
109
121
  `globalPrefix`/`versioning` state them explicitly (or `false` ignores them),
110
122
  which replaces the detection and its diagnostics. Nothing is written when
@@ -125,7 +137,9 @@ apps behaves like several single-app builds sharing one plugin.
125
137
  5. When a tracked controller, resolver, or bootstrap file changes
126
138
  (`watchChange`), it re-analyzes only the app that owns the file and rewrites
127
139
  its declarations, including the interceptor, filter, prefix and versioning
128
- detection.
140
+ detection. The bootstrap file and the interceptor files that took part in the
141
+ detection are registered with the bundler's watcher (`addWatchFile`), so
142
+ editing them re-analyzes the app.
129
143
 
130
144
  Diagnostics from `@nestbridge/core` (an unsupported decorator, a
131
145
  non-literal route path, a global prefix or versioning setup that cannot be
@@ -19,7 +19,7 @@ interface VersioningOption {
19
19
  interface NestBridgeOptions {
20
20
  /**
21
21
  * Identifies the server app. Required, and unique, when several apps are
22
- * configured. It also names the runtime service and the declaration folder.
22
+ * configured. It names the runtime service and does not affect where declarations go.
23
23
  */
24
24
  name?: string;
25
25
  controllers: string | string[];
@@ -28,7 +28,8 @@ interface NestBridgeOptions {
28
28
  * Also turns the controllers' `@EventPattern()` / `@MessagePattern()` handlers into client
29
29
  * methods that publish through `nestbridge/microservices`. Requires `name`, which is the service
30
30
  * the message client is looked up by. Off by default, so browser clients never receive
31
- * microservice code.
31
+ * microservice code. The generated declarations always describe the message handlers, whatever
32
+ * this is set to.
32
33
  */
33
34
  messagePatterns?: boolean;
34
35
  baseURL?: string;
@@ -58,10 +59,15 @@ interface NestBridgeOptions {
58
59
  /**
59
60
  * Where the generated declarations go. By default `.nestbridge` at the workspace root (the nearest
60
61
  * ancestor with `nx.json`, `pnpm-workspace.yaml`, `turbo.json`, `lerna.json` or a `package.json`
61
- * with `workspaces`), shared by every app, or in the project root when there is no workspace. An
62
- * explicit value is resolved from the bundler's own root and keeps the per-project layout.
62
+ * with `workspaces`), or in the project root when there is no workspace. An explicit value is
63
+ * resolved from the bundler's own root. Either way the declarations of a server go into a folder
64
+ * named after its package.
63
65
  */
64
66
  outputDir?: string;
67
+ /**
68
+ * The server package, resolved from the bundler's root. Its `package.json` must have a `name`,
69
+ * which names the server's declaration folder. Declaration paths mirror this directory.
70
+ */
65
71
  root?: string;
66
72
  }
67
73
  //#endregion
@@ -1,7 +1,7 @@
1
1
  import { createUnplugin } from "unplugin";
2
2
  import { closeSync, existsSync, globSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join, posix, relative, resolve, sep } from "node:path";
4
- import { analyzeControllers, analyzeResolvers, applyApplicationRouting, detectErrorResponseShape, detectGlobalPrefix, detectResponseWrapper, detectVersioning, formatDiagnostic, generateControllerDeclaration, generateErrorBodyDeclaration } from "@nestbridge/core";
4
+ import { INTERCEPTOR_DECLARATION_FILE_NAMES, analyzeControllers, analyzeResolvers, applyApplicationRouting, detectErrorResponseShape, detectGlobalPrefix, detectVersioning, formatDiagnostic, generateControllerDeclaration, generateErrorBodyDeclaration, generateInterceptorsDeclaration } from "@nestbridge/core";
5
5
  //#region src/codegen/generate-config-module.ts
6
6
  var generateBaseURLStatement = (entry) => {
7
7
  if (entry.baseURL === void 0) return;
@@ -302,6 +302,17 @@ var mostVerboseLogLevel = (levels) => levels.reduce((mostVerbose, level) => {
302
302
  return LOG_LEVEL_RANKS[level] > LOG_LEVEL_RANKS[mostVerbose] ? level : mostVerbose;
303
303
  }, "silent");
304
304
  //#endregion
305
+ //#region src/declarations/mirrored-path.ts
306
+ var stripLeadingParentSegments = (relativePath) => {
307
+ const segments = relativePath.split(/[\\/]/);
308
+ const firstOwnedIndex = segments.findIndex((segment) => segment !== "..");
309
+ return segments.slice(firstOwnedIndex === -1 ? segments.length : firstOwnedIndex).join("/");
310
+ };
311
+ var mirroredPath = (sourceRoot, resolvedOutputDir, sourcePath) => join(resolvedOutputDir, stripLeadingParentSegments(relative(sourceRoot, sourcePath)));
312
+ //#endregion
313
+ //#region src/declarations/mirror-declaration-path.ts
314
+ var mirroredDeclarationPath = (sourceRoot, resolvedOutputDir, controllerFilePath) => mirroredPath(sourceRoot, resolvedOutputDir, controllerFilePath).replace(/\.ts$/, ".d.ts");
315
+ //#endregion
305
316
  //#region \0@oxc-project+runtime@0.148.0/helpers/esm/usingCtx.js
306
317
  function _usingCtx() {
307
318
  var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
@@ -396,61 +407,23 @@ var acquireLock = (lockPath, options) => {
396
407
  }
397
408
  };
398
409
  var hasContent = (filePath, content) => existsSync(filePath) && readFileSync(filePath, "utf-8") === content;
399
- var lockFile = (filePath, options = {}) => acquireLock(`${filePath}${LOCK_FILE_SUFFIX}`, {
400
- timeoutMs: options.timeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS,
401
- staleAfterMs: options.staleAfterMs ?? DEFAULT_STALE_LOCK_MS
402
- });
403
- /**
404
- * Swaps the content in through a rename. Callers must hold the file's lock.
405
- */
406
- var writeFileAtomically = (filePath, content) => {
407
- const temporaryPath = `${filePath}.${process.pid}.tmp`;
408
- try {
409
- writeFileSync(temporaryPath, content, "utf-8");
410
- renameSync(temporaryPath, filePath);
411
- } finally {
412
- rmSync(temporaryPath, { force: true });
413
- }
414
- };
415
410
  var writeFileLocked = (filePath, content, options = {}) => {
416
411
  try {
417
- var _usingCtx$2 = _usingCtx();
412
+ var _usingCtx$1 = _usingCtx();
418
413
  if (hasContent(filePath, content)) return;
419
- _usingCtx$2.u(lockFile(filePath, options));
414
+ const lockPath = `${filePath}${LOCK_FILE_SUFFIX}`;
415
+ _usingCtx$1.u(acquireLock(lockPath, {
416
+ timeoutMs: options.timeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS,
417
+ staleAfterMs: options.staleAfterMs ?? DEFAULT_STALE_LOCK_MS
418
+ }));
420
419
  if (hasContent(filePath, content)) return;
421
- writeFileAtomically(filePath, content);
422
- } catch (_) {
423
- _usingCtx$2.e = _;
424
- } finally {
425
- _usingCtx$2.d();
426
- }
427
- };
428
- //#endregion
429
- //#region src/declarations/claim-declarations.ts
430
- var DECLARATION_CLAIM_FILE_NAME = "nestbridge-app.json";
431
- var isDeclarationClaim = (value) => typeof value === "object" && value !== null && "caller" in value && typeof value.caller === "string" && "messagePatterns" in value && typeof value.messagePatterns === "boolean" && "bootstrap" in value && (typeof value.bootstrap === "string" || value.bootstrap === null);
432
- var readClaim = (claimPath) => {
433
- if (!existsSync(claimPath)) return;
434
- const claim = JSON.parse(readFileSync(claimPath, "utf-8"));
435
- if (!isDeclarationClaim(claim)) throw new Error(`[NestBridge] ${claimPath} is not a NestBridge declaration claim. Delete it so the next build recreates it.`);
436
- return claim;
437
- };
438
- var hasSameOptions = (left, right) => left.messagePatterns === right.messagePatterns && left.bootstrap === right.bootstrap;
439
- var serializeClaim = (claim) => `${JSON.stringify(claim, null, 2)}\n`;
440
- /**
441
- * Records `claim` as the owner of an app's declarations, unless another caller that still exists
442
- * owns them with options that generate different declarations. That owner's claim is returned, and
443
- * the caller must not write the declarations.
444
- */
445
- var claimDeclarations = (claimPath, claim) => {
446
- try {
447
- var _usingCtx$1 = _usingCtx();
448
- mkdirSync(dirname(claimPath), { recursive: true });
449
- _usingCtx$1.u(lockFile(claimPath));
450
- const existing = readClaim(claimPath);
451
- if (existing !== void 0 && existing.caller !== claim.caller && existsSync(existing.caller)) return hasSameOptions(existing, claim) ? void 0 : existing;
452
- writeFileAtomically(claimPath, serializeClaim(claim));
453
- return;
420
+ const temporaryPath = `${filePath}.${process.pid}.tmp`;
421
+ try {
422
+ writeFileSync(temporaryPath, content, "utf-8");
423
+ renameSync(temporaryPath, filePath);
424
+ } finally {
425
+ rmSync(temporaryPath, { force: true });
426
+ }
454
427
  } catch (_) {
455
428
  _usingCtx$1.e = _;
456
429
  } finally {
@@ -458,28 +431,17 @@ var claimDeclarations = (claimPath, claim) => {
458
431
  }
459
432
  };
460
433
  //#endregion
461
- //#region src/declarations/mirrored-path.ts
462
- var stripLeadingParentSegments = (relativePath) => {
463
- const segments = relativePath.split(/[\\/]/);
464
- const firstOwnedIndex = segments.findIndex((segment) => segment !== "..");
465
- return segments.slice(firstOwnedIndex === -1 ? segments.length : firstOwnedIndex).join("/");
466
- };
467
- var mirroredPath = (sourceRoot, resolvedOutputDir, sourcePath) => join(resolvedOutputDir, stripLeadingParentSegments(relative(sourceRoot, sourcePath)));
468
- //#endregion
469
- //#region src/declarations/mirror-declaration-path.ts
470
- var mirroredDeclarationPath = (sourceRoot, resolvedOutputDir, controllerFilePath) => mirroredPath(sourceRoot, resolvedOutputDir, controllerFilePath).replace(/\.ts$/, ".d.ts");
471
- //#endregion
472
434
  //#region src/declarations/write-controller-declarations.ts
473
- var writeControllerDeclarations = (controllers, sourceRoot, resolvedOutputDir, responseWrapper) => {
435
+ var writeControllerDeclarations = (controllers, sourceRoot, resolvedOutputDir, interceptorsDeclarationFilePath) => {
474
436
  for (const controller of controllers) {
475
437
  const outputFilePath = mirroredDeclarationPath(sourceRoot, resolvedOutputDir, controller.sourceFile);
476
438
  mkdirSync(dirname(outputFilePath), { recursive: true });
477
- writeFileLocked(outputFilePath, generateControllerDeclaration(controller, outputFilePath, responseWrapper));
439
+ writeFileLocked(outputFilePath, generateControllerDeclaration(controller, outputFilePath, { interceptorsDeclarationFilePath }));
478
440
  }
479
441
  };
480
442
  //#endregion
481
443
  //#region src/declarations/write-error-body-declaration.ts
482
- var ERROR_BODY_DECLARATION_FILE_NAME = "nestbridge-error-body.d.ts";
444
+ var ERROR_BODY_DECLARATION_FILE_NAME = "error-body.d.ts";
483
445
  var errorBodyDeclarationPath = (resolvedOutputDir) => join(resolvedOutputDir, ERROR_BODY_DECLARATION_FILE_NAME);
484
446
  var writeErrorBodyDeclaration = (resolvedOutputDir, errorResponseShape) => {
485
447
  const outputFilePath = errorBodyDeclarationPath(resolvedOutputDir);
@@ -491,6 +453,19 @@ var writeErrorBodyDeclaration = (resolvedOutputDir, errorResponseShape) => {
491
453
  writeFileLocked(outputFilePath, generateErrorBodyDeclaration(errorResponseShape.errorBodyTypeSource));
492
454
  };
493
455
  //#endregion
456
+ //#region src/declarations/write-interceptors-declaration.ts
457
+ var INTERCEPTORS_DECLARATION_FILE_NAME = "interceptors.d.ts";
458
+ var interceptorsDeclarationPath = (resolvedOutputDir) => join(resolvedOutputDir, INTERCEPTORS_DECLARATION_FILE_NAME);
459
+ var writeInterceptorsDeclaration = (resolvedOutputDir, declarations) => {
460
+ const outputFilePath = interceptorsDeclarationPath(resolvedOutputDir);
461
+ if (declarations.length === 0) {
462
+ rmSync(outputFilePath, { force: true });
463
+ return;
464
+ }
465
+ mkdirSync(dirname(outputFilePath), { recursive: true });
466
+ writeFileLocked(outputFilePath, generateInterceptorsDeclaration(declarations, outputFilePath));
467
+ };
468
+ //#endregion
494
469
  //#region src/declarations/write-resolver-declarations.ts
495
470
  var writeResolverDeclarations = (resolvers, sourceRoot, resolvedOutputDir) => {
496
471
  for (const resolver of resolvers) {
@@ -531,15 +506,20 @@ var normalizePath = (filePath) => posix.normalize(isWindows ? filePath.replaceAl
531
506
  //#region src/plugin/controller-registry.ts
532
507
  var createControllerRegistry = (patterns, root, analysisOptions) => {
533
508
  const controllersByFile = /* @__PURE__ */ new Map();
534
- const refresh = (routing = {}) => {
509
+ const refresh = (routing = {}, bootstrapFilePath) => {
535
510
  controllersByFile.clear();
536
511
  const files = discoverFiles(patterns, root);
537
- const { controllers: analyzed, diagnostics } = analyzeControllers(files, analysisOptions);
512
+ const { controllers: analyzed, diagnostics, interceptorFiles, interceptorDeclarations } = analyzeControllers(files, {
513
+ ...analysisOptions,
514
+ bootstrapFilePath
515
+ });
538
516
  const controllers = applyApplicationRouting(analyzed, routing);
539
517
  for (const controller of controllers) controllersByFile.set(normalizePath(controller.sourceFile), controller);
540
518
  return {
541
519
  controllers,
542
- diagnostics
520
+ diagnostics,
521
+ interceptorFiles,
522
+ interceptorDeclarations
543
523
  };
544
524
  };
545
525
  return {
@@ -550,19 +530,6 @@ var createControllerRegistry = (patterns, root, analysisOptions) => {
550
530
  };
551
531
  };
552
532
  //#endregion
553
- //#region src/plugin/describe-declaration-conflict.ts
554
- var describeDifferences = (owner, claim) => {
555
- const differences = [];
556
- if (owner.messagePatterns !== claim.messagePatterns) differences.push(`messagePatterns ${owner.messagePatterns} there, ${claim.messagePatterns} here`);
557
- if (owner.bootstrap !== claim.bootstrap) differences.push(`bootstrap ${owner.bootstrap ?? "none"} there, ${claim.bootstrap ?? "none"} here`);
558
- return differences.join("; ");
559
- };
560
- var describeDeclarationConflict = (appName, declarationDir, owner, claim) => {
561
- const app = appName === void 0 ? "The app" : `App "${appName}"`;
562
- const remedy = appName === void 0 ? "give this app a `name`" : "give this app another `name`";
563
- return `${app} shares its declarations in ${declarationDir} with the build of ${owner.caller}, which configures it differently (${describeDifferences(owner, claim)}). Builds that use the same app name for the same server must configure it the same way: ${remedy}, or match the other build's options. Declarations were not written.`;
564
- };
565
- //#endregion
566
533
  //#region src/discovery/find-workspace-root.ts
567
534
  var WORKSPACE_MARKER_FILES = [
568
535
  "nx.json",
@@ -587,38 +554,32 @@ var findWorkspaceRoot = (startDirectory) => {
587
554
  }
588
555
  };
589
556
  //#endregion
557
+ //#region src/discovery/read-package-name.ts
558
+ var missingName = (root) => /* @__PURE__ */ new Error(`[NestBridge] ${join(root, "package.json")} has no "name". NestBridge names a server's declaration folder after its package: point \`root\` at the server package, or give it a name.`);
559
+ var readPackageName = (root) => {
560
+ const manifestPath = join(root, "package.json");
561
+ if (!existsSync(manifestPath)) throw missingName(root);
562
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
563
+ if (typeof manifest !== "object" || manifest === null || !("name" in manifest) || typeof manifest.name !== "string" || manifest.name === "") throw missingName(root);
564
+ return manifest.name;
565
+ };
566
+ //#endregion
590
567
  //#region src/plugin/resolve-output-location.ts
591
568
  var DEFAULT_OUTPUT_DIR = ".nestbridge";
592
- var withAppName = (outputDir, name) => name === void 0 ? outputDir : join(outputDir, name);
593
- var resolveOutputLocation = (input) => {
569
+ var resolveOutputDir = (input) => {
594
570
  const projectRoot = input.bundlerRoot ?? input.root;
595
- if (input.outputDir !== void 0) {
596
- const outputDir = resolve(projectRoot, input.outputDir);
597
- const declarationDir = withAppName(outputDir, input.name);
598
- return {
599
- outputDir,
600
- declarationDir,
601
- errorBodyDir: declarationDir,
602
- mirrorRoot: input.root
603
- };
604
- }
605
- const workspaceRoot = findWorkspaceRoot(projectRoot);
606
- if (workspaceRoot === void 0) {
607
- const outputDir = resolve(projectRoot, DEFAULT_OUTPUT_DIR);
608
- const declarationDir = withAppName(outputDir, input.name);
609
- return {
610
- outputDir,
611
- declarationDir,
612
- errorBodyDir: declarationDir,
613
- mirrorRoot: input.root
614
- };
615
- }
616
- const outputDir = resolve(workspaceRoot, DEFAULT_OUTPUT_DIR);
571
+ if (input.outputDir !== void 0) return resolve(projectRoot, input.outputDir);
572
+ return resolve(findWorkspaceRoot(projectRoot) ?? projectRoot, DEFAULT_OUTPUT_DIR);
573
+ };
574
+ /**
575
+ * Every server gets one folder, named after the package at its `root`, so any number of clients of
576
+ * that server share the same declarations.
577
+ */
578
+ var resolveOutputLocation = (input) => {
579
+ const outputDir = resolveOutputDir(input);
617
580
  return {
618
581
  outputDir,
619
- declarationDir: withAppName(outputDir, input.name),
620
- errorBodyDir: withAppName(join(outputDir, relative(workspaceRoot, projectRoot)), input.name),
621
- mirrorRoot: workspaceRoot
582
+ declarationDir: join(outputDir, readPackageName(input.root))
622
583
  };
623
584
  };
624
585
  //#endregion
@@ -664,15 +625,17 @@ var createNestBridgeApp = (options, location) => {
664
625
  const root = options.root === void 0 ? location.baseRoot : resolve(location.baseRoot, options.root);
665
626
  const output = resolveOutputLocation({
666
627
  outputDir: options.outputDir,
667
- name: options.name,
668
628
  root,
669
629
  bundlerRoot: location.bundlerRoot
670
630
  });
671
- const controllerRegistry = createControllerRegistry(options.controllers, root, { messagePatterns: options.messagePatterns });
631
+ const interceptorDeclarationFilePaths = INTERCEPTOR_DECLARATION_FILE_NAMES.map((fileName) => normalizePath(join(root, fileName)));
632
+ const controllerRegistry = createControllerRegistry(options.controllers, root, {
633
+ messagePatterns: true,
634
+ interceptorDeclarationFilePaths
635
+ });
672
636
  const resolverRegistry = createResolverRegistry(options.resolvers, root);
673
- const claimPath = mirroredPath(output.mirrorRoot, output.declarationDir, join(root, DECLARATION_CLAIM_FILE_NAME));
674
- const caller = normalizePath(location.bundlerRoot ?? location.baseRoot);
675
637
  let bootstrapFilePath;
638
+ let interceptorFiles = /* @__PURE__ */ new Set();
676
639
  const describeApp = () => options.name === void 0 ? "the app" : `app "${options.name}"`;
677
640
  const locateBootstrapFile = (problems) => {
678
641
  const bootstrapFile = resolveBootstrapFile(root, output.outputDir, options.bootstrap);
@@ -697,28 +660,22 @@ var createNestBridgeApp = (options, location) => {
697
660
  globalPrefix: globalPrefix.value,
698
661
  versioning: versioning.value
699
662
  };
700
- const responseWrapper = bootstrapFile === void 0 ? void 0 : detectResponseWrapper(bootstrapFile);
701
663
  const errorResponseShape = bootstrapFile === void 0 ? void 0 : detectErrorResponseShape(bootstrapFile);
702
- const { controllers, diagnostics: controllerDiagnostics } = controllerRegistry.refresh(routing);
664
+ const { controllers, diagnostics: controllerDiagnostics, interceptorFiles: analyzedInterceptorFiles, interceptorDeclarations } = controllerRegistry.refresh(routing, bootstrapFile);
665
+ interceptorFiles = new Set(analyzedInterceptorFiles.map(normalizePath));
703
666
  const { resolvers, diagnostics: resolverDiagnostics } = resolverRegistry.refresh();
704
- const claim = {
705
- caller,
706
- messagePatterns: options.messagePatterns,
707
- bootstrap: bootstrapFilePath ?? null
708
- };
709
- const owner = claimDeclarations(claimPath, claim);
710
- if (owner === void 0) {
711
- writeControllerDeclarations(controllers, output.mirrorRoot, output.declarationDir, responseWrapper);
712
- writeResolverDeclarations(resolvers, output.mirrorRoot, output.declarationDir);
713
- writeErrorBodyDeclaration(output.errorBodyDir, errorResponseShape);
714
- } else problems.push(describeDeclarationConflict(options.name, output.declarationDir, owner, claim));
667
+ const reportedControllerDiagnostics = options.messagePatterns ? controllerDiagnostics : controllerDiagnostics.filter(({ code }) => code !== "unsupported-message-pattern");
668
+ writeControllerDeclarations(controllers, root, output.declarationDir, interceptorsDeclarationPath(output.declarationDir));
669
+ writeResolverDeclarations(resolvers, root, output.declarationDir);
670
+ writeErrorBodyDeclaration(output.declarationDir, errorResponseShape);
671
+ writeInterceptorsDeclaration(output.declarationDir, interceptorDeclarations);
715
672
  return {
716
673
  controllerCount: controllers.length,
717
674
  resolverCount: resolvers.length,
718
675
  diagnostics: [
719
676
  ...globalPrefix.diagnostics,
720
677
  ...versioning.diagnostics,
721
- ...controllerDiagnostics,
678
+ ...reportedControllerDiagnostics,
722
679
  ...resolverDiagnostics
723
680
  ],
724
681
  problems
@@ -726,17 +683,26 @@ var createNestBridgeApp = (options, location) => {
726
683
  };
727
684
  const transform = (filePath) => {
728
685
  const controller = controllerRegistry.get(filePath);
729
- if (controller !== void 0) return generateControllerModule(controller, options.name);
686
+ if (controller !== void 0) return generateControllerModule(options.messagePatterns ? controller : {
687
+ ...controller,
688
+ messageHandlers: []
689
+ }, options.name);
730
690
  const resolver = resolverRegistry.get(filePath);
731
691
  if (resolver !== void 0) return generateResolverModule(resolver, options.name);
732
692
  };
733
693
  const ownedFiles = () => [...controllerRegistry.all().map((controller) => normalizePath(controller.sourceFile)), ...resolverRegistry.all().map((resolver) => normalizePath(resolver.sourceFile))];
734
- const isAffectedBy = (changedFile) => controllerRegistry.has(changedFile) || resolverRegistry.has(changedFile) || changedFile === bootstrapFilePath || matchesPatterns(options.controllers, changedFile) || matchesPatterns(options.resolvers, changedFile) || isBootstrapFile(changedFile);
694
+ const supportFiles = () => [
695
+ ...bootstrapFilePath === void 0 ? [] : [bootstrapFilePath],
696
+ ...interceptorFiles,
697
+ ...interceptorDeclarationFilePaths
698
+ ];
699
+ const isAffectedBy = (changedFile) => controllerRegistry.has(changedFile) || resolverRegistry.has(changedFile) || changedFile === bootstrapFilePath || interceptorFiles.has(changedFile) || interceptorDeclarationFilePaths.includes(changedFile) || matchesPatterns(options.controllers, changedFile) || matchesPatterns(options.resolvers, changedFile) || isBootstrapFile(changedFile);
735
700
  return {
736
701
  options,
737
702
  analyze,
738
703
  transform,
739
704
  ownedFiles,
705
+ supportFiles,
740
706
  isAffectedBy
741
707
  };
742
708
  };
@@ -770,10 +736,11 @@ var nestBridgeUnplugin = createUnplugin((options, meta) => {
770
736
  loggerOf(app).info(`[nestbridge] ${prefix}${message}`);
771
737
  }
772
738
  };
773
- const analyzeApps = (targets) => {
739
+ const analyzeApps = (targets, context) => {
774
740
  const watchMode = isWatchMode();
775
741
  for (const app of targets) {
776
742
  const { controllerCount, resolverCount, diagnostics, problems } = app.analyze();
743
+ for (const supportFile of app.supportFiles()) context.addWatchFile(supportFile);
777
744
  reportMessages(problems.map((problem) => `[nestbridge] ${problem}`), watchMode, loggerOf(app));
778
745
  reportDiagnostics(diagnostics, watchMode, loggerOf(app));
779
746
  log(app, `analyzed ${controllerCount} controller(s), ${resolverCount} resolver(s), ${diagnostics.length} diagnostic(s)`);
@@ -788,7 +755,7 @@ var nestBridgeUnplugin = createUnplugin((options, meta) => {
788
755
  baseRoot,
789
756
  bundlerRoot
790
757
  }));
791
- analyzeApps(apps);
758
+ analyzeApps(apps, this);
792
759
  },
793
760
  resolveId(source) {
794
761
  if (source === "virtual-nestbridge-config") return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;
@@ -810,7 +777,7 @@ var nestBridgeUnplugin = createUnplugin((options, meta) => {
810
777
  const changedFile = normalizePath(id);
811
778
  const affectedApps = apps.filter((app) => app.isAffectedBy(changedFile));
812
779
  if (affectedApps.length === 0) return;
813
- analyzeApps(affectedApps);
780
+ analyzeApps(affectedApps, this);
814
781
  for (const app of affectedApps) log(app, `nestbridge source changed: ${changedFile}`);
815
782
  },
816
783
  vite: { configResolved(config) {
@@ -829,7 +796,7 @@ var nestBridgeUnplugin = createUnplugin((options, meta) => {
829
796
  });
830
797
  //#endregion
831
798
  //#region src/version.ts
832
- var VERSION = "2.6.1";
799
+ var VERSION = "3.1.0";
833
800
  //#endregion
834
801
  export { VERSION, nestBridgeUnplugin };
835
802
 
@@ -1 +1 @@
1
- {"version":3,"file":"nestbridge.unplugin.js","names":[],"sources":["../src/codegen/generate-config-module.ts","../src/virtual-modules/config-virtual-id.ts","../src/codegen/merge-named-parameters-expression.ts","../src/codegen/generate-body-expression.ts","../src/codegen/generate-headers-expression.ts","../src/codegen/message-runtime-function.ts","../src/codegen/generate-message-method.ts","../src/codegen/generate-parameter-list.ts","../src/codegen/generate-path-expression.ts","../src/codegen/generate-query-expression.ts","../src/codegen/generate-controller-module.ts","../src/codegen/generate-graphql-document.ts","../src/codegen/generate-resolver-argument-list.ts","../src/codegen/generate-resolver-module.ts","../src/options/log-level-ranks.ts","../src/options/resolve-global-prefix-option.ts","../src/options/resolve-versioning-option.ts","../src/options/resolve-nestbridge-entry.ts","../src/options/validate-nestbridge-entries.ts","../src/options/resolve-nestbridge-options.ts","../src/plugin/console-logger.ts","../src/plugin/create-level-logger.ts","../src/plugin/find-overlapping-files.ts","../src/plugin/most-verbose-log-level.ts","../src/declarations/write-file-locked.ts","../src/declarations/claim-declarations.ts","../src/declarations/mirrored-path.ts","../src/declarations/mirror-declaration-path.ts","../src/declarations/write-controller-declarations.ts","../src/declarations/write-error-body-declaration.ts","../src/declarations/write-resolver-declarations.ts","../src/discovery/discover-files.ts","../src/discovery/discover-bootstrap-file.ts","../src/discovery/resolve-bootstrap-file.ts","../src/plugin/normalize-path.ts","../src/plugin/controller-registry.ts","../src/plugin/describe-declaration-conflict.ts","../src/discovery/find-workspace-root.ts","../src/plugin/resolve-output-location.ts","../src/plugin/resolve-routing-option.ts","../src/plugin/resolver-registry.ts","../src/plugin/nestbridge-app.ts","../src/plugin/report-messages.ts","../src/plugin/report-diagnostics.ts","../src/plugin/nestbridge-unplugin-factory.ts","../package.json","../src/version.ts"],"sourcesContent":["import type { ResolvedNestBridgeOptions } from '../options';\n\nconst generateBaseURLStatement = (entry: ResolvedNestBridgeOptions) => {\n if (entry.baseURL === undefined) {\n return undefined;\n }\n\n if (entry.name === undefined) {\n return `setNestBridgeBaseURL(${JSON.stringify(entry.baseURL)});`;\n }\n\n return `setNestBridgeServiceBaseURL(${JSON.stringify(entry.name)}, ${JSON.stringify(entry.baseURL)});`;\n};\n\nexport const generateConfigModule = (entries: readonly ResolvedNestBridgeOptions[]) => {\n const statements = entries\n .map(generateBaseURLStatement)\n .filter((statement) => statement !== undefined);\n\n if (statements.length === 0) {\n return '';\n }\n\n const importedNames = ['setNestBridgeBaseURL', 'setNestBridgeServiceBaseURL'].filter((name) =>\n statements.some((statement) => statement.startsWith(`${name}(`)),\n );\n\n return [`import { ${importedNames.join(', ')} } from 'nestbridge';`, '', ...statements, ''].join(\n '\\n',\n );\n};\n","/**\n * Must not contain a colon: webpack treats any `letter+:` prefix as a URL\n * scheme and routes the request past its filesystem resolver entirely,\n * bypassing the resolveId hook this virtual module relies on.\n */\nexport const CONFIG_VIRTUAL_MODULE_ID = 'virtual-nestbridge-config';\n\nexport const RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\\0${CONFIG_VIRTUAL_MODULE_ID}`;\n","interface NamedParameterLike {\n name?: string;\n parameterName: string;\n}\n\nexport const mergeNamedParametersExpression = (parameters: readonly NamedParameterLike[]) => {\n if (parameters.length === 0) {\n return undefined;\n }\n\n const whole = parameters.find((parameter) => parameter.name === undefined);\n const named = parameters.filter((parameter) => parameter.name !== undefined);\n const namedEntries = named.map(\n (parameter) => `${JSON.stringify(parameter.name)}: ${parameter.parameterName}`,\n );\n\n if (whole === undefined) {\n return `{ ${namedEntries.join(', ')} }`;\n }\n\n if (named.length === 0) {\n return whole.parameterName;\n }\n\n return `{ ...${whole.parameterName}, ${namedEntries.join(', ')} }`;\n};\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\nimport { mergeNamedParametersExpression } from './merge-named-parameters-expression';\n\nexport const generateBodyExpression = (parameters: readonly ControllerParameterDefinition[]) =>\n mergeNamedParametersExpression(parameters.filter((parameter) => parameter.kind === 'body'));\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\n\nexport const generateHeadersExpression = (parameters: readonly ControllerParameterDefinition[]) => {\n const headerParameters = parameters.filter((parameter) => parameter.kind === 'header');\n\n if (headerParameters.length === 0) {\n return undefined;\n }\n\n const entries = headerParameters.map(\n (parameter) => `${JSON.stringify(parameter.name)}: ${parameter.parameterName}`,\n );\n\n return `{ ${entries.join(', ')} }`;\n};\n","import type { MessageKind } from '@nestbridge/core';\n\nexport const messageRuntimeFunctionOf = (kind: MessageKind) =>\n kind === 'event' ? 'emitMessage' : 'sendMessage';\n","import type { MessageHandlerDefinition } from '@nestbridge/core';\nimport { messageRuntimeFunctionOf } from './message-runtime-function';\n\nconst PAYLOAD_PARAMETER = 'payload';\n\nconst EMPTY_PAYLOAD = '{}';\n\nexport const generateMessageMethod = (handler: MessageHandlerDefinition, service: string) => {\n const hasPayload = handler.payloadParameterIndex !== null;\n const messageProperties = [\n `service: ${JSON.stringify(service)}`,\n `pattern: ${JSON.stringify(handler.pattern)}`,\n hasPayload ? PAYLOAD_PARAMETER : `payload: ${EMPTY_PAYLOAD}`,\n ];\n\n return [\n ` ${handler.name}(${hasPayload ? PAYLOAD_PARAMETER : ''}) {`,\n ` return ${messageRuntimeFunctionOf(handler.kind)}({`,\n ...messageProperties.map((property) => ` ${property},`),\n ' });',\n ' }',\n ].join('\\n');\n};\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\n\nexport const generateParameterList = (parameters: readonly ControllerParameterDefinition[]) =>\n [...parameters]\n .sort((a, b) => a.index - b.index)\n .map((parameter) => parameter.parameterName)\n .join(', ');\n","import type { ControllerMethodDefinition } from '@nestbridge/core';\n\nconst PARAM_TOKEN_PATTERN = /:([A-Za-z0-9_]+)/;\nconst IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst generatePropertyAccess = (objectName: string, propertyName: string) =>\n IDENTIFIER_PATTERN.test(propertyName)\n ? `${objectName}.${propertyName}`\n : `${objectName}[${JSON.stringify(propertyName)}]`;\n\nexport const generatePathExpression = (method: ControllerMethodDefinition) => {\n const paramParameters = method.parameters.filter((parameter) => parameter.kind === 'param');\n const wholeParameter = paramParameters.find((parameter) => parameter.name === undefined);\n const parts = method.path.split(PARAM_TOKEN_PATTERN);\n const expressionParts: string[] = [];\n\n const generateTokenExpression = (token: string) => {\n const namedParameter = paramParameters.find((parameter) => parameter.name === token);\n\n if (namedParameter !== undefined) {\n return `encodeURIComponent(${namedParameter.parameterName})`;\n }\n\n if (wholeParameter !== undefined) {\n return `encodeURIComponent(${generatePropertyAccess(wholeParameter.parameterName, token)})`;\n }\n\n return JSON.stringify(`:${token}`);\n };\n\n parts.forEach((part, index) => {\n const isParamToken = index % 2 === 1;\n\n if (isParamToken) {\n expressionParts.push(generateTokenExpression(part));\n return;\n }\n\n if (part.length > 0) {\n expressionParts.push(JSON.stringify(part));\n }\n });\n\n return expressionParts.length > 0 ? expressionParts.join(' + ') : \"''\";\n};\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\nimport { mergeNamedParametersExpression } from './merge-named-parameters-expression';\n\nexport const generateQueryExpression = (parameters: readonly ControllerParameterDefinition[]) =>\n mergeNamedParametersExpression(parameters.filter((parameter) => parameter.kind === 'query'));\n","import type { ControllerDefinition, ControllerMethodDefinition } from '@nestbridge/core';\nimport { CONFIG_VIRTUAL_MODULE_ID } from '../virtual-modules';\nimport { generateBodyExpression } from './generate-body-expression';\nimport { generateHeadersExpression } from './generate-headers-expression';\nimport { generateMessageMethod } from './generate-message-method';\nimport { generateParameterList } from './generate-parameter-list';\nimport { generatePathExpression } from './generate-path-expression';\nimport { generateQueryExpression } from './generate-query-expression';\nimport { messageRuntimeFunctionOf } from './message-runtime-function';\n\nconst generateMethod = (method: ControllerMethodDefinition, service: string | undefined) => {\n const requestProperties = [\n `method: ${JSON.stringify(method.httpMethod)}`,\n `path: ${generatePathExpression(method)}`,\n ];\n\n if (service !== undefined) {\n requestProperties.push(`service: ${JSON.stringify(service)}`);\n }\n\n const queryExpression = generateQueryExpression(method.parameters);\n if (queryExpression !== undefined) {\n requestProperties.push(`query: ${queryExpression}`);\n }\n\n const bodyExpression = generateBodyExpression(method.parameters);\n if (bodyExpression !== undefined) {\n requestProperties.push(`body: ${bodyExpression}`);\n }\n\n const headersExpression = generateHeadersExpression(method.parameters);\n if (headersExpression !== undefined) {\n requestProperties.push(`headers: ${headersExpression}`);\n }\n\n if (method.responseKind === 'stream') {\n requestProperties.push(`responseType: \"blob\"`);\n }\n\n return [\n ` ${method.name}(${generateParameterList(method.parameters)}) {`,\n ' return request({',\n ...requestProperties.map((property) => ` ${property},`),\n ' });',\n ' }',\n ].join('\\n');\n};\n\nconst generateMessageMethods = (controller: ControllerDefinition, service: string | undefined) => {\n if (controller.messageHandlers.length === 0) {\n return [];\n }\n\n if (service === undefined) {\n throw new Error(\n `[nestbridge] ${controller.name} has message handlers, but its app has no \\`name\\` to address the service by.`,\n );\n }\n\n return controller.messageHandlers.map((handler) => generateMessageMethod(handler, service));\n};\n\nexport const generateControllerModule = (controller: ControllerDefinition, service?: string) => {\n const methods = [\n ...controller.methods.map((method) => generateMethod(method, service)),\n ...generateMessageMethods(controller, service),\n ].join('\\n\\n');\n const messageRuntimeFunctions = Array.from(\n new Set(controller.messageHandlers.map((handler) => messageRuntimeFunctionOf(handler.kind))),\n ).sort();\n\n return [\n `import '${CONFIG_VIRTUAL_MODULE_ID}';`,\n \"import { request } from 'nestbridge';\",\n ...(messageRuntimeFunctions.length > 0\n ? [`import { ${messageRuntimeFunctions.join(', ')} } from 'nestbridge/microservices';`]\n : []),\n '',\n `export class ${controller.name} {`,\n ' constructor() {}',\n '',\n methods,\n '}',\n '',\n ].join('\\n');\n};\n","import type { ResolverMethodDefinition, SelectionField } from '@nestbridge/core';\n\nconst capitalize = (value: string) => `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n\nconst renderSelectionSet = (fields: readonly SelectionField[]): string => {\n const rendered = fields.map((field) =>\n field.children === undefined\n ? field.name\n : `${field.name} ${renderSelectionSet(field.children)}`,\n );\n\n return `{ ${rendered.join(' ')} }`;\n};\n\nexport const generateGraphqlDocument = (method: ResolverMethodDefinition) => {\n const variableDeclarations = method.arguments\n .map((argument) => `$${argument.name}: ${argument.graphqlType}`)\n .join(', ');\n const fieldArguments = method.arguments\n .map((argument) => `${argument.name}: $${argument.name}`)\n .join(', ');\n\n const variablesClause = variableDeclarations.length > 0 ? `(${variableDeclarations})` : '';\n const fieldArgumentsClause = fieldArguments.length > 0 ? `(${fieldArguments})` : '';\n const fieldSelection =\n method.selection.length > 0 ? ` ${renderSelectionSet(method.selection)}` : '';\n\n return `${method.operationKind} ${capitalize(method.name)}${variablesClause} { ${method.operationName}${fieldArgumentsClause}${fieldSelection} }`;\n};\n","import type { ResolverArgumentDefinition } from '@nestbridge/core';\n\nexport const generateResolverArgumentList = (\n resolverArguments: readonly ResolverArgumentDefinition[],\n) =>\n [...resolverArguments]\n .sort((a, b) => a.index - b.index)\n .map((argument) => argument.parameterName)\n .join(', ');\n","import type {\n ResolverArgumentDefinition,\n ResolverDefinition,\n ResolverMethodDefinition,\n} from '@nestbridge/core';\nimport { CONFIG_VIRTUAL_MODULE_ID } from '../virtual-modules';\nimport { generateGraphqlDocument } from './generate-graphql-document';\nimport { generateResolverArgumentList } from './generate-resolver-argument-list';\n\nconst generateVariablesExpression = (resolverArguments: readonly ResolverArgumentDefinition[]) => {\n if (resolverArguments.length === 0) {\n return undefined;\n }\n\n const entries = resolverArguments.map(\n (argument) => `${JSON.stringify(argument.name)}: ${argument.parameterName}`,\n );\n\n return `{ ${entries.join(', ')} }`;\n};\n\nconst generateMethod = (method: ResolverMethodDefinition, service: string | undefined) => {\n const requestProperties = [\n `document: ${JSON.stringify(generateGraphqlDocument(method))}`,\n `field: ${JSON.stringify(method.operationName)}`,\n ];\n\n if (service !== undefined) {\n requestProperties.push(`service: ${JSON.stringify(service)}`);\n }\n\n const variablesExpression = generateVariablesExpression(method.arguments);\n if (variablesExpression !== undefined) {\n requestProperties.push(`variables: ${variablesExpression}`);\n }\n\n return [\n ` ${method.name}(${generateResolverArgumentList(method.arguments)}) {`,\n ' return graphqlRequest({',\n ...requestProperties.map((property) => ` ${property},`),\n ' });',\n ' }',\n ].join('\\n');\n};\n\nexport const generateResolverModule = (resolver: ResolverDefinition, service?: string) => {\n const methods = resolver.methods.map((method) => generateMethod(method, service)).join('\\n\\n');\n\n return [\n `import '${CONFIG_VIRTUAL_MODULE_ID}';`,\n \"import { graphqlRequest } from 'nestbridge';\",\n '',\n `export class ${resolver.name} {`,\n ' constructor() {}',\n '',\n methods,\n '}',\n '',\n ].join('\\n');\n};\n","import type { NestBridgeLogLevel } from './nestbridge-log-level';\n\nexport const LOG_LEVEL_RANKS: Record<NestBridgeLogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n};\n","import type { GlobalPrefix } from '@nestbridge/core';\nimport type { NestBridgeOptions } from './nestbridge-options';\n\nexport const resolveGlobalPrefixOption = (\n option: NestBridgeOptions['globalPrefix'],\n): GlobalPrefix | false | undefined => {\n if (option === undefined || option === false) {\n return option;\n }\n\n if (typeof option === 'string') {\n return { prefix: option, exclude: [] };\n }\n\n return {\n prefix: option.prefix,\n exclude: (option.exclude ?? []).map((entry) =>\n typeof entry === 'string' ? { path: entry } : entry,\n ),\n };\n};\n","import type { UriVersioning } from '@nestbridge/core';\nimport type { NestBridgeOptions } from './nestbridge-options';\n\nconst DEFAULT_VERSION_PREFIX = 'v';\n\nexport const resolveVersioningOption = (\n option: NestBridgeOptions['versioning'],\n): UriVersioning | false | undefined => {\n if (option === undefined || option === false) {\n return option;\n }\n\n return {\n prefix: option.prefix ?? DEFAULT_VERSION_PREFIX,\n defaultVersion: option.defaultVersion,\n };\n};\n","import type { NestBridgeOptions } from './nestbridge-options';\nimport { resolveGlobalPrefixOption } from './resolve-global-prefix-option';\nimport { resolveVersioningOption } from './resolve-versioning-option';\nimport type { ResolvedNestBridgeOptions } from './resolved-nestbridge-options';\n\nconst toArray = (value: string | string[] | undefined) => {\n if (value === undefined) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n};\n\nexport const resolveNestBridgeEntry = (options: NestBridgeOptions): ResolvedNestBridgeOptions => ({\n name: options.name,\n controllers: toArray(options.controllers),\n resolvers: toArray(options.resolvers),\n messagePatterns: options.messagePatterns ?? false,\n baseURL: options.baseURL,\n bootstrap: options.bootstrap,\n globalPrefix: resolveGlobalPrefixOption(options.globalPrefix),\n versioning: resolveVersioningOption(options.versioning),\n debug: options.debug ?? false,\n logLevel: options.logLevel,\n outputDir: options.outputDir,\n root: options.root,\n});\n","import { LOG_LEVEL_RANKS } from './log-level-ranks';\nimport type { ResolvedNestBridgeOptions } from './resolved-nestbridge-options';\n\nconst NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/;\n\nexport const validateNestBridgeEntries = (entries: readonly ResolvedNestBridgeOptions[]): void => {\n if (entries.length === 0) {\n throw new Error('[nestbridge] Pass at least one app to the plugin options.');\n }\n\n const seenNames = new Set<string>();\n\n entries.forEach((entry, index) => {\n if (entry.logLevel !== undefined && !Object.hasOwn(LOG_LEVEL_RANKS, entry.logLevel)) {\n throw new Error(\n `[nestbridge] Invalid logLevel \"${entry.logLevel}\". Use one of: ${Object.keys(LOG_LEVEL_RANKS).join(', ')}.`,\n );\n }\n\n if (entry.messagePatterns && entry.name === undefined) {\n throw new Error(\n `[nestbridge] App #${index + 1} sets \\`messagePatterns\\` and needs a \\`name\\`, the service its message client is looked up by.`,\n );\n }\n\n if (entry.name === undefined) {\n if (entries.length > 1) {\n throw new Error(\n `[nestbridge] App #${index + 1} needs a \\`name\\` because several apps are configured.`,\n );\n }\n\n return;\n }\n\n if (!NAME_PATTERN.test(entry.name)) {\n throw new Error(\n `[nestbridge] Invalid app name \"${entry.name}\". Start with a letter and use only letters, digits, \"-\" and \"_\".`,\n );\n }\n\n if (seenNames.has(entry.name)) {\n throw new Error(\n `[nestbridge] Duplicate app name \"${entry.name}\". Each app needs its own name.`,\n );\n }\n\n seenNames.add(entry.name);\n });\n};\n","import type { NestBridgePluginOptions } from './nestbridge-plugin-options';\nimport { resolveNestBridgeEntry } from './resolve-nestbridge-entry';\nimport type { ResolvedNestBridgeOptions } from './resolved-nestbridge-options';\nimport { validateNestBridgeEntries } from './validate-nestbridge-entries';\n\nexport const resolveNestBridgeOptions = (\n options: NestBridgePluginOptions,\n): ResolvedNestBridgeOptions[] => {\n const entries = (Array.isArray(options) ? options : [options]).map(resolveNestBridgeEntry);\n\n validateNestBridgeEntries(entries);\n\n return entries;\n};\n","import type { BundlerLogger } from './bundler-logger';\n\nexport const consoleLogger: BundlerLogger = {\n info: (message) => console.log(message),\n warn: (message) => console.warn(message),\n};\n","import { LOG_LEVEL_RANKS, type NestBridgeLogLevel } from '../options';\nimport type { BundlerLogger } from './bundler-logger';\n\nexport const createLevelLogger = (level: NestBridgeLogLevel | undefined, logger: BundlerLogger) => {\n const rank = LOG_LEVEL_RANKS[level ?? 'info'];\n\n return {\n info: (message) => {\n if (rank >= LOG_LEVEL_RANKS.info) {\n logger.info(message);\n }\n },\n warn: (message) => {\n if (rank >= LOG_LEVEL_RANKS.warn) {\n logger.warn(message);\n }\n },\n } satisfies BundlerLogger;\n};\n","import type { NestBridgeApp } from './nestbridge-app';\n\nconst describeOwner = (app: NestBridgeApp) =>\n app.options.name === undefined ? 'the app' : `\"${app.options.name}\"`;\n\nexport const findOverlappingFiles = (apps: readonly NestBridgeApp[]) => {\n const ownersByFile = new Map<string, NestBridgeApp[]>();\n\n for (const app of apps) {\n for (const filePath of app.ownedFiles()) {\n ownersByFile.set(filePath, [...(ownersByFile.get(filePath) ?? []), app]);\n }\n }\n\n return [...ownersByFile.entries()]\n .filter(([, owners]) => owners.length > 1)\n .map(\n ([filePath, owners]) =>\n `${filePath} is matched by several apps (${owners.map(describeOwner).join(', ')}). ` +\n 'Narrow their controllers and resolvers globs so each file belongs to one app.',\n );\n};\n","import { LOG_LEVEL_RANKS, type NestBridgeLogLevel } from '../options';\n\nexport const mostVerboseLogLevel = (levels: readonly (NestBridgeLogLevel | undefined)[]) =>\n levels.reduce<NestBridgeLogLevel | undefined>((mostVerbose, level) => {\n if (mostVerbose === undefined || level === undefined) {\n return undefined;\n }\n\n return LOG_LEVEL_RANKS[level] > LOG_LEVEL_RANKS[mostVerbose] ? level : mostVerbose;\n }, 'silent');\n","import {\n closeSync,\n existsSync,\n openSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\n\nexport const LOCK_FILE_SUFFIX = '.lock';\n\nconst DEFAULT_LOCK_TIMEOUT_MS = 5_000;\nconst DEFAULT_STALE_LOCK_MS = 10_000;\nconst LOCK_RETRY_INTERVAL_MS = 10;\n\nexport interface WriteFileLockedOptions {\n timeoutMs?: number;\n staleAfterMs?: number;\n}\n\nconst sleep = (milliseconds: number) => {\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);\n};\n\nconst isErrnoException = (error: unknown): error is NodeJS.ErrnoException =>\n error instanceof Error && 'code' in error;\n\nconst isStale = (lockPath: string, staleAfterMs: number) => {\n try {\n return Date.now() - statSync(lockPath).mtimeMs > staleAfterMs;\n } catch (error) {\n if (isErrnoException(error) && error.code === 'ENOENT') {\n return true;\n }\n\n throw error;\n }\n};\n\nconst acquireLock = (lockPath: string, options: Required<WriteFileLockedOptions>) => {\n const deadline = Date.now() + options.timeoutMs;\n\n while (true) {\n try {\n const descriptor = openSync(lockPath, 'wx');\n\n return {\n [Symbol.dispose]: () => {\n closeSync(descriptor);\n rmSync(lockPath, { force: true });\n },\n };\n } catch (error) {\n if (!isErrnoException(error) || error.code !== 'EEXIST') {\n throw error;\n }\n }\n\n if (isStale(lockPath, options.staleAfterMs)) {\n rmSync(lockPath, { force: true });\n continue;\n }\n\n if (Date.now() >= deadline) {\n throw new Error(\n `[NestBridge] Timed out after ${options.timeoutMs}ms waiting for ${lockPath}. Delete it if no other NestBridge process is running.`,\n );\n }\n\n sleep(LOCK_RETRY_INTERVAL_MS);\n }\n};\n\nconst hasContent = (filePath: string, content: string) =>\n existsSync(filePath) && readFileSync(filePath, 'utf-8') === content;\n\nexport const lockFile = (filePath: string, options: WriteFileLockedOptions = {}) =>\n acquireLock(`${filePath}${LOCK_FILE_SUFFIX}`, {\n timeoutMs: options.timeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS,\n staleAfterMs: options.staleAfterMs ?? DEFAULT_STALE_LOCK_MS,\n });\n\n/**\n * Swaps the content in through a rename. Callers must hold the file's lock.\n */\nexport const writeFileAtomically = (filePath: string, content: string) => {\n const temporaryPath = `${filePath}.${process.pid}.tmp`;\n\n try {\n writeFileSync(temporaryPath, content, 'utf-8');\n renameSync(temporaryPath, filePath);\n } finally {\n rmSync(temporaryPath, { force: true });\n }\n};\n\nexport const writeFileLocked = (\n filePath: string,\n content: string,\n options: WriteFileLockedOptions = {},\n) => {\n if (hasContent(filePath, content)) {\n return;\n }\n\n using _lock = lockFile(filePath, options);\n\n if (hasContent(filePath, content)) {\n return;\n }\n\n writeFileAtomically(filePath, content);\n};\n","import { existsSync, mkdirSync, readFileSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport type { DeclarationClaim } from './declaration-claim';\nimport { lockFile, writeFileAtomically } from './write-file-locked';\n\nexport const DECLARATION_CLAIM_FILE_NAME = 'nestbridge-app.json';\n\nconst isDeclarationClaim = (value: unknown): value is DeclarationClaim =>\n typeof value === 'object' &&\n value !== null &&\n 'caller' in value &&\n typeof value.caller === 'string' &&\n 'messagePatterns' in value &&\n typeof value.messagePatterns === 'boolean' &&\n 'bootstrap' in value &&\n (typeof value.bootstrap === 'string' || value.bootstrap === null);\n\nconst readClaim = (claimPath: string) => {\n if (!existsSync(claimPath)) {\n return undefined;\n }\n\n const claim: unknown = JSON.parse(readFileSync(claimPath, 'utf-8'));\n\n if (!isDeclarationClaim(claim)) {\n throw new Error(\n `[NestBridge] ${claimPath} is not a NestBridge declaration claim. Delete it so the next build recreates it.`,\n );\n }\n\n return claim;\n};\n\nconst hasSameOptions = (left: DeclarationClaim, right: DeclarationClaim) =>\n left.messagePatterns === right.messagePatterns && left.bootstrap === right.bootstrap;\n\nconst serializeClaim = (claim: DeclarationClaim) => `${JSON.stringify(claim, null, 2)}\\n`;\n\n/**\n * Records `claim` as the owner of an app's declarations, unless another caller that still exists\n * owns them with options that generate different declarations. That owner's claim is returned, and\n * the caller must not write the declarations.\n */\nexport const claimDeclarations = (claimPath: string, claim: DeclarationClaim) => {\n mkdirSync(dirname(claimPath), { recursive: true });\n using _lock = lockFile(claimPath);\n\n const existing = readClaim(claimPath);\n\n if (existing !== undefined && existing.caller !== claim.caller && existsSync(existing.caller)) {\n return hasSameOptions(existing, claim) ? undefined : existing;\n }\n\n writeFileAtomically(claimPath, serializeClaim(claim));\n return undefined;\n};\n","import { join, relative } from 'node:path';\n\nconst stripLeadingParentSegments = (relativePath: string) => {\n const segments = relativePath.split(/[\\\\/]/);\n const firstOwnedIndex = segments.findIndex((segment) => segment !== '..');\n return segments.slice(firstOwnedIndex === -1 ? segments.length : firstOwnedIndex).join('/');\n};\n\nexport const mirroredPath = (sourceRoot: string, resolvedOutputDir: string, sourcePath: string) =>\n join(resolvedOutputDir, stripLeadingParentSegments(relative(sourceRoot, sourcePath)));\n","import { mirroredPath } from './mirrored-path';\n\nexport const mirroredDeclarationPath = (\n sourceRoot: string,\n resolvedOutputDir: string,\n controllerFilePath: string,\n) => mirroredPath(sourceRoot, resolvedOutputDir, controllerFilePath).replace(/\\.ts$/, '.d.ts');\n","import { mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport {\n type ControllerDefinition,\n generateControllerDeclaration,\n type ResponseWrapperDetection,\n} from '@nestbridge/core';\nimport { mirroredDeclarationPath } from './mirror-declaration-path';\nimport { writeFileLocked } from './write-file-locked';\n\nexport const writeControllerDeclarations = (\n controllers: readonly ControllerDefinition[],\n sourceRoot: string,\n resolvedOutputDir: string,\n responseWrapper?: ResponseWrapperDetection,\n) => {\n for (const controller of controllers) {\n const outputFilePath = mirroredDeclarationPath(\n sourceRoot,\n resolvedOutputDir,\n controller.sourceFile,\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileLocked(\n outputFilePath,\n generateControllerDeclaration(controller, outputFilePath, responseWrapper),\n );\n }\n};\n","import { mkdirSync, rmSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { type ErrorResponseShapeDetection, generateErrorBodyDeclaration } from '@nestbridge/core';\nimport { writeFileLocked } from './write-file-locked';\n\nexport const ERROR_BODY_DECLARATION_FILE_NAME = 'nestbridge-error-body.d.ts';\n\nexport const errorBodyDeclarationPath = (resolvedOutputDir: string) =>\n join(resolvedOutputDir, ERROR_BODY_DECLARATION_FILE_NAME);\n\nexport const writeErrorBodyDeclaration = (\n resolvedOutputDir: string,\n errorResponseShape?: ErrorResponseShapeDetection,\n) => {\n const outputFilePath = errorBodyDeclarationPath(resolvedOutputDir);\n\n if (errorResponseShape === undefined) {\n rmSync(outputFilePath, { force: true });\n return;\n }\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileLocked(\n outputFilePath,\n generateErrorBodyDeclaration(errorResponseShape.errorBodyTypeSource),\n );\n};\n","import { mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport { generateControllerDeclaration, type ResolverDefinition } from '@nestbridge/core';\nimport { mirroredDeclarationPath } from './mirror-declaration-path';\nimport { writeFileLocked } from './write-file-locked';\n\nexport const writeResolverDeclarations = (\n resolvers: readonly ResolverDefinition[],\n sourceRoot: string,\n resolvedOutputDir: string,\n) => {\n for (const resolver of resolvers) {\n const outputFilePath = mirroredDeclarationPath(\n sourceRoot,\n resolvedOutputDir,\n resolver.sourceFile,\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileLocked(outputFilePath, generateControllerDeclaration(resolver, outputFilePath));\n }\n};\n","import { globSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nexport const discoverFiles = (\n patterns: readonly string[],\n root: string,\n exclude?: (filePath: string) => boolean,\n) => {\n const matches = globSync([...patterns], { cwd: root, exclude });\n return [...new Set(matches.map((match) => resolve(root, match)))].sort();\n};\n","import { resolve, sep } from 'node:path';\nimport { discoverFiles } from './discover-files';\n\nconst BOOTSTRAP_FILE_PATTERN = '**/main.ts';\n\nexport const discoverBootstrapFile = (root: string, resolvedOutputDir: string) => {\n const isExcluded = (filePath: string) => {\n if (filePath.split(/[\\\\/]/).includes('node_modules')) {\n return true;\n }\n\n const resolvedPath = resolve(root, filePath);\n return (\n resolvedPath === resolvedOutputDir || resolvedPath.startsWith(`${resolvedOutputDir}${sep}`)\n );\n };\n\n const matches = discoverFiles([BOOTSTRAP_FILE_PATTERN], root, isExcluded);\n\n return matches.length === 1 ? matches[0] : undefined;\n};\n","import { resolve } from 'node:path';\nimport { discoverBootstrapFile } from './discover-bootstrap-file';\n\nexport const resolveBootstrapFile = (\n root: string,\n resolvedOutputDir: string,\n bootstrap: string | undefined,\n): string | undefined =>\n bootstrap === undefined\n ? discoverBootstrapFile(root, resolvedOutputDir)\n : resolve(root, bootstrap);\n","import { posix } from 'node:path';\n\nconst isWindows = process.platform === 'win32';\n\nexport const normalizePath = (filePath: string) =>\n posix.normalize(isWindows ? filePath.replaceAll('\\\\', '/') : filePath);\n","import {\n type ApplicationRouting,\n analyzeControllers,\n applyApplicationRouting,\n type ControllerAnalysisOptions,\n type ControllerDefinition,\n type NestBridgeDiagnostic,\n} from '@nestbridge/core';\nimport { discoverFiles } from '../discovery';\nimport { normalizePath } from './normalize-path';\n\nexport interface ControllerRegistryRefreshResult {\n controllers: ControllerDefinition[];\n diagnostics: NestBridgeDiagnostic[];\n}\n\nexport interface ControllerRegistry {\n refresh: (routing?: ApplicationRouting) => ControllerRegistryRefreshResult;\n get: (filePath: string) => ControllerDefinition | undefined;\n has: (filePath: string) => boolean;\n all: () => ControllerDefinition[];\n}\n\nexport const createControllerRegistry = (\n patterns: readonly string[],\n root: string,\n analysisOptions: ControllerAnalysisOptions,\n): ControllerRegistry => {\n const controllersByFile = new Map<string, ControllerDefinition>();\n\n const refresh = (routing: ApplicationRouting = {}) => {\n controllersByFile.clear();\n\n const files = discoverFiles(patterns, root);\n const { controllers: analyzed, diagnostics } = analyzeControllers(files, analysisOptions);\n const controllers = applyApplicationRouting(analyzed, routing);\n\n for (const controller of controllers) {\n controllersByFile.set(normalizePath(controller.sourceFile), controller);\n }\n\n return { controllers, diagnostics };\n };\n\n return {\n refresh,\n get: (filePath) => controllersByFile.get(filePath),\n has: (filePath) => controllersByFile.has(filePath),\n all: () => [...controllersByFile.values()],\n };\n};\n","import type { DeclarationClaim } from '../declarations';\n\nconst describeDifferences = (owner: DeclarationClaim, claim: DeclarationClaim) => {\n const differences: string[] = [];\n\n if (owner.messagePatterns !== claim.messagePatterns) {\n differences.push(\n `messagePatterns ${owner.messagePatterns} there, ${claim.messagePatterns} here`,\n );\n }\n\n if (owner.bootstrap !== claim.bootstrap) {\n differences.push(\n `bootstrap ${owner.bootstrap ?? 'none'} there, ${claim.bootstrap ?? 'none'} here`,\n );\n }\n\n return differences.join('; ');\n};\n\nexport const describeDeclarationConflict = (\n appName: string | undefined,\n declarationDir: string,\n owner: DeclarationClaim,\n claim: DeclarationClaim,\n) => {\n const app = appName === undefined ? 'The app' : `App \"${appName}\"`;\n const remedy = appName === undefined ? 'give this app a `name`' : 'give this app another `name`';\n\n return (\n `${app} shares its declarations in ${declarationDir} with the build of ${owner.caller}, ` +\n `which configures it differently (${describeDifferences(owner, claim)}). ` +\n `Builds that use the same app name for the same server must configure it the same way: ` +\n `${remedy}, or match the other build's options. Declarations were not written.`\n );\n};\n","import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nconst WORKSPACE_MARKER_FILES = ['nx.json', 'pnpm-workspace.yaml', 'turbo.json', 'lerna.json'];\n\nconst declaresWorkspaces = (directory: string) => {\n const manifestPath = join(directory, 'package.json');\n\n if (!existsSync(manifestPath)) {\n return false;\n }\n\n const manifest: unknown = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n\n return typeof manifest === 'object' && manifest !== null && 'workspaces' in manifest;\n};\n\nconst isWorkspaceRoot = (directory: string) =>\n WORKSPACE_MARKER_FILES.some((file) => existsSync(join(directory, file))) ||\n declaresWorkspaces(directory);\n\nexport const findWorkspaceRoot = (startDirectory: string) => {\n let directory = startDirectory;\n\n while (true) {\n if (isWorkspaceRoot(directory)) {\n return directory;\n }\n\n const parent = dirname(directory);\n\n if (parent === directory) {\n return undefined;\n }\n\n directory = parent;\n }\n};\n","import { join, relative, resolve } from 'node:path';\nimport { findWorkspaceRoot } from '../discovery/find-workspace-root';\n\nexport const DEFAULT_OUTPUT_DIR = '.nestbridge';\n\ninterface OutputLocationInput {\n outputDir: string | undefined;\n name: string | undefined;\n root: string;\n bundlerRoot: string | undefined;\n}\n\nexport interface OutputLocation {\n outputDir: string;\n declarationDir: string;\n errorBodyDir: string;\n mirrorRoot: string;\n}\n\nconst withAppName = (outputDir: string, name: string | undefined) =>\n name === undefined ? outputDir : join(outputDir, name);\n\nexport const resolveOutputLocation = (input: OutputLocationInput): OutputLocation => {\n const projectRoot = input.bundlerRoot ?? input.root;\n\n if (input.outputDir !== undefined) {\n const outputDir = resolve(projectRoot, input.outputDir);\n const declarationDir = withAppName(outputDir, input.name);\n\n return { outputDir, declarationDir, errorBodyDir: declarationDir, mirrorRoot: input.root };\n }\n\n const workspaceRoot = findWorkspaceRoot(projectRoot);\n\n if (workspaceRoot === undefined) {\n const outputDir = resolve(projectRoot, DEFAULT_OUTPUT_DIR);\n const declarationDir = withAppName(outputDir, input.name);\n\n return { outputDir, declarationDir, errorBodyDir: declarationDir, mirrorRoot: input.root };\n }\n\n const outputDir = resolve(workspaceRoot, DEFAULT_OUTPUT_DIR);\n\n return {\n outputDir,\n declarationDir: withAppName(outputDir, input.name),\n errorBodyDir: withAppName(join(outputDir, relative(workspaceRoot, projectRoot)), input.name),\n mirrorRoot: workspaceRoot,\n };\n};\n","import type { BootstrapDetection } from '@nestbridge/core';\n\nexport const resolveRoutingOption = <T>(\n explicit: T | false | undefined,\n bootstrapFile: string | undefined,\n detect: (bootstrapFilePath: string) => BootstrapDetection<T>,\n): BootstrapDetection<T> => {\n if (explicit === false) {\n return { value: undefined, diagnostics: [] };\n }\n\n if (explicit !== undefined) {\n return { value: explicit, diagnostics: [] };\n }\n\n return bootstrapFile === undefined\n ? { value: undefined, diagnostics: [] }\n : detect(bootstrapFile);\n};\n","import {\n analyzeResolvers,\n type NestBridgeDiagnostic,\n type ResolverDefinition,\n} from '@nestbridge/core';\nimport { discoverFiles } from '../discovery';\nimport { normalizePath } from './normalize-path';\n\nexport interface ResolverRegistryRefreshResult {\n resolvers: ResolverDefinition[];\n diagnostics: NestBridgeDiagnostic[];\n}\n\nexport interface ResolverRegistry {\n refresh: () => ResolverRegistryRefreshResult;\n get: (filePath: string) => ResolverDefinition | undefined;\n has: (filePath: string) => boolean;\n all: () => ResolverDefinition[];\n}\n\nexport const createResolverRegistry = (\n patterns: readonly string[],\n root: string,\n): ResolverRegistry => {\n const resolversByFile = new Map<string, ResolverDefinition>();\n\n const refresh = () => {\n resolversByFile.clear();\n\n const files = discoverFiles(patterns, root);\n const { resolvers, diagnostics } = analyzeResolvers(files);\n\n for (const resolver of resolvers) {\n resolversByFile.set(normalizePath(resolver.sourceFile), resolver);\n }\n\n return { resolvers, diagnostics };\n };\n\n return {\n refresh,\n get: (filePath) => resolversByFile.get(filePath),\n has: (filePath) => resolversByFile.has(filePath),\n all: () => [...resolversByFile.values()],\n };\n};\n","import { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n type ApplicationRouting,\n detectErrorResponseShape,\n detectGlobalPrefix,\n detectResponseWrapper,\n detectVersioning,\n} from '@nestbridge/core';\nimport { generateControllerModule, generateResolverModule } from '../codegen';\nimport {\n claimDeclarations,\n DECLARATION_CLAIM_FILE_NAME,\n type DeclarationClaim,\n mirroredPath,\n writeControllerDeclarations,\n writeErrorBodyDeclaration,\n writeResolverDeclarations,\n} from '../declarations';\nimport { discoverFiles, resolveBootstrapFile } from '../discovery';\nimport type { ResolvedNestBridgeOptions } from '../options';\nimport { createControllerRegistry } from './controller-registry';\nimport { describeDeclarationConflict } from './describe-declaration-conflict';\nimport type { NestBridgeAppAnalysis } from './nestbridge-app-analysis';\nimport type { NestBridgeAppLocation } from './nestbridge-app-location';\nimport { normalizePath } from './normalize-path';\nimport { resolveOutputLocation } from './resolve-output-location';\nimport { resolveRoutingOption } from './resolve-routing-option';\nimport { createResolverRegistry } from './resolver-registry';\n\nexport interface NestBridgeApp {\n options: ResolvedNestBridgeOptions;\n analyze: () => NestBridgeAppAnalysis;\n transform: (filePath: string) => string | undefined;\n ownedFiles: () => string[];\n isAffectedBy: (changedFile: string) => boolean;\n}\n\nexport const createNestBridgeApp = (\n options: ResolvedNestBridgeOptions,\n location: NestBridgeAppLocation,\n): NestBridgeApp => {\n const root =\n options.root === undefined ? location.baseRoot : resolve(location.baseRoot, options.root);\n const output = resolveOutputLocation({\n outputDir: options.outputDir,\n name: options.name,\n root,\n bundlerRoot: location.bundlerRoot,\n });\n const controllerRegistry = createControllerRegistry(options.controllers, root, {\n messagePatterns: options.messagePatterns,\n });\n const resolverRegistry = createResolverRegistry(options.resolvers, root);\n const claimPath = mirroredPath(\n output.mirrorRoot,\n output.declarationDir,\n join(root, DECLARATION_CLAIM_FILE_NAME),\n );\n const caller = normalizePath(location.bundlerRoot ?? location.baseRoot);\n let bootstrapFilePath: string | undefined;\n\n const describeApp = () => (options.name === undefined ? 'the app' : `app \"${options.name}\"`);\n\n const locateBootstrapFile = (problems: string[]) => {\n const bootstrapFile = resolveBootstrapFile(root, output.outputDir, options.bootstrap);\n\n if (\n bootstrapFile !== undefined &&\n options.bootstrap !== undefined &&\n !existsSync(bootstrapFile)\n ) {\n problems.push(`Bootstrap file of ${describeApp()} not found: ${bootstrapFile}`);\n return undefined;\n }\n\n return bootstrapFile;\n };\n\n const matchesPatterns = (patterns: readonly string[], filePath: string) =>\n discoverFiles(patterns, root).map(normalizePath).includes(filePath);\n\n const isBootstrapFile = (filePath: string) => {\n const bootstrapFile = resolveBootstrapFile(root, output.outputDir, options.bootstrap);\n return bootstrapFile !== undefined && normalizePath(bootstrapFile) === filePath;\n };\n\n const analyze = (): NestBridgeAppAnalysis => {\n const problems: string[] = [];\n const bootstrapFile = locateBootstrapFile(problems);\n bootstrapFilePath = bootstrapFile === undefined ? undefined : normalizePath(bootstrapFile);\n\n const globalPrefix = resolveRoutingOption(\n options.globalPrefix,\n bootstrapFile,\n detectGlobalPrefix,\n );\n const versioning = resolveRoutingOption(options.versioning, bootstrapFile, detectVersioning);\n const routing: ApplicationRouting = {\n globalPrefix: globalPrefix.value,\n versioning: versioning.value,\n };\n const responseWrapper =\n bootstrapFile === undefined ? undefined : detectResponseWrapper(bootstrapFile);\n const errorResponseShape =\n bootstrapFile === undefined ? undefined : detectErrorResponseShape(bootstrapFile);\n\n const { controllers, diagnostics: controllerDiagnostics } = controllerRegistry.refresh(routing);\n const { resolvers, diagnostics: resolverDiagnostics } = resolverRegistry.refresh();\n\n const claim: DeclarationClaim = {\n caller,\n messagePatterns: options.messagePatterns,\n bootstrap: bootstrapFilePath ?? null,\n };\n const owner = claimDeclarations(claimPath, claim);\n\n if (owner === undefined) {\n writeControllerDeclarations(\n controllers,\n output.mirrorRoot,\n output.declarationDir,\n responseWrapper,\n );\n writeResolverDeclarations(resolvers, output.mirrorRoot, output.declarationDir);\n writeErrorBodyDeclaration(output.errorBodyDir, errorResponseShape);\n } else {\n problems.push(describeDeclarationConflict(options.name, output.declarationDir, owner, claim));\n }\n\n return {\n controllerCount: controllers.length,\n resolverCount: resolvers.length,\n diagnostics: [\n ...globalPrefix.diagnostics,\n ...versioning.diagnostics,\n ...controllerDiagnostics,\n ...resolverDiagnostics,\n ],\n problems,\n };\n };\n\n const transform = (filePath: string) => {\n const controller = controllerRegistry.get(filePath);\n if (controller !== undefined) {\n return generateControllerModule(controller, options.name);\n }\n\n const resolver = resolverRegistry.get(filePath);\n if (resolver !== undefined) {\n return generateResolverModule(resolver, options.name);\n }\n\n return undefined;\n };\n\n const ownedFiles = () => [\n ...controllerRegistry.all().map((controller) => normalizePath(controller.sourceFile)),\n ...resolverRegistry.all().map((resolver) => normalizePath(resolver.sourceFile)),\n ];\n\n const isAffectedBy = (changedFile: string) =>\n controllerRegistry.has(changedFile) ||\n resolverRegistry.has(changedFile) ||\n changedFile === bootstrapFilePath ||\n matchesPatterns(options.controllers, changedFile) ||\n matchesPatterns(options.resolvers, changedFile) ||\n isBootstrapFile(changedFile);\n\n return { options, analyze, transform, ownedFiles, isAffectedBy };\n};\n","import type { BundlerLogger } from './bundler-logger';\n\nexport const reportMessages = (\n messages: readonly string[],\n watchMode: boolean | undefined,\n logger: Pick<BundlerLogger, 'warn'>,\n) => {\n for (const message of messages) {\n if (watchMode === false) {\n throw new Error(message);\n }\n\n logger.warn(message);\n }\n};\n","import { formatDiagnostic, type NestBridgeDiagnostic } from '@nestbridge/core';\nimport type { BundlerLogger } from './bundler-logger';\nimport { reportMessages } from './report-messages';\n\nexport const reportDiagnostics = (\n diagnostics: readonly NestBridgeDiagnostic[],\n watchMode: boolean | undefined,\n logger: Pick<BundlerLogger, 'warn'>,\n) => {\n reportMessages(diagnostics.map(formatDiagnostic), watchMode, logger);\n};\n","import { createUnplugin, type UnpluginInstance, type UnpluginOptions } from 'unplugin';\nimport { generateConfigModule } from '../codegen';\nimport { type NestBridgePluginOptions, resolveNestBridgeOptions } from '../options';\nimport { CONFIG_VIRTUAL_MODULE_ID, RESOLVED_CONFIG_VIRTUAL_MODULE_ID } from '../virtual-modules';\nimport type { BundlerLogger } from './bundler-logger';\nimport { consoleLogger } from './console-logger';\nimport { createLevelLogger } from './create-level-logger';\nimport { findOverlappingFiles } from './find-overlapping-files';\nimport { mostVerboseLogLevel } from './most-verbose-log-level';\nimport { createNestBridgeApp, type NestBridgeApp } from './nestbridge-app';\nimport { normalizePath } from './normalize-path';\nimport { reportDiagnostics } from './report-diagnostics';\nimport { reportMessages } from './report-messages';\n\nexport const nestBridgeUnplugin: UnpluginInstance<NestBridgePluginOptions, false> = createUnplugin<\n NestBridgePluginOptions,\n false\n>((options, meta) => {\n const entries = resolveNestBridgeOptions(options);\n\n let baseRoot = process.cwd();\n let bundlerRoot: string | undefined;\n let apps: NestBridgeApp[] = [];\n let bundlerLogger: BundlerLogger = consoleLogger;\n let readBundlerWatchMode: (() => boolean) | undefined;\n\n const isWatchMode = () => meta.watchMode ?? readBundlerWatchMode?.();\n\n const loggerOf = (app: NestBridgeApp) => createLevelLogger(app.options.logLevel, bundlerLogger);\n\n const log = (app: NestBridgeApp, message: string) => {\n if (app.options.debug) {\n const prefix = app.options.name === undefined ? '' : `${app.options.name}: `;\n loggerOf(app).info(`[nestbridge] ${prefix}${message}`);\n }\n };\n\n const analyzeApps = (targets: readonly NestBridgeApp[]) => {\n const watchMode = isWatchMode();\n\n for (const app of targets) {\n const { controllerCount, resolverCount, diagnostics, problems } = app.analyze();\n\n reportMessages(\n problems.map((problem) => `[nestbridge] ${problem}`),\n watchMode,\n loggerOf(app),\n );\n reportDiagnostics(diagnostics, watchMode, loggerOf(app));\n log(\n app,\n `analyzed ${controllerCount} controller(s), ${resolverCount} resolver(s), ` +\n `${diagnostics.length} diagnostic(s)`,\n );\n }\n\n reportMessages(\n findOverlappingFiles(apps).map((problem) => `[nestbridge] ${problem}`),\n watchMode,\n createLevelLogger(\n mostVerboseLogLevel(apps.map((app) => app.options.logLevel)),\n bundlerLogger,\n ),\n );\n };\n\n return {\n name: 'nestbridge',\n enforce: 'pre',\n\n buildStart() {\n apps = entries.map((entry) => createNestBridgeApp(entry, { baseRoot, bundlerRoot }));\n analyzeApps(apps);\n },\n\n resolveId(source) {\n if (source === CONFIG_VIRTUAL_MODULE_ID) {\n return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;\n }\n\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) {\n return generateConfigModule(entries);\n }\n\n return null;\n },\n\n transform(_code, id) {\n const absolutePath = normalizePath(id);\n\n for (const app of apps) {\n const code = app.transform(absolutePath);\n\n if (code !== undefined) {\n return code;\n }\n }\n\n return null;\n },\n\n watchChange(id) {\n const changedFile = normalizePath(id);\n const affectedApps = apps.filter((app) => app.isAffectedBy(changedFile));\n\n if (affectedApps.length === 0) {\n return;\n }\n\n analyzeApps(affectedApps);\n\n for (const app of affectedApps) {\n log(app, `nestbridge source changed: ${changedFile}`);\n }\n },\n\n vite: {\n configResolved(config) {\n baseRoot = config.root;\n bundlerRoot = config.root;\n bundlerLogger = config.logger;\n\n const watching = config.command === 'serve' || Boolean(config.build.watch);\n readBundlerWatchMode = () => watching;\n },\n },\n\n webpack(compiler) {\n bundlerRoot = compiler.options.context ?? bundlerRoot;\n bundlerLogger = compiler.getInfrastructureLogger('nestbridge');\n readBundlerWatchMode = () => compiler.watchMode;\n },\n } satisfies UnpluginOptions;\n});\n","{\n \"name\": \"@nestbridge/unplugin\",\n \"version\": \"2.6.1\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/MDReal32/nestbridge.git\",\n \"directory\": \"packages/unplugin\"\n },\n \"main\": \"./build/nestbridge.unplugin.js\",\n \"types\": \"./build/nestbridge.unplugin.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./build/nestbridge.unplugin.d.ts\",\n \"import\": \"./build/nestbridge.unplugin.js\"\n }\n },\n \"files\": [\n \"build\"\n ],\n \"scripts\": {\n \"build\": \"vite build\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"lint\": \"biome check .\"\n },\n \"dependencies\": {\n \"@nestbridge/core\": \"workspace:*\",\n \"unplugin\": \"^3.3.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.4.1\",\n \"rolldown-plugin-dts\": \"^0.28.5\",\n \"typescript\": \"^7.0.2\",\n \"vite\": \"^8.2.2\",\n \"vitest\": \"^5.0.0\"\n }\n}\n","import { version } from '../package.json';\n\nexport const VERSION: string = version;\n"],"mappings":";;;;;AAEA,IAAM,4BAA4B,UAAqC;CACrE,IAAI,MAAM,YAAY,KAAA,GACpB;CAGF,IAAI,MAAM,SAAS,KAAA,GACjB,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QAAQ,UAAU;GAChB,cAAc,SAAS,QAAQ,WAAW;GAC1C,gBAAgB,SAAS,wBAAwB,YAAY;GAC7D,6BAA6B,SAAS;EACxC;CACF;AACF,CAAC;;;AEvID,IAAa,UAAkB"}
1
+ {"version":3,"file":"nestbridge.unplugin.js","names":[],"sources":["../src/codegen/generate-config-module.ts","../src/virtual-modules/config-virtual-id.ts","../src/codegen/merge-named-parameters-expression.ts","../src/codegen/generate-body-expression.ts","../src/codegen/generate-headers-expression.ts","../src/codegen/message-runtime-function.ts","../src/codegen/generate-message-method.ts","../src/codegen/generate-parameter-list.ts","../src/codegen/generate-path-expression.ts","../src/codegen/generate-query-expression.ts","../src/codegen/generate-controller-module.ts","../src/codegen/generate-graphql-document.ts","../src/codegen/generate-resolver-argument-list.ts","../src/codegen/generate-resolver-module.ts","../src/options/log-level-ranks.ts","../src/options/resolve-global-prefix-option.ts","../src/options/resolve-versioning-option.ts","../src/options/resolve-nestbridge-entry.ts","../src/options/validate-nestbridge-entries.ts","../src/options/resolve-nestbridge-options.ts","../src/plugin/console-logger.ts","../src/plugin/create-level-logger.ts","../src/plugin/find-overlapping-files.ts","../src/plugin/most-verbose-log-level.ts","../src/declarations/mirrored-path.ts","../src/declarations/mirror-declaration-path.ts","../src/declarations/write-file-locked.ts","../src/declarations/write-controller-declarations.ts","../src/declarations/write-error-body-declaration.ts","../src/declarations/write-interceptors-declaration.ts","../src/declarations/write-resolver-declarations.ts","../src/discovery/discover-files.ts","../src/discovery/discover-bootstrap-file.ts","../src/discovery/resolve-bootstrap-file.ts","../src/plugin/normalize-path.ts","../src/plugin/controller-registry.ts","../src/discovery/find-workspace-root.ts","../src/discovery/read-package-name.ts","../src/plugin/resolve-output-location.ts","../src/plugin/resolve-routing-option.ts","../src/plugin/resolver-registry.ts","../src/plugin/nestbridge-app.ts","../src/plugin/report-messages.ts","../src/plugin/report-diagnostics.ts","../src/plugin/nestbridge-unplugin-factory.ts","../package.json","../src/version.ts"],"sourcesContent":["import type { ResolvedNestBridgeOptions } from '../options';\n\nconst generateBaseURLStatement = (entry: ResolvedNestBridgeOptions) => {\n if (entry.baseURL === undefined) {\n return undefined;\n }\n\n if (entry.name === undefined) {\n return `setNestBridgeBaseURL(${JSON.stringify(entry.baseURL)});`;\n }\n\n return `setNestBridgeServiceBaseURL(${JSON.stringify(entry.name)}, ${JSON.stringify(entry.baseURL)});`;\n};\n\nexport const generateConfigModule = (entries: readonly ResolvedNestBridgeOptions[]) => {\n const statements = entries\n .map(generateBaseURLStatement)\n .filter((statement) => statement !== undefined);\n\n if (statements.length === 0) {\n return '';\n }\n\n const importedNames = ['setNestBridgeBaseURL', 'setNestBridgeServiceBaseURL'].filter((name) =>\n statements.some((statement) => statement.startsWith(`${name}(`)),\n );\n\n return [`import { ${importedNames.join(', ')} } from 'nestbridge';`, '', ...statements, ''].join(\n '\\n',\n );\n};\n","/**\n * Must not contain a colon: webpack treats any `letter+:` prefix as a URL\n * scheme and routes the request past its filesystem resolver entirely,\n * bypassing the resolveId hook this virtual module relies on.\n */\nexport const CONFIG_VIRTUAL_MODULE_ID = 'virtual-nestbridge-config';\n\nexport const RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\\0${CONFIG_VIRTUAL_MODULE_ID}`;\n","interface NamedParameterLike {\n name?: string;\n parameterName: string;\n}\n\nexport const mergeNamedParametersExpression = (parameters: readonly NamedParameterLike[]) => {\n if (parameters.length === 0) {\n return undefined;\n }\n\n const whole = parameters.find((parameter) => parameter.name === undefined);\n const named = parameters.filter((parameter) => parameter.name !== undefined);\n const namedEntries = named.map(\n (parameter) => `${JSON.stringify(parameter.name)}: ${parameter.parameterName}`,\n );\n\n if (whole === undefined) {\n return `{ ${namedEntries.join(', ')} }`;\n }\n\n if (named.length === 0) {\n return whole.parameterName;\n }\n\n return `{ ...${whole.parameterName}, ${namedEntries.join(', ')} }`;\n};\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\nimport { mergeNamedParametersExpression } from './merge-named-parameters-expression';\n\nexport const generateBodyExpression = (parameters: readonly ControllerParameterDefinition[]) =>\n mergeNamedParametersExpression(parameters.filter((parameter) => parameter.kind === 'body'));\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\n\nexport const generateHeadersExpression = (parameters: readonly ControllerParameterDefinition[]) => {\n const headerParameters = parameters.filter((parameter) => parameter.kind === 'header');\n\n if (headerParameters.length === 0) {\n return undefined;\n }\n\n const entries = headerParameters.map(\n (parameter) => `${JSON.stringify(parameter.name)}: ${parameter.parameterName}`,\n );\n\n return `{ ${entries.join(', ')} }`;\n};\n","import type { MessageKind } from '@nestbridge/core';\n\nexport const messageRuntimeFunctionOf = (kind: MessageKind) =>\n kind === 'event' ? 'emitMessage' : 'sendMessage';\n","import type { MessageHandlerDefinition } from '@nestbridge/core';\nimport { messageRuntimeFunctionOf } from './message-runtime-function';\n\nconst PAYLOAD_PARAMETER = 'payload';\n\nconst EMPTY_PAYLOAD = '{}';\n\nexport const generateMessageMethod = (handler: MessageHandlerDefinition, service: string) => {\n const hasPayload = handler.payloadParameterIndex !== null;\n const messageProperties = [\n `service: ${JSON.stringify(service)}`,\n `pattern: ${JSON.stringify(handler.pattern)}`,\n hasPayload ? PAYLOAD_PARAMETER : `payload: ${EMPTY_PAYLOAD}`,\n ];\n\n return [\n ` ${handler.name}(${hasPayload ? PAYLOAD_PARAMETER : ''}) {`,\n ` return ${messageRuntimeFunctionOf(handler.kind)}({`,\n ...messageProperties.map((property) => ` ${property},`),\n ' });',\n ' }',\n ].join('\\n');\n};\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\n\nexport const generateParameterList = (parameters: readonly ControllerParameterDefinition[]) =>\n [...parameters]\n .sort((a, b) => a.index - b.index)\n .map((parameter) => parameter.parameterName)\n .join(', ');\n","import type { ControllerMethodDefinition } from '@nestbridge/core';\n\nconst PARAM_TOKEN_PATTERN = /:([A-Za-z0-9_]+)/;\nconst IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst generatePropertyAccess = (objectName: string, propertyName: string) =>\n IDENTIFIER_PATTERN.test(propertyName)\n ? `${objectName}.${propertyName}`\n : `${objectName}[${JSON.stringify(propertyName)}]`;\n\nexport const generatePathExpression = (method: ControllerMethodDefinition) => {\n const paramParameters = method.parameters.filter((parameter) => parameter.kind === 'param');\n const wholeParameter = paramParameters.find((parameter) => parameter.name === undefined);\n const parts = method.path.split(PARAM_TOKEN_PATTERN);\n const expressionParts: string[] = [];\n\n const generateTokenExpression = (token: string) => {\n const namedParameter = paramParameters.find((parameter) => parameter.name === token);\n\n if (namedParameter !== undefined) {\n return `encodeURIComponent(${namedParameter.parameterName})`;\n }\n\n if (wholeParameter !== undefined) {\n return `encodeURIComponent(${generatePropertyAccess(wholeParameter.parameterName, token)})`;\n }\n\n return JSON.stringify(`:${token}`);\n };\n\n parts.forEach((part, index) => {\n const isParamToken = index % 2 === 1;\n\n if (isParamToken) {\n expressionParts.push(generateTokenExpression(part));\n return;\n }\n\n if (part.length > 0) {\n expressionParts.push(JSON.stringify(part));\n }\n });\n\n return expressionParts.length > 0 ? expressionParts.join(' + ') : \"''\";\n};\n","import type { ControllerParameterDefinition } from '@nestbridge/core';\nimport { mergeNamedParametersExpression } from './merge-named-parameters-expression';\n\nexport const generateQueryExpression = (parameters: readonly ControllerParameterDefinition[]) =>\n mergeNamedParametersExpression(parameters.filter((parameter) => parameter.kind === 'query'));\n","import type { ControllerDefinition, ControllerMethodDefinition } from '@nestbridge/core';\nimport { CONFIG_VIRTUAL_MODULE_ID } from '../virtual-modules';\nimport { generateBodyExpression } from './generate-body-expression';\nimport { generateHeadersExpression } from './generate-headers-expression';\nimport { generateMessageMethod } from './generate-message-method';\nimport { generateParameterList } from './generate-parameter-list';\nimport { generatePathExpression } from './generate-path-expression';\nimport { generateQueryExpression } from './generate-query-expression';\nimport { messageRuntimeFunctionOf } from './message-runtime-function';\n\nconst generateMethod = (method: ControllerMethodDefinition, service: string | undefined) => {\n const requestProperties = [\n `method: ${JSON.stringify(method.httpMethod)}`,\n `path: ${generatePathExpression(method)}`,\n ];\n\n if (service !== undefined) {\n requestProperties.push(`service: ${JSON.stringify(service)}`);\n }\n\n const queryExpression = generateQueryExpression(method.parameters);\n if (queryExpression !== undefined) {\n requestProperties.push(`query: ${queryExpression}`);\n }\n\n const bodyExpression = generateBodyExpression(method.parameters);\n if (bodyExpression !== undefined) {\n requestProperties.push(`body: ${bodyExpression}`);\n }\n\n const headersExpression = generateHeadersExpression(method.parameters);\n if (headersExpression !== undefined) {\n requestProperties.push(`headers: ${headersExpression}`);\n }\n\n if (method.responseKind === 'stream') {\n requestProperties.push(`responseType: \"blob\"`);\n }\n\n return [\n ` ${method.name}(${generateParameterList(method.parameters)}) {`,\n ' return request({',\n ...requestProperties.map((property) => ` ${property},`),\n ' });',\n ' }',\n ].join('\\n');\n};\n\nconst generateMessageMethods = (controller: ControllerDefinition, service: string | undefined) => {\n if (controller.messageHandlers.length === 0) {\n return [];\n }\n\n if (service === undefined) {\n throw new Error(\n `[nestbridge] ${controller.name} has message handlers, but its app has no \\`name\\` to address the service by.`,\n );\n }\n\n return controller.messageHandlers.map((handler) => generateMessageMethod(handler, service));\n};\n\nexport const generateControllerModule = (controller: ControllerDefinition, service?: string) => {\n const methods = [\n ...controller.methods.map((method) => generateMethod(method, service)),\n ...generateMessageMethods(controller, service),\n ].join('\\n\\n');\n const messageRuntimeFunctions = Array.from(\n new Set(controller.messageHandlers.map((handler) => messageRuntimeFunctionOf(handler.kind))),\n ).sort();\n\n return [\n `import '${CONFIG_VIRTUAL_MODULE_ID}';`,\n \"import { request } from 'nestbridge';\",\n ...(messageRuntimeFunctions.length > 0\n ? [`import { ${messageRuntimeFunctions.join(', ')} } from 'nestbridge/microservices';`]\n : []),\n '',\n `export class ${controller.name} {`,\n ' constructor() {}',\n '',\n methods,\n '}',\n '',\n ].join('\\n');\n};\n","import type { ResolverMethodDefinition, SelectionField } from '@nestbridge/core';\n\nconst capitalize = (value: string) => `${value.charAt(0).toUpperCase()}${value.slice(1)}`;\n\nconst renderSelectionSet = (fields: readonly SelectionField[]): string => {\n const rendered = fields.map((field) =>\n field.children === undefined\n ? field.name\n : `${field.name} ${renderSelectionSet(field.children)}`,\n );\n\n return `{ ${rendered.join(' ')} }`;\n};\n\nexport const generateGraphqlDocument = (method: ResolverMethodDefinition) => {\n const variableDeclarations = method.arguments\n .map((argument) => `$${argument.name}: ${argument.graphqlType}`)\n .join(', ');\n const fieldArguments = method.arguments\n .map((argument) => `${argument.name}: $${argument.name}`)\n .join(', ');\n\n const variablesClause = variableDeclarations.length > 0 ? `(${variableDeclarations})` : '';\n const fieldArgumentsClause = fieldArguments.length > 0 ? `(${fieldArguments})` : '';\n const fieldSelection =\n method.selection.length > 0 ? ` ${renderSelectionSet(method.selection)}` : '';\n\n return `${method.operationKind} ${capitalize(method.name)}${variablesClause} { ${method.operationName}${fieldArgumentsClause}${fieldSelection} }`;\n};\n","import type { ResolverArgumentDefinition } from '@nestbridge/core';\n\nexport const generateResolverArgumentList = (\n resolverArguments: readonly ResolverArgumentDefinition[],\n) =>\n [...resolverArguments]\n .sort((a, b) => a.index - b.index)\n .map((argument) => argument.parameterName)\n .join(', ');\n","import type {\n ResolverArgumentDefinition,\n ResolverDefinition,\n ResolverMethodDefinition,\n} from '@nestbridge/core';\nimport { CONFIG_VIRTUAL_MODULE_ID } from '../virtual-modules';\nimport { generateGraphqlDocument } from './generate-graphql-document';\nimport { generateResolverArgumentList } from './generate-resolver-argument-list';\n\nconst generateVariablesExpression = (resolverArguments: readonly ResolverArgumentDefinition[]) => {\n if (resolverArguments.length === 0) {\n return undefined;\n }\n\n const entries = resolverArguments.map(\n (argument) => `${JSON.stringify(argument.name)}: ${argument.parameterName}`,\n );\n\n return `{ ${entries.join(', ')} }`;\n};\n\nconst generateMethod = (method: ResolverMethodDefinition, service: string | undefined) => {\n const requestProperties = [\n `document: ${JSON.stringify(generateGraphqlDocument(method))}`,\n `field: ${JSON.stringify(method.operationName)}`,\n ];\n\n if (service !== undefined) {\n requestProperties.push(`service: ${JSON.stringify(service)}`);\n }\n\n const variablesExpression = generateVariablesExpression(method.arguments);\n if (variablesExpression !== undefined) {\n requestProperties.push(`variables: ${variablesExpression}`);\n }\n\n return [\n ` ${method.name}(${generateResolverArgumentList(method.arguments)}) {`,\n ' return graphqlRequest({',\n ...requestProperties.map((property) => ` ${property},`),\n ' });',\n ' }',\n ].join('\\n');\n};\n\nexport const generateResolverModule = (resolver: ResolverDefinition, service?: string) => {\n const methods = resolver.methods.map((method) => generateMethod(method, service)).join('\\n\\n');\n\n return [\n `import '${CONFIG_VIRTUAL_MODULE_ID}';`,\n \"import { graphqlRequest } from 'nestbridge';\",\n '',\n `export class ${resolver.name} {`,\n ' constructor() {}',\n '',\n methods,\n '}',\n '',\n ].join('\\n');\n};\n","import type { NestBridgeLogLevel } from './nestbridge-log-level';\n\nexport const LOG_LEVEL_RANKS: Record<NestBridgeLogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n};\n","import type { GlobalPrefix } from '@nestbridge/core';\nimport type { NestBridgeOptions } from './nestbridge-options';\n\nexport const resolveGlobalPrefixOption = (\n option: NestBridgeOptions['globalPrefix'],\n): GlobalPrefix | false | undefined => {\n if (option === undefined || option === false) {\n return option;\n }\n\n if (typeof option === 'string') {\n return { prefix: option, exclude: [] };\n }\n\n return {\n prefix: option.prefix,\n exclude: (option.exclude ?? []).map((entry) =>\n typeof entry === 'string' ? { path: entry } : entry,\n ),\n };\n};\n","import type { UriVersioning } from '@nestbridge/core';\nimport type { NestBridgeOptions } from './nestbridge-options';\n\nconst DEFAULT_VERSION_PREFIX = 'v';\n\nexport const resolveVersioningOption = (\n option: NestBridgeOptions['versioning'],\n): UriVersioning | false | undefined => {\n if (option === undefined || option === false) {\n return option;\n }\n\n return {\n prefix: option.prefix ?? DEFAULT_VERSION_PREFIX,\n defaultVersion: option.defaultVersion,\n };\n};\n","import type { NestBridgeOptions } from './nestbridge-options';\nimport { resolveGlobalPrefixOption } from './resolve-global-prefix-option';\nimport { resolveVersioningOption } from './resolve-versioning-option';\nimport type { ResolvedNestBridgeOptions } from './resolved-nestbridge-options';\n\nconst toArray = (value: string | string[] | undefined) => {\n if (value === undefined) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n};\n\nexport const resolveNestBridgeEntry = (options: NestBridgeOptions): ResolvedNestBridgeOptions => ({\n name: options.name,\n controllers: toArray(options.controllers),\n resolvers: toArray(options.resolvers),\n messagePatterns: options.messagePatterns ?? false,\n baseURL: options.baseURL,\n bootstrap: options.bootstrap,\n globalPrefix: resolveGlobalPrefixOption(options.globalPrefix),\n versioning: resolveVersioningOption(options.versioning),\n debug: options.debug ?? false,\n logLevel: options.logLevel,\n outputDir: options.outputDir,\n root: options.root,\n});\n","import { LOG_LEVEL_RANKS } from './log-level-ranks';\nimport type { ResolvedNestBridgeOptions } from './resolved-nestbridge-options';\n\nconst NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/;\n\nexport const validateNestBridgeEntries = (entries: readonly ResolvedNestBridgeOptions[]): void => {\n if (entries.length === 0) {\n throw new Error('[nestbridge] Pass at least one app to the plugin options.');\n }\n\n const seenNames = new Set<string>();\n\n entries.forEach((entry, index) => {\n if (entry.logLevel !== undefined && !Object.hasOwn(LOG_LEVEL_RANKS, entry.logLevel)) {\n throw new Error(\n `[nestbridge] Invalid logLevel \"${entry.logLevel}\". Use one of: ${Object.keys(LOG_LEVEL_RANKS).join(', ')}.`,\n );\n }\n\n if (entry.messagePatterns && entry.name === undefined) {\n throw new Error(\n `[nestbridge] App #${index + 1} sets \\`messagePatterns\\` and needs a \\`name\\`, the service its message client is looked up by.`,\n );\n }\n\n if (entry.name === undefined) {\n if (entries.length > 1) {\n throw new Error(\n `[nestbridge] App #${index + 1} needs a \\`name\\` because several apps are configured.`,\n );\n }\n\n return;\n }\n\n if (!NAME_PATTERN.test(entry.name)) {\n throw new Error(\n `[nestbridge] Invalid app name \"${entry.name}\". Start with a letter and use only letters, digits, \"-\" and \"_\".`,\n );\n }\n\n if (seenNames.has(entry.name)) {\n throw new Error(\n `[nestbridge] Duplicate app name \"${entry.name}\". Each app needs its own name.`,\n );\n }\n\n seenNames.add(entry.name);\n });\n};\n","import type { NestBridgePluginOptions } from './nestbridge-plugin-options';\nimport { resolveNestBridgeEntry } from './resolve-nestbridge-entry';\nimport type { ResolvedNestBridgeOptions } from './resolved-nestbridge-options';\nimport { validateNestBridgeEntries } from './validate-nestbridge-entries';\n\nexport const resolveNestBridgeOptions = (\n options: NestBridgePluginOptions,\n): ResolvedNestBridgeOptions[] => {\n const entries = (Array.isArray(options) ? options : [options]).map(resolveNestBridgeEntry);\n\n validateNestBridgeEntries(entries);\n\n return entries;\n};\n","import type { BundlerLogger } from './bundler-logger';\n\nexport const consoleLogger: BundlerLogger = {\n info: (message) => console.log(message),\n warn: (message) => console.warn(message),\n};\n","import { LOG_LEVEL_RANKS, type NestBridgeLogLevel } from '../options';\nimport type { BundlerLogger } from './bundler-logger';\n\nexport const createLevelLogger = (level: NestBridgeLogLevel | undefined, logger: BundlerLogger) => {\n const rank = LOG_LEVEL_RANKS[level ?? 'info'];\n\n return {\n info: (message) => {\n if (rank >= LOG_LEVEL_RANKS.info) {\n logger.info(message);\n }\n },\n warn: (message) => {\n if (rank >= LOG_LEVEL_RANKS.warn) {\n logger.warn(message);\n }\n },\n } satisfies BundlerLogger;\n};\n","import type { NestBridgeApp } from './nestbridge-app';\n\nconst describeOwner = (app: NestBridgeApp) =>\n app.options.name === undefined ? 'the app' : `\"${app.options.name}\"`;\n\nexport const findOverlappingFiles = (apps: readonly NestBridgeApp[]) => {\n const ownersByFile = new Map<string, NestBridgeApp[]>();\n\n for (const app of apps) {\n for (const filePath of app.ownedFiles()) {\n ownersByFile.set(filePath, [...(ownersByFile.get(filePath) ?? []), app]);\n }\n }\n\n return [...ownersByFile.entries()]\n .filter(([, owners]) => owners.length > 1)\n .map(\n ([filePath, owners]) =>\n `${filePath} is matched by several apps (${owners.map(describeOwner).join(', ')}). ` +\n 'Narrow their controllers and resolvers globs so each file belongs to one app.',\n );\n};\n","import { LOG_LEVEL_RANKS, type NestBridgeLogLevel } from '../options';\n\nexport const mostVerboseLogLevel = (levels: readonly (NestBridgeLogLevel | undefined)[]) =>\n levels.reduce<NestBridgeLogLevel | undefined>((mostVerbose, level) => {\n if (mostVerbose === undefined || level === undefined) {\n return undefined;\n }\n\n return LOG_LEVEL_RANKS[level] > LOG_LEVEL_RANKS[mostVerbose] ? level : mostVerbose;\n }, 'silent');\n","import { join, relative } from 'node:path';\n\nconst stripLeadingParentSegments = (relativePath: string) => {\n const segments = relativePath.split(/[\\\\/]/);\n const firstOwnedIndex = segments.findIndex((segment) => segment !== '..');\n return segments.slice(firstOwnedIndex === -1 ? segments.length : firstOwnedIndex).join('/');\n};\n\nexport const mirroredPath = (sourceRoot: string, resolvedOutputDir: string, sourcePath: string) =>\n join(resolvedOutputDir, stripLeadingParentSegments(relative(sourceRoot, sourcePath)));\n","import { mirroredPath } from './mirrored-path';\n\nexport const mirroredDeclarationPath = (\n sourceRoot: string,\n resolvedOutputDir: string,\n controllerFilePath: string,\n) => mirroredPath(sourceRoot, resolvedOutputDir, controllerFilePath).replace(/\\.ts$/, '.d.ts');\n","import {\n closeSync,\n existsSync,\n openSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\n\nexport const LOCK_FILE_SUFFIX = '.lock';\n\nconst DEFAULT_LOCK_TIMEOUT_MS = 5_000;\nconst DEFAULT_STALE_LOCK_MS = 10_000;\nconst LOCK_RETRY_INTERVAL_MS = 10;\n\nexport interface WriteFileLockedOptions {\n timeoutMs?: number;\n staleAfterMs?: number;\n}\n\nconst sleep = (milliseconds: number) => {\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);\n};\n\nconst isErrnoException = (error: unknown): error is NodeJS.ErrnoException =>\n error instanceof Error && 'code' in error;\n\nconst isStale = (lockPath: string, staleAfterMs: number) => {\n try {\n return Date.now() - statSync(lockPath).mtimeMs > staleAfterMs;\n } catch (error) {\n if (isErrnoException(error) && error.code === 'ENOENT') {\n return true;\n }\n\n throw error;\n }\n};\n\nconst acquireLock = (lockPath: string, options: Required<WriteFileLockedOptions>) => {\n const deadline = Date.now() + options.timeoutMs;\n\n while (true) {\n try {\n const descriptor = openSync(lockPath, 'wx');\n\n return {\n [Symbol.dispose]: () => {\n closeSync(descriptor);\n rmSync(lockPath, { force: true });\n },\n };\n } catch (error) {\n if (!isErrnoException(error) || error.code !== 'EEXIST') {\n throw error;\n }\n }\n\n if (isStale(lockPath, options.staleAfterMs)) {\n rmSync(lockPath, { force: true });\n continue;\n }\n\n if (Date.now() >= deadline) {\n throw new Error(\n `[NestBridge] Timed out after ${options.timeoutMs}ms waiting for ${lockPath}. Delete it if no other NestBridge process is running.`,\n );\n }\n\n sleep(LOCK_RETRY_INTERVAL_MS);\n }\n};\n\nconst hasContent = (filePath: string, content: string) =>\n existsSync(filePath) && readFileSync(filePath, 'utf-8') === content;\n\nexport const writeFileLocked = (\n filePath: string,\n content: string,\n options: WriteFileLockedOptions = {},\n) => {\n if (hasContent(filePath, content)) {\n return;\n }\n\n const lockPath = `${filePath}${LOCK_FILE_SUFFIX}`;\n using _lock = acquireLock(lockPath, {\n timeoutMs: options.timeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS,\n staleAfterMs: options.staleAfterMs ?? DEFAULT_STALE_LOCK_MS,\n });\n\n if (hasContent(filePath, content)) {\n return;\n }\n\n const temporaryPath = `${filePath}.${process.pid}.tmp`;\n\n try {\n writeFileSync(temporaryPath, content, 'utf-8');\n renameSync(temporaryPath, filePath);\n } finally {\n rmSync(temporaryPath, { force: true });\n }\n};\n","import { mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport { type ControllerDefinition, generateControllerDeclaration } from '@nestbridge/core';\nimport { mirroredDeclarationPath } from './mirror-declaration-path';\nimport { writeFileLocked } from './write-file-locked';\n\nexport const writeControllerDeclarations = (\n controllers: readonly ControllerDefinition[],\n sourceRoot: string,\n resolvedOutputDir: string,\n interceptorsDeclarationFilePath?: string,\n) => {\n for (const controller of controllers) {\n const outputFilePath = mirroredDeclarationPath(\n sourceRoot,\n resolvedOutputDir,\n controller.sourceFile,\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileLocked(\n outputFilePath,\n generateControllerDeclaration(controller, outputFilePath, {\n interceptorsDeclarationFilePath,\n }),\n );\n }\n};\n","import { mkdirSync, rmSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { type ErrorResponseShapeDetection, generateErrorBodyDeclaration } from '@nestbridge/core';\nimport { writeFileLocked } from './write-file-locked';\n\nexport const ERROR_BODY_DECLARATION_FILE_NAME = 'error-body.d.ts';\n\nexport const errorBodyDeclarationPath = (resolvedOutputDir: string) =>\n join(resolvedOutputDir, ERROR_BODY_DECLARATION_FILE_NAME);\n\nexport const writeErrorBodyDeclaration = (\n resolvedOutputDir: string,\n errorResponseShape?: ErrorResponseShapeDetection,\n) => {\n const outputFilePath = errorBodyDeclarationPath(resolvedOutputDir);\n\n if (errorResponseShape === undefined) {\n rmSync(outputFilePath, { force: true });\n return;\n }\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileLocked(\n outputFilePath,\n generateErrorBodyDeclaration(errorResponseShape.errorBodyTypeSource),\n );\n};\n","import { mkdirSync, rmSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { generateInterceptorsDeclaration, type InterceptorDeclaration } from '@nestbridge/core';\nimport { writeFileLocked } from './write-file-locked';\n\nexport const INTERCEPTORS_DECLARATION_FILE_NAME = 'interceptors.d.ts';\n\nexport const interceptorsDeclarationPath = (resolvedOutputDir: string) =>\n join(resolvedOutputDir, INTERCEPTORS_DECLARATION_FILE_NAME);\n\nexport const writeInterceptorsDeclaration = (\n resolvedOutputDir: string,\n declarations: readonly InterceptorDeclaration[],\n) => {\n const outputFilePath = interceptorsDeclarationPath(resolvedOutputDir);\n\n if (declarations.length === 0) {\n rmSync(outputFilePath, { force: true });\n return;\n }\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileLocked(outputFilePath, generateInterceptorsDeclaration(declarations, outputFilePath));\n};\n","import { mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport { generateControllerDeclaration, type ResolverDefinition } from '@nestbridge/core';\nimport { mirroredDeclarationPath } from './mirror-declaration-path';\nimport { writeFileLocked } from './write-file-locked';\n\nexport const writeResolverDeclarations = (\n resolvers: readonly ResolverDefinition[],\n sourceRoot: string,\n resolvedOutputDir: string,\n) => {\n for (const resolver of resolvers) {\n const outputFilePath = mirroredDeclarationPath(\n sourceRoot,\n resolvedOutputDir,\n resolver.sourceFile,\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileLocked(outputFilePath, generateControllerDeclaration(resolver, outputFilePath));\n }\n};\n","import { globSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nexport const discoverFiles = (\n patterns: readonly string[],\n root: string,\n exclude?: (filePath: string) => boolean,\n) => {\n const matches = globSync([...patterns], { cwd: root, exclude });\n return [...new Set(matches.map((match) => resolve(root, match)))].sort();\n};\n","import { resolve, sep } from 'node:path';\nimport { discoverFiles } from './discover-files';\n\nconst BOOTSTRAP_FILE_PATTERN = '**/main.ts';\n\nexport const discoverBootstrapFile = (root: string, resolvedOutputDir: string) => {\n const isExcluded = (filePath: string) => {\n if (filePath.split(/[\\\\/]/).includes('node_modules')) {\n return true;\n }\n\n const resolvedPath = resolve(root, filePath);\n return (\n resolvedPath === resolvedOutputDir || resolvedPath.startsWith(`${resolvedOutputDir}${sep}`)\n );\n };\n\n const matches = discoverFiles([BOOTSTRAP_FILE_PATTERN], root, isExcluded);\n\n return matches.length === 1 ? matches[0] : undefined;\n};\n","import { resolve } from 'node:path';\nimport { discoverBootstrapFile } from './discover-bootstrap-file';\n\nexport const resolveBootstrapFile = (\n root: string,\n resolvedOutputDir: string,\n bootstrap: string | undefined,\n): string | undefined =>\n bootstrap === undefined\n ? discoverBootstrapFile(root, resolvedOutputDir)\n : resolve(root, bootstrap);\n","import { posix } from 'node:path';\n\nconst isWindows = process.platform === 'win32';\n\nexport const normalizePath = (filePath: string) =>\n posix.normalize(isWindows ? filePath.replaceAll('\\\\', '/') : filePath);\n","import {\n type ApplicationRouting,\n analyzeControllers,\n applyApplicationRouting,\n type ControllerAnalysisOptions,\n type ControllerDefinition,\n type InterceptorDeclaration,\n type NestBridgeDiagnostic,\n} from '@nestbridge/core';\nimport { discoverFiles } from '../discovery';\nimport { normalizePath } from './normalize-path';\n\nexport interface ControllerRegistryRefreshResult {\n controllers: ControllerDefinition[];\n diagnostics: NestBridgeDiagnostic[];\n interceptorFiles: string[];\n interceptorDeclarations: InterceptorDeclaration[];\n}\n\nexport interface ControllerRegistry {\n refresh: (\n routing?: ApplicationRouting,\n bootstrapFilePath?: string,\n ) => ControllerRegistryRefreshResult;\n get: (filePath: string) => ControllerDefinition | undefined;\n has: (filePath: string) => boolean;\n all: () => ControllerDefinition[];\n}\n\nexport const createControllerRegistry = (\n patterns: readonly string[],\n root: string,\n analysisOptions: ControllerAnalysisOptions,\n): ControllerRegistry => {\n const controllersByFile = new Map<string, ControllerDefinition>();\n\n const refresh = (routing: ApplicationRouting = {}, bootstrapFilePath?: string) => {\n controllersByFile.clear();\n\n const files = discoverFiles(patterns, root);\n const {\n controllers: analyzed,\n diagnostics,\n interceptorFiles,\n interceptorDeclarations,\n } = analyzeControllers(files, { ...analysisOptions, bootstrapFilePath });\n const controllers = applyApplicationRouting(analyzed, routing);\n\n for (const controller of controllers) {\n controllersByFile.set(normalizePath(controller.sourceFile), controller);\n }\n\n return { controllers, diagnostics, interceptorFiles, interceptorDeclarations };\n };\n\n return {\n refresh,\n get: (filePath) => controllersByFile.get(filePath),\n has: (filePath) => controllersByFile.has(filePath),\n all: () => [...controllersByFile.values()],\n };\n};\n","import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nconst WORKSPACE_MARKER_FILES = ['nx.json', 'pnpm-workspace.yaml', 'turbo.json', 'lerna.json'];\n\nconst declaresWorkspaces = (directory: string) => {\n const manifestPath = join(directory, 'package.json');\n\n if (!existsSync(manifestPath)) {\n return false;\n }\n\n const manifest: unknown = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n\n return typeof manifest === 'object' && manifest !== null && 'workspaces' in manifest;\n};\n\nconst isWorkspaceRoot = (directory: string) =>\n WORKSPACE_MARKER_FILES.some((file) => existsSync(join(directory, file))) ||\n declaresWorkspaces(directory);\n\nexport const findWorkspaceRoot = (startDirectory: string) => {\n let directory = startDirectory;\n\n while (true) {\n if (isWorkspaceRoot(directory)) {\n return directory;\n }\n\n const parent = dirname(directory);\n\n if (parent === directory) {\n return undefined;\n }\n\n directory = parent;\n }\n};\n","import { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nconst missingName = (root: string) =>\n new Error(\n `[NestBridge] ${join(root, 'package.json')} has no \"name\". NestBridge names a server's ` +\n 'declaration folder after its package: point `root` at the server package, or give it a name.',\n );\n\nexport const readPackageName = (root: string) => {\n const manifestPath = join(root, 'package.json');\n\n if (!existsSync(manifestPath)) {\n throw missingName(root);\n }\n\n const manifest: unknown = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n\n if (\n typeof manifest !== 'object' ||\n manifest === null ||\n !('name' in manifest) ||\n typeof manifest.name !== 'string' ||\n manifest.name === ''\n ) {\n throw missingName(root);\n }\n\n return manifest.name;\n};\n","import { join, resolve } from 'node:path';\nimport { findWorkspaceRoot } from '../discovery/find-workspace-root';\nimport { readPackageName } from '../discovery/read-package-name';\n\nexport const DEFAULT_OUTPUT_DIR = '.nestbridge';\n\ninterface OutputLocationInput {\n outputDir: string | undefined;\n root: string;\n bundlerRoot: string | undefined;\n}\n\nexport interface OutputLocation {\n outputDir: string;\n declarationDir: string;\n}\n\nconst resolveOutputDir = (input: OutputLocationInput) => {\n const projectRoot = input.bundlerRoot ?? input.root;\n\n if (input.outputDir !== undefined) {\n return resolve(projectRoot, input.outputDir);\n }\n\n return resolve(findWorkspaceRoot(projectRoot) ?? projectRoot, DEFAULT_OUTPUT_DIR);\n};\n\n/**\n * Every server gets one folder, named after the package at its `root`, so any number of clients of\n * that server share the same declarations.\n */\nexport const resolveOutputLocation = (input: OutputLocationInput): OutputLocation => {\n const outputDir = resolveOutputDir(input);\n\n return { outputDir, declarationDir: join(outputDir, readPackageName(input.root)) };\n};\n","import type { BootstrapDetection } from '@nestbridge/core';\n\nexport const resolveRoutingOption = <T>(\n explicit: T | false | undefined,\n bootstrapFile: string | undefined,\n detect: (bootstrapFilePath: string) => BootstrapDetection<T>,\n): BootstrapDetection<T> => {\n if (explicit === false) {\n return { value: undefined, diagnostics: [] };\n }\n\n if (explicit !== undefined) {\n return { value: explicit, diagnostics: [] };\n }\n\n return bootstrapFile === undefined\n ? { value: undefined, diagnostics: [] }\n : detect(bootstrapFile);\n};\n","import {\n analyzeResolvers,\n type NestBridgeDiagnostic,\n type ResolverDefinition,\n} from '@nestbridge/core';\nimport { discoverFiles } from '../discovery';\nimport { normalizePath } from './normalize-path';\n\nexport interface ResolverRegistryRefreshResult {\n resolvers: ResolverDefinition[];\n diagnostics: NestBridgeDiagnostic[];\n}\n\nexport interface ResolverRegistry {\n refresh: () => ResolverRegistryRefreshResult;\n get: (filePath: string) => ResolverDefinition | undefined;\n has: (filePath: string) => boolean;\n all: () => ResolverDefinition[];\n}\n\nexport const createResolverRegistry = (\n patterns: readonly string[],\n root: string,\n): ResolverRegistry => {\n const resolversByFile = new Map<string, ResolverDefinition>();\n\n const refresh = () => {\n resolversByFile.clear();\n\n const files = discoverFiles(patterns, root);\n const { resolvers, diagnostics } = analyzeResolvers(files);\n\n for (const resolver of resolvers) {\n resolversByFile.set(normalizePath(resolver.sourceFile), resolver);\n }\n\n return { resolvers, diagnostics };\n };\n\n return {\n refresh,\n get: (filePath) => resolversByFile.get(filePath),\n has: (filePath) => resolversByFile.has(filePath),\n all: () => [...resolversByFile.values()],\n };\n};\n","import { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n type ApplicationRouting,\n detectErrorResponseShape,\n detectGlobalPrefix,\n detectVersioning,\n INTERCEPTOR_DECLARATION_FILE_NAMES,\n} from '@nestbridge/core';\nimport { generateControllerModule, generateResolverModule } from '../codegen';\nimport {\n interceptorsDeclarationPath,\n writeControllerDeclarations,\n writeErrorBodyDeclaration,\n writeInterceptorsDeclaration,\n writeResolverDeclarations,\n} from '../declarations';\nimport { discoverFiles, resolveBootstrapFile } from '../discovery';\nimport type { ResolvedNestBridgeOptions } from '../options';\nimport { createControllerRegistry } from './controller-registry';\nimport type { NestBridgeAppAnalysis } from './nestbridge-app-analysis';\nimport type { NestBridgeAppLocation } from './nestbridge-app-location';\nimport { normalizePath } from './normalize-path';\nimport { resolveOutputLocation } from './resolve-output-location';\nimport { resolveRoutingOption } from './resolve-routing-option';\nimport { createResolverRegistry } from './resolver-registry';\n\nexport interface NestBridgeApp {\n options: ResolvedNestBridgeOptions;\n analyze: () => NestBridgeAppAnalysis;\n transform: (filePath: string) => string | undefined;\n ownedFiles: () => string[];\n supportFiles: () => string[];\n isAffectedBy: (changedFile: string) => boolean;\n}\n\nexport const createNestBridgeApp = (\n options: ResolvedNestBridgeOptions,\n location: NestBridgeAppLocation,\n): NestBridgeApp => {\n const root =\n options.root === undefined ? location.baseRoot : resolve(location.baseRoot, options.root);\n const output = resolveOutputLocation({\n outputDir: options.outputDir,\n root,\n bundlerRoot: location.bundlerRoot,\n });\n const interceptorDeclarationFilePaths = INTERCEPTOR_DECLARATION_FILE_NAMES.map((fileName) =>\n normalizePath(join(root, fileName)),\n );\n const controllerRegistry = createControllerRegistry(options.controllers, root, {\n messagePatterns: true,\n interceptorDeclarationFilePaths,\n });\n const resolverRegistry = createResolverRegistry(options.resolvers, root);\n let bootstrapFilePath: string | undefined;\n let interceptorFiles: ReadonlySet<string> = new Set();\n\n const describeApp = () => (options.name === undefined ? 'the app' : `app \"${options.name}\"`);\n\n const locateBootstrapFile = (problems: string[]) => {\n const bootstrapFile = resolveBootstrapFile(root, output.outputDir, options.bootstrap);\n\n if (\n bootstrapFile !== undefined &&\n options.bootstrap !== undefined &&\n !existsSync(bootstrapFile)\n ) {\n problems.push(`Bootstrap file of ${describeApp()} not found: ${bootstrapFile}`);\n return undefined;\n }\n\n return bootstrapFile;\n };\n\n const matchesPatterns = (patterns: readonly string[], filePath: string) =>\n discoverFiles(patterns, root).map(normalizePath).includes(filePath);\n\n const isBootstrapFile = (filePath: string) => {\n const bootstrapFile = resolveBootstrapFile(root, output.outputDir, options.bootstrap);\n return bootstrapFile !== undefined && normalizePath(bootstrapFile) === filePath;\n };\n\n const analyze = (): NestBridgeAppAnalysis => {\n const problems: string[] = [];\n const bootstrapFile = locateBootstrapFile(problems);\n bootstrapFilePath = bootstrapFile === undefined ? undefined : normalizePath(bootstrapFile);\n\n const globalPrefix = resolveRoutingOption(\n options.globalPrefix,\n bootstrapFile,\n detectGlobalPrefix,\n );\n const versioning = resolveRoutingOption(options.versioning, bootstrapFile, detectVersioning);\n const routing: ApplicationRouting = {\n globalPrefix: globalPrefix.value,\n versioning: versioning.value,\n };\n const errorResponseShape =\n bootstrapFile === undefined ? undefined : detectErrorResponseShape(bootstrapFile);\n\n const {\n controllers,\n diagnostics: controllerDiagnostics,\n interceptorFiles: analyzedInterceptorFiles,\n interceptorDeclarations,\n } = controllerRegistry.refresh(routing, bootstrapFile);\n interceptorFiles = new Set(analyzedInterceptorFiles.map(normalizePath));\n const { resolvers, diagnostics: resolverDiagnostics } = resolverRegistry.refresh();\n const reportedControllerDiagnostics = options.messagePatterns\n ? controllerDiagnostics\n : controllerDiagnostics.filter(({ code }) => code !== 'unsupported-message-pattern');\n\n writeControllerDeclarations(\n controllers,\n root,\n output.declarationDir,\n interceptorsDeclarationPath(output.declarationDir),\n );\n writeResolverDeclarations(resolvers, root, output.declarationDir);\n writeErrorBodyDeclaration(output.declarationDir, errorResponseShape);\n writeInterceptorsDeclaration(output.declarationDir, interceptorDeclarations);\n\n return {\n controllerCount: controllers.length,\n resolverCount: resolvers.length,\n diagnostics: [\n ...globalPrefix.diagnostics,\n ...versioning.diagnostics,\n ...reportedControllerDiagnostics,\n ...resolverDiagnostics,\n ],\n problems,\n };\n };\n\n const transform = (filePath: string) => {\n const controller = controllerRegistry.get(filePath);\n if (controller !== undefined) {\n return generateControllerModule(\n options.messagePatterns ? controller : { ...controller, messageHandlers: [] },\n options.name,\n );\n }\n\n const resolver = resolverRegistry.get(filePath);\n if (resolver !== undefined) {\n return generateResolverModule(resolver, options.name);\n }\n\n return undefined;\n };\n\n const ownedFiles = () => [\n ...controllerRegistry.all().map((controller) => normalizePath(controller.sourceFile)),\n ...resolverRegistry.all().map((resolver) => normalizePath(resolver.sourceFile)),\n ];\n\n const supportFiles = () => [\n ...(bootstrapFilePath === undefined ? [] : [bootstrapFilePath]),\n ...interceptorFiles,\n ...interceptorDeclarationFilePaths,\n ];\n\n const isAffectedBy = (changedFile: string) =>\n controllerRegistry.has(changedFile) ||\n resolverRegistry.has(changedFile) ||\n changedFile === bootstrapFilePath ||\n interceptorFiles.has(changedFile) ||\n interceptorDeclarationFilePaths.includes(changedFile) ||\n matchesPatterns(options.controllers, changedFile) ||\n matchesPatterns(options.resolvers, changedFile) ||\n isBootstrapFile(changedFile);\n\n return { options, analyze, transform, ownedFiles, supportFiles, isAffectedBy };\n};\n","import type { BundlerLogger } from './bundler-logger';\n\nexport const reportMessages = (\n messages: readonly string[],\n watchMode: boolean | undefined,\n logger: Pick<BundlerLogger, 'warn'>,\n) => {\n for (const message of messages) {\n if (watchMode === false) {\n throw new Error(message);\n }\n\n logger.warn(message);\n }\n};\n","import { formatDiagnostic, type NestBridgeDiagnostic } from '@nestbridge/core';\nimport type { BundlerLogger } from './bundler-logger';\nimport { reportMessages } from './report-messages';\n\nexport const reportDiagnostics = (\n diagnostics: readonly NestBridgeDiagnostic[],\n watchMode: boolean | undefined,\n logger: Pick<BundlerLogger, 'warn'>,\n) => {\n reportMessages(diagnostics.map(formatDiagnostic), watchMode, logger);\n};\n","import {\n createUnplugin,\n type UnpluginBuildContext,\n type UnpluginInstance,\n type UnpluginOptions,\n} from 'unplugin';\nimport { generateConfigModule } from '../codegen';\nimport { type NestBridgePluginOptions, resolveNestBridgeOptions } from '../options';\nimport { CONFIG_VIRTUAL_MODULE_ID, RESOLVED_CONFIG_VIRTUAL_MODULE_ID } from '../virtual-modules';\nimport type { BundlerLogger } from './bundler-logger';\nimport { consoleLogger } from './console-logger';\nimport { createLevelLogger } from './create-level-logger';\nimport { findOverlappingFiles } from './find-overlapping-files';\nimport { mostVerboseLogLevel } from './most-verbose-log-level';\nimport { createNestBridgeApp, type NestBridgeApp } from './nestbridge-app';\nimport { normalizePath } from './normalize-path';\nimport { reportDiagnostics } from './report-diagnostics';\nimport { reportMessages } from './report-messages';\n\nexport const nestBridgeUnplugin: UnpluginInstance<NestBridgePluginOptions, false> = createUnplugin<\n NestBridgePluginOptions,\n false\n>((options, meta) => {\n const entries = resolveNestBridgeOptions(options);\n\n let baseRoot = process.cwd();\n let bundlerRoot: string | undefined;\n let apps: NestBridgeApp[] = [];\n let bundlerLogger: BundlerLogger = consoleLogger;\n let readBundlerWatchMode: (() => boolean) | undefined;\n\n const isWatchMode = () => meta.watchMode ?? readBundlerWatchMode?.();\n\n const loggerOf = (app: NestBridgeApp) => createLevelLogger(app.options.logLevel, bundlerLogger);\n\n const log = (app: NestBridgeApp, message: string) => {\n if (app.options.debug) {\n const prefix = app.options.name === undefined ? '' : `${app.options.name}: `;\n loggerOf(app).info(`[nestbridge] ${prefix}${message}`);\n }\n };\n\n const analyzeApps = (\n targets: readonly NestBridgeApp[],\n context: Pick<UnpluginBuildContext, 'addWatchFile'>,\n ) => {\n const watchMode = isWatchMode();\n\n for (const app of targets) {\n const { controllerCount, resolverCount, diagnostics, problems } = app.analyze();\n\n for (const supportFile of app.supportFiles()) {\n context.addWatchFile(supportFile);\n }\n\n reportMessages(\n problems.map((problem) => `[nestbridge] ${problem}`),\n watchMode,\n loggerOf(app),\n );\n reportDiagnostics(diagnostics, watchMode, loggerOf(app));\n log(\n app,\n `analyzed ${controllerCount} controller(s), ${resolverCount} resolver(s), ` +\n `${diagnostics.length} diagnostic(s)`,\n );\n }\n\n reportMessages(\n findOverlappingFiles(apps).map((problem) => `[nestbridge] ${problem}`),\n watchMode,\n createLevelLogger(\n mostVerboseLogLevel(apps.map((app) => app.options.logLevel)),\n bundlerLogger,\n ),\n );\n };\n\n return {\n name: 'nestbridge',\n enforce: 'pre',\n\n buildStart() {\n apps = entries.map((entry) => createNestBridgeApp(entry, { baseRoot, bundlerRoot }));\n analyzeApps(apps, this);\n },\n\n resolveId(source) {\n if (source === CONFIG_VIRTUAL_MODULE_ID) {\n return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;\n }\n\n return null;\n },\n\n load(id) {\n if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) {\n return generateConfigModule(entries);\n }\n\n return null;\n },\n\n transform(_code, id) {\n const absolutePath = normalizePath(id);\n\n for (const app of apps) {\n const code = app.transform(absolutePath);\n\n if (code !== undefined) {\n return code;\n }\n }\n\n return null;\n },\n\n watchChange(id) {\n const changedFile = normalizePath(id);\n const affectedApps = apps.filter((app) => app.isAffectedBy(changedFile));\n\n if (affectedApps.length === 0) {\n return;\n }\n\n analyzeApps(affectedApps, this);\n\n for (const app of affectedApps) {\n log(app, `nestbridge source changed: ${changedFile}`);\n }\n },\n\n vite: {\n configResolved(config) {\n baseRoot = config.root;\n bundlerRoot = config.root;\n bundlerLogger = config.logger;\n\n const watching = config.command === 'serve' || Boolean(config.build.watch);\n readBundlerWatchMode = () => watching;\n },\n },\n\n webpack(compiler) {\n bundlerRoot = compiler.options.context ?? bundlerRoot;\n bundlerLogger = compiler.getInfrastructureLogger('nestbridge');\n readBundlerWatchMode = () => compiler.watchMode;\n },\n } satisfies UnpluginOptions;\n});\n","{\n \"name\": \"@nestbridge/unplugin\",\n \"version\": \"3.1.0\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/MDReal32/nestbridge.git\",\n \"directory\": \"packages/unplugin\"\n },\n \"main\": \"./build/nestbridge.unplugin.js\",\n \"types\": \"./build/nestbridge.unplugin.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./build/nestbridge.unplugin.d.ts\",\n \"import\": \"./build/nestbridge.unplugin.js\"\n }\n },\n \"files\": [\n \"build\"\n ],\n \"scripts\": {\n \"build\": \"vite build\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc -p tsconfig.json --noEmit\",\n \"lint\": \"biome check .\"\n },\n \"dependencies\": {\n \"@nestbridge/core\": \"workspace:*\",\n \"unplugin\": \"^3.3.0\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^26.4.1\",\n \"rolldown-plugin-dts\": \"^0.28.5\",\n \"typescript\": \"^7.0.2\",\n \"vite\": \"^8.2.2\",\n \"vitest\": \"^5.0.0\"\n }\n}\n","import { version } from '../package.json';\n\nexport const VERSION: string = version;\n"],"mappings":";;;;;AAEA,IAAM,4BAA4B,UAAqC;CACrE,IAAI,MAAM,YAAY,KAAA,GACpB;CAGF,IAAI,MAAM,SAAS,KAAA,GACjB,OAAO,wBAAwB,KAAK,UAAU,MAAM,OAAO,EAAE;CAG/D,OAAO,+BAA+B,KAAK,UAAU,MAAM,IAAI,EAAE,IAAI,KAAK,UAAU,MAAM,OAAO,EAAE;AACrG;AAEA,IAAa,wBAAwB,YAAkD;CACrF,MAAM,aAAa,QAChB,IAAI,wBAAwB,CAAC,CAC7B,QAAQ,cAAc,cAAc,KAAA,CAAS;CAEhD,IAAI,WAAW,WAAW,GACxB,OAAO;CAOT,OAAO;EAAC,YAJc,CAAC,wBAAwB,6BAA6B,CAAC,CAAC,QAAQ,SACpF,WAAW,MAAM,cAAc,UAAU,WAAW,GAAG,KAAK,EAAE,CAAC,CA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{
2
2
  "name": "@nestbridge/unplugin",
3
- "version": "2.6.1",
3
+ "version": "3.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "lint": "biome check ."
27
27
  },
28
28
  "dependencies": {
29
- "@nestbridge/core": "2.6.1",
29
+ "@nestbridge/core": "3.1.0",
30
30
  "unplugin": "^3.3.0"
31
31
  },
32
32
  "devDependencies": {