@depup/openapi-typescript 7.13.0-depup.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +1162 -0
  2. package/CONTRIBUTING.md +149 -0
  3. package/LICENSE +21 -0
  4. package/README.md +32 -0
  5. package/bin/cli.js +297 -0
  6. package/changes.json +14 -0
  7. package/dist/index.cjs +152 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.cts +517 -0
  10. package/dist/index.d.mts +515 -0
  11. package/dist/index.d.ts +517 -0
  12. package/dist/index.mjs +85 -0
  13. package/dist/index.mjs.map +1 -0
  14. package/dist/lib/redoc.cjs +129 -0
  15. package/dist/lib/redoc.cjs.map +1 -0
  16. package/dist/lib/redoc.mjs +122 -0
  17. package/dist/lib/redoc.mjs.map +1 -0
  18. package/dist/lib/ts.cjs +470 -0
  19. package/dist/lib/ts.cjs.map +1 -0
  20. package/dist/lib/ts.mjs +431 -0
  21. package/dist/lib/ts.mjs.map +1 -0
  22. package/dist/lib/utils.cjs +295 -0
  23. package/dist/lib/utils.cjs.map +1 -0
  24. package/dist/lib/utils.mjs +278 -0
  25. package/dist/lib/utils.mjs.map +1 -0
  26. package/dist/transform/components-object.cjs +150 -0
  27. package/dist/transform/components-object.cjs.map +1 -0
  28. package/dist/transform/components-object.mjs +127 -0
  29. package/dist/transform/components-object.mjs.map +1 -0
  30. package/dist/transform/header-object.cjs +48 -0
  31. package/dist/transform/header-object.cjs.map +1 -0
  32. package/dist/transform/header-object.mjs +42 -0
  33. package/dist/transform/header-object.mjs.map +1 -0
  34. package/dist/transform/index.cjs +124 -0
  35. package/dist/transform/index.cjs.map +1 -0
  36. package/dist/transform/index.mjs +118 -0
  37. package/dist/transform/index.mjs.map +1 -0
  38. package/dist/transform/media-type-object.cjs +14 -0
  39. package/dist/transform/media-type-object.cjs.map +1 -0
  40. package/dist/transform/media-type-object.mjs +12 -0
  41. package/dist/transform/media-type-object.mjs.map +1 -0
  42. package/dist/transform/operation-object.cjs +105 -0
  43. package/dist/transform/operation-object.cjs.map +1 -0
  44. package/dist/transform/operation-object.mjs +96 -0
  45. package/dist/transform/operation-object.mjs.map +1 -0
  46. package/dist/transform/parameter-object.cjs +11 -0
  47. package/dist/transform/parameter-object.cjs.map +1 -0
  48. package/dist/transform/parameter-object.mjs +9 -0
  49. package/dist/transform/parameter-object.mjs.map +1 -0
  50. package/dist/transform/parameters-array.cjs +120 -0
  51. package/dist/transform/parameters-array.cjs.map +1 -0
  52. package/dist/transform/parameters-array.mjs +114 -0
  53. package/dist/transform/parameters-array.mjs.map +1 -0
  54. package/dist/transform/path-item-object.cjs +84 -0
  55. package/dist/transform/path-item-object.cjs.map +1 -0
  56. package/dist/transform/path-item-object.mjs +78 -0
  57. package/dist/transform/path-item-object.mjs.map +1 -0
  58. package/dist/transform/paths-enum.cjs +35 -0
  59. package/dist/transform/paths-enum.cjs.map +1 -0
  60. package/dist/transform/paths-enum.mjs +33 -0
  61. package/dist/transform/paths-enum.mjs.map +1 -0
  62. package/dist/transform/paths-object.cjs +134 -0
  63. package/dist/transform/paths-object.cjs.map +1 -0
  64. package/dist/transform/paths-object.mjs +128 -0
  65. package/dist/transform/paths-object.mjs.map +1 -0
  66. package/dist/transform/request-body-object.cjs +68 -0
  67. package/dist/transform/request-body-object.cjs.map +1 -0
  68. package/dist/transform/request-body-object.mjs +62 -0
  69. package/dist/transform/request-body-object.mjs.map +1 -0
  70. package/dist/transform/response-object.cjs +123 -0
  71. package/dist/transform/response-object.cjs.map +1 -0
  72. package/dist/transform/response-object.mjs +117 -0
  73. package/dist/transform/response-object.mjs.map +1 -0
  74. package/dist/transform/responses-object.cjs +36 -0
  75. package/dist/transform/responses-object.cjs.map +1 -0
  76. package/dist/transform/responses-object.mjs +30 -0
  77. package/dist/transform/responses-object.mjs.map +1 -0
  78. package/dist/transform/schema-object.cjs +502 -0
  79. package/dist/transform/schema-object.cjs.map +1 -0
  80. package/dist/transform/schema-object.mjs +493 -0
  81. package/dist/transform/schema-object.mjs.map +1 -0
  82. package/dist/transform/webhooks-object.cjs +37 -0
  83. package/dist/transform/webhooks-object.cjs.map +1 -0
  84. package/dist/transform/webhooks-object.mjs +31 -0
  85. package/dist/transform/webhooks-object.mjs.map +1 -0
  86. package/package.json +102 -0
  87. package/src/index.ts +108 -0
  88. package/src/lib/redoc.ts +164 -0
  89. package/src/lib/ts.ts +616 -0
  90. package/src/lib/utils.ts +394 -0
  91. package/src/transform/components-object.ts +161 -0
  92. package/src/transform/header-object.ts +45 -0
  93. package/src/transform/index.ts +116 -0
  94. package/src/transform/media-type-object.ts +18 -0
  95. package/src/transform/operation-object.ts +104 -0
  96. package/src/transform/parameter-object.ts +15 -0
  97. package/src/transform/parameters-array.ts +129 -0
  98. package/src/transform/path-item-object.ts +102 -0
  99. package/src/transform/paths-enum.ts +43 -0
  100. package/src/transform/paths-object.ts +134 -0
  101. package/src/transform/request-body-object.ts +59 -0
  102. package/src/transform/response-object.ts +112 -0
  103. package/src/transform/responses-object.ts +36 -0
  104. package/src/transform/schema-object.ts +737 -0
  105. package/src/transform/webhooks-object.ts +27 -0
  106. package/src/types.ts +735 -0
@@ -0,0 +1,114 @@
1
+ import ts from 'typescript';
2
+ import { oapiRef, tsModifiers, tsPropertyIndex, addJSDocComment, QUESTION_TOKEN, NEVER } from '../lib/ts.mjs';
3
+ import { createRef } from '../lib/utils.mjs';
4
+ import transformParameterObject from './parameter-object.mjs';
5
+
6
+ const PATH_PARAM_RE = /\{([^}]+)\}/g;
7
+ function createPathParameter(paramName) {
8
+ return {
9
+ name: paramName,
10
+ in: "path",
11
+ required: true,
12
+ schema: { type: "string" }
13
+ };
14
+ }
15
+ function extractPathParamsFromUrl(path) {
16
+ const params = [];
17
+ const matches = path.match(PATH_PARAM_RE);
18
+ if (matches) {
19
+ for (const match of matches) {
20
+ const paramName = match.slice(1, -1);
21
+ params.push(createPathParameter(paramName));
22
+ }
23
+ }
24
+ return params;
25
+ }
26
+ function transformParametersArray(parametersArray, options) {
27
+ const type = [];
28
+ const workingParameters = [...parametersArray];
29
+ if (options.ctx.generatePathParams && options.path) {
30
+ const pathString = Array.isArray(options.path) ? options.path[0] : options.path;
31
+ if (typeof pathString === "string") {
32
+ const pathParams = extractPathParamsFromUrl(pathString);
33
+ for (const param of pathParams) {
34
+ const exists = workingParameters.some((p) => {
35
+ const resolved = "$ref" in p ? options.ctx.resolve(p.$ref) : p;
36
+ return resolved?.in === "path" && resolved?.name === param.name;
37
+ });
38
+ if (!exists) {
39
+ workingParameters.push(param);
40
+ }
41
+ }
42
+ }
43
+ }
44
+ const paramType = [];
45
+ for (const paramIn of ["query", "header", "path", "cookie"]) {
46
+ const paramLocType = [];
47
+ let operationParameters = workingParameters.map((param) => ({
48
+ original: param,
49
+ resolved: "$ref" in param ? options.ctx.resolve(param.$ref) : param
50
+ }));
51
+ if (options.ctx.alphabetize) {
52
+ operationParameters.sort((a, b) => (a.resolved?.name ?? "").localeCompare(b.resolved?.name ?? ""));
53
+ }
54
+ if (options.ctx.excludeDeprecated) {
55
+ operationParameters = operationParameters.filter(
56
+ ({ resolved }) => !resolved?.deprecated && !resolved?.schema?.deprecated
57
+ );
58
+ }
59
+ for (const { original, resolved } of operationParameters) {
60
+ if (resolved?.in !== paramIn) {
61
+ continue;
62
+ }
63
+ let optional;
64
+ if (paramIn !== "path" && !resolved.required) {
65
+ optional = QUESTION_TOKEN;
66
+ }
67
+ const subType = "$ref" in original ? oapiRef(original.$ref, resolved) : transformParameterObject(resolved, {
68
+ ...options,
69
+ path: createRef([options.path, "parameters", resolved.in, resolved.name])
70
+ });
71
+ const property = ts.factory.createPropertySignature(
72
+ /* modifiers */
73
+ tsModifiers({ readonly: options.ctx.immutable }),
74
+ /* name */
75
+ tsPropertyIndex(resolved?.name),
76
+ /* questionToken */
77
+ optional,
78
+ /* type */
79
+ subType
80
+ );
81
+ addJSDocComment(resolved, property);
82
+ paramLocType.push(property);
83
+ }
84
+ const allOptional = paramLocType.every((node) => !!node.questionToken);
85
+ paramType.push(
86
+ ts.factory.createPropertySignature(
87
+ /* modifiers */
88
+ tsModifiers({ readonly: options.ctx.immutable }),
89
+ /* name */
90
+ tsPropertyIndex(paramIn),
91
+ /* questionToken */
92
+ allOptional || !paramLocType.length ? QUESTION_TOKEN : void 0,
93
+ /* type */
94
+ paramLocType.length ? ts.factory.createTypeLiteralNode(paramLocType) : NEVER
95
+ )
96
+ );
97
+ }
98
+ type.push(
99
+ ts.factory.createPropertySignature(
100
+ /* modifiers */
101
+ tsModifiers({ readonly: options.ctx.immutable }),
102
+ /* name */
103
+ tsPropertyIndex("parameters"),
104
+ /* questionToken */
105
+ !paramType.length ? QUESTION_TOKEN : void 0,
106
+ /* type */
107
+ paramType.length ? ts.factory.createTypeLiteralNode(paramType) : NEVER
108
+ )
109
+ );
110
+ return type;
111
+ }
112
+
113
+ export { transformParametersArray };
114
+ //# sourceMappingURL=parameters-array.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters-array.mjs","sources":["../../src/transform/parameters-array.ts"],"sourcesContent":["import ts from \"typescript\";\nimport { addJSDocComment, NEVER, oapiRef, QUESTION_TOKEN, tsModifiers, tsPropertyIndex } from \"../lib/ts.js\";\nimport { createRef } from \"../lib/utils.js\";\nimport type { ParameterObject, ReferenceObject, TransformNodeOptions } from \"../types.js\";\nimport transformParameterObject from \"./parameter-object.js\";\n\n// Regex to match path parameters in URL\nconst PATH_PARAM_RE = /\\{([^}]+)\\}/g;\n\n/**\n * Create a synthetic path parameter object from a parameter name\n */\nfunction createPathParameter(paramName: string): ParameterObject {\n return {\n name: paramName,\n in: \"path\",\n required: true,\n schema: { type: \"string\" },\n };\n}\n\n/**\n * Extract path parameters from a URL\n */\nfunction extractPathParamsFromUrl(path: string): ParameterObject[] {\n const params: ParameterObject[] = [];\n const matches = path.match(PATH_PARAM_RE);\n if (matches) {\n for (const match of matches) {\n const paramName = match.slice(1, -1);\n params.push(createPathParameter(paramName));\n }\n }\n return params;\n}\n\n/**\n * Synthetic type. Array of (ParameterObject | ReferenceObject)s found in OperationObject and PathItemObject.\n */\nexport function transformParametersArray(\n parametersArray: (ParameterObject | ReferenceObject)[],\n options: TransformNodeOptions,\n): ts.TypeElement[] {\n const type: ts.TypeElement[] = [];\n\n // Create a working copy of parameters array\n const workingParameters = [...parametersArray];\n\n // Generate path parameters if enabled\n if (options.ctx.generatePathParams && options.path) {\n const pathString = Array.isArray(options.path) ? options.path[0] : options.path;\n if (typeof pathString === \"string\") {\n const pathParams = extractPathParamsFromUrl(pathString);\n // Only add path parameters that aren't already defined\n for (const param of pathParams) {\n const exists = workingParameters.some((p) => {\n const resolved = \"$ref\" in p ? options.ctx.resolve<ParameterObject>(p.$ref) : p;\n return resolved?.in === \"path\" && resolved?.name === param.name;\n });\n if (!exists) {\n workingParameters.push(param);\n }\n }\n }\n }\n\n // parameters\n const paramType: ts.TypeElement[] = [];\n for (const paramIn of [\"query\", \"header\", \"path\", \"cookie\"] as ParameterObject[\"in\"][]) {\n const paramLocType: ts.TypeElement[] = [];\n let operationParameters = workingParameters.map((param) => ({\n original: param,\n resolved: \"$ref\" in param ? options.ctx.resolve<ParameterObject>(param.$ref) : param,\n }));\n\n // this is the only array type in the spec, so we have to one-off sort here\n if (options.ctx.alphabetize) {\n operationParameters.sort((a, b) => (a.resolved?.name ?? \"\").localeCompare(b.resolved?.name ?? \"\"));\n }\n if (options.ctx.excludeDeprecated) {\n operationParameters = operationParameters.filter(\n ({ resolved }) => !resolved?.deprecated && !resolved?.schema?.deprecated,\n );\n }\n for (const { original, resolved } of operationParameters) {\n if (resolved?.in !== paramIn) {\n continue;\n }\n let optional: ts.QuestionToken | undefined;\n if (paramIn !== \"path\" && !(resolved as ParameterObject).required) {\n optional = QUESTION_TOKEN;\n }\n const subType =\n \"$ref\" in original\n ? oapiRef(original.$ref, resolved)\n : transformParameterObject(resolved as ParameterObject, {\n ...options,\n path: createRef([options.path, \"parameters\", resolved.in, resolved.name]),\n });\n const property = ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),\n /* name */ tsPropertyIndex(resolved?.name),\n /* questionToken */ optional,\n /* type */ subType,\n );\n addJSDocComment(resolved, property);\n paramLocType.push(property);\n }\n const allOptional = paramLocType.every((node) => !!node.questionToken);\n paramType.push(\n ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),\n /* name */ tsPropertyIndex(paramIn),\n /* questionToken */ allOptional || !paramLocType.length ? QUESTION_TOKEN : undefined,\n /* type */ paramLocType.length ? ts.factory.createTypeLiteralNode(paramLocType) : NEVER,\n ),\n );\n }\n type.push(\n ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),\n /* name */ tsPropertyIndex(\"parameters\"),\n /* questionToken */ !paramType.length ? QUESTION_TOKEN : undefined,\n /* type */ paramType.length ? ts.factory.createTypeLiteralNode(paramType) : NEVER,\n ),\n );\n\n return type;\n}\n"],"names":[],"mappings":";;;;;AAOA,MAAM,aAAA,GAAgB,cAAA;AAKtB,SAAS,oBAAoB,SAAA,EAAoC;AAC/D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,SAAA;AAAA,IACN,EAAA,EAAI,MAAA;AAAA,IACJ,QAAA,EAAU,IAAA;AAAA,IACV,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA;AAAS,GAC3B;AACF;AAKA,SAAS,yBAAyB,IAAA,EAAiC;AACjE,EAAA,MAAM,SAA4B,EAAC;AACnC,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,aAAa,CAAA;AACxC,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC3B,MAAA,MAAM,SAAA,GAAY,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AACnC,MAAA,MAAA,CAAO,IAAA,CAAK,mBAAA,CAAoB,SAAS,CAAC,C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');
4
+ const ts$1 = require('../lib/ts.cjs');
5
+ const utils = require('../lib/utils.cjs');
6
+ const operationObject = require('./operation-object.cjs');
7
+ const parametersArray = require('./parameters-array.cjs');
8
+
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
+
11
+ const ts__default = /*#__PURE__*/_interopDefaultCompat(ts);
12
+
13
+ function transformPathItemObject(pathItem, options) {
14
+ const type = [];
15
+ type.push(
16
+ ...parametersArray.transformParametersArray(pathItem.parameters ?? [], {
17
+ ...options,
18
+ path: utils.createRef([options.path, "parameters"])
19
+ })
20
+ );
21
+ for (const method of ["get", "put", "post", "delete", "options", "head", "patch", "trace"]) {
22
+ const operationObject$1 = pathItem[method];
23
+ if (!operationObject$1 || options.ctx.excludeDeprecated && ("$ref" in operationObject$1 ? options.ctx.resolve(operationObject$1.$ref) : operationObject$1)?.deprecated) {
24
+ type.push(
25
+ ts__default.factory.createPropertySignature(
26
+ /* modifiers */
27
+ ts$1.tsModifiers({ readonly: options.ctx.immutable }),
28
+ /* name */
29
+ ts$1.tsPropertyIndex(method),
30
+ /* questionToken */
31
+ ts$1.QUESTION_TOKEN,
32
+ /* type */
33
+ ts$1.NEVER
34
+ )
35
+ );
36
+ continue;
37
+ }
38
+ const keyedParameters = {};
39
+ if (!("$ref" in operationObject$1)) {
40
+ for (const parameter of [...pathItem.parameters ?? [], ...operationObject$1.parameters ?? []]) {
41
+ const name = "$ref" in parameter ? `${options.ctx.resolve(parameter.$ref)?.in}-${options.ctx.resolve(parameter.$ref)?.name}` : `${parameter.in}-${parameter.name}`;
42
+ if (name) {
43
+ keyedParameters[name] = parameter;
44
+ }
45
+ }
46
+ }
47
+ let operationType;
48
+ if ("$ref" in operationObject$1) {
49
+ operationType = ts$1.oapiRef(operationObject$1.$ref);
50
+ } else if (operationObject$1.operationId) {
51
+ const operationId = operationObject$1.operationId.replace(HASH_RE, "/");
52
+ operationType = ts$1.oapiRef(utils.createRef(["operations", operationId]));
53
+ operationObject.injectOperationObject(
54
+ operationId,
55
+ { ...operationObject$1, parameters: Object.values(keyedParameters) },
56
+ { ...options, path: utils.createRef([options.path, method]) }
57
+ );
58
+ } else {
59
+ operationType = ts__default.factory.createTypeLiteralNode(
60
+ operationObject.default(
61
+ { ...operationObject$1, parameters: Object.values(keyedParameters) },
62
+ { ...options, path: utils.createRef([options.path, method]) }
63
+ )
64
+ );
65
+ }
66
+ const property = ts__default.factory.createPropertySignature(
67
+ /* modifiers */
68
+ ts$1.tsModifiers({ readonly: options.ctx.immutable }),
69
+ /* name */
70
+ ts$1.tsPropertyIndex(method),
71
+ /* questionToken */
72
+ void 0,
73
+ /* type */
74
+ operationType
75
+ );
76
+ ts$1.addJSDocComment(operationObject$1, property);
77
+ type.push(property);
78
+ }
79
+ return ts__default.factory.createTypeLiteralNode(type);
80
+ }
81
+ const HASH_RE = /#/g;
82
+
83
+ module.exports = transformPathItemObject;
84
+ //# sourceMappingURL=path-item-object.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-item-object.cjs","sources":["../../src/transform/path-item-object.ts"],"sourcesContent":["import ts from \"typescript\";\nimport { addJSDocComment, NEVER, oapiRef, QUESTION_TOKEN, tsModifiers, tsPropertyIndex } from \"../lib/ts.js\";\nimport { createRef } from \"../lib/utils.js\";\nimport type {\n OperationObject,\n ParameterObject,\n PathItemObject,\n ReferenceObject,\n TransformNodeOptions,\n} from \"../types.js\";\nimport transformOperationObject, { injectOperationObject } from \"./operation-object.js\";\nimport { transformParametersArray } from \"./parameters-array.js\";\n\nexport type Method = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\";\n\n/**\n * Transform PathItem nodes (4.8.9)\n * @see https://spec.openapis.org/oas/v3.1.0#path-item-object\n */\nexport default function transformPathItemObject(pathItem: PathItemObject, options: TransformNodeOptions): ts.TypeNode {\n const type: ts.TypeElement[] = [];\n\n // parameters\n type.push(\n ...transformParametersArray(pathItem.parameters ?? [], {\n ...options,\n path: createRef([options.path, \"parameters\"]),\n }),\n );\n\n // methods\n for (const method of [\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"] as Method[]) {\n const operationObject = pathItem[method];\n if (\n !operationObject ||\n (options.ctx.excludeDeprecated &&\n (\"$ref\" in operationObject ? options.ctx.resolve<OperationObject>(operationObject.$ref) : operationObject)\n ?.deprecated)\n ) {\n type.push(\n ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),\n /* name */ tsPropertyIndex(method),\n /* questionToken */ QUESTION_TOKEN,\n /* type */ NEVER,\n ),\n );\n continue;\n }\n\n // fold top-level PathItem parameters into method-level, with the latter overriding the former\n const keyedParameters: Record<string, ParameterObject | ReferenceObject> = {};\n if (!(\"$ref\" in operationObject)) {\n // important: OperationObject parameters come last, and will override any conflicts with PathItem parameters\n for (const parameter of [...(pathItem.parameters ?? []), ...(operationObject.parameters ?? [])]) {\n // fix: #1798, use unique key\n const name =\n \"$ref\" in parameter\n ? `${options.ctx.resolve<ParameterObject>(parameter.$ref)?.in}-${options.ctx.resolve<ParameterObject>(parameter.$ref)?.name}`\n : `${parameter.in}-${parameter.name}`;\n if (name) {\n keyedParameters[name] = parameter;\n }\n }\n }\n\n let operationType: ts.TypeNode;\n if (\"$ref\" in operationObject) {\n operationType = oapiRef(operationObject.$ref);\n }\n // if operationId exists, move into an `operations` export and pass the reference in here\n else if (operationObject.operationId) {\n // workaround for issue caused by redocly ref parsing: https://github.com/openapi-ts/openapi-typescript/issues/1542\n const operationId = operationObject.operationId.replace(HASH_RE, \"/\");\n operationType = oapiRef(createRef([\"operations\", operationId]));\n injectOperationObject(\n operationId,\n { ...operationObject, parameters: Object.values(keyedParameters) },\n { ...options, path: createRef([options.path, method]) },\n );\n } else {\n operationType = ts.factory.createTypeLiteralNode(\n transformOperationObject(\n { ...operationObject, parameters: Object.values(keyedParameters) },\n { ...options, path: createRef([options.path, method]) },\n ),\n );\n }\n const property = ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),\n /* name */ tsPropertyIndex(method),\n /* questionToken */ undefined,\n /* type */ operationType,\n );\n addJSDocComment(operationObject, property);\n type.push(property);\n }\n\n return ts.factory.createTypeLiteralNode(type);\n}\n\nconst HASH_RE = /#/g;\n"],"names":["transformParametersArray","createRef","operationObject","ts","tsModifiers","tsPropertyIndex","QUESTION_TOKEN","NEVER","oapiRef","injectOperationObject","transformOperationObject","addJSDocComment"],"mappings":";;;;;;;;;;;;AAmBA,SAAwB,uBAAA,CAAwB,UAA0B,OAAA,EAA4C;AACpH,EAAA,MAAM,OAAyB,EAAC;AAGhC,EAAA,IAAA,CAAK,IAAA;AAAA,IACH,GAAGA,wCAAA,CAAyB,QAAA,CAAS,UAAA,IAAc,EAAC,EAAG;AAAA,MACrD,GAAG,OAAA;AAAA,MACH,MAAMC,eAAA,CAAU,CAAC,OAAA,CAAQ,IAAA,EAAM,YAAY,CAAC;AAAA,KAC7C;AAAA,GACH;AAGA,EAAA,KAAA,MAAW,MAAA,IAAU,CAAC,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,UAAU,SAAA,EAAW,MAAA,EAAQ,OAAA,EAAS,OAAO,CAAA,EAAe;AACtG,IAAA,MAAMC,iBAAA,GAAkB,SAAS,MAAM,CAAA;AACvC,IAAA,IACE,CAACA,iBAAA,IACA,OAAA,CAAQ,GAAA,CAAI,sBACV,MAAA,IAAUA,iBAAA,GAAkB,OAAA,CAAQ,GAAA,CAAI,OAAA,CAAyBA,iBAAA,CAAgB,IAAI,CAAA,GAAIA,oBACtF,UAAA,EACN;AACA,MAAA,IAAA,CAAK,IAAA;AAAA,QACHC,YAAG,OAAA,CAAQ,uBAAA;AAAA;AAAA,UACWC,iBAAY,EAAE,QAAA,EAAU,OAAA,CAAQ,GAAA,CAAI,WAAW,CAAA;AAAA;AAAA,UAC/CC,qBAAgB,MAAM,CAAA;AAAA;AAAA,UACtBC,mBAAA;AAAA;AAA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AAA,CAAU,CAAC,OAAA,CAAQ,IAAA,EAAM,MAAM,CAAC,CAAA;AAAE,OACxD;AAAA,IACF,CAAA,MAAO;AACL,MAAA,aAAA,GAAgBE,YAAG,OAAA,CAAQ,qBAAA;AAAA,QACzBO,uBAAA;AAAA,UACE,EAAE,GAAGR,iBAAA,EAAiB,YAAY,MAAA,CAAO,MAAA,CAAO,eAAe,CAAA,EAAE;AAAA,UACjE,EAAE,GAAG,OAAA,EAAS,IAAA,EAAMD,eAAA,CAAU,CAAC,OAAA,CAAQ,IAAA,EAAM,MAAM,CAAC,CAAA;AAAE;AACxD,OACF;AAAA,IACF;AACA,IAAA,MAAM,QAAA,GAAWE,YAAG,OAAA,CAAQ,uBAAA;AAAA;AAAA,MACNC,iBAAY,EAAE,QAAA,EAAU,OAAA,CAAQ,GAAA,CAAI,WAAW,CAAA;AAAA;AAAA,MAC/CC,qBAAgB,MAAM,CAAA;AAAA;AAAA,MACtB,MAAA;AAAA;AAAA,MACA;AAAA,KACtB;AACA,IAAAM,oBAAA,CAAgBT,mBAAiB,QAAQ,CAAA;AACzC,IAAA,IAAA,CAAK,KAAK,QAAQ,CAAA;AAAA,EACpB;AAEA,EAAA,OAAOC,WAAA,CAAG,OAAA,CAAQ,qBAAA,CAAsB,IAAI,CAAA;AAC9C;AAEA,MAAM,OAAA,GAAU,IAAA;;;;"}
@@ -0,0 +1,78 @@
1
+ import ts from 'typescript';
2
+ import { tsModifiers, tsPropertyIndex, QUESTION_TOKEN, NEVER, oapiRef, addJSDocComment } from '../lib/ts.mjs';
3
+ import { createRef } from '../lib/utils.mjs';
4
+ import transformOperationObject, { injectOperationObject } from './operation-object.mjs';
5
+ import { transformParametersArray } from './parameters-array.mjs';
6
+
7
+ function transformPathItemObject(pathItem, options) {
8
+ const type = [];
9
+ type.push(
10
+ ...transformParametersArray(pathItem.parameters ?? [], {
11
+ ...options,
12
+ path: createRef([options.path, "parameters"])
13
+ })
14
+ );
15
+ for (const method of ["get", "put", "post", "delete", "options", "head", "patch", "trace"]) {
16
+ const operationObject = pathItem[method];
17
+ if (!operationObject || options.ctx.excludeDeprecated && ("$ref" in operationObject ? options.ctx.resolve(operationObject.$ref) : operationObject)?.deprecated) {
18
+ type.push(
19
+ ts.factory.createPropertySignature(
20
+ /* modifiers */
21
+ tsModifiers({ readonly: options.ctx.immutable }),
22
+ /* name */
23
+ tsPropertyIndex(method),
24
+ /* questionToken */
25
+ QUESTION_TOKEN,
26
+ /* type */
27
+ NEVER
28
+ )
29
+ );
30
+ continue;
31
+ }
32
+ const keyedParameters = {};
33
+ if (!("$ref" in operationObject)) {
34
+ for (const parameter of [...pathItem.parameters ?? [], ...operationObject.parameters ?? []]) {
35
+ const name = "$ref" in parameter ? `${options.ctx.resolve(parameter.$ref)?.in}-${options.ctx.resolve(parameter.$ref)?.name}` : `${parameter.in}-${parameter.name}`;
36
+ if (name) {
37
+ keyedParameters[name] = parameter;
38
+ }
39
+ }
40
+ }
41
+ let operationType;
42
+ if ("$ref" in operationObject) {
43
+ operationType = oapiRef(operationObject.$ref);
44
+ } else if (operationObject.operationId) {
45
+ const operationId = operationObject.operationId.replace(HASH_RE, "/");
46
+ operationType = oapiRef(createRef(["operations", operationId]));
47
+ injectOperationObject(
48
+ operationId,
49
+ { ...operationObject, parameters: Object.values(keyedParameters) },
50
+ { ...options, path: createRef([options.path, method]) }
51
+ );
52
+ } else {
53
+ operationType = ts.factory.createTypeLiteralNode(
54
+ transformOperationObject(
55
+ { ...operationObject, parameters: Object.values(keyedParameters) },
56
+ { ...options, path: createRef([options.path, method]) }
57
+ )
58
+ );
59
+ }
60
+ const property = ts.factory.createPropertySignature(
61
+ /* modifiers */
62
+ tsModifiers({ readonly: options.ctx.immutable }),
63
+ /* name */
64
+ tsPropertyIndex(method),
65
+ /* questionToken */
66
+ void 0,
67
+ /* type */
68
+ operationType
69
+ );
70
+ addJSDocComment(operationObject, property);
71
+ type.push(property);
72
+ }
73
+ return ts.factory.createTypeLiteralNode(type);
74
+ }
75
+ const HASH_RE = /#/g;
76
+
77
+ export { transformPathItemObject as default };
78
+ //# sourceMappingURL=path-item-object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-item-object.mjs","sources":["../../src/transform/path-item-object.ts"],"sourcesContent":["import ts from \"typescript\";\nimport { addJSDocComment, NEVER, oapiRef, QUESTION_TOKEN, tsModifiers, tsPropertyIndex } from \"../lib/ts.js\";\nimport { createRef } from \"../lib/utils.js\";\nimport type {\n OperationObject,\n ParameterObject,\n PathItemObject,\n ReferenceObject,\n TransformNodeOptions,\n} from \"../types.js\";\nimport transformOperationObject, { injectOperationObject } from \"./operation-object.js\";\nimport { transformParametersArray } from \"./parameters-array.js\";\n\nexport type Method = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\";\n\n/**\n * Transform PathItem nodes (4.8.9)\n * @see https://spec.openapis.org/oas/v3.1.0#path-item-object\n */\nexport default function transformPathItemObject(pathItem: PathItemObject, options: TransformNodeOptions): ts.TypeNode {\n const type: ts.TypeElement[] = [];\n\n // parameters\n type.push(\n ...transformParametersArray(pathItem.parameters ?? [], {\n ...options,\n path: createRef([options.path, \"parameters\"]),\n }),\n );\n\n // methods\n for (const method of [\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"] as Method[]) {\n const operationObject = pathItem[method];\n if (\n !operationObject ||\n (options.ctx.excludeDeprecated &&\n (\"$ref\" in operationObject ? options.ctx.resolve<OperationObject>(operationObject.$ref) : operationObject)\n ?.deprecated)\n ) {\n type.push(\n ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),\n /* name */ tsPropertyIndex(method),\n /* questionToken */ QUESTION_TOKEN,\n /* type */ NEVER,\n ),\n );\n continue;\n }\n\n // fold top-level PathItem parameters into method-level, with the latter overriding the former\n const keyedParameters: Record<string, ParameterObject | ReferenceObject> = {};\n if (!(\"$ref\" in operationObject)) {\n // important: OperationObject parameters come last, and will override any conflicts with PathItem parameters\n for (const parameter of [...(pathItem.parameters ?? []), ...(operationObject.parameters ?? [])]) {\n // fix: #1798, use unique key\n const name =\n \"$ref\" in parameter\n ? `${options.ctx.resolve<ParameterObject>(parameter.$ref)?.in}-${options.ctx.resolve<ParameterObject>(parameter.$ref)?.name}`\n : `${parameter.in}-${parameter.name}`;\n if (name) {\n keyedParameters[name] = parameter;\n }\n }\n }\n\n let operationType: ts.TypeNode;\n if (\"$ref\" in operationObject) {\n operationType = oapiRef(operationObject.$ref);\n }\n // if operationId exists, move into an `operations` export and pass the reference in here\n else if (operationObject.operationId) {\n // workaround for issue caused by redocly ref parsing: https://github.com/openapi-ts/openapi-typescript/issues/1542\n const operationId = operationObject.operationId.replace(HASH_RE, \"/\");\n operationType = oapiRef(createRef([\"operations\", operationId]));\n injectOperationObject(\n operationId,\n { ...operationObject, parameters: Object.values(keyedParameters) },\n { ...options, path: createRef([options.path, method]) },\n );\n } else {\n operationType = ts.factory.createTypeLiteralNode(\n transformOperationObject(\n { ...operationObject, parameters: Object.values(keyedParameters) },\n { ...options, path: createRef([options.path, method]) },\n ),\n );\n }\n const property = ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: options.ctx.immutable }),\n /* name */ tsPropertyIndex(method),\n /* questionToken */ undefined,\n /* type */ operationType,\n );\n addJSDocComment(operationObject, property);\n type.push(property);\n }\n\n return ts.factory.createTypeLiteralNode(type);\n}\n\nconst HASH_RE = /#/g;\n"],"names":[],"mappings":";;;;;;AAmBA,SAAwB,uBAAA,CAAwB,UAA0B,OAAA,EAA4C;AACpH,EAAA,MAAM,OAAyB,EAAC;AAGhC,EAAA,IAAA,CAAK,IAAA;AAAA,IACH,GAAG,wBAAA,CAAyB,QAAA,CAAS,UAAA,IAAc,EAAC,EAAG;AAAA,MACrD,GAAG,OAAA;AAAA,MACH,MAAM,SAAA,CAAU,CAAC,OAAA,CAAQ,IAAA,EAAM,YAAY,CAAC;AAAA,KAC7C;AAAA,GACH;AAG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IAAA,CAAK,KAAK,QAAQ,CAAA;AAAA,EACpB;AAEA,EAAA,OAAO,EAAA,CAAG,OAAA,CAAQ,qBAAA,CAAsB,IAAI,CAAA;AAC9C;AAEA,MAAM,OAAA,GAAU,IAAA;;;;"}
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const ts = require('../lib/ts.cjs');
4
+ const utils = require('../lib/utils.cjs');
5
+
6
+ function makeApiPathsEnum(pathsObject) {
7
+ const enumKeys = [];
8
+ const enumMetaData = [];
9
+ for (const [url, pathItemObject] of utils.getEntries(pathsObject)) {
10
+ for (const [method, operation] of Object.entries(pathItemObject)) {
11
+ if (!["get", "put", "post", "delete", "options", "head", "patch", "trace"].includes(method)) {
12
+ continue;
13
+ }
14
+ let pathName;
15
+ if (operation.operationId) {
16
+ pathName = operation.operationId;
17
+ } else {
18
+ pathName = (method + url).split("/").map((part) => {
19
+ const capitalised = part.charAt(0).toUpperCase() + part.slice(1);
20
+ return capitalised.replace(/{.*}|:.*|[^a-zA-Z\d_]+/, "");
21
+ }).join("");
22
+ }
23
+ enumKeys.push(url);
24
+ enumMetaData.push({
25
+ name: pathName
26
+ });
27
+ }
28
+ }
29
+ return ts.tsEnum("ApiPaths", enumKeys, enumMetaData, {
30
+ export: true
31
+ });
32
+ }
33
+
34
+ module.exports = makeApiPathsEnum;
35
+ //# sourceMappingURL=paths-enum.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths-enum.cjs","sources":["../../src/transform/paths-enum.ts"],"sourcesContent":["import type ts from \"typescript\";\nimport { tsEnum } from \"../lib/ts.js\";\nimport { getEntries } from \"../lib/utils.js\";\nimport type { PathsObject } from \"../types.js\";\n\nexport default function makeApiPathsEnum(pathsObject: PathsObject): ts.EnumDeclaration {\n const enumKeys = [];\n const enumMetaData = [];\n\n for (const [url, pathItemObject] of getEntries(pathsObject)) {\n for (const [method, operation] of Object.entries(pathItemObject)) {\n if (![\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"].includes(method)) {\n continue;\n }\n\n // Generate a name from the operation ID\n let pathName: string;\n if (operation.operationId) {\n pathName = operation.operationId;\n } else {\n // If the operation ID is not present, construct a name from the method and path\n pathName = (method + url)\n .split(\"/\")\n .map((part) => {\n const capitalised = part.charAt(0).toUpperCase() + part.slice(1);\n\n // Remove any characters not allowed as enum keys, and attempt to remove\n // named parameters.\n return capitalised.replace(/{.*}|:.*|[^a-zA-Z\\d_]+/, \"\");\n })\n .join(\"\");\n }\n enumKeys.push(url);\n enumMetaData.push({\n name: pathName,\n });\n }\n }\n\n return tsEnum(\"ApiPaths\", enumKeys, enumMetaData, {\n export: true,\n });\n}\n"],"names":["getEntries","tsEnum"],"mappings":";;;;;AAKA,SAAwB,iBAAiB,WAAA,EAA8C;AACrF,EAAA,MAAM,WAAW,EAAC;AAClB,EAAA,MAAM,eAAe,EAAC;AAEtB,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,cAAc,CAAA,IAAKA,gBAAA,CAAW,WAAW,CAAA,EAAG;AAC3D,IAAA,KAAA,MAAW,CAAC,MAAA,EAAQ,SAAS,KAAK,MAAA,CAAO,OAAA,CAAQ,cAAc,CAAA,EAAG;AAChE,MAAA,IAAI,CAAC,CAAC,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,QAAA,EAAU,SAAA,EAAW,MAAA,EAAQ,OAAA,EAAS,OAAO,CAAA,CAAE,QAAA,CAAS,MAAM,CAAA,EAAG;AAC3F,QAAA;AAAA,MACF;AAGA,MAAA,IAAI,QAAA;AACJ,MAAA,IAAI,UAAU,WAAA,EAAa;AACzB,QAAA,QAAA,GAAW,SAAA,CAAU,WAAA;AAAA,MACvB,CAAA,MAAO;AAEL,QAAA,QAAA,GAAA,CAAY,SAAS,GAAA,EAClB,KAAA,CAAM,GAAG,CAAA,CACT,GAAA,CAAI,CAAC,IAAA,KAAS;AACb,UAAA,MAAM,WAAA,GAAc,KAAK,MAAA,CAAO,CAAC,EAAE,WAAA,EAAY,GAAI,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AAI/D,UAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,wBAAA,EAA0B,EAAE,CAAA;AAAA,QACzD,CAAC,CAAA,CACA,IAAA,CAAK,EAAE,CAAA;AAAA,MACZ;AACA,MAAA,QAAA,CAAS,KAAK,GAAG,CAAA;AACjB,MAAA,YAAA,CAAa,IAAA,CAAK;AAAA,QAChB,IAAA,EAAM;AAAA,OACP,CAAA;AAAA,IACH;AAAA,EACF;AAEA,EAAA,OAAOC,SAAA,CAAO,UAAA,EAAY,QAAA,EAAU,YAAA,EAAc;AAAA,IAChD,MAAA,EAAQ;AAAA,GACT,CAAA;AACH;;;;"}
@@ -0,0 +1,33 @@
1
+ import { tsEnum } from '../lib/ts.mjs';
2
+ import { getEntries } from '../lib/utils.mjs';
3
+
4
+ function makeApiPathsEnum(pathsObject) {
5
+ const enumKeys = [];
6
+ const enumMetaData = [];
7
+ for (const [url, pathItemObject] of getEntries(pathsObject)) {
8
+ for (const [method, operation] of Object.entries(pathItemObject)) {
9
+ if (!["get", "put", "post", "delete", "options", "head", "patch", "trace"].includes(method)) {
10
+ continue;
11
+ }
12
+ let pathName;
13
+ if (operation.operationId) {
14
+ pathName = operation.operationId;
15
+ } else {
16
+ pathName = (method + url).split("/").map((part) => {
17
+ const capitalised = part.charAt(0).toUpperCase() + part.slice(1);
18
+ return capitalised.replace(/{.*}|:.*|[^a-zA-Z\d_]+/, "");
19
+ }).join("");
20
+ }
21
+ enumKeys.push(url);
22
+ enumMetaData.push({
23
+ name: pathName
24
+ });
25
+ }
26
+ }
27
+ return tsEnum("ApiPaths", enumKeys, enumMetaData, {
28
+ export: true
29
+ });
30
+ }
31
+
32
+ export { makeApiPathsEnum as default };
33
+ //# sourceMappingURL=paths-enum.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths-enum.mjs","sources":["../../src/transform/paths-enum.ts"],"sourcesContent":["import type ts from \"typescript\";\nimport { tsEnum } from \"../lib/ts.js\";\nimport { getEntries } from \"../lib/utils.js\";\nimport type { PathsObject } from \"../types.js\";\n\nexport default function makeApiPathsEnum(pathsObject: PathsObject): ts.EnumDeclaration {\n const enumKeys = [];\n const enumMetaData = [];\n\n for (const [url, pathItemObject] of getEntries(pathsObject)) {\n for (const [method, operation] of Object.entries(pathItemObject)) {\n if (![\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"].includes(method)) {\n continue;\n }\n\n // Generate a name from the operation ID\n let pathName: string;\n if (operation.operationId) {\n pathName = operation.operationId;\n } else {\n // If the operation ID is not present, construct a name from the method and path\n pathName = (method + url)\n .split(\"/\")\n .map((part) => {\n const capitalised = part.charAt(0).toUpperCase() + part.slice(1);\n\n // Remove any characters not allowed as enum keys, and attempt to remove\n // named parameters.\n return capitalised.replace(/{.*}|:.*|[^a-zA-Z\\d_]+/, \"\");\n })\n .join(\"\");\n }\n enumKeys.push(url);\n enumMetaData.push({\n name: pathName,\n });\n }\n }\n\n return tsEnum(\"ApiPaths\", enumKeys, enumMetaData, {\n export: true,\n });\n}\n"],"names":[],"mappings":";;;AAKA,SAAwB,iBAAiB,WAAA,EAA8C;AACrF,EAAA,MAAM,WAAW,EAAC;AAClB,EAAA,MAAM,eAAe,EAAC;AAEtB,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,cAAc,CAAA,IAAK,UAAA,CAAW,WAAW,CAAA,EAAG;AAC3D,IAAA,KAAA,MAAW,CAAC,MAAA,EAAQ,SAAS,KAAK,MAAA,CAAO,OAAA,CAAQ,cAAc,CAAA,EAAG;AAChE,MAAA,IAAI,CAAC,CAAC,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,QAAA,EAAU,SAAA,EAAW,MAAA,EAAQ,OAAA,EAAS,OAAO,CAAA,CAAE,QAAA,CAAS,MAAM,CAAA,EAAG;AAC3F,QAAA;AAAA,MACF;AAGA,MAAA,IAAI,QAAA;AACJ,MAAA,IAAI,UAAU,WAAA,EAAa;AACzB,QAAA,QAAA,GAAW,SAAA,CAAU,WAAA;AAAA,MACvB,CAAA,MAAO;AAEL,QAAA,QAAA,GAAA,CAAY,SAAS,GAAA,EAClB,KAAA,CAAM,GAAG,CAAA,CACT,GAAA,CAAI,CAAC,IAAA,KAAS;AACb,UAAA,MAAM,WAAA,GAAc,KAAK,MAAA,CAAO,CAAC,EAAE,WAAA,EAAY,GAAI,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AAI/D,UAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,wBAAA,EAA0B,EAAE,CAAA;AAAA,QACzD,CAAC,CAAA,CACA,IAAA,CAAK,EAAE,CAAA;AAAA,MACZ;AACA,MAAA,QAAA,CAAS,KAAK,GAAG,CAAA;AACjB,MAAA,YAAA,CAAa,IAAA,CAAK;AAAA,QAChB,IAAA,EAAM;AAAA,OACP,CAAA;AAAA,IACH;AAAA,EACF;AAEA,EAAA,OAAO,MAAA,CAAO,UAAA,EAAY,QAAA,EAAU,YAAA,EAAc;AAAA,IAChD,MAAA,EAAQ;AAAA,GACT,CAAA;AACH;;;;"}
@@ -0,0 +1,134 @@
1
+ 'use strict';
2
+
3
+ const node_perf_hooks = require('node:perf_hooks');
4
+ const ts = require('typescript');
5
+ const ts$1 = require('../lib/ts.cjs');
6
+ const utils = require('../lib/utils.cjs');
7
+ const pathItemObject = require('./path-item-object.cjs');
8
+
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
+
11
+ const ts__default = /*#__PURE__*/_interopDefaultCompat(ts);
12
+
13
+ const PATH_PARAM_RE = /\{[^}]+\}/g;
14
+ function transformPathsObject(pathsObject, ctx) {
15
+ const type = [];
16
+ for (const [url, pathItemObject$1] of utils.getEntries(pathsObject, ctx)) {
17
+ if (!pathItemObject$1 || typeof pathItemObject$1 !== "object") {
18
+ continue;
19
+ }
20
+ const pathT = node_perf_hooks.performance.now();
21
+ if ("$ref" in pathItemObject$1) {
22
+ const property = ts__default.factory.createPropertySignature(
23
+ /* modifiers */
24
+ ts$1.tsModifiers({ readonly: ctx.immutable }),
25
+ /* name */
26
+ ts$1.tsPropertyIndex(url),
27
+ /* questionToken */
28
+ void 0,
29
+ /* type */
30
+ ts$1.oapiRef(pathItemObject$1.$ref)
31
+ );
32
+ ts$1.addJSDocComment(pathItemObject$1, property);
33
+ type.push(property);
34
+ } else {
35
+ const pathItemType = pathItemObject(pathItemObject$1, {
36
+ path: utils.createRef(["paths", url]),
37
+ ctx
38
+ });
39
+ if (ctx.pathParamsAsTypes && url.includes("{")) {
40
+ const pathParams = extractPathParams(pathItemObject$1, ctx);
41
+ const matches = url.match(PATH_PARAM_RE);
42
+ let rawPath = `\`${url}\``;
43
+ if (matches) {
44
+ for (const match of matches) {
45
+ const paramName = match.slice(1, -1);
46
+ const param = pathParams[paramName];
47
+ switch (param?.schema?.type) {
48
+ case "number":
49
+ case "integer":
50
+ rawPath = rawPath.replace(match, "${number}");
51
+ break;
52
+ case "boolean":
53
+ rawPath = rawPath.replace(match, "${boolean}");
54
+ break;
55
+ default:
56
+ rawPath = rawPath.replace(match, "${string}");
57
+ break;
58
+ }
59
+ }
60
+ const pathType = ts$1.stringToAST(rawPath)[0]?.expression;
61
+ if (pathType) {
62
+ type.push(
63
+ ts__default.factory.createIndexSignature(
64
+ /* modifiers */
65
+ ts$1.tsModifiers({ readonly: ctx.immutable }),
66
+ /* parameters */
67
+ [
68
+ ts__default.factory.createParameterDeclaration(
69
+ /* modifiers */
70
+ void 0,
71
+ /* dotDotDotToken */
72
+ void 0,
73
+ /* name */
74
+ "path",
75
+ /* questionToken */
76
+ void 0,
77
+ /* type */
78
+ pathType,
79
+ /* initializer */
80
+ void 0
81
+ )
82
+ ],
83
+ /* type */
84
+ pathItemType
85
+ )
86
+ );
87
+ continue;
88
+ }
89
+ }
90
+ }
91
+ type.push(
92
+ ts__default.factory.createPropertySignature(
93
+ /* modifiers */
94
+ ts$1.tsModifiers({ readonly: ctx.immutable }),
95
+ /* name */
96
+ ts$1.tsPropertyIndex(url),
97
+ /* questionToken */
98
+ void 0,
99
+ /* type */
100
+ pathItemType
101
+ )
102
+ );
103
+ utils.debug(`Transformed path "${url}"`, "ts", node_perf_hooks.performance.now() - pathT);
104
+ }
105
+ }
106
+ return ts__default.factory.createTypeLiteralNode(type);
107
+ }
108
+ function extractPathParams(pathItemObject, ctx) {
109
+ const params = {};
110
+ for (const p of pathItemObject.parameters ?? []) {
111
+ const resolved = "$ref" in p && p.$ref ? ctx.resolve(p.$ref) : p;
112
+ if (resolved && resolved.in === "path") {
113
+ params[resolved.name] = resolved;
114
+ }
115
+ }
116
+ for (const method of ["get", "put", "post", "delete", "options", "head", "patch", "trace"]) {
117
+ if (!(method in pathItemObject)) {
118
+ continue;
119
+ }
120
+ const resolvedMethod = pathItemObject[method].$ref ? ctx.resolve(pathItemObject[method].$ref) : pathItemObject[method];
121
+ if (resolvedMethod?.parameters) {
122
+ for (const p of resolvedMethod.parameters) {
123
+ const resolvedParam = "$ref" in p && p.$ref ? ctx.resolve(p.$ref) : p;
124
+ if (resolvedParam && resolvedParam.in === "path") {
125
+ params[resolvedParam.name] = resolvedParam;
126
+ }
127
+ }
128
+ }
129
+ }
130
+ return params;
131
+ }
132
+
133
+ module.exports = transformPathsObject;
134
+ //# sourceMappingURL=paths-object.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths-object.cjs","sources":["../../src/transform/paths-object.ts"],"sourcesContent":["import { performance } from \"node:perf_hooks\";\nimport ts from \"typescript\";\nimport { addJSDocComment, oapiRef, stringToAST, tsModifiers, tsPropertyIndex } from \"../lib/ts.js\";\nimport { createRef, debug, getEntries } from \"../lib/utils.js\";\nimport type {\n GlobalContext,\n OperationObject,\n ParameterObject,\n PathItemObject,\n PathsObject,\n ReferenceObject,\n} from \"../types.js\";\nimport transformPathItemObject, { type Method } from \"./path-item-object.js\";\n\nconst PATH_PARAM_RE = /\\{[^}]+\\}/g;\n\n/**\n * Transform the PathsObject node (4.8.8)\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport default function transformPathsObject(pathsObject: PathsObject, ctx: GlobalContext): ts.TypeNode {\n const type: ts.TypeElement[] = [];\n for (const [url, pathItemObject] of getEntries(pathsObject, ctx)) {\n if (!pathItemObject || typeof pathItemObject !== \"object\") {\n continue;\n }\n\n const pathT = performance.now();\n\n // handle $ref\n if (\"$ref\" in pathItemObject) {\n const property = ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: ctx.immutable }),\n /* name */ tsPropertyIndex(url),\n /* questionToken */ undefined,\n /* type */ oapiRef(pathItemObject.$ref),\n );\n addJSDocComment(pathItemObject, property);\n type.push(property);\n } else {\n const pathItemType = transformPathItemObject(pathItemObject, {\n path: createRef([\"paths\", url]),\n ctx,\n });\n\n // pathParamsAsTypes\n if (ctx.pathParamsAsTypes && url.includes(\"{\")) {\n const pathParams = extractPathParams(pathItemObject, ctx);\n const matches = url.match(PATH_PARAM_RE);\n let rawPath = `\\`${url}\\``;\n if (matches) {\n for (const match of matches) {\n const paramName = match.slice(1, -1);\n const param = pathParams[paramName];\n switch (param?.schema?.type) {\n case \"number\":\n case \"integer\":\n rawPath = rawPath.replace(match, \"${number}\");\n break;\n case \"boolean\":\n rawPath = rawPath.replace(match, \"${boolean}\");\n break;\n default:\n rawPath = rawPath.replace(match, \"${string}\");\n break;\n }\n }\n // note: creating a string template literal’s AST manually is hard!\n // just pass an arbitrary string to TS\n const pathType = (stringToAST(rawPath)[0] as any)?.expression;\n if (pathType) {\n type.push(\n ts.factory.createIndexSignature(\n /* modifiers */ tsModifiers({ readonly: ctx.immutable }),\n /* parameters */ [\n ts.factory.createParameterDeclaration(\n /* modifiers */ undefined,\n /* dotDotDotToken */ undefined,\n /* name */ \"path\",\n /* questionToken */ undefined,\n /* type */ pathType,\n /* initializer */ undefined,\n ),\n ],\n /* type */ pathItemType,\n ),\n );\n continue;\n }\n }\n }\n\n type.push(\n ts.factory.createPropertySignature(\n /* modifiers */ tsModifiers({ readonly: ctx.immutable }),\n /* name */ tsPropertyIndex(url),\n /* questionToken */ undefined,\n /* type */ pathItemType,\n ),\n );\n\n debug(`Transformed path \"${url}\"`, \"ts\", performance.now() - pathT);\n }\n }\n\n return ts.factory.createTypeLiteralNode(type);\n}\n\nfunction extractPathParams(pathItemObject: PathItemObject, ctx: GlobalContext) {\n const params: Record<string, ParameterObject> = {};\n for (const p of pathItemObject.parameters ?? []) {\n const resolved = \"$ref\" in p && p.$ref ? ctx.resolve<ParameterObject>(p.$ref) : (p as ParameterObject);\n if (resolved && resolved.in === \"path\") {\n params[resolved.name] = resolved;\n }\n }\n for (const method of [\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"] as Method[]) {\n if (!(method in pathItemObject)) {\n continue;\n }\n const resolvedMethod = (pathItemObject[method] as ReferenceObject).$ref\n ? ctx.resolve<OperationObject>((pathItemObject[method] as ReferenceObject).$ref)\n : (pathItemObject[method] as OperationObject);\n if (resolvedMethod?.parameters) {\n for (const p of resolvedMethod.parameters) {\n const resolvedParam = \"$ref\" in p && p.$ref ? ctx.resolve<ParameterObject>(p.$ref) : (p as ParameterObject);\n if (resolvedParam && resolvedParam.in === \"path\") {\n params[resolvedParam.name] = resolvedParam;\n }\n }\n }\n }\n return params;\n}\n"],"names":["pathItemObject","getEntries","performance","ts","tsModifiers","tsPropertyIndex","oapiRef","addJSDocComment","transformPathItemObject","createRef","stringToAST","debug"],"mappings":";;;;;;;;;;;;AAcA,MAAM,aAAA,GAAgB,YAAA;AAMtB,SAAwB,oBAAA,CAAqB,aAA0B,GAAA,EAAiC;AACtG,EAAA,MAAM,OAAyB,EAAC;AAChC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAKA,gBAAc,KAAKC,gBAAA,CAAW,WAAA,EAAa,GAAG,CAAA,EAAG;AAChE,IAAA,IAAI,CAACD,gBAAA,IAAkB,OAAOA,gBAAA,KAAmB,QAAA,EAAU;AACzD,MAAA;AAAA,I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