@kubb/ast 5.25.0 → 5.26.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/dist/{file-3gsgXreK.js → combineFileMembers-DJHNAZBN.js} +204 -161
- package/dist/combineFileMembers-DJHNAZBN.js.map +1 -0
- package/dist/{file-D73XubVb.cjs → combineFileMembers-DmmuOmY8.cjs} +216 -160
- package/dist/combineFileMembers-DmmuOmY8.cjs.map +1 -0
- package/dist/factory.cjs +6 -6
- package/dist/factory.d.cts +2 -2
- package/dist/factory.d.ts +2 -2
- package/dist/factory.js +2 -2
- package/dist/{file-CMHRNuMX.d.cts → file-DJqd2j3y.d.cts} +3 -1
- package/dist/{file-D67ITWja.d.ts → file-Dg70hXm3.d.ts} +3 -1
- package/dist/{file-1YtTOZeL.js → file-HwCmj--S.js} +5 -3
- package/dist/file-HwCmj--S.js.map +1 -0
- package/dist/{file-azmmZwDb.cjs → file-z3xToonr.cjs} +11 -9
- package/dist/file-z3xToonr.cjs.map +1 -0
- package/dist/file.cjs +7 -5
- package/dist/file.d.cts +2 -2
- package/dist/file.d.ts +2 -2
- package/dist/file.js +3 -3
- package/dist/{graph-DImDxlJE.js → graph-CePbhGIt.js} +17 -20
- package/dist/graph-CePbhGIt.js.map +1 -0
- package/dist/{graph-DDh1FFrm.cjs → graph-D-0CbFIv.cjs} +17 -20
- package/dist/graph-D-0CbFIv.cjs.map +1 -0
- package/dist/graph.cjs +1 -1
- package/dist/graph.d.cts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/graph.js +1 -1
- package/dist/{index-DfTgdgaH.d.cts → index-BNf4pYPx.d.cts} +3 -2
- package/dist/{index-DerFkxlp.d.ts → index-BfNUrkK6.d.ts} +3 -2
- package/dist/{index-DNZgWmNq.d.cts → index-BjmAaymt.d.cts} +1 -1
- package/dist/{index-CIUD99Ft.d.ts → index-Br4bwEnS.d.ts} +2 -2
- package/dist/{index-CGmrJThc.d.ts → index-Bz33tfQo.d.ts} +1 -1
- package/dist/{index-Bcxj7FqZ.d.cts → index-C5SXJAtZ.d.cts} +2 -2
- package/dist/{index-bkTCYnZj.d.cts → index-CCUB1hoV.d.cts} +1 -1
- package/dist/{index-C-nsgwuD.d.ts → index-D3yqgtiN.d.ts} +2 -2
- package/dist/{index-84453BaS.d.cts → index-DBKL6vyC.d.cts} +16 -3
- package/dist/{index-BvdIGsVr.d.cts → index-DNDNDzyJ.d.cts} +2 -2
- package/dist/{index-C7U9EiIP.d.ts → index-DXdwkq7X.d.ts} +2 -2
- package/dist/{index-B3o1AkNE.d.ts → index-MzcNxet1.d.ts} +1 -1
- package/dist/{index-DR9ahJ-x.d.cts → index-OfWkiJ5O.d.cts} +2 -2
- package/dist/{index-BFwAhPp8.d.ts → index-VPq6RwTm.d.ts} +16 -3
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/macro-3uGSg-ic.js.map +1 -1
- package/dist/macro-Ywn4-0s5.cjs.map +1 -1
- package/dist/macro.d.cts +1 -1
- package/dist/macro.d.ts +1 -1
- package/dist/mediaType-BbIfudh0.cjs.map +1 -1
- package/dist/mediaType-DXQCNYdM.js.map +1 -1
- package/dist/mediaType.d.cts +2 -2
- package/dist/mediaType.d.ts +2 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/{nodes-BdZfapPI.cjs → nodes-TtDfZ9qf.cjs} +12 -12
- package/dist/{nodes-BdZfapPI.cjs.map → nodes-TtDfZ9qf.cjs.map} +1 -1
- package/dist/{nodes-D9nwroV5.js → nodes-u9i-tqFp.js} +2 -2
- package/dist/{nodes-D9nwroV5.js.map → nodes-u9i-tqFp.js.map} +1 -1
- package/dist/promise-B3YkZ4C8.js.map +1 -1
- package/dist/promise-DScaykew.cjs.map +1 -1
- package/dist/schema-0YJZqRXb.cjs.map +1 -1
- package/dist/schema-BvUrXIoX.js.map +1 -1
- package/dist/schema-CC008xgK.js.map +1 -1
- package/dist/schema-DfLGJ-oh.cjs.map +1 -1
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/{visitor-VYLe7Q4m.d.cts → visitor-BN5QJX7-.d.cts} +1 -1
- package/dist/{visitor-CqI8T9Qa.d.ts → visitor-BNGMMmpe.d.ts} +1 -1
- package/dist/visitor-DA5yfOJz.js.map +1 -1
- package/dist/visitor-DhuKS-7x.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/file-1YtTOZeL.js.map +0 -1
- package/dist/file-3gsgXreK.js.map +0 -1
- package/dist/file-D73XubVb.cjs.map +0 -1
- package/dist/file-azmmZwDb.cjs.map +0 -1
- package/dist/graph-DDh1FFrm.cjs.map +0 -1
- package/dist/graph-DImDxlJE.js.map +0 -1
|
@@ -605,6 +605,7 @@ type ExportInput = Omit<ExportNode, 'kind'>;
|
|
|
605
605
|
/**
|
|
606
606
|
* Creates an `ImportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
|
|
607
607
|
* `isTypeOnly` that differs from the one `names` gives overrides it, so `{ ...imp, isTypeOnly: true }` still works.
|
|
608
|
+
* Fields a spread copies over unchanged are not overrides, so `{ ...imp, names }` uses the new `names`.
|
|
608
609
|
*
|
|
609
610
|
* @example Named import
|
|
610
611
|
* ```ts
|
|
@@ -615,7 +616,8 @@ type ExportInput = Omit<ExportNode, 'kind'>;
|
|
|
615
616
|
declare function createImport(input: ImportInput): ImportNode;
|
|
616
617
|
/**
|
|
617
618
|
* Creates an `ExportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
|
|
618
|
-
* `isTypeOnly` that differs from the one `names` gives overrides it.
|
|
619
|
+
* `isTypeOnly` that differs from the one `names` gives overrides it. Fields a spread copies over unchanged are not
|
|
620
|
+
* overrides, so `{ ...exp, names }` uses the new `names`.
|
|
619
621
|
*
|
|
620
622
|
* @example Named export
|
|
621
623
|
* ```ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
|
|
2
|
+
import { c as getSpace, i as createImport, l as isExported, r as createFile, s as getNames, t as getRelativePath } from "./combineFileMembers-DJHNAZBN.js";
|
|
2
3
|
import { t as nodeKinds } from "./constants-UorsTFsa.js";
|
|
3
|
-
import { n as createFile, o as getNames, r as createImport, s as getSpace } from "./file-3gsgXreK.js";
|
|
4
4
|
import { n as getNodeText, t as CODE_NODE_TEXT_FIELDS } from "./nodeText-DFak5VpX.js";
|
|
5
5
|
// src/utils/inline.ts
|
|
6
6
|
/**
|
|
@@ -136,9 +136,11 @@ function rewriteNodes(nodes, rewrite) {
|
|
|
136
136
|
// src/file/index.ts
|
|
137
137
|
var file_exports = /* @__PURE__ */ __exportAll({
|
|
138
138
|
getNames: () => getNames,
|
|
139
|
+
getRelativePath: () => getRelativePath,
|
|
139
140
|
getSpace: () => getSpace,
|
|
140
|
-
inline: () => inlineFiles
|
|
141
|
+
inline: () => inlineFiles,
|
|
142
|
+
isExported: () => isExported
|
|
141
143
|
});
|
|
142
144
|
export { inlineFiles as n, file_exports as t };
|
|
143
145
|
|
|
144
|
-
//# sourceMappingURL=file-
|
|
146
|
+
//# sourceMappingURL=file-HwCmj--S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-HwCmj--S.js","names":[],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile, createImport } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\nexport type InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\nexport type InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, imports)\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n imports.push(...definition.imports)\n return lang.wrap(definition.expression)\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && getNames(imp).find((item) => (item.alias ?? item.name) === local)\n if (item) return { path: imp.path, name: item.name }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n const names = getNames(imp).filter((item) => used.has(item.alias ?? item.name))\n return names.length > 0 ? [createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names })] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { getRelativePath } from '../utils/combineFileMembers.ts'\nexport { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace, isExported } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;AAiDA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;CACxF,MAAM,SAA4B;EAAE,OAAO,CAAC;EAAG,cAAc,CAAC,GAAG,aAAa,KAAK,CAAC;EAAG,UAAU,CAAC;CAAE;CACpG,IAAI,aAAa,SAAS,GAAG,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAA+B;CAEvD,SAAS,OAAO,MAAc,MAAc,MAAc,MAA8C;EACtG,MAAM,MAAM,GAAG,KAAK,IAAI;EACxB,IAAI,YAAY,I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A,SAAS,OAAO,QAAoD;CAClE,IAAI,QAAQ,QAAQ,OAAO,OAAO,OAAO;CACzC,MAAM,OAAO,QAAQ,OAAO,WAAW,IAAI,OAAO,MAAM,KAAK,KAAA;CAC7D,IAAI,MAAM,SAAS,UAAU,SAAS,MAAM,SAAS,UAAU,MAAM,OAAO,KAAA;CAC5E,OAAO,YAAY,KAAK,KAAK,KAAK,KAAA;AACpC;AAEA,SAAS,UAAU,KAAiB,MAA8C;CAChF,MAAM,QAAQ,SAAS,GAAG,CAAC,CAAC,QAAQ,SAAS,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,CAAC;CAC9E,OAAO,MAAM,SAAS,IAAI,CAAC,aAAa;EAAE,MAAM,IAAI;EAAM,GAAI,IAAI,QAAQ,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;EAAI;CAAM,CAAC,CAAC,IAAI,CAAC;AAC1H;AAGA,SAAS,aAAa,OAAoC,SAAgE;CACxH,OAAO,OAAO,KAAK,SAAmB;EAEpC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;EACjD,IAAI,KAAK,SAAS,UAAU,OAAO,OAAO;EAE1C,MAAM,OAAO,EAAE,GAAG,KAAK;EACvB,KAAK,MAAM,SAAS,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
|
+
const require_combineFileMembers = require("./combineFileMembers-DmmuOmY8.cjs");
|
|
2
3
|
const require_constants = require("./constants-BCRkFAiy.cjs");
|
|
3
|
-
const require_file = require("./file-D73XubVb.cjs");
|
|
4
4
|
const require_nodeText = require("./nodeText-DH4dLGUb.cjs");
|
|
5
5
|
// src/utils/inline.ts
|
|
6
6
|
/**
|
|
@@ -68,7 +68,7 @@ function inlineFiles(files, { language }) {
|
|
|
68
68
|
name: local
|
|
69
69
|
};
|
|
70
70
|
for (const imp of file.imports) {
|
|
71
|
-
const item = virtualFiles.has(imp.path) &&
|
|
71
|
+
const item = virtualFiles.has(imp.path) && require_combineFileMembers.getNames(imp).find((item) => (item.alias ?? item.name) === local);
|
|
72
72
|
if (item) return {
|
|
73
73
|
path: imp.path,
|
|
74
74
|
name: item.name
|
|
@@ -94,7 +94,7 @@ function inlineFiles(files, { language }) {
|
|
|
94
94
|
...imp,
|
|
95
95
|
root: file.path
|
|
96
96
|
} : imp)];
|
|
97
|
-
result.files.push(
|
|
97
|
+
result.files.push(require_combineFileMembers.createFile({
|
|
98
98
|
...file,
|
|
99
99
|
sources,
|
|
100
100
|
imports
|
|
@@ -112,8 +112,8 @@ function bodyOf(source) {
|
|
|
112
112
|
return require_nodeText.getNodeText(node.nodes) || void 0;
|
|
113
113
|
}
|
|
114
114
|
function pickNames(imp, used) {
|
|
115
|
-
const names =
|
|
116
|
-
return names.length > 0 ? [
|
|
115
|
+
const names = require_combineFileMembers.getNames(imp).filter((item) => used.has(item.alias ?? item.name));
|
|
116
|
+
return names.length > 0 ? [require_combineFileMembers.createImport({
|
|
117
117
|
path: imp.path,
|
|
118
118
|
...imp.root != null ? { root: imp.root } : {},
|
|
119
119
|
names
|
|
@@ -135,9 +135,11 @@ function rewriteNodes(nodes, rewrite) {
|
|
|
135
135
|
}
|
|
136
136
|
// src/file/index.ts
|
|
137
137
|
var file_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
138
|
-
getNames: () =>
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
getNames: () => require_combineFileMembers.getNames,
|
|
139
|
+
getRelativePath: () => require_combineFileMembers.getRelativePath,
|
|
140
|
+
getSpace: () => require_combineFileMembers.getSpace,
|
|
141
|
+
inline: () => inlineFiles,
|
|
142
|
+
isExported: () => require_combineFileMembers.isExported
|
|
141
143
|
});
|
|
142
144
|
Object.defineProperty(exports, "file_exports", {
|
|
143
145
|
enumerable: true,
|
|
@@ -152,4 +154,4 @@ Object.defineProperty(exports, "inlineFiles", {
|
|
|
152
154
|
}
|
|
153
155
|
});
|
|
154
156
|
|
|
155
|
-
//# sourceMappingURL=file-
|
|
157
|
+
//# sourceMappingURL=file-z3xToonr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-z3xToonr.cjs","names":["getNames","createFile","nodeKinds","getNodeText","createImport","CODE_NODE_TEXT_FIELDS"],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile, createImport } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\nexport type InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\nexport type InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, imports)\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n imports.push(...definition.imports)\n return lang.wrap(definition.expression)\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && getNames(imp).find((item) => (item.alias ?? item.name) === local)\n if (item) return { path: imp.path, name: item.name }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n const names = getNames(imp).filter((item) => used.has(item.alias ?? item.name))\n return names.length > 0 ? [createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names })] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { getRelativePath } from '../utils/combineFileMembers.ts'\nexport { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace, isExported } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;AAiDA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;CACxF,MAAM,SAA4B;EAAE,OAAO,CAAC;EAAG,cAAc,CAAC,GAAG,aAAa,KAAK,CAAC;EAAG,UAAU,CAAC;CAAE;CACpG,IAAI,aAAa,SAAS,GAAG,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAA+B;CAEvD,SAAS,OAAO,MAAc,MAAc,MAAc,MAA8C;EACtG,MAAM,MAAM,GAAG,KAAK,IAAI;EACxB,IAAI,YAAY,IAAI,GAAG,GAAG;GACxB,MAAM,aAAa,YAAY,IAAI,GAAG;GACtC,IAAI,eAAe,MAAM,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,UAAU,KAAK;GAAkC,CAAC;GAChI,OAAO,cAAc,KAAA;EACvB;EAEA,MAAM,OAAO,aAAa,IAAI,IAAI;EAClC,MAAM,aAAa,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,CAAC;EAC7E,IAAI,eAAe,KAAA,GAAW;GAC5B,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI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AAC,QAAQ,SAAS,KAAK,IAAI,KAAK,SAAS,KAAK,IAAI,CAAC;CAC9E,OAAO,MAAM,SAAS,IAAI,CAACI,2BAAAA,aAAa;EAAE,MAAM,IAAI;EAAM,GAAI,IAAI,QAAQ,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;EAAI;CAAM,CAAC,CAAC,IAAI,CAAC;AAC1H;AAGA,SAAS,aAAa,OAAoC,SAAgE;CACxH,OAAO,OAAO,KAAK,SAAmB;EAEpC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;EACjD,IAAI,KAAK,SAASF,kBAAAA,UAAU,OAAO,OAAO;EAE1C,MAAM,OAAO,EAAE,GAAG,KAAK;EACvB,KAAK,MAAM,SAASG,iBAAAA,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
|
package/dist/file.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_file
|
|
4
|
-
exports.getNames =
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
2
|
+
const require_combineFileMembers = require("./combineFileMembers-DmmuOmY8.cjs");
|
|
3
|
+
const require_file = require("./file-z3xToonr.cjs");
|
|
4
|
+
exports.getNames = require_combineFileMembers.getNames;
|
|
5
|
+
exports.getRelativePath = require_combineFileMembers.getRelativePath;
|
|
6
|
+
exports.getSpace = require_combineFileMembers.getSpace;
|
|
7
|
+
exports.inline = require_file.inlineFiles;
|
|
8
|
+
exports.isExported = require_combineFileMembers.isExported;
|
package/dist/file.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
1
|
+
import { a as getRelativePath, i as isExported, n as getNames, r as getSpace, s as inlineFiles } from "./index-DBKL6vyC.cjs";
|
|
2
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
package/dist/file.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
1
|
+
import { a as getRelativePath, i as isExported, n as getNames, r as getSpace, s as inlineFiles } from "./index-VPq6RwTm.js";
|
|
2
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
package/dist/file.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as inlineFiles } from "./file-
|
|
3
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
1
|
+
import { c as getSpace, l as isExported, s as getNames, t as getRelativePath } from "./combineFileMembers-DJHNAZBN.js";
|
|
2
|
+
import { n as inlineFiles } from "./file-HwCmj--S.js";
|
|
3
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
|
@@ -66,7 +66,8 @@ function collectImportedRefNames(node, { checks = false } = {}) {
|
|
|
66
66
|
return memo(checks ? importedCheckRefNames : importedRefNames, node, () => [...new Set(collectRefEntries(node, { checks }).flatMap((entry) => entry.hasPointer ? [entry.name] : []))]);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Collects the names of all top-level schemas transitively used by a set of operations.
|
|
69
|
+
* Collects the names of all top-level schemas transitively used by a set of operations or schemas.
|
|
70
|
+
* A schema root counts the schemas it references, not itself.
|
|
70
71
|
*
|
|
71
72
|
* An operation uses a schema when its parameters, request body, or responses reference it, directly
|
|
72
73
|
* or through other named schemas. Once a name is added to the result it is not revisited, so
|
|
@@ -85,7 +86,7 @@ function collectImportedRefNames(node, { checks = false } = {}) {
|
|
|
85
86
|
* }
|
|
86
87
|
* ```
|
|
87
88
|
*/
|
|
88
|
-
function collectUsedSchemaNames(
|
|
89
|
+
function collectUsedSchemaNames(roots, schemas) {
|
|
89
90
|
const schemaMap = /* @__PURE__ */ new Map();
|
|
90
91
|
for (const schema of schemas) if (schema.name) schemaMap.set(schema.name, schema);
|
|
91
92
|
const result = /* @__PURE__ */ new Set();
|
|
@@ -96,7 +97,7 @@ function collectUsedSchemaNames(operations, schemas) {
|
|
|
96
97
|
if (namedSchema) visitSchema(namedSchema);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
for (const
|
|
100
|
+
for (const root of roots) for (const schema of collect(root, {
|
|
100
101
|
depth: "shallow",
|
|
101
102
|
schema: (node) => node
|
|
102
103
|
})) visitSchema(schema);
|
|
@@ -114,23 +115,19 @@ function collectUsedSchemaNames(operations, schemas) {
|
|
|
114
115
|
function findCircularSchemas(schemas) {
|
|
115
116
|
const graph = /* @__PURE__ */ new Map();
|
|
116
117
|
for (const schema of schemas) if (schema.name) graph.set(schema.name, collectSchemaRefs(schema));
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
visited.add(node);
|
|
129
|
-
const next = graph.get(node);
|
|
130
|
-
if (next) for (const r of next) stack.push(r);
|
|
131
|
-
}
|
|
118
|
+
return new Set([...graph.keys()].filter((start) => reachesItself(graph, start)));
|
|
119
|
+
}
|
|
120
|
+
function reachesItself(graph, start) {
|
|
121
|
+
const visited = /* @__PURE__ */ new Set();
|
|
122
|
+
const stack = [...graph.get(start) ?? []];
|
|
123
|
+
while (stack.length > 0) {
|
|
124
|
+
const node = stack.pop();
|
|
125
|
+
if (node === start) return true;
|
|
126
|
+
if (visited.has(node)) continue;
|
|
127
|
+
visited.add(node);
|
|
128
|
+
for (const next of graph.get(node) ?? []) stack.push(next);
|
|
132
129
|
}
|
|
133
|
-
return
|
|
130
|
+
return false;
|
|
134
131
|
}
|
|
135
132
|
// src/graph/index.ts
|
|
136
133
|
var graph_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -141,4 +138,4 @@ var graph_exports = /* @__PURE__ */ __exportAll({
|
|
|
141
138
|
});
|
|
142
139
|
export { findCircularSchemas as a, collectUsedSchemaNames as i, collectImportedRefNames as n, collectSchemaRefs as r, graph_exports as t };
|
|
143
140
|
|
|
144
|
-
//# sourceMappingURL=graph-
|
|
141
|
+
//# sourceMappingURL=graph-CePbhGIt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-CePbhGIt.js","names":[],"sources":["../src/utils/schemaGraph.ts","../src/graph/index.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport { nodeKinds } from '../constants.ts'\nimport type { Node } from '../nodes/index.ts'\nimport type { OperationNode } from '../nodes/operation.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { collect, visitChildNodes } from '../visitor.ts'\nimport { resolveRefName } from './refs.ts'\n\ntype RefEntry = { name: string; hasPointer: boolean }\n\nconst refEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst checkRefEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst schemaRefs = memo.create<SchemaNode, ReadonlySet<string>>({ weak: true })\nconst importedRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\nconst importedCheckRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\n\n/**\n * Walks a node's subtree once and lists every ref it holds, in traversal order, as the resolved\n * name plus whether the ref carries a `$ref` pointer. Memoized per node and per `checks` mode, so\n * each helper below scans a schema once.\n */\nfunction collectRefEntries(node: SchemaNode, { checks }: { checks: boolean }): ReadonlyArray<RefEntry> {\n return memo(checks ? checkRefEntries : refEntries, node, () => {\n const entries: Array<RefEntry> = []\n const walk = (current: Node): boolean => {\n if (current.kind === nodeKinds.schema && current.type === 'ref') {\n const name = resolveRefName(current)\n if (name) entries.push({ name, hasPointer: Boolean(current.ref) })\n }\n visitChildNodes(current, walk, { checks })\n return false\n }\n walk(node)\n return entries\n })\n}\n\n/**\n * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.\n * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by\n * node identity, so repeated calls on one schema scan it once.\n *\n * @example\n * ```ts\n * collectSchemaRefs(petSchema)\n * // Set { 'Category', 'Tag' }\n * ```\n */\nexport function collectSchemaRefs(node: SchemaNode): ReadonlySet<string> {\n return memo(schemaRefs, node, () => new Set(collectRefEntries(node, { checks: true }).map((entry) => entry.name)))\n}\n\n/**\n * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in\n * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result\n * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.\n *\n * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the\n * same file (a union member created by name) is left out. That leaves exactly the set\n * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with\n * `checks: true`, for a plugin that prints those checks.\n *\n * @example\n * ```ts\n * collectImportedRefNames(petSchema)\n * // ['Category', 'Tag']\n * ```\n */\nexport function collectImportedRefNames(node: SchemaNode, { checks = false }: { checks?: boolean } = {}): ReadonlyArray<string> {\n return memo(checks ? importedCheckRefNames : importedRefNames, node, () => [\n ...new Set(collectRefEntries(node, { checks }).flatMap((entry) => (entry.hasPointer ? [entry.name] : []))),\n ])\n}\n\n/**\n * Collects the names of all top-level schemas transitively used by a set of operations or schemas.\n * A schema root counts the schemas it references, not itself.\n *\n * An operation uses a schema when its parameters, request body, or responses reference it, directly\n * or through other named schemas. Once a name is added to the result it is not revisited, so\n * reference cycles terminate.\n *\n * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.\n *\n * @example Only generate schemas referenced by included operations\n * ```ts\n * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)\n * const allowed = collectUsedSchemaNames(includedOps, schemas)\n *\n * for (const schema of schemas) {\n * if (schema.name && !allowed.has(schema.name)) continue\n * // generate schema\n * }\n * ```\n */\nexport function collectUsedSchemaNames(roots: ReadonlyArray<OperationNode | SchemaNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const schemaMap = new Map<string, SchemaNode>()\n for (const schema of schemas) {\n if (schema.name) schemaMap.set(schema.name, schema)\n }\n\n const result = new Set<string>()\n\n function visitSchema(schema: SchemaNode): void {\n for (const name of collectSchemaRefs(schema)) {\n if (!result.has(name)) {\n result.add(name)\n const namedSchema = schemaMap.get(name)\n if (namedSchema) visitSchema(namedSchema)\n }\n }\n }\n\n for (const root of roots) {\n for (const schema of collect<SchemaNode>(root, { depth: 'shallow', schema: (node) => node })) {\n visitSchema(schema)\n }\n }\n\n return result\n}\n\n/**\n * Finds every schema that takes part in a circular dependency chain, including direct self-loops.\n *\n * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so\n * the generated code does not recurse forever. Refs are followed by name only, so the walk stays\n * linear in the size of the schema graph.\n *\n * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const graph = new Map<string, ReadonlySet<string>>()\n for (const schema of schemas) {\n if (schema.name) graph.set(schema.name, collectSchemaRefs(schema))\n }\n\n return new Set([...graph.keys()].filter((start) => reachesItself(graph, start)))\n}\n\nfunction reachesItself(graph: ReadonlyMap<string, ReadonlySet<string>>, start: string): boolean {\n const visited = new Set<string>()\n const stack: Array<string> = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) return true\n if (visited.has(node)) continue\n visited.add(node)\n for (const next of graph.get(node) ?? []) stack.push(next)\n }\n\n return false\n}\n","export {\n collectImportedRefNames as getImportedNames,\n collectSchemaRefs as get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K,IAAI;CAC3D;CAEA,OAAO;AACT"}
|
|
@@ -66,7 +66,8 @@ function collectImportedRefNames(node, { checks = false } = {}) {
|
|
|
66
66
|
return require_promise.memo(checks ? importedCheckRefNames : importedRefNames, node, () => [...new Set(collectRefEntries(node, { checks }).flatMap((entry) => entry.hasPointer ? [entry.name] : []))]);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Collects the names of all top-level schemas transitively used by a set of operations.
|
|
69
|
+
* Collects the names of all top-level schemas transitively used by a set of operations or schemas.
|
|
70
|
+
* A schema root counts the schemas it references, not itself.
|
|
70
71
|
*
|
|
71
72
|
* An operation uses a schema when its parameters, request body, or responses reference it, directly
|
|
72
73
|
* or through other named schemas. Once a name is added to the result it is not revisited, so
|
|
@@ -85,7 +86,7 @@ function collectImportedRefNames(node, { checks = false } = {}) {
|
|
|
85
86
|
* }
|
|
86
87
|
* ```
|
|
87
88
|
*/
|
|
88
|
-
function collectUsedSchemaNames(
|
|
89
|
+
function collectUsedSchemaNames(roots, schemas) {
|
|
89
90
|
const schemaMap = /* @__PURE__ */ new Map();
|
|
90
91
|
for (const schema of schemas) if (schema.name) schemaMap.set(schema.name, schema);
|
|
91
92
|
const result = /* @__PURE__ */ new Set();
|
|
@@ -96,7 +97,7 @@ function collectUsedSchemaNames(operations, schemas) {
|
|
|
96
97
|
if (namedSchema) visitSchema(namedSchema);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
for (const
|
|
100
|
+
for (const root of roots) for (const schema of require_visitor.collect(root, {
|
|
100
101
|
depth: "shallow",
|
|
101
102
|
schema: (node) => node
|
|
102
103
|
})) visitSchema(schema);
|
|
@@ -114,23 +115,19 @@ function collectUsedSchemaNames(operations, schemas) {
|
|
|
114
115
|
function findCircularSchemas(schemas) {
|
|
115
116
|
const graph = /* @__PURE__ */ new Map();
|
|
116
117
|
for (const schema of schemas) if (schema.name) graph.set(schema.name, collectSchemaRefs(schema));
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
visited.add(node);
|
|
129
|
-
const next = graph.get(node);
|
|
130
|
-
if (next) for (const r of next) stack.push(r);
|
|
131
|
-
}
|
|
118
|
+
return new Set([...graph.keys()].filter((start) => reachesItself(graph, start)));
|
|
119
|
+
}
|
|
120
|
+
function reachesItself(graph, start) {
|
|
121
|
+
const visited = /* @__PURE__ */ new Set();
|
|
122
|
+
const stack = [...graph.get(start) ?? []];
|
|
123
|
+
while (stack.length > 0) {
|
|
124
|
+
const node = stack.pop();
|
|
125
|
+
if (node === start) return true;
|
|
126
|
+
if (visited.has(node)) continue;
|
|
127
|
+
visited.add(node);
|
|
128
|
+
for (const next of graph.get(node) ?? []) stack.push(next);
|
|
132
129
|
}
|
|
133
|
-
return
|
|
130
|
+
return false;
|
|
134
131
|
}
|
|
135
132
|
// src/graph/index.ts
|
|
136
133
|
var graph_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
@@ -170,4 +167,4 @@ Object.defineProperty(exports, "graph_exports", {
|
|
|
170
167
|
}
|
|
171
168
|
});
|
|
172
169
|
|
|
173
|
-
//# sourceMappingURL=graph-
|
|
170
|
+
//# sourceMappingURL=graph-D-0CbFIv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-D-0CbFIv.cjs","names":["memo","nodeKinds","resolveRefName","visitChildNodes","collect"],"sources":["../src/utils/schemaGraph.ts","../src/graph/index.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport { nodeKinds } from '../constants.ts'\nimport type { Node } from '../nodes/index.ts'\nimport type { OperationNode } from '../nodes/operation.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { collect, visitChildNodes } from '../visitor.ts'\nimport { resolveRefName } from './refs.ts'\n\ntype RefEntry = { name: string; hasPointer: boolean }\n\nconst refEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst checkRefEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst schemaRefs = memo.create<SchemaNode, ReadonlySet<string>>({ weak: true })\nconst importedRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\nconst importedCheckRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\n\n/**\n * Walks a node's subtree once and lists every ref it holds, in traversal order, as the resolved\n * name plus whether the ref carries a `$ref` pointer. Memoized per node and per `checks` mode, so\n * each helper below scans a schema once.\n */\nfunction collectRefEntries(node: SchemaNode, { checks }: { checks: boolean }): ReadonlyArray<RefEntry> {\n return memo(checks ? checkRefEntries : refEntries, node, () => {\n const entries: Array<RefEntry> = []\n const walk = (current: Node): boolean => {\n if (current.kind === nodeKinds.schema && current.type === 'ref') {\n const name = resolveRefName(current)\n if (name) entries.push({ name, hasPointer: Boolean(current.ref) })\n }\n visitChildNodes(current, walk, { checks })\n return false\n }\n walk(node)\n return entries\n })\n}\n\n/**\n * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.\n * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by\n * node identity, so repeated calls on one schema scan it once.\n *\n * @example\n * ```ts\n * collectSchemaRefs(petSchema)\n * // Set { 'Category', 'Tag' }\n * ```\n */\nexport function collectSchemaRefs(node: SchemaNode): ReadonlySet<string> {\n return memo(schemaRefs, node, () => new Set(collectRefEntries(node, { checks: true }).map((entry) => entry.name)))\n}\n\n/**\n * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in\n * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result\n * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.\n *\n * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the\n * same file (a union member created by name) is left out. That leaves exactly the set\n * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with\n * `checks: true`, for a plugin that prints those checks.\n *\n * @example\n * ```ts\n * collectImportedRefNames(petSchema)\n * // ['Category', 'Tag']\n * ```\n */\nexport function collectImportedRefNames(node: SchemaNode, { checks = false }: { checks?: boolean } = {}): ReadonlyArray<string> {\n return memo(checks ? importedCheckRefNames : importedRefNames, node, () => [\n ...new Set(collectRefEntries(node, { checks }).flatMap((entry) => (entry.hasPointer ? [entry.name] : []))),\n ])\n}\n\n/**\n * Collects the names of all top-level schemas transitively used by a set of operations or schemas.\n * A schema root counts the schemas it references, not itself.\n *\n * An operation uses a schema when its parameters, request body, or responses reference it, directly\n * or through other named schemas. Once a name is added to the result it is not revisited, so\n * reference cycles terminate.\n *\n * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.\n *\n * @example Only generate schemas referenced by included operations\n * ```ts\n * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)\n * const allowed = collectUsedSchemaNames(includedOps, schemas)\n *\n * for (const schema of schemas) {\n * if (schema.name && !allowed.has(schema.name)) continue\n * // generate schema\n * }\n * ```\n */\nexport function collectUsedSchemaNames(roots: ReadonlyArray<OperationNode | SchemaNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const schemaMap = new Map<string, SchemaNode>()\n for (const schema of schemas) {\n if (schema.name) schemaMap.set(schema.name, schema)\n }\n\n const result = new Set<string>()\n\n function visitSchema(schema: SchemaNode): void {\n for (const name of collectSchemaRefs(schema)) {\n if (!result.has(name)) {\n result.add(name)\n const namedSchema = schemaMap.get(name)\n if (namedSchema) visitSchema(namedSchema)\n }\n }\n }\n\n for (const root of roots) {\n for (const schema of collect<SchemaNode>(root, { depth: 'shallow', schema: (node) => node })) {\n visitSchema(schema)\n }\n }\n\n return result\n}\n\n/**\n * Finds every schema that takes part in a circular dependency chain, including direct self-loops.\n *\n * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so\n * the generated code does not recurse forever. Refs are followed by name only, so the walk stays\n * linear in the size of the schema graph.\n *\n * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const graph = new Map<string, ReadonlySet<string>>()\n for (const schema of schemas) {\n if (schema.name) graph.set(schema.name, collectSchemaRefs(schema))\n }\n\n return new Set([...graph.keys()].filter((start) => reachesItself(graph, start)))\n}\n\nfunction reachesItself(graph: ReadonlyMap<string, ReadonlySet<string>>, start: string): boolean {\n const visited = new Set<string>()\n const stack: Array<string> = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) return true\n if (visited.has(node)) continue\n visited.add(node)\n for (const next of graph.get(node) ?? []) stack.push(next)\n }\n\n return false\n}\n","export {\n collectImportedRefNames as getImportedNames,\n collectSchemaRefs as getRefNames,\n collectUsedSchemaNames as getUsedNames,\n findCircularSchemas as getCircularNames,\n} from '../utils/schemaGraph.ts'\n"],"mappings":";;;;;;AAUA,MAAM,aAAaA,gBAAAA,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;AAClF,MAAM,kBAAkBA,gBAAAA,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;AACvF,MAAM,aAAaA,gBAAAA,KAAK,OAAwC,EAAE,MAAM,KAAK,CAAC;AAC9E,MAAM,mBAAmBA,gBAAAA,KAAK,OAA0C,EAAE,MAAM,KAAK,CAAC;AACtF,MAAM,wBAAwBA,gBAAAA,KAAK,OAA0C,EAAE,MAAM,KAAK,CAAC;;;;;;AAO3F,SAAS,kBAAkB,MAAkB,EAAE,UAAwD;CACrG,OAAOA,gBAAAA,KAAK,SAAS,kBAAkB,YAAY,YAAY;EAC7D,MAAM,UAA2B,CAAC;EAClC,MAAM,QAAQ,YAA2B;GACvC,IAAI,QAAQ,SAASC,kBAAAA,UAAU,UAAU,QAAQ,SAAS,OAAO;IAC/D,MAAM,OAAOC,aAAAA,eAAe,OAAO;IACnC,IAAI,MAAM,QAAQ,KAAK;KAAE;KAAM,YAAY,QAAQ,QAAQ,GAAG;IAAE,CAA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AAI,IAAiC;CACnD,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,MAAM,MAAM,IAAI,OAAO,MAAM,kBAAkB,MAAM,CAAC;CAGnE,OAAO,IAAI,IAAI,CAAC,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,QAAQ,UAAU,cAAc,OAAO,KAAK,CAAC,CAAC;AACjF;AAEA,SAAS,cAAc,OAAiD,OAAwB;CAC9F,MAAM,0BAAU,IAAI,IAAY;CAChC,MAAM,QAAuB,CAAC,GAAI,MAAM,IAAI,KAAK,KAAK,CAAC,CAAE;CACzD,OAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,IAAI;EACvB,IAAI,SAAS,OAAO,OAAO;EAC3B,IAAI,QAAQ,IAAI,IAAI,GAAG;EACvB,QAAQ,IAAI,IAAI;EAChB,KAAK,MAAM,QAAQ,MAAM,IAAI,IAAI,KAAK,CAAC,GAAG,MAAM,KAAK,IAAI;CAC3D;CAEA,OAAO;AACT"}
|
package/dist/graph.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_graph = require("./graph-
|
|
2
|
+
const require_graph = require("./graph-D-0CbFIv.cjs");
|
|
3
3
|
exports.getCircularNames = require_graph.findCircularSchemas;
|
|
4
4
|
exports.getImportedNames = require_graph.collectImportedRefNames;
|
|
5
5
|
exports.getRefNames = require_graph.collectSchemaRefs;
|
package/dist/graph.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-
|
|
1
|
+
import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-BNf4pYPx.cjs";
|
|
2
2
|
export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
|
package/dist/graph.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-
|
|
1
|
+
import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-BfNUrkK6.js";
|
|
2
2
|
export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
|
package/dist/graph.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as getCircularNames, n as getImportedNames, r as getRefNames, i as getUsedNames } from "./graph-
|
|
1
|
+
export { a as getCircularNames, n as getImportedNames, r as getRefNames, i as getUsedNames } from "./graph-CePbhGIt.js";
|
|
@@ -31,7 +31,8 @@ declare function collectImportedRefNames(node: SchemaNode, { checks }?: {
|
|
|
31
31
|
checks?: boolean;
|
|
32
32
|
}): ReadonlyArray<string>;
|
|
33
33
|
/**
|
|
34
|
-
* Collects the names of all top-level schemas transitively used by a set of operations.
|
|
34
|
+
* Collects the names of all top-level schemas transitively used by a set of operations or schemas.
|
|
35
|
+
* A schema root counts the schemas it references, not itself.
|
|
35
36
|
*
|
|
36
37
|
* An operation uses a schema when its parameters, request body, or responses reference it, directly
|
|
37
38
|
* or through other named schemas. Once a name is added to the result it is not revisited, so
|
|
@@ -50,7 +51,7 @@ declare function collectImportedRefNames(node: SchemaNode, { checks }?: {
|
|
|
50
51
|
* }
|
|
51
52
|
* ```
|
|
52
53
|
*/
|
|
53
|
-
declare function collectUsedSchemaNames(
|
|
54
|
+
declare function collectUsedSchemaNames(roots: ReadonlyArray<OperationNode | SchemaNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
|
|
54
55
|
/**
|
|
55
56
|
* Finds every schema that takes part in a circular dependency chain, including direct self-loops.
|
|
56
57
|
*
|
|
@@ -31,7 +31,8 @@ declare function collectImportedRefNames(node: SchemaNode, { checks }?: {
|
|
|
31
31
|
checks?: boolean;
|
|
32
32
|
}): ReadonlyArray<string>;
|
|
33
33
|
/**
|
|
34
|
-
* Collects the names of all top-level schemas transitively used by a set of operations.
|
|
34
|
+
* Collects the names of all top-level schemas transitively used by a set of operations or schemas.
|
|
35
|
+
* A schema root counts the schemas it references, not itself.
|
|
35
36
|
*
|
|
36
37
|
* An operation uses a schema when its parameters, request body, or responses reference it, directly
|
|
37
38
|
* or through other named schemas. Once a name is added to the result it is not revisited, so
|
|
@@ -50,7 +51,7 @@ declare function collectImportedRefNames(node: SchemaNode, { checks }?: {
|
|
|
50
51
|
* }
|
|
51
52
|
* ```
|
|
52
53
|
*/
|
|
53
|
-
declare function collectUsedSchemaNames(
|
|
54
|
+
declare function collectUsedSchemaNames(roots: ReadonlyArray<OperationNode | SchemaNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
|
|
54
55
|
/**
|
|
55
56
|
* Finds every schema that takes part in a circular dependency chain, including direct self-loops.
|
|
56
57
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-
|
|
1
|
+
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-DJqd2j3y.cjs";
|
|
2
2
|
import { $ as PropertyNode, D as InputNode, G as SchemaNode, Q as createSchema, _ as createParameter, a as OperationsNode, d as createResponse, et as createProperty, f as RequestBodyNode, h as ParameterNode, i as OperationNode, j as createInput, l as ResponseNode, o as createOperation, p as createRequestBody, s as createOperations, v as ContentNode, x as createContent } from "./operation-De4lbIZS.cjs";
|
|
3
3
|
declare namespace index_d_exports {
|
|
4
4
|
export { ExportInput, ImportInput, ModuleName, Node, Space, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createOperations, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as nodeKinds } from "./base-A-xF4pUL.js";
|
|
2
|
-
import { g as CodeNode } from "./file-
|
|
3
|
-
import { a as collect, s as transform } from "./visitor-
|
|
2
|
+
import { g as CodeNode } from "./file-Dg70hXm3.js";
|
|
3
|
+
import { a as collect, s as transform } from "./visitor-BNGMMmpe.js";
|
|
4
4
|
/**
|
|
5
5
|
* Extracts all string content from a `CodeNode` tree recursively.
|
|
6
6
|
* Collects the text fields and nested node content, to build the source string for import filtering.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-
|
|
1
|
+
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-Dg70hXm3.js";
|
|
2
2
|
import { $ as PropertyNode, D as InputNode, G as SchemaNode, Q as createSchema, _ as createParameter, a as OperationsNode, d as createResponse, et as createProperty, f as RequestBodyNode, h as ParameterNode, i as OperationNode, j as createInput, l as ResponseNode, o as createOperation, p as createRequestBody, s as createOperations, v as ContentNode, x as createContent } from "./operation-Dd0-l2VB.js";
|
|
3
3
|
declare namespace index_d_exports {
|
|
4
4
|
export { ExportInput, ImportInput, ModuleName, Node, Space, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createOperations, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as nodeKinds } from "./base-CyJhBRMi.cjs";
|
|
2
|
-
import { g as CodeNode } from "./file-
|
|
3
|
-
import { a as collect, s as transform } from "./visitor-
|
|
2
|
+
import { g as CodeNode } from "./file-DJqd2j3y.cjs";
|
|
3
|
+
import { a as collect, s as transform } from "./visitor-BN5QJX7-.cjs";
|
|
4
4
|
/**
|
|
5
5
|
* Extracts all string content from a `CodeNode` tree recursively.
|
|
6
6
|
* Collects the text fields and nested node content, to build the source string for import filtering.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $ as PropertyNode, G as SchemaNode, J as StringSchemaNode } from "./operation-De4lbIZS.cjs";
|
|
2
2
|
import { a as schemaTypes } from "./base-CyJhBRMi.cjs";
|
|
3
3
|
import { n as narrowSchema } from "./guards-B6LgmDhJ.cjs";
|
|
4
|
-
import { o as findSchema } from "./visitor-
|
|
4
|
+
import { o as findSchema } from "./visitor-BN5QJX7-.cjs";
|
|
5
5
|
/**
|
|
6
6
|
* Generic JSON Schema optionality: a non-required field is optional, and a
|
|
7
7
|
* non-required nullable field is nullish.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace index_d_exports {
|
|
2
|
-
export { getBase, isJson };
|
|
2
|
+
export { MediaTypeInput, getBase, isJson };
|
|
3
3
|
}
|
|
4
4
|
type MediaTypeInput = string | {
|
|
5
5
|
contentType: string;
|
|
@@ -8,4 +8,4 @@ type MediaTypeInput = string | {
|
|
|
8
8
|
declare function getBase(mediaType: MediaTypeInput): string;
|
|
9
9
|
/** Whether the media type is `application/json`, `text/json`, or has a `+json` suffix. */
|
|
10
10
|
declare function isJson(mediaType: MediaTypeInput): boolean;
|
|
11
|
-
export {
|
|
11
|
+
export { isJson as i, getBase as n, index_d_exports as r, MediaTypeInput as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-
|
|
1
|
+
import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-DJqd2j3y.cjs";
|
|
2
2
|
type InlineFilesResult = {
|
|
3
3
|
/**
|
|
4
4
|
* Files that imported an inline name, rewritten to hold its definition.
|
|
@@ -40,13 +40,26 @@ type InlineFilesOptions = {
|
|
|
40
40
|
* declaration, until no inline names are left. The definitions' own imports move to the importing file.
|
|
41
41
|
*/
|
|
42
42
|
declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
|
|
43
|
+
/**
|
|
44
|
+
* Module specifier that imports `filePath` from the file at `root`: POSIX, relative to that file's directory, `./`-prefixed unless it climbs with `../`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* getRelativePath('/root/src/models/pet.ts', '/root/lib/client.ts') // '../../lib/client.ts'
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function getRelativePath(root: string, filePath: string): string;
|
|
43
52
|
/**
|
|
44
53
|
* Returns the names an import or export brings across. A node built with the deprecated fields gets them from
|
|
45
54
|
* those, each with an explicit `space`, so it prints exactly as before.
|
|
46
55
|
*/
|
|
47
56
|
declare function getNames(node: ImportNode | ExportNode): Array<ModuleName>;
|
|
57
|
+
/**
|
|
58
|
+
* Returns `true` when a source is an exported declaration. Reads the deprecated `isIndexable` and `isExportable`, in that order, when `export` is unset.
|
|
59
|
+
*/
|
|
60
|
+
declare function isExported(source: Pick<SourceNode, 'export' | 'isIndexable' | 'isExportable'>): boolean;
|
|
48
61
|
declare function getSpace(source: SourceNode): Space;
|
|
49
62
|
declare namespace index_d_exports {
|
|
50
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
63
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
|
51
64
|
}
|
|
52
|
-
export {
|
|
65
|
+
export { getRelativePath as a, isExported as i, getNames as n, InlineLanguage as o, getSpace as r, inlineFiles as s, index_d_exports as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Node } from "./index-
|
|
2
|
-
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-
|
|
1
|
+
import { t as Node } from "./index-BjmAaymt.cjs";
|
|
2
|
+
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-BN5QJX7-.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
|
|
5
5
|
* and `undefined` keeps declaration order.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Node } from "./index-
|
|
2
|
-
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-
|
|
1
|
+
import { t as Node } from "./index-Bz33tfQo.js";
|
|
2
|
+
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-BNGMMmpe.js";
|
|
3
3
|
/**
|
|
4
4
|
* Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
|
|
5
5
|
* and `undefined` keeps declaration order.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $ as PropertyNode, G as SchemaNode, J as StringSchemaNode } from "./operation-Dd0-l2VB.js";
|
|
2
2
|
import { a as schemaTypes } from "./base-A-xF4pUL.js";
|
|
3
3
|
import { n as narrowSchema } from "./guards-l2AsKeHR.js";
|
|
4
|
-
import { o as findSchema } from "./visitor-
|
|
4
|
+
import { o as findSchema } from "./visitor-BNGMMmpe.js";
|
|
5
5
|
/**
|
|
6
6
|
* Generic JSON Schema optionality: a non-required field is optional, and a
|
|
7
7
|
* non-required nullable field is nullish.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace index_d_exports {
|
|
2
|
-
export { getBase, isJson };
|
|
2
|
+
export { MediaTypeInput, getBase, isJson };
|
|
3
3
|
}
|
|
4
4
|
type MediaTypeInput = string | {
|
|
5
5
|
contentType: string;
|
|
@@ -8,4 +8,4 @@ type MediaTypeInput = string | {
|
|
|
8
8
|
declare function getBase(mediaType: MediaTypeInput): string;
|
|
9
9
|
/** Whether the media type is `application/json`, `text/json`, or has a `+json` suffix. */
|
|
10
10
|
declare function isJson(mediaType: MediaTypeInput): boolean;
|
|
11
|
-
export {
|
|
11
|
+
export { isJson as i, getBase as n, index_d_exports as r, MediaTypeInput as t };
|