@webpieces/openapi-generator 0.4.939 → 0.4.941

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/ManifestLoader.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,sEAAmE;AACnE,6CAA0C;AAC1C,4DAA2D;AAC3D,uDAU2B;AAE3B,gGAAgG;AAChG,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B;;;GAGG;AACH,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C,sGAAsG;AACtG,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAAiB;IAC3E,CAAC,MAAM,EAAE,kFAAkF,CAAC;IAC5F;QACI,SAAS;QACT,sFAAsF;KACzF;IACD,CAAC,SAAS,EAAE,kDAAkD,CAAC;IAC/D,CAAC,QAAQ,EAAE,mDAAmD,CAAC;IAC/D,CAAC,iBAAiB,EAAE,gDAAgD,CAAC;IACrE,CAAC,qBAAqB,EAAE,yCAAyC,CAAC;IAClE,CAAC,cAAc,EAAE,iDAAiD,CAAC;CACtE,CAAC,CAAC;AAEH,kFAAkF;AAClF,MAAM,mBAAmB,GAAgC;IACrD,kCAAgB,CAAC,eAAe;IAChC,kCAAgB,CAAC,MAAM;CAC1B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAa,cAAc;IACvB;;;OAGG;IACH,YAAY,CAAC,YAAoB;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,IAAI,KAAK,UAAU,EAA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WAAW,CAAC;aACpB,GAAG,CACA,CAAC,QAAoB,EAAE,EAAE,CACrB,IAAI,oCAAkB,CAClB,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EACzB,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAC9B,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,KAAK,CACpD,CACR,CACR,CAAC;IACN,CAAC;IAEO,eAAe,CAAC,GAAe;QACnC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,MAAkB,EAAE,EAAE;YAC7D,0FAA0F;YAC1F,0FAA0F;YAC1F,8DAA8D;YAC9D,IAAI,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,+CAAsB,CAC5B,IAAI,qBAAqB,gEAAgE,EACzF,GAAG,CAAC,KAAK,EACT,YAAY,qBAAqB,uDAAuD;oBACpF,kFAAkF;oBAClF,8FAA8F,CACrG,CAAC;YACN,CAAC;YACD,OAAO,IAAI,qCAAmB,CAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAC3B,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACpC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,+EAA+E;IAC/E,OAAO,CAAC,YAAoB,EAAE,QAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ;AA1PD,wCA0PC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { JsonReader } from './JsonReader';\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\nimport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n MANIFEST_SUMMARY_MAX_LENGTH,\n OpenApiManifest,\n OperationIdStyle,\n ResponseHeaderEntry,\n ServerEntry,\n} from './OpenApiManifest';\n\n/** The only `kind` an api entry may declare. Anything else is a typo, and typos are refused. */\nconst WEBHOOK = 'webhook';\n\n/**\n * The only `kind` a MANIFEST may declare (#1058): a DTO library's components-only document. A\n * manifest with no `kind` is a contract library's, exactly as before.\n */\nconst COMPONENTS = 'components';\n\n/** The deleted string-constant spelling of a response header's name (#1249). */\nconst RETIRED_NAME_CONSTANT = 'nameConstant';\n\n/** Keys a components manifest must not carry, each with why — a contract-manifest key is a mix-up. */\nconst NOT_IN_COMPONENTS: ReadonlyMap<string, string> = new Map<string, string>([\n ['apis', 'a components document has no paths; list the library\\'s entry files in \"entries\"'],\n [\n 'version',\n \"a library document's info.version is the package version, read from its package.json\",\n ],\n ['servers', 'a components document has no operations to serve'],\n ['errors', 'the error contract belongs to a contract document'],\n ['responseHeaders', 'response headers belong to a contract document'],\n ['securitySchemeNames', 'security belongs to a contract document'],\n ['operationIds', 'a components document has no operations to name'],\n]);\n\n/** Every spelling `operationIds` accepts, in the order the refusal lists them. */\nconst OPERATION_ID_STYLES: readonly OperationIdStyle[] = [\n OperationIdStyle.CONTRACT_METHOD,\n OperationIdStyle.METHOD,\n];\n\n/**\n * Read `openapi.manifest.json` into {@link OpenApiManifest}.\n *\n * It deals only in {@link JsonReader}, which is where the \"came off disk, not yet checked\" state is\n * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.\n *\n * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section\n * is indistinguishable, from outside, from an API that genuinely has no error contract.\n */\nexport class ManifestLoader {\n /**\n * True for a DTO library's `\"kind\": \"components\"` manifest, false for a contract library's (no\n * `kind`). Any other `kind` is refused: a typo there would otherwise render the wrong document.\n */\n isComponents(manifestPath: string): boolean {\n const kind = this.read(manifestPath).optionalString('kind');\n if (kind === undefined) {\n return false;\n }\n if (kind !== COMPONENTS) {\n throw new OpenApiGenerationError(\n `unknown manifest kind '${kind}'`,\n manifestPath,\n `The only manifest kind is \"${COMPONENTS}\", for a DTO library's components document. ` +\n \"Leave it out for a contract library's manifest.\",\n );\n }\n return true;\n }\n\n /** A DTO library's components manifest. See {@link ComponentsManifest}. */\n loadComponents(manifestPath: string): ComponentsManifest {\n const raw = this.read(manifestPath);\n for (const key of NOT_IN_COMPONENTS.keys()) {\n const why = NOT_IN_COMPONENTS.get(key)!;\n if (raw.has(key)) {\n throw new OpenApiGenerationError(\n `a \"kind\": \"${COMPONENTS}\" manifest declares '${key}'`,\n raw.where,\n `Delete it — ${why}.`,\n );\n }\n }\n const entries = raw.strings('entries');\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'entries' is empty\",\n raw.where,\n 'Name the library\\'s entry files, e.g. \"entries\": [\"src/index.ts\"]; the document holds every type they export.',\n );\n }\n return new ComponentsManifest(raw.string('title'), entries, this.schemaNames(raw));\n }\n\n private read(manifestPath: string): JsonReader {\n if (!fs.existsSync(manifestPath)) {\n throw new OpenApiGenerationError(\n 'no manifest at this path',\n manifestPath,\n 'Pass --manifest pointing at an openapi.manifest.json that exists.',\n );\n }\n return JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);\n }\n\n /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */\n load(manifestPath: string): OpenApiManifest {\n if (this.isComponents(manifestPath)) {\n throw new OpenApiGenerationError(\n `this is a \"kind\": \"${COMPONENTS}\" manifest, not a contract manifest`,\n manifestPath,\n 'Render it as a components document (wp-openapi does so on its own when it reads the kind).',\n );\n }\n const raw = this.read(manifestPath);\n return new OpenApiManifest(\n raw.string('title'),\n this.summary(raw),\n raw.string('version'),\n this.servers(raw),\n raw.optionalString('descriptionFile'),\n this.apis(raw),\n raw.strings('securitySchemeNames'),\n this.errors(raw),\n this.responseHeaders(raw),\n this.schemaNames(raw),\n this.operationIds(raw),\n );\n }\n\n /**\n * REQUIRED (#1296): the API's one-line summary, published as `info.summary`. A heading's subtitle\n * and a directory listing's one-liner, so a second line or a paragraph is refused rather than\n * published.\n */\n private summary(raw: JsonReader): string {\n const cure =\n `Give \"summary\" one line of at most ${MANIFEST_SUMMARY_MAX_LENGTH} characters saying what the API ` +\n 'lets a caller do, e.g. \"summary\": \"Read and cancel the orders placed at your stores.\" It is ' +\n \"published as info.summary under the API's title; the long form stays in descriptionFile.\";\n if (!raw.has('summary')) {\n throw new OpenApiGenerationError(\"'summary' is missing\", raw.where, cure);\n }\n const value = raw.optionalString('summary');\n if (value === undefined || value.trim() === '') {\n throw new OpenApiGenerationError(\"'summary' is not a non-empty string\", raw.where, cure);\n }\n if (/[\\r\\n]/.test(value)) {\n throw new OpenApiGenerationError(\"'summary' spans more than one line\", raw.where, cure);\n }\n if (value.length > MANIFEST_SUMMARY_MAX_LENGTH) {\n throw new OpenApiGenerationError(\n `'summary' is ${value.length} characters, over the ${MANIFEST_SUMMARY_MAX_LENGTH}-character limit`,\n raw.where,\n cure,\n );\n }\n return value;\n }\n\n /**\n * OPTIONAL, defaulting to `\"contract_method\"` (#1283) — the spelling every release before #1270\n * published, and the one that is unique by construction, so a new contract gets the safe scheme\n * without writing anything. `\"method\"` is the opt-in for a document that already published bare\n * names. A value that is present but is neither choice is still refused.\n */\n private operationIds(raw: JsonReader): OperationIdStyle {\n if (!raw.has('operationIds')) {\n return OperationIdStyle.CONTRACT_METHOD;\n }\n const value = raw.optionalString('operationIds');\n const style = OPERATION_ID_STYLES.find((each: OperationIdStyle) => each === value);\n if (style !== undefined) {\n return style;\n }\n const choices = OPERATION_ID_STYLES.map((each: OperationIdStyle) => `\"${each}\"`).join(' or ');\n throw new OpenApiGenerationError(\n value === undefined\n ? \"'operationIds' is present but is not a non-empty string\"\n : `unknown operationIds style '${value}'`,\n raw.where,\n `Set \"operationIds\" to ${choices}, or omit it for \"${OperationIdStyle.CONTRACT_METHOD}\". ` +\n `\"${OperationIdStyle.CONTRACT_METHOD}\" publishes OrdersApi_fetchOrders; ` +\n `\"${OperationIdStyle.METHOD}\" publishes fetchOrders and fails generation when two ` +\n 'operations of one document would share it. Generated partner clients name their ' +\n 'methods from it, so changing it renames every method in their SDKs.',\n );\n }\n\n private servers(raw: JsonReader): readonly ServerEntry[] {\n return raw\n .objects('servers')\n .map(\n (server: JsonReader) =>\n new ServerEntry(server.string('url'), server.optionalString('description')),\n );\n }\n\n private schemaNames(raw: JsonReader): readonly SchemaNameEntry[] {\n return raw.objects('schemaNames').map((entry: JsonReader) => {\n const paths = entry.strings('paths');\n const suffixes = entry.strings('stripSuffixes');\n if (\n paths.length === 0 ||\n paths.some((glob: string) => glob.trim() === '') ||\n !entry.has('stripSuffixes') ||\n suffixes.some((suffix: string) => suffix.length === 0)\n ) {\n throw new OpenApiGenerationError(\n 'invalid schemaNames entry',\n raw.where,\n 'Provide non-empty paths and an explicit stripSuffixes array of non-empty suffixes (or [] to preserve names). First matching path wins.',\n );\n }\n return new SchemaNameEntry(\n paths.map((glob: string) => path.resolve(path.dirname(raw.where), glob)),\n suffixes,\n );\n });\n }\n\n private apis(raw: JsonReader): readonly ApiEntry[] {\n const entries = raw\n .objects('apis')\n .map(\n (api: JsonReader) =>\n new ApiEntry(\n api.string('entry'),\n api.string('tag'),\n api.optionalString('kind'),\n ),\n );\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'apis' is empty\",\n raw.where,\n 'List at least one contract; a document with no operations publishes nothing.',\n );\n }\n for (const entry of entries) {\n if (entry.kind !== undefined && entry.kind !== WEBHOOK) {\n throw new OpenApiGenerationError(\n `unknown api kind '${entry.kind}' on '${entry.entry}'`,\n raw.where,\n `The only declared kind is \"${WEBHOOK}\". Leave it out for an ordinary contract.`,\n );\n }\n }\n return entries;\n }\n\n private errors(raw: JsonReader): ErrorsEntry | undefined {\n const errors = raw.object('errors');\n if (errors === undefined) {\n return undefined;\n }\n return new ErrorsEntry(\n errors.string('entry'),\n errors.string('type'),\n errors\n .objects('responses')\n .map(\n (response: JsonReader) =>\n new ErrorResponseEntry(\n response.string('status'),\n response.string('description'),\n response.optionalBoolean('requiresAuth') ?? false,\n ),\n ),\n );\n }\n\n private responseHeaders(raw: JsonReader): readonly ResponseHeaderEntry[] {\n return raw.objects('responseHeaders').map((header: JsonReader) => {\n // RETIRED (#1249): a header NAME is never a string constant any more — it is read off the\n // ContextKey that is the one definition of the header. Refused, never accepted beside the\n // new key: two spellings means the old one is never migrated.\n if (header.has(RETIRED_NAME_CONSTANT)) {\n throw new OpenApiGenerationError(\n `'${RETIRED_NAME_CONSTANT}' was removed from responseHeaders[]; it moved to 'contextKey'`,\n raw.where,\n `Replace \"${RETIRED_NAME_CONSTANT}\" with \"contextKey\" naming an exported ContextKey in ` +\n '\"entry\" (e.g. `export const REQUEST_ID_KEY = WebpiecesCoreHeaders.REQUEST_ID;`, ' +\n 'or a dotted path like \"OneTabletKey.TX_ID\"); the header name is read off its responseHeader.',\n );\n }\n return new ResponseHeaderEntry(\n header.string('entry'),\n header.string('contextKey'),\n header.optionalString('description'),\n header.optionalBoolean('required'),\n );\n });\n }\n\n /** A manifest-relative path, resolved against the manifest's own directory. */\n resolve(manifestPath: string, relative: string): string {\n return path.resolve(path.dirname(manifestPath), relative);\n }\n}\n"]}
1
+ {"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/ManifestLoader.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,sEAAmE;AACnE,6CAA0C;AAC1C,4DAA6E;AAC7E,uDAS2B;AAE3B,gGAAgG;AAChG,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B;;;GAGG;AACH,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C,sGAAsG;AACtG,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAAiB;IAC3E,CAAC,M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AK,EACT,YAAY,qBAAqB,uDAAuD;oBACpF,kFAAkF;oBAClF,8FAA8F,CACrG,CAAC;YACN,CAAC;YACD,OAAO,IAAI,qCAAmB,CAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAC3B,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACpC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,+EAA+E;IAC/E,OAAO,CAAC,YAAoB,EAAE,QAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ;AA1PD,wCA0PC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { JsonReader } from './JsonReader';\nimport { OperationIdStyle, SchemaNameEntry } from '@webpieces/api-doc-model';\nimport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n MANIFEST_SUMMARY_MAX_LENGTH,\n OpenApiManifest,\n ResponseHeaderEntry,\n ServerEntry,\n} from './OpenApiManifest';\n\n/** The only `kind` an api entry may declare. Anything else is a typo, and typos are refused. */\nconst WEBHOOK = 'webhook';\n\n/**\n * The only `kind` a MANIFEST may declare (#1058): a DTO library's components-only document. A\n * manifest with no `kind` is a contract library's, exactly as before.\n */\nconst COMPONENTS = 'components';\n\n/** The deleted string-constant spelling of a response header's name (#1249). */\nconst RETIRED_NAME_CONSTANT = 'nameConstant';\n\n/** Keys a components manifest must not carry, each with why — a contract-manifest key is a mix-up. */\nconst NOT_IN_COMPONENTS: ReadonlyMap<string, string> = new Map<string, string>([\n ['apis', 'a components document has no paths; list the library\\'s entry files in \"entries\"'],\n [\n 'version',\n \"a library document's info.version is the package version, read from its package.json\",\n ],\n ['servers', 'a components document has no operations to serve'],\n ['errors', 'the error contract belongs to a contract document'],\n ['responseHeaders', 'response headers belong to a contract document'],\n ['securitySchemeNames', 'security belongs to a contract document'],\n ['operationIds', 'a components document has no operations to name'],\n]);\n\n/** Every spelling `operationIds` accepts, in the order the refusal lists them. */\nconst OPERATION_ID_STYLES: readonly OperationIdStyle[] = [\n OperationIdStyle.CONTRACT_METHOD,\n OperationIdStyle.METHOD,\n];\n\n/**\n * Read `openapi.manifest.json` into {@link OpenApiManifest}.\n *\n * It deals only in {@link JsonReader}, which is where the \"came off disk, not yet checked\" state is\n * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.\n *\n * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section\n * is indistinguishable, from outside, from an API that genuinely has no error contract.\n */\nexport class ManifestLoader {\n /**\n * True for a DTO library's `\"kind\": \"components\"` manifest, false for a contract library's (no\n * `kind`). Any other `kind` is refused: a typo there would otherwise render the wrong document.\n */\n isComponents(manifestPath: string): boolean {\n const kind = this.read(manifestPath).optionalString('kind');\n if (kind === undefined) {\n return false;\n }\n if (kind !== COMPONENTS) {\n throw new OpenApiGenerationError(\n `unknown manifest kind '${kind}'`,\n manifestPath,\n `The only manifest kind is \"${COMPONENTS}\", for a DTO library's components document. ` +\n \"Leave it out for a contract library's manifest.\",\n );\n }\n return true;\n }\n\n /** A DTO library's components manifest. See {@link ComponentsManifest}. */\n loadComponents(manifestPath: string): ComponentsManifest {\n const raw = this.read(manifestPath);\n for (const key of NOT_IN_COMPONENTS.keys()) {\n const why = NOT_IN_COMPONENTS.get(key)!;\n if (raw.has(key)) {\n throw new OpenApiGenerationError(\n `a \"kind\": \"${COMPONENTS}\" manifest declares '${key}'`,\n raw.where,\n `Delete it — ${why}.`,\n );\n }\n }\n const entries = raw.strings('entries');\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'entries' is empty\",\n raw.where,\n 'Name the library\\'s entry files, e.g. \"entries\": [\"src/index.ts\"]; the document holds every type they export.',\n );\n }\n return new ComponentsManifest(raw.string('title'), entries, this.schemaNames(raw));\n }\n\n private read(manifestPath: string): JsonReader {\n if (!fs.existsSync(manifestPath)) {\n throw new OpenApiGenerationError(\n 'no manifest at this path',\n manifestPath,\n 'Pass --manifest pointing at an openapi.manifest.json that exists.',\n );\n }\n return JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);\n }\n\n /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */\n load(manifestPath: string): OpenApiManifest {\n if (this.isComponents(manifestPath)) {\n throw new OpenApiGenerationError(\n `this is a \"kind\": \"${COMPONENTS}\" manifest, not a contract manifest`,\n manifestPath,\n 'Render it as a components document (wp-openapi does so on its own when it reads the kind).',\n );\n }\n const raw = this.read(manifestPath);\n return new OpenApiManifest(\n raw.string('title'),\n this.summary(raw),\n raw.string('version'),\n this.servers(raw),\n raw.optionalString('descriptionFile'),\n this.apis(raw),\n raw.strings('securitySchemeNames'),\n this.errors(raw),\n this.responseHeaders(raw),\n this.schemaNames(raw),\n this.operationIds(raw),\n );\n }\n\n /**\n * REQUIRED (#1296): the API's one-line summary, published as `info.summary`. A heading's subtitle\n * and a directory listing's one-liner, so a second line or a paragraph is refused rather than\n * published.\n */\n private summary(raw: JsonReader): string {\n const cure =\n `Give \"summary\" one line of at most ${MANIFEST_SUMMARY_MAX_LENGTH} characters saying what the API ` +\n 'lets a caller do, e.g. \"summary\": \"Read and cancel the orders placed at your stores.\" It is ' +\n \"published as info.summary under the API's title; the long form stays in descriptionFile.\";\n if (!raw.has('summary')) {\n throw new OpenApiGenerationError(\"'summary' is missing\", raw.where, cure);\n }\n const value = raw.optionalString('summary');\n if (value === undefined || value.trim() === '') {\n throw new OpenApiGenerationError(\"'summary' is not a non-empty string\", raw.where, cure);\n }\n if (/[\\r\\n]/.test(value)) {\n throw new OpenApiGenerationError(\"'summary' spans more than one line\", raw.where, cure);\n }\n if (value.length > MANIFEST_SUMMARY_MAX_LENGTH) {\n throw new OpenApiGenerationError(\n `'summary' is ${value.length} characters, over the ${MANIFEST_SUMMARY_MAX_LENGTH}-character limit`,\n raw.where,\n cure,\n );\n }\n return value;\n }\n\n /**\n * OPTIONAL, defaulting to `\"contract_method\"` (#1283) — the spelling every release before #1270\n * published, and the one that is unique by construction, so a new contract gets the safe scheme\n * without writing anything. `\"method\"` is the opt-in for a document that already published bare\n * names. A value that is present but is neither choice is still refused.\n */\n private operationIds(raw: JsonReader): OperationIdStyle {\n if (!raw.has('operationIds')) {\n return OperationIdStyle.CONTRACT_METHOD;\n }\n const value = raw.optionalString('operationIds');\n const style = OPERATION_ID_STYLES.find((each: OperationIdStyle) => each === value);\n if (style !== undefined) {\n return style;\n }\n const choices = OPERATION_ID_STYLES.map((each: OperationIdStyle) => `\"${each}\"`).join(' or ');\n throw new OpenApiGenerationError(\n value === undefined\n ? \"'operationIds' is present but is not a non-empty string\"\n : `unknown operationIds style '${value}'`,\n raw.where,\n `Set \"operationIds\" to ${choices}, or omit it for \"${OperationIdStyle.CONTRACT_METHOD}\". ` +\n `\"${OperationIdStyle.CONTRACT_METHOD}\" publishes OrdersApi_fetchOrders; ` +\n `\"${OperationIdStyle.METHOD}\" publishes fetchOrders and fails generation when two ` +\n 'operations of one document would share it. Generated partner clients name their ' +\n 'methods from it, so changing it renames every method in their SDKs.',\n );\n }\n\n private servers(raw: JsonReader): readonly ServerEntry[] {\n return raw\n .objects('servers')\n .map(\n (server: JsonReader) =>\n new ServerEntry(server.string('url'), server.optionalString('description')),\n );\n }\n\n private schemaNames(raw: JsonReader): readonly SchemaNameEntry[] {\n return raw.objects('schemaNames').map((entry: JsonReader) => {\n const paths = entry.strings('paths');\n const suffixes = entry.strings('stripSuffixes');\n if (\n paths.length === 0 ||\n paths.some((glob: string) => glob.trim() === '') ||\n !entry.has('stripSuffixes') ||\n suffixes.some((suffix: string) => suffix.length === 0)\n ) {\n throw new OpenApiGenerationError(\n 'invalid schemaNames entry',\n raw.where,\n 'Provide non-empty paths and an explicit stripSuffixes array of non-empty suffixes (or [] to preserve names). First matching path wins.',\n );\n }\n return new SchemaNameEntry(\n paths.map((glob: string) => path.resolve(path.dirname(raw.where), glob)),\n suffixes,\n );\n });\n }\n\n private apis(raw: JsonReader): readonly ApiEntry[] {\n const entries = raw\n .objects('apis')\n .map(\n (api: JsonReader) =>\n new ApiEntry(\n api.string('entry'),\n api.string('tag'),\n api.optionalString('kind'),\n ),\n );\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'apis' is empty\",\n raw.where,\n 'List at least one contract; a document with no operations publishes nothing.',\n );\n }\n for (const entry of entries) {\n if (entry.kind !== undefined && entry.kind !== WEBHOOK) {\n throw new OpenApiGenerationError(\n `unknown api kind '${entry.kind}' on '${entry.entry}'`,\n raw.where,\n `The only declared kind is \"${WEBHOOK}\". Leave it out for an ordinary contract.`,\n );\n }\n }\n return entries;\n }\n\n private errors(raw: JsonReader): ErrorsEntry | undefined {\n const errors = raw.object('errors');\n if (errors === undefined) {\n return undefined;\n }\n return new ErrorsEntry(\n errors.string('entry'),\n errors.string('type'),\n errors\n .objects('responses')\n .map(\n (response: JsonReader) =>\n new ErrorResponseEntry(\n response.string('status'),\n response.string('description'),\n response.optionalBoolean('requiresAuth') ?? false,\n ),\n ),\n );\n }\n\n private responseHeaders(raw: JsonReader): readonly ResponseHeaderEntry[] {\n return raw.objects('responseHeaders').map((header: JsonReader) => {\n // RETIRED (#1249): a header NAME is never a string constant any more — it is read off the\n // ContextKey that is the one definition of the header. Refused, never accepted beside the\n // new key: two spellings means the old one is never migrated.\n if (header.has(RETIRED_NAME_CONSTANT)) {\n throw new OpenApiGenerationError(\n `'${RETIRED_NAME_CONSTANT}' was removed from responseHeaders[]; it moved to 'contextKey'`,\n raw.where,\n `Replace \"${RETIRED_NAME_CONSTANT}\" with \"contextKey\" naming an exported ContextKey in ` +\n '\"entry\" (e.g. `export const REQUEST_ID_KEY = WebpiecesCoreHeaders.REQUEST_ID;`, ' +\n 'or a dotted path like \"OneTabletKey.TX_ID\"); the header name is read off its responseHeader.',\n );\n }\n return new ResponseHeaderEntry(\n header.string('entry'),\n header.string('contextKey'),\n header.optionalString('description'),\n header.optionalBoolean('required'),\n );\n });\n }\n\n /** A manifest-relative path, resolved against the manifest's own directory. */\n resolve(manifestPath: string, relative: string): string {\n return path.resolve(path.dirname(manifestPath), relative);\n }\n}\n"]}
@@ -28,28 +28,12 @@
28
28
  * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.
29
29
  * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.
30
30
  */
31
- import { SchemaNameEntry } from '@webpieces/api-doc-model';
31
+ import { OperationIdStyle, SchemaNameEntry } from '@webpieces/api-doc-model';
32
32
  /**
33
33
  * The longest manifest `summary` (#1296): the Claude Connectors Directory's limit for a server's
34
34
  * one-line description, so the line published as `info.summary` can be pasted there unchanged.
35
35
  */
36
36
  export declare const MANIFEST_SUMMARY_MAX_LENGTH = 200;
37
- /**
38
- * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting
39
- * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one
40
- * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the
41
- * METHOD in every client a partner generates, so changing the spelling renames every method in every
42
- * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.
43
- */
44
- export declare enum OperationIdStyle {
45
- /** `OrdersApi_fetchOrders` — unique by construction across contracts. */
46
- CONTRACT_METHOD = "contract_method",
47
- /**
48
- * `fetchOrders` — the bare method name. Two operations of one document sharing it is a HARD
49
- * FAILURE naming both, so the id is still unique.
50
- */
51
- METHOD = "method"
52
- }
53
37
  export declare class ServerEntry {
54
38
  readonly url: string;
55
39
  readonly description: string | undefined;
@@ -1,28 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComponentsManifest = exports.OpenApiManifest = exports.ResponseHeaderEntry = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ApiEntry = exports.ServerEntry = exports.OperationIdStyle = exports.MANIFEST_SUMMARY_MAX_LENGTH = void 0;
3
+ exports.ComponentsManifest = exports.OpenApiManifest = exports.ResponseHeaderEntry = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ApiEntry = exports.ServerEntry = exports.MANIFEST_SUMMARY_MAX_LENGTH = void 0;
4
4
  /**
5
5
  * The longest manifest `summary` (#1296): the Claude Connectors Directory's limit for a server's
6
6
  * one-line description, so the line published as `info.summary` can be pasted there unchanged.
7
7
  */
8
8
  exports.MANIFEST_SUMMARY_MAX_LENGTH = 200;
9
- /**
10
- * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting
11
- * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one
12
- * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the
13
- * METHOD in every client a partner generates, so changing the spelling renames every method in every
14
- * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.
15
- */
16
- var OperationIdStyle;
17
- (function (OperationIdStyle) {
18
- /** `OrdersApi_fetchOrders` — unique by construction across contracts. */
19
- OperationIdStyle["CONTRACT_METHOD"] = "contract_method";
20
- /**
21
- * `fetchOrders` — the bare method name. Two operations of one document sharing it is a HARD
22
- * FAILURE naming both, so the id is still unique.
23
- */
24
- OperationIdStyle["METHOD"] = "method";
25
- })(OperationIdStyle || (exports.OperationIdStyle = OperationIdStyle = {}));
26
9
  class ServerEntry {
27
10
  url;
28
11
  description;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/OpenApiManifest.ts"],"names":[],"mappings":";;;AAgCA;;;GAGG;AACU,QAAA,2BAA2B,GAAG,GAAG,CAAC;AAE/C;;;;;;GAMG;AACH,IAAY,gBAQX;AARD,WAAY,gBAAgB;IACxB,yEAAyE;IACzE,uDAAmC,CAAA;IACnC;;;OAGG;IACH,qCAAiB,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BAAW,GAAX,WAAW,CAAoB;QAK/B,aAAQ,GAAR,QAAQ,CAAqB;IACvC,CAAC;CACP;AAXD,kDAWC;AAED,MAAa,eAAe;IAEX;IAKA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IAhBb,YACa,KAAa;IACtB;;;OAGG;IACM,OAAe,EACf,OAAe,EACf,OAA+B;IACxC,uFAAuF;IAC9E,eAAmC,EACnC,IAAyB,EACzB,mBAAsC,EACtC,MAA+B,EAC/B,eAA+C,EAC/C,WAAuC,EACvC,YAA8B;QAf9B,UAAK,GAAL,KAAK,CAAQ;QAKb,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAwB;QAE/B,oBAAe,GAAf,eAAe,CAAoB;QACnC,SAAI,GAAJ,IAAI,CAAqB;QACzB,wBAAmB,GAAnB,mBAAmB,CAAmB;QACtC,WAAM,GAAN,MAAM,CAAyB;QAC/B,oBAAe,GAAf,eAAe,CAAgC;QAC/C,gBAAW,GAAX,WAAW,CAA4B;QACvC,iBAAY,GAAZ,YAAY,CAAkB;IACxC,CAAC;CACP;AAnBD,0CAmBC;AAED;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAEd;IAEA;IACA;IAJb,YACa,KAAa;IACtB,gGAAgG;IACvF,OAA0B,EAC1B,WAAuC;QAHvC,UAAK,GAAL,KAAK,CAAQ;QAEb,YAAO,GAAP,OAAO,CAAmB;QAC1B,gBAAW,GAAX,WAAW,CAA4B;IACjD,CAAC;CACP;AAPD,gDAOC","sourcesContent":["/**\n * `openapi.manifest.json`, as CLASSES.\n *\n * ## What is allowed in here, and what is not\n *\n * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field\n * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:\n *\n * - `title`, `summary`, `version` — product decisions. `summary` is the API's one-line pitch (#1296),\n * published as `info.summary`; REQUIRED, one line, at most 200 characters — the Claude Connectors\n * Directory's one-liner limit, so the same text can be pasted there.\n * - `servers[]` — a deployment fact.\n * - `descriptionFile` — a teaching decision.\n * - `apis[]` — which contracts, in the order the published sidebar shows them.\n * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and\n * the AND-ed `security` requirement, is DERIVED from the contract's own `apiKey(...)`. A\n * `components.securitySchemes` block here would be a second copy of header names the running\n * server never reads, and nothing could contradict it.\n * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the\n * published shape cannot drift from the one on the wire.\n * - `responseHeaders[]` — declared by `contextKey` naming an exported ContextKey, never by a literal.\n * - `operationIds` — the published operationId spelling (#1270); optional, `contract_method` when omitted (#1283).\n *\n * Anything a renderer could read off the source instead belongs in the source.\n *\n * ## The ORDER of `apis[]` is published navigation\n *\n * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.\n * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.\n */\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\n\n/**\n * The longest manifest `summary` (#1296): the Claude Connectors Directory's limit for a server's\n * one-line description, so the line published as `info.summary` can be pasted there unchanged.\n */\nexport const MANIFEST_SUMMARY_MAX_LENGTH = 200;\n\n/**\n * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting\n * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one\n * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the\n * METHOD in every client a partner generates, so changing the spelling renames every method in every\n * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.\n */\nexport enum OperationIdStyle {\n /** `OrdersApi_fetchOrders` — unique by construction across contracts. */\n CONTRACT_METHOD = 'contract_method',\n /**\n * `fetchOrders` — the bare method name. Two operations of one document sharing it is a HARD\n * FAILURE naming both, so the id is still unique.\n */\n METHOD = 'method',\n}\n\nexport class ServerEntry {\n constructor(\n readonly url: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/** One contract file the generator reads. */\nexport class ApiEntry {\n constructor(\n /** Path to the contract `.ts`, relative to the manifest's own directory. */\n readonly entry: string,\n /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */\n readonly tag: string,\n /**\n * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE\n * make to a partner's server, not routes on ours.\n *\n * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a\n * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for\n * contract impact.\n */\n readonly kind: string | undefined,\n ) {}\n\n isWebhook(): boolean {\n return this.kind === 'webhook';\n }\n}\n\n/** One status code of the document-wide failure contract. */\nexport class ErrorResponseEntry {\n constructor(\n readonly status: string,\n readonly description: string,\n /**\n * `true`: this failure can only happen to an AUTHENTICATED operation (a 401 for a bad\n * credential), so it is left OFF every operation whose resolved auth is public\n * (`@WpAuthPublic`) — a public endpoint cannot fail authentication. Omitted means `false`:\n * the response is listed on every operation.\n */\n readonly requiresAuth: boolean,\n ) {}\n}\n\n/**\n * The document-wide failure contract.\n *\n * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written\n * list to keep in step with the handlers, and stating them once tells a partner the truth — any\n * operation can fail these ways.\n */\nexport class ErrorsEntry {\n constructor(\n /** The `.ts` file declaring the error body, relative to the manifest. */\n readonly entry: string,\n /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */\n readonly type: string,\n readonly responses: readonly ErrorResponseEntry[],\n ) {}\n}\n\n/**\n * One response header every operation carries — on its success response AND on every failure the\n * document declares for it (#1270): a correlation id matters most on the response that FAILED, and\n * the server stamps it on every response, so declaring it on the 200 alone under-documents the wire.\n *\n * `contextKey` names an exported `ContextKey` in `entry` — the export's name, or a dotted path into\n * one (`OneTabletKey.TX_ID`) — and the generator reads the header name off that key's own\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` definition: its `responseHeader`, which is\n * what the server's response choke point actually writes (#1249). A literal here would be a copy of\n * the header name that a rename leaves silently stale — and JSON cannot import, so naming the key is\n * the only way for this file to point at the one definition. Failing to resolve it is a HARD\n * FAILURE for the same reason.\n */\nexport class ResponseHeaderEntry {\n constructor(\n readonly entry: string,\n readonly contextKey: string,\n readonly description: string | undefined,\n /**\n * Rendered verbatim as the OpenAPI header object's `required`. Omitted means the document\n * does not state it, which OpenAPI reads as `false`.\n */\n readonly required: boolean | undefined,\n ) {}\n}\n\nexport class OpenApiManifest {\n constructor(\n readonly title: string,\n /**\n * The API's one-line summary (#1296) — OpenAPI 3.1 `info.summary`. REQUIRED: one line, at most\n * {@link MANIFEST_SUMMARY_MAX_LENGTH} characters.\n */\n readonly summary: string,\n readonly version: string,\n readonly servers: readonly ServerEntry[],\n /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */\n readonly descriptionFile: string | undefined,\n readonly apis: readonly ApiEntry[],\n readonly securitySchemeNames: readonly string[],\n readonly errors: ErrorsEntry | undefined,\n readonly responseHeaders: readonly ResponseHeaderEntry[],\n readonly schemaNames: readonly SchemaNameEntry[],\n readonly operationIds: OperationIdStyle,\n ) {}\n}\n\n/**\n * A DTO library's `openapi.manifest.json` — `\"kind\": \"components\"` (#1058).\n *\n * It names the library's ENTRY FILES instead of contracts: the document it produces is\n * components-only — `openapi`, `info` and `components.schemas`, no paths — holding every type the\n * library exports and declares, which contract documents `$ref` instead of copying. There is no\n * `version` here: a library document's `info.version` IS the package version, read from its\n * `package.json`, so the two cannot disagree.\n */\nexport class ComponentsManifest {\n constructor(\n readonly title: string,\n /** The library's entry files (usually `src/index.ts`), relative to the manifest's directory. */\n readonly entries: readonly string[],\n readonly schemaNames: readonly SchemaNameEntry[],\n ) {}\n}\n"]}
1
+ {"version":3,"file":"OpenApiManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/OpenApiManifest.ts"],"names":[],"mappings":";;;AAgCA;;;GAGG;AACU,QAAA,2BAA2B,GAAG,GAAG,CAAC;AAE/C,MAAa,WAAW;IAEP;IACA;IAFb,YACa,GAAW,EACX,WAA+B;QAD/B,QAAG,GAAH,GAAG,CAAQ;QACX,gB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;IACA;IACA;IAhBb,YACa,KAAa;IACtB;;;OAGG;IACM,OAAe,EACf,OAAe,EACf,OAA+B;IACxC,uFAAuF;IAC9E,eAAmC,EACnC,IAAyB,EACzB,mBAAsC,EACtC,MAA+B,EAC/B,eAA+C,EAC/C,WAAuC,EACvC,YAA8B;QAf9B,UAAK,GAAL,KAAK,CAAQ;QAKb,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAwB;QAE/B,oBAAe,GAAf,eAAe,CAAoB;QACnC,SAAI,GAAJ,IAAI,CAAqB;QACzB,wBAAmB,GAAnB,mBAAmB,CAAmB;QACtC,WAAM,GAAN,MAAM,CAAyB;QAC/B,oBAAe,GAAf,eAAe,CAAgC;QAC/C,gBAAW,GAAX,WAAW,CAA4B;QACvC,iBAAY,GAAZ,YAAY,CAAkB;IACxC,CAAC;CACP;AAnBD,0CAmBC;AAED;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAEd;IAEA;IACA;IAJb,YACa,KAAa;IACtB,gGAAgG;IACvF,OAA0B,EAC1B,WAAuC;QAHvC,UAAK,GAAL,KAAK,CAAQ;QAEb,YAAO,GAAP,OAAO,CAAmB;QAC1B,gBAAW,GAAX,WAAW,CAA4B;IACjD,CAAC;CACP;AAPD,gDAOC","sourcesContent":["/**\n * `openapi.manifest.json`, as CLASSES.\n *\n * ## What is allowed in here, and what is not\n *\n * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field\n * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:\n *\n * - `title`, `summary`, `version` — product decisions. `summary` is the API's one-line pitch (#1296),\n * published as `info.summary`; REQUIRED, one line, at most 200 characters — the Claude Connectors\n * Directory's one-liner limit, so the same text can be pasted there.\n * - `servers[]` — a deployment fact.\n * - `descriptionFile` — a teaching decision.\n * - `apis[]` — which contracts, in the order the published sidebar shows them.\n * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and\n * the AND-ed `security` requirement, is DERIVED from the contract's own `apiKey(...)`. A\n * `components.securitySchemes` block here would be a second copy of header names the running\n * server never reads, and nothing could contradict it.\n * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the\n * published shape cannot drift from the one on the wire.\n * - `responseHeaders[]` — declared by `contextKey` naming an exported ContextKey, never by a literal.\n * - `operationIds` — the published operationId spelling (#1270); optional, `contract_method` when omitted (#1283).\n *\n * Anything a renderer could read off the source instead belongs in the source.\n *\n * ## The ORDER of `apis[]` is published navigation\n *\n * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.\n * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.\n */\nimport { OperationIdStyle, SchemaNameEntry } from '@webpieces/api-doc-model';\n\n/**\n * The longest manifest `summary` (#1296): the Claude Connectors Directory's limit for a server's\n * one-line description, so the line published as `info.summary` can be pasted there unchanged.\n */\nexport const MANIFEST_SUMMARY_MAX_LENGTH = 200;\n\nexport class ServerEntry {\n constructor(\n readonly url: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/** One contract file the generator reads. */\nexport class ApiEntry {\n constructor(\n /** Path to the contract `.ts`, relative to the manifest's own directory. */\n readonly entry: string,\n /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */\n readonly tag: string,\n /**\n * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE\n * make to a partner's server, not routes on ours.\n *\n * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a\n * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for\n * contract impact.\n */\n readonly kind: string | undefined,\n ) {}\n\n isWebhook(): boolean {\n return this.kind === 'webhook';\n }\n}\n\n/** One status code of the document-wide failure contract. */\nexport class ErrorResponseEntry {\n constructor(\n readonly status: string,\n readonly description: string,\n /**\n * `true`: this failure can only happen to an AUTHENTICATED operation (a 401 for a bad\n * credential), so it is left OFF every operation whose resolved auth is public\n * (`@WpAuthPublic`) — a public endpoint cannot fail authentication. Omitted means `false`:\n * the response is listed on every operation.\n */\n readonly requiresAuth: boolean,\n ) {}\n}\n\n/**\n * The document-wide failure contract.\n *\n * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written\n * list to keep in step with the handlers, and stating them once tells a partner the truth — any\n * operation can fail these ways.\n */\nexport class ErrorsEntry {\n constructor(\n /** The `.ts` file declaring the error body, relative to the manifest. */\n readonly entry: string,\n /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */\n readonly type: string,\n readonly responses: readonly ErrorResponseEntry[],\n ) {}\n}\n\n/**\n * One response header every operation carries — on its success response AND on every failure the\n * document declares for it (#1270): a correlation id matters most on the response that FAILED, and\n * the server stamps it on every response, so declaring it on the 200 alone under-documents the wire.\n *\n * `contextKey` names an exported `ContextKey` in `entry` — the export's name, or a dotted path into\n * one (`OneTabletKey.TX_ID`) — and the generator reads the header name off that key's own\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` definition: its `responseHeader`, which is\n * what the server's response choke point actually writes (#1249). A literal here would be a copy of\n * the header name that a rename leaves silently stale — and JSON cannot import, so naming the key is\n * the only way for this file to point at the one definition. Failing to resolve it is a HARD\n * FAILURE for the same reason.\n */\nexport class ResponseHeaderEntry {\n constructor(\n readonly entry: string,\n readonly contextKey: string,\n readonly description: string | undefined,\n /**\n * Rendered verbatim as the OpenAPI header object's `required`. Omitted means the document\n * does not state it, which OpenAPI reads as `false`.\n */\n readonly required: boolean | undefined,\n ) {}\n}\n\nexport class OpenApiManifest {\n constructor(\n readonly title: string,\n /**\n * The API's one-line summary (#1296) — OpenAPI 3.1 `info.summary`. REQUIRED: one line, at most\n * {@link MANIFEST_SUMMARY_MAX_LENGTH} characters.\n */\n readonly summary: string,\n readonly version: string,\n readonly servers: readonly ServerEntry[],\n /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */\n readonly descriptionFile: string | undefined,\n readonly apis: readonly ApiEntry[],\n readonly securitySchemeNames: readonly string[],\n readonly errors: ErrorsEntry | undefined,\n readonly responseHeaders: readonly ResponseHeaderEntry[],\n readonly schemaNames: readonly SchemaNameEntry[],\n readonly operationIds: OperationIdStyle,\n ) {}\n}\n\n/**\n * A DTO library's `openapi.manifest.json` — `\"kind\": \"components\"` (#1058).\n *\n * It names the library's ENTRY FILES instead of contracts: the document it produces is\n * components-only — `openapi`, `info` and `components.schemas`, no paths — holding every type the\n * library exports and declares, which contract documents `$ref` instead of copying. There is no\n * `version` here: a library document's `info.version` IS the package version, read from its\n * `package.json`, so the two cannot disagree.\n */\nexport class ComponentsManifest {\n constructor(\n readonly title: string,\n /** The library's entry files (usually `src/index.ts`), relative to the manifest's directory. */\n readonly entries: readonly string[],\n readonly schemaNames: readonly SchemaNameEntry[],\n ) {}\n}\n"]}