@nage-api/compat 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +215 -0
  3. package/dist/cli.d.ts +9 -0
  4. package/dist/cli.js +29 -0
  5. package/dist/codemods/cli-main.d.ts +32 -0
  6. package/dist/codemods/cli-main.js +128 -0
  7. package/dist/codemods/config-inventory.d.ts +20 -0
  8. package/dist/codemods/config-inventory.js +118 -0
  9. package/dist/codemods/env-rename.d.ts +36 -0
  10. package/dist/codemods/env-rename.js +104 -0
  11. package/dist/codemods/import-paths.d.ts +45 -0
  12. package/dist/codemods/import-paths.js +247 -0
  13. package/dist/codemods/job-generics.d.ts +17 -0
  14. package/dist/codemods/job-generics.js +74 -0
  15. package/dist/codemods/node-fs.d.ts +11 -0
  16. package/dist/codemods/node-fs.js +35 -0
  17. package/dist/codemods/registry.d.ts +26 -0
  18. package/dist/codemods/registry.js +42 -0
  19. package/dist/codemods/res-envelope.d.ts +29 -0
  20. package/dist/codemods/res-envelope.js +111 -0
  21. package/dist/codemods/runner.d.ts +36 -0
  22. package/dist/codemods/runner.js +44 -0
  23. package/dist/codemods/types.d.ts +69 -0
  24. package/dist/codemods/types.js +40 -0
  25. package/dist/index.d.ts +31 -0
  26. package/dist/index.js +63 -0
  27. package/dist/legacy/compat.module.d.ts +14 -0
  28. package/dist/legacy/compat.module.js +39 -0
  29. package/dist/legacy/envelope.d.ts +62 -0
  30. package/dist/legacy/envelope.js +86 -0
  31. package/dist/legacy/legacy-envelope.decorator.d.ts +17 -0
  32. package/dist/legacy/legacy-envelope.decorator.js +23 -0
  33. package/dist/legacy/legacy-envelope.interceptor.d.ts +25 -0
  34. package/dist/legacy/legacy-envelope.interceptor.js +67 -0
  35. package/dist/legacy/options.d.ts +14 -0
  36. package/dist/legacy/options.js +7 -0
  37. package/dist/legacy/responses.d.ts +48 -0
  38. package/dist/legacy/responses.js +52 -0
  39. package/package.json +61 -0
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * The real filesystem behind `CodemodFileSystem`.
4
+ *
5
+ * Separated from the command layer so every test of the command runs against an
6
+ * in-memory map. The skip list is the same one the CLI's own scanner uses:
7
+ * walking `node_modules` of a legacy monorepo is minutes of work producing notes
8
+ * about somebody else's code.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.nodeCodemodFs = nodeCodemodFs;
12
+ const promises_1 = require("node:fs/promises");
13
+ const node_path_1 = require("node:path");
14
+ const SKIP = new Set(['node_modules', 'dist', 'build', 'coverage', '.turbo', '.git', '.next']);
15
+ async function walk(directory) {
16
+ const found = [];
17
+ for (const entry of await (0, promises_1.readdir)(directory, { withFileTypes: true })) {
18
+ if (SKIP.has(entry.name))
19
+ continue;
20
+ const path = (0, node_path_1.join)(directory, entry.name);
21
+ if (entry.isDirectory())
22
+ found.push(...(await walk(path)));
23
+ else if (entry.isFile())
24
+ found.push(path);
25
+ }
26
+ return found;
27
+ }
28
+ function nodeCodemodFs() {
29
+ return {
30
+ list: walk,
31
+ read: (path) => (0, promises_1.readFile)(path, 'utf8'),
32
+ write: (path, content) => (0, promises_1.writeFile)(path, content, 'utf8'),
33
+ };
34
+ }
35
+ //# sourceMappingURL=node-fs.js.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The codemods §23.4 names, and the one it names that is not here.
3
+ *
4
+ * §23.4 lists five: entity/schema introspection → migration, `Result(res, x)` →
5
+ * `return x`, import-path rewrites, an env-var rename map, and config blob →
6
+ * `defineConfig`. Four are below. **Entity/schema introspection is not**, and
7
+ * not because it is hard:
8
+ *
9
+ * - it is a generator, not a source transform — its input is a live database's
10
+ * `information_schema`, which is the one thing none of the others need;
11
+ * - its output is a migration in @nage-api/data-sql's format, and `nage db
12
+ * migrate` is not a command yet (`docs/migration.md` → "What has no
13
+ * equivalent yet"), so nothing could apply what it wrote;
14
+ * - nothing in this repository could test it. Every codemod here has a
15
+ * before/after fixture; that one would have a fixture of a schema dump
16
+ * somebody typed, which proves the code runs and nothing about whether the
17
+ * migration it emits matches a real database.
18
+ *
19
+ * Writing it against a guess would produce the most dangerous artefact in the
20
+ * set: a plausible schema migration for a production database.
21
+ */
22
+ import type { Codemod } from './types.js';
23
+ /** Rewrites first: a report is more useful once the certain edits have landed. */
24
+ export declare const CODEMODS: readonly Codemod[];
25
+ export declare function findCodemod(name: string): Codemod | undefined;
26
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * The codemods §23.4 names, and the one it names that is not here.
4
+ *
5
+ * §23.4 lists five: entity/schema introspection → migration, `Result(res, x)` →
6
+ * `return x`, import-path rewrites, an env-var rename map, and config blob →
7
+ * `defineConfig`. Four are below. **Entity/schema introspection is not**, and
8
+ * not because it is hard:
9
+ *
10
+ * - it is a generator, not a source transform — its input is a live database's
11
+ * `information_schema`, which is the one thing none of the others need;
12
+ * - its output is a migration in @nage-api/data-sql's format, and `nage db
13
+ * migrate` is not a command yet (`docs/migration.md` → "What has no
14
+ * equivalent yet"), so nothing could apply what it wrote;
15
+ * - nothing in this repository could test it. Every codemod here has a
16
+ * before/after fixture; that one would have a fixture of a schema dump
17
+ * somebody typed, which proves the code runs and nothing about whether the
18
+ * migration it emits matches a real database.
19
+ *
20
+ * Writing it against a guess would produce the most dangerous artefact in the
21
+ * set: a plausible schema migration for a production database.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.CODEMODS = void 0;
25
+ exports.findCodemod = findCodemod;
26
+ const config_inventory_js_1 = require("./config-inventory.js");
27
+ const env_rename_js_1 = require("./env-rename.js");
28
+ const import_paths_js_1 = require("./import-paths.js");
29
+ const job_generics_js_1 = require("./job-generics.js");
30
+ const res_envelope_js_1 = require("./res-envelope.js");
31
+ /** Rewrites first: a report is more useful once the certain edits have landed. */
32
+ exports.CODEMODS = [
33
+ import_paths_js_1.importPathsCodemod,
34
+ env_rename_js_1.envRenameCodemod,
35
+ res_envelope_js_1.resEnvelopeCodemod,
36
+ config_inventory_js_1.configInventoryCodemod,
37
+ job_generics_js_1.jobGenericsCodemod,
38
+ ];
39
+ function findCodemod(name) {
40
+ return exports.CODEMODS.find((codemod) => codemod.name === name);
41
+ }
42
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `Result(res, x)` → `return x` (PLAN.md §23.4) — as a report, not a rewrite.
3
+ *
4
+ * §23.4 lists this as automatable and it is the transform everybody wants,
5
+ * because eighteen legacy controllers do it. It is not applied here, for one
6
+ * decisive reason and two supporting ones.
7
+ *
8
+ * The decisive one: rewriting the body without removing the `@Res()` parameter
9
+ * produces a route that **hangs**. Nest switches a handler to library-specific
10
+ * mode the moment `@Res()` appears in its signature and stops doing anything
11
+ * with the returned value, so `return data` writes nothing and the request times
12
+ * out. The two edits have to land together or not at all — and removing a
13
+ * parameter changes the method signature, every direct caller and every test
14
+ * that constructs a fake response, none of which is decidable from the line
15
+ * being rewritten.
16
+ *
17
+ * The supporting ones: `Result(res, { data, message })` has no home for
18
+ * `message` in the new envelope (§16.1 has no such field), so an automatic
19
+ * rewrite either drops a string the UI renders or invents a field; and a
20
+ * paginated payload changes shape rather than moving, `{ records, offset, limit,
21
+ * count }` becoming `{ records, pagination: { … } }`.
22
+ *
23
+ * So each site gets a note saying which of those it is. `@nage-api/compat` covers
24
+ * the interim: repoint the import (the `import-paths` codemod does that), and
25
+ * the controller compiles and behaves while you work through this list.
26
+ */
27
+ import { type Codemod } from './types.js';
28
+ export declare const resEnvelopeCodemod: Codemod;
29
+ //# sourceMappingURL=res-envelope.d.ts.map
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /**
3
+ * `Result(res, x)` → `return x` (PLAN.md §23.4) — as a report, not a rewrite.
4
+ *
5
+ * §23.4 lists this as automatable and it is the transform everybody wants,
6
+ * because eighteen legacy controllers do it. It is not applied here, for one
7
+ * decisive reason and two supporting ones.
8
+ *
9
+ * The decisive one: rewriting the body without removing the `@Res()` parameter
10
+ * produces a route that **hangs**. Nest switches a handler to library-specific
11
+ * mode the moment `@Res()` appears in its signature and stops doing anything
12
+ * with the returned value, so `return data` writes nothing and the request times
13
+ * out. The two edits have to land together or not at all — and removing a
14
+ * parameter changes the method signature, every direct caller and every test
15
+ * that constructs a fake response, none of which is decidable from the line
16
+ * being rewritten.
17
+ *
18
+ * The supporting ones: `Result(res, { data, message })` has no home for
19
+ * `message` in the new envelope (§16.1 has no such field), so an automatic
20
+ * rewrite either drops a string the UI renders or invents a field; and a
21
+ * paginated payload changes shape rather than moving, `{ records, offset, limit,
22
+ * count }` becoming `{ records, pagination: { … } }`.
23
+ *
24
+ * So each site gets a note saying which of those it is. `@nage-api/compat` covers
25
+ * the interim: repoint the import (the `import-paths` codemod does that), and
26
+ * the controller compiles and behaves while you work through this list.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.resEnvelopeCodemod = void 0;
30
+ const types_js_1 = require("./types.js");
31
+ /** `Result(` / `Created(` but not `this.Result(`, `fooResult(`. */
32
+ const BUILDER_CALL = /(?<![\w$.])(Result|Created)\s*\(/;
33
+ const ERROR_BUILDER_CALL = /(?<![\w$.])ErrorResponse\s*\(/;
34
+ const RES_PARAMETER = /@Res\s*\(\s*\)/;
35
+ const DIRECT_WRITE = /\bres\s*\.\s*(?:json|send|status|end|render|redirect)\s*\(/;
36
+ /**
37
+ * Payload keys that tell us which of the three shapes this call site is.
38
+ *
39
+ * Read from the call's own line only. A payload spread over several lines falls
40
+ * through to the generic message, which is the right way for a *report* to be
41
+ * wrong: it still names the line and still says to delete the `@Res()`
42
+ * parameter, and the developer reads the payload themselves.
43
+ */
44
+ const PAGE_KEYS = /\b(?:records|count|offset|limit)\s*:/;
45
+ const MESSAGE_KEY = /\bmessage\s*:/;
46
+ function describePayload(line) {
47
+ if (PAGE_KEYS.test(line)) {
48
+ return {
49
+ message: 'This builds the legacy list body: `records` and the three counters at the top level.',
50
+ action: 'Return `Paginated<T>` — `{ records, pagination: { offset, limit, count } }` — and let `ResponseInterceptor` lift it into `data` + `meta.pagination` (§16.1). `parseQuery` from @nage-api/data produces the query that page answers.',
51
+ };
52
+ }
53
+ if (MESSAGE_KEY.test(line)) {
54
+ return {
55
+ message: 'This call carries a `message`, and the success envelope has no field for one (§16.1).',
56
+ action: 'Decide where it goes: into the resource if a client renders it, or nowhere if it was for a developer. Do not invent a `meta.message` — one application doing that is how the envelope stopped being a contract last time.',
57
+ };
58
+ }
59
+ return {
60
+ message: 'This builds the response body by hand.',
61
+ action: 'Return the value and delete the `@Res()` parameter in the same edit. Until then, `@nage-api/compat` supplies `Result`/`Created` so the controller compiles unchanged.',
62
+ };
63
+ }
64
+ exports.resEnvelopeCodemod = {
65
+ name: 'res-envelope',
66
+ kind: 'report',
67
+ section: '§23.4, §16.1',
68
+ summary: 'Locates every manual response build and `@Res()` handler, and says which of the three ports each one is.',
69
+ run(files) {
70
+ const notes = [];
71
+ for (const file of files) {
72
+ if (!(0, types_js_1.isSourceFile)(file.path))
73
+ continue;
74
+ file.content.split('\n').forEach((line, index) => {
75
+ if ((0, types_js_1.isCommented)(line))
76
+ return;
77
+ const at = { path: file.path, line: index + 1 };
78
+ if (RES_PARAMETER.test(line)) {
79
+ notes.push({
80
+ ...at,
81
+ rule: 'res-parameter',
82
+ message: '`@Res()` puts the handler in library-specific mode: its return value is ignored, `ResponseInterceptor` never sees it and `AllExceptionsFilter` never sees its errors.',
83
+ action: 'Remove the parameter in the same commit as the `return`. If the route genuinely owns its bytes — a download, a webhook callback — use `@NoEnvelope()` from @nage-api/core, which keeps the exception filter.',
84
+ });
85
+ }
86
+ if (BUILDER_CALL.test(line)) {
87
+ const described = describePayload(line);
88
+ notes.push({ ...at, rule: 'manual-envelope', ...described });
89
+ }
90
+ if (ERROR_BUILDER_CALL.test(line)) {
91
+ notes.push({
92
+ ...at,
93
+ rule: 'error-envelope',
94
+ message: 'The legacy `ErrorResponse` echoed `error.message || error` to the client, so SQL text and upstream bodies reached callers (§5.2).',
95
+ action: 'Throw a `@nage-api/core` error instead and let `AllExceptionsFilter` answer. Check what this site was echoing before you decide the replacement is equivalent.',
96
+ });
97
+ }
98
+ if (DIRECT_WRITE.test(line)) {
99
+ notes.push({
100
+ ...at,
101
+ rule: 'direct-write',
102
+ message: 'The response object is written to directly.',
103
+ action: 'Nothing downstream of this line is in the envelope or the filter. Port it with the handler, not separately.',
104
+ });
105
+ }
106
+ });
107
+ }
108
+ return { changes: [], notes };
109
+ },
110
+ };
111
+ //# sourceMappingURL=res-envelope.js.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Runs codemods over a set of files, in order, threading the rewrites through.
3
+ *
4
+ * Sequential rather than parallel because a later rewrite has to see an earlier
5
+ * one's output: two codemods touching the same import line would otherwise both
6
+ * produce a "new" version of the file from the original text, and whichever was
7
+ * written last would win silently.
8
+ *
9
+ * The `kind` declaration is enforced here rather than trusted. A codemod that
10
+ * calls itself a report and returns a change is a bug that would otherwise
11
+ * appear as an unexplained edit in somebody's repository, so it fails loudly at
12
+ * the point the contract is broken.
13
+ */
14
+ import type { CodemodEdit, CodemodNote, SourceFile } from './types.js';
15
+ export interface AppliedEdit extends CodemodEdit {
16
+ readonly codemod: string;
17
+ readonly path: string;
18
+ }
19
+ export interface AttributedNote extends CodemodNote {
20
+ readonly codemod: string;
21
+ }
22
+ export interface CodemodRunReport {
23
+ /** Every file, with rewrites applied — unchanged files included. */
24
+ readonly files: readonly SourceFile[];
25
+ /** Paths whose content differs from the input. */
26
+ readonly changed: readonly string[];
27
+ readonly edits: readonly AppliedEdit[];
28
+ readonly notes: readonly AttributedNote[];
29
+ }
30
+ export interface CodemodRunOptions {
31
+ readonly files: readonly SourceFile[];
32
+ /** Names to run; defaults to all of `CODEMODS`, in registry order. */
33
+ readonly only?: readonly string[];
34
+ }
35
+ export declare function runCodemods(options: CodemodRunOptions): CodemodRunReport;
36
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Runs codemods over a set of files, in order, threading the rewrites through.
4
+ *
5
+ * Sequential rather than parallel because a later rewrite has to see an earlier
6
+ * one's output: two codemods touching the same import line would otherwise both
7
+ * produce a "new" version of the file from the original text, and whichever was
8
+ * written last would win silently.
9
+ *
10
+ * The `kind` declaration is enforced here rather than trusted. A codemod that
11
+ * calls itself a report and returns a change is a bug that would otherwise
12
+ * appear as an unexplained edit in somebody's repository, so it fails loudly at
13
+ * the point the contract is broken.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.runCodemods = runCodemods;
17
+ const registry_js_1 = require("./registry.js");
18
+ function runCodemods(options) {
19
+ const selected = options.only === undefined
20
+ ? registry_js_1.CODEMODS
21
+ : registry_js_1.CODEMODS.filter((codemod) => options.only?.includes(codemod.name) === true);
22
+ const working = new Map(options.files.map((file) => [file.path, file.content]));
23
+ const edits = [];
24
+ const notes = [];
25
+ for (const codemod of selected) {
26
+ const input = [...working].map(([path, content]) => ({ path, content }));
27
+ const result = codemod.run(input);
28
+ if (codemod.kind === 'report' && result.changes.length > 0) {
29
+ throw new Error(`codemod "${codemod.name}" is declared as a report but returned ${String(result.changes.length)} file change(s)`);
30
+ }
31
+ for (const change of result.changes) {
32
+ working.set(change.path, change.content);
33
+ edits.push(...change.edits.map((edit) => ({ ...edit, codemod: codemod.name, path: change.path })));
34
+ }
35
+ notes.push(...result.notes.map((note) => ({ ...note, codemod: codemod.name })));
36
+ }
37
+ const files = [...working].map(([path, content]) => ({ path, content }));
38
+ const original = new Map(options.files.map((file) => [file.path, file.content]));
39
+ const changed = files
40
+ .filter((file) => original.get(file.path) !== file.content)
41
+ .map((file) => file.path);
42
+ return { files, changed, edits, notes };
43
+ }
44
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The codemod contract (PLAN.md §23.4).
3
+ *
4
+ * Every codemod declares a `kind`, and the distinction is the point of this
5
+ * whole surface:
6
+ *
7
+ * - **rewrite** — the transform is decidable from the text alone and the
8
+ * result is what a careful developer would have typed. Applied to the file.
9
+ * - **report** — the change needs a fact the source does not carry (which
10
+ * entity a `Job<any>` is about; whether a dropped `message` mattered; what a
11
+ * variable's type is). A note is emitted naming the file, the line and what
12
+ * to do, and nothing is edited.
13
+ *
14
+ * The split exists because a codemod that is right most of the time is worse
15
+ * than no codemod: it produces a large, plausible diff that a reviewer approves
16
+ * by scrolling. `report` is what the uncertain cases get instead of a guess, and
17
+ * `runCodemods` enforces that a `report` codemod returns no changes.
18
+ */
19
+ /** One file, read into memory by the runner. */
20
+ export interface SourceFile {
21
+ readonly path: string;
22
+ readonly content: string;
23
+ }
24
+ export type CodemodKind = 'rewrite' | 'report';
25
+ /** One line a rewrite changed, kept so the runner can print a diff. */
26
+ export interface CodemodEdit {
27
+ /** 1-based, as an editor counts. */
28
+ readonly line: number;
29
+ readonly before: string;
30
+ readonly after: string;
31
+ }
32
+ export interface CodemodChange {
33
+ readonly path: string;
34
+ readonly content: string;
35
+ readonly edits: readonly CodemodEdit[];
36
+ }
37
+ /** A place a developer has to look, and what to do when they get there. */
38
+ export interface CodemodNote {
39
+ readonly path: string;
40
+ readonly line: number;
41
+ /** Stable identifier for the rule that fired, so notes can be triaged. */
42
+ readonly rule: string;
43
+ readonly message: string;
44
+ readonly action: string;
45
+ }
46
+ export interface CodemodResult {
47
+ readonly changes: readonly CodemodChange[];
48
+ readonly notes: readonly CodemodNote[];
49
+ }
50
+ export interface Codemod {
51
+ readonly name: string;
52
+ readonly kind: CodemodKind;
53
+ /** The PLAN.md section this implements, quoted in `--help` and the report. */
54
+ readonly section: string;
55
+ readonly summary: string;
56
+ run(files: readonly SourceFile[]): CodemodResult;
57
+ }
58
+ /** Files a source-level codemod looks at. */
59
+ export declare const SOURCE_EXTENSIONS: readonly [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
60
+ export declare function isSourceFile(path: string): boolean;
61
+ /**
62
+ * Whether a line is commented out.
63
+ *
64
+ * Deliberately the same cheap test `scanForLegacyPatterns` uses: a line-oriented
65
+ * scanner that tried to track block comments properly would need a lexer, and a
66
+ * lexer that is nearly right is how a codemod edits a line inside a comment.
67
+ */
68
+ export declare function isCommented(line: string): boolean;
69
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * The codemod contract (PLAN.md §23.4).
4
+ *
5
+ * Every codemod declares a `kind`, and the distinction is the point of this
6
+ * whole surface:
7
+ *
8
+ * - **rewrite** — the transform is decidable from the text alone and the
9
+ * result is what a careful developer would have typed. Applied to the file.
10
+ * - **report** — the change needs a fact the source does not carry (which
11
+ * entity a `Job<any>` is about; whether a dropped `message` mattered; what a
12
+ * variable's type is). A note is emitted naming the file, the line and what
13
+ * to do, and nothing is edited.
14
+ *
15
+ * The split exists because a codemod that is right most of the time is worse
16
+ * than no codemod: it produces a large, plausible diff that a reviewer approves
17
+ * by scrolling. `report` is what the uncertain cases get instead of a guess, and
18
+ * `runCodemods` enforces that a `report` codemod returns no changes.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.SOURCE_EXTENSIONS = void 0;
22
+ exports.isSourceFile = isSourceFile;
23
+ exports.isCommented = isCommented;
24
+ /** Files a source-level codemod looks at. */
25
+ exports.SOURCE_EXTENSIONS = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'];
26
+ function isSourceFile(path) {
27
+ return exports.SOURCE_EXTENSIONS.some((extension) => path.endsWith(extension));
28
+ }
29
+ /**
30
+ * Whether a line is commented out.
31
+ *
32
+ * Deliberately the same cheap test `scanForLegacyPatterns` uses: a line-oriented
33
+ * scanner that tried to track block comments properly would need a lexer, and a
34
+ * lexer that is nearly right is how a codemod edits a line inside a comment.
35
+ */
36
+ function isCommented(line) {
37
+ const trimmed = line.trimStart();
38
+ return trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*');
39
+ }
40
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `@nage-api/compat` — the shim and the codemods for moving a `nest-core-v2`
3
+ * application onto `@nage-api` (PLAN.md §23, §25 P1).
4
+ *
5
+ * Two halves that do not depend on each other:
6
+ *
7
+ * - the **runtime shim**, which lets a ported controller keep answering old
8
+ * clients in the old shape while the rest of the migration happens;
9
+ * - the **codemods**, which are a build-time tool and never loaded by an
10
+ * application.
11
+ *
12
+ * This package is temporary by design. When no route carries `@LegacyEnvelope()`
13
+ * any more, remove the import and the dependency; nothing else is holding it.
14
+ */
15
+ export { defaultLegacyBody, legacyErrorBody, type LegacyBodyBuilder, type LegacyBodyInput, type LegacyListBody, } from './legacy/envelope.js';
16
+ export { Created, ErrorResponse, Result, type LegacyResponse, type LegacyResponseOptions, } from './legacy/responses.js';
17
+ export { LegacyEnvelope, LEGACY_ENVELOPE_METADATA } from './legacy/legacy-envelope.decorator.js';
18
+ export { LegacyEnvelopeInterceptor } from './legacy/legacy-envelope.interceptor.js';
19
+ export { NageCompatModule } from './legacy/compat.module.js';
20
+ export { NAGE_COMPAT_OPTIONS, type CompatOptions } from './legacy/options.js';
21
+ export { CODEMODS, findCodemod } from './codemods/registry.js';
22
+ export { runCodemods, type AppliedEdit, type AttributedNote, type CodemodRunOptions, type CodemodRunReport, } from './codemods/runner.js';
23
+ export { isCommented, isSourceFile, SOURCE_EXTENSIONS, type Codemod, type CodemodChange, type CodemodEdit, type CodemodKind, type CodemodNote, type CodemodResult, type SourceFile, } from './codemods/types.js';
24
+ export { runCodemodCli, type CodemodCliOptions, type CodemodFileSystem, type CodemodIo, } from './codemods/cli-main.js';
25
+ export { nodeCodemodFs } from './codemods/node-fs.js';
26
+ export { importPathsCodemod, REPORT_RULES, REWRITE_RULES } from './codemods/import-paths.js';
27
+ export { envRenameCodemod, ENV_NOTES, ENV_RENAMES } from './codemods/env-rename.js';
28
+ export { resEnvelopeCodemod } from './codemods/res-envelope.js';
29
+ export { configInventoryCodemod } from './codemods/config-inventory.js';
30
+ export { jobGenericsCodemod } from './codemods/job-generics.js';
31
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * `@nage-api/compat` — the shim and the codemods for moving a `nest-core-v2`
4
+ * application onto `@nage-api` (PLAN.md §23, §25 P1).
5
+ *
6
+ * Two halves that do not depend on each other:
7
+ *
8
+ * - the **runtime shim**, which lets a ported controller keep answering old
9
+ * clients in the old shape while the rest of the migration happens;
10
+ * - the **codemods**, which are a build-time tool and never loaded by an
11
+ * application.
12
+ *
13
+ * This package is temporary by design. When no route carries `@LegacyEnvelope()`
14
+ * any more, remove the import and the dependency; nothing else is holding it.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.jobGenericsCodemod = exports.configInventoryCodemod = exports.resEnvelopeCodemod = exports.ENV_RENAMES = exports.ENV_NOTES = exports.envRenameCodemod = exports.REWRITE_RULES = exports.REPORT_RULES = exports.importPathsCodemod = exports.nodeCodemodFs = exports.runCodemodCli = exports.SOURCE_EXTENSIONS = exports.isSourceFile = exports.isCommented = exports.runCodemods = exports.findCodemod = exports.CODEMODS = exports.NAGE_COMPAT_OPTIONS = exports.NageCompatModule = exports.LegacyEnvelopeInterceptor = exports.LEGACY_ENVELOPE_METADATA = exports.LegacyEnvelope = exports.Result = exports.ErrorResponse = exports.Created = exports.legacyErrorBody = exports.defaultLegacyBody = void 0;
18
+ // ── Runtime shim (§23.1) ────────────────────────────────────────────────────
19
+ var envelope_js_1 = require("./legacy/envelope.js");
20
+ Object.defineProperty(exports, "defaultLegacyBody", { enumerable: true, get: function () { return envelope_js_1.defaultLegacyBody; } });
21
+ Object.defineProperty(exports, "legacyErrorBody", { enumerable: true, get: function () { return envelope_js_1.legacyErrorBody; } });
22
+ var responses_js_1 = require("./legacy/responses.js");
23
+ Object.defineProperty(exports, "Created", { enumerable: true, get: function () { return responses_js_1.Created; } });
24
+ Object.defineProperty(exports, "ErrorResponse", { enumerable: true, get: function () { return responses_js_1.ErrorResponse; } });
25
+ Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return responses_js_1.Result; } });
26
+ var legacy_envelope_decorator_js_1 = require("./legacy/legacy-envelope.decorator.js");
27
+ Object.defineProperty(exports, "LegacyEnvelope", { enumerable: true, get: function () { return legacy_envelope_decorator_js_1.LegacyEnvelope; } });
28
+ Object.defineProperty(exports, "LEGACY_ENVELOPE_METADATA", { enumerable: true, get: function () { return legacy_envelope_decorator_js_1.LEGACY_ENVELOPE_METADATA; } });
29
+ var legacy_envelope_interceptor_js_1 = require("./legacy/legacy-envelope.interceptor.js");
30
+ Object.defineProperty(exports, "LegacyEnvelopeInterceptor", { enumerable: true, get: function () { return legacy_envelope_interceptor_js_1.LegacyEnvelopeInterceptor; } });
31
+ var compat_module_js_1 = require("./legacy/compat.module.js");
32
+ Object.defineProperty(exports, "NageCompatModule", { enumerable: true, get: function () { return compat_module_js_1.NageCompatModule; } });
33
+ var options_js_1 = require("./legacy/options.js");
34
+ Object.defineProperty(exports, "NAGE_COMPAT_OPTIONS", { enumerable: true, get: function () { return options_js_1.NAGE_COMPAT_OPTIONS; } });
35
+ // ── Codemods (§23.4) ────────────────────────────────────────────────────────
36
+ var registry_js_1 = require("./codemods/registry.js");
37
+ Object.defineProperty(exports, "CODEMODS", { enumerable: true, get: function () { return registry_js_1.CODEMODS; } });
38
+ Object.defineProperty(exports, "findCodemod", { enumerable: true, get: function () { return registry_js_1.findCodemod; } });
39
+ var runner_js_1 = require("./codemods/runner.js");
40
+ Object.defineProperty(exports, "runCodemods", { enumerable: true, get: function () { return runner_js_1.runCodemods; } });
41
+ var types_js_1 = require("./codemods/types.js");
42
+ Object.defineProperty(exports, "isCommented", { enumerable: true, get: function () { return types_js_1.isCommented; } });
43
+ Object.defineProperty(exports, "isSourceFile", { enumerable: true, get: function () { return types_js_1.isSourceFile; } });
44
+ Object.defineProperty(exports, "SOURCE_EXTENSIONS", { enumerable: true, get: function () { return types_js_1.SOURCE_EXTENSIONS; } });
45
+ var cli_main_js_1 = require("./codemods/cli-main.js");
46
+ Object.defineProperty(exports, "runCodemodCli", { enumerable: true, get: function () { return cli_main_js_1.runCodemodCli; } });
47
+ var node_fs_js_1 = require("./codemods/node-fs.js");
48
+ Object.defineProperty(exports, "nodeCodemodFs", { enumerable: true, get: function () { return node_fs_js_1.nodeCodemodFs; } });
49
+ var import_paths_js_1 = require("./codemods/import-paths.js");
50
+ Object.defineProperty(exports, "importPathsCodemod", { enumerable: true, get: function () { return import_paths_js_1.importPathsCodemod; } });
51
+ Object.defineProperty(exports, "REPORT_RULES", { enumerable: true, get: function () { return import_paths_js_1.REPORT_RULES; } });
52
+ Object.defineProperty(exports, "REWRITE_RULES", { enumerable: true, get: function () { return import_paths_js_1.REWRITE_RULES; } });
53
+ var env_rename_js_1 = require("./codemods/env-rename.js");
54
+ Object.defineProperty(exports, "envRenameCodemod", { enumerable: true, get: function () { return env_rename_js_1.envRenameCodemod; } });
55
+ Object.defineProperty(exports, "ENV_NOTES", { enumerable: true, get: function () { return env_rename_js_1.ENV_NOTES; } });
56
+ Object.defineProperty(exports, "ENV_RENAMES", { enumerable: true, get: function () { return env_rename_js_1.ENV_RENAMES; } });
57
+ var res_envelope_js_1 = require("./codemods/res-envelope.js");
58
+ Object.defineProperty(exports, "resEnvelopeCodemod", { enumerable: true, get: function () { return res_envelope_js_1.resEnvelopeCodemod; } });
59
+ var config_inventory_js_1 = require("./codemods/config-inventory.js");
60
+ Object.defineProperty(exports, "configInventoryCodemod", { enumerable: true, get: function () { return config_inventory_js_1.configInventoryCodemod; } });
61
+ var job_generics_js_1 = require("./codemods/job-generics.js");
62
+ Object.defineProperty(exports, "jobGenericsCodemod", { enumerable: true, get: function () { return job_generics_js_1.jobGenericsCodemod; } });
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `NageCompatModule.forRoot()` — registers the legacy envelope interceptor.
3
+ *
4
+ * Importing it changes nothing on its own: the interceptor only acts on routes
5
+ * carrying `@LegacyEnvelope()`. That is what makes it safe to leave imported for
6
+ * the whole of a migration and remove in one commit at the end, once no route
7
+ * carries the decorator any more.
8
+ */
9
+ import { type DynamicModule } from '@nestjs/common';
10
+ import { type CompatOptions } from './options.js';
11
+ export declare class NageCompatModule {
12
+ static forRoot(options?: CompatOptions): DynamicModule;
13
+ }
14
+ //# sourceMappingURL=compat.module.d.ts.map
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * `NageCompatModule.forRoot()` — registers the legacy envelope interceptor.
4
+ *
5
+ * Importing it changes nothing on its own: the interceptor only acts on routes
6
+ * carrying `@LegacyEnvelope()`. That is what makes it safe to leave imported for
7
+ * the whole of a migration and remove in one commit at the end, once no route
8
+ * carries the decorator any more.
9
+ */
10
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
11
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
13
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
15
+ };
16
+ var NageCompatModule_1;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.NageCompatModule = void 0;
19
+ const common_1 = require("@nestjs/common");
20
+ const core_1 = require("@nestjs/core");
21
+ const legacy_envelope_interceptor_js_1 = require("./legacy-envelope.interceptor.js");
22
+ const options_js_1 = require("./options.js");
23
+ let NageCompatModule = NageCompatModule_1 = class NageCompatModule {
24
+ static forRoot(options = {}) {
25
+ return {
26
+ module: NageCompatModule_1,
27
+ providers: [
28
+ { provide: options_js_1.NAGE_COMPAT_OPTIONS, useValue: options },
29
+ { provide: core_1.APP_INTERCEPTOR, useClass: legacy_envelope_interceptor_js_1.LegacyEnvelopeInterceptor },
30
+ ],
31
+ exports: [options_js_1.NAGE_COMPAT_OPTIONS],
32
+ };
33
+ }
34
+ };
35
+ exports.NageCompatModule = NageCompatModule;
36
+ exports.NageCompatModule = NageCompatModule = NageCompatModule_1 = __decorate([
37
+ (0, common_1.Module)({})
38
+ ], NageCompatModule);
39
+ //# sourceMappingURL=compat.module.js.map