@sdk-it/spec 0.21.0 → 0.22.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.
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2629 -2
- package/dist/index.js.map +4 -4
- package/dist/lib/find-polymorphic-varients.d.ts +15 -0
- package/dist/lib/find-polymorphic-varients.d.ts.map +1 -0
- package/dist/lib/find-polymorphic-varients.test.d.ts +2 -0
- package/dist/lib/find-polymorphic-varients.test.d.ts.map +1 -0
- package/dist/lib/find-unique-schema-name.d.ts +3 -0
- package/dist/lib/find-unique-schema-name.d.ts.map +1 -0
- package/dist/lib/format-name.d.ts +2 -0
- package/dist/lib/format-name.d.ts.map +1 -0
- package/dist/lib/get-ref-usage.d.ts +3 -0
- package/dist/lib/get-ref-usage.d.ts.map +1 -0
- package/dist/lib/is-primitive-schema.d.ts +3 -0
- package/dist/lib/is-primitive-schema.d.ts.map +1 -0
- package/dist/lib/loaders/load-spec.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.d.ts.map +1 -1
- package/dist/lib/metadata.d.ts +22 -0
- package/dist/lib/metadata.d.ts.map +1 -0
- package/dist/lib/operation.d.ts +62 -18
- package/dist/lib/operation.d.ts.map +1 -1
- package/dist/lib/pagination/pagination-result.d.ts.map +1 -1
- package/dist/lib/pagination/pagination.d.ts +1 -1
- package/dist/lib/pagination/pagination.d.ts.map +1 -1
- package/dist/lib/security.d.ts +10 -0
- package/dist/lib/security.d.ts.map +1 -0
- package/dist/lib/sidebar.d.ts +2 -2
- package/dist/lib/sidebar.d.ts.map +1 -1
- package/dist/lib/tune.d.ts +11 -0
- package/dist/lib/tune.d.ts.map +1 -0
- package/dist/lib/tune.test.d.ts +2 -0
- package/dist/lib/tune.test.d.ts.map +1 -0
- package/package.json +8 -4
- package/dist/lib/loaders/load-spec.js +0 -27
- package/dist/lib/loaders/load-spec.js.map +0 -7
- package/dist/lib/loaders/local-loader.js +0 -20
- package/dist/lib/loaders/local-loader.js.map +0 -7
- package/dist/lib/loaders/postman/postman-converter.js +0 -486
- package/dist/lib/loaders/postman/postman-converter.js.map +0 -7
- package/dist/lib/loaders/postman/spec-types.js +0 -1
- package/dist/lib/loaders/postman/spec-types.js.map +0 -7
- package/dist/lib/loaders/remote-loader.js +0 -29
- package/dist/lib/loaders/remote-loader.js.map +0 -7
- package/dist/lib/operation.js +0 -425
- package/dist/lib/operation.js.map +0 -7
- package/dist/lib/operation.test.js +0 -261
- package/dist/lib/operation.test.js.map +0 -7
- package/dist/lib/pagination/pagination-result.js +0 -237
- package/dist/lib/pagination/pagination-result.js.map +0 -7
- package/dist/lib/pagination/pagination-result.test.js +0 -548
- package/dist/lib/pagination/pagination-result.test.js.map +0 -7
- package/dist/lib/pagination/pagination.js +0 -199
- package/dist/lib/pagination/pagination.js.map +0 -7
- package/dist/lib/pagination/pagination.test.js +0 -380
- package/dist/lib/pagination/pagination.test.js.map +0 -7
- package/dist/lib/sidebar.js +0 -81
- package/dist/lib/sidebar.js.map +0 -7
package/dist/lib/operation.js
DELETED
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
import { camelcase } from "stringcase";
|
|
2
|
-
import { followRef, isRef } from "@sdk-it/core/ref.js";
|
|
3
|
-
import {
|
|
4
|
-
guessPagination
|
|
5
|
-
} from "./pagination/pagination.js";
|
|
6
|
-
function augmentSpec(config) {
|
|
7
|
-
config.spec.paths ??= {};
|
|
8
|
-
const paths = {};
|
|
9
|
-
for (const [path, pathItem] of Object.entries(config.spec.paths)) {
|
|
10
|
-
const { parameters = [], ...methods } = pathItem;
|
|
11
|
-
const fixedPath = path.replace(/:([^/]+)/g, "{$1}");
|
|
12
|
-
for (const [method, operation] of Object.entries(methods)) {
|
|
13
|
-
const formatOperationId = config.operationId ?? defaults.operationId;
|
|
14
|
-
const formatTag = config.tag ?? defaults.tag;
|
|
15
|
-
const operationId = formatOperationId(operation, fixedPath, method);
|
|
16
|
-
const operationTag = formatTag(operation, fixedPath);
|
|
17
|
-
const requestBody = isRef(operation.requestBody) ? followRef(config.spec, operation.requestBody.$ref) : operation.requestBody;
|
|
18
|
-
const tunedOperation = {
|
|
19
|
-
...operation,
|
|
20
|
-
parameters: [...parameters, ...operation.parameters ?? []].map(
|
|
21
|
-
(it) => isRef(it) ? followRef(config.spec, it.$ref) : it
|
|
22
|
-
),
|
|
23
|
-
tags: [operationTag],
|
|
24
|
-
operationId,
|
|
25
|
-
responses: resolveResponses(config.spec, operation),
|
|
26
|
-
requestBody
|
|
27
|
-
};
|
|
28
|
-
tunedOperation["x-pagination"] = toPagination(
|
|
29
|
-
config.spec,
|
|
30
|
-
tunedOperation
|
|
31
|
-
);
|
|
32
|
-
Object.assign(paths, {
|
|
33
|
-
[fixedPath]: {
|
|
34
|
-
...paths[fixedPath],
|
|
35
|
-
[method]: tunedOperation
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return { ...config.spec, paths };
|
|
41
|
-
}
|
|
42
|
-
function toPagination(spec, tunedOperation) {
|
|
43
|
-
if (tunedOperation["x-pagination"]) {
|
|
44
|
-
return tunedOperation["x-pagination"];
|
|
45
|
-
}
|
|
46
|
-
const schema = getResponseContentSchema(
|
|
47
|
-
spec,
|
|
48
|
-
tunedOperation.responses["200"],
|
|
49
|
-
"application/json"
|
|
50
|
-
);
|
|
51
|
-
const pagination = guessPagination(
|
|
52
|
-
tunedOperation,
|
|
53
|
-
tunedOperation.requestBody ? getRequestContentSchema(
|
|
54
|
-
spec,
|
|
55
|
-
tunedOperation.requestBody,
|
|
56
|
-
"application/json"
|
|
57
|
-
) : void 0,
|
|
58
|
-
schema
|
|
59
|
-
);
|
|
60
|
-
if (pagination && pagination.type !== "none" && schema) {
|
|
61
|
-
return pagination;
|
|
62
|
-
}
|
|
63
|
-
return void 0;
|
|
64
|
-
}
|
|
65
|
-
function getResponseContentSchema(spec, response, type) {
|
|
66
|
-
if (!response) {
|
|
67
|
-
return void 0;
|
|
68
|
-
}
|
|
69
|
-
const content = response.content;
|
|
70
|
-
if (!content) {
|
|
71
|
-
return void 0;
|
|
72
|
-
}
|
|
73
|
-
for (const contentType in content) {
|
|
74
|
-
if (contentType.toLowerCase() === type.toLowerCase()) {
|
|
75
|
-
return isRef(content[contentType].schema) ? followRef(spec, content[contentType].schema.$ref) : content[contentType].schema;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return void 0;
|
|
79
|
-
}
|
|
80
|
-
function getRequestContentSchema(spec, requestBody, type) {
|
|
81
|
-
const content = requestBody.content;
|
|
82
|
-
if (!content) {
|
|
83
|
-
return void 0;
|
|
84
|
-
}
|
|
85
|
-
for (const contentType in content) {
|
|
86
|
-
if (contentType.toLowerCase() === type.toLowerCase()) {
|
|
87
|
-
return isRef(content[contentType].schema) ? followRef(spec, content[contentType].schema.$ref) : content[contentType].schema;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return void 0;
|
|
91
|
-
}
|
|
92
|
-
const defaults = {
|
|
93
|
-
operationId: (operation, path, method) => {
|
|
94
|
-
if (operation.operationId) {
|
|
95
|
-
return camelcase(operation.operationId);
|
|
96
|
-
}
|
|
97
|
-
const metadata = operation["x-oaiMeta"];
|
|
98
|
-
if (metadata && metadata.name) {
|
|
99
|
-
return camelcase(metadata.name);
|
|
100
|
-
}
|
|
101
|
-
return camelcase(
|
|
102
|
-
[method, ...path.replace(/[\\/\\{\\}]/g, " ").split(" ")].filter(Boolean).join(" ").trim()
|
|
103
|
-
);
|
|
104
|
-
},
|
|
105
|
-
tag: (operation, path) => {
|
|
106
|
-
return operation.tags?.[0] ? sanitizeTag(operation.tags?.[0]) : determineGenericTag(path, operation);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
function resolveResponses(spec, operation) {
|
|
110
|
-
const responses = operation.responses ?? {};
|
|
111
|
-
const resolved = {};
|
|
112
|
-
for (const status in responses) {
|
|
113
|
-
const response = isRef(responses[status]) ? followRef(spec, responses[status].$ref) : responses[status];
|
|
114
|
-
resolved[status] = response;
|
|
115
|
-
}
|
|
116
|
-
return resolved;
|
|
117
|
-
}
|
|
118
|
-
function forEachOperation(config, callback) {
|
|
119
|
-
const result = [];
|
|
120
|
-
for (const [path, pathItem] of Object.entries(config.spec.paths ?? {})) {
|
|
121
|
-
const { parameters = [], ...methods } = pathItem;
|
|
122
|
-
for (const [method, operation] of Object.entries(methods)) {
|
|
123
|
-
const metadata = operation["x-oaiMeta"] ?? {};
|
|
124
|
-
const operationTag = operation.tags?.[0];
|
|
125
|
-
result.push(
|
|
126
|
-
callback(
|
|
127
|
-
{
|
|
128
|
-
name: metadata.name,
|
|
129
|
-
method,
|
|
130
|
-
path,
|
|
131
|
-
groupName: operationTag,
|
|
132
|
-
tag: operationTag
|
|
133
|
-
},
|
|
134
|
-
operation
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
const reservedKeywords = /* @__PURE__ */ new Set([
|
|
142
|
-
"await",
|
|
143
|
-
// Reserved in async functions
|
|
144
|
-
"break",
|
|
145
|
-
"case",
|
|
146
|
-
"catch",
|
|
147
|
-
"class",
|
|
148
|
-
"const",
|
|
149
|
-
"continue",
|
|
150
|
-
"debugger",
|
|
151
|
-
"default",
|
|
152
|
-
"delete",
|
|
153
|
-
"do",
|
|
154
|
-
"else",
|
|
155
|
-
"enum",
|
|
156
|
-
"export",
|
|
157
|
-
"extends",
|
|
158
|
-
"false",
|
|
159
|
-
"finally",
|
|
160
|
-
"for",
|
|
161
|
-
"function",
|
|
162
|
-
"if",
|
|
163
|
-
"implements",
|
|
164
|
-
// Strict mode
|
|
165
|
-
"import",
|
|
166
|
-
"in",
|
|
167
|
-
"instanceof",
|
|
168
|
-
"interface",
|
|
169
|
-
// Strict mode
|
|
170
|
-
"let",
|
|
171
|
-
// Strict mode
|
|
172
|
-
"new",
|
|
173
|
-
"null",
|
|
174
|
-
"package",
|
|
175
|
-
// Strict mode
|
|
176
|
-
"private",
|
|
177
|
-
// Strict mode
|
|
178
|
-
"protected",
|
|
179
|
-
// Strict mode
|
|
180
|
-
"public",
|
|
181
|
-
// Strict mode
|
|
182
|
-
"return",
|
|
183
|
-
"static",
|
|
184
|
-
// Strict mode
|
|
185
|
-
"super",
|
|
186
|
-
"switch",
|
|
187
|
-
"this",
|
|
188
|
-
"throw",
|
|
189
|
-
"true",
|
|
190
|
-
"try",
|
|
191
|
-
"typeof",
|
|
192
|
-
"var",
|
|
193
|
-
"void",
|
|
194
|
-
"while",
|
|
195
|
-
"with",
|
|
196
|
-
"yield",
|
|
197
|
-
// Strict mode / Generator functions
|
|
198
|
-
// 'arguments' is not technically a reserved word, but it's a special identifier within functions
|
|
199
|
-
// and assigning to it or declaring it can cause issues or unexpected behavior.
|
|
200
|
-
"arguments"
|
|
201
|
-
]);
|
|
202
|
-
function sanitizeTag(camelCasedTag) {
|
|
203
|
-
if (/^\d/.test(camelCasedTag)) {
|
|
204
|
-
return `_${camelCasedTag}`;
|
|
205
|
-
}
|
|
206
|
-
return reservedKeywords.has(camelcase(camelCasedTag)) ? `${camelCasedTag}_` : camelCasedTag;
|
|
207
|
-
}
|
|
208
|
-
function determineGenericTag(pathString, operation) {
|
|
209
|
-
const operationId = operation.operationId || "";
|
|
210
|
-
const VERSION_REGEX = /^[vV]\d+$/;
|
|
211
|
-
const commonVerbs = /* @__PURE__ */ new Set([
|
|
212
|
-
// Verbs to potentially strip from operationId prefix
|
|
213
|
-
"get",
|
|
214
|
-
"list",
|
|
215
|
-
"create",
|
|
216
|
-
"update",
|
|
217
|
-
"delete",
|
|
218
|
-
"post",
|
|
219
|
-
"put",
|
|
220
|
-
"patch",
|
|
221
|
-
"do",
|
|
222
|
-
"send",
|
|
223
|
-
"add",
|
|
224
|
-
"remove",
|
|
225
|
-
"set",
|
|
226
|
-
"find",
|
|
227
|
-
"search",
|
|
228
|
-
"check",
|
|
229
|
-
"make"
|
|
230
|
-
]);
|
|
231
|
-
const segments = pathString.split("/").filter(Boolean);
|
|
232
|
-
const potentialCandidates = segments.filter(
|
|
233
|
-
(segment) => segment && !segment.startsWith("{") && !segment.endsWith("}") && !VERSION_REGEX.test(segment)
|
|
234
|
-
);
|
|
235
|
-
for (let i = potentialCandidates.length - 1; i >= 0; i--) {
|
|
236
|
-
const segment = potentialCandidates[i];
|
|
237
|
-
if (!segment.startsWith("@")) {
|
|
238
|
-
return sanitizeTag(camelcase(segment));
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
const canFallbackToPathSegment = potentialCandidates.length > 0;
|
|
242
|
-
if (operationId) {
|
|
243
|
-
const lowerOpId = operationId.toLowerCase();
|
|
244
|
-
const parts = operationId.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").replace(/([a-zA-Z])(\d)/g, "$1_$2").replace(/(\d)([a-zA-Z])/g, "$1_$2").toLowerCase().split(/[_-\s]+/);
|
|
245
|
-
const validParts = parts.filter(Boolean);
|
|
246
|
-
if (commonVerbs.has(lowerOpId) && validParts.length === 1 && canFallbackToPathSegment) {
|
|
247
|
-
} else if (validParts.length > 0) {
|
|
248
|
-
const firstPart = validParts[0];
|
|
249
|
-
const isFirstPartVerb = commonVerbs.has(firstPart);
|
|
250
|
-
if (isFirstPartVerb && validParts.length > 1) {
|
|
251
|
-
const verbPrefixLength = firstPart.length;
|
|
252
|
-
let nextPartStartIndex = -1;
|
|
253
|
-
if (operationId.length > verbPrefixLength) {
|
|
254
|
-
const charAfterPrefix = operationId[verbPrefixLength];
|
|
255
|
-
if (charAfterPrefix >= "A" && charAfterPrefix <= "Z") {
|
|
256
|
-
nextPartStartIndex = verbPrefixLength;
|
|
257
|
-
} else if (charAfterPrefix >= "0" && charAfterPrefix <= "9") {
|
|
258
|
-
nextPartStartIndex = verbPrefixLength;
|
|
259
|
-
} else if (["_", "-"].includes(charAfterPrefix)) {
|
|
260
|
-
nextPartStartIndex = verbPrefixLength + 1;
|
|
261
|
-
} else {
|
|
262
|
-
const match = operationId.substring(verbPrefixLength).match(/[A-Z0-9]/);
|
|
263
|
-
if (match && match.index !== void 0) {
|
|
264
|
-
nextPartStartIndex = verbPrefixLength + match.index;
|
|
265
|
-
}
|
|
266
|
-
if (nextPartStartIndex === -1 && operationId.length > verbPrefixLength) {
|
|
267
|
-
nextPartStartIndex = verbPrefixLength;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (nextPartStartIndex !== -1 && nextPartStartIndex < operationId.length) {
|
|
272
|
-
const remainingOriginalSubstring = operationId.substring(nextPartStartIndex);
|
|
273
|
-
const potentialTag = camelcase(remainingOriginalSubstring);
|
|
274
|
-
if (potentialTag) {
|
|
275
|
-
return sanitizeTag(potentialTag);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
const potentialTagJoined = camelcase(validParts.slice(1).join("_"));
|
|
279
|
-
if (potentialTagJoined) {
|
|
280
|
-
return sanitizeTag(potentialTagJoined);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
const potentialTagFull = camelcase(operationId);
|
|
284
|
-
if (potentialTagFull) {
|
|
285
|
-
const isResultSingleVerb = validParts.length === 1 && isFirstPartVerb;
|
|
286
|
-
if (!(isResultSingleVerb && canFallbackToPathSegment)) {
|
|
287
|
-
if (potentialTagFull.length > 0) {
|
|
288
|
-
return sanitizeTag(potentialTagFull);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
const firstPartCamel = camelcase(firstPart);
|
|
293
|
-
if (firstPartCamel) {
|
|
294
|
-
const isFirstPartCamelVerb = commonVerbs.has(firstPartCamel);
|
|
295
|
-
if (!isFirstPartCamelVerb || validParts.length === 1 || !canFallbackToPathSegment) {
|
|
296
|
-
return sanitizeTag(firstPartCamel);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if (isFirstPartVerb && validParts.length > 1 && validParts[1] && canFallbackToPathSegment) {
|
|
300
|
-
const secondPartCamel = camelcase(validParts[1]);
|
|
301
|
-
if (secondPartCamel) {
|
|
302
|
-
return sanitizeTag(secondPartCamel);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (potentialCandidates.length > 0) {
|
|
308
|
-
let firstCandidate = potentialCandidates[0];
|
|
309
|
-
if (firstCandidate.startsWith("@")) {
|
|
310
|
-
firstCandidate = firstCandidate.substring(1);
|
|
311
|
-
}
|
|
312
|
-
if (firstCandidate) {
|
|
313
|
-
return sanitizeTag(camelcase(firstCandidate));
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
console.warn(
|
|
317
|
-
`Could not determine a suitable tag for path: ${pathString}, operationId: ${operationId}. Using 'unknown'.`
|
|
318
|
-
);
|
|
319
|
-
return "unknown";
|
|
320
|
-
}
|
|
321
|
-
function parseJsonContentType(contentType) {
|
|
322
|
-
if (!contentType) {
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
|
-
let mainType = contentType.trim();
|
|
326
|
-
const semicolonIndex = mainType.indexOf(";");
|
|
327
|
-
if (semicolonIndex !== -1) {
|
|
328
|
-
mainType = mainType.substring(0, semicolonIndex).trim();
|
|
329
|
-
}
|
|
330
|
-
mainType = mainType.toLowerCase();
|
|
331
|
-
if (mainType.endsWith("/json")) {
|
|
332
|
-
return mainType.split("/")[1];
|
|
333
|
-
} else if (mainType.endsWith("+json")) {
|
|
334
|
-
return mainType.split("+")[1];
|
|
335
|
-
}
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
function isSseContentType(contentType) {
|
|
339
|
-
if (!contentType) {
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
let mainType = contentType.trim();
|
|
343
|
-
const semicolonIndex = mainType.indexOf(";");
|
|
344
|
-
if (semicolonIndex !== -1) {
|
|
345
|
-
mainType = mainType.substring(0, semicolonIndex).trim();
|
|
346
|
-
}
|
|
347
|
-
mainType = mainType.toLowerCase();
|
|
348
|
-
return mainType === "text/event-stream";
|
|
349
|
-
}
|
|
350
|
-
function isStreamingContentType(contentType) {
|
|
351
|
-
return contentType === "application/octet-stream";
|
|
352
|
-
}
|
|
353
|
-
function isSuccessStatusCode(statusCode) {
|
|
354
|
-
statusCode = Number(statusCode);
|
|
355
|
-
return statusCode >= 200 && statusCode < 300;
|
|
356
|
-
}
|
|
357
|
-
function patchParameters(spec, objectSchema, operation) {
|
|
358
|
-
const securitySchemes = spec.components?.securitySchemes ?? {};
|
|
359
|
-
const securityOptions = securityToOptions(
|
|
360
|
-
spec,
|
|
361
|
-
operation.security ?? [],
|
|
362
|
-
securitySchemes
|
|
363
|
-
);
|
|
364
|
-
objectSchema.properties ??= {};
|
|
365
|
-
objectSchema.required ??= [];
|
|
366
|
-
for (const param of operation.parameters) {
|
|
367
|
-
if (param.required) {
|
|
368
|
-
objectSchema.required.push(param.name);
|
|
369
|
-
}
|
|
370
|
-
objectSchema.properties[param.name] = isRef(param.schema) ? followRef(spec, param.schema.$ref) : param.schema ?? { type: "string" };
|
|
371
|
-
}
|
|
372
|
-
for (const param of securityOptions) {
|
|
373
|
-
objectSchema.required = (objectSchema.required ?? []).filter(
|
|
374
|
-
(name) => name !== param.name
|
|
375
|
-
);
|
|
376
|
-
objectSchema.properties[param.name] = isRef(param.schema) ? followRef(spec, param.schema.$ref) : param.schema ?? { type: "string" };
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
function securityToOptions(spec, security, securitySchemes, staticIn) {
|
|
380
|
-
securitySchemes ??= {};
|
|
381
|
-
const parameters = [];
|
|
382
|
-
for (const it of security) {
|
|
383
|
-
const [name] = Object.keys(it);
|
|
384
|
-
if (!name) {
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
const schema = isRef(securitySchemes[name]) ? followRef(spec, securitySchemes[name].$ref) : securitySchemes[name];
|
|
388
|
-
if (schema.type === "http") {
|
|
389
|
-
parameters.push({
|
|
390
|
-
in: staticIn ?? "header",
|
|
391
|
-
name: "authorization",
|
|
392
|
-
schema: { type: "string" }
|
|
393
|
-
});
|
|
394
|
-
continue;
|
|
395
|
-
}
|
|
396
|
-
if (schema.type === "apiKey") {
|
|
397
|
-
if (!schema.in) {
|
|
398
|
-
throw new Error(`apiKey security schema must have an "in" field`);
|
|
399
|
-
}
|
|
400
|
-
if (!schema.name) {
|
|
401
|
-
throw new Error(`apiKey security schema must have a "name" field`);
|
|
402
|
-
}
|
|
403
|
-
parameters.push({
|
|
404
|
-
in: staticIn ?? schema.in,
|
|
405
|
-
name: schema.name,
|
|
406
|
-
schema: { type: "string" }
|
|
407
|
-
});
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return parameters;
|
|
412
|
-
}
|
|
413
|
-
export {
|
|
414
|
-
augmentSpec,
|
|
415
|
-
defaults,
|
|
416
|
-
determineGenericTag,
|
|
417
|
-
forEachOperation,
|
|
418
|
-
isSseContentType,
|
|
419
|
-
isStreamingContentType,
|
|
420
|
-
isSuccessStatusCode,
|
|
421
|
-
parseJsonContentType,
|
|
422
|
-
patchParameters,
|
|
423
|
-
securityToOptions
|
|
424
|
-
};
|
|
425
|
-
//# sourceMappingURL=operation.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/lib/operation.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n ComponentsObject,\n OpenAPIObject,\n OperationObject,\n ParameterLocation,\n ParameterObject,\n PathsObject,\n ReferenceObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n SecurityRequirementObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\n\nimport type { Method } from '@sdk-it/core/paths.js';\nimport { followRef, isRef } from '@sdk-it/core/ref.js';\n\nimport {\n type PaginationGuess,\n guessPagination,\n} from './pagination/pagination.js';\n\nexport function augmentSpec(config: GenerateSdkConfig) {\n config.spec.paths ??= {};\n const paths: PathsObject = {};\n for (const [path, pathItem] of Object.entries(config.spec.paths)) {\n const { parameters = [], ...methods } = pathItem;\n\n // Convert Express-style routes (:param) to OpenAPI-style routes ({param})\n const fixedPath = path.replace(/:([^/]+)/g, '{$1}');\n for (const [method, operation] of Object.entries(methods) as [\n Method,\n OperationObject,\n ][]) {\n const formatOperationId = config.operationId ?? defaults.operationId;\n const formatTag = config.tag ?? defaults.tag;\n const operationId = formatOperationId(operation, fixedPath, method);\n const operationTag = formatTag(operation, fixedPath);\n const requestBody = isRef(operation.requestBody)\n ? followRef<RequestBodyObject>(config.spec, operation.requestBody.$ref)\n : operation.requestBody;\n const tunedOperation: TunedOperationObject = {\n ...operation,\n parameters: [...parameters, ...(operation.parameters ?? [])].map(\n (it) =>\n isRef(it) ? followRef<ParameterObject>(config.spec, it.$ref) : it,\n ),\n tags: [operationTag],\n operationId: operationId,\n responses: resolveResponses(config.spec, operation),\n requestBody: requestBody,\n };\n\n tunedOperation['x-pagination'] = toPagination(\n config.spec,\n tunedOperation,\n );\n\n Object.assign(paths, {\n [fixedPath]: {\n ...paths[fixedPath],\n [method]: tunedOperation,\n },\n });\n }\n }\n return { ...config.spec, paths };\n}\n\nexport type OperationPagination = PaginationGuess & {\n items: string;\n};\n\nfunction toPagination(\n spec: OpenAPIObject,\n tunedOperation: TunedOperationObject,\n) {\n if (tunedOperation['x-pagination']) {\n return tunedOperation['x-pagination'];\n }\n const schema = getResponseContentSchema(\n spec,\n tunedOperation.responses['200'],\n 'application/json',\n );\n const pagination = guessPagination(\n tunedOperation,\n tunedOperation.requestBody\n ? getRequestContentSchema(\n spec,\n tunedOperation.requestBody,\n 'application/json',\n )\n : undefined,\n schema,\n );\n if (pagination && pagination.type !== 'none' && schema) {\n // console.dir({\n // [`${method.toUpperCase()} ${fixedPath}`]: {\n // ...pagination,\n // },\n // });\n return pagination;\n }\n return undefined;\n}\n\nfunction getResponseContentSchema(\n spec: OpenAPIObject,\n response: ResponseObject,\n type: string,\n) {\n if (!response) {\n return undefined;\n }\n const content = response.content;\n if (!content) {\n return undefined;\n }\n for (const contentType in content) {\n if (contentType.toLowerCase() === type.toLowerCase()) {\n return isRef(content[contentType].schema)\n ? followRef<SchemaObject>(spec, content[contentType].schema.$ref)\n : content[contentType].schema;\n }\n }\n return undefined;\n}\n\nfunction getRequestContentSchema(\n spec: OpenAPIObject,\n requestBody: RequestBodyObject,\n type: string,\n) {\n const content = requestBody.content;\n if (!content) {\n return undefined;\n }\n for (const contentType in content) {\n if (contentType.toLowerCase() === type.toLowerCase()) {\n return isRef(content[contentType].schema)\n ? followRef<SchemaObject>(spec, content[contentType].schema.$ref)\n : content[contentType].schema;\n }\n }\n return undefined;\n}\n\nexport const defaults: Partial<GenerateSdkConfig> &\n Required<Pick<GenerateSdkConfig, 'operationId' | 'tag'>> = {\n operationId: (operation, path, method) => {\n if (operation.operationId) {\n return camelcase(operation.operationId);\n }\n const metadata = operation['x-oaiMeta'];\n if (metadata && metadata.name) {\n return camelcase(metadata.name);\n }\n return camelcase(\n [method, ...path.replace(/[\\\\/\\\\{\\\\}]/g, ' ').split(' ')]\n .filter(Boolean)\n .join(' ')\n .trim(),\n );\n },\n tag: (operation, path) => {\n return operation.tags?.[0]\n ? sanitizeTag(operation.tags?.[0])\n : determineGenericTag(path, operation);\n },\n};\n\nexport type TunedOperationObject = Omit<\n OperationObject,\n 'operationId' | 'parameters' | 'responses'\n> & {\n operationId: string;\n parameters: ParameterObject[];\n responses: Record<string, ResponseObject>;\n requestBody: RequestBodyObject | undefined;\n};\n\nexport interface OperationEntry {\n name?: string;\n method: string;\n path: string;\n groupName: string;\n tag: string;\n}\nexport type Operation = {\n entry: OperationEntry;\n operation: TunedOperationObject;\n};\n\nfunction resolveResponses(spec: OpenAPIObject, operation: OperationObject) {\n const responses = operation.responses ?? {};\n const resolved: Record<string, ResponseObject> = {};\n for (const status in responses) {\n const response = isRef(responses[status] as ReferenceObject)\n ? followRef<ResponseObject>(spec, responses[status].$ref)\n : (responses[status] as ResponseObject);\n resolved[status] = response;\n }\n return resolved;\n}\n\nexport function forEachOperation<T>(\n config: GenerateSdkConfig,\n callback: (entry: OperationEntry, operation: TunedOperationObject) => T,\n) {\n const result: T[] = [];\n for (const [path, pathItem] of Object.entries(config.spec.paths ?? {})) {\n const { parameters = [], ...methods } = pathItem;\n\n for (const [method, operation] of Object.entries(methods) as [\n string,\n OperationObject,\n ][]) {\n const metadata = operation['x-oaiMeta'] ?? {};\n const operationTag = operation.tags?.[0] as string;\n\n result.push(\n callback(\n {\n name: metadata.name,\n method,\n path: path,\n groupName: operationTag,\n tag: operationTag,\n },\n operation as TunedOperationObject,\n ),\n );\n }\n }\n return result;\n}\n\nexport interface GenerateSdkConfig {\n spec: OpenAPIObject;\n operationId?: (\n operation: OperationObject,\n path: string,\n method: string,\n ) => string;\n tag?: (operation: OperationObject, path: string) => string;\n}\n\n/**\n * Set of reserved TypeScript keywords and common verbs potentially used as tags.\n */\n\nconst reservedKeywords = new Set([\n 'await', // Reserved in async functions\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'enum',\n 'export',\n 'extends',\n 'false',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'implements', // Strict mode\n 'import',\n 'in',\n 'instanceof',\n 'interface', // Strict mode\n 'let', // Strict mode\n 'new',\n 'null',\n 'package', // Strict mode\n 'private', // Strict mode\n 'protected', // Strict mode\n 'public', // Strict mode\n 'return',\n 'static', // Strict mode\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield', // Strict mode / Generator functions\n // 'arguments' is not technically a reserved word, but it's a special identifier within functions\n // and assigning to it or declaring it can cause issues or unexpected behavior.\n 'arguments',\n]);\n\n/**\n * Sanitizes a potential tag name (assumed to be already camelCased)\n * to avoid conflicts with reserved keywords or invalid starting characters (numbers).\n * Appends an underscore if the tag matches a reserved keyword.\n * Prepends an underscore if the tag starts with a number.\n * @param camelCasedTag The potential tag name, already camelCased.\n * @returns The sanitized tag name.\n */\nfunction sanitizeTag(camelCasedTag: string): string {\n // Prepend underscore if starts with a number\n if (/^\\d/.test(camelCasedTag)) {\n return `_${camelCasedTag}`;\n }\n // Append underscore if it's a reserved keyword\n return reservedKeywords.has(camelcase(camelCasedTag))\n ? `${camelCasedTag}_`\n : camelCasedTag;\n}\n\n/**\n * Attempts to determine a generic tag for an OpenAPI operation based on path and operationId.\n * Rules and fallbacks are documented within the code.\n * @param pathString The path string.\n * @param operation The OpenAPI Operation Object.\n * @returns A sanitized, camelCased tag name string.\n */\nexport function determineGenericTag(\n pathString: string,\n operation: OperationObject,\n): string {\n const operationId = operation.operationId || '';\n const VERSION_REGEX = /^[vV]\\d+$/;\n const commonVerbs = new Set([\n // Verbs to potentially strip from operationId prefix\n 'get',\n 'list',\n 'create',\n 'update',\n 'delete',\n 'post',\n 'put',\n 'patch',\n 'do',\n 'send',\n 'add',\n 'remove',\n 'set',\n 'find',\n 'search',\n 'check',\n 'make',\n ]);\n\n const segments = pathString.split('/').filter(Boolean);\n\n const potentialCandidates = segments.filter(\n (segment) =>\n segment &&\n !segment.startsWith('{') &&\n !segment.endsWith('}') &&\n !VERSION_REGEX.test(segment),\n );\n\n // --- Heuristic 1: Last non-'@' path segment ---\n for (let i = potentialCandidates.length - 1; i >= 0; i--) {\n const segment = potentialCandidates[i];\n if (!segment.startsWith('@')) {\n // Sanitize just before returning\n return sanitizeTag(camelcase(segment));\n }\n }\n\n const canFallbackToPathSegment = potentialCandidates.length > 0;\n\n // --- Heuristic 2: OperationId parsing ---\n if (operationId) {\n const lowerOpId = operationId.toLowerCase();\n const parts = operationId\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')\n .replace(/([a-zA-Z])(\\d)/g, '$1_$2')\n .replace(/(\\d)([a-zA-Z])/g, '$1_$2')\n .toLowerCase()\n .split(/[_-\\s]+/);\n\n const validParts = parts.filter(Boolean);\n\n // Quick skip: If opId is just a verb and we can use Heuristic 3, prefer that.\n if (\n commonVerbs.has(lowerOpId) &&\n validParts.length === 1 &&\n canFallbackToPathSegment\n ) {\n // Proceed directly to Heuristic 3\n }\n // Only process if there are valid parts and the quick skip didn't happen\n else if (validParts.length > 0) {\n const firstPart = validParts[0];\n const isFirstPartVerb = commonVerbs.has(firstPart);\n\n // Case 2a: Starts with verb, has following parts\n if (isFirstPartVerb && validParts.length > 1) {\n const verbPrefixLength = firstPart.length;\n let nextPartStartIndex = -1;\n if (operationId.length > verbPrefixLength) {\n // Simplified check for next part start\n const charAfterPrefix = operationId[verbPrefixLength];\n if (charAfterPrefix >= 'A' && charAfterPrefix <= 'Z') {\n nextPartStartIndex = verbPrefixLength;\n } else if (charAfterPrefix >= '0' && charAfterPrefix <= '9') {\n nextPartStartIndex = verbPrefixLength;\n } else if (['_', '-'].includes(charAfterPrefix)) {\n nextPartStartIndex = verbPrefixLength + 1;\n } else {\n const match = operationId\n .substring(verbPrefixLength)\n .match(/[A-Z0-9]/);\n if (match && match.index !== undefined) {\n nextPartStartIndex = verbPrefixLength + match.index;\n }\n if (\n nextPartStartIndex === -1 &&\n operationId.length > verbPrefixLength\n ) {\n nextPartStartIndex = verbPrefixLength; // Default guess\n }\n }\n }\n\n if (\n nextPartStartIndex !== -1 &&\n nextPartStartIndex < operationId.length\n ) {\n const remainingOriginalSubstring =\n operationId.substring(nextPartStartIndex);\n const potentialTag = camelcase(remainingOriginalSubstring);\n if (potentialTag) {\n // Sanitize just before returning\n return sanitizeTag(potentialTag);\n }\n }\n\n // Fallback: join remaining lowercased parts\n const potentialTagJoined = camelcase(validParts.slice(1).join('_'));\n if (potentialTagJoined) {\n // Sanitize just before returning\n return sanitizeTag(potentialTagJoined);\n }\n }\n\n // Case 2b: Doesn't start with verb, or only one part (might be verb)\n const potentialTagFull = camelcase(operationId);\n if (potentialTagFull) {\n const isResultSingleVerb = validParts.length === 1 && isFirstPartVerb;\n\n // Avoid returning only a verb if Heuristic 3 is possible\n if (!(isResultSingleVerb && canFallbackToPathSegment)) {\n if (potentialTagFull.length > 0) {\n // Sanitize just before returning\n return sanitizeTag(potentialTagFull);\n }\n }\n }\n\n // Case 2c: Further fallbacks within OpId if above failed/skipped\n const firstPartCamel = camelcase(firstPart);\n if (firstPartCamel) {\n const isFirstPartCamelVerb = commonVerbs.has(firstPartCamel);\n if (\n !isFirstPartCamelVerb ||\n validParts.length === 1 ||\n !canFallbackToPathSegment\n ) {\n // Sanitize just before returning\n return sanitizeTag(firstPartCamel);\n }\n }\n if (\n isFirstPartVerb &&\n validParts.length > 1 &&\n validParts[1] &&\n canFallbackToPathSegment\n ) {\n const secondPartCamel = camelcase(validParts[1]);\n if (secondPartCamel) {\n // Sanitize just before returning\n return sanitizeTag(secondPartCamel);\n }\n }\n } // End if(validParts.length > 0) after quick skip check\n } // End if(operationId)\n\n // --- Heuristic 3: First path segment (stripping '@') ---\n if (potentialCandidates.length > 0) {\n let firstCandidate = potentialCandidates[0];\n if (firstCandidate.startsWith('@')) {\n firstCandidate = firstCandidate.substring(1);\n }\n if (firstCandidate) {\n // Sanitize just before returning\n return sanitizeTag(camelcase(firstCandidate));\n }\n }\n\n // --- Heuristic 4: Default ---\n console.warn(\n `Could not determine a suitable tag for path: ${pathString}, operationId: ${operationId}. Using 'unknown'.`,\n );\n return 'unknown'; // 'unknown' is safe\n}\n\nexport function parseJsonContentType(contentType: string | null | undefined) {\n if (!contentType) {\n return null;\n }\n\n // 1. Trim whitespace\n let mainType = contentType.trim();\n\n // 2. Remove parameters (anything after the first ';')\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n mainType = mainType.substring(0, semicolonIndex).trim(); // Trim potential space before ';'\n }\n\n // 3. Convert to lowercase for case-insensitive comparison\n mainType = mainType.toLowerCase();\n\n if (mainType.endsWith('/json')) {\n return mainType.split('/')[1];\n } else if (mainType.endsWith('+json')) {\n return mainType.split('+')[1];\n }\n return null;\n}\n\n/**\n * Checks if a given content type string represents Server-Sent Events (SSE).\n * Handles case-insensitivity, parameters (like charset), and leading/trailing whitespace.\n *\n * @param contentType The content type string to check (e.g., from a Content-Type header).\n * @returns True if the content type is 'text/event-stream', false otherwise.\n */\nexport function isSseContentType(\n contentType: string | null | undefined,\n): boolean {\n if (!contentType) {\n return false; // Handle null, undefined, or empty string\n }\n\n // 1. Trim whitespace from the input string\n let mainType = contentType.trim();\n\n // 2. Find the position of the first semicolon (if any) to remove parameters\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n // Extract the part before the semicolon and trim potential space\n mainType = mainType.substring(0, semicolonIndex).trim();\n }\n\n // 3. Convert the main type part to lowercase for case-insensitive comparison\n mainType = mainType.toLowerCase();\n\n // 4. Compare against the standard SSE MIME type\n return mainType === 'text/event-stream';\n}\n\nexport function isStreamingContentType(\n contentType: string | null | undefined,\n): boolean {\n return contentType === 'application/octet-stream';\n}\n\nexport function isSuccessStatusCode(statusCode: number | string): boolean {\n statusCode = Number(statusCode);\n return statusCode >= 200 && statusCode < 300;\n}\n\nexport function patchParameters(\n spec: OpenAPIObject,\n objectSchema: SchemaObject,\n operation: TunedOperationObject,\n) {\n const securitySchemes = spec.components?.securitySchemes ?? {};\n const securityOptions = securityToOptions(\n spec,\n operation.security ?? [],\n securitySchemes,\n );\n\n objectSchema.properties ??= {};\n objectSchema.required ??= [];\n for (const param of operation.parameters) {\n if (param.required) {\n objectSchema.required.push(param.name);\n }\n objectSchema.properties[param.name] = isRef(param.schema)\n ? followRef<SchemaObject>(spec, param.schema.$ref)\n : (param.schema ?? { type: 'string' });\n }\n for (const param of securityOptions) {\n objectSchema.required = (objectSchema.required ?? []).filter(\n (name) => name !== param.name,\n );\n objectSchema.properties[param.name] = isRef(param.schema)\n ? followRef<SchemaObject>(spec, param.schema.$ref)\n : (param.schema ?? { type: 'string' });\n }\n}\n\nexport function securityToOptions(\n spec: OpenAPIObject,\n security: SecurityRequirementObject[],\n securitySchemes: ComponentsObject['securitySchemes'],\n staticIn?: ParameterLocation,\n) {\n securitySchemes ??= {};\n const parameters: ParameterObject[] = [];\n for (const it of security) {\n const [name] = Object.keys(it);\n if (!name) {\n // this means the operation doesn't necessarily require security\n continue;\n }\n const schema = isRef(securitySchemes[name])\n ? followRef(spec, securitySchemes[name].$ref)\n : securitySchemes[name];\n\n if (schema.type === 'http') {\n parameters.push({\n in: staticIn ?? 'header',\n name: 'authorization',\n schema: { type: 'string' },\n });\n continue;\n }\n if (schema.type === 'apiKey') {\n if (!schema.in) {\n throw new Error(`apiKey security schema must have an \"in\" field`);\n }\n if (!schema.name) {\n throw new Error(`apiKey security schema must have a \"name\" field`);\n }\n parameters.push({\n in: staticIn ?? (schema.in as ParameterLocation),\n name: schema.name,\n schema: { type: 'string' },\n });\n continue;\n }\n }\n return parameters;\n}\n"],
|
|
5
|
-
"mappings": "AAaA,SAAS,iBAAiB;AAG1B,SAAS,WAAW,aAAa;AAEjC;AAAA,EAEE;AAAA,OACK;AAEA,SAAS,YAAY,QAA2B;AACrD,SAAO,KAAK,UAAU,CAAC;AACvB,QAAM,QAAqB,CAAC;AAC5B,aAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,OAAO,KAAK,KAAK,GAAG;AAChE,UAAM,EAAE,aAAa,CAAC,GAAG,GAAG,QAAQ,IAAI;AAGxC,UAAM,YAAY,KAAK,QAAQ,aAAa,MAAM;AAClD,eAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAGnD;AACH,YAAM,oBAAoB,OAAO,eAAe,SAAS;AACzD,YAAM,YAAY,OAAO,OAAO,SAAS;AACzC,YAAM,cAAc,kBAAkB,WAAW,WAAW,MAAM;AAClE,YAAM,eAAe,UAAU,WAAW,SAAS;AACnD,YAAM,cAAc,MAAM,UAAU,WAAW,IAC3C,UAA6B,OAAO,MAAM,UAAU,YAAY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