@webpieces/openapi-generator 0.0.1

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.
Files changed (68) hide show
  1. package/README.md +118 -0
  2. package/package.json +32 -0
  3. package/src/OpenApiGenerationError.d.ts +41 -0
  4. package/src/OpenApiGenerationError.js +45 -0
  5. package/src/OpenApiGenerationError.js.map +1 -0
  6. package/src/cli/OpenApiCli.d.ts +33 -0
  7. package/src/cli/OpenApiCli.js +100 -0
  8. package/src/cli/OpenApiCli.js.map +1 -0
  9. package/src/cli/WpOpenApiMain.d.ts +25 -0
  10. package/src/cli/WpOpenApiMain.js +62 -0
  11. package/src/cli/WpOpenApiMain.js.map +1 -0
  12. package/src/cli/wp-openapi.d.ts +2 -0
  13. package/src/cli/wp-openapi.js +18 -0
  14. package/src/cli/wp-openapi.js.map +1 -0
  15. package/src/emit/ArtifactWriter.d.ts +44 -0
  16. package/src/emit/ArtifactWriter.js +75 -0
  17. package/src/emit/ArtifactWriter.js.map +1 -0
  18. package/src/generate/DocumentSelection.d.ts +96 -0
  19. package/src/generate/DocumentSelection.js +153 -0
  20. package/src/generate/DocumentSelection.js.map +1 -0
  21. package/src/generate/GenerationInputs.d.ts +67 -0
  22. package/src/generate/GenerationInputs.js +88 -0
  23. package/src/generate/GenerationInputs.js.map +1 -0
  24. package/src/generate/OpenApiGenerator.d.ts +113 -0
  25. package/src/generate/OpenApiGenerator.js +306 -0
  26. package/src/generate/OpenApiGenerator.js.map +1 -0
  27. package/src/generate/OperationRenderer.d.ts +129 -0
  28. package/src/generate/OperationRenderer.js +256 -0
  29. package/src/generate/OperationRenderer.js.map +1 -0
  30. package/src/generate/SchemaRenderer.d.ts +89 -0
  31. package/src/generate/SchemaRenderer.js +236 -0
  32. package/src/generate/SchemaRenderer.js.map +1 -0
  33. package/src/generate/SecurityDeriver.d.ts +39 -0
  34. package/src/generate/SecurityDeriver.js +81 -0
  35. package/src/generate/SecurityDeriver.js.map +1 -0
  36. package/src/index.d.ts +32 -0
  37. package/src/index.js +70 -0
  38. package/src/index.js.map +1 -0
  39. package/src/json/JsonObject.d.ts +35 -0
  40. package/src/json/JsonObject.js +32 -0
  41. package/src/json/JsonObject.js.map +1 -0
  42. package/src/json/JsonWriter.d.ts +18 -0
  43. package/src/json/JsonWriter.js +48 -0
  44. package/src/json/JsonWriter.js.map +1 -0
  45. package/src/json/YamlReader.d.ts +35 -0
  46. package/src/json/YamlReader.js +111 -0
  47. package/src/json/YamlReader.js.map +1 -0
  48. package/src/json/YamlWriter.d.ts +35 -0
  49. package/src/json/YamlWriter.js +88 -0
  50. package/src/json/YamlWriter.js.map +1 -0
  51. package/src/load/ExportedConstantFolder.d.ts +21 -0
  52. package/src/load/ExportedConstantFolder.js +57 -0
  53. package/src/load/ExportedConstantFolder.js.map +1 -0
  54. package/src/load/ForeignFailure.d.ts +24 -0
  55. package/src/load/ForeignFailure.js +41 -0
  56. package/src/load/ForeignFailure.js.map +1 -0
  57. package/src/load/InputsLoader.d.ts +43 -0
  58. package/src/load/InputsLoader.js +148 -0
  59. package/src/load/InputsLoader.js.map +1 -0
  60. package/src/manifest/JsonReader.d.ts +37 -0
  61. package/src/manifest/JsonReader.js +109 -0
  62. package/src/manifest/JsonReader.js.map +1 -0
  63. package/src/manifest/ManifestLoader.d.ts +20 -0
  64. package/src/manifest/ManifestLoader.js +69 -0
  65. package/src/manifest/ManifestLoader.js.map +1 -0
  66. package/src/manifest/OpenApiManifest.d.ts +116 -0
  67. package/src/manifest/OpenApiManifest.js +142 -0
  68. package/src/manifest/OpenApiManifest.js.map +1 -0
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsonReader = void 0;
4
+ const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
5
+ /**
6
+ * A narrowing reader over ONE parsed JSON object.
7
+ *
8
+ * ## Why this class exists at all
9
+ *
10
+ * `JSON.parse` returns something with no shape, and a loader that passed that shapelessness around
11
+ * would spread it over every method that touches the manifest. Concentrating it HERE means the rest
12
+ * of the package deals only in `string`, `JsonReader` and the manifest classes — and it means the
13
+ * "this value came off disk and has not been checked yet" state exists in exactly one file, where a
14
+ * reader can see every check that state is subjected to.
15
+ *
16
+ * ## Every miss is a HARD FAILURE naming the field
17
+ *
18
+ * There is deliberately no defaulting of anything a reader would notice. A published document quietly
19
+ * missing a section is indistinguishable, from the outside, from an API that genuinely has no error
20
+ * contract — so a mistyped `errors` must stop the run rather than silently publish less.
21
+ */
22
+ class JsonReader {
23
+ entries;
24
+ where;
25
+ constructor(
26
+ // webpieces-disable no-any-unknown -- parsed JSON is genuinely shapeless until the accessors below narrow it; this is the ONE place that state exists
27
+ entries,
28
+ /** The file this came from, so every failure names something somebody can open. */
29
+ where) {
30
+ this.entries = entries;
31
+ this.where = where;
32
+ }
33
+ /** Parse a whole file. */
34
+ // webpieces-disable no-function-outside-class -- static factory; the private constructor is what keeps unchecked JSON out of every other file
35
+ static parseFile(text, where) {
36
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- re-thrown as the ONE error type of this package, with its cure
37
+ try {
38
+ // webpieces-disable no-any-unknown -- JSON.parse's result, before anything has narrowed it
39
+ const parsed = JSON.parse(text);
40
+ return JsonReader.of(parsed, where, 'the manifest');
41
+ }
42
+ catch (err) {
43
+ //const error = toError(err);
44
+ if (err instanceof OpenApiGenerationError_1.OpenApiGenerationError) {
45
+ throw err;
46
+ }
47
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`not valid JSON: ${err instanceof Error ? err.message : String(err)}`, where, 'Fix the JSON syntax. The manifest is read before anything else runs.');
48
+ }
49
+ }
50
+ /** One already-parsed value that must be an object. */
51
+ // webpieces-disable no-any-unknown -- the value has not been narrowed yet; that is this method's job
52
+ // webpieces-disable no-function-outside-class -- static factory of this class
53
+ static of(value, where, what) {
54
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
55
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`${what} is not a JSON object`, where, 'Write it as a JSON object — one `{ ... }` with named fields.');
56
+ }
57
+ return new JsonReader(new Map(Object.entries(value)), where);
58
+ }
59
+ has(field) {
60
+ return this.entries.get(field) !== undefined;
61
+ }
62
+ /** A required, non-empty string. */
63
+ string(field) {
64
+ const value = this.optionalString(field);
65
+ if (value === undefined) {
66
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`'${field}' is missing or is not a non-empty string`, this.where, `Give "${field}" a value; an empty one publishes a document nobody can identify.`);
67
+ }
68
+ return value;
69
+ }
70
+ optionalString(field) {
71
+ // webpieces-disable no-any-unknown -- the raw entry, narrowed on the next line
72
+ const value = this.entries.get(field);
73
+ return typeof value === 'string' && value !== '' ? value : undefined;
74
+ }
75
+ /** An array of strings, empty when the field is absent. */
76
+ strings(field) {
77
+ // webpieces-disable no-any-unknown -- the raw entry, narrowed below
78
+ const value = this.entries.get(field);
79
+ if (value === undefined) {
80
+ return [];
81
+ }
82
+ // webpieces-disable no-any-unknown -- element of a not-yet-narrowed array
83
+ if (!Array.isArray(value) || value.some((each) => typeof each !== 'string')) {
84
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`'${field}' is not an array of strings`, this.where, `Write "${field}" as a JSON array of strings, or leave it out.`);
85
+ }
86
+ return value;
87
+ }
88
+ /** A nested object, or undefined when the field is absent. */
89
+ object(field) {
90
+ // webpieces-disable no-any-unknown -- the raw entry, narrowed by `of`
91
+ const value = this.entries.get(field);
92
+ return value === undefined ? undefined : JsonReader.of(value, this.where, `'${field}'`);
93
+ }
94
+ /** An array of objects, empty when the field is absent. */
95
+ objects(field) {
96
+ // webpieces-disable no-any-unknown -- the raw entry, narrowed below
97
+ const value = this.entries.get(field);
98
+ if (value === undefined) {
99
+ return [];
100
+ }
101
+ if (!Array.isArray(value)) {
102
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`'${field}' is not an array`, this.where, `Write "${field}" as a JSON array, or leave it out.`);
103
+ }
104
+ // webpieces-disable no-any-unknown -- element of a not-yet-narrowed array
105
+ return value.map((each) => JsonReader.of(each, this.where, `an entry of '${field}'`));
106
+ }
107
+ }
108
+ exports.JsonReader = JsonReader;
109
+ //# sourceMappingURL=JsonReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonReader.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/JsonReader.ts"],"names":[],"mappings":";;;AAAA,sEAAmE;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,UAAU;IAGE;IAER;IAJb;IACI,sJAAsJ;IACrI,OAAqC;IACtD,mFAAmF;IAC1E,KAAa;QAFL,YAAO,GAAP,OAAO,CAA8B;QAE7C,UAAK,GAAL,KAAK,CAAQ;IACvB,CAAC;IAEJ,0BAA0B;IAC1B,8IAA8I;IAC9I,MAAM,CAAC,SAAS,CAAC,IAAY,EAAE,KAAa;QACxC,gIAAgI;QAChI,IAAI,CAAC;YACD,2FAA2F;YAC3F,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,6BAA6B;YAC7B,IAAI,GAAG,YAAY,+CAAsB,EAAE,CAAC;gBACxC,MAAM,GAAG,CAAC;YACd,CAAC;YACD,MAAM,IAAI,+CAAsB,CAC5B,mBAAmB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EACrE,KAAK,EACL,sEAAsE,CACzE,CAAC;QACN,CAAC;IACL,CAAC;IAED,uDAAuD;IACvD,qGAAqG;IACrG,8EAA8E;IACtE,MAAM,CAAC,EAAE,CAAC,KAAc,EAAE,KAAa,EAAE,IAAY;QACzD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK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\n\n/**\n * A narrowing reader over ONE parsed JSON object.\n *\n * ## Why this class exists at all\n *\n * `JSON.parse` returns something with no shape, and a loader that passed that shapelessness around\n * would spread it over every method that touches the manifest. Concentrating it HERE means the rest\n * of the package deals only in `string`, `JsonReader` and the manifest classes — and it means the\n * \"this value came off disk and has not been checked yet\" state exists in exactly one file, where a\n * reader can see every check that state is subjected to.\n *\n * ## Every miss is a HARD FAILURE naming the field\n *\n * There is deliberately no defaulting of anything a reader would notice. A published document quietly\n * missing a section is indistinguishable, from the outside, from an API that genuinely has no error\n * contract — so a mistyped `errors` must stop the run rather than silently publish less.\n */\nexport class JsonReader {\n private constructor(\n // webpieces-disable no-any-unknown -- parsed JSON is genuinely shapeless until the accessors below narrow it; this is the ONE place that state exists\n private readonly entries: ReadonlyMap<string, unknown>,\n /** The file this came from, so every failure names something somebody can open. */\n readonly where: string,\n ) {}\n\n /** Parse a whole file. */\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what keeps unchecked JSON out of every other file\n static parseFile(text: string, where: string): JsonReader {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- re-thrown as the ONE error type of this package, with its cure\n try {\n // webpieces-disable no-any-unknown -- JSON.parse's result, before anything has narrowed it\n const parsed: unknown = JSON.parse(text);\n return JsonReader.of(parsed, where, 'the manifest');\n } catch (err: unknown) {\n //const error = toError(err);\n if (err instanceof OpenApiGenerationError) {\n throw err;\n }\n throw new OpenApiGenerationError(\n `not valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n where,\n 'Fix the JSON syntax. The manifest is read before anything else runs.',\n );\n }\n }\n\n /** One already-parsed value that must be an object. */\n // webpieces-disable no-any-unknown -- the value has not been narrowed yet; that is this method's job\n // webpieces-disable no-function-outside-class -- static factory of this class\n private static of(value: unknown, where: string, what: string): JsonReader {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new OpenApiGenerationError(\n `${what} is not a JSON object`,\n where,\n 'Write it as a JSON object — one `{ ... }` with named fields.',\n );\n }\n return new JsonReader(new Map(Object.entries(value)), where);\n }\n\n has(field: string): boolean {\n return this.entries.get(field) !== undefined;\n }\n\n /** A required, non-empty string. */\n string(field: string): string {\n const value = this.optionalString(field);\n if (value === undefined) {\n throw new OpenApiGenerationError(\n `'${field}' is missing or is not a non-empty string`,\n this.where,\n `Give \"${field}\" a value; an empty one publishes a document nobody can identify.`,\n );\n }\n return value;\n }\n\n optionalString(field: string): string | undefined {\n // webpieces-disable no-any-unknown -- the raw entry, narrowed on the next line\n const value: unknown = this.entries.get(field);\n return typeof value === 'string' && value !== '' ? value : undefined;\n }\n\n /** An array of strings, empty when the field is absent. */\n strings(field: string): readonly string[] {\n // webpieces-disable no-any-unknown -- the raw entry, narrowed below\n const value: unknown = this.entries.get(field);\n if (value === undefined) {\n return [];\n }\n // webpieces-disable no-any-unknown -- element of a not-yet-narrowed array\n if (!Array.isArray(value) || value.some((each: unknown) => typeof each !== 'string')) {\n throw new OpenApiGenerationError(\n `'${field}' is not an array of strings`,\n this.where,\n `Write \"${field}\" as a JSON array of strings, or leave it out.`,\n );\n }\n return value as readonly string[];\n }\n\n /** A nested object, or undefined when the field is absent. */\n object(field: string): JsonReader | undefined {\n // webpieces-disable no-any-unknown -- the raw entry, narrowed by `of`\n const value: unknown = this.entries.get(field);\n return value === undefined ? undefined : JsonReader.of(value, this.where, `'${field}'`);\n }\n\n /** An array of objects, empty when the field is absent. */\n objects(field: string): readonly JsonReader[] {\n // webpieces-disable no-any-unknown -- the raw entry, narrowed below\n const value: unknown = this.entries.get(field);\n if (value === undefined) {\n return [];\n }\n if (!Array.isArray(value)) {\n throw new OpenApiGenerationError(\n `'${field}' is not an array`,\n this.where,\n `Write \"${field}\" as a JSON array, or leave it out.`,\n );\n }\n // webpieces-disable no-any-unknown -- element of a not-yet-narrowed array\n return value.map((each: unknown) =>\n JsonReader.of(each, this.where, `an entry of '${field}'`),\n );\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { OpenApiManifest } from './OpenApiManifest';
2
+ /**
3
+ * Read `openapi.manifest.json` into {@link OpenApiManifest}.
4
+ *
5
+ * It deals only in {@link JsonReader}, which is where the "came off disk, not yet checked" state is
6
+ * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.
7
+ *
8
+ * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section
9
+ * is indistinguishable, from outside, from an API that genuinely has no error contract.
10
+ */
11
+ export declare class ManifestLoader {
12
+ /** @param manifestPath absolute path to `openapi.manifest.json`. */
13
+ load(manifestPath: string): OpenApiManifest;
14
+ private servers;
15
+ private apis;
16
+ private errors;
17
+ private responseHeaders;
18
+ /** A manifest-relative path, resolved against the manifest's own directory. */
19
+ resolve(manifestPath: string, relative: string): string;
20
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManifestLoader = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("node:fs"));
6
+ const path = tslib_1.__importStar(require("node:path"));
7
+ const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
8
+ const JsonReader_1 = require("./JsonReader");
9
+ const OpenApiManifest_1 = require("./OpenApiManifest");
10
+ /** The only `kind` an api entry may declare. Anything else is a typo, and typos are refused. */
11
+ const WEBHOOK = 'webhook';
12
+ /**
13
+ * Read `openapi.manifest.json` into {@link OpenApiManifest}.
14
+ *
15
+ * It deals only in {@link JsonReader}, which is where the "came off disk, not yet checked" state is
16
+ * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.
17
+ *
18
+ * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section
19
+ * is indistinguishable, from outside, from an API that genuinely has no error contract.
20
+ */
21
+ class ManifestLoader {
22
+ /** @param manifestPath absolute path to `openapi.manifest.json`. */
23
+ load(manifestPath) {
24
+ if (!fs.existsSync(manifestPath)) {
25
+ throw new OpenApiGenerationError_1.OpenApiGenerationError('no manifest at this path', manifestPath, 'Pass --manifest pointing at an openapi.manifest.json that exists.');
26
+ }
27
+ const raw = JsonReader_1.JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);
28
+ return new OpenApiManifest_1.OpenApiManifest(raw.string('title'), raw.string('version'), this.servers(raw), raw.optionalString('descriptionFile'), this.apis(raw), raw.strings('securitySchemeNames'), this.errors(raw), this.responseHeaders(raw));
29
+ }
30
+ servers(raw) {
31
+ return raw
32
+ .objects('servers')
33
+ .map((server) => new OpenApiManifest_1.ServerEntry(server.string('url'), server.optionalString('description')));
34
+ }
35
+ apis(raw) {
36
+ const entries = raw
37
+ .objects('apis')
38
+ .map((api) => new OpenApiManifest_1.ApiEntry(api.string('entry'), api.string('tag'), api.optionalString('kind')));
39
+ if (entries.length === 0) {
40
+ throw new OpenApiGenerationError_1.OpenApiGenerationError("'apis' is empty", raw.where, 'List at least one contract; a document with no operations publishes nothing.');
41
+ }
42
+ for (const entry of entries) {
43
+ if (entry.kind !== undefined && entry.kind !== WEBHOOK) {
44
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`unknown api kind '${entry.kind}' on '${entry.entry}'`, raw.where, `The only declared kind is "${WEBHOOK}". Leave it out for an ordinary contract.`);
45
+ }
46
+ }
47
+ return entries;
48
+ }
49
+ errors(raw) {
50
+ const errors = raw.object('errors');
51
+ if (errors === undefined) {
52
+ return undefined;
53
+ }
54
+ return new OpenApiManifest_1.ErrorsEntry(errors.string('entry'), errors.string('type'), errors
55
+ .objects('responses')
56
+ .map((response) => new OpenApiManifest_1.ErrorResponseEntry(response.string('status'), response.string('description'))));
57
+ }
58
+ responseHeaders(raw) {
59
+ return raw
60
+ .objects('responseHeaders')
61
+ .map((header) => new OpenApiManifest_1.ResponseHeaderEntry(header.string('entry'), header.string('nameConstant'), header.optionalString('description')));
62
+ }
63
+ /** A manifest-relative path, resolved against the manifest's own directory. */
64
+ resolve(manifestPath, relative) {
65
+ return path.resolve(path.dirname(manifestPath), relative);
66
+ }
67
+ }
68
+ exports.ManifestLoader = ManifestLoader;
69
+ //# sourceMappingURL=ManifestLoader.js.map
@@ -0,0 +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,uDAO2B;AAE3B,gGAAgG;AAChG,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B;;;;;;;;GAQG;AACH,MAAa,cAAc;IACvB,oEAAoE;IACpE,IAAI,CAAC,YAAoB;QACrB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,+CAAsB,CAC5B,0BAA0B,EAC1B,YAAY,EACZ,mEAAmE,CACtE,CAAC;QACN,CAAC;QACD,MAAM,GAAG,GAAG,uBAAU,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC;QACtF,OAAO,IAAI,iCAAe,CACtB,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EACnB,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EACrB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EACjB,GAAG,CAAC,cAAc,CAAC,iBAAiB,CAAC,EACrC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EACd,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAChB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAC5B,CAAC;IACN,CAAC;IAEO,OAAO,CAAC,GAAe;QAC3B,OAAO,GAAG;aACL,OAAO,CAAC,SAAS,CAAC;aAClB,GAAG,CACA,CAAC,MAAkB,EAAE,EAAE,CACnB,IAAI,6BAAW,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,c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QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EACzB,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CACjC,CACR,CACR,CAAC;IACN,CAAC;IAEO,eAAe,CAAC,GAAe;QACnC,OAAO,GAAG;aACL,OAAO,CAAC,iBAAiB,CAAC;aAC1B,GAAG,CACA,CAAC,MAAkB,EAAE,EAAE,CACnB,IAAI,qCAAmB,CACnB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAC7B,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CACvC,CACR,CAAC;IACV,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;AAnGD,wCAmGC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { JsonReader } from './JsonReader';\nimport {\n ApiEntry,\n ErrorResponseEntry,\n ErrorsEntry,\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 * 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 /** @param manifestPath absolute path to `openapi.manifest.json`. */\n load(manifestPath: string): OpenApiManifest {\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 const raw = JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);\n return new OpenApiManifest(\n raw.string('title'),\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 );\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 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 ),\n ),\n );\n }\n\n private responseHeaders(raw: JsonReader): readonly ResponseHeaderEntry[] {\n return raw\n .objects('responseHeaders')\n .map(\n (header: JsonReader) =>\n new ResponseHeaderEntry(\n header.string('entry'),\n header.string('nameConstant'),\n header.optionalString('description'),\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"]}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * `openapi.manifest.json`, as CLASSES.
3
+ *
4
+ * ## What is allowed in here, and what is not
5
+ *
6
+ * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field
7
+ * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:
8
+ *
9
+ * - `title`, `version` — product decisions.
10
+ * - `servers[]` — a deployment fact.
11
+ * - `descriptionFile` — a teaching decision.
12
+ * - `apis[]` — which contracts, in the order the published sidebar shows them.
13
+ * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and
14
+ * the AND-ed `security` requirement, is DERIVED from the contract's own `@WpAuthApiKey`. A
15
+ * `components.securitySchemes` block here would be a second copy of header names the running
16
+ * server never reads, and nothing could contradict it.
17
+ * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the
18
+ * published shape cannot drift from the one on the wire.
19
+ * - `responseHeaders[]` — declared by `nameConstant` naming an exported const, never by a literal.
20
+ *
21
+ * Anything a renderer could read off the source instead belongs in the source.
22
+ *
23
+ * ## The ORDER of `apis[]` is published navigation
24
+ *
25
+ * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.
26
+ * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.
27
+ */
28
+ export declare class ServerEntry {
29
+ readonly url: string;
30
+ readonly description: string | undefined;
31
+ constructor(url: string, description: string | undefined);
32
+ }
33
+ /** One contract file the generator reads. */
34
+ export declare class ApiEntry {
35
+ /** Path to the contract `.ts`, relative to the manifest's own directory. */
36
+ readonly entry: string;
37
+ /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */
38
+ readonly tag: string;
39
+ /**
40
+ * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE
41
+ * make to a partner's server, not routes on ours.
42
+ *
43
+ * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a
44
+ * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for
45
+ * contract impact.
46
+ */
47
+ readonly kind: string | undefined;
48
+ constructor(
49
+ /** Path to the contract `.ts`, relative to the manifest's own directory. */
50
+ entry: string,
51
+ /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */
52
+ tag: string,
53
+ /**
54
+ * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE
55
+ * make to a partner's server, not routes on ours.
56
+ *
57
+ * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a
58
+ * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for
59
+ * contract impact.
60
+ */
61
+ kind: string | undefined);
62
+ isWebhook(): boolean;
63
+ }
64
+ /** One status code of the document-wide failure contract. */
65
+ export declare class ErrorResponseEntry {
66
+ readonly status: string;
67
+ readonly description: string;
68
+ constructor(status: string, description: string);
69
+ }
70
+ /**
71
+ * The document-wide failure contract.
72
+ *
73
+ * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written
74
+ * list to keep in step with the handlers, and stating them once tells a partner the truth — any
75
+ * operation can fail these ways.
76
+ */
77
+ export declare class ErrorsEntry {
78
+ /** The `.ts` file declaring the error body, relative to the manifest. */
79
+ readonly entry: string;
80
+ /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */
81
+ readonly type: string;
82
+ readonly responses: readonly ErrorResponseEntry[];
83
+ constructor(
84
+ /** The `.ts` file declaring the error body, relative to the manifest. */
85
+ entry: string,
86
+ /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */
87
+ type: string, responses: readonly ErrorResponseEntry[]);
88
+ }
89
+ /**
90
+ * One response header every operation carries.
91
+ *
92
+ * `nameConstant` names an exported `const` in `entry`, and the generator FOLDS it. A literal here
93
+ * would be a copy of the header name that a rename leaves silently stale — and JSON cannot import,
94
+ * so naming the constant is the only way for this file to point at the one the server actually
95
+ * writes. Failing to fold it is a HARD FAILURE for the same reason.
96
+ */
97
+ export declare class ResponseHeaderEntry {
98
+ readonly entry: string;
99
+ readonly nameConstant: string;
100
+ readonly description: string | undefined;
101
+ constructor(entry: string, nameConstant: string, description: string | undefined);
102
+ }
103
+ export declare class OpenApiManifest {
104
+ readonly title: string;
105
+ readonly version: string;
106
+ readonly servers: readonly ServerEntry[];
107
+ /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */
108
+ readonly descriptionFile: string | undefined;
109
+ readonly apis: readonly ApiEntry[];
110
+ readonly securitySchemeNames: readonly string[];
111
+ readonly errors: ErrorsEntry | undefined;
112
+ readonly responseHeaders: readonly ResponseHeaderEntry[];
113
+ constructor(title: string, version: string, servers: readonly ServerEntry[],
114
+ /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */
115
+ descriptionFile: string | undefined, apis: readonly ApiEntry[], securitySchemeNames: readonly string[], errors: ErrorsEntry | undefined, responseHeaders: readonly ResponseHeaderEntry[]);
116
+ }
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenApiManifest = exports.ResponseHeaderEntry = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ApiEntry = exports.ServerEntry = void 0;
4
+ /**
5
+ * `openapi.manifest.json`, as CLASSES.
6
+ *
7
+ * ## What is allowed in here, and what is not
8
+ *
9
+ * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field
10
+ * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:
11
+ *
12
+ * - `title`, `version` — product decisions.
13
+ * - `servers[]` — a deployment fact.
14
+ * - `descriptionFile` — a teaching decision.
15
+ * - `apis[]` — which contracts, in the order the published sidebar shows them.
16
+ * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and
17
+ * the AND-ed `security` requirement, is DERIVED from the contract's own `@WpAuthApiKey`. A
18
+ * `components.securitySchemes` block here would be a second copy of header names the running
19
+ * server never reads, and nothing could contradict it.
20
+ * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the
21
+ * published shape cannot drift from the one on the wire.
22
+ * - `responseHeaders[]` — declared by `nameConstant` naming an exported const, never by a literal.
23
+ *
24
+ * Anything a renderer could read off the source instead belongs in the source.
25
+ *
26
+ * ## The ORDER of `apis[]` is published navigation
27
+ *
28
+ * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.
29
+ * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.
30
+ */
31
+ class ServerEntry {
32
+ url;
33
+ description;
34
+ constructor(url, description) {
35
+ this.url = url;
36
+ this.description = description;
37
+ }
38
+ }
39
+ exports.ServerEntry = ServerEntry;
40
+ /** One contract file the generator reads. */
41
+ class ApiEntry {
42
+ entry;
43
+ tag;
44
+ kind;
45
+ constructor(
46
+ /** Path to the contract `.ts`, relative to the manifest's own directory. */
47
+ entry,
48
+ /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */
49
+ tag,
50
+ /**
51
+ * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE
52
+ * make to a partner's server, not routes on ours.
53
+ *
54
+ * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a
55
+ * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for
56
+ * contract impact.
57
+ */
58
+ kind) {
59
+ this.entry = entry;
60
+ this.tag = tag;
61
+ this.kind = kind;
62
+ }
63
+ isWebhook() {
64
+ return this.kind === 'webhook';
65
+ }
66
+ }
67
+ exports.ApiEntry = ApiEntry;
68
+ /** One status code of the document-wide failure contract. */
69
+ class ErrorResponseEntry {
70
+ status;
71
+ description;
72
+ constructor(status, description) {
73
+ this.status = status;
74
+ this.description = description;
75
+ }
76
+ }
77
+ exports.ErrorResponseEntry = ErrorResponseEntry;
78
+ /**
79
+ * The document-wide failure contract.
80
+ *
81
+ * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written
82
+ * list to keep in step with the handlers, and stating them once tells a partner the truth — any
83
+ * operation can fail these ways.
84
+ */
85
+ class ErrorsEntry {
86
+ entry;
87
+ type;
88
+ responses;
89
+ constructor(
90
+ /** The `.ts` file declaring the error body, relative to the manifest. */
91
+ entry,
92
+ /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */
93
+ type, responses) {
94
+ this.entry = entry;
95
+ this.type = type;
96
+ this.responses = responses;
97
+ }
98
+ }
99
+ exports.ErrorsEntry = ErrorsEntry;
100
+ /**
101
+ * One response header every operation carries.
102
+ *
103
+ * `nameConstant` names an exported `const` in `entry`, and the generator FOLDS it. A literal here
104
+ * would be a copy of the header name that a rename leaves silently stale — and JSON cannot import,
105
+ * so naming the constant is the only way for this file to point at the one the server actually
106
+ * writes. Failing to fold it is a HARD FAILURE for the same reason.
107
+ */
108
+ class ResponseHeaderEntry {
109
+ entry;
110
+ nameConstant;
111
+ description;
112
+ constructor(entry, nameConstant, description) {
113
+ this.entry = entry;
114
+ this.nameConstant = nameConstant;
115
+ this.description = description;
116
+ }
117
+ }
118
+ exports.ResponseHeaderEntry = ResponseHeaderEntry;
119
+ class OpenApiManifest {
120
+ title;
121
+ version;
122
+ servers;
123
+ descriptionFile;
124
+ apis;
125
+ securitySchemeNames;
126
+ errors;
127
+ responseHeaders;
128
+ constructor(title, version, servers,
129
+ /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */
130
+ descriptionFile, apis, securitySchemeNames, errors, responseHeaders) {
131
+ this.title = title;
132
+ this.version = version;
133
+ this.servers = servers;
134
+ this.descriptionFile = descriptionFile;
135
+ this.apis = apis;
136
+ this.securitySchemeNames = securitySchemeNames;
137
+ this.errors = errors;
138
+ this.responseHeaders = responseHeaders;
139
+ }
140
+ }
141
+ exports.OpenApiManifest = OpenApiManifest;
142
+ //# sourceMappingURL=OpenApiManifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenApiManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/OpenApiManifest.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,WAAW;IAEP;IACA;IAFb,YACa,GAAW,EACX,WAA+B;QAD/B,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAoB;IACzC,CAAC;CAC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;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;IACzD,CAAC;CACP;AAZD,0CAYC","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`, `version` — product decisions.\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 `@WpAuthApiKey`. 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 `nameConstant` naming an exported const, never by a literal.\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 */\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}\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.\n *\n * `nameConstant` names an exported `const` in `entry`, and the generator FOLDS it. A literal here\n * would be a copy of the header name that a rename leaves silently stale — and JSON cannot import,\n * so naming the constant is the only way for this file to point at the one the server actually\n * writes. Failing to fold it is a HARD FAILURE for the same reason.\n */\nexport class ResponseHeaderEntry {\n constructor(\n readonly entry: string,\n readonly nameConstant: string,\n readonly description: string | undefined,\n ) {}\n}\n\nexport class OpenApiManifest {\n constructor(\n readonly title: 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 ) {}\n}\n"]}