oazapfts 7.0.0-beta.2 → 7.0.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/cli.cjs +2 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/context-j-dMIA6M.js +572 -0
- package/dist/context-j-dMIA6M.js.map +1 -0
- package/dist/context-lKBK5qCf.cjs +7 -0
- package/dist/context-lKBK5qCf.cjs.map +1 -0
- package/dist/context.cjs +2 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.ts +269 -0
- package/dist/context.js +7 -0
- package/dist/context.js.map +1 -0
- package/dist/index-0o7BUGZA.js +1085 -0
- package/dist/index-0o7BUGZA.js.map +1 -0
- package/dist/index-BTckgXdX.cjs +8 -0
- package/dist/index-BTckgXdX.cjs.map +1 -0
- package/dist/index.cjs +1 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +11 -1658
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs +2 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.ts +390 -0
- package/dist/plugin.js +43 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-j-dMIA6M.js","sources":["../src/helpers/getOnlyModeSuffix.ts","../src/helpers/toIdentifier.ts","../src/generate/tscodegen.ts","../src/generate/generateServers.ts","../src/context.ts"],"sourcesContent":["import { OnlyMode } from \"../context\";\n\nconst onlyModeSuffixes: Record<OnlyMode, string> = {\n readOnly: \"Read\",\n writeOnly: \"Write\",\n};\n\nexport function getOnlyModeSuffix(onlyMode?: OnlyMode) {\n if (!onlyMode) return \"\";\n return onlyModeSuffixes[onlyMode];\n}\n","import _ from \"lodash\";\nimport { OnlyMode } from \"../context\";\nimport { isValidIdentifier } from \"../generate/tscodegen\";\nimport { getOnlyModeSuffix } from \"./getOnlyModeSuffix\";\n\nexport function toIdentifier(s: string, upper = false, onlyMode?: OnlyMode) {\n let cc = _.camelCase(s) + getOnlyModeSuffix(onlyMode);\n if (upper) cc = _.upperFirst(cc);\n if (isValidIdentifier(cc)) return cc;\n return \"$\" + cc;\n}\n","import ts from \"typescript\";\nimport { toIdentifier } from \"../helpers/toIdentifier\";\n\nconst factory = ts.factory;\n\nexport const questionToken = factory.createToken(ts.SyntaxKind.QuestionToken);\n\nexport function createQuestionToken(token?: boolean | ts.QuestionToken) {\n if (!token) return undefined;\n if (token === true) return questionToken;\n return token;\n}\n\nexport const keywordType = {\n any: factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n number: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n integer: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n object: factory.createKeywordTypeNode(ts.SyntaxKind.ObjectKeyword),\n string: factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n boolean: factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),\n undefined: factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),\n void: factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword),\n never: factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword),\n null: factory.createLiteralTypeNode(factory.createNull()),\n unknown: factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),\n};\n\ntype KeywordTypeName = keyof typeof keywordType;\n\nexport function createKeywordType(type: KeywordTypeName) {\n return keywordType[type];\n}\n\nexport const modifier = {\n async: factory.createModifier(ts.SyntaxKind.AsyncKeyword),\n export: factory.createModifier(ts.SyntaxKind.ExportKeyword),\n};\n\nexport function createLiteral(v: string | boolean | number) {\n switch (typeof v) {\n case \"string\":\n return factory.createStringLiteral(v);\n case \"boolean\":\n return v ? factory.createTrue() : factory.createFalse();\n case \"number\":\n return String(v).charAt(0) === \"-\"\n ? factory.createPrefixUnaryExpression(\n ts.SyntaxKind.MinusToken,\n factory.createNumericLiteral(String(-v)),\n )\n : factory.createNumericLiteral(String(v));\n }\n}\n\nexport function createEnumTypeNode(values: Array<string | boolean | number>) {\n const types = values.map((v) =>\n v === null\n ? keywordType.null\n : factory.createLiteralTypeNode(createLiteral(v)),\n );\n return types.length > 1 ? factory.createUnionTypeNode(types) : types[0];\n}\n\nexport function createTypeAliasDeclaration({\n modifiers,\n name,\n typeParameters,\n type,\n}: {\n modifiers?: Array<ts.Modifier>;\n name: string | ts.Identifier;\n typeParameters?: Array<ts.TypeParameterDeclaration>;\n type: ts.TypeNode;\n}) {\n return factory.createTypeAliasDeclaration(\n modifiers,\n name,\n typeParameters,\n type,\n );\n}\n\nexport function createInterfaceAliasDeclaration({\n modifiers,\n name,\n typeParameters,\n type,\n inheritedNodeNames,\n}: {\n modifiers?: Array<ts.Modifier>;\n name: string | ts.Identifier;\n typeParameters?: Array<ts.TypeParameterDeclaration>;\n type: ts.TypeNode;\n inheritedNodeNames?: (string | ts.Identifier)[];\n}) {\n const heritageClauses = inheritedNodeNames\n ? [\n factory.createHeritageClause(\n ts.SyntaxKind.ExtendsKeyword,\n inheritedNodeNames.map((name) => {\n const extendedInterfaceName =\n typeof name === \"string\" ? name : name.escapedText.toString();\n return factory.createExpressionWithTypeArguments(\n factory.createIdentifier(\n toIdentifier(extendedInterfaceName, true),\n ),\n undefined,\n );\n }),\n ),\n ]\n : [];\n return factory.createInterfaceDeclaration(\n modifiers,\n name,\n typeParameters,\n heritageClauses,\n (type as ts.TypeLiteralNode).members,\n );\n}\n\nexport function toExpression(ex: ts.Expression | string) {\n if (typeof ex === \"string\") return factory.createIdentifier(ex);\n return ex;\n}\n\nexport function createCall(\n expression: ts.Expression | string,\n {\n typeArgs,\n args,\n }: {\n typeArgs?: Array<ts.TypeNode>;\n args?: Array<ts.Expression>;\n } = {},\n) {\n return factory.createCallExpression(toExpression(expression), typeArgs, args);\n}\n\nexport function createMethodCall(\n method: string,\n opts: {\n typeArgs?: Array<ts.TypeNode>;\n args?: Array<ts.Expression>;\n },\n) {\n return createCall(\n factory.createPropertyAccessExpression(factory.createThis(), method),\n opts,\n );\n}\n\nexport function createObjectLiteral(props: [string, string | ts.Expression][]) {\n return factory.createObjectLiteralExpression(\n props.map(([name, identifier]) =>\n createPropertyAssignment(name, toExpression(identifier)),\n ),\n true,\n );\n}\n\nexport function createPropertyAssignment(\n name: string,\n expression: ts.Expression,\n) {\n if (ts.isIdentifier(expression)) {\n if (expression.text === name) {\n return factory.createShorthandPropertyAssignment(name);\n }\n }\n return factory.createPropertyAssignment(propertyName(name), expression);\n}\n\nexport function block(...statements: ts.Statement[]) {\n return factory.createBlock(statements, true);\n}\n\nexport function createArrowFunction(\n parameters: ts.ParameterDeclaration[],\n body: ts.ConciseBody,\n {\n modifiers,\n typeParameters,\n type,\n equalsGreaterThanToken,\n }: {\n modifiers?: ts.Modifier[];\n typeParameters?: ts.TypeParameterDeclaration[];\n type?: ts.TypeNode;\n equalsGreaterThanToken?: ts.EqualsGreaterThanToken;\n } = {},\n) {\n return factory.createArrowFunction(\n modifiers,\n typeParameters,\n parameters,\n type,\n equalsGreaterThanToken,\n body,\n );\n}\n\nexport function createFunctionDeclaration(\n name: string | ts.Identifier | undefined,\n {\n modifiers,\n asteriskToken,\n typeParameters,\n type,\n }: {\n modifiers?: ts.Modifier[];\n asteriskToken?: ts.AsteriskToken;\n typeParameters?: ts.TypeParameterDeclaration[];\n type?: ts.TypeNode;\n },\n parameters: ts.ParameterDeclaration[],\n body?: ts.Block,\n): ts.FunctionDeclaration {\n return factory.createFunctionDeclaration(\n modifiers,\n asteriskToken,\n name,\n typeParameters,\n parameters,\n type,\n body,\n );\n}\n\nexport function createClassDeclaration({\n modifiers,\n name,\n typeParameters,\n heritageClauses,\n members,\n}: {\n modifiers?: Array<ts.Modifier>;\n name?: string | ts.Identifier;\n typeParameters?: Array<ts.TypeParameterDeclaration>;\n heritageClauses?: Array<ts.HeritageClause>;\n members: Array<ts.ClassElement>;\n}) {\n return factory.createClassDeclaration(\n modifiers,\n name,\n typeParameters,\n heritageClauses,\n members,\n );\n}\n\nexport function createConstructor({\n modifiers,\n parameters,\n body,\n}: {\n modifiers?: Array<ts.Modifier>;\n parameters: Array<ts.ParameterDeclaration>;\n body?: ts.Block;\n}) {\n return factory.createConstructorDeclaration(modifiers, parameters, body);\n}\n\nexport function createMethod(\n name:\n | string\n | ts.Identifier\n | ts.StringLiteral\n | ts.NumericLiteral\n | ts.ComputedPropertyName,\n {\n modifiers,\n asteriskToken,\n questionToken,\n typeParameters,\n type,\n }: {\n modifiers?: ts.Modifier[];\n asteriskToken?: ts.AsteriskToken;\n questionToken?: ts.QuestionToken | boolean;\n typeParameters?: ts.TypeParameterDeclaration[];\n type?: ts.TypeNode;\n } = {},\n parameters: ts.ParameterDeclaration[] = [],\n body?: ts.Block,\n): ts.MethodDeclaration {\n return factory.createMethodDeclaration(\n modifiers,\n asteriskToken,\n name,\n createQuestionToken(questionToken),\n typeParameters,\n parameters,\n type,\n body,\n );\n}\n\nexport function createParameter(\n name: string | ts.BindingName,\n {\n modifiers,\n dotDotDotToken,\n questionToken,\n type,\n initializer,\n }: {\n modifiers?: Array<ts.Modifier>;\n dotDotDotToken?: ts.DotDotDotToken;\n questionToken?: ts.QuestionToken | boolean;\n type?: ts.TypeNode;\n initializer?: ts.Expression;\n },\n): ts.ParameterDeclaration {\n return factory.createParameterDeclaration(\n modifiers,\n dotDotDotToken,\n name,\n createQuestionToken(questionToken),\n type,\n initializer,\n );\n}\n\nfunction propertyName(name: string | ts.PropertyName): ts.PropertyName {\n if (typeof name === \"string\") {\n return isValidIdentifier(name)\n ? factory.createIdentifier(name)\n : factory.createStringLiteral(name);\n }\n return name;\n}\n\nexport function createPropertySignature({\n modifiers,\n name,\n questionToken,\n type,\n}: {\n modifiers?: Array<ts.Modifier>;\n name: ts.PropertyName | string;\n questionToken?: ts.QuestionToken | boolean;\n type?: ts.TypeNode;\n}) {\n return factory.createPropertySignature(\n modifiers,\n propertyName(name),\n createQuestionToken(questionToken),\n type,\n );\n}\n\nexport function createIndexSignature(\n type: ts.TypeNode,\n {\n modifiers,\n indexName = \"key\",\n indexType = keywordType.string,\n }: {\n indexName?: string;\n indexType?: ts.TypeNode;\n modifiers?: Array<ts.Modifier>;\n } = {},\n) {\n return factory.createIndexSignature(\n modifiers,\n [createParameter(indexName, { type: indexType })],\n type,\n );\n}\n\nexport function createObjectBinding(\n elements: Array<{\n name: string | ts.BindingName;\n dotDotDotToken?: ts.DotDotDotToken;\n propertyName?: string | ts.PropertyName;\n initializer?: ts.Expression;\n }>,\n) {\n return factory.createObjectBindingPattern(\n elements.map(({ dotDotDotToken, propertyName, name, initializer }) =>\n factory.createBindingElement(\n dotDotDotToken,\n propertyName,\n name,\n initializer,\n ),\n ),\n );\n}\n\nexport function createTemplateString(\n head: string,\n spans: Array<{ literal: string; expression: ts.Expression }>,\n) {\n if (!spans.length) return factory.createStringLiteral(head);\n return factory.createTemplateExpression(\n factory.createTemplateHead(head),\n spans.map(({ expression, literal }, i) =>\n factory.createTemplateSpan(\n expression,\n i === spans.length - 1\n ? factory.createTemplateTail(literal)\n : factory.createTemplateMiddle(literal),\n ),\n ),\n );\n}\n\nexport function findNode<T extends ts.Node>(\n nodes: ts.NodeArray<ts.Node>,\n kind: T extends { kind: infer K } ? K : never,\n test?: (node: T) => boolean | undefined,\n): T {\n const node = nodes.find(\n (s) => s.kind === kind && (!test || test(s as T)),\n ) as T;\n if (!node) throw new Error(`Node not found: ${kind}`);\n return node;\n}\n\nexport function getName(name: ts.Node) {\n if (ts.isIdentifier(name)) {\n return name.escapedText;\n }\n if (ts.isLiteralExpression(name)) {\n return name.text;\n }\n return \"\";\n}\n\nexport function getFirstDeclarationName(n: ts.VariableStatement) {\n const name = ts.getNameOfDeclaration(n.declarationList.declarations[0]);\n return name ? getName(name) : \"\";\n}\n\nexport function findFirstVariableDeclaration(\n nodes: ts.NodeArray<ts.Node>,\n name: string,\n) {\n const statement = findNode<ts.VariableStatement>(\n nodes,\n ts.SyntaxKind.VariableStatement,\n (n) => getFirstDeclarationName(n) === name,\n );\n const [first] = statement.declarationList.declarations;\n if (!first) throw new Error(`Missing ${name} declaration`);\n return first;\n}\n\nexport function changePropertyValue(\n o: ts.ObjectLiteralExpression,\n property: string,\n value: ts.Expression,\n) {\n const p = o.properties.find(\n (p) => ts.isPropertyAssignment(p) && getName(p.name) === property,\n );\n if (p && ts.isPropertyAssignment(p)) {\n // p.initializer is readonly, this might break in a future TS version, but works fine for now.\n Object.assign(p, { initializer: value });\n } else {\n throw new Error(`No such property: ${property}`);\n }\n}\n\ntype Visitor = (\n node: ts.Node,\n context: ts.TransformationContext,\n) => void | ts.Node;\n\nfunction createTransformer(visitor: Visitor) {\n return <T extends ts.Node>(context: ts.TransformationContext) =>\n (rootNode: T) => {\n function visit(node: ts.Node): ts.Node {\n const result = visitor(node, context);\n\n if (result) {\n return result;\n }\n\n return ts.visitEachChild(node, visit, context);\n }\n\n return ts.visitNode(rootNode, visit);\n };\n}\n\nexport function transform<T extends ts.Node>(\n source: T,\n ...visitors: Visitor[]\n) {\n const result = ts.transform(source, visitors.map(createTransformer));\n\n return result.transformed[0] as T;\n}\n\nexport function appendNodes<T extends ts.Node>(\n array: ts.NodeArray<T>,\n ...nodes: T[]\n) {\n return factory.createNodeArray([...array, ...nodes]);\n}\n\nexport function addComment<T extends ts.Node>(node: T, comment?: string) {\n if (!comment) return node;\n return ts.addSyntheticLeadingComment(\n node,\n ts.SyntaxKind.MultiLineCommentTrivia,\n `*\\n * ${comment.replace(/\\n/g, \"\\n * \")}\\n `,\n true,\n );\n}\n\nconst printer = ts.createPrinter({\n newLine: ts.NewLineKind.LineFeed,\n});\n\nexport function printNode(node: ts.Node) {\n const file = ts.createSourceFile(\n \"someFileName.ts\",\n \"\",\n ts.ScriptTarget.Latest,\n /*setParentNodes*/ false,\n ts.ScriptKind.TS,\n );\n return printer.printNode(ts.EmitHint.Unspecified, node, file);\n}\n\nexport function printNodes(nodes: ts.Node[]) {\n const file = ts.createSourceFile(\n \"someFileName.ts\",\n \"\",\n ts.ScriptTarget.Latest,\n /*setParentNodes*/ false,\n ts.ScriptKind.TS,\n );\n return nodes\n .map((node) => printer.printNode(ts.EmitHint.Unspecified, node, file))\n .join(\"\\n\");\n}\n\nexport function printFile(sourceFile: ts.SourceFile) {\n return printer.printFile(sourceFile);\n}\n\nexport function isValidIdentifier(str: string) {\n if (!str.length || str.trim() !== str) return false;\n const node = ts.parseIsolatedEntityName(str, ts.ScriptTarget.Latest);\n return (\n !!node &&\n node.kind === ts.SyntaxKind.Identifier &&\n ts.identifierToKeywordKind(node) === undefined\n );\n}\n\nexport function updateVariableDeclaration(\n node: ts.VariableDeclaration,\n updates: Partial<ts.VariableDeclaration>,\n) {\n return ts.factory.updateVariableDeclaration(\n node,\n updates.name || node.name,\n updates.exclamationToken || node.exclamationToken,\n updates.type || node.type,\n updates.initializer || node.initializer,\n );\n}\n\nexport function updateFunctionDeclaration(\n node: ts.FunctionDeclaration,\n updates: Partial<ts.FunctionDeclaration>,\n) {\n return ts.factory.updateFunctionDeclaration(\n node,\n updates.modifiers || node.modifiers,\n updates.asteriskToken || node.asteriskToken,\n updates.name || node.name,\n updates.typeParameters || node.typeParameters,\n updates.parameters || node.parameters,\n updates.type || node.type,\n updates.body || node.body,\n );\n}\n","import _ from \"lodash\";\nimport * as cg from \"./tscodegen\";\nimport ts from \"typescript\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { ServerObject } from \"../helpers/openApi3-x\";\n\nconst factory = ts.factory;\n\nfunction createTemplate(url: string) {\n const tokens = url.split(/{([\\s\\S]+?)}/g);\n const chunks = _.chunk(tokens.slice(1), 2);\n return cg.createTemplateString(\n tokens[0],\n chunks.map(([expression, literal]) => ({\n expression: factory.createIdentifier(expression),\n literal,\n })),\n );\n}\n\nfunction createServerFunction(\n template: string,\n vars: Record<string, OpenAPIV3.ServerVariableObject>,\n) {\n const params = [\n cg.createParameter(\n cg.createObjectBinding(\n Object.entries(vars || {}).map(([name, value]) => {\n return {\n name,\n initializer: cg.createLiteral(value.default),\n };\n }),\n ),\n {\n type: factory.createTypeLiteralNode(\n Object.entries(vars || {}).map(([name, value]) => {\n return cg.createPropertySignature({\n name,\n type: value.enum\n ? cg.createEnumTypeNode(value.enum)\n : factory.createUnionTypeNode([\n cg.keywordType.string,\n cg.keywordType.number,\n cg.keywordType.boolean,\n ]),\n });\n }),\n ),\n },\n ),\n ];\n\n return cg.createArrowFunction(params, createTemplate(template));\n}\n\nfunction generateServerExpression(server: ServerObject) {\n return server.variables\n ? createServerFunction(server.url, server.variables)\n : factory.createStringLiteral(server.url);\n}\n\nfunction defaultUrl(server?: ServerObject) {\n if (!server) return \"/\";\n const { url, variables } = server;\n if (!variables) return url;\n return url.replace(/\\{(.+?)\\}/g, (m, name) =>\n variables[name] ? String(variables[name].default) : m,\n );\n}\n\nexport function defaultBaseUrl(servers?: ServerObject[]) {\n return defaultUrl(servers?.[0]);\n}\n\nfunction serverName(server: ServerObject, index: number) {\n return server.description\n ? _.camelCase(server.description.replace(/\\W+/, \" \"))\n : `server${index + 1}`;\n}\n\nexport function generateServers(servers: ServerObject[]) {\n return cg.createObjectLiteral(\n servers.map((server, i) => [\n serverName(server, i),\n generateServerExpression(server),\n ]),\n );\n}\n\nexport function createServersStatement(servers: ServerObject[]) {\n return ts.factory.createVariableStatement(\n [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n \"servers\",\n undefined,\n undefined,\n generateServers(servers),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n","import ts, {\n InterfaceDeclaration,\n Statement,\n TypeAliasDeclaration,\n TypeReferenceNode,\n} from \"typescript\";\nimport type { OazapftsOptions } from \"./\";\nimport type {\n Document,\n SchemaObject,\n ServerObject,\n} from \"./helpers/openApi3-x\";\nimport { defaultBaseUrl } from \"./generate/generateServers\";\nimport _ from \"lodash\";\nimport { CustomHeaders } from \"@oazapfts/runtime\";\n\n// ─── Data types for template parts ──────────────────────────────────────────\n\nexport type ImportSpecifier = {\n name: string;\n as?: string;\n};\nexport type DefaultImport = [string, { from: string }];\nexport type NamespaceImport = [{ namespace: string }, { from: string }];\nexport type ImportsWithoutDefault = [\n (ImportSpecifier | string)[],\n { from: string },\n];\nexport type ImportWithDefault = [\n string,\n (ImportSpecifier | string)[],\n { from: string },\n];\n\nexport type Import =\n | string\n | ImportsWithoutDefault\n | DefaultImport\n | ImportWithDefault\n | NamespaceImport;\n\nexport type OnlyMode = \"readOnly\" | \"writeOnly\";\nexport type OnlyModes = Record<OnlyMode, boolean>;\n\nexport type ReadonlyDeep<T> = {\n readonly [P in keyof T]: ReadonlyDeep<T[P]>;\n};\n\nexport type Defaults = {\n baseUrl?: string;\n headers?: CustomHeaders;\n FormData?: ts.ClassExpression | ts.Identifier;\n fetch?: ts.FunctionExpression | ts.ArrowFunction | ts.Identifier;\n};\n\nexport type OazapftsContext = {\n readonly opts: ReadonlyDeep<OazapftsOptions>;\n readonly spec: Document;\n\n /** Banner comment at the top of the file (the text content, not including comment markers) */\n banner: string;\n /** Import declarations (AST nodes) */\n imports: Import[];\n /** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */\n defaults: Defaults;\n /** Server definitions - will be generated as `export const servers = { ... }` */\n servers: ServerObject[];\n /** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */\n init: Statement[];\n\n // see `preprocessComponents` for the definition of a discriminating schema\n discriminatingSchemas: Set<SchemaObject>;\n\n aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];\n\n enumAliases: Statement[];\n enumRefs: Record<string, { values: string; type: TypeReferenceNode }>;\n\n // Collect the types of all referenced schemas so we can export them later\n // Referenced schemas can be pointing at the following versions:\n // - \"base\": The regular type/interface e.g. ExampleSchema\n // - \"readOnly\": The readOnly version e.g. ExampleSchemaRead\n // - \"writeOnly\": The writeOnly version e.g. ExampleSchemaWrite\n refs: Record<\n string,\n {\n base: TypeReferenceNode;\n readOnly?: TypeReferenceNode;\n writeOnly?: TypeReferenceNode;\n }\n >;\n\n // Maps a referenced schema to its readOnly/writeOnly status\n // This field should be used exclusively within the `checkSchemaOnlyMode` method\n refsOnlyMode: Map<string, OnlyModes>;\n\n // Keep track of already used type aliases\n typeAliases: Record<string, number>;\n};\n\nexport function createContext(\n inputSpec: Document,\n opts: OazapftsContext[\"opts\"] = {},\n): OazapftsContext {\n const spec = _.cloneDeep(inputSpec);\n\n return {\n opts,\n spec,\n\n // Template parts\n banner: `DO NOT MODIFY - This file has been generated using oazapfts.\nSee https://www.npmjs.com/package/oazapfts`,\n imports: [\n [{ namespace: \"Oazapfts\" }, { from: \"@oazapfts/runtime\" }],\n [{ namespace: \"QS\" }, { from: \"@oazapfts/runtime/query\" }],\n ],\n defaults: { baseUrl: defaultBaseUrl(spec.servers), headers: {} },\n servers: spec.servers || [],\n init: createInit(),\n\n // Internal state\n discriminatingSchemas: new Set(),\n aliases: [],\n enumAliases: [],\n enumRefs: {},\n refs: {},\n refsOnlyMode: new Map(),\n typeAliases: {},\n };\n}\n\n/** Creates: const oazapfts = Oazapfts.runtime(defaults); */\nfunction createInit(): Statement[] {\n return [\n ts.factory.createVariableStatement(\n undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n \"oazapfts\",\n undefined,\n undefined,\n ts.factory.createCallExpression(\n ts.factory.createPropertyAccessExpression(\n ts.factory.createIdentifier(\"Oazapfts\"),\n \"runtime\",\n ),\n undefined,\n [ts.factory.createIdentifier(\"defaults\")],\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n ];\n}\n"],"names":["onlyModeSuffixes","getOnlyModeSuffix","onlyMode","toIdentifier","s","upper","cc","_","isValidIdentifier","factory","ts","questionToken","createQuestionToken","token","keywordType","createKeywordType","type","modifier","createLiteral","v","createEnumTypeNode","values","types","createTypeAliasDeclaration","modifiers","name","typeParameters","createInterfaceAliasDeclaration","inheritedNodeNames","heritageClauses","extendedInterfaceName","toExpression","ex","createCall","expression","typeArgs","args","createMethodCall","method","opts","createObjectLiteral","props","identifier","createPropertyAssignment","propertyName","block","statements","createArrowFunction","parameters","body","equalsGreaterThanToken","createFunctionDeclaration","asteriskToken","createClassDeclaration","members","createConstructor","createMethod","createParameter","dotDotDotToken","initializer","createPropertySignature","createIndexSignature","indexName","indexType","createObjectBinding","elements","createTemplateString","head","spans","literal","i","findNode","nodes","kind","test","node","getName","getFirstDeclarationName","n","findFirstVariableDeclaration","statement","first","changePropertyValue","o","property","value","p","createTransformer","visitor","context","rootNode","visit","result","transform","source","visitors","appendNodes","array","addComment","comment","printer","printNode","file","printNodes","printFile","sourceFile","str","updateVariableDeclaration","updates","updateFunctionDeclaration","createTemplate","url","tokens","chunks","cg.createTemplateString","createServerFunction","template","vars","params","cg.createParameter","cg.createObjectBinding","cg.createLiteral","cg.createPropertySignature","cg.createEnumTypeNode","cg.keywordType","cg.createArrowFunction","generateServerExpression","server","defaultUrl","variables","m","defaultBaseUrl","servers","serverName","index","generateServers","cg.createObjectLiteral","createServersStatement","createContext","inputSpec","spec","createInit"],"mappings":";;AAEA,MAAMA,IAA6C;AAAA,EACjD,UAAU;AAAA,EACV,WAAW;AACb;AAEO,SAASC,EAAkBC,GAAqB;AACrD,SAAKA,IACEF,EAAiBE,CAAQ,IADV;AAExB;ACLO,SAASC,EAAaC,GAAWC,IAAQ,IAAOH,GAAqB;AAC1E,MAAII,IAAKC,EAAE,UAAUH,CAAC,IAAIH,EAAkBC,CAAQ;AAEpD,SADIG,MAAOC,IAAKC,EAAE,WAAWD,CAAE,IAC3BE,EAAkBF,CAAE,IAAUA,IAC3B,MAAMA;AACf;ACPA,MAAMG,IAAUC,EAAG,SAENC,IAAgBF,EAAQ,YAAYC,EAAG,WAAW,aAAa;AAErE,SAASE,EAAoBC,GAAoC;AACtE,MAAKA;AACL,WAAIA,MAAU,KAAaF,IACpBE;AACT;AAEO,MA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,QAEFA,EAAG,UAAU;AAAA,MAAA;AAAA,IACf;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";const r=require("typescript"),l=require("lodash"),q={readOnly:"Read",writeOnly:"Write"};function B(e){return e?q[e]:""}function k(e,t=!1,n){let i=l.camelCase(e)+B(n);return t&&(i=l.upperFirst(i)),m(i)?i:"$"+i}const a=r.factory,E=a.createToken(r.SyntaxKind.QuestionToken);function f(e){if(e)return e===!0?E:e}const s={any:a.createKeywordTypeNode(r.SyntaxKind.AnyKeyword),number:a.createKeywordTypeNode(r.SyntaxKind.NumberKeyword),integer:a.createKeywordTypeNode(r.SyntaxKind.NumberKeyword),object:a.createKeywordTypeNode(r.SyntaxKind.ObjectKeyword),string:a.createKeywordTypeNode(r.SyntaxKind.StringKeyword),boolean:a.createKeywordTypeNode(r.SyntaxKind.BooleanKeyword),undefined:a.createKeywordTypeNode(r.SyntaxKind.UndefinedKeyword),void:a.createKeywordTypeNode(r.SyntaxKind.VoidKeyword),never:a.createKeywordTypeNode(r.SyntaxKind.NeverKeyword),null:a.createLiteralTypeNode(a.createNull()),unknown:a.createKeywordTypeNode(r.SyntaxKind.UnknownKeyword)};function $(e){return s[e]}const F={async:a.createModifier(r.SyntaxKind.AsyncKeyword),export:a.createModifier(r.SyntaxKind.ExportKeyword)};function y(e){switch(typeof e){case"string":return a.createStringLiteral(e);case"boolean":return e?a.createTrue():a.createFalse();case"number":return String(e).charAt(0)==="-"?a.createPrefixUnaryExpression(r.SyntaxKind.MinusToken,a.createNumericLiteral(String(-e))):a.createNumericLiteral(String(e))}}function S(e){const t=e.map(n=>n===null?s.null:a.createLiteralTypeNode(y(n)));return t.length>1?a.createUnionTypeNode(t):t[0]}function C({modifiers:e,name:t,typeParameters:n,type:i}){return a.createTypeAliasDeclaration(e,t,n,i)}function _({modifiers:e,name:t,typeParameters:n,type:i,inheritedNodeNames:o}){const c=o?[a.createHeritageClause(r.SyntaxKind.ExtendsKeyword,o.map(u=>{const g=typeof u=="string"?u:u.escapedText.toString();return a.createExpressionWithTypeArguments(a.createIdentifier(k(g,!0)),void 0)}))]:[];return a.createInterfaceDeclaration(e,t,n,c,i.members)}function T(e){return typeof e=="string"?a.createIdentifier(e):e}function K(e,{typeArgs:t,args:n}={}){return a.createCallExpression(T(e),t,n)}function H(e,t){return K(a.createPropertyAccessExpression(a.createThis(),e),t)}function w(e){return a.createObjectLiteralExpression(e.map(([t,n])=>x(t,T(n))),!0)}function x(e,t){return r.isIdentifier(t)&&t.text===e?a.createShorthandPropertyAssignment(e):a.createPropertyAssignment(P(e),t)}function I(...e){return a.createBlock(e,!0)}function O(e,t,{modifiers:n,typeParameters:i,type:o,equalsGreaterThanToken:c}={}){return a.createArrowFunction(n,i,e,o,c,t)}function A(e,{modifiers:t,asteriskToken:n,typeParameters:i,type:o},c,u){return a.createFunctionDeclaration(t,n,e,i,c,o,u)}function Q({modifiers:e,name:t,typeParameters:n,heritageClauses:i,members:o}){return a.createClassDeclaration(e,t,n,i,o)}function W({modifiers:e,parameters:t,body:n}){return a.createConstructorDeclaration(e,t,n)}function R(e,{modifiers:t,asteriskToken:n,questionToken:i,typeParameters:o,type:c}={},u=[],g){return a.createMethodDeclaration(t,n,e,f(i),o,u,c,g)}function p(e,{modifiers:t,dotDotDotToken:n,questionToken:i,type:o,initializer:c}){return a.createParameterDeclaration(t,n,e,f(i),o,c)}function P(e){return typeof e=="string"?m(e)?a.createIdentifier(e):a.createStringLiteral(e):e}function N({modifiers:e,name:t,questionToken:n,type:i}){return a.createPropertySignature(e,P(t),f(n),i)}function j(e,{modifiers:t,indexName:n="key",indexType:i=s.string}={}){return a.createIndexSignature(t,[p(n,{type:i})],e)}function b(e){return a.createObjectBindingPattern(e.map(({dotDotDotToken:t,propertyName:n,name:i,initializer:o})=>a.createBindingElement(t,n,i,o)))}function D(e,t){return t.length?a.createTemplateExpression(a.createTemplateHead(e),t.map(({expression:n,literal:i},o)=>a.createTemplateSpan(n,o===t.length-1?a.createTemplateTail(i):a.createTemplateMiddle(i)))):a.createStringLiteral(e)}function M(e,t,n){const i=e.find(o=>o.kind===t&&(!n||n(o)));if(!i)throw new Error(`Node not found: ${t}`);return i}function h(e){return r.isIdentifier(e)?e.escapedText:r.isLiteralExpression(e)?e.text:""}function V(e){const t=r.getNameOfDeclaration(e.declarationList.declarations[0]);return t?h(t):""}function Y(e,t){const n=M(e,r.SyntaxKind.VariableStatement,o=>V(o)===t),[i]=n.declarationList.declarations;if(!i)throw new Error(`Missing ${t} declaration`);return i}function G(e,t,n){const i=e.properties.find(o=>r.isPropertyAssignment(o)&&h(o.name)===t);if(i&&r.isPropertyAssignment(i))Object.assign(i,{initializer:n});else throw new Error(`No such property: ${t}`)}function J(e){return t=>n=>{function i(o){const c=e(o,t);return c||r.visitEachChild(o,i,t)}return r.visitNode(n,i)}}function X(e,...t){return r.transform(e,t.map(J)).transformed[0]}function Z(e,...t){return a.createNodeArray([...e,...t])}function v(e,t){return t?r.addSyntheticLeadingComment(e,r.SyntaxKind.MultiLineCommentTrivia,`*
|
|
2
|
+
* ${t.replace(/\n/g,`
|
|
3
|
+
* `)}
|
|
4
|
+
`,!0):e}const L=r.createPrinter({newLine:r.NewLineKind.LineFeed});function ee(e){const t=r.createSourceFile("someFileName.ts","",r.ScriptTarget.Latest,!1,r.ScriptKind.TS);return L.printNode(r.EmitHint.Unspecified,e,t)}function te(e){const t=r.createSourceFile("someFileName.ts","",r.ScriptTarget.Latest,!1,r.ScriptKind.TS);return e.map(n=>L.printNode(r.EmitHint.Unspecified,n,t)).join(`
|
|
5
|
+
`)}function z(e){return L.printFile(e)}function m(e){if(!e.length||e.trim()!==e)return!1;const t=r.parseIsolatedEntityName(e,r.ScriptTarget.Latest);return!!t&&t.kind===r.SyntaxKind.Identifier&&r.identifierToKeywordKind(t)===void 0}function re(e,t){return r.factory.updateVariableDeclaration(e,t.name||e.name,t.exclamationToken||e.exclamationToken,t.type||e.type,t.initializer||e.initializer)}function U(e,t){return r.factory.updateFunctionDeclaration(e,t.modifiers||e.modifiers,t.asteriskToken||e.asteriskToken,t.name||e.name,t.typeParameters||e.typeParameters,t.parameters||e.parameters,t.type||e.type,t.body||e.body)}const ne=Object.freeze(Object.defineProperty({__proto__:null,addComment:v,appendNodes:Z,block:I,changePropertyValue:G,createArrowFunction:O,createCall:K,createClassDeclaration:Q,createConstructor:W,createEnumTypeNode:S,createFunctionDeclaration:A,createIndexSignature:j,createInterfaceAliasDeclaration:_,createKeywordType:$,createLiteral:y,createMethod:R,createMethodCall:H,createObjectBinding:b,createObjectLiteral:w,createParameter:p,createPropertyAssignment:x,createPropertySignature:N,createQuestionToken:f,createTemplateString:D,createTypeAliasDeclaration:C,findFirstVariableDeclaration:Y,findNode:M,getFirstDeclarationName:V,getName:h,isValidIdentifier:m,keywordType:s,modifier:F,printFile:z,printNode:ee,printNodes:te,questionToken:E,toExpression:T,transform:X,updateFunctionDeclaration:U,updateVariableDeclaration:re},Symbol.toStringTag,{value:"Module"})),d=r.factory;function ae(e){const t=e.split(/{([\s\S]+?)}/g),n=l.chunk(t.slice(1),2);return D(t[0],n.map(([i,o])=>({expression:d.createIdentifier(i),literal:o})))}function ie(e,t){const n=[p(b(Object.entries(t||{}).map(([i,o])=>({name:i,initializer:y(o.default)}))),{type:d.createTypeLiteralNode(Object.entries(t||{}).map(([i,o])=>N({name:i,type:o.enum?S(o.enum):d.createUnionTypeNode([s.string,s.number,s.boolean])})))})];return O(n,ae(e))}function oe(e){return e.variables?ie(e.url,e.variables):d.createStringLiteral(e.url)}function ce(e){if(!e)return"/";const{url:t,variables:n}=e;return n?t.replace(/\{(.+?)\}/g,(i,o)=>n[o]?String(n[o].default):i):t}function se(e){return ce(e==null?void 0:e[0])}function ue(e,t){return e.description?l.camelCase(e.description.replace(/\W+/," ")):`server${t+1}`}function le(e){return w(e.map((t,n)=>[ue(t,n),oe(t)]))}function de(e){return r.factory.createVariableStatement([r.factory.createModifier(r.SyntaxKind.ExportKeyword)],r.factory.createVariableDeclarationList([r.factory.createVariableDeclaration("servers",void 0,void 0,le(e))],r.NodeFlags.Const))}function fe(e,t={}){const n=l.cloneDeep(e);return{opts:t,spec:n,banner:`DO NOT MODIFY - This file has been generated using oazapfts.
|
|
6
|
+
See https://www.npmjs.com/package/oazapfts`,imports:[[{namespace:"Oazapfts"},{from:"@oazapfts/runtime"}],[{namespace:"QS"},{from:"@oazapfts/runtime/query"}]],defaults:{baseUrl:se(n.servers),headers:{}},servers:n.servers||[],init:ye(),discriminatingSchemas:new Set,aliases:[],enumAliases:[],enumRefs:{},refs:{},refsOnlyMode:new Map,typeAliases:{}}}function ye(){return[r.factory.createVariableStatement(void 0,r.factory.createVariableDeclarationList([r.factory.createVariableDeclaration("oazapfts",void 0,void 0,r.factory.createCallExpression(r.factory.createPropertyAccessExpression(r.factory.createIdentifier("Oazapfts"),"runtime"),void 0,[r.factory.createIdentifier("defaults")]))],r.NodeFlags.Const))]}exports.addComment=v;exports.block=I;exports.createCall=K;exports.createContext=fe;exports.createEnumTypeNode=S;exports.createFunctionDeclaration=A;exports.createIndexSignature=j;exports.createLiteral=y;exports.createObjectBinding=b;exports.createObjectLiteral=w;exports.createParameter=p;exports.createPropertyAssignment=x;exports.createPropertySignature=N;exports.createServersStatement=de;exports.createTemplateString=D;exports.createTypeAliasDeclaration=C;exports.isValidIdentifier=m;exports.keywordType=s;exports.modifier=F;exports.printFile=z;exports.toIdentifier=k;exports.tscodegen=ne;exports.updateFunctionDeclaration=U;
|
|
7
|
+
//# sourceMappingURL=context-lKBK5qCf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-lKBK5qCf.cjs","sources":["../src/helpers/getOnlyModeSuffix.ts","../src/helpers/toIdentifier.ts","../src/generate/tscodegen.ts","../src/generate/generateServers.ts","../src/context.ts"],"sourcesContent":["import { OnlyMode } from \"../context\";\n\nconst onlyModeSuffixes: Record<OnlyMode, string> = {\n readOnly: \"Read\",\n writeOnly: \"Write\",\n};\n\nexport function getOnlyModeSuffix(onlyMode?: OnlyMode) {\n if (!onlyMode) return \"\";\n return onlyModeSuffixes[onlyMode];\n}\n","import _ from \"lodash\";\nimport { OnlyMode } from \"../context\";\nimport { isValidIdentifier } from \"../generate/tscodegen\";\nimport { getOnlyModeSuffix } from \"./getOnlyModeSuffix\";\n\nexport function toIdentifier(s: string, upper = false, onlyMode?: OnlyMode) {\n let cc = _.camelCase(s) + getOnlyModeSuffix(onlyMode);\n if (upper) cc = _.upperFirst(cc);\n if (isValidIdentifier(cc)) return cc;\n return \"$\" + cc;\n}\n","import ts from \"typescript\";\nimport { toIdentifier } from \"../helpers/toIdentifier\";\n\nconst factory = ts.factory;\n\nexport const questionToken = factory.createToken(ts.SyntaxKind.QuestionToken);\n\nexport function createQuestionToken(token?: boolean | ts.QuestionToken) {\n if (!token) return undefined;\n if (token === true) return questionToken;\n return token;\n}\n\nexport const keywordType = {\n any: factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n number: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n integer: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n object: factory.createKeywordTypeNode(ts.SyntaxKind.ObjectKeyword),\n string: factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n boolean: factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),\n undefined: factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),\n void: factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword),\n never: factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword),\n null: factory.createLiteralTypeNode(factory.createNull()),\n unknown: factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),\n};\n\ntype KeywordTypeName = keyof typeof keywordType;\n\nexport function createKeywordType(type: KeywordTypeName) {\n return keywordType[type];\n}\n\nexport const modifier = {\n async: factory.createModifier(ts.SyntaxKind.AsyncKeyword),\n export: factory.createModifier(ts.SyntaxKind.ExportKeyword),\n};\n\nexport function createLiteral(v: string | boolean | number) {\n switch (typeof v) {\n case \"string\":\n return factory.createStringLiteral(v);\n case \"boolean\":\n return v ? factory.createTrue() : factory.createFalse();\n case \"number\":\n return String(v).charAt(0) === \"-\"\n ? factory.createPrefixUnaryExpression(\n ts.SyntaxKind.MinusToken,\n factory.createNumericLiteral(String(-v)),\n )\n : factory.createNumericLiteral(String(v));\n }\n}\n\nexport function createEnumTypeNode(values: Array<string | boolean | number>) {\n const types = values.map((v) =>\n v === null\n ? keywordType.null\n : factory.createLiteralTypeNode(createLiteral(v)),\n );\n return types.length > 1 ? factory.createUnionTypeNode(types) : types[0];\n}\n\nexport function createTypeAliasDeclaration({\n modifiers,\n name,\n typeParameters,\n type,\n}: {\n modifiers?: Array<ts.Modifier>;\n name: string | ts.Identifier;\n typeParameters?: Array<ts.TypeParameterDeclaration>;\n type: ts.TypeNode;\n}) {\n return factory.createTypeAliasDeclaration(\n modifiers,\n name,\n typeParameters,\n type,\n );\n}\n\nexport function createInterfaceAliasDeclaration({\n modifiers,\n name,\n typeParameters,\n type,\n inheritedNodeNames,\n}: {\n modifiers?: Array<ts.Modifier>;\n name: string | ts.Identifier;\n typeParameters?: Array<ts.TypeParameterDeclaration>;\n type: ts.TypeNode;\n inheritedNodeNames?: (string | ts.Identifier)[];\n}) {\n const heritageClauses = inheritedNodeNames\n ? [\n factory.createHeritageClause(\n ts.SyntaxKind.ExtendsKeyword,\n inheritedNodeNames.map((name) => {\n const extendedInterfaceName =\n typeof name === \"string\" ? name : name.escapedText.toString();\n return factory.createExpressionWithTypeArguments(\n factory.createIdentifier(\n toIdentifier(extendedInterfaceName, true),\n ),\n undefined,\n );\n }),\n ),\n ]\n : [];\n return factory.createInterfaceDeclaration(\n modifiers,\n name,\n typeParameters,\n heritageClauses,\n (type as ts.TypeLiteralNode).members,\n );\n}\n\nexport function toExpression(ex: ts.Expression | string) {\n if (typeof ex === \"string\") return factory.createIdentifier(ex);\n return ex;\n}\n\nexport function createCall(\n expression: ts.Expression | string,\n {\n typeArgs,\n args,\n }: {\n typeArgs?: Array<ts.TypeNode>;\n args?: Array<ts.Expression>;\n } = {},\n) {\n return factory.createCallExpression(toExpression(expression), typeArgs, args);\n}\n\nexport function createMethodCall(\n method: string,\n opts: {\n typeArgs?: Array<ts.TypeNode>;\n args?: Array<ts.Expression>;\n },\n) {\n return createCall(\n factory.createPropertyAccessExpression(factory.createThis(), method),\n opts,\n );\n}\n\nexport function createObjectLiteral(props: [string, string | ts.Expression][]) {\n return factory.createObjectLiteralExpression(\n props.map(([name, identifier]) =>\n createPropertyAssignment(name, toExpression(identifier)),\n ),\n true,\n );\n}\n\nexport function createPropertyAssignment(\n name: string,\n expression: ts.Expression,\n) {\n if (ts.isIdentifier(expression)) {\n if (expression.text === name) {\n return factory.createShorthandPropertyAssignment(name);\n }\n }\n return factory.createPropertyAssignment(propertyName(name), expression);\n}\n\nexport function block(...statements: ts.Statement[]) {\n return factory.createBlock(statements, true);\n}\n\nexport function createArrowFunction(\n parameters: ts.ParameterDeclaration[],\n body: ts.ConciseBody,\n {\n modifiers,\n typeParameters,\n type,\n equalsGreaterThanToken,\n }: {\n modifiers?: ts.Modifier[];\n typeParameters?: ts.TypeParameterDeclaration[];\n type?: ts.TypeNode;\n equalsGreaterThanToken?: ts.EqualsGreaterThanToken;\n } = {},\n) {\n return factory.createArrowFunction(\n modifiers,\n typeParameters,\n parameters,\n type,\n equalsGreaterThanToken,\n body,\n );\n}\n\nexport function createFunctionDeclaration(\n name: string | ts.Identifier | undefined,\n {\n modifiers,\n asteriskToken,\n typeParameters,\n type,\n }: {\n modifiers?: ts.Modifier[];\n asteriskToken?: ts.AsteriskToken;\n typeParameters?: ts.TypeParameterDeclaration[];\n type?: ts.TypeNode;\n },\n parameters: ts.ParameterDeclaration[],\n body?: ts.Block,\n): ts.FunctionDeclaration {\n return factory.createFunctionDeclaration(\n modifiers,\n asteriskToken,\n name,\n typeParameters,\n parameters,\n type,\n body,\n );\n}\n\nexport function createClassDeclaration({\n modifiers,\n name,\n typeParameters,\n heritageClauses,\n members,\n}: {\n modifiers?: Array<ts.Modifier>;\n name?: string | ts.Identifier;\n typeParameters?: Array<ts.TypeParameterDeclaration>;\n heritageClauses?: Array<ts.HeritageClause>;\n members: Array<ts.ClassElement>;\n}) {\n return factory.createClassDeclaration(\n modifiers,\n name,\n typeParameters,\n heritageClauses,\n members,\n );\n}\n\nexport function createConstructor({\n modifiers,\n parameters,\n body,\n}: {\n modifiers?: Array<ts.Modifier>;\n parameters: Array<ts.ParameterDeclaration>;\n body?: ts.Block;\n}) {\n return factory.createConstructorDeclaration(modifiers, parameters, body);\n}\n\nexport function createMethod(\n name:\n | string\n | ts.Identifier\n | ts.StringLiteral\n | ts.NumericLiteral\n | ts.ComputedPropertyName,\n {\n modifiers,\n asteriskToken,\n questionToken,\n typeParameters,\n type,\n }: {\n modifiers?: ts.Modifier[];\n asteriskToken?: ts.AsteriskToken;\n questionToken?: ts.QuestionToken | boolean;\n typeParameters?: ts.TypeParameterDeclaration[];\n type?: ts.TypeNode;\n } = {},\n parameters: ts.ParameterDeclaration[] = [],\n body?: ts.Block,\n): ts.MethodDeclaration {\n return factory.createMethodDeclaration(\n modifiers,\n asteriskToken,\n name,\n createQuestionToken(questionToken),\n typeParameters,\n parameters,\n type,\n body,\n );\n}\n\nexport function createParameter(\n name: string | ts.BindingName,\n {\n modifiers,\n dotDotDotToken,\n questionToken,\n type,\n initializer,\n }: {\n modifiers?: Array<ts.Modifier>;\n dotDotDotToken?: ts.DotDotDotToken;\n questionToken?: ts.QuestionToken | boolean;\n type?: ts.TypeNode;\n initializer?: ts.Expression;\n },\n): ts.ParameterDeclaration {\n return factory.createParameterDeclaration(\n modifiers,\n dotDotDotToken,\n name,\n createQuestionToken(questionToken),\n type,\n initializer,\n );\n}\n\nfunction propertyName(name: string | ts.PropertyName): ts.PropertyName {\n if (typeof name === \"string\") {\n return isValidIdentifier(name)\n ? factory.createIdentifier(name)\n : factory.createStringLiteral(name);\n }\n return name;\n}\n\nexport function createPropertySignature({\n modifiers,\n name,\n questionToken,\n type,\n}: {\n modifiers?: Array<ts.Modifier>;\n name: ts.PropertyName | string;\n questionToken?: ts.QuestionToken | boolean;\n type?: ts.TypeNode;\n}) {\n return factory.createPropertySignature(\n modifiers,\n propertyName(name),\n createQuestionToken(questionToken),\n type,\n );\n}\n\nexport function createIndexSignature(\n type: ts.TypeNode,\n {\n modifiers,\n indexName = \"key\",\n indexType = keywordType.string,\n }: {\n indexName?: string;\n indexType?: ts.TypeNode;\n modifiers?: Array<ts.Modifier>;\n } = {},\n) {\n return factory.createIndexSignature(\n modifiers,\n [createParameter(indexName, { type: indexType })],\n type,\n );\n}\n\nexport function createObjectBinding(\n elements: Array<{\n name: string | ts.BindingName;\n dotDotDotToken?: ts.DotDotDotToken;\n propertyName?: string | ts.PropertyName;\n initializer?: ts.Expression;\n }>,\n) {\n return factory.createObjectBindingPattern(\n elements.map(({ dotDotDotToken, propertyName, name, initializer }) =>\n factory.createBindingElement(\n dotDotDotToken,\n propertyName,\n name,\n initializer,\n ),\n ),\n );\n}\n\nexport function createTemplateString(\n head: string,\n spans: Array<{ literal: string; expression: ts.Expression }>,\n) {\n if (!spans.length) return factory.createStringLiteral(head);\n return factory.createTemplateExpression(\n factory.createTemplateHead(head),\n spans.map(({ expression, literal }, i) =>\n factory.createTemplateSpan(\n expression,\n i === spans.length - 1\n ? factory.createTemplateTail(literal)\n : factory.createTemplateMiddle(literal),\n ),\n ),\n );\n}\n\nexport function findNode<T extends ts.Node>(\n nodes: ts.NodeArray<ts.Node>,\n kind: T extends { kind: infer K } ? K : never,\n test?: (node: T) => boolean | undefined,\n): T {\n const node = nodes.find(\n (s) => s.kind === kind && (!test || test(s as T)),\n ) as T;\n if (!node) throw new Error(`Node not found: ${kind}`);\n return node;\n}\n\nexport function getName(name: ts.Node) {\n if (ts.isIdentifier(name)) {\n return name.escapedText;\n }\n if (ts.isLiteralExpression(name)) {\n return name.text;\n }\n return \"\";\n}\n\nexport function getFirstDeclarationName(n: ts.VariableStatement) {\n const name = ts.getNameOfDeclaration(n.declarationList.declarations[0]);\n return name ? getName(name) : \"\";\n}\n\nexport function findFirstVariableDeclaration(\n nodes: ts.NodeArray<ts.Node>,\n name: string,\n) {\n const statement = findNode<ts.VariableStatement>(\n nodes,\n ts.SyntaxKind.VariableStatement,\n (n) => getFirstDeclarationName(n) === name,\n );\n const [first] = statement.declarationList.declarations;\n if (!first) throw new Error(`Missing ${name} declaration`);\n return first;\n}\n\nexport function changePropertyValue(\n o: ts.ObjectLiteralExpression,\n property: string,\n value: ts.Expression,\n) {\n const p = o.properties.find(\n (p) => ts.isPropertyAssignment(p) && getName(p.name) === property,\n );\n if (p && ts.isPropertyAssignment(p)) {\n // p.initializer is readonly, this might break in a future TS version, but works fine for now.\n Object.assign(p, { initializer: value });\n } else {\n throw new Error(`No such property: ${property}`);\n }\n}\n\ntype Visitor = (\n node: ts.Node,\n context: ts.TransformationContext,\n) => void | ts.Node;\n\nfunction createTransformer(visitor: Visitor) {\n return <T extends ts.Node>(context: ts.TransformationContext) =>\n (rootNode: T) => {\n function visit(node: ts.Node): ts.Node {\n const result = visitor(node, context);\n\n if (result) {\n return result;\n }\n\n return ts.visitEachChild(node, visit, context);\n }\n\n return ts.visitNode(rootNode, visit);\n };\n}\n\nexport function transform<T extends ts.Node>(\n source: T,\n ...visitors: Visitor[]\n) {\n const result = ts.transform(source, visitors.map(createTransformer));\n\n return result.transformed[0] as T;\n}\n\nexport function appendNodes<T extends ts.Node>(\n array: ts.NodeArray<T>,\n ...nodes: T[]\n) {\n return factory.createNodeArray([...array, ...nodes]);\n}\n\nexport function addComment<T extends ts.Node>(node: T, comment?: string) {\n if (!comment) return node;\n return ts.addSyntheticLeadingComment(\n node,\n ts.SyntaxKind.MultiLineCommentTrivia,\n `*\\n * ${comment.replace(/\\n/g, \"\\n * \")}\\n `,\n true,\n );\n}\n\nconst printer = ts.createPrinter({\n newLine: ts.NewLineKind.LineFeed,\n});\n\nexport function printNode(node: ts.Node) {\n const file = ts.createSourceFile(\n \"someFileName.ts\",\n \"\",\n ts.ScriptTarget.Latest,\n /*setParentNodes*/ false,\n ts.ScriptKind.TS,\n );\n return printer.printNode(ts.EmitHint.Unspecified, node, file);\n}\n\nexport function printNodes(nodes: ts.Node[]) {\n const file = ts.createSourceFile(\n \"someFileName.ts\",\n \"\",\n ts.ScriptTarget.Latest,\n /*setParentNodes*/ false,\n ts.ScriptKind.TS,\n );\n return nodes\n .map((node) => printer.printNode(ts.EmitHint.Unspecified, node, file))\n .join(\"\\n\");\n}\n\nexport function printFile(sourceFile: ts.SourceFile) {\n return printer.printFile(sourceFile);\n}\n\nexport function isValidIdentifier(str: string) {\n if (!str.length || str.trim() !== str) return false;\n const node = ts.parseIsolatedEntityName(str, ts.ScriptTarget.Latest);\n return (\n !!node &&\n node.kind === ts.SyntaxKind.Identifier &&\n ts.identifierToKeywordKind(node) === undefined\n );\n}\n\nexport function updateVariableDeclaration(\n node: ts.VariableDeclaration,\n updates: Partial<ts.VariableDeclaration>,\n) {\n return ts.factory.updateVariableDeclaration(\n node,\n updates.name || node.name,\n updates.exclamationToken || node.exclamationToken,\n updates.type || node.type,\n updates.initializer || node.initializer,\n );\n}\n\nexport function updateFunctionDeclaration(\n node: ts.FunctionDeclaration,\n updates: Partial<ts.FunctionDeclaration>,\n) {\n return ts.factory.updateFunctionDeclaration(\n node,\n updates.modifiers || node.modifiers,\n updates.asteriskToken || node.asteriskToken,\n updates.name || node.name,\n updates.typeParameters || node.typeParameters,\n updates.parameters || node.parameters,\n updates.type || node.type,\n updates.body || node.body,\n );\n}\n","import _ from \"lodash\";\nimport * as cg from \"./tscodegen\";\nimport ts from \"typescript\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { ServerObject } from \"../helpers/openApi3-x\";\n\nconst factory = ts.factory;\n\nfunction createTemplate(url: string) {\n const tokens = url.split(/{([\\s\\S]+?)}/g);\n const chunks = _.chunk(tokens.slice(1), 2);\n return cg.createTemplateString(\n tokens[0],\n chunks.map(([expression, literal]) => ({\n expression: factory.createIdentifier(expression),\n literal,\n })),\n );\n}\n\nfunction createServerFunction(\n template: string,\n vars: Record<string, OpenAPIV3.ServerVariableObject>,\n) {\n const params = [\n cg.createParameter(\n cg.createObjectBinding(\n Object.entries(vars || {}).map(([name, value]) => {\n return {\n name,\n initializer: cg.createLiteral(value.default),\n };\n }),\n ),\n {\n type: factory.createTypeLiteralNode(\n Object.entries(vars || {}).map(([name, value]) => {\n return cg.createPropertySignature({\n name,\n type: value.enum\n ? cg.createEnumTypeNode(value.enum)\n : factory.createUnionTypeNode([\n cg.keywordType.string,\n cg.keywordType.number,\n cg.keywordType.boolean,\n ]),\n });\n }),\n ),\n },\n ),\n ];\n\n return cg.createArrowFunction(params, createTemplate(template));\n}\n\nfunction generateServerExpression(server: ServerObject) {\n return server.variables\n ? createServerFunction(server.url, server.variables)\n : factory.createStringLiteral(server.url);\n}\n\nfunction defaultUrl(server?: ServerObject) {\n if (!server) return \"/\";\n const { url, variables } = server;\n if (!variables) return url;\n return url.replace(/\\{(.+?)\\}/g, (m, name) =>\n variables[name] ? String(variables[name].default) : m,\n );\n}\n\nexport function defaultBaseUrl(servers?: ServerObject[]) {\n return defaultUrl(servers?.[0]);\n}\n\nfunction serverName(server: ServerObject, index: number) {\n return server.description\n ? _.camelCase(server.description.replace(/\\W+/, \" \"))\n : `server${index + 1}`;\n}\n\nexport function generateServers(servers: ServerObject[]) {\n return cg.createObjectLiteral(\n servers.map((server, i) => [\n serverName(server, i),\n generateServerExpression(server),\n ]),\n );\n}\n\nexport function createServersStatement(servers: ServerObject[]) {\n return ts.factory.createVariableStatement(\n [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n \"servers\",\n undefined,\n undefined,\n generateServers(servers),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n );\n}\n","import ts, {\n InterfaceDeclaration,\n Statement,\n TypeAliasDeclaration,\n TypeReferenceNode,\n} from \"typescript\";\nimport type { OazapftsOptions } from \"./\";\nimport type {\n Document,\n SchemaObject,\n ServerObject,\n} from \"./helpers/openApi3-x\";\nimport { defaultBaseUrl } from \"./generate/generateServers\";\nimport _ from \"lodash\";\nimport { CustomHeaders } from \"@oazapfts/runtime\";\n\n// ─── Data types for template parts ──────────────────────────────────────────\n\nexport type ImportSpecifier = {\n name: string;\n as?: string;\n};\nexport type DefaultImport = [string, { from: string }];\nexport type NamespaceImport = [{ namespace: string }, { from: string }];\nexport type ImportsWithoutDefault = [\n (ImportSpecifier | string)[],\n { from: string },\n];\nexport type ImportWithDefault = [\n string,\n (ImportSpecifier | string)[],\n { from: string },\n];\n\nexport type Import =\n | string\n | ImportsWithoutDefault\n | DefaultImport\n | ImportWithDefault\n | NamespaceImport;\n\nexport type OnlyMode = \"readOnly\" | \"writeOnly\";\nexport type OnlyModes = Record<OnlyMode, boolean>;\n\nexport type ReadonlyDeep<T> = {\n readonly [P in keyof T]: ReadonlyDeep<T[P]>;\n};\n\nexport type Defaults = {\n baseUrl?: string;\n headers?: CustomHeaders;\n FormData?: ts.ClassExpression | ts.Identifier;\n fetch?: ts.FunctionExpression | ts.ArrowFunction | ts.Identifier;\n};\n\nexport type OazapftsContext = {\n readonly opts: ReadonlyDeep<OazapftsOptions>;\n readonly spec: Document;\n\n /** Banner comment at the top of the file (the text content, not including comment markers) */\n banner: string;\n /** Import declarations (AST nodes) */\n imports: Import[];\n /** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */\n defaults: Defaults;\n /** Server definitions - will be generated as `export const servers = { ... }` */\n servers: ServerObject[];\n /** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */\n init: Statement[];\n\n // see `preprocessComponents` for the definition of a discriminating schema\n discriminatingSchemas: Set<SchemaObject>;\n\n aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];\n\n enumAliases: Statement[];\n enumRefs: Record<string, { values: string; type: TypeReferenceNode }>;\n\n // Collect the types of all referenced schemas so we can export them later\n // Referenced schemas can be pointing at the following versions:\n // - \"base\": The regular type/interface e.g. ExampleSchema\n // - \"readOnly\": The readOnly version e.g. ExampleSchemaRead\n // - \"writeOnly\": The writeOnly version e.g. ExampleSchemaWrite\n refs: Record<\n string,\n {\n base: TypeReferenceNode;\n readOnly?: TypeReferenceNode;\n writeOnly?: TypeReferenceNode;\n }\n >;\n\n // Maps a referenced schema to its readOnly/writeOnly status\n // This field should be used exclusively within the `checkSchemaOnlyMode` method\n refsOnlyMode: Map<string, OnlyModes>;\n\n // Keep track of already used type aliases\n typeAliases: Record<string, number>;\n};\n\nexport function createContext(\n inputSpec: Document,\n opts: OazapftsContext[\"opts\"] = {},\n): OazapftsContext {\n const spec = _.cloneDeep(inputSpec);\n\n return {\n opts,\n spec,\n\n // Template parts\n banner: `DO NOT MODIFY - This file has been generated using oazapfts.\nSee https://www.npmjs.com/package/oazapfts`,\n imports: [\n [{ namespace: \"Oazapfts\" }, { from: \"@oazapfts/runtime\" }],\n [{ namespace: \"QS\" }, { from: \"@oazapfts/runtime/query\" }],\n ],\n defaults: { baseUrl: defaultBaseUrl(spec.servers), headers: {} },\n servers: spec.servers || [],\n init: createInit(),\n\n // Internal state\n discriminatingSchemas: new Set(),\n aliases: [],\n enumAliases: [],\n enumRefs: {},\n refs: {},\n refsOnlyMode: new Map(),\n typeAliases: {},\n };\n}\n\n/** Creates: const oazapfts = Oazapfts.runtime(defaults); */\nfunction createInit(): Statement[] {\n return [\n ts.factory.createVariableStatement(\n undefined,\n ts.factory.createVariableDeclarationList(\n [\n ts.factory.createVariableDeclaration(\n \"oazapfts\",\n undefined,\n undefined,\n ts.factory.createCallExpression(\n ts.factory.createPropertyAccessExpression(\n ts.factory.createIdentifier(\"Oazapfts\"),\n \"runtime\",\n ),\n undefined,\n [ts.factory.createIdentifier(\"defaults\")],\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n ];\n}\n"],"names":["onlyModeSuffixes","getOnlyModeSuffix","onlyMode","toIdentifier","s","upper","cc","_","isValidIdentifier","factory","ts","questionToken","createQuestionToken","token","keywordType","createKeywordType","type","modifier","createLiteral","v","createEnumTypeNode","values","types","createTypeAliasDeclaration","modifiers","name","typeParameters","createInterfaceAliasDeclaration","inheritedNodeNames","heritageClauses","extendedInterfaceName","toExpression","ex","createCall","expression","typeArgs","args","createMethodCall","method","opts","createObjectLiteral","props","identifier","createPropertyAssignment","propertyName","block","statements","createArrowFunction","parameters","body","equalsGreaterThanToken","createFunctionDeclaration","asteriskToken","createClassDeclaration","members","createConstructor","createMethod","createParameter","dotDotDotToken","initializer","createPropertySignature","createIndexSignature","indexName","indexType","createObjectBinding","elements","createTemplateString","head","spans","literal","i","findNode","nodes","kind","test","node","getName","getFirstDeclarationName","n","findFirstVariableDeclaration","statement","first","changePropertyValue","o","property","value","p","createTransformer","visitor","context","rootNode","visit","result","transform","source","visitors","appendNodes","array","addComment","comment","printer","printNode","file","printNodes","printFile","sourceFile","str","updateVariableDeclaration","updates","updateFunctionDeclaration","createTemplate","url","tokens","chunks","cg.createTemplateString","createServerFunction","template","vars","params","cg.createParameter","cg.createObjectBinding","cg.createLiteral","cg.createPropertySignature","cg.createEnumTypeNode","cg.keywordType","cg.createArrowFunction","generateServerExpression","server","defaultUrl","variables","m","defaultBaseUrl","servers","serverName","index","generateServers","cg.createObjectLiteral","createServersStatement","createContext","inputSpec","spec","createInit"],"mappings":"+DAEMA,EAA6C,CACjD,SAAU,OACV,UAAW,OACb,EAEO,SAASC,EAAkBC,EAAqB,CACrD,OAAKA,EACEF,EAAiBE,CAAQ,EADV,EAExB,CCLO,SAASC,EAAaC,EAAWC,EAAQ,GAAOH,EAAqB,CAC1E,IAAII,EAAKC,EAAE,UAAUH,CAAC,EAAIH,EAAkBC,CAAQ,EAEpD,OADIG,IAAOC,EAAKC,EAAE,WAAWD,CAAE,GAC3BE,EAAkBF,CAAE,EAAUA,EAC3B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AAG,UAAU,KAAA,CACf,CAEJ,CCLO,SAASgI,GACdC,EACApG,EAAgC,GACf,CACjB,MAAMqG,EAAOrI,EAAE,UAAUoI,CAAS,EAElC,MAAO,CACL,KAAApG,EACA,KAAAqG,EAGA,OAAQ;AAAA,4CAER,QAAS,CACP,CAAC,CAAE,UAAW,UAAA,EAAc,CAAE,KAAM,oBAAqB,EACzD,CAAC,CAAE,UAAW,IAAA,EAAQ,CAAE,KAAM,0BAA2B,CAAA,EAE3D,SAAU,CAAE,QAAST,GAAeS,EAAK,OAAO,EAAG,QAAS,EAAC,EAC7D,QAASA,EAAK,SAAW,CAAA,EACzB,KAAMC,GAAA,EAGN,0BAA2B,IAC3B,QAAS,CAAA,EACT,YAAa,CAAA,EACb,SAAU,CAAA,EACV,KAAM,CAAA,EACN,iBAAkB,IAClB,YAAa,CAAA,CAAC,CAElB,CAGA,SAASA,IAA0B,CACjC,MAAO,CACLnI,EAAG,QAAQ,wBACT,OACAA,EAAG,QAAQ,8BACT,CACEA,EAAG,QAAQ,0BACT,WACA,OACA,OACAA,EAAG,QAAQ,qBACTA,EAAG,QAAQ,+BACTA,EAAG,QAAQ,iBAAiB,UAAU,EACtC,SAAA,EAEF,OACA,CAACA,EAAG,QAAQ,iBAAiB,UAAU,CAAC,CAAA,CAC1C,CACF,EAEFA,EAAG,UAAU,KAAA,CACf,CACF,CAEJ"}
|
package/dist/context.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { AsyncSeriesHook } from 'tapable';
|
|
2
|
+
import { AsyncSeriesWaterfallHook } from 'tapable';
|
|
3
|
+
import { CustomHeaders } from '@oazapfts/runtime';
|
|
4
|
+
import { default as default_2 } from 'typescript';
|
|
5
|
+
import { InterfaceDeclaration } from 'typescript';
|
|
6
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
7
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
8
|
+
import { Statement } from 'typescript';
|
|
9
|
+
import { TypeAliasDeclaration } from 'typescript';
|
|
10
|
+
import { TypeReferenceNode } from 'typescript';
|
|
11
|
+
|
|
12
|
+
declare type ArgumentStyle = (typeof argumentStyleOptions)[number];
|
|
13
|
+
|
|
14
|
+
declare const argumentStyleOptions: readonly ["positional", "object"];
|
|
15
|
+
|
|
16
|
+
export declare function createContext(inputSpec: Document_2, opts?: OazapftsContext["opts"]): OazapftsContext;
|
|
17
|
+
|
|
18
|
+
export declare type DefaultImport = [string, {
|
|
19
|
+
from: string;
|
|
20
|
+
}];
|
|
21
|
+
|
|
22
|
+
declare type DefaultImport_2 = [string, {
|
|
23
|
+
from: string;
|
|
24
|
+
}];
|
|
25
|
+
|
|
26
|
+
export declare type Defaults = {
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
headers?: CustomHeaders;
|
|
29
|
+
FormData?: default_2.ClassExpression | default_2.Identifier;
|
|
30
|
+
fetch?: default_2.FunctionExpression | default_2.ArrowFunction | default_2.Identifier;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare type Defaults_2 = {
|
|
34
|
+
baseUrl?: string;
|
|
35
|
+
headers?: CustomHeaders;
|
|
36
|
+
FormData?: default_2.ClassExpression | default_2.Identifier;
|
|
37
|
+
fetch?: default_2.FunctionExpression | default_2.ArrowFunction | default_2.Identifier;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
declare type Document_2 = OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
41
|
+
|
|
42
|
+
declare type Document_2_2 = OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
43
|
+
|
|
44
|
+
declare type HttpMethod = (typeof HttpMethods)[number];
|
|
45
|
+
|
|
46
|
+
declare const HttpMethods: readonly ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
|
|
47
|
+
|
|
48
|
+
export declare type Import = string | ImportsWithoutDefault | DefaultImport | ImportWithDefault | NamespaceImport;
|
|
49
|
+
|
|
50
|
+
declare type Import_2 = string | ImportsWithoutDefault_2 | DefaultImport_2 | ImportWithDefault_2 | NamespaceImport_2;
|
|
51
|
+
|
|
52
|
+
export declare type ImportSpecifier = {
|
|
53
|
+
name: string;
|
|
54
|
+
as?: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
declare type ImportSpecifier_2 = {
|
|
58
|
+
name: string;
|
|
59
|
+
as?: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export declare type ImportsWithoutDefault = [
|
|
63
|
+
(ImportSpecifier | string)[],
|
|
64
|
+
{
|
|
65
|
+
from: string;
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
declare type ImportsWithoutDefault_2 = [
|
|
70
|
+
(ImportSpecifier_2 | string)[],
|
|
71
|
+
{
|
|
72
|
+
from: string;
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
export declare type ImportWithDefault = [
|
|
77
|
+
string,
|
|
78
|
+
(ImportSpecifier | string)[],
|
|
79
|
+
{
|
|
80
|
+
from: string;
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
declare type ImportWithDefault_2 = [
|
|
85
|
+
string,
|
|
86
|
+
(ImportSpecifier_2 | string)[],
|
|
87
|
+
{
|
|
88
|
+
from: string;
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
export declare type NamespaceImport = [{
|
|
93
|
+
namespace: string;
|
|
94
|
+
}, {
|
|
95
|
+
from: string;
|
|
96
|
+
}];
|
|
97
|
+
|
|
98
|
+
declare type NamespaceImport_2 = [{
|
|
99
|
+
namespace: string;
|
|
100
|
+
}, {
|
|
101
|
+
from: string;
|
|
102
|
+
}];
|
|
103
|
+
|
|
104
|
+
export declare type OazapftsContext = {
|
|
105
|
+
readonly opts: ReadonlyDeep<OazapftsOptions>;
|
|
106
|
+
readonly spec: Document_2;
|
|
107
|
+
/** Banner comment at the top of the file (the text content, not including comment markers) */
|
|
108
|
+
banner: string;
|
|
109
|
+
/** Import declarations (AST nodes) */
|
|
110
|
+
imports: Import[];
|
|
111
|
+
/** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */
|
|
112
|
+
defaults: Defaults;
|
|
113
|
+
/** Server definitions - will be generated as `export const servers = { ... }` */
|
|
114
|
+
servers: ServerObject_2[];
|
|
115
|
+
/** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */
|
|
116
|
+
init: Statement[];
|
|
117
|
+
discriminatingSchemas: Set<SchemaObject_2>;
|
|
118
|
+
aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];
|
|
119
|
+
enumAliases: Statement[];
|
|
120
|
+
enumRefs: Record<string, {
|
|
121
|
+
values: string;
|
|
122
|
+
type: TypeReferenceNode;
|
|
123
|
+
}>;
|
|
124
|
+
refs: Record<string, {
|
|
125
|
+
base: TypeReferenceNode;
|
|
126
|
+
readOnly?: TypeReferenceNode;
|
|
127
|
+
writeOnly?: TypeReferenceNode;
|
|
128
|
+
}>;
|
|
129
|
+
refsOnlyMode: Map<string, OnlyModes>;
|
|
130
|
+
typeAliases: Record<string, number>;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
declare type OazapftsContext_2 = {
|
|
134
|
+
readonly opts: ReadonlyDeep_2<OazapftsOptions>;
|
|
135
|
+
readonly spec: Document_2_2;
|
|
136
|
+
/** Banner comment at the top of the file (the text content, not including comment markers) */
|
|
137
|
+
banner: string;
|
|
138
|
+
/** Import declarations (AST nodes) */
|
|
139
|
+
imports: Import_2[];
|
|
140
|
+
/** Runtime defaults (baseUrl, etc.) - will be generated as `export const defaults = { ... }` */
|
|
141
|
+
defaults: Defaults_2;
|
|
142
|
+
/** Server definitions - will be generated as `export const servers = { ... }` */
|
|
143
|
+
servers: ServerObject[];
|
|
144
|
+
/** Initialization statements (e.g., `const oazapfts = Oazapfts.runtime(defaults)`) */
|
|
145
|
+
init: Statement[];
|
|
146
|
+
discriminatingSchemas: Set<SchemaObject>;
|
|
147
|
+
aliases: (TypeAliasDeclaration | InterfaceDeclaration)[];
|
|
148
|
+
enumAliases: Statement[];
|
|
149
|
+
enumRefs: Record<string, {
|
|
150
|
+
values: string;
|
|
151
|
+
type: TypeReferenceNode;
|
|
152
|
+
}>;
|
|
153
|
+
refs: Record<string, {
|
|
154
|
+
base: TypeReferenceNode;
|
|
155
|
+
readOnly?: TypeReferenceNode;
|
|
156
|
+
writeOnly?: TypeReferenceNode;
|
|
157
|
+
}>;
|
|
158
|
+
refsOnlyMode: Map<string, OnlyModes_2>;
|
|
159
|
+
typeAliases: Record<string, number>;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
declare type OazapftsOptions = {
|
|
163
|
+
include?: string[];
|
|
164
|
+
exclude?: string[];
|
|
165
|
+
optimistic?: boolean;
|
|
166
|
+
unionUndefined?: boolean;
|
|
167
|
+
useEnumType?: boolean;
|
|
168
|
+
mergeReadWriteOnly?: boolean;
|
|
169
|
+
useUnknown?: boolean;
|
|
170
|
+
argumentStyle?: ArgumentStyle;
|
|
171
|
+
/**
|
|
172
|
+
* Plugins to apply during code generation.
|
|
173
|
+
* Each plugin receives hooks and can tap into generation steps.
|
|
174
|
+
*/
|
|
175
|
+
UNSTABLE_plugins?: UNSTABLE_OazapftsPlugin[];
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export declare type OnlyMode = "readOnly" | "writeOnly";
|
|
179
|
+
|
|
180
|
+
declare type OnlyMode_2 = "readOnly" | "writeOnly";
|
|
181
|
+
|
|
182
|
+
export declare type OnlyModes = Record<OnlyMode, boolean>;
|
|
183
|
+
|
|
184
|
+
declare type OnlyModes_2 = Record<OnlyMode_2, boolean>;
|
|
185
|
+
|
|
186
|
+
declare namespace OpenAPI {
|
|
187
|
+
{
|
|
188
|
+
SchemaObject,
|
|
189
|
+
UNSTABLE_DiscriminatingSchemaObject,
|
|
190
|
+
ReferenceObject,
|
|
191
|
+
ParameterObject,
|
|
192
|
+
Document_2 as Document,
|
|
193
|
+
DiscriminatorObject,
|
|
194
|
+
ResponseObject,
|
|
195
|
+
ResponsesObject,
|
|
196
|
+
RequestBodyObject,
|
|
197
|
+
MediaTypeObject,
|
|
198
|
+
OperationObject,
|
|
199
|
+
PathsObject,
|
|
200
|
+
PathItemObject,
|
|
201
|
+
ServerObject
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export declare type ReadonlyDeep<T> = {
|
|
206
|
+
readonly [P in keyof T]: ReadonlyDeep<T[P]>;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
declare type ReadonlyDeep_2<T> = {
|
|
210
|
+
readonly [P in keyof T]: ReadonlyDeep_2<T[P]>;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
declare type SchemaObject = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | boolean;
|
|
214
|
+
|
|
215
|
+
declare type SchemaObject_2 = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | boolean;
|
|
216
|
+
|
|
217
|
+
declare type ServerObject = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
|
|
218
|
+
|
|
219
|
+
declare type ServerObject_2 = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
|
|
220
|
+
|
|
221
|
+
declare enum UNSTABLE_OAZAPFTS_PLUGIN_PRECEDENCE {
|
|
222
|
+
EAGER = "eager",
|
|
223
|
+
DEFAULT = "default",
|
|
224
|
+
LAZY = "lazy"
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare type UNSTABLE_OazapftsPlugin = UNSTABLE_OazapftsPluginFn & UNSTABLE_OazapftsPluginOptions;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* A plugin initiator function that receives hooks and can tap into them.
|
|
231
|
+
*/
|
|
232
|
+
declare type UNSTABLE_OazapftsPluginFn = (hooks: UNSTABLE_OazapftsPluginHooks) => void | Promise<void>;
|
|
233
|
+
|
|
234
|
+
declare type UNSTABLE_OazapftsPluginHooks = {
|
|
235
|
+
/**
|
|
236
|
+
* Called after context is created with all template parts initialized.
|
|
237
|
+
* Use this to modify the spec, context, or template parts.
|
|
238
|
+
* This is the only hook where ctx.spec is mutable.
|
|
239
|
+
*/
|
|
240
|
+
prepare: AsyncSeriesHook<[OazapftsContext_2]>;
|
|
241
|
+
/**
|
|
242
|
+
* Generate or modify a client method for an endpoint.
|
|
243
|
+
* First argument is the array of generated FunctionDeclarations (may be empty).
|
|
244
|
+
* Return modified array to change the methods for this endpoint.
|
|
245
|
+
*/
|
|
246
|
+
generateMethod: AsyncSeriesWaterfallHook<[
|
|
247
|
+
default_2.FunctionDeclaration[],
|
|
248
|
+
{
|
|
249
|
+
method: HttpMethod;
|
|
250
|
+
path: string;
|
|
251
|
+
operation: OpenAPI.OperationObject;
|
|
252
|
+
pathItem: OpenAPI.PathItemObject;
|
|
253
|
+
},
|
|
254
|
+
OazapftsContext_2
|
|
255
|
+
]>;
|
|
256
|
+
/**
|
|
257
|
+
* Called after the full AST has been generated, before printing to string.
|
|
258
|
+
* Use this to add/modify/remove statements from the final source file.
|
|
259
|
+
*/
|
|
260
|
+
astGenerated: AsyncSeriesWaterfallHook<[default_2.SourceFile, OazapftsContext_2]>;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
declare type UNSTABLE_OazapftsPluginOptions = {
|
|
264
|
+
name?: string;
|
|
265
|
+
version?: string;
|
|
266
|
+
precedence?: UNSTABLE_OAZAPFTS_PLUGIN_PRECEDENCE;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export { }
|
package/dist/context.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|