@nxgt/typespec 0.13.1 → 0.14.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/README.md +36 -1
- package/dist/components.d.ts +17 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/document-text.d.ts +7 -0
- package/dist/document-text.d.ts.map +1 -0
- package/dist/emitter.d.ts +3 -1
- package/dist/emitter.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +501 -38
- package/dist/index.js.map +13 -7
- package/dist/lib.d.ts +25 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/marks.d.ts +32 -0
- package/dist/marks.d.ts.map +1 -0
- package/dist/query-operations.d.ts +1 -6
- package/dist/query-operations.d.ts.map +1 -1
- package/dist/response-marks.d.ts +10 -0
- package/dist/response-marks.d.ts.map +1 -0
- package/dist/server-variables.d.ts +10 -0
- package/dist/server-variables.d.ts.map +1 -0
- package/dist/shared-components.d.ts +11 -0
- package/dist/shared-components.d.ts.map +1 -0
- package/docs/README.md +1 -1
- package/docs/guide/emitter.md +147 -1
- package/docs/guide/scalars.md +6 -3
- package/docs/roadmap.md +18 -3
- package/docs/troubleshooting.md +105 -7
- package/lib/components.tsp +65 -0
- package/lib/main.tsp +1 -0
- package/package.json +3 -2
package/dist/index.js.map
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/
|
|
3
|
+
"sources": ["../src/components.ts", "../src/lib.ts", "../src/marks.ts", "../src/server-variables.ts", "../src/one-reply-per-status.ts", "../src/http-operations.ts", "../src/operation-ids.ts", "../src/verbs.ts", "../src/resource.ts", "../src/query-method.ts", "../src/verb-methods.ts", "../src/emitter.ts", "../src/document-text.ts", "../src/query-operations.ts", "../src/response-marks.ts", "../src/shared-components.ts", "../src/linter.ts", "../src/rules/error-body-shape.ts", "../src/rules/written.ts", "../src/rules/list-returns-page.ts", "../src/rules/service-operation-ids.ts", "../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"/**\n * `@sharedResponse`, `@sharedHeader` and `@pathServer`: what the spec asks\n * to be emitted once under `components`, or on one path item. A header and\n * an operation carry their mark (`marks.ts`) until `shared-components.ts`\n * rewrites the emitted document; a response is marked at emit time\n * (`response-marks.ts`).\n */\nimport {\n\ttype DecoratorContext,\n\tgetTypeName,\n\ttype Model,\n\ttype ModelProperty,\n\ttype Operation,\n\ttype Program,\n} from '@typespec/compiler';\nimport { setExtension } from '@typespec/openapi';\nimport { $lib } from './lib';\nimport { COMPONENT_EXTENSION, SERVERS_EXTENSION, type Server } from './marks';\nimport { serverVariables } from './server-variables';\n\n/** What OpenAPI allows a component to be named. */\nconst COMPONENT_NAME = /^[a-zA-Z0-9._-]+$/;\n\nfunction checkedName(\n\tprogram: Program,\n\ttarget: Model | ModelProperty,\n\tname: string,\n): string | undefined {\n\tif (COMPONENT_NAME.test(name)) return name;\n\t$lib.reportDiagnostic(program, {\n\t\tcode: 'invalid-component-name',\n\t\tformat: { name },\n\t\ttarget,\n\t});\n\treturn undefined;\n}\n\nexport function sharedResponse(\n\tcontext: DecoratorContext,\n\ttarget: Model,\n\tname?: string,\n): void {\n\tconst { program } = context;\n\tconst checked = checkedName(program, target, name ?? target.name);\n\tif (checked === undefined) return;\n\tprogram.stateMap($lib.stateKeys.sharedResponses).set(target, checked);\n}\n\nexport function sharedHeader(\n\tcontext: DecoratorContext,\n\ttarget: ModelProperty,\n\tname?: string,\n): void {\n\tconst { program } = context;\n\tconst checked = checkedName(program, target, name ?? target.name);\n\tif (checked === undefined) return;\n\tprogram.stateSet($lib.stateKeys.sharedHeaders).add(target);\n\tsetExtension(program, target, COMPONENT_EXTENSION, checked);\n}\n\nexport function pathServer(\n\tcontext: DecoratorContext,\n\ttarget: Operation,\n\turl: string,\n\tdescription?: string,\n\tparameters?: Model,\n): void {\n\tconst { program } = context;\n\tconst variables =\n\t\tparameters === undefined\n\t\t\t? {}\n\t\t\t: serverVariables(program, target, parameters);\n\tfor (const [, variable] of url.matchAll(/\\{([^}]+)\\}/g)) {\n\t\tif (variable !== undefined && !(variable in variables)) {\n\t\t\t// A variable refused above is reported once, not again as missing.\n\t\t\tif (parameters?.properties.has(variable)) continue;\n\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\tcode: 'path-server-missing-variable',\n\t\t\t\tformat: { operation: target.name, url, variable },\n\t\t\t\ttarget: context.getArgumentTarget(0) ?? target,\n\t\t\t});\n\t\t}\n\t}\n\tconst map = program.stateMap($lib.stateKeys.pathServers);\n\tconst servers: Server[] = map.get(target) ?? [];\n\tservers.push({\n\t\turl,\n\t\t...(description === undefined ? {} : { description }),\n\t\t...(Object.keys(variables).length === 0 ? {} : { variables }),\n\t});\n\tmap.set(target, servers);\n\tsetExtension(\n\t\tprogram,\n\t\ttarget,\n\t\t`${SERVERS_EXTENSION}${getTypeName(target)}`,\n\t\tservers,\n\t);\n}\n\n/**\n * Each marked target must be emitted by `@nxgt/typespec`: `@typespec/openapi3`\n * would write the copies, or drop the servers, without a word.\n */\nexport function validateComponents(program: Program): void {\n\tif (!(program.compilerOptions.emit ?? []).includes('@typespec/openapi3')) {\n\t\treturn;\n\t}\n\tconst marked: [string, string][] = [];\n\tfor (const model of program.stateMap($lib.stateKeys.sharedResponses).keys()) {\n\t\tmarked.push([(model as Model).name, '@sharedResponse']);\n\t}\n\tfor (const property of program.stateSet($lib.stateKeys.sharedHeaders)) {\n\t\tmarked.push([(property as ModelProperty).name, '@sharedHeader']);\n\t}\n\tfor (const operation of program.stateMap($lib.stateKeys.pathServers).keys()) {\n\t\tmarked.push([(operation as Operation).name, '@pathServer']);\n\t}\n\tfor (const [target, decorator] of marked) {\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'shared-needs-nxgt-emitter',\n\t\t\tformat: { target, decorator },\n\t\t\ttarget: program.getGlobalNamespaceType(),\n\t\t});\n\t}\n}\n",
|
|
6
|
+
"/** The library's definition: its name, diagnostics and state keys. */\nimport { createTypeSpecLibrary, paramMessage } from '@typespec/compiler';\n\nexport const $lib = createTypeSpecLibrary({\n\tname: '@nxgt/typespec',\n\tdiagnostics: {\n\t\t'duplicate-operation-id': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`Two operations are named ${'id'}: an OpenAPI operation id must be unique.`,\n\t\t\t},\n\t\t},\n\t\t'resource-name-on-namespace': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault:\n\t\t\t\t\t\"`singular` and `plural` name an interface's resource: a namespace has none. Put them on the interface.\",\n\t\t\t},\n\t\t},\n\t\t'verb-method-mismatch': {\n\t\t\tseverity: 'warning',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is sent with ${'method'}, where its verb ${'verb'} is sent with ${'expected'}. Give it that method, or a name that is not a verb.`,\n\t\t\t},\n\t\t},\n\t\t'query-method-not-post': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is marked @queryMethod and sent with ${'method'}: @queryMethod marks a @post, which @nxgt/typespec writes as a QUERY in OpenAPI 3.2. Make it a @post.`,\n\t\t\t},\n\t\t},\n\t\t'query-method-needs-openapi-3.2': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is marked @queryMethod: only OpenAPI 3.2 has a QUERY operation, and openapi-versions asks for ${'version'}. Emit 3.2 only, or take off @queryMethod.`,\n\t\t\t},\n\t\t},\n\t\t'query-method-needs-nxgt-emitter': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is marked @queryMethod: emit with @nxgt/typespec, which writes it as a QUERY; @typespec/openapi3 would write a POST.`,\n\t\t\t},\n\t\t},\n\t\t'shared-component-conflict': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`Two shared ${'kind'} named ${'name'} differ: a component is emitted once. Give each its own name, or make them the same.`,\n\t\t\t},\n\t\t},\n\t\t'path-server-conflict': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`Two @pathServer of ${'path'} give the server ${'url'} a description or variables that differ. Give the path one definition of it.`,\n\t\t\t},\n\t\t},\n\t\t'path-server-missing-variable': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`The server URL ${'url'} of ${'operation'} has {${'variable'}}, which is not a property of its parameters. Add the variable, or take the braces out.`,\n\t\t\t},\n\t\t},\n\t\t'path-server-invalid-variable': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`The variable ${'variable'} of the @pathServer of ${'operation'} is not a string, a string enum or a union of strings: an OpenAPI server variable is a string.`,\n\t\t\t},\n\t\t},\n\t\t'shared-header-misplaced': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'name'} is marked @sharedHeader outside a response header: it applies to a @header of a reply only, not to a request header or a body property.`,\n\t\t\t},\n\t\t},\n\t\t'shared-response-merged': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`Operations sharing the route ${'verb'} ${'path'} reply ${'status'} with different responses, one of them a @sharedResponse: @sharedRoute merges them into one reply, which cannot be a component. Give them the same shared response, or none.`,\n\t\t\t},\n\t\t},\n\t\t'invalid-component-name': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'name'} is not a name OpenAPI allows for a component: use letters, digits, '.', '_' and '-'.`,\n\t\t\t},\n\t\t},\n\t\t'shared-needs-nxgt-emitter': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'target'} is marked ${'decorator'}: emit with @nxgt/typespec, which writes it; @typespec/openapi3 would write it inline or drop it.`,\n\t\t\t},\n\t\t},\n\t\t'openapi3-missing': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault:\n\t\t\t\t\t'The emitter @nxgt/typespec runs @typespec/openapi3, which is not installed: add it beside @nxgt/typespec.',\n\t\t\t},\n\t\t},\n\t\t'duplicate-status-reply': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} declares a reply without a body and one with a body of status ${'status'}: the emitter merges them into one, and the reply without a body is lost. Declare the one the route sends.`,\n\t\t\t},\n\t\t},\n\t\t'merged-status-reply': {\n\t\t\tseverity: 'warning',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} declares two replies with a body of status ${'status'}: the emitter merges their bodies under the first one's description. Declare the one the route sends.`,\n\t\t\t},\n\t\t},\n\t},\n\t// `@typespec/openapi3` returns before writing anything on a dry run.\n\tcapabilities: { dryRun: true },\n\tstate: {\n\t\tqueryMethod: {\n\t\t\tdescription: 'The operations marked with @queryMethod',\n\t\t},\n\t\tsharedResponses: {\n\t\t\tdescription:\n\t\t\t\t'The models marked with @sharedResponse, to their component name',\n\t\t},\n\t\tsharedHeaders: {\n\t\t\tdescription: 'The properties marked with @sharedHeader',\n\t\t},\n\t\tpathServers: {\n\t\t\tdescription: 'The operations marked with @pathServer, to their servers',\n\t\t},\n\t\toperationIds: {\n\t\t\tdescription: 'The interfaces and namespaces marked with @operationIds',\n\t\t},\n\t\toperationIdsOptions: {\n\t\t\tdescription:\n\t\t\t\t\"Each marked interface's or namespace's @operationIds options\",\n\t\t},\n\t},\n});\n",
|
|
7
|
+
"/**\n * The marks this library writes into the emitted document, which\n * `shared-components.ts` reads and takes off before the text is written. Each\n * rides on the object `@typespec/openapi3` writes for the type it is set on,\n * as `x-nxgt-method` does for `@queryMethod`, so the rewrite never has to\n * infer which service or operation a part of the document came from.\n */\n\n/** On a response header: the component name it is emitted under. */\nexport const COMPONENT_EXTENSION = 'x-nxgt-component';\n\n/**\n * On an operation: its servers, which belong on its path item. The key ends\n * with the operation's name: operations of a `@sharedRoute` merge into one\n * object, and `@typespec/openapi3` lets the last of two equal keys win.\n */\nexport const SERVERS_EXTENSION = 'x-nxgt-servers-';\n\n/** On an operation: the component name of each shared reply, by status. Keyed as the servers are. */\nexport const RESPONSES_EXTENSION = 'x-nxgt-responses-';\n\n/** The keys of an object that carry a mark with this prefix. */\nexport const marksOf = (object: Record<string, unknown>, prefix: string) =>\n\tObject.keys(object).filter((key) => key.startsWith(prefix));\n\n/** Whether a key is one of the marks. */\nexport const isMark = (key: string) =>\n\tkey === COMPONENT_EXTENSION ||\n\tkey.startsWith(SERVERS_EXTENSION) ||\n\tkey.startsWith(RESPONSES_EXTENSION);\n\nexport type ServerVariable = {\n\tdefault: string;\n\tdescription?: string;\n\tenum?: string[];\n};\n\nexport type Server = {\n\turl: string;\n\tdescription?: string;\n\tvariables?: Record<string, ServerVariable>;\n};\n",
|
|
8
|
+
"/**\n * The variables of a `@pathServer` URL, from `@server`'s parameters model: a\n * property's default is the variable's, its doc the description, and its\n * type, a string, a string enum or a union of strings, its `enum`.\n */\nimport {\n\tgetDoc,\n\ttype Model,\n\ttype Operation,\n\ttype Program,\n\tserializeValueAsJson,\n\ttype Type,\n} from '@typespec/compiler';\nimport { $ } from '@typespec/compiler/typekit';\nimport { $lib } from './lib';\nimport type { ServerVariable } from './marks';\n\n/** The values a variable may take, when its type lists them. */\nfunction variableEnum(type: Type): string[] | undefined {\n\tswitch (type.kind) {\n\t\tcase 'String':\n\t\t\treturn [type.value];\n\t\tcase 'Enum':\n\t\t\treturn [...type.members.values()].map((member) =>\n\t\t\t\tString(member.value ?? member.name),\n\t\t\t);\n\t\tcase 'Union': {\n\t\t\tconst values = [...type.variants.values()].map((variant) =>\n\t\t\t\tvariableEnum(variant.type),\n\t\t\t);\n\t\t\treturn values.every((value) => value !== undefined)\n\t\t\t\t? values.flat()\n\t\t\t\t: undefined;\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\n/** Whether a type is a string, as `@server`'s variable must be. */\nfunction isStringType(program: Program, type: Type): boolean {\n\tswitch (type.kind) {\n\t\tcase 'String':\n\t\t\treturn true;\n\t\tcase 'Scalar':\n\t\t\treturn $(program).type.isAssignableTo(\n\t\t\t\ttype,\n\t\t\t\t$(program).builtin.string,\n\t\t\t\ttype,\n\t\t\t);\n\t\tcase 'Enum':\n\t\t\treturn [...type.members.values()].every(\n\t\t\t\t(member) =>\n\t\t\t\t\tmember.value === undefined || typeof member.value === 'string',\n\t\t\t);\n\t\tcase 'Union':\n\t\t\treturn [...type.variants.values()].every((variant) =>\n\t\t\t\tisStringType(program, variant.type),\n\t\t\t);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/** `@server`'s parameters: a property's default is the variable's, its doc the description. */\nexport function serverVariables(\n\tprogram: Program,\n\ttarget: Operation,\n\tparameters: Model,\n): Record<string, ServerVariable> {\n\tconst variables: Record<string, ServerVariable> = {};\n\tfor (const [name, property] of parameters.properties) {\n\t\tif (!isStringType(program, property.type)) {\n\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\tcode: 'path-server-invalid-variable',\n\t\t\t\tformat: { operation: target.name, variable: name },\n\t\t\t\ttarget: property,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst description = getDoc(program, property);\n\t\tconst values = variableEnum(property.type);\n\t\tvariables[name] = {\n\t\t\tdefault:\n\t\t\t\tproperty.defaultValue === undefined\n\t\t\t\t\t? ''\n\t\t\t\t\t: String(\n\t\t\t\t\t\t\tserializeValueAsJson(\n\t\t\t\t\t\t\t\tprogram,\n\t\t\t\t\t\t\t\tproperty.defaultValue,\n\t\t\t\t\t\t\t\tproperty.type,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t...(description === undefined ? {} : { description }),\n\t\t\t...(values === undefined ? {} : { enum: values }),\n\t\t};\n\t}\n\treturn variables;\n}\n",
|
|
5
9
|
"/**\n * One reply per status: `@typespec/openapi3` merges two replies of one\n * status into one without a word. A reply without a body beside one with a\n * body is lost in the merge, an error; a `void` body is none, as the emitter\n * sees it. Two bodies of one content type are merged under the first reply's\n * description, a warning where the status is a code. Under `*` or a range,\n * where undocumented `@error` models share one description, they pass.\n * Bodies of different content types are one reply, negotiated, and pass.\n */\nimport { isVoidType, type Program } from '@typespec/compiler';\nimport type {\n\tHttpOperationResponse,\n\tHttpStatusCodesEntry,\n} from '@typespec/http';\nimport { eachHttpOperation } from './http-operations';\nimport { $lib } from './lib';\n\nfunction statusOf(code: HttpStatusCodesEntry): string {\n\treturn typeof code === 'object' ? `${code.start}-${code.end}` : `${code}`;\n}\n\n/** What the emitter's merge costs: a reply, a description, or nothing. */\nfunction mergeOf({\n\tstatusCodes,\n\tresponses,\n}: HttpOperationResponse):\n\t| 'duplicate-status-reply'\n\t| 'merged-status-reply'\n\t| undefined {\n\tconst bodies = responses.flatMap(({ body }) =>\n\t\tbody && !isVoidType(body.type) ? [body] : [],\n\t);\n\tif (bodies.length > 0 && bodies.length < responses.length) {\n\t\treturn 'duplicate-status-reply';\n\t}\n\tif (typeof statusCodes !== 'number') return undefined;\n\tconst seen = new Set<string>();\n\tfor (const body of bodies) {\n\t\tif (body.contentTypes.some((type) => seen.has(type))) {\n\t\t\treturn 'merged-status-reply';\n\t\t}\n\t\tfor (const type of body.contentTypes) seen.add(type);\n\t}\n\treturn undefined;\n}\n\n/** Checks each operation of each service, as the emitter sees it, once. */\nexport function validateOneReplyPerStatus(program: Program): void {\n\teachHttpOperation(program, (operation) => {\n\t\tfor (const response of operation.responses) {\n\t\t\tconst code = mergeOf(response);\n\t\t\tif (code === undefined) continue;\n\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\tcode,\n\t\t\t\tformat: {\n\t\t\t\t\toperation: operation.operation.name,\n\t\t\t\t\tstatus: statusOf(response.statusCodes),\n\t\t\t\t},\n\t\t\t\ttarget: operation.operation,\n\t\t\t});\n\t\t}\n\t});\n}\n",
|
|
6
10
|
"/**\n * Each HTTP operation of each service, once, as the emitter sends it: a\n * service nested in another lists its operations in both. The services' own\n * diagnostics are the emitter's to report.\n */\nimport type { Program } from '@typespec/compiler';\nimport { getAllHttpServices, type HttpOperation } from '@typespec/http';\n\nexport function eachHttpOperation(\n\tprogram: Program,\n\tvisit: (operation: HttpOperation) => void,\n): void {\n\tconst [services] = getAllHttpServices(program);\n\tconst visited = new Set<HttpOperation['operation']>();\n\tfor (const service of services) {\n\t\tfor (const operation of service.operations) {\n\t\t\tif (visited.has(operation.operation)) continue;\n\t\t\tvisited.add(operation.operation);\n\t\t\tvisit(operation);\n\t\t}\n\t}\n}\n",
|
|
7
|
-
"/** The library's definition: its name, diagnostics and state keys. */\nimport { createTypeSpecLibrary, paramMessage } from '@typespec/compiler';\n\nexport const $lib = createTypeSpecLibrary({\n\tname: '@nxgt/typespec',\n\tdiagnostics: {\n\t\t'duplicate-operation-id': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`Two operations are named ${'id'}: an OpenAPI operation id must be unique.`,\n\t\t\t},\n\t\t},\n\t\t'resource-name-on-namespace': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault:\n\t\t\t\t\t\"`singular` and `plural` name an interface's resource: a namespace has none. Put them on the interface.\",\n\t\t\t},\n\t\t},\n\t\t'verb-method-mismatch': {\n\t\t\tseverity: 'warning',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is sent with ${'method'}, where its verb ${'verb'} is sent with ${'expected'}. Give it that method, or a name that is not a verb.`,\n\t\t\t},\n\t\t},\n\t\t'query-method-not-post': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is marked @queryMethod and sent with ${'method'}: @queryMethod marks a @post, which @nxgt/typespec writes as a QUERY in OpenAPI 3.2. Make it a @post.`,\n\t\t\t},\n\t\t},\n\t\t'query-method-needs-openapi-3.2': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is marked @queryMethod: only OpenAPI 3.2 has a QUERY operation, and openapi-versions asks for ${'version'}. Emit 3.2 only, or take off @queryMethod.`,\n\t\t\t},\n\t\t},\n\t\t'query-method-needs-nxgt-emitter': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is marked @queryMethod: emit with @nxgt/typespec, which writes it as a QUERY; @typespec/openapi3 would write a POST.`,\n\t\t\t},\n\t\t},\n\t\t'openapi3-missing': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault:\n\t\t\t\t\t'The emitter @nxgt/typespec runs @typespec/openapi3, which is not installed: add it beside @nxgt/typespec.',\n\t\t\t},\n\t\t},\n\t\t'duplicate-status-reply': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} declares a reply without a body and one with a body of status ${'status'}: the emitter merges them into one, and the reply without a body is lost. Declare the one the route sends.`,\n\t\t\t},\n\t\t},\n\t\t'merged-status-reply': {\n\t\t\tseverity: 'warning',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} declares two replies with a body of status ${'status'}: the emitter merges their bodies under the first one's description. Declare the one the route sends.`,\n\t\t\t},\n\t\t},\n\t},\n\t// `@typespec/openapi3` returns before writing anything on a dry run.\n\tcapabilities: { dryRun: true },\n\tstate: {\n\t\tqueryMethod: {\n\t\t\tdescription: 'The operations marked with @queryMethod',\n\t\t},\n\t\toperationIds: {\n\t\t\tdescription: 'The interfaces and namespaces marked with @operationIds',\n\t\t},\n\t\toperationIdsOptions: {\n\t\t\tdescription:\n\t\t\t\t\"Each marked interface's or namespace's @operationIds options\",\n\t\t},\n\t},\n});\n",
|
|
8
11
|
"/**\n * `@operationIds`: the id of each operation is its name, as written:\n * `@get findPostComments()` is `findPostComments`, where `@typespec/openapi3`\n * would write `Posts_findPostComments`. In an interface, a known verb takes\n * the interface's resource: `create` in `Users` is `createUser` (`verbs.ts`).\n */\nimport {\n\ttype DecoratorContext,\n\ttype Interface,\n\tisService,\n\tisTemplateInstance,\n\tlistServices,\n\ttype Namespace,\n\tnavigateProgram,\n\ttype Operation,\n\ttype Program,\n} from '@typespec/compiler';\nimport {\n\tgetOperationId,\n\tresolveOperationId,\n\tsetOperationId,\n} from '@typespec/openapi';\nimport { $lib } from './lib';\nimport { idOf, type OperationIdsOptions } from './resource';\n\n/**\n * Marks the interface or the namespace; its ids are set once the program is\n * checked. On a template, TypeSpec runs it on each instance, which\n * `isMarkedInterface` follows to the interfaces extending it. A namespace\n * has no resource to name: `singular` and `plural` are an interface's.\n */\nexport function operationIds(\n\tcontext: DecoratorContext,\n\ttarget: Interface | Namespace,\n\toptions: OperationIdsOptions = {},\n): void {\n\tconst { program } = context;\n\tprogram.stateSet($lib.stateKeys.operationIds).add(target);\n\tprogram.stateMap($lib.stateKeys.operationIdsOptions).set(target, options);\n\tif (\n\t\ttarget.kind === 'Namespace' &&\n\t\t(options.singular !== undefined || options.plural !== undefined)\n\t) {\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'resource-name-on-namespace',\n\t\t\ttarget: context.decoratorTarget,\n\t\t});\n\t}\n}\n\n/** Marked itself, or in a marked namespace, however deep. */\nexport function isMarkedNamespace(\n\tprogram: Program,\n\ttarget: Namespace | undefined,\n): boolean {\n\tfor (let at = target; at !== undefined; at = at.namespace) {\n\t\tif (program.stateSet($lib.stateKeys.operationIds).has(at)) return true;\n\t}\n\treturn false;\n}\n\n/** Marked itself, or extending a marked interface: an instance of a marked template included. */\nfunction isMarkedInterface(program: Program, target: Interface): boolean {\n\treturn (\n\t\tprogram.stateSet($lib.stateKeys.operationIds).has(target) ||\n\t\ttarget.sourceInterfaces.some((source) => isMarkedInterface(program, source))\n\t);\n}\n\n/**\n * Whether `@operationIds` names the operation's id, or checks it: its\n * interface or one of its namespaces is marked. An interface template's\n * instance is never emitted; only the interfaces extending it are.\n */\nexport function isNamed(program: Program, operation: Operation): boolean {\n\tconst container = operation.interface;\n\tif (container === undefined) {\n\t\treturn isMarkedNamespace(program, operation.namespace);\n\t}\n\treturn (\n\t\t!isTemplateInstance(container) &&\n\t\t(isMarkedInterface(program, container) ||\n\t\t\tisMarkedNamespace(program, container.namespace))\n\t);\n}\n\n/**\n * Whether the emitter writes the operation: not an instance of an operation\n * template, `Read<Pet>`, nor an operation of an interface template's\n * instance. An interface extending an instance copies its operations, which\n * are instances too, and emitted.\n */\nexport function isEmitted(operation: Operation): boolean {\n\tconst container = operation.interface;\n\tif (container === undefined) return !isTemplateInstance(operation);\n\treturn !isTemplateInstance(container);\n}\n\n/**\n * The services whose document the operation is in: each `@service`\n * namespace around it, a nested one and the one outside it both. None, in a\n * program without a service, is the one document the emitter writes; in a\n * program with one, no document at all.\n */\nfunction servicesOf(program: Program, operation: Operation): Namespace[] {\n\tconst services: Namespace[] = [];\n\tfor (\n\t\tlet at = operation.interface?.namespace ?? operation.namespace;\n\t\tat !== undefined;\n\t\tat = at.namespace\n\t) {\n\t\tif (isService(program, at)) services.push(at);\n\t}\n\treturn services;\n}\n\n/**\n * Sets the ids, after every decorator, so the order of `@operationId` and\n * `@operationIds` in the source does not matter. Two operations with one id\n * in one service's document, one of them named by `@operationIds`, are an\n * error: one name in two interfaces, an interface that `extends` another and\n * so copies its operations, or an `@operationId` written elsewhere.\n * `@typespec/openapi3` would emit both without a word. An operation\n * template's instance, such as `Read<Pet>`, is never emitted; only the\n * operations declared from it (`op readPet is Read<Pet>`) are.\n */\nexport function validateOperationIds(program: Program): void {\n\tconst seen = new Map<Namespace | undefined, Map<string, boolean>>();\n\tconst hasServices = listServices(program).length > 0;\n\tnavigateProgram(program, {\n\t\toperation(operation) {\n\t\t\tif (!isEmitted(operation)) return;\n\t\t\tconst named = isNamed(program, operation);\n\t\t\tconst own = getOperationId(program, operation);\n\t\t\t// Elsewhere, only checked: the id `@typespec/openapi3` gives under its\n\t\t\t// default strategy.\n\t\t\tconst id =\n\t\t\t\town ??\n\t\t\t\t(named\n\t\t\t\t\t? idOf(program, operation)\n\t\t\t\t\t: resolveOperationId(program, operation));\n\t\t\tconst services = servicesOf(program, operation);\n\t\t\t// Outside every service of a program that has one: in no document.\n\t\t\tconst emitted = services.length > 0 || !hasServices;\n\t\t\tlet duplicate = false;\n\t\t\tfor (const service of services.length > 0 ? services : [undefined]) {\n\t\t\t\tconst ids = seen.get(service) ?? new Map<string, boolean>();\n\t\t\t\tseen.set(service, ids);\n\t\t\t\tif (emitted && ids.has(id) && (named || ids.get(id))) duplicate = true;\n\t\t\t\tids.set(id, named || (ids.get(id) ?? false));\n\t\t\t}\n\t\t\tif (duplicate) {\n\t\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\t\tcode: 'duplicate-operation-id',\n\t\t\t\t\tformat: { id },\n\t\t\t\t\ttarget: operation,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// Only the ids it gives: an explicit id on any other operation would\n\t\t\t// override the emitter's `operation-id-strategy`.\n\t\t\tif (named && own === undefined) setOperationId(program, operation, id);\n\t\t},\n\t});\n}\n",
|
|
9
12
|
"/**\n * The verbs `@operationIds` completes with an interface's resource: `create`\n * in `Users` is `createUser`, `list` is `listUsers`, and `findById` is\n * `findUserById`. Any other name is the id as written.\n */\n\n/** Whether a verb takes the resource's singular or its plural. */\nexport type Grammar = 'singular' | 'plural';\n\n/** A resource's two names: `User` and `Users`. */\nexport interface Resource {\n\treadonly singular: string;\n\treadonly plural: string;\n}\n\n/** The library's own verbs. */\nexport const VERBS: Readonly<Record<string, Grammar>> = {\n\tlist: 'plural',\n\tread: 'plural',\n\tfind: 'plural',\n\tsearch: 'plural',\n\tquery: 'plural',\n\tcount: 'plural',\n\tcreateMany: 'plural',\n\tupdateMany: 'plural',\n\tdeleteMany: 'plural',\n\tget: 'singular',\n\tcreate: 'singular',\n\tupdate: 'singular',\n\tpatch: 'singular',\n\treplace: 'singular',\n\tupsert: 'singular',\n\tdelete: 'singular',\n};\n\n/**\n * The HTTP methods each of the library's verbs is sent with: a read is a\n * `GET` (or a `HEAD`), a search may carry its criteria in a `POST` body, a\n * bulk delete its ids. A `QUERY`, a `POST` marked `@queryMethod`, is\n * a search too.\n */\nexport const METHODS: Readonly<Record<string, readonly string[]>> = {\n\tlist: ['get', 'head'],\n\tread: ['get', 'head'],\n\tfind: ['get', 'head'],\n\tcount: ['get', 'head'],\n\tget: ['get', 'head'],\n\tsearch: ['get', 'post', 'query'],\n\tquery: ['get', 'post', 'query'],\n\tcreate: ['post'],\n\tcreateMany: ['post'],\n\tupdate: ['put', 'patch'],\n\tupdateMany: ['put', 'patch'],\n\tpatch: ['patch'],\n\treplace: ['put'],\n\tupsert: ['put'],\n\tdelete: ['delete'],\n\tdeleteMany: ['delete', 'post'],\n};\n\n/** Plurals the rules below get wrong, by their singular. */\nconst IRREGULAR: Readonly<Record<string, string>> = {\n\tpeople: 'person',\n\tchildren: 'child',\n\tmen: 'man',\n\twomen: 'woman',\n\tmice: 'mouse',\n\tfeet: 'foot',\n\tteeth: 'tooth',\n\tgeese: 'goose',\n\tmovies: 'movie',\n\tcookies: 'cookie',\n\tseries: 'series',\n\tspecies: 'species',\n\tnews: 'news',\n};\n\n/** `-es` plurals of a singular in `-us`: `Statuses`, not `Houses`. */\nconst US_ES = /(stat|bon|camp|vir|b|foc|cens|corp|radi|syllab)uses$/i;\n\n/** `-es` plurals of a singular in a sibilant: `Boxes`, `Matches`, `Wishes`. */\nconst SIBILANT_ES = /(ss|x|zz|sh|tch|nch|rch|oach)es$/i;\n\n/**\n * The singular of a plural name, by a short English rule on its last word:\n * `Users`, `BlogPosts`, `Categories`, `Addresses`, `Statuses`, `People`. A\n * guess: it misses some (`Heroes`, `Analysis`), which `singular` names.\n */\nexport function singularOf(plural: string): string {\n\tconst word = /[A-Z]?[a-z0-9]*$/.exec(plural)?.[0] ?? '';\n\tconst head = plural.slice(0, plural.length - word.length);\n\tconst key = word.toLowerCase();\n\tconst irregular = Object.hasOwn(IRREGULAR, key) ? IRREGULAR[key] : undefined;\n\tif (irregular !== undefined) {\n\t\tconst cased = word[0] === word[0]?.toUpperCase();\n\t\treturn `${head}${cased ? irregular[0]?.toUpperCase() + irregular.slice(1) : irregular}`;\n\t}\n\tif (/ies$/.test(word) && word.length > 4)\n\t\treturn `${head}${word.slice(0, -3)}y`;\n\tif (US_ES.test(word) || SIBILANT_ES.test(word)) {\n\t\treturn `${head}${word.slice(0, -2)}`;\n\t}\n\tif (/[^su]s$/.test(word)) return `${head}${word.slice(0, -1)}`;\n\treturn plural;\n}\n\n/**\n * The verb a name starts with, and the rest: the whole name, `list`, or the\n * verb before a `By`, `findById`. `undefined` when the name is neither.\n */\nexport function verbIn(\n\tname: string,\n\tverbs: Readonly<Record<string, Grammar>>,\n): { readonly verb: string; readonly rest: string } | undefined {\n\tif (Object.hasOwn(verbs, name)) return { verb: name, rest: '' };\n\tfor (const by of name.matchAll(/By[A-Z]/g)) {\n\t\tconst verb = name.slice(0, by.index);\n\t\tif (verb !== '' && Object.hasOwn(verbs, verb)) {\n\t\t\treturn { verb, rest: name.slice(by.index) };\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * The id of an operation of a resource: the verb and the resource's singular\n * or plural, or the verb, the resource and the rest of a `By` name:\n * `findById` to `findUserById`, the singular, but `deleteManyByTeam` to\n * `deleteManyUsersByTeam`, the plural of a `*Many` verb. `undefined` when\n * the name is none of them. The resource is taken only then.\n */\nexport function idWithVerb(\n\tname: string,\n\tresource: () => Resource,\n\tverbs: Readonly<Record<string, Grammar>>,\n): string | undefined {\n\tconst found = verbIn(name, verbs);\n\tif (found === undefined) return undefined;\n\tconst { verb, rest } = found;\n\tconst names = resource();\n\tconst noun =\n\t\trest === ''\n\t\t\t? names[verbs[verb] as Grammar]\n\t\t\t: verb.endsWith('Many')\n\t\t\t\t? names.plural\n\t\t\t\t: names.singular;\n\treturn `${verb}${noun}${rest}`;\n}\n",
|
|
10
13
|
"/**\n * What `@operationIds` names an operation of an interface after: the\n * interface's resource, its singular and plural, and the verbs that take\n * them, layered from the library's, the namespaces', and the interface's.\n */\nimport type {\n\tInterface,\n\tNamespace,\n\tOperation,\n\tProgram,\n} from '@typespec/compiler';\nimport { $lib } from './lib';\nimport {\n\ttype Grammar,\n\tidWithVerb,\n\ttype Resource,\n\tsingularOf,\n\tVERBS,\n\tverbIn,\n} from './verbs';\n\n/** `@operationIds`' options, as `OperationIdsOptions` declares them. */\nexport interface OperationIdsOptions {\n\treadonly singular?: string;\n\treadonly plural?: string;\n\treadonly verbs?: Readonly<Record<string, Grammar>>;\n}\n\nfunction optionsOf(\n\tprogram: Program,\n\ttarget: Interface | Namespace,\n): OperationIdsOptions | undefined {\n\treturn program.stateMap($lib.stateKeys.operationIdsOptions).get(target);\n}\n\n/** The interface, then those it extends, however deep. */\nfunction lineageOf(target: Interface): Interface[] {\n\treturn [target, ...target.sourceInterfaces.flatMap(lineageOf)];\n}\n\n/**\n * The verbs an interface's operations take: the library's, then each marked\n * namespace's around it, outermost first, then its lineage's, its own last,\n * each overriding the one before.\n */\nfunction verbsOf(program: Program, target: Interface): Record<string, Grammar> {\n\tconst namespaces: Namespace[] = [];\n\tfor (let at = target.namespace; at !== undefined; at = at.namespace) {\n\t\tnamespaces.unshift(at);\n\t}\n\tconst layers = [...namespaces, ...lineageOf(target).reverse()];\n\treturn Object.assign(\n\t\t{},\n\t\tVERBS,\n\t\t...layers.map((layer) => optionsOf(program, layer)?.verbs ?? {}),\n\t);\n}\n\n/**\n * An interface's resource: its own `plural`, or its name, and its own\n * `singular`, or the plural's singular. Never an interface it extends: two\n * interfaces extending one would share its names, and collide.\n */\nfunction resourceOf(program: Program, target: Interface): Resource {\n\tconst options = optionsOf(program, target);\n\tconst plural = options?.plural || target.name;\n\treturn { plural, singular: options?.singular || singularOf(plural) };\n}\n\n/** The id `@operationIds` gives: the name as written, or a verb with its resource. */\nexport function idOf(program: Program, operation: Operation): string {\n\tconst container = operation.interface;\n\tif (container === undefined) return operation.name;\n\treturn (\n\t\tidWithVerb(\n\t\t\toperation.name,\n\t\t\t() => resourceOf(program, container),\n\t\t\tverbsOf(program, container),\n\t\t) ?? operation.name\n\t);\n}\n\n/** The verb an operation of an interface is named with, `find` in `findById`. */\nexport function verbOf(\n\tprogram: Program,\n\toperation: Operation,\n): string | undefined {\n\tconst container = operation.interface;\n\tif (container === undefined) return undefined;\n\treturn verbIn(operation.name, verbsOf(program, container))?.verb;\n}\n",
|
|
11
14
|
"/**\n * `@queryMethod`: a `POST` that is a `QUERY`, a safe request with its\n * criteria in the body. `@typespec/http` declares no `QUERY` yet, so the\n * operation is sent as a `POST` and the document marks it,\n * `x-nxgt-method: query`, for `@nxgt/openapi-codegen`.\n */\nimport type { DecoratorContext, Operation, Program } from '@typespec/compiler';\nimport { setExtension } from '@typespec/openapi';\nimport { eachHttpOperation } from './http-operations';\nimport { $lib } from './lib';\n\nexport function queryMethod(\n\tcontext: DecoratorContext,\n\ttarget: Operation,\n): void {\n\tconst { program } = context;\n\tprogram.stateSet($lib.stateKeys.queryMethod).add(target);\n\tsetExtension(program, target, 'x-nxgt-method', 'query');\n}\n\n/** Marked with `@queryMethod`. */\nexport function isQueryMethod(program: Program, operation: Operation): boolean {\n\treturn program.stateSet($lib.stateKeys.queryMethod).has(operation);\n}\n\n/** The operations marked with `@queryMethod`, each once. */\nexport function queryMethods(program: Program): Operation[] {\n\treturn [...program.stateSet($lib.stateKeys.queryMethod)] as Operation[];\n}\n\n/**\n * Each marked operation is a `POST`, as the emitter sends it, and is emitted\n * by `@nxgt/typespec`: `@typespec/openapi3` alone would write the `POST`.\n */\nexport function validateQueryMethods(program: Program): void {\n\teachHttpOperation(program, ({ operation, verb: method }) => {\n\t\tif (!isQueryMethod(program, operation) || method === 'post') return;\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'query-method-not-post',\n\t\t\tformat: { operation: operation.name, method: method.toUpperCase() },\n\t\t\ttarget: operation,\n\t\t});\n\t});\n\tif (!(program.compilerOptions.emit ?? []).includes('@typespec/openapi3')) {\n\t\treturn;\n\t}\n\tfor (const operation of queryMethods(program)) {\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'query-method-needs-nxgt-emitter',\n\t\t\tformat: { operation: operation.name },\n\t\t\ttarget: operation,\n\t\t});\n\t}\n}\n",
|
|
12
15
|
"/**\n * A verb names what an operation does, and its method says the same:\n * `create` in `Users` is `createUser`, and a `GET` would tell a cache, a\n * proxy or a retry it is safe. An operation `@operationIds` names after one\n * of the library's verbs is sent with that verb's methods (`verbs.ts`), or\n * warned of. A verb `verbs` adds has no method to check, and an operation's\n * own `@operationId` is an id that is no verb. It runs before\n * `validateOperationIds` sets the others.\n */\nimport type { Program } from '@typespec/compiler';\nimport { getOperationId } from '@typespec/openapi';\nimport { eachHttpOperation } from './http-operations';\nimport { $lib } from './lib';\nimport { isNamed } from './operation-ids';\nimport { isQueryMethod } from './query-method';\nimport { verbOf } from './resource';\nimport { METHODS } from './verbs';\n\n/** `PUT or PATCH`. */\nfunction methodsOf(methods: readonly string[]): string {\n\treturn methods.map((method) => method.toUpperCase()).join(' or ');\n}\n\n/** Checks each operation of each service once, as the emitter sends it. */\nexport function validateVerbMethods(program: Program): void {\n\teachHttpOperation(program, ({ operation, verb: sent }) => {\n\t\tif (!isNamed(program, operation)) return;\n\t\tif (getOperationId(program, operation) !== undefined) return;\n\t\tconst verb = verbOf(program, operation);\n\t\tif (verb === undefined || !Object.hasOwn(METHODS, verb)) return;\n\t\t// A `POST` marked `@queryMethod` is checked as the `QUERY` it is.\n\t\tconst method =\n\t\t\tsent === 'post' && isQueryMethod(program, operation) ? 'query' : sent;\n\t\tconst expected = METHODS[verb] as readonly string[];\n\t\tif (expected.includes(method)) return;\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'verb-method-mismatch',\n\t\t\tformat: {\n\t\t\t\toperation: operation.name,\n\t\t\t\tmethod: method.toUpperCase(),\n\t\t\t\tverb,\n\t\t\t\texpected: methodsOf(expected),\n\t\t\t},\n\t\t\ttarget: operation,\n\t\t});\n\t});\n}\n",
|
|
13
|
-
"/**\n * The emitter `@nxgt/typespec`: `@typespec/openapi3`, with its options,\n * checked by its own schema, and its files, and each `POST` marked\n * `@queryMethod` a real `QUERY` in an OpenAPI 3.2 document\n * (`query-operations.ts`). Only 3.2 has a `QUERY`: a marked operation with\n * an older version asked for is an error, and nothing is emitted.\n * `@typespec/openapi3` is loaded only here, so a spec that only imports the\n * library does not need it.\n */\nimport {\n\ttype CompilerHost,\n\ttype Diagnostic,\n\ttype EmitContext,\n\tNoTarget,\n} from '@typespec/compiler';\nimport { $lib } from './lib';\nimport { queryMethods } from './query-method';\nimport { withQueryOperations } from './query-operations';\n\n/** `@typespec/openapi3`'s default, when `openapi-versions` is not set. */\nconst DEFAULT_VERSIONS = ['3.0.0'];\n\ntype OpenAPI3 = typeof import('@typespec/openapi3');\n\n/**\n * `@typespec/openapi3`'s options checked by its own schema, as the compiler\n * checks them under its name: `createTypeSpecLibrary` gives each library an\n * `emitterOptionValidator`, which its types leave out.\n */\nfunction invalidOptions(\n\topenapi3: OpenAPI3,\n\toptions: unknown,\n): readonly Diagnostic[] {\n\tconst lib: object = openapi3.$lib;\n\tconst validator =\n\t\t'emitterOptionValidator' in lib ? lib.emitterOptionValidator : undefined;\n\tif (\n\t\ttypeof validator !== 'object' ||\n\t\tvalidator === null ||\n\t\t!('validate' in validator) ||\n\t\ttypeof validator.validate !== 'function'\n\t) {\n\t\treturn [];\n\t}\n\treturn validator.validate(options, NoTarget);\n}\n\nasync function loadOpenAPI3(\n\tcontext: EmitContext,\n): Promise<OpenAPI3 | undefined> {\n\ttry {\n\t\treturn await import('@typespec/openapi3');\n\t} catch {\n\t\t$lib.reportDiagnostic(context.program, {\n\t\t\tcode: 'openapi3-missing',\n\t\t\ttarget: NoTarget,\n\t\t});\n\t\treturn undefined;\n\t}\n}\n\n/** Whether every version asked for has a `QUERY`; each marked operation is reported otherwise. */\nfunction queriesFit(context: EmitContext): boolean {\n\tconst { program } = context;\n\tconst marked = queryMethods(program);\n\tif (marked.length === 0) return true;\n\tconst versions =\n\t\t(context.options['openapi-versions'] as string[] | undefined) ??\n\t\tDEFAULT_VERSIONS;\n\tconst older = versions.find((version) => !version.startsWith('3.2'));\n\tif (older === undefined) return true;\n\tfor (const operation of marked) {\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'query-method-needs-openapi-3.2',\n\t\t\tformat: { operation: operation.name, version: older },\n\t\t\ttarget: operation,\n\t\t});\n\t}\n\treturn false;\n}\n\nexport async function $onEmit(context: EmitContext): Promise<void> {\n\tconst openapi3 = await loadOpenAPI3(context);\n\tif (openapi3 === undefined) return;\n\tconst { program } = context;\n\t// `@typespec/openapi3`'s schema: a typo or a bad value is refused, as\n\t// under its own name, instead of reaching it unchecked.\n\tconst invalid = invalidOptions(openapi3, context.options);\n\tif (invalid.length > 0) {\n\t\tprogram.reportDiagnostics(invalid);\n\t\treturn;\n\t}\n\tif (!queriesFit(context)) return;\n\t// Every file `@typespec/openapi3` writes goes through `program.host`: a\n\t// stand-in whose every call is the real host's, on the real host.\n\tconst host = program.host;\n\tconst writing = new Proxy(host, {\n\t\tget(target, key) {\n\t\t\tif (key === 'writeFile') {\n\t\t\t\treturn (path: string, content: string) =>\n\t\t\t\t\ttarget.writeFile(
|
|
14
|
-
"/**\n *
|
|
16
|
+
"/**\n * The emitter `@nxgt/typespec`: `@typespec/openapi3`, with its options,\n * checked by its own schema, and its files, and each `POST` marked\n * `@queryMethod` a real `QUERY` in an OpenAPI 3.2 document\n * (`query-operations.ts`), and what `@sharedResponse`, `@sharedHeader` and\n * `@pathServer` ask: components emitted once, servers on a path item\n * (`shared-components.ts`). Only 3.2 has a `QUERY`: a marked operation with\n * an older version asked for is an error, and nothing is emitted.\n * `@typespec/openapi3` is loaded only here, so a spec that only imports the\n * library does not need it.\n */\nimport {\n\ttype CompilerHost,\n\ttype Diagnostic,\n\ttype EmitContext,\n\tNoTarget,\n\ttype Program,\n} from '@typespec/compiler';\nimport { $lib } from './lib';\nimport { queryMethods } from './query-method';\nimport { withQueryOperations } from './query-operations';\nimport { markSharedResponses } from './response-marks';\nimport { type Problem, withComponents } from './shared-components';\n\n/** `@typespec/openapi3`'s default, when `openapi-versions` is not set. */\nconst DEFAULT_VERSIONS = ['3.0.0'];\n\ntype OpenAPI3 = typeof import('@typespec/openapi3');\n\n/**\n * `@typespec/openapi3`'s options checked by its own schema, as the compiler\n * checks them under its name: `createTypeSpecLibrary` gives each library an\n * `emitterOptionValidator`, which its types leave out.\n */\nfunction invalidOptions(\n\topenapi3: OpenAPI3,\n\toptions: unknown,\n): readonly Diagnostic[] {\n\tconst lib: object = openapi3.$lib;\n\tconst validator =\n\t\t'emitterOptionValidator' in lib ? lib.emitterOptionValidator : undefined;\n\tif (\n\t\ttypeof validator !== 'object' ||\n\t\tvalidator === null ||\n\t\t!('validate' in validator) ||\n\t\ttypeof validator.validate !== 'function'\n\t) {\n\t\treturn [];\n\t}\n\treturn validator.validate(options, NoTarget);\n}\n\nasync function loadOpenAPI3(\n\tcontext: EmitContext,\n): Promise<OpenAPI3 | undefined> {\n\ttry {\n\t\treturn await import('@typespec/openapi3');\n\t} catch {\n\t\t$lib.reportDiagnostic(context.program, {\n\t\t\tcode: 'openapi3-missing',\n\t\t\ttarget: NoTarget,\n\t\t});\n\t\treturn undefined;\n\t}\n}\n\n/** Whether every version asked for has a `QUERY`; each marked operation is reported otherwise. */\nfunction queriesFit(context: EmitContext): boolean {\n\tconst { program } = context;\n\tconst marked = queryMethods(program);\n\tif (marked.length === 0) return true;\n\tconst versions =\n\t\t(context.options['openapi-versions'] as string[] | undefined) ??\n\t\tDEFAULT_VERSIONS;\n\tconst older = versions.find((version) => !version.startsWith('3.2'));\n\tif (older === undefined) return true;\n\tfor (const operation of marked) {\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'query-method-needs-openapi-3.2',\n\t\t\tformat: { operation: operation.name, version: older },\n\t\t\ttarget: operation,\n\t\t});\n\t}\n\treturn false;\n}\n\n/** One report per kind and name, whatever the number of versions written. */\nfunction reportProblems(program: Program, problems: Problem[]): void {\n\tconst seen = new Set<string>();\n\tfor (const problem of problems) {\n\t\tconst key = JSON.stringify(problem);\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tif (problem.kind === 'server') {\n\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\tcode: 'path-server-conflict',\n\t\t\t\tformat: { path: problem.path, url: problem.url },\n\t\t\t\ttarget: NoTarget,\n\t\t\t});\n\t\t} else if (problem.kind === 'misplaced') {\n\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\tcode: 'shared-header-misplaced',\n\t\t\t\tformat: { name: problem.name },\n\t\t\t\ttarget: NoTarget,\n\t\t\t});\n\t\t} else {\n\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\tcode: 'shared-component-conflict',\n\t\t\t\tformat: { kind: problem.kind, name: problem.name },\n\t\t\t\ttarget: NoTarget,\n\t\t\t});\n\t\t}\n\t}\n}\n\nexport async function $onEmit(context: EmitContext): Promise<void> {\n\tconst openapi3 = await loadOpenAPI3(context);\n\tif (openapi3 === undefined) return;\n\tconst { program } = context;\n\t// `@typespec/openapi3`'s schema: a typo or a bad value is refused, as\n\t// under its own name, instead of reaching it unchecked.\n\tconst invalid = invalidOptions(openapi3, context.options);\n\tif (invalid.length > 0) {\n\t\tprogram.reportDiagnostics(invalid);\n\t\treturn;\n\t}\n\tif (!queriesFit(context)) return;\n\t// Every file `@typespec/openapi3` writes goes through `program.host`: a\n\t// stand-in whose every call is the real host's, on the real host.\n\tconst host = program.host;\n\tmarkSharedResponses(program);\n\tconst problems: Problem[] = [];\n\tconst writing = new Proxy(host, {\n\t\tget(target, key) {\n\t\t\tif (key === 'writeFile') {\n\t\t\t\treturn (path: string, content: string) =>\n\t\t\t\t\ttarget.writeFile(\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\t// Components first: the paths still say `post`.\n\t\t\t\t\t\twithQueryOperations(withComponents(content, problems)),\n\t\t\t\t\t);\n\t\t\t}\n\t\t\tconst value = Reflect.get(target, key, target);\n\t\t\treturn typeof value === 'function' ? value.bind(target) : value;\n\t\t},\n\t}) satisfies CompilerHost;\n\tprogram.host = writing;\n\ttry {\n\t\tawait openapi3.$onEmit(context as Parameters<OpenAPI3['$onEmit']>[0]);\n\t} finally {\n\t\tprogram.host = host;\n\t}\n\treportProblems(program, problems);\n}\n",
|
|
17
|
+
"/**\n * An emitted OpenAPI document read from its text and written back as\n * `@typespec/openapi3` writes it, for the rewrites of this emitter. The\n * format is the text's: YAML whatever the file is named, unless `file-type`\n * says JSON. Line endings stay as written: `new-line: crlf` reaches here\n * already applied.\n */\nimport { parse, stringify } from 'yaml';\n\nexport type Document = Record<string, unknown>;\n\n/**\n * The text with `rewrite` applied to its document, and left as it was when\n * `rewrite` says nothing changed.\n */\nexport function rewriteDocument(\n\tcontent: string,\n\trewrite: (document: Document) => boolean,\n): string {\n\tconst json = content.trimStart().startsWith('{');\n\tconst document = (json ? JSON.parse(content) : parse(content)) as unknown;\n\tif (typeof document !== 'object' || document === null) return content;\n\tif (!rewrite(document as Document)) return content;\n\tconst text = json\n\t\t? `${JSON.stringify(document, null, 2)}\\n`\n\t\t: // `@typespec/openapi3`'s own options, so the rest of the text is unchanged.\n\t\t\tstringify(document, {\n\t\t\t\tsingleQuote: true,\n\t\t\t\taliasDuplicateObjects: false,\n\t\t\t\tlineWidth: 0,\n\t\t\t\tcompat: 'yaml-1.1',\n\t\t\t});\n\treturn content.includes('\\r\\n') ? text.replace(/\\n/g, '\\r\\n') : text;\n}\n",
|
|
18
|
+
"/**\n * A `POST` marked `@queryMethod` made the `QUERY` it is, in an emitted\n * OpenAPI 3.2 document: its operation moves from `post` to `query` and loses\n * `x-nxgt-method`, which says nothing more there. A 3.1 document has no\n * `query` operation and keeps the `POST` and the mark. The text is written\n * again as `@typespec/openapi3` writes it, and left alone when nothing moves.\n */\nimport { rewriteDocument } from './document-text';\n\ntype PathItem = Record<string, unknown>;\n\n/** Moves each marked `post` of a 3.2 document to `query`; whether any moved. */\nfunction moveQueries(document: Record<string, unknown>): boolean {\n\tif (!String(document['openapi']).startsWith('3.2')) return false;\n\tconst paths = document['paths'];\n\tif (typeof paths !== 'object' || paths === null) return false;\n\tlet moved = false;\n\tfor (const [path, item] of Object.entries(\n\t\tpaths as Record<string, PathItem>,\n\t)) {\n\t\tconst post = item['post'] as Record<string, unknown> | undefined;\n\t\tif (post?.['x-nxgt-method'] !== 'query' || item['query'] !== undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst { 'x-nxgt-method': _, ...operation } = post;\n\t\t// In place of the `post`, so the path item keeps its order.\n\t\t(paths as Record<string, PathItem>)[path] = Object.fromEntries(\n\t\t\tObject.entries(item).map(([key, value]) =>\n\t\t\t\tkey === 'post' ? ['query', operation] : [key, value],\n\t\t\t),\n\t\t);\n\t\tmoved = true;\n\t}\n\treturn moved;\n}\n\n/** The document's text with its queries moved. */\nexport function withQueryOperations(content: string): string {\n\treturn rewriteDocument(content, moveQueries);\n}\n",
|
|
19
|
+
"/**\n * Marks each operation that returns a `@sharedResponse` with the component\n * name of each such reply, by status, before `@typespec/openapi3` writes it.\n * A model whose replies have several statuses (`@statusCode code: 400 | 404`)\n * is one component per status, `Name400` and `Name404`: their descriptions\n * differ.\n */\nimport { getTypeName, type Program, type Type } from '@typespec/compiler';\nimport { getAllHttpServices } from '@typespec/http';\nimport { setExtension } from '@typespec/openapi';\nimport { $lib } from './lib';\nimport { RESPONSES_EXTENSION } from './marks';\n\n/** The document's status key for a reply: `200`, `4XX` or `default`. */\nfunction statusKey(\n\tstatus: number | '*' | { start: number; end: number },\n): string | undefined {\n\tif (typeof status === 'number') return String(status);\n\tif (status === '*') return 'default';\n\tconst hundred = Math.floor(status.start / 100);\n\treturn status.start === hundred * 100 && status.end === hundred * 100 + 99\n\t\t? `${hundred}XX`\n\t\t: undefined;\n}\n\ntype Services = ReturnType<typeof getAllHttpServices>[0];\n\n/**\n * The `verb path status` of replies that `@sharedRoute` operations merge into\n * one although they differ, a shared one among them: a component cannot be\n * two responses. Each is reported, and none is marked.\n */\nfunction mergedStatuses(program: Program, services: Services): Set<string> {\n\tconst names = program.stateMap($lib.stateKeys.sharedResponses);\n\tconst groups = new Map<string, Map<Type, string>>();\n\tconst refused = new Set<string>();\n\tfor (const service of services) {\n\t\tfor (const { operation, path, verb, responses } of service.operations) {\n\t\t\tfor (const reply of responses) {\n\t\t\t\tconst status = statusKey(reply.statusCodes);\n\t\t\t\tif (status === undefined) continue;\n\t\t\t\tconst key = `${verb} ${path} ${status}`;\n\t\t\t\tconst held = groups.get(key) ?? new Map<Type, string>();\n\t\t\t\theld.set(reply.type, operation.name);\n\t\t\t\tgroups.set(key, held);\n\t\t\t\tconst shared = [...held.keys()].some((type) => names.has(type));\n\t\t\t\tif (held.size > 1 && shared && !refused.has(key)) {\n\t\t\t\t\trefused.add(key);\n\t\t\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\t\t\tcode: 'shared-response-merged',\n\t\t\t\t\t\tformat: { status, path, verb: verb.toUpperCase() },\n\t\t\t\t\t\ttarget: operation,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn refused;\n}\n\nexport function markSharedResponses(program: Program): void {\n\tconst names = program.stateMap($lib.stateKeys.sharedResponses);\n\tif (names.size === 0) return;\n\tconst [services] = getAllHttpServices(program);\n\tconst statuses = new Map<Type, Set<string>>();\n\tfor (const service of services) {\n\t\tfor (const { responses } of service.operations) {\n\t\t\tfor (const reply of responses) {\n\t\t\t\tconst status = statusKey(reply.statusCodes);\n\t\t\t\tif (status === undefined || !names.has(reply.type)) continue;\n\t\t\t\tstatuses.set(\n\t\t\t\t\treply.type,\n\t\t\t\t\t(statuses.get(reply.type) ?? new Set()).add(status),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tconst merged = mergedStatuses(program, services);\n\tfor (const service of services) {\n\t\tfor (const { operation, path, verb, responses } of service.operations) {\n\t\t\tconst marked: Record<string, string> = {};\n\t\t\tfor (const reply of responses) {\n\t\t\t\tconst name = names.get(reply.type);\n\t\t\t\tconst status = statusKey(reply.statusCodes);\n\t\t\t\tif (typeof name !== 'string' || status === undefined) continue;\n\t\t\t\tif (merged.has(`${verb} ${path} ${status}`)) continue;\n\t\t\t\tconst several = (statuses.get(reply.type)?.size ?? 0) > 1;\n\t\t\t\tmarked[status] = several ? `${name}${status}` : name;\n\t\t\t}\n\t\t\tif (Object.keys(marked).length > 0) {\n\t\t\t\tsetExtension(\n\t\t\t\t\tprogram,\n\t\t\t\t\toperation,\n\t\t\t\t\t`${RESPONSES_EXTENSION}${getTypeName(operation)}`,\n\t\t\t\t\tmarked,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
20
|
+
"/**\n * The emitted document rewritten from the marks `marks.ts` lists: each header\n * marked `x-nxgt-component` and each reply an operation marks in\n * `x-nxgt-responses` moved once under `components`, a `$ref` in its place,\n * and the servers an operation marks set on its path item. Every mark is taken\n * off. The first of two components of one name is the component; one that\n * differs from it stays inline, and the caller reports the conflict. A\n * `x-nxgt-component` left anywhere but on a response header is reported.\n */\nimport { type Document, rewriteDocument } from './document-text';\nimport {\n\tCOMPONENT_EXTENSION,\n\tisMark,\n\tmarksOf,\n\tRESPONSES_EXTENSION,\n\tSERVERS_EXTENSION,\n\ttype Server,\n} from './marks';\n\ntype Obj = Record<string, unknown>;\nconst isObj = (value: unknown): value is Obj =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport type Problem =\n\t| { kind: 'headers' | 'responses' | 'misplaced'; name: string }\n\t| { kind: 'server'; path: string; url: string };\n\n/** Canonical text of a value, whatever the order of its keys. */\nfunction canonical(value: unknown): string {\n\treturn JSON.stringify(value, (_, held: unknown) =>\n\t\ttypeof held === 'object' && held !== null && !Array.isArray(held)\n\t\t\t? Object.fromEntries(\n\t\t\t\t\tObject.entries(held).sort(([left], [right]) =>\n\t\t\t\t\t\tleft < right ? -1 : 1,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t: held,\n\t);\n}\n\n/** Moves `value` to `components[kind][name]`; false when another one is there. */\nfunction hoist(\n\tcomponents: Obj,\n\tkind: 'headers' | 'responses',\n\tname: string,\n\tvalue: unknown,\n): boolean {\n\tif (!isObj(components[kind])) components[kind] = {};\n\tconst group = components[kind] as Obj;\n\tconst held = group[name];\n\tif (held === undefined) {\n\t\tgroup[name] = value;\n\t\treturn true;\n\t}\n\treturn canonical(held) === canonical(value);\n}\n\n/** Each operation of each path item, with its path. */\nfunction* operations(paths: Obj): Generator<[string, Obj, Obj]> {\n\tfor (const [path, item] of Object.entries(paths)) {\n\t\tif (!isObj(item)) continue;\n\t\tfor (const operation of Object.values(item)) {\n\t\t\tif (isObj(operation)) yield [path, item, operation];\n\t\t}\n\t}\n}\n\nfunction hoistHeaders(\n\tpaths: Obj,\n\tcomponents: Obj,\n\tproblems: Problem[],\n): boolean {\n\tlet changed = false;\n\tfor (const [, , operation] of operations(paths)) {\n\t\tfor (const reply of Object.values(operation['responses'] ?? {})) {\n\t\t\tif (!isObj(reply) || !isObj(reply['headers'])) continue;\n\t\t\tfor (const [key, header] of Object.entries(reply['headers'])) {\n\t\t\t\tif (!isObj(header)) continue;\n\t\t\t\tconst name = header[COMPONENT_EXTENSION];\n\t\t\t\tif (typeof name !== 'string') continue;\n\t\t\t\tconst { [COMPONENT_EXTENSION]: _, ...bare } = header;\n\t\t\t\tif (hoist(components, 'headers', name, bare)) {\n\t\t\t\t\treply['headers'][key] = { $ref: `#/components/headers/${name}` };\n\t\t\t\t} else {\n\t\t\t\t\t// Inline, without the mark.\n\t\t\t\t\treply['headers'][key] = bare;\n\t\t\t\t\tproblems.push({ kind: 'headers', name });\n\t\t\t\t}\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\t}\n\treturn changed;\n}\n\nfunction hoistResponses(\n\tpaths: Obj,\n\tcomponents: Obj,\n\tproblems: Problem[],\n): boolean {\n\tlet changed = false;\n\tfor (const [, , operation] of operations(paths)) {\n\t\tconst replies = operation['responses'];\n\t\tif (!isObj(replies)) continue;\n\t\t// One mark for each operation merged into this one by @sharedRoute.\n\t\tfor (const key of marksOf(operation, RESPONSES_EXTENSION)) {\n\t\t\tconst marked = operation[key];\n\t\t\tif (!isObj(marked)) continue;\n\t\t\tfor (const [status, name] of Object.entries(marked)) {\n\t\t\t\tconst reply = replies[status];\n\t\t\t\tif (typeof name !== 'string' || !isObj(reply)) continue;\n\t\t\t\tconst ref = `#/components/responses/${name}`;\n\t\t\t\tif (reply['$ref'] === ref) continue;\n\t\t\t\tif (reply['$ref'] !== undefined) {\n\t\t\t\t\t// Merged into one reply by another shared response.\n\t\t\t\t\tproblems.push({ kind: 'responses', name });\n\t\t\t\t} else if (hoist(components, 'responses', name, reply)) {\n\t\t\t\t\treplies[status] = { $ref: ref };\n\t\t\t\t\tchanged = true;\n\t\t\t\t} else {\n\t\t\t\t\tproblems.push({ kind: 'responses', name });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn changed;\n}\n\n/** The servers the operations of each path item mark, once each. */\nfunction setServers(paths: Obj, problems: Problem[]): boolean {\n\tconst found = new Map<string, Server[]>();\n\tfor (const [path, , operation] of operations(paths)) {\n\t\tconst held = found.get(path) ?? [];\n\t\t// One mark for each operation merged into this one by @sharedRoute.\n\t\tfor (const key of marksOf(operation, SERVERS_EXTENSION)) {\n\t\t\tconst marked = operation[key];\n\t\t\tif (!Array.isArray(marked)) continue;\n\t\t\tfor (const server of marked as Server[]) {\n\t\t\t\tconst same = held.find(({ url }) => url === server.url);\n\t\t\t\tif (same === undefined) held.push(server);\n\t\t\t\telse if (canonical(same) !== canonical(server)) {\n\t\t\t\t\tproblems.push({ kind: 'server', path, url: server.url });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (held.length > 0) found.set(path, held);\n\t}\n\tfor (const [path, servers] of found) {\n\t\t(paths[path] as Obj)['servers'] = servers;\n\t}\n\treturn found.size > 0;\n}\n\n/** Takes every mark off the document; the names a header mark was left on. */\nfunction takeMarks(value: unknown, left: string[]): boolean {\n\tlet taken = false;\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) taken = takeMarks(item, left) || taken;\n\t} else if (isObj(value)) {\n\t\tfor (const mark of Object.keys(value).filter(isMark)) {\n\t\t\tif (mark === COMPONENT_EXTENSION) left.push(String(value[mark]));\n\t\t\tdelete value[mark];\n\t\t\ttaken = true;\n\t\t}\n\t\tfor (const item of Object.values(value)) {\n\t\t\ttaken = takeMarks(item, left) || taken;\n\t\t}\n\t}\n\treturn taken;\n}\n\n/** The document's text rewritten; `problems` gets each thing refused. */\nexport function withComponents(content: string, problems: Problem[]): string {\n\treturn rewriteDocument(content, (document: Document) => {\n\t\tconst paths = document['paths'];\n\t\tif (!isObj(paths)) return false;\n\t\tconst components = (\n\t\t\tisObj(document['components']) ? document['components'] : {}\n\t\t) as Obj;\n\t\t// Headers first: a shared response holds them as `$ref`s.\n\t\tconst headers = hoistHeaders(paths, components, problems);\n\t\tconst responses = hoistResponses(paths, components, problems);\n\t\tsetServers(paths, problems);\n\t\tif (headers || responses) document['components'] = components;\n\t\tconst misplaced: string[] = [];\n\t\tconst taken = takeMarks(document, misplaced);\n\t\tfor (const name of misplaced) problems.push({ kind: 'misplaced', name });\n\t\treturn taken;\n\t});\n}\n",
|
|
15
21
|
"/**\n * The library's linter: rules a spec opts into in its `tspconfig.yaml`,\n * each a warning, each one it can turn off.\n *\n * ```yaml\n * linter:\n * extends:\n * - \"@nxgt/typespec/recommended\"\n * ```\n */\nimport { defineLinter } from '@typespec/compiler';\nimport { errorBodyShape } from './rules/error-body-shape';\nimport { listReturnsPage } from './rules/list-returns-page';\nimport { serviceOperationIds } from './rules/service-operation-ids';\n\nconst rules = [listReturnsPage, serviceOperationIds, errorBodyShape];\n\nexport const $linter = defineLinter({\n\trules,\n\truleSets: {\n\t\trecommended: {\n\t\t\tenable: Object.fromEntries(\n\t\t\t\trules.map(({ name }) => [`@nxgt/typespec/${name}`, true]),\n\t\t\t),\n\t\t},\n\t},\n});\n",
|
|
16
22
|
"/**\n * An error reply's body is the envelope `@nxgt/openapi-hono` sends: a\n * `status`, a `message` and a `timestamp`, as `ErrorBody<Status>` declares\n * them. A reply without a body passes: `AuthenticationRequired` has none.\n */\nimport {\n\tcreateRule,\n\tisVoidType,\n\ttype Model,\n\tparamMessage,\n\twalkPropertiesInherited,\n} from '@typespec/compiler';\nimport { getHttpOperation } from '@typespec/http';\nimport { isWritten } from './written';\n\nconst ENVELOPE = ['status', 'message', 'timestamp'];\n\n/** Its own properties and those of the models it extends. */\nfunction isEnvelope(body: Model): boolean {\n\tconst names = new Set(\n\t\t[...walkPropertiesInherited(body)].map(({ name }) => name),\n\t);\n\treturn ENVELOPE.every((name) => names.has(name));\n}\n\nfunction statusOf(code: number | { start: number; end: number } | '*'): string {\n\treturn typeof code === 'object' ? `${code.start}-${code.end}` : `${code}`;\n}\n\nexport const errorBodyShape = createRule({\n\tname: 'error-body-shape',\n\tseverity: 'warning',\n\tdescription:\n\t\t'An error reply has the nxgt envelope: status, message and timestamp.',\n\tmessages: {\n\t\tdefault: paramMessage`${'operation'} answers ${'status'} with a body that is not the nxgt envelope: declare BadRequest, NotFound or another of the library's errors, or a body that spreads or extends ErrorBody<Status>.`,\n\t},\n\tcreate: (context) => ({\n\t\toperation(operation) {\n\t\t\tif (!isWritten(operation)) return;\n\t\t\tconst [http] = getHttpOperation(context.program, operation);\n\t\t\tfor (const { statusCodes, responses } of http.responses) {\n\t\t\t\tconst error =\n\t\t\t\t\tstatusCodes === '*' ||\n\t\t\t\t\t(typeof statusCodes === 'number'\n\t\t\t\t\t\t? statusCodes >= 400\n\t\t\t\t\t\t: statusCodes.start >= 400);\n\t\t\t\tif (!error) continue;\n\t\t\t\tconst wrong = responses.some(({ body }) => {\n\t\t\t\t\tif (body === undefined || isVoidType(body.type)) return false;\n\t\t\t\t\treturn body.type.kind !== 'Model' || !isEnvelope(body.type);\n\t\t\t\t});\n\t\t\t\tif (!wrong) continue;\n\t\t\t\tcontext.reportDiagnostic({\n\t\t\t\t\tformat: { operation: operation.name, status: statusOf(statusCodes) },\n\t\t\t\t\ttarget: operation,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t}),\n});\n",
|
|
17
23
|
"/**\n * Whether the emitter writes an operation: not a template's declaration,\n * nor its instance (`Read<Pet>`), nor an operation of an interface\n * template's. Only the operations declared from them are checked.\n */\nimport { isTemplateDeclaration, type Operation } from '@typespec/compiler';\nimport { isEmitted } from '../operation-ids';\n\nexport function isWritten(operation: Operation): boolean {\n\tconst container = operation.interface;\n\treturn (\n\t\tisEmitted(operation) &&\n\t\t!isTemplateDeclaration(operation) &&\n\t\t(container === undefined || !isTemplateDeclaration(container))\n\t);\n}\n",
|
|
18
24
|
"/**\n * A list returns a page: `Page<Item>` or `CursorPage<Item>`, never a bare\n * array, which cannot grow a `total` or a `nextCursor` without breaking its\n * clients. A list is an operation named `list`, `search` or `query`, alone\n * or followed by more: `listUsers`, `searchPosts`.\n */\nimport { createRule, isArrayModelType, paramMessage } from '@typespec/compiler';\nimport { getHttpOperation } from '@typespec/http';\nimport { isWritten } from './written';\n\nconst LIST = /^(list|search|query)(?=[A-Z]|$)/;\n\nexport const listReturnsPage = createRule({\n\tname: 'list-returns-page',\n\tseverity: 'warning',\n\tdescription:\n\t\t'A list, search or query returns Page<Item> or CursorPage<Item>.',\n\tmessages: {\n\t\tdefault: paramMessage`${'operation'} returns an array: return Page<Item> or CursorPage<Item>, which can carry a total or a next cursor.`,\n\t},\n\tcreate: (context) => ({\n\t\toperation(operation) {\n\t\t\tif (!isWritten(operation) || !LIST.test(operation.name)) return;\n\t\t\tconst [http] = getHttpOperation(context.program, operation);\n\t\t\tconst array = http.responses.some(\n\t\t\t\t({ statusCodes, responses }) =>\n\t\t\t\t\ttypeof statusCodes === 'number' &&\n\t\t\t\t\tstatusCodes >= 200 &&\n\t\t\t\t\tstatusCodes < 300 &&\n\t\t\t\t\tresponses.some(\n\t\t\t\t\t\t({ body }) =>\n\t\t\t\t\t\t\tbody?.type.kind === 'Model' && isArrayModelType(body.type),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (!array) return;\n\t\t\tcontext.reportDiagnostic({\n\t\t\t\tformat: { operation: operation.name },\n\t\t\t\ttarget: operation,\n\t\t\t});\n\t\t},\n\t}),\n});\n",
|
|
19
25
|
"/**\n * A service without `@operationIds` gets the emitter's ids: `Users_list`,\n * which the generated client's methods are named after.\n */\nimport { createRule, isService, paramMessage } from '@typespec/compiler';\nimport { isMarkedNamespace } from '../operation-ids';\n\nexport const serviceOperationIds = createRule({\n\tname: 'service-operation-ids',\n\tseverity: 'warning',\n\tdescription:\n\t\t'A service namespace marks its operation ids with @operationIds.',\n\tmessages: {\n\t\tdefault: paramMessage`The service ${'service'} has no @operationIds: its ids are the emitter's, such as Users_list. Mark the namespace with @operationIds.`,\n\t},\n\tcreate: (context) => ({\n\t\tnamespace(namespace) {\n\t\t\tconst { program } = context;\n\t\t\tif (!isService(program, namespace)) return;\n\t\t\tif (isMarkedNamespace(program, namespace)) return;\n\t\t\tcontext.reportDiagnostic({\n\t\t\t\tformat: { service: namespace.name },\n\t\t\t\ttarget: namespace,\n\t\t\t});\n\t\t},\n\t}),\n});\n",
|
|
20
|
-
"/**\n * The JavaScript side of the `@nxgt/typespec` library, which `lib/main.tsp`\n * imports from `dist/`: its name and diagnostics, and the decorators a\n * template cannot express. The conventions themselves are in `lib/`.\n *\n * A decorator is exported only through `$decorators`: a top-level `$name`\n * export would declare it a second time, in the global namespace.\n */\nimport type { Program } from '@typespec/compiler';\nimport { validateOneReplyPerStatus } from './one-reply-per-status';\nimport { operationIds, validateOperationIds } from './operation-ids';\nimport { queryMethod, validateQueryMethods } from './query-method';\nimport { validateVerbMethods } from './verb-methods';\n\nexport { $onEmit } from './emitter';\nexport { $lib } from './lib';\nexport { $linter } from './linter';\n\nexport function $onValidate(program: Program): void {\n\tvalidateQueryMethods(program);\n\t// Before the ids are set: only an `@operationId` written in the spec is\n\t// one then, and the operation it names is not checked.\n\tvalidateVerbMethods(program);\n\tvalidateOperationIds(program);\n\tvalidateOneReplyPerStatus(program);\n}\n\nexport const $decorators = {\n\tNxgt: {
|
|
26
|
+
"/**\n * The JavaScript side of the `@nxgt/typespec` library, which `lib/main.tsp`\n * imports from `dist/`: its name and diagnostics, and the decorators a\n * template cannot express. The conventions themselves are in `lib/`.\n *\n * A decorator is exported only through `$decorators`: a top-level `$name`\n * export would declare it a second time, in the global namespace.\n */\nimport type { Program } from '@typespec/compiler';\nimport {\n\tpathServer,\n\tsharedHeader,\n\tsharedResponse,\n\tvalidateComponents,\n} from './components';\nimport { validateOneReplyPerStatus } from './one-reply-per-status';\nimport { operationIds, validateOperationIds } from './operation-ids';\nimport { queryMethod, validateQueryMethods } from './query-method';\nimport { validateVerbMethods } from './verb-methods';\n\nexport { $onEmit } from './emitter';\nexport { $lib } from './lib';\nexport { $linter } from './linter';\n\nexport function $onValidate(program: Program): void {\n\tvalidateQueryMethods(program);\n\tvalidateComponents(program);\n\t// Before the ids are set: only an `@operationId` written in the spec is\n\t// one then, and the operation it names is not checked.\n\tvalidateVerbMethods(program);\n\tvalidateOperationIds(program);\n\tvalidateOneReplyPerStatus(program);\n}\n\nexport const $decorators = {\n\tNxgt: {\n\t\toperationIds,\n\t\tpathServer,\n\t\tqueryMethod,\n\t\tsharedHeader,\n\t\tsharedResponse,\n\t},\n};\n"
|
|
21
27
|
],
|
|
22
|
-
"mappings": ";AASA;;;ACHA;AAEO,SAAS,iBAAiB,CAChC,SACA,OACO;AAAA,EACP,OAAO,YAAY,mBAAmB,OAAO;AAAA,EAC7C,MAAM,UAAU,IAAI;AAAA,EACpB,WAAW,WAAW,UAAU;AAAA,IAC/B,WAAW,aAAa,QAAQ,YAAY;AAAA,MAC3C,IAAI,QAAQ,IA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25
31
|
}
|
package/dist/lib.d.ts
CHANGED
|
@@ -17,6 +17,30 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
17
17
|
'query-method-needs-nxgt-emitter': {
|
|
18
18
|
readonly default: import("@typespec/compiler").CallableMessage<["operation"]>;
|
|
19
19
|
};
|
|
20
|
+
'shared-component-conflict': {
|
|
21
|
+
readonly default: import("@typespec/compiler").CallableMessage<["kind", "name"]>;
|
|
22
|
+
};
|
|
23
|
+
'path-server-conflict': {
|
|
24
|
+
readonly default: import("@typespec/compiler").CallableMessage<["path", "url"]>;
|
|
25
|
+
};
|
|
26
|
+
'path-server-missing-variable': {
|
|
27
|
+
readonly default: import("@typespec/compiler").CallableMessage<["url", "operation", "variable"]>;
|
|
28
|
+
};
|
|
29
|
+
'path-server-invalid-variable': {
|
|
30
|
+
readonly default: import("@typespec/compiler").CallableMessage<["variable", "operation"]>;
|
|
31
|
+
};
|
|
32
|
+
'shared-header-misplaced': {
|
|
33
|
+
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
|
|
34
|
+
};
|
|
35
|
+
'shared-response-merged': {
|
|
36
|
+
readonly default: import("@typespec/compiler").CallableMessage<["verb", "path", "status"]>;
|
|
37
|
+
};
|
|
38
|
+
'invalid-component-name': {
|
|
39
|
+
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
|
|
40
|
+
};
|
|
41
|
+
'shared-needs-nxgt-emitter': {
|
|
42
|
+
readonly default: import("@typespec/compiler").CallableMessage<["target", "decorator"]>;
|
|
43
|
+
};
|
|
20
44
|
'openapi3-missing': {
|
|
21
45
|
readonly default: "The emitter @nxgt/typespec runs @typespec/openapi3, which is not installed: add it beside @nxgt/typespec.";
|
|
22
46
|
};
|
|
@@ -26,5 +50,5 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
26
50
|
'merged-status-reply': {
|
|
27
51
|
readonly default: import("@typespec/compiler").CallableMessage<["operation", "status"]>;
|
|
28
52
|
};
|
|
29
|
-
}, Record<string, any>, "queryMethod" | "operationIds" | "operationIdsOptions">;
|
|
53
|
+
}, Record<string, any>, "queryMethod" | "sharedResponses" | "sharedHeaders" | "pathServers" | "operationIds" | "operationIdsOptions">;
|
|
30
54
|
//# sourceMappingURL=lib.d.ts.map
|
package/dist/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qIAoIf,CAAC"}
|
package/dist/marks.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The marks this library writes into the emitted document, which
|
|
3
|
+
* `shared-components.ts` reads and takes off before the text is written. Each
|
|
4
|
+
* rides on the object `@typespec/openapi3` writes for the type it is set on,
|
|
5
|
+
* as `x-nxgt-method` does for `@queryMethod`, so the rewrite never has to
|
|
6
|
+
* infer which service or operation a part of the document came from.
|
|
7
|
+
*/
|
|
8
|
+
/** On a response header: the component name it is emitted under. */
|
|
9
|
+
export declare const COMPONENT_EXTENSION = "x-nxgt-component";
|
|
10
|
+
/**
|
|
11
|
+
* On an operation: its servers, which belong on its path item. The key ends
|
|
12
|
+
* with the operation's name: operations of a `@sharedRoute` merge into one
|
|
13
|
+
* object, and `@typespec/openapi3` lets the last of two equal keys win.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SERVERS_EXTENSION = "x-nxgt-servers-";
|
|
16
|
+
/** On an operation: the component name of each shared reply, by status. Keyed as the servers are. */
|
|
17
|
+
export declare const RESPONSES_EXTENSION = "x-nxgt-responses-";
|
|
18
|
+
/** The keys of an object that carry a mark with this prefix. */
|
|
19
|
+
export declare const marksOf: (object: Record<string, unknown>, prefix: string) => string[];
|
|
20
|
+
/** Whether a key is one of the marks. */
|
|
21
|
+
export declare const isMark: (key: string) => boolean;
|
|
22
|
+
export type ServerVariable = {
|
|
23
|
+
default: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
enum?: string[];
|
|
26
|
+
};
|
|
27
|
+
export type Server = {
|
|
28
|
+
url: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
variables?: Record<string, ServerVariable>;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=marks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marks.d.ts","sourceRoot":"","sources":["../src/marks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,qGAAqG;AACrG,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,gEAAgE;AAChE,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,MAAM,aACX,CAAC;AAE7D,yCAAyC;AACzC,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,YAGE,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC3C,CAAC"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The document's text with its queries moved. The format is the text's:
|
|
3
|
-
* `@typespec/openapi3` writes YAML whatever the file is named, unless
|
|
4
|
-
* `file-type` says JSON. Line endings stay as written: `new-line: crlf`
|
|
5
|
-
* reaches here already applied.
|
|
6
|
-
*/
|
|
1
|
+
/** The document's text with its queries moved. */
|
|
7
2
|
export declare function withQueryOperations(content: string): string;
|
|
8
3
|
//# sourceMappingURL=query-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-operations.d.ts","sourceRoot":"","sources":["../src/query-operations.ts"],"names":[],"mappings":"AAoCA
|
|
1
|
+
{"version":3,"file":"query-operations.d.ts","sourceRoot":"","sources":["../src/query-operations.ts"],"names":[],"mappings":"AAoCA,kDAAkD;AAClD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks each operation that returns a `@sharedResponse` with the component
|
|
3
|
+
* name of each such reply, by status, before `@typespec/openapi3` writes it.
|
|
4
|
+
* A model whose replies have several statuses (`@statusCode code: 400 | 404`)
|
|
5
|
+
* is one component per status, `Name400` and `Name404`: their descriptions
|
|
6
|
+
* differ.
|
|
7
|
+
*/
|
|
8
|
+
import { type Program } from '@typespec/compiler';
|
|
9
|
+
export declare function markSharedResponses(program: Program): void;
|
|
10
|
+
//# sourceMappingURL=response-marks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-marks.d.ts","sourceRoot":"","sources":["../src/response-marks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAe,KAAK,OAAO,EAAa,MAAM,oBAAoB,CAAC;AAqD1E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuC1D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The variables of a `@pathServer` URL, from `@server`'s parameters model: a
|
|
3
|
+
* property's default is the variable's, its doc the description, and its
|
|
4
|
+
* type, a string, a string enum or a union of strings, its `enum`.
|
|
5
|
+
*/
|
|
6
|
+
import { type Model, type Operation, type Program } from '@typespec/compiler';
|
|
7
|
+
import type { ServerVariable } from './marks.js';
|
|
8
|
+
/** `@server`'s parameters: a property's default is the variable's, its doc the description. */
|
|
9
|
+
export declare function serverVariables(program: Program, target: Operation, parameters: Model): Record<string, ServerVariable>;
|
|
10
|
+
//# sourceMappingURL=server-variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-variables.d.ts","sourceRoot":"","sources":["../src/server-variables.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEN,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,OAAO,EAGZ,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAiD9C,+FAA+F;AAC/F,wBAAgB,eAAe,CAC9B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,KAAK,GACf,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA6BhC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Problem = {
|
|
2
|
+
kind: 'headers' | 'responses' | 'misplaced';
|
|
3
|
+
name: string;
|
|
4
|
+
} | {
|
|
5
|
+
kind: 'server';
|
|
6
|
+
path: string;
|
|
7
|
+
url: string;
|
|
8
|
+
};
|
|
9
|
+
/** The document's text rewritten; `problems` gets each thing refused. */
|
|
10
|
+
export declare function withComponents(content: string, problems: Problem[]): string;
|
|
11
|
+
//# sourceMappingURL=shared-components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-components.d.ts","sourceRoot":"","sources":["../src/shared-components.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,OAAO,GAChB;IAAE,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAkJjD,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAiB3E"}
|
package/docs/README.md
CHANGED
|
@@ -5,7 +5,7 @@ The [package README](../README.md) is the short version.
|
|
|
5
5
|
| Page | Read it when |
|
|
6
6
|
| --- | --- |
|
|
7
7
|
| [Getting started](guide/getting-started.md) | starting a new API project from the `tsp init` template, up to a Hono route |
|
|
8
|
-
| [The emitter](guide/emitter.md) | emitting the spec with `@nxgt/typespec` in `tspconfig.yaml`, or getting a real `QUERY` from a `@queryMethod`, which needs OpenAPI 3.2 |
|
|
8
|
+
| [The emitter](guide/emitter.md) | emitting the spec with `@nxgt/typespec` in `tspconfig.yaml`, or getting a real `QUERY` from a `@queryMethod`, which needs OpenAPI 3.2, or a response or header emitted once under `components`, and `servers` on one path |
|
|
9
9
|
| [Request bodies](guide/requests.md) | naming the body of a create, a `PUT` and a `PATCH`: `CreatePostRequest`, `UpdatePostRequest`, `PatchPostRequest` |
|
|
10
10
|
| [Error replies](guide/errors.md) | declaring what an operation answers when it fails |
|
|
11
11
|
| [Pagination](guide/pagination.md) | listing a collection a page at a time |
|