@emeryld/rrroutes-export 1.0.1 → 1.0.3
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 +1 -0
- package/package.json +3 -4
- package/tools/finalized-leaves-viewer.html +67 -24
- package/dist/defaultViewerTemplate.d.ts +0 -1
- package/dist/exportFinalizedLeaves.cli.d.ts +0 -14
- package/dist/exportFinalizedLeaves.d.ts +0 -61
- package/dist/extractLeafSourceByAst.d.ts +0 -38
- package/dist/flattenSchema.d.ts +0 -12
- package/dist/index.d.ts +0 -7
- package/dist/schemaIntrospection.d.ts +0 -47
- package/dist/serializeLeafContract.d.ts +0 -31
package/README.md
CHANGED
|
@@ -7,3 +7,4 @@ Export helpers and CLI for RRRoutes finalized leaves.
|
|
|
7
7
|
- Schema utilities: `serializeLeafContract`, `flattenLeafSchemas`, `introspectSchema`
|
|
8
8
|
|
|
9
9
|
Depends on `@emeryld/rrroutes-contract` for contract types and schema parsing.
|
|
10
|
+
This package is configured to install `@emeryld/rrroutes-contract` from npm (not from the local workspace) to ensure release-version parity.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emeryld/rrroutes-export",
|
|
3
3
|
"description": "Finalized leaves export helpers and CLI for RRRoutes",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.cjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"bin/rrroutes-export-finalized-leaves.mjs"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@emeryld/rrroutes-contract": "^2.
|
|
26
|
+
"@emeryld/rrroutes-contract": "^2.8.0",
|
|
27
27
|
"typescript": "^5.9.3",
|
|
28
28
|
"zod": "^4.3.6"
|
|
29
29
|
},
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"clean": "rimraf dist && rimraf node_modules",
|
|
39
|
-
"build": "pnpm run clean && pnpm install && pnpm run build:js
|
|
39
|
+
"build": "pnpm run clean && pnpm install && pnpm run build:js",
|
|
40
40
|
"build:js": "tsup --config tsup.config.ts",
|
|
41
|
-
"build:types": "tsc -p tsconfig.build.json",
|
|
42
41
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
43
42
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config ../../jest.base.config.js --watchman=false --runInBand",
|
|
44
43
|
"export:finalized-leaves": "TS_NODE_PROJECT=tsconfig.tools.json TS_NODE_TRANSPILE_ONLY=1 node --experimental-specifier-resolution=node --loader ts-node/esm ./scripts/export-finalized-leaves.ts"
|
|
@@ -924,15 +924,35 @@
|
|
|
924
924
|
return node
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
-
function
|
|
928
|
-
|
|
927
|
+
function normalizeFieldIds(fieldIds) {
|
|
928
|
+
if (!fieldIds) return []
|
|
929
|
+
return Array.isArray(fieldIds) ? fieldIds : [fieldIds]
|
|
929
930
|
}
|
|
930
931
|
|
|
931
|
-
function
|
|
932
|
+
function shouldHighlightField(fieldIds, selectedIds) {
|
|
933
|
+
const ids = normalizeFieldIds(fieldIds)
|
|
934
|
+
if (ids.length === 0) return false
|
|
935
|
+
if (!Array.isArray(selectedIds)) return false
|
|
936
|
+
return ids.some((id) => selectedIds.includes(id))
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
function highlightWithFieldScope(text, engine, selectedIds, fieldIds) {
|
|
940
|
+
const source = text ?? ''
|
|
941
|
+
if (!engine.active || !shouldHighlightField(fieldIds, selectedIds)) {
|
|
942
|
+
return escapeHtml(source)
|
|
943
|
+
}
|
|
944
|
+
return engine.highlight(source)
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function setHighlighted(node, text, engine, selectedIds, fieldIds) {
|
|
948
|
+
node.innerHTML = highlightWithFieldScope(text, engine, selectedIds, fieldIds)
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
function kv(key, value, engine, selectedIds, fieldIds) {
|
|
932
952
|
const box = el('div', 'kv')
|
|
933
953
|
box.appendChild(el('div', 'k', key))
|
|
934
954
|
const valueNode = el('div', 'v mono')
|
|
935
|
-
setHighlighted(valueNode, value === undefined ? '—' : String(value), engine)
|
|
955
|
+
setHighlighted(valueNode, value === undefined ? '—' : String(value), engine, selectedIds, fieldIds)
|
|
936
956
|
box.appendChild(valueNode)
|
|
937
957
|
return box
|
|
938
958
|
}
|
|
@@ -982,12 +1002,12 @@
|
|
|
982
1002
|
return `vscode://file/${encodeURI(vscodePath)}:${line}:${column}`
|
|
983
1003
|
}
|
|
984
1004
|
|
|
985
|
-
function createSourceRow(label, source, engine) {
|
|
1005
|
+
function createSourceRow(label, source, engine, selectedIds, fieldIds) {
|
|
986
1006
|
const box = el('div', 'kv')
|
|
987
1007
|
const labelNode = el('div', 'v mono')
|
|
988
1008
|
|
|
989
1009
|
if (!source || !source.file) {
|
|
990
|
-
setHighlighted(labelNode, label, engine)
|
|
1010
|
+
setHighlighted(labelNode, label, engine, selectedIds, fieldIds)
|
|
991
1011
|
box.appendChild(labelNode)
|
|
992
1012
|
return box
|
|
993
1013
|
}
|
|
@@ -997,7 +1017,7 @@
|
|
|
997
1017
|
link.href = href
|
|
998
1018
|
link.target = '_blank'
|
|
999
1019
|
link.rel = 'noopener noreferrer'
|
|
1000
|
-
link.innerHTML =
|
|
1020
|
+
link.innerHTML = highlightWithFieldScope(label, engine, selectedIds, fieldIds)
|
|
1001
1021
|
labelNode.appendChild(link)
|
|
1002
1022
|
box.appendChild(labelNode)
|
|
1003
1023
|
return box
|
|
@@ -1083,14 +1103,14 @@
|
|
|
1083
1103
|
return root
|
|
1084
1104
|
}
|
|
1085
1105
|
|
|
1086
|
-
function renderTreeNode(node, engine, isRoot) {
|
|
1106
|
+
function renderTreeNode(node, engine, selectedIds, sectionName, isRoot) {
|
|
1087
1107
|
const childKeys = Object.keys(node.children)
|
|
1088
1108
|
const hasChildren = childKeys.length > 0
|
|
1089
1109
|
const hasInfo = Boolean(node.info)
|
|
1090
1110
|
const appendNameCell = (row) => {
|
|
1091
1111
|
const nameWrap = el('span', 'mono tree-name')
|
|
1092
1112
|
const nameNode = el('span')
|
|
1093
|
-
setHighlighted(nameNode, node.name, engine)
|
|
1113
|
+
setHighlighted(nameNode, node.name, engine, selectedIds, sectionName)
|
|
1094
1114
|
nameWrap.appendChild(nameNode)
|
|
1095
1115
|
|
|
1096
1116
|
if (node.info && !node.info.optional) {
|
|
@@ -1107,7 +1127,10 @@
|
|
|
1107
1127
|
|
|
1108
1128
|
const appendTypeCell = (row, info) => {
|
|
1109
1129
|
const type = el('span', 'tree-pill')
|
|
1110
|
-
setHighlighted(type, info?.type || info?.kind || '—', engine
|
|
1130
|
+
setHighlighted(type, info?.type || info?.kind || '—', engine, selectedIds, [
|
|
1131
|
+
sectionName,
|
|
1132
|
+
'types',
|
|
1133
|
+
])
|
|
1111
1134
|
row.appendChild(type)
|
|
1112
1135
|
}
|
|
1113
1136
|
|
|
@@ -1126,7 +1149,11 @@
|
|
|
1126
1149
|
const container = el('div', 'schema-tree')
|
|
1127
1150
|
childKeys
|
|
1128
1151
|
.sort((a, b) => a.localeCompare(b))
|
|
1129
|
-
.forEach((key) =>
|
|
1152
|
+
.forEach((key) =>
|
|
1153
|
+
container.appendChild(
|
|
1154
|
+
renderTreeNode(node.children[key], engine, selectedIds, sectionName, false),
|
|
1155
|
+
),
|
|
1156
|
+
)
|
|
1130
1157
|
details.appendChild(container)
|
|
1131
1158
|
return details
|
|
1132
1159
|
}
|
|
@@ -1163,7 +1190,7 @@
|
|
|
1163
1190
|
hasAnySchemaEntries = true
|
|
1164
1191
|
const block = el('div', 'schema-block')
|
|
1165
1192
|
const header = el('div', 'schema-header mono')
|
|
1166
|
-
setHighlighted(header, sectionName, engine)
|
|
1193
|
+
setHighlighted(header, sectionName, engine, selectedIds, sectionName)
|
|
1167
1194
|
block.appendChild(header)
|
|
1168
1195
|
|
|
1169
1196
|
const schemaSource = getSchemaSource(source, sectionName)
|
|
@@ -1176,12 +1203,14 @@
|
|
|
1176
1203
|
),
|
|
1177
1204
|
schemaSource.sourceValue,
|
|
1178
1205
|
engine,
|
|
1206
|
+
selectedIds,
|
|
1207
|
+
'sourceSchemas',
|
|
1179
1208
|
),
|
|
1180
1209
|
)
|
|
1181
1210
|
}
|
|
1182
1211
|
|
|
1183
1212
|
const tree = buildSchemaTree(entries, sectionName)
|
|
1184
|
-
block.appendChild(renderTreeNode(tree, engine, true))
|
|
1213
|
+
block.appendChild(renderTreeNode(tree, engine, selectedIds, sectionName, true))
|
|
1185
1214
|
|
|
1186
1215
|
section.appendChild(block)
|
|
1187
1216
|
})
|
|
@@ -1192,7 +1221,13 @@
|
|
|
1192
1221
|
function renderLeaf(leaf, engine, selectedIds) {
|
|
1193
1222
|
const details = el('details', 'leaf')
|
|
1194
1223
|
const summary = el('summary')
|
|
1195
|
-
setHighlighted(
|
|
1224
|
+
setHighlighted(
|
|
1225
|
+
summary,
|
|
1226
|
+
`${String(leaf.method || '').toUpperCase()} ${leaf.path || ''}`,
|
|
1227
|
+
engine,
|
|
1228
|
+
selectedIds,
|
|
1229
|
+
['method', 'path'],
|
|
1230
|
+
)
|
|
1196
1231
|
details.appendChild(summary)
|
|
1197
1232
|
|
|
1198
1233
|
const content = el('div', 'leaf-content')
|
|
@@ -1202,32 +1237,38 @@
|
|
|
1202
1237
|
const overview = el('div', 'section')
|
|
1203
1238
|
overview.appendChild(el('h3', '', 'Overview'))
|
|
1204
1239
|
const topGrid = el('div', 'grid-3')
|
|
1205
|
-
topGrid.appendChild(kv('group', cfg.docsGroup, engine))
|
|
1240
|
+
topGrid.appendChild(kv('group', cfg.docsGroup, engine, selectedIds, 'docsGroup'))
|
|
1206
1241
|
topGrid.appendChild(
|
|
1207
|
-
kv(
|
|
1242
|
+
kv(
|
|
1243
|
+
'tags',
|
|
1244
|
+
cfg.tags && cfg.tags.length > 0 ? cfg.tags.join(', ') : undefined,
|
|
1245
|
+
engine,
|
|
1246
|
+
selectedIds,
|
|
1247
|
+
'tags',
|
|
1248
|
+
),
|
|
1208
1249
|
)
|
|
1209
|
-
topGrid.appendChild(kv('stability', cfg.stability, engine))
|
|
1250
|
+
topGrid.appendChild(kv('stability', cfg.stability, engine, selectedIds, 'stability'))
|
|
1210
1251
|
overview.appendChild(topGrid)
|
|
1211
|
-
overview.appendChild(kv('summary', cfg.summary, engine))
|
|
1212
|
-
overview.appendChild(kv('description', cfg.description, engine))
|
|
1252
|
+
overview.appendChild(kv('summary', cfg.summary, engine, selectedIds, 'summary'))
|
|
1253
|
+
overview.appendChild(kv('description', cfg.description, engine, selectedIds, 'description'))
|
|
1213
1254
|
|
|
1214
1255
|
const iconRow = el('div', 'icon-row')
|
|
1215
1256
|
if (cfg.feed) {
|
|
1216
1257
|
const feed = el('span', 'icon-badge feed')
|
|
1217
1258
|
feed.title = 'Feed endpoint'
|
|
1218
|
-
|
|
1259
|
+
feed.textContent = 'Feed'
|
|
1219
1260
|
iconRow.appendChild(feed)
|
|
1220
1261
|
}
|
|
1221
1262
|
if (cfg.deprecated) {
|
|
1222
1263
|
const deprecated = el('span', 'icon-badge warn')
|
|
1223
1264
|
deprecated.title = 'Deprecated'
|
|
1224
|
-
|
|
1265
|
+
deprecated.textContent = 'D'
|
|
1225
1266
|
iconRow.appendChild(deprecated)
|
|
1226
1267
|
}
|
|
1227
1268
|
if (cfg.docsHidden) {
|
|
1228
1269
|
const hidden = el('span', 'icon-badge warn')
|
|
1229
1270
|
hidden.title = 'Hidden'
|
|
1230
|
-
|
|
1271
|
+
hidden.textContent = 'H'
|
|
1231
1272
|
iconRow.appendChild(hidden)
|
|
1232
1273
|
}
|
|
1233
1274
|
if (iconRow.childNodes.length > 0) {
|
|
@@ -1241,7 +1282,7 @@
|
|
|
1241
1282
|
const chips = el('div', 'chips')
|
|
1242
1283
|
cfg.bodyFiles.forEach((file) => {
|
|
1243
1284
|
const chip = el('span', 'chip ok')
|
|
1244
|
-
|
|
1285
|
+
chip.textContent = `${file.name} (max ${file.maxCount})`
|
|
1245
1286
|
chips.appendChild(chip)
|
|
1246
1287
|
})
|
|
1247
1288
|
files.appendChild(chips)
|
|
@@ -1251,7 +1292,9 @@
|
|
|
1251
1292
|
const sourceByLeaf = state.payload?.sourceByLeaf || {}
|
|
1252
1293
|
const source = sourceByLeaf[leaf.key]
|
|
1253
1294
|
if (source?.definition) {
|
|
1254
|
-
overview.appendChild(
|
|
1295
|
+
overview.appendChild(
|
|
1296
|
+
createSourceRow('definition', source.definition, engine, selectedIds, 'sourceDefinition'),
|
|
1297
|
+
)
|
|
1255
1298
|
}
|
|
1256
1299
|
|
|
1257
1300
|
const separatedSchemas = renderSeparatedSchemas(flatSchema, engine, selectedIds, source)
|
|
@@ -1 +0,0 @@
|
|
|
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 || !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";
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,61 +0,0 @@
|
|
|
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>;
|
|
@@ -1,38 +0,0 @@
|
|
|
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 {};
|
package/dist/flattenSchema.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './schemaIntrospection';
|
|
2
|
-
export * from './serializeLeafContract';
|
|
3
|
-
export * from './flattenSchema';
|
|
4
|
-
export * from './exportFinalizedLeaves';
|
|
5
|
-
export * from './exportFinalizedLeaves.cli';
|
|
6
|
-
export * from './defaultViewerTemplate';
|
|
7
|
-
export * from './extractLeafSourceByAst';
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
export declare const serializableSchemaKinds: readonly ["object", "string", "number", "boolean", "bigint", "date", "array", "enum", "literal", "union", "record", "tuple", "unknown", "any"];
|
|
3
|
-
export type SerializableSchemaKind = (typeof serializableSchemaKinds)[number];
|
|
4
|
-
export type SerializableSchema = {
|
|
5
|
-
kind: SerializableSchemaKind;
|
|
6
|
-
optional?: boolean;
|
|
7
|
-
nullable?: boolean;
|
|
8
|
-
description?: string;
|
|
9
|
-
properties?: Record<string, SerializableSchema>;
|
|
10
|
-
element?: SerializableSchema;
|
|
11
|
-
union?: SerializableSchema[];
|
|
12
|
-
literal?: unknown;
|
|
13
|
-
enumValues?: string[];
|
|
14
|
-
};
|
|
15
|
-
type ZodAny = z.ZodTypeAny;
|
|
16
|
-
type InternalSchemaKind = SerializableSchemaKind | 'intersection';
|
|
17
|
-
type IntrospectionWalker = (schema: ZodAny | undefined) => SerializableSchema | undefined;
|
|
18
|
-
export type IntrospectionContext = {
|
|
19
|
-
zod: typeof z;
|
|
20
|
-
introspect: IntrospectionWalker;
|
|
21
|
-
getDef: (schema: unknown) => any | undefined;
|
|
22
|
-
unwrap: (schema: ZodAny) => {
|
|
23
|
-
base: ZodAny;
|
|
24
|
-
optional: boolean;
|
|
25
|
-
nullable: boolean;
|
|
26
|
-
};
|
|
27
|
-
getDescription: (schema: ZodAny) => string | undefined;
|
|
28
|
-
};
|
|
29
|
-
export type IntrospectionNode = {
|
|
30
|
-
schema: ZodAny;
|
|
31
|
-
base: ZodAny;
|
|
32
|
-
def: any;
|
|
33
|
-
kind: InternalSchemaKind;
|
|
34
|
-
optional: boolean;
|
|
35
|
-
nullable: boolean;
|
|
36
|
-
node: SerializableSchema;
|
|
37
|
-
};
|
|
38
|
-
export type SchemaIntrospectionHandler = (args: IntrospectionNode, ctx: IntrospectionContext) => SerializableSchema | undefined;
|
|
39
|
-
export type SchemaIntrospectionHandlerMap = Partial<Record<InternalSchemaKind, SchemaIntrospectionHandler>>;
|
|
40
|
-
export type IntrospectSchemaOptions = {
|
|
41
|
-
handlers?: SchemaIntrospectionHandlerMap;
|
|
42
|
-
};
|
|
43
|
-
export declare function registerSchemaIntrospectionHandler(kind: InternalSchemaKind, handler: SchemaIntrospectionHandler): void;
|
|
44
|
-
export declare function clearSchemaIntrospectionHandlers(): void;
|
|
45
|
-
export declare function createSchemaIntrospector(options?: IntrospectSchemaOptions): IntrospectionWalker;
|
|
46
|
-
export declare function introspectSchema(schema: ZodAny | undefined, options?: IntrospectSchemaOptions): SerializableSchema | undefined;
|
|
47
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type AnyLeafLowProfile, type FileField } from '@emeryld/rrroutes-contract';
|
|
2
|
-
import { type IntrospectSchemaOptions, type SerializableSchema } from './schemaIntrospection';
|
|
3
|
-
export type ContractLeafSchemas = {
|
|
4
|
-
body?: SerializableSchema;
|
|
5
|
-
query?: SerializableSchema;
|
|
6
|
-
params?: SerializableSchema;
|
|
7
|
-
output?: SerializableSchema;
|
|
8
|
-
outputMeta?: SerializableSchema;
|
|
9
|
-
queryExtension?: SerializableSchema;
|
|
10
|
-
};
|
|
11
|
-
export type SerializedLeafContract = {
|
|
12
|
-
key: string;
|
|
13
|
-
method: AnyLeafLowProfile['method'];
|
|
14
|
-
path: string;
|
|
15
|
-
cfg: {
|
|
16
|
-
description?: string;
|
|
17
|
-
summary?: string;
|
|
18
|
-
docsGroup?: string;
|
|
19
|
-
tags?: string[];
|
|
20
|
-
deprecated?: boolean;
|
|
21
|
-
stability?: 'experimental' | 'beta' | 'stable' | 'deprecated';
|
|
22
|
-
docsHidden?: boolean;
|
|
23
|
-
docsMeta?: Record<string, unknown>;
|
|
24
|
-
feed?: boolean;
|
|
25
|
-
bodyFiles?: FileField[];
|
|
26
|
-
schemas: ContractLeafSchemas;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export type SerializeLeafContractOptions = IntrospectSchemaOptions;
|
|
30
|
-
export declare function serializeLeafContract(leaf: AnyLeafLowProfile, options?: SerializeLeafContractOptions): SerializedLeafContract;
|
|
31
|
-
export declare function serializeLeavesContract(leaves: readonly AnyLeafLowProfile[], options?: SerializeLeafContractOptions): SerializedLeafContract[];
|