@emeryld/rrroutes-export 1.0.3 → 1.0.5
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/README.md +132 -3
- package/bin/rrroutes-export-changelog.mjs +16 -0
- package/dist/defaultViewerTemplate.d.ts +1 -0
- package/dist/exportFinalizedLeaves.changelog.cli.d.ts +15 -0
- package/dist/exportFinalizedLeaves.changelog.d.ts +145 -0
- package/dist/exportFinalizedLeaves.cli.d.ts +14 -0
- package/dist/exportFinalizedLeaves.d.ts +61 -0
- package/dist/extractLeafSourceByAst.d.ts +38 -0
- package/dist/flattenSchema.d.ts +12 -0
- package/dist/index.cjs +882 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +877 -14
- package/dist/index.mjs.map +1 -1
- package/dist/schemaIntrospection.d.ts +47 -0
- package/dist/serializeLeafContract.d.ts +31 -0
- package/package.json +10 -5
- package/tools/finalized-leaves-viewer.html +129 -1
package/README.md
CHANGED
|
@@ -2,9 +2,138 @@
|
|
|
2
2
|
|
|
3
3
|
Export helpers and CLI for RRRoutes finalized leaves.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
5
|
+
## What this package provides
|
|
6
|
+
|
|
7
|
+
- Runtime API:
|
|
8
|
+
- `exportFinalizedLeaves`
|
|
9
|
+
- `writeFinalizedLeavesExport`
|
|
10
|
+
- `exportFinalizedLeavesChangelog`
|
|
11
|
+
- `writeFinalizedLeavesChangelogExport`
|
|
12
|
+
- CLI:
|
|
13
|
+
- `rrroutes-export-finalized-leaves`
|
|
14
|
+
- `rrroutes-export-changelog`
|
|
15
|
+
- Schema utilities:
|
|
16
|
+
- `serializeLeafContract`
|
|
17
|
+
- `flattenLeafSchemas`
|
|
18
|
+
- `introspectSchema`
|
|
8
19
|
|
|
9
20
|
Depends on `@emeryld/rrroutes-contract` for contract types and schema parsing.
|
|
10
21
|
This package is configured to install `@emeryld/rrroutes-contract` from npm (not from the local workspace) to ensure release-version parity.
|
|
22
|
+
|
|
23
|
+
## Finalized leaves export CLI
|
|
24
|
+
|
|
25
|
+
Command:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
rrroutes-export-finalized-leaves \
|
|
29
|
+
--module ./path/to/leaves-module.cjs \
|
|
30
|
+
--export leaves \
|
|
31
|
+
--out ./finalized-leaves.export.json \
|
|
32
|
+
--with-source \
|
|
33
|
+
--tsconfig ./tsconfig.json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Settings:
|
|
37
|
+
|
|
38
|
+
- `--module <path>`: required. Path to the module that exports your leaves/registry.
|
|
39
|
+
- `--export <name>`: optional. Export name to load from the module. Default: `leaves`.
|
|
40
|
+
- `--out <path>`: optional. JSON output file path. Default: `finalized-leaves.export.json`.
|
|
41
|
+
- `--with-source`: optional flag. Enables AST source extraction (`sourceByLeaf`).
|
|
42
|
+
- `--tsconfig <path>`: optional. TS config used by source extraction.
|
|
43
|
+
|
|
44
|
+
## Changelog export CLI
|
|
45
|
+
|
|
46
|
+
Command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
rrroutes-export-changelog \
|
|
50
|
+
--module ./path/to/leaves-module.cjs \
|
|
51
|
+
--export leaves \
|
|
52
|
+
--from v1.4.0 \
|
|
53
|
+
--to HEAD \
|
|
54
|
+
--out ./finalized-leaves.changelog.json \
|
|
55
|
+
--html ./finalized-leaves.changelog.viewer.html \
|
|
56
|
+
--tsconfig ./tsconfig.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Settings:
|
|
60
|
+
|
|
61
|
+
- `--module <path>`: required. Module path used for per-commit snapshots.
|
|
62
|
+
- `--export <name>`: optional. Export name in the module. Default: `leaves`.
|
|
63
|
+
- `--from <rev>`: optional. Baseline revision/tag. Default: last reachable semver tag.
|
|
64
|
+
- `--to <rev>`: optional. End revision/tag. Default: `HEAD`.
|
|
65
|
+
- `--out <path>`: optional. Changelog JSON output. Default: `finalized-leaves.changelog.json`.
|
|
66
|
+
- `--html <path>`: optional. Baked HTML viewer for changelog payload.
|
|
67
|
+
- `--tsconfig <path>`: optional. TS config used for source extraction in snapshots.
|
|
68
|
+
- `--with-source`: accepted for parity; changelog mode always enables source extraction.
|
|
69
|
+
|
|
70
|
+
Behavior summary:
|
|
71
|
+
|
|
72
|
+
- Resolves commit path from `from..to` (chronological).
|
|
73
|
+
- Filters commits to those touching module tree/relevant config files.
|
|
74
|
+
- Ensures tip commit is always included.
|
|
75
|
+
- Creates a temp git worktree per selected commit.
|
|
76
|
+
- Exports snapshots, then computes adjacent diffs:
|
|
77
|
+
- route events (`route_added`, `route_removed`, `schema_changed`, `cfg_changed`)
|
|
78
|
+
- source-object events (`source_object_added`, `source_object_removed`, `source_schema_changed`)
|
|
79
|
+
|
|
80
|
+
## Recommended end-to-end script
|
|
81
|
+
|
|
82
|
+
Use this when you want one command to produce everything (snapshot + changelog + HTML + summary + timestamped storage).
|
|
83
|
+
|
|
84
|
+
Script command:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm --filter @emeryld/rrroutes-export run export:bundle -- \
|
|
88
|
+
--module ./src/contract/leaves.cjs \
|
|
89
|
+
--export leaves \
|
|
90
|
+
--tsconfig ./tsconfig.json \
|
|
91
|
+
--from v1.4.0 \
|
|
92
|
+
--to HEAD \
|
|
93
|
+
--dir ./.rrroutes-exports
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Bundle script settings (`scripts/export-release-bundle.ts`):
|
|
97
|
+
|
|
98
|
+
- `--module <path>`: required.
|
|
99
|
+
- `--export <name>`: optional. Default: `leaves`.
|
|
100
|
+
- `--tsconfig <path>`: optional.
|
|
101
|
+
- `--from <rev>`: optional.
|
|
102
|
+
- `--to <rev>`: optional.
|
|
103
|
+
- `--dir <path>`: optional base directory for stored bundles. Default: `.rrroutes-exports`.
|
|
104
|
+
|
|
105
|
+
Per run, it writes a timestamped directory:
|
|
106
|
+
|
|
107
|
+
- `finalized-leaves.export.json`
|
|
108
|
+
- `finalized-leaves.viewer.html`
|
|
109
|
+
- `finalized-leaves.changelog.json`
|
|
110
|
+
- `finalized-leaves.changelog.viewer.html`
|
|
111
|
+
- `summary.json`
|
|
112
|
+
|
|
113
|
+
This is the recommended CI/release flow because outputs are immutable per run and easy to archive.
|
|
114
|
+
|
|
115
|
+
## Runtime API (quick example)
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import {
|
|
119
|
+
exportFinalizedLeaves,
|
|
120
|
+
exportFinalizedLeavesChangelog,
|
|
121
|
+
} from '@emeryld/rrroutes-export'
|
|
122
|
+
|
|
123
|
+
const snapshot = await exportFinalizedLeaves(leaves, {
|
|
124
|
+
outFile: './finalized-leaves.export.json',
|
|
125
|
+
htmlFile: './finalized-leaves.viewer.html',
|
|
126
|
+
includeSource: true,
|
|
127
|
+
sourceModulePath: './src/contract/leaves.cjs',
|
|
128
|
+
sourceExportName: 'leaves',
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const changelog = await exportFinalizedLeavesChangelog({
|
|
132
|
+
modulePath: './src/contract/leaves.cjs',
|
|
133
|
+
exportName: 'leaves',
|
|
134
|
+
from: 'v1.4.0',
|
|
135
|
+
to: 'HEAD',
|
|
136
|
+
outFile: './finalized-leaves.changelog.json',
|
|
137
|
+
htmlFile: './finalized-leaves.changelog.viewer.html',
|
|
138
|
+
})
|
|
139
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runExportFinalizedLeavesChangelogCli } from '../dist/index.mjs'
|
|
4
|
+
|
|
5
|
+
runExportFinalizedLeavesChangelogCli(process.argv.slice(2))
|
|
6
|
+
.then(({ payload, outFile }) => {
|
|
7
|
+
process.stdout.write(
|
|
8
|
+
`Exported changelog for ${payload.commits.length} commits to ${outFile}\n`,
|
|
9
|
+
)
|
|
10
|
+
})
|
|
11
|
+
.catch((error) => {
|
|
12
|
+
process.stderr.write(
|
|
13
|
+
`${error instanceof Error ? error.message : String(error)}\n`,
|
|
14
|
+
)
|
|
15
|
+
process.exitCode = 1
|
|
16
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_VIEWER_TEMPLATE = "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Finalized Leaves Viewer</title>\n <style>\n :root {\n --bg: #212121;\n --surface: #2a2a2a;\n --border: #4a4a4a;\n --text: #fffafa;\n --muted: #c8c2c2;\n --accent: #a764d3;\n --schema-accent: #fbbd23;\n }\n body {\n margin: 0;\n font-family: 'Iosevka Web', 'SFMono-Regular', Menlo, Consolas, monospace;\n color: var(--text);\n background: var(--bg);\n }\n a { color: var(--schema-accent); }\n .wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }\n .card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }\n .meta { color: var(--muted); font-size: 12px; }\n #results { margin-top: 12px; display: grid; gap: 8px; }\n details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }\n summary { cursor: pointer; font-weight: 700; color: var(--accent); }\n pre { margin: 10px 0 0; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #303030; color: var(--text); }\n </style>\n </head>\n <body>\n <div class=\"wrap\">\n <h1>Finalized Leaves Viewer (Baked)</h1>\n <div class=\"card\">\n <div id=\"status\" class=\"meta\">Waiting for baked payload...</div>\n </div>\n <div id=\"results\"></div>\n </div>\n\n <!--__FINALIZED_LEAVES_BAKED_PAYLOAD__-->\n\n <script>\n const statusEl = document.getElementById('status')\n const resultsEl = document.getElementById('results')\n const payload = window.__FINALIZED_LEAVES_PAYLOAD\n\n if (payload && payload.kind === 'finalized-leaves-changelog') {\n statusEl.textContent =\n 'Loaded changelog payload with ' + (payload.commits?.length || 0) + ' commits.'\n\n const wrapSection = (title, value) => {\n const card = document.createElement('details')\n const summary = document.createElement('summary')\n summary.textContent = title\n const pre = document.createElement('pre')\n pre.textContent = JSON.stringify(value, null, 2)\n card.appendChild(summary)\n card.appendChild(pre)\n return card\n }\n\n resultsEl.appendChild(wrapSection('Commits', payload.commits || []))\n resultsEl.appendChild(wrapSection('By Route', payload.byRoute || {}))\n resultsEl.appendChild(\n wrapSection('By Source Object', payload.bySourceObject || {}),\n )\n } else if (!payload || !Array.isArray(payload.leaves)) {\n statusEl.textContent = 'No baked payload found in this HTML file.'\n } else {\n statusEl.textContent = 'Loaded baked payload with ' + payload.leaves.length + ' routes.'\n\n const toHref = (source) => {\n if (!source || !source.file) return null\n const normalizedPath = String(source.file).replace(/\\\\/g, '/')\n const platform =\n (navigator.userAgentData && navigator.userAgentData.platform) ||\n navigator.platform ||\n ''\n const isWindows = /win/i.test(platform)\n const vscodePath = isWindows\n ? normalizedPath.replace(/^\\/+/, '')\n : normalizedPath.startsWith('/')\n ? normalizedPath\n : '/' + normalizedPath\n const line = Number.isFinite(source.line) ? source.line : 1\n const column = Number.isFinite(source.column) ? source.column : 1\n return 'vscode://file/' + encodeURI(vscodePath) + ':' + line + ':' + column\n }\n\n const sourceDisplay = (source) => {\n return ''\n }\n\n payload.leaves.forEach((leaf) => {\n const details = document.createElement('details')\n const summary = document.createElement('summary')\n summary.textContent = String(leaf.method || '').toUpperCase() + ' ' + (leaf.path || '')\n\n const pre = document.createElement('pre')\n pre.textContent = JSON.stringify(leaf, null, 2)\n\n const source = payload.sourceByLeaf && payload.sourceByLeaf[leaf.key]\n let sourceWrap = null\n if (source) {\n sourceWrap = document.createElement('div')\n sourceWrap.className = 'meta'\n\n const definitionHref = toHref(source.definition)\n if (definitionHref) {\n const label = document.createElement('div')\n const link = document.createElement('a')\n link.href = definitionHref\n link.target = '_blank'\n link.rel = 'noopener noreferrer'\n link.textContent = 'definition'\n label.appendChild(link)\n sourceWrap.appendChild(label)\n }\n\n if (source.schemas && typeof source.schemas === 'object') {\n Object.entries(source.schemas).forEach(([name, schema]) => {\n if (!schema) return\n const href = toHref(schema)\n const row = document.createElement('div')\n if (href) {\n const link = document.createElement('a')\n link.href = href\n link.target = '_blank'\n link.rel = 'noopener noreferrer'\n link.textContent =\n name + ': ' + (schema.sourceName || schema.tag || '<anonymous>')\n row.appendChild(link)\n } else {\n row.textContent = name + ': ' + (schema.sourceName || schema.tag || '<anonymous>')\n }\n sourceWrap.appendChild(row)\n })\n }\n\n }\n\n details.appendChild(summary)\n if (sourceWrap) details.appendChild(sourceWrap)\n details.appendChild(pre)\n resultsEl.appendChild(details)\n })\n }\n </script>\n </body>\n</html>\n";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type FinalizedLeavesChangelogCliArgs = {
|
|
2
|
+
modulePath: string;
|
|
3
|
+
exportName: string;
|
|
4
|
+
outFile: string;
|
|
5
|
+
htmlFile?: string;
|
|
6
|
+
tsconfigPath?: string;
|
|
7
|
+
from?: string;
|
|
8
|
+
to?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function parseFinalizedLeavesChangelogCliArgs(argv: string[]): FinalizedLeavesChangelogCliArgs;
|
|
11
|
+
export declare function runExportFinalizedLeavesChangelogCli(argv: string[]): Promise<{
|
|
12
|
+
payload: import("./exportFinalizedLeaves.changelog").FinalizedLeavesChangelogExport;
|
|
13
|
+
outFile: string;
|
|
14
|
+
htmlFile: string | undefined;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { type ExportFinalizedLeavesOptions, type FinalizedLeavesExport, type WriteFinalizedLeavesExportOptions } from './exportFinalizedLeaves';
|
|
2
|
+
import type { FlatSchemaEntry, FlatSchemaMap } from './flattenSchema';
|
|
3
|
+
declare const CHANGESET_CFG_FIELDS: readonly ["summary", "description", "tags", "deprecated", "stability", "docsGroup", "docsHidden", "feed"];
|
|
4
|
+
declare const SCHEMA_SECTIONS: readonly ["params", "query", "body", "output"];
|
|
5
|
+
type ChangelogSchemaSection = (typeof SCHEMA_SECTIONS)[number];
|
|
6
|
+
type RouteCfgSubset = Partial<Record<(typeof CHANGESET_CFG_FIELDS)[number], unknown>>;
|
|
7
|
+
type SourceIdentity = {
|
|
8
|
+
id: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
file?: string;
|
|
11
|
+
line?: number;
|
|
12
|
+
column?: number;
|
|
13
|
+
tag?: string;
|
|
14
|
+
sourceName?: string;
|
|
15
|
+
};
|
|
16
|
+
type RouteSnapshot = {
|
|
17
|
+
key: string;
|
|
18
|
+
method: string;
|
|
19
|
+
path: string;
|
|
20
|
+
cfg: RouteCfgSubset;
|
|
21
|
+
flatSchema: FlatSchemaMap;
|
|
22
|
+
sourceBySection: Partial<Record<ChangelogSchemaSection, SourceIdentity>>;
|
|
23
|
+
};
|
|
24
|
+
type SourceObjectSectionSnapshot = Record<string, string[]>;
|
|
25
|
+
type SourceObjectSnapshot = {
|
|
26
|
+
id: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
routeKeys: string[];
|
|
29
|
+
sections: Record<ChangelogSchemaSection, SourceObjectSectionSnapshot>;
|
|
30
|
+
};
|
|
31
|
+
type CommitSnapshot = {
|
|
32
|
+
commit: ChangelogCommit;
|
|
33
|
+
routesByKey: Record<string, RouteSnapshot>;
|
|
34
|
+
sourceObjectsById: Record<string, SourceObjectSnapshot>;
|
|
35
|
+
};
|
|
36
|
+
type DiffOp = 'added' | 'removed' | 'changed';
|
|
37
|
+
export type SchemaPathDelta = {
|
|
38
|
+
path: string;
|
|
39
|
+
op: DiffOp;
|
|
40
|
+
before?: FlatSchemaEntry;
|
|
41
|
+
after?: FlatSchemaEntry;
|
|
42
|
+
};
|
|
43
|
+
export type RouteCfgFieldDelta = {
|
|
44
|
+
field: (typeof CHANGESET_CFG_FIELDS)[number];
|
|
45
|
+
before?: unknown;
|
|
46
|
+
after?: unknown;
|
|
47
|
+
};
|
|
48
|
+
export type SourceSchemaPathDelta = {
|
|
49
|
+
section: ChangelogSchemaSection;
|
|
50
|
+
path: string;
|
|
51
|
+
op: DiffOp;
|
|
52
|
+
before?: string[];
|
|
53
|
+
after?: string[];
|
|
54
|
+
};
|
|
55
|
+
export type ChangelogCommit = {
|
|
56
|
+
sha: string;
|
|
57
|
+
authorDate: string;
|
|
58
|
+
subject: string;
|
|
59
|
+
};
|
|
60
|
+
export type RouteChangeType = 'route_added' | 'route_removed' | 'schema_changed' | 'cfg_changed';
|
|
61
|
+
export type SourceObjectChangeType = 'source_object_added' | 'source_object_removed' | 'source_schema_changed';
|
|
62
|
+
export type RouteChangeEvent = {
|
|
63
|
+
type: RouteChangeType;
|
|
64
|
+
commitSha: string;
|
|
65
|
+
routeKey: string;
|
|
66
|
+
method?: string;
|
|
67
|
+
path?: string;
|
|
68
|
+
schemaDiff?: SchemaPathDelta[];
|
|
69
|
+
cfgDiff?: RouteCfgFieldDelta[];
|
|
70
|
+
};
|
|
71
|
+
export type SourceObjectChangeEvent = {
|
|
72
|
+
type: SourceObjectChangeType;
|
|
73
|
+
commitSha: string;
|
|
74
|
+
sourceObjectId: string;
|
|
75
|
+
displayName: string;
|
|
76
|
+
impactedRoutes: string[];
|
|
77
|
+
schemaDiff?: SourceSchemaPathDelta[];
|
|
78
|
+
routeAdded?: string[];
|
|
79
|
+
routeRemoved?: string[];
|
|
80
|
+
};
|
|
81
|
+
export type ChangelogRollups = {
|
|
82
|
+
route: Record<RouteChangeType, number>;
|
|
83
|
+
sourceObject: Record<SourceObjectChangeType, number>;
|
|
84
|
+
byCommit: Record<string, {
|
|
85
|
+
routeEvents: number;
|
|
86
|
+
sourceEvents: number;
|
|
87
|
+
}>;
|
|
88
|
+
};
|
|
89
|
+
export type FinalizedLeavesChangelogExport = {
|
|
90
|
+
kind: 'finalized-leaves-changelog';
|
|
91
|
+
_meta: {
|
|
92
|
+
generatedAt: string;
|
|
93
|
+
description: string;
|
|
94
|
+
modulePath: string;
|
|
95
|
+
exportName: string;
|
|
96
|
+
from: string;
|
|
97
|
+
to: string;
|
|
98
|
+
selectedCommitCount: number;
|
|
99
|
+
};
|
|
100
|
+
commits: ChangelogCommit[];
|
|
101
|
+
byRoute: Record<string, RouteChangeEvent[]>;
|
|
102
|
+
bySourceObject: Record<string, SourceObjectChangeEvent[]>;
|
|
103
|
+
rollups: ChangelogRollups;
|
|
104
|
+
};
|
|
105
|
+
export type ExportFinalizedLeavesChangelogOptions = {
|
|
106
|
+
modulePath: string;
|
|
107
|
+
exportName?: string;
|
|
108
|
+
tsconfigPath?: string;
|
|
109
|
+
from?: string;
|
|
110
|
+
to?: string;
|
|
111
|
+
outFile?: string;
|
|
112
|
+
htmlFile?: string;
|
|
113
|
+
viewerTemplateFile?: string;
|
|
114
|
+
openOnFinish?: boolean;
|
|
115
|
+
includeSource?: boolean;
|
|
116
|
+
handlers?: ExportFinalizedLeavesOptions['handlers'];
|
|
117
|
+
};
|
|
118
|
+
declare function resolveCommitWindow(cwd: string, from?: string, to?: string): Promise<{
|
|
119
|
+
from: string;
|
|
120
|
+
to: string;
|
|
121
|
+
}>;
|
|
122
|
+
declare function resolveCommitPath(cwd: string, fromCommit: string, toCommit: string): Promise<string[]>;
|
|
123
|
+
declare function filterCommits(cwd: string, commits: string[], moduleRel: string, tsconfigRel?: string): Promise<string[]>;
|
|
124
|
+
declare function buildSourceIdentity(section: ChangelogSchemaSection, value: Record<string, unknown>): SourceIdentity;
|
|
125
|
+
declare function toRouteSnapshots(payload: FinalizedLeavesExport): Record<string, RouteSnapshot>;
|
|
126
|
+
declare function toSourceObjectSnapshots(routesByKey: Record<string, RouteSnapshot>): Record<string, SourceObjectSnapshot>;
|
|
127
|
+
declare function diffSnapshots(previous: CommitSnapshot, current: CommitSnapshot): {
|
|
128
|
+
routeEvents: RouteChangeEvent[];
|
|
129
|
+
sourceEvents: SourceObjectChangeEvent[];
|
|
130
|
+
};
|
|
131
|
+
export declare function writeFinalizedLeavesChangelogExport(payload: FinalizedLeavesChangelogExport, outFileOrOptions: string | WriteFinalizedLeavesExportOptions): Promise<{
|
|
132
|
+
outFile?: string;
|
|
133
|
+
htmlFile?: string;
|
|
134
|
+
}>;
|
|
135
|
+
export declare function exportFinalizedLeavesChangelog(options: ExportFinalizedLeavesChangelogOptions): Promise<FinalizedLeavesChangelogExport>;
|
|
136
|
+
export declare const __private: {
|
|
137
|
+
resolveCommitWindow: typeof resolveCommitWindow;
|
|
138
|
+
resolveCommitPath: typeof resolveCommitPath;
|
|
139
|
+
filterCommits: typeof filterCommits;
|
|
140
|
+
toRouteSnapshots: typeof toRouteSnapshots;
|
|
141
|
+
toSourceObjectSnapshots: typeof toSourceObjectSnapshots;
|
|
142
|
+
diffSnapshots: typeof diffSnapshots;
|
|
143
|
+
buildSourceIdentity: typeof buildSourceIdentity;
|
|
144
|
+
};
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ExportFinalizedLeavesInput } from './exportFinalizedLeaves';
|
|
2
|
+
export type FinalizedLeavesCliArgs = {
|
|
3
|
+
modulePath: string;
|
|
4
|
+
exportName: string;
|
|
5
|
+
outFile: string;
|
|
6
|
+
withSource: boolean;
|
|
7
|
+
tsconfigPath?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function parseFinalizedLeavesCliArgs(argv: string[]): FinalizedLeavesCliArgs;
|
|
10
|
+
export declare function loadFinalizedLeavesInput({ modulePath, exportName, }: FinalizedLeavesCliArgs): Promise<ExportFinalizedLeavesInput>;
|
|
11
|
+
export declare function runExportFinalizedLeavesCli(argv: string[]): Promise<{
|
|
12
|
+
payload: import("./exportFinalizedLeaves").FinalizedLeavesExport;
|
|
13
|
+
outFile: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AnyLeafLowProfile, FinalizedRegistry } from '@emeryld/rrroutes-contract';
|
|
2
|
+
import { type FlatSchemaMap } from './flattenSchema';
|
|
3
|
+
import { type SerializeLeafContractOptions, type SerializedLeafContract } from './serializeLeafContract';
|
|
4
|
+
import { type LeafSourceByKey, type SourceExtractionReason } from './extractLeafSourceByAst';
|
|
5
|
+
export type ExportFinalizedLeavesInput = readonly AnyLeafLowProfile[] | FinalizedRegistry<readonly AnyLeafLowProfile[]>;
|
|
6
|
+
export type ExportFinalizedLeavesMeta = {
|
|
7
|
+
generatedAt: string;
|
|
8
|
+
description: string;
|
|
9
|
+
sourceExtraction?: {
|
|
10
|
+
mode: 'ast';
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
modulePath?: string;
|
|
13
|
+
exportName?: string;
|
|
14
|
+
tsconfigPath?: string;
|
|
15
|
+
resolvedLeafCount: number;
|
|
16
|
+
reason?: SourceExtractionReason;
|
|
17
|
+
stats?: {
|
|
18
|
+
visitedSymbols: number;
|
|
19
|
+
visitedFiles: number;
|
|
20
|
+
unresolvedReferences: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
fieldCatalog: {
|
|
24
|
+
leaf: string[];
|
|
25
|
+
cfg: string[];
|
|
26
|
+
schemaNode: string[];
|
|
27
|
+
flatSchemaEntry: string[];
|
|
28
|
+
};
|
|
29
|
+
flattening: {
|
|
30
|
+
notation: 'dot+[]';
|
|
31
|
+
unionBranchSuffix: '-N';
|
|
32
|
+
sections: readonly ['params', 'query', 'body', 'output'];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type FinalizedLeavesExport = {
|
|
36
|
+
_meta: ExportFinalizedLeavesMeta;
|
|
37
|
+
leaves: SerializedLeafContract[];
|
|
38
|
+
schemaFlatByLeaf: Record<string, FlatSchemaMap>;
|
|
39
|
+
sourceByLeaf?: LeafSourceByKey;
|
|
40
|
+
};
|
|
41
|
+
export type ExportFinalizedLeavesOptions = SerializeLeafContractOptions & {
|
|
42
|
+
outFile?: string;
|
|
43
|
+
htmlFile?: string;
|
|
44
|
+
viewerTemplateFile?: string;
|
|
45
|
+
openOnFinish?: boolean;
|
|
46
|
+
includeSource?: boolean;
|
|
47
|
+
tsconfigPath?: string;
|
|
48
|
+
sourceModulePath?: string;
|
|
49
|
+
sourceExportName?: string;
|
|
50
|
+
};
|
|
51
|
+
export type WriteFinalizedLeavesExportOptions = {
|
|
52
|
+
outFile?: string;
|
|
53
|
+
htmlFile?: string;
|
|
54
|
+
viewerTemplateFile?: string;
|
|
55
|
+
openOnFinish?: boolean;
|
|
56
|
+
};
|
|
57
|
+
export declare function writeFinalizedLeavesExport(payload: FinalizedLeavesExport, outFileOrOptions: string | WriteFinalizedLeavesExportOptions): Promise<{
|
|
58
|
+
outFile?: string;
|
|
59
|
+
htmlFile?: string;
|
|
60
|
+
}>;
|
|
61
|
+
export declare function exportFinalizedLeaves(input: ExportFinalizedLeavesInput, options?: ExportFinalizedLeavesOptions): Promise<FinalizedLeavesExport>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare const SCHEMA_KEYS: readonly ["bodySchema", "querySchema", "paramsSchema", "outputSchema", "outputMetaSchema", "queryExtensionSchema"];
|
|
2
|
+
export type SourceExtractionReason = 'module_not_in_program' | 'export_not_found' | 'unsupported_expression_shape' | 'resolved_zero_leaves';
|
|
3
|
+
type SchemaKey = (typeof SCHEMA_KEYS)[number];
|
|
4
|
+
export type LeafSourceLocation = {
|
|
5
|
+
file: string;
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
};
|
|
9
|
+
export type SchemaSourceMetadata = LeafSourceLocation & {
|
|
10
|
+
sourceName?: string;
|
|
11
|
+
tag?: '<inline>' | '<anonymous>' | '<expression>';
|
|
12
|
+
};
|
|
13
|
+
export type LeafSourceMetadata = {
|
|
14
|
+
definition: LeafSourceLocation & {
|
|
15
|
+
symbolName?: string;
|
|
16
|
+
};
|
|
17
|
+
schemas: Partial<Record<SchemaKey, SchemaSourceMetadata>>;
|
|
18
|
+
};
|
|
19
|
+
export type LeafSourceByKey = Record<string, LeafSourceMetadata>;
|
|
20
|
+
export type ExtractLeafSourceByAstOptions = {
|
|
21
|
+
modulePath: string;
|
|
22
|
+
exportName: string;
|
|
23
|
+
tsconfigPath?: string;
|
|
24
|
+
cwd?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ExtractLeafSourceByAstStats = {
|
|
27
|
+
visitedSymbols: number;
|
|
28
|
+
visitedFiles: number;
|
|
29
|
+
unresolvedReferences: number;
|
|
30
|
+
};
|
|
31
|
+
export type ExtractLeafSourceByAstResult = {
|
|
32
|
+
sourceByLeaf: LeafSourceByKey;
|
|
33
|
+
tsconfigPath?: string;
|
|
34
|
+
reason?: SourceExtractionReason;
|
|
35
|
+
stats: ExtractLeafSourceByAstStats;
|
|
36
|
+
};
|
|
37
|
+
export declare function extractLeafSourceByAst({ modulePath, exportName, tsconfigPath, cwd, }: ExtractLeafSourceByAstOptions): ExtractLeafSourceByAstResult;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AnyLeafLowProfile } from '@emeryld/rrroutes-contract';
|
|
2
|
+
import { type SerializedLeafContract } from './serializeLeafContract';
|
|
3
|
+
import type { SerializableSchema } from './schemaIntrospection';
|
|
4
|
+
export type FlatSchemaEntry = {
|
|
5
|
+
type: string;
|
|
6
|
+
nullable: boolean;
|
|
7
|
+
optional: boolean;
|
|
8
|
+
literal?: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type FlatSchemaMap = Record<string, FlatSchemaEntry>;
|
|
11
|
+
export declare function flattenSerializableSchema(schema: SerializableSchema | undefined, path: string): FlatSchemaMap;
|
|
12
|
+
export declare function flattenLeafSchemas(leaf: AnyLeafLowProfile | SerializedLeafContract): FlatSchemaMap;
|