@sdk-it/spec 0.45.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +2 -2
- package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
- package/dist/lib/find-polymorphic-varients.js +5 -10
- package/dist/lib/find-polymorphic-varients.js.map +2 -2
- package/dist/lib/for-each-operation.d.ts +11 -3
- package/dist/lib/for-each-operation.d.ts.map +1 -1
- package/dist/lib/for-each-operation.js +23 -15
- package/dist/lib/for-each-operation.js.map +2 -2
- package/dist/lib/format-name.d.ts.map +1 -1
- package/dist/lib/format-name.js +0 -1
- package/dist/lib/format-name.js.map +2 -2
- package/dist/lib/ir.d.ts +2 -2
- package/dist/lib/ir.d.ts.map +1 -1
- package/dist/lib/ir.js +6 -120
- package/dist/lib/ir.js.map +2 -2
- package/dist/lib/is.d.ts.map +1 -1
- package/dist/lib/is.js +1 -3
- package/dist/lib/is.js.map +2 -2
- package/dist/lib/loaders/postman/postman-converter.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.js +1 -11
- package/dist/lib/loaders/postman/postman-converter.js.map +2 -2
- package/dist/lib/options.d.ts +7 -45
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +26 -28
- package/dist/lib/options.js.map +2 -2
- package/dist/lib/overview-docs/overview-pagination.d.ts +1 -1
- package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-pagination.js +1 -1
- package/dist/lib/overview-docs/overview-pagination.js.map +2 -2
- package/dist/lib/pagination/guess-pagination.d.ts.map +1 -1
- package/dist/lib/pagination/guess-pagination.js.map +2 -2
- package/dist/lib/pagination/pagination-result.d.ts.map +1 -1
- package/dist/lib/pagination/pagination-result.js +15 -5
- package/dist/lib/pagination/pagination-result.js.map +2 -2
- package/dist/lib/pagination/pagination.d.ts.map +1 -1
- package/dist/lib/pagination/pagination.js +7 -6
- package/dist/lib/pagination/pagination.js.map +2 -2
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts +3 -0
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts.map +1 -0
- package/dist/lib/processing-plugins/canonicalize-spec.js +29 -0
- package/dist/lib/processing-plugins/canonicalize-spec.js.map +7 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts +5 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts.map +1 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.js +30 -0
- package/dist/lib/processing-plugins/create-default-processing-plugins.js.map +7 -0
- package/dist/lib/processing-plugins/enrich-examples.d.ts +25 -0
- package/dist/lib/processing-plugins/enrich-examples.d.ts.map +1 -0
- package/dist/lib/processing-plugins/enrich-examples.js +93 -0
- package/dist/lib/processing-plugins/enrich-examples.js.map +7 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts +3 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts.map +1 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.js +14 -0
- package/dist/lib/processing-plugins/extract-inline-schemas.js.map +7 -0
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts +3 -0
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts.map +1 -0
- package/dist/lib/processing-plugins/extract-overview-docs.js +13 -0
- package/dist/lib/processing-plugins/extract-overview-docs.js.map +7 -0
- package/dist/lib/processing-plugins/index.d.ts +14 -0
- package/dist/lib/processing-plugins/index.d.ts.map +1 -0
- package/dist/lib/processing-plugins/index.js +14 -0
- package/dist/lib/processing-plugins/index.js.map +7 -0
- package/dist/lib/processing-plugins/infer-pagination.d.ts +3 -0
- package/dist/lib/processing-plugins/infer-pagination.d.ts.map +1 -0
- package/dist/lib/processing-plugins/infer-pagination.js +21 -0
- package/dist/lib/processing-plugins/infer-pagination.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.js +74 -0
- package/dist/lib/processing-plugins/normalize-operation-ids.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-parameters.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-parameters.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-parameters.js +29 -0
- package/dist/lib/processing-plugins/normalize-parameters.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-paths.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-paths.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-paths.js +67 -0
- package/dist/lib/processing-plugins/normalize-paths.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.js +44 -0
- package/dist/lib/processing-plugins/normalize-request-bodies.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-responses.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-responses.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-responses.js +38 -0
- package/dist/lib/processing-plugins/normalize-responses.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-schemas.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-schemas.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-schemas.js +13 -0
- package/dist/lib/processing-plugins/normalize-schemas.js.map +7 -0
- package/dist/lib/processing-plugins/normalize-tags.d.ts +3 -0
- package/dist/lib/processing-plugins/normalize-tags.d.ts.map +1 -0
- package/dist/lib/processing-plugins/normalize-tags.js +18 -0
- package/dist/lib/processing-plugins/normalize-tags.js.map +7 -0
- package/dist/lib/processing.d.ts +33 -0
- package/dist/lib/processing.d.ts.map +1 -0
- package/dist/lib/processing.js +41 -0
- package/dist/lib/processing.js.map +7 -0
- package/dist/lib/reserved-keywords.d.ts.map +1 -1
- package/dist/lib/reserved-keywords.js +18 -1
- package/dist/lib/reserved-keywords.js.map +2 -2
- package/dist/lib/tag.js +2 -2
- package/dist/lib/tag.js.map +2 -2
- package/dist/lib/tune-request-body.d.ts.map +1 -1
- package/dist/lib/tune-request-body.js +22 -12
- package/dist/lib/tune-request-body.js.map +2 -2
- package/dist/lib/tune-response.d.ts.map +1 -1
- package/dist/lib/tune-response.js +16 -12
- package/dist/lib/tune-response.js.map +2 -2
- package/dist/lib/tune.d.ts.map +1 -1
- package/dist/lib/tune.js +31 -7
- package/dist/lib/tune.js.map +2 -2
- package/dist/lib/types.d.ts +4 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/walk-schemas.d.ts +8 -0
- package/dist/lib/walk-schemas.d.ts.map +1 -0
- package/dist/lib/walk-schemas.js +51 -0
- package/dist/lib/walk-schemas.js.map +7 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -12,13 +12,15 @@ export * from './lib/loaders/local-loader.js';
|
|
|
12
12
|
export * from './lib/loaders/remote-loader.js';
|
|
13
13
|
export * from './lib/metadata.js';
|
|
14
14
|
export * from './lib/options.js';
|
|
15
|
+
export * from './lib/processing-plugins/index.js';
|
|
16
|
+
export * from './lib/processing.js';
|
|
15
17
|
export * from './lib/overview-docs/overview-errors.js';
|
|
16
18
|
export * from './lib/reserved-keywords.js';
|
|
17
19
|
export * from './lib/security.js';
|
|
18
20
|
export * from './lib/sidebar.js';
|
|
19
21
|
export * from './lib/tag.js';
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export * from './lib/tune.js';
|
|
22
|
+
export { patchParameters } from './lib/tune-request-body.js';
|
|
23
|
+
export { coerceTypes } from './lib/tune.js';
|
|
23
24
|
export * from './lib/types.js';
|
|
25
|
+
export * from './lib/walk-schemas.js';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,13 +12,19 @@ export * from "./lib/loaders/local-loader.js";
|
|
|
12
12
|
export * from "./lib/loaders/remote-loader.js";
|
|
13
13
|
export * from "./lib/metadata.js";
|
|
14
14
|
export * from "./lib/options.js";
|
|
15
|
+
export * from "./lib/processing-plugins/index.js";
|
|
16
|
+
export * from "./lib/processing.js";
|
|
15
17
|
export * from "./lib/overview-docs/overview-errors.js";
|
|
16
18
|
export * from "./lib/reserved-keywords.js";
|
|
17
19
|
export * from "./lib/security.js";
|
|
18
20
|
export * from "./lib/sidebar.js";
|
|
19
21
|
export * from "./lib/tag.js";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export * from "./lib/tune.js";
|
|
22
|
+
import { patchParameters } from "./lib/tune-request-body.js";
|
|
23
|
+
import { coerceTypes } from "./lib/tune.js";
|
|
23
24
|
export * from "./lib/types.js";
|
|
25
|
+
export * from "./lib/walk-schemas.js";
|
|
26
|
+
export {
|
|
27
|
+
coerceTypes,
|
|
28
|
+
patchParameters
|
|
29
|
+
};
|
|
24
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './lib/create-operation.js';\nexport * from './lib/find-polymorphic-varients.js';\nexport * from './lib/find-unique-schema-name.js';\nexport * from './lib/for-each-operation.js';\nexport * from './lib/format-name.js';\nexport * from './lib/get-ref-usage.js';\nexport * from './lib/ir.js';\nexport * from './lib/is-primitive-schema.js';\nexport * from './lib/is.js';\nexport * from './lib/loaders/load-spec.js';\nexport * from './lib/loaders/local-loader.js';\nexport * from './lib/loaders/remote-loader.js';\nexport * from './lib/metadata.js';\nexport * from './lib/options.js';\nexport * from './lib/overview-docs/overview-errors.js';\nexport * from './lib/reserved-keywords.js';\nexport * from './lib/security.js';\nexport * from './lib/sidebar.js';\nexport * from './lib/tag.js';\nexport
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './lib/create-operation.js';\nexport * from './lib/find-polymorphic-varients.js';\nexport * from './lib/find-unique-schema-name.js';\nexport * from './lib/for-each-operation.js';\nexport * from './lib/format-name.js';\nexport * from './lib/get-ref-usage.js';\nexport * from './lib/ir.js';\nexport * from './lib/is-primitive-schema.js';\nexport * from './lib/is.js';\nexport * from './lib/loaders/load-spec.js';\nexport * from './lib/loaders/local-loader.js';\nexport * from './lib/loaders/remote-loader.js';\nexport * from './lib/metadata.js';\nexport * from './lib/options.js';\nexport * from './lib/processing-plugins/index.js';\nexport * from './lib/processing.js';\nexport * from './lib/overview-docs/overview-errors.js';\nexport * from './lib/reserved-keywords.js';\nexport * from './lib/security.js';\nexport * from './lib/sidebar.js';\nexport * from './lib/tag.js';\nexport { patchParameters } from './lib/tune-request-body.js';\nexport { coerceTypes } from './lib/tune.js';\nexport * from './lib/types.js';\nexport * from './lib/walk-schemas.js';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-polymorphic-varients.d.ts","sourceRoot":"","sources":["../../src/lib/find-polymorphic-varients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B,CAAC;
|
|
1
|
+
{"version":3,"file":"find-polymorphic-varients.d.ts","sourceRoot":"","sources":["../../src/lib/find-polymorphic-varients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA0EF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,GAC1C,OAAO,EAAE,CAkQX;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,GAC1C,OAAO,EAAE,CAQX"}
|
|
@@ -204,7 +204,11 @@ function findVarients(spec, schemas) {
|
|
|
204
204
|
}
|
|
205
205
|
const matrix = [];
|
|
206
206
|
for (const { schema, position } of schemasByType.object ?? []) {
|
|
207
|
-
if (schema.additionalProperties
|
|
207
|
+
if (schema.additionalProperties) {
|
|
208
|
+
varients.push({ name: "object", type: "object", position });
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (isEmpty({ ...schema.properties, ...schema["x-properties"] })) {
|
|
208
212
|
continue;
|
|
209
213
|
}
|
|
210
214
|
for (const key of ["properties", "x-properties"]) {
|
|
@@ -237,15 +241,6 @@ function findVarients(spec, schemas) {
|
|
|
237
241
|
"No valid objects found. Please check your OpenAPI spec."
|
|
238
242
|
);
|
|
239
243
|
}
|
|
240
|
-
let discriminatorProp;
|
|
241
|
-
const firstRow = matrix[0];
|
|
242
|
-
for (const prop of firstRow) {
|
|
243
|
-
const existsCrossAllRows = matrix.every((row) => row.includes(prop));
|
|
244
|
-
if (existsCrossAllRows) {
|
|
245
|
-
discriminatorProp = prop;
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
244
|
}
|
|
250
245
|
for (const row of matrix) {
|
|
251
246
|
for (const prop of row) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/find-polymorphic-varients.ts"],
|
|
4
|
-
"sourcesContent": ["import { groupBy, uniqBy } from 'lodash-es';\nimport type {\n ReferenceObject,\n SchemaObject,\n SchemaObjectType,\n} from 'openapi3-ts/oas31';\n\nimport { camelcase, isEmpty, isRef, resolveRef } from '@sdk-it/core';\n\nimport { coerceTypes } from './tune.js';\nimport type { IR } from './types.js';\n\nexport type Varient = {\n name: string;\n type: string;\n position: number;\n priority?: number;\n description?: string;\n source?: string;\n static?: boolean;\n subtype?: SchemaObjectType;\n};\n\nconst groupSchemasByType = (\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n) => {\n const groups = schemas.reduce<\n Partial<{\n [K in\n | SchemaObjectType\n | '$ref'\n | 'oneOf'\n | 'anyOf']: K extends SchemaObjectType\n ? { schema: SchemaObject; position: number }[]\n : K extends 'oneOf' | 'anyOf'\n ? { schema: (SchemaObject | ReferenceObject)[]; position: number }[]\n : { schema: ReferenceObject; position: number }[];\n }>\n >((acc, schema, index) => {\n if (isRef(schema)) {\n const referenced = resolveRef<SchemaObject>(spec, schema);\n const [type] = coerceTypes(referenced, false);\n acc[type] ??= [];\n acc[type].push({ schema: referenced, position: index });\n return acc;\n }\n\n if (isRef(schema.items)) {\n const referenced = resolveRef<SchemaObject>(spec, schema.items);\n acc.array ??= [];\n acc.array.push({\n schema: { ...schema, items: referenced },\n position: index,\n });\n return acc;\n }\n if (schema.oneOf) {\n acc['oneOf'] ??= [];\n acc['oneOf'].push({ schema: schema.oneOf, position: index });\n return acc;\n }\n if (schema.anyOf) {\n acc['oneOf'] ??= [];\n acc['oneOf'].push({ schema: schema.anyOf, position: index });\n return acc;\n }\n if (schema.const) {\n switch (typeof schema.const) {\n case 'string':\n acc.string ??= [];\n acc.string.push({ schema, position: index });\n return acc;\n case 'number':\n acc.number ??= [];\n acc.number.push({ schema, position: index });\n return acc;\n case 'boolean':\n acc.boolean ??= [];\n acc.boolean.push({ schema, position: index });\n return acc;\n default:\n throw new Error(\n `Unsupported const type: ${typeof schema.const} for ${schema.const}`,\n );\n }\n }\n\n const [type] = coerceTypes(schema, false);\n acc[type] ??= [];\n acc[type].push({ schema, position: index });\n return acc;\n }, {});\n\n return groups;\n};\n\nexport function findVarients(\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n): Varient[] {\n let varients: Varient[] = [];\n const schemasByType = groupSchemasByType(spec, schemas);\n if (!isEmpty(schemasByType.string)) {\n for (const { schema, position } of schemasByType.string) {\n if (schema.const !== undefined) {\n varients.push({\n name: schema.const || 'empty',\n type: 'string',\n position,\n priority: 100 - varients.length,\n });\n continue;\n }\n\n if (schema.format) {\n varients.push({\n name: camelcase(schema.format),\n type: 'string',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n\n // if (!isEmpty(schema.enum)) {\n // for (const enumValue of schema.enum) {\n // if (enumValue === '') {\n // varients.push({\n // name: 'empty',\n // type: 'string',\n // position,\n // priority: 80 - varients.length,\n // });\n // continue;\n // }\n // varients.push({\n // name: enumValue,\n // type: 'string',\n // position,\n // priority: 80 - varients.length,\n // });\n // }\n // continue;\n // }\n\n varients.push({ name: 'text', type: 'string', position });\n }\n varients = uniqBy(varients, (it) => it.name);\n }\n\n if (!isEmpty(schemasByType.number) || !isEmpty(schemasByType.integer)) {\n const schemas = [\n ...(schemasByType.number ?? []),\n ...(schemasByType.integer ?? []),\n ];\n for (const { schema, position } of schemas) {\n if (schema.format === 'int64') {\n varients.push({\n name: 'integer',\n type: 'number',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n if (schema.format === 'float') {\n varients.push({\n name: 'float',\n type: 'number',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n if (schema.format === 'double') {\n varients.push({\n name: 'double',\n type: 'number',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n varients.push({ name: 'number', type: 'number', position });\n }\n }\n\n if (!isEmpty(schemasByType.array)) {\n for (const { schema, position } of schemasByType.array) {\n const items = schema.items;\n if (!items) {\n varients.push({ name: 'any', type: 'array', position });\n continue;\n }\n const [type] = coerceTypes(items as SchemaObject);\n if (type === 'string') {\n varients.push({\n name: 'textList',\n type: 'array',\n subtype: 'string',\n position,\n });\n continue;\n }\n if (type === 'number') {\n varients.push({\n name: 'numList',\n type: 'array',\n subtype: 'number',\n position,\n });\n continue;\n }\n if (type === 'integer') {\n varients.push({\n name: 'intList',\n type: 'array',\n subtype: 'integer',\n position,\n });\n continue;\n }\n if (type === 'object') {\n const subvarients = findVarients(spec, [items]);\n for (const subvarient of subvarients) {\n varients.push({\n ...subvarient,\n type: 'array',\n position,\n });\n }\n continue;\n }\n if (type === 'array') {\n const subvarients = findVarients(spec, [items]);\n for (const subvarient of subvarients) {\n varients.push({\n ...subvarient,\n name: `${subvarient.name}Matrix`,\n type: 'array',\n position,\n });\n }\n continue;\n }\n varients.push({ name: 'list', type: 'array', position });\n }\n }\n\n if (!isEmpty(schemasByType.$ref)) {\n const subvarients = findVarients(\n spec,\n schemasByType.$ref.map((it) => resolveRef(spec, it.schema)),\n );\n varients.push(\n ...subvarients.map((it) => ({\n ...it,\n })),\n );\n }\n\n if (!isEmpty(schemasByType.oneOf)) {\n for (const { schema, position } of schemasByType.oneOf) {\n const subvarients = findVarients(spec, schema);\n varients.push(\n ...subvarients.map((it) => ({\n ...it,\n position,\n })),\n );\n }\n }\n\n const matrix: Varient[][] = [];\n\n for (const { schema, position } of schemasByType.object ?? []) {\n if (\n schema.additionalProperties ||\n isEmpty({ ...schema.properties, ...schema['x-properties'] })\n ) {\n continue;\n }\n\n for (const key of ['properties', 'x-properties'] as const) {\n if (!schema[key]) continue;\n const list = (\n Object.entries(schema[key]) as [\n string,\n SchemaObject | ReferenceObject,\n ][]\n ).map(([name, schemaOrRef]) => {\n const schema = resolveRef<SchemaObject>(spec, schemaOrRef);\n name = schema.const ?? schema.enum?.[0] ?? name;\n if (schema.type === 'string') {\n return {\n static: true,\n subtype: 'string',\n source: name,\n name: name,\n type: 'object',\n position,\n } satisfies Varient;\n }\n return {\n subtype: 'string',\n source: name,\n name: name,\n type: 'object',\n position,\n } satisfies Varient;\n });\n matrix.push([...new Set(list)].sort((a) => (a.static ? -1 : 1)));\n }\n if (matrix.length === 0) {\n throw new Error(\n 'No valid objects found. Please check your OpenAPI spec.',\n );\n }\n let discriminatorProp: Varient | undefined;\n const firstRow = matrix[0];\n for (const prop of firstRow) {\n // check if this prop is exists across all rows\n const existsCrossAllRows = matrix.every((row) => row.includes(prop));\n if (existsCrossAllRows) {\n discriminatorProp = prop;\n break;\n }\n }\n }\n\n for (const row of matrix) {\n for (const prop of row) {\n // check if this prop is unique across all rows\n const isUnique = matrix.every((it) =>\n it === row ? true : !it.some((p) => p.name === prop.name),\n );\n if (isUnique) {\n varients.push(prop);\n break;\n }\n }\n }\n\n // Sort all variants by priority (highest first), then by original position\n return varients.sort((a, b) => {\n const aHasPriority = a.priority !== undefined;\n const bHasPriority = b.priority !== undefined;\n\n if (aHasPriority && bHasPriority) {\n // Both have priority\n if (a.priority !== b.priority) {\n return b.priority! - a.priority!; // Higher priority first\n }\n // Priorities are equal, sort by original position as a tie-breaker\n return a.position - b.position;\n } else if (aHasPriority) {\n return -1; // 'a' comes first\n } else if (bHasPriority) {\n return 1; // 'b' comes first\n } else {\n // Neither has priority. Keep their relative order from before this sort.\n // This relies on a stable sort (standard in ES2019+).\n // Returning 0 preserves the order in which they were added to the 'varients' array.\n return 0;\n }\n });\n}\n\nexport function findPolymorphicVarients(\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n): Varient[] {\n const varients = findVarients(spec, schemas);\n // prepend '-' to prevent key sortings\n return Object.values(groupBy(varients, (it) => '-' + it.position)).map(\n (group) => {\n return (group ?? [])[0];\n },\n );\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS,cAAc;AAOhC,SAAS,WAAW,SAAS,OAAO,kBAAkB;AAEtD,SAAS,mBAAmB;AAc5B,MAAM,qBAAqB,CACzB,MACA,YACG;AACH,QAAM,SAAS,QAAQ,
|
|
4
|
+
"sourcesContent": ["import { groupBy, uniqBy } from 'lodash-es';\nimport type {\n ReferenceObject,\n SchemaObject,\n SchemaObjectType,\n} from 'openapi3-ts/oas31';\n\nimport { camelcase, isEmpty, isRef, resolveRef } from '@sdk-it/core';\n\nimport { coerceTypes } from './tune.js';\nimport type { IR } from './types.js';\n\nexport type Varient = {\n name: string;\n type: string;\n position: number;\n priority?: number;\n description?: string;\n source?: string;\n static?: boolean;\n subtype?: SchemaObjectType;\n};\n\nconst groupSchemasByType = (\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n) => {\n const groups = schemas.reduce<\n Partial<{\n [\n K in SchemaObjectType | '$ref' | 'oneOf' | 'anyOf'\n ]: K extends SchemaObjectType\n ? { schema: SchemaObject; position: number }[]\n : K extends 'oneOf' | 'anyOf'\n ? { schema: (SchemaObject | ReferenceObject)[]; position: number }[]\n : { schema: ReferenceObject; position: number }[];\n }>\n >((acc, schema, index) => {\n if (isRef(schema)) {\n const referenced = resolveRef<SchemaObject>(spec, schema);\n const [type] = coerceTypes(referenced, false);\n acc[type] ??= [];\n acc[type].push({ schema: referenced, position: index });\n return acc;\n }\n\n if (isRef(schema.items)) {\n const referenced = resolveRef<SchemaObject>(spec, schema.items);\n acc.array ??= [];\n acc.array.push({\n schema: { ...schema, items: referenced },\n position: index,\n });\n return acc;\n }\n if (schema.oneOf) {\n acc['oneOf'] ??= [];\n acc['oneOf'].push({ schema: schema.oneOf, position: index });\n return acc;\n }\n if (schema.anyOf) {\n acc['oneOf'] ??= [];\n acc['oneOf'].push({ schema: schema.anyOf, position: index });\n return acc;\n }\n if (schema.const) {\n switch (typeof schema.const) {\n case 'string':\n acc.string ??= [];\n acc.string.push({ schema, position: index });\n return acc;\n case 'number':\n acc.number ??= [];\n acc.number.push({ schema, position: index });\n return acc;\n case 'boolean':\n acc.boolean ??= [];\n acc.boolean.push({ schema, position: index });\n return acc;\n default:\n throw new Error(\n `Unsupported const type: ${typeof schema.const} for ${schema.const}`,\n );\n }\n }\n\n const [type] = coerceTypes(schema, false);\n acc[type] ??= [];\n acc[type].push({ schema, position: index });\n return acc;\n }, {});\n\n return groups;\n};\n\nexport function findVarients(\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n): Varient[] {\n let varients: Varient[] = [];\n const schemasByType = groupSchemasByType(spec, schemas);\n if (!isEmpty(schemasByType.string)) {\n for (const { schema, position } of schemasByType.string) {\n if (schema.const !== undefined) {\n varients.push({\n name: schema.const || 'empty',\n type: 'string',\n position,\n priority: 100 - varients.length,\n });\n continue;\n }\n\n if (schema.format) {\n varients.push({\n name: camelcase(schema.format),\n type: 'string',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n\n // if (!isEmpty(schema.enum)) {\n // for (const enumValue of schema.enum) {\n // if (enumValue === '') {\n // varients.push({\n // name: 'empty',\n // type: 'string',\n // position,\n // priority: 80 - varients.length,\n // });\n // continue;\n // }\n // varients.push({\n // name: enumValue,\n // type: 'string',\n // position,\n // priority: 80 - varients.length,\n // });\n // }\n // continue;\n // }\n\n varients.push({ name: 'text', type: 'string', position });\n }\n varients = uniqBy(varients, (it) => it.name);\n }\n\n if (!isEmpty(schemasByType.number) || !isEmpty(schemasByType.integer)) {\n const schemas = [\n ...(schemasByType.number ?? []),\n ...(schemasByType.integer ?? []),\n ];\n for (const { schema, position } of schemas) {\n if (schema.format === 'int64') {\n varients.push({\n name: 'integer',\n type: 'number',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n if (schema.format === 'float') {\n varients.push({\n name: 'float',\n type: 'number',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n if (schema.format === 'double') {\n varients.push({\n name: 'double',\n type: 'number',\n position,\n priority: 90 - varients.length,\n });\n continue;\n }\n varients.push({ name: 'number', type: 'number', position });\n }\n }\n\n if (!isEmpty(schemasByType.array)) {\n for (const { schema, position } of schemasByType.array) {\n const items = schema.items;\n if (!items) {\n varients.push({ name: 'any', type: 'array', position });\n continue;\n }\n const [type] = coerceTypes(items as SchemaObject);\n if (type === 'string') {\n varients.push({\n name: 'textList',\n type: 'array',\n subtype: 'string',\n position,\n });\n continue;\n }\n if (type === 'number') {\n varients.push({\n name: 'numList',\n type: 'array',\n subtype: 'number',\n position,\n });\n continue;\n }\n if (type === 'integer') {\n varients.push({\n name: 'intList',\n type: 'array',\n subtype: 'integer',\n position,\n });\n continue;\n }\n if (type === 'object') {\n const subvarients = findVarients(spec, [items]);\n for (const subvarient of subvarients) {\n varients.push({\n ...subvarient,\n type: 'array',\n position,\n });\n }\n continue;\n }\n if (type === 'array') {\n const subvarients = findVarients(spec, [items]);\n for (const subvarient of subvarients) {\n varients.push({\n ...subvarient,\n name: `${subvarient.name}Matrix`,\n type: 'array',\n position,\n });\n }\n continue;\n }\n varients.push({ name: 'list', type: 'array', position });\n }\n }\n\n if (!isEmpty(schemasByType.$ref)) {\n const subvarients = findVarients(\n spec,\n schemasByType.$ref.map((it) => resolveRef(spec, it.schema)),\n );\n varients.push(\n ...subvarients.map((it) => ({\n ...it,\n })),\n );\n }\n\n if (!isEmpty(schemasByType.oneOf)) {\n for (const { schema, position } of schemasByType.oneOf) {\n const subvarients = findVarients(spec, schema);\n varients.push(\n ...subvarients.map((it) => ({\n ...it,\n position,\n })),\n );\n }\n }\n\n const matrix: Varient[][] = [];\n\n for (const { schema, position } of schemasByType.object ?? []) {\n if (schema.additionalProperties) {\n varients.push({ name: 'object', type: 'object', position });\n continue;\n }\n if (isEmpty({ ...schema.properties, ...schema['x-properties'] })) {\n continue;\n }\n\n for (const key of ['properties', 'x-properties'] as const) {\n if (!schema[key]) continue;\n const list = (\n Object.entries(schema[key]) as [\n string,\n SchemaObject | ReferenceObject,\n ][]\n ).map(([name, schemaOrRef]) => {\n const schema = resolveRef<SchemaObject>(spec, schemaOrRef);\n name = schema.const ?? schema.enum?.[0] ?? name;\n if (schema.type === 'string') {\n return {\n static: true,\n subtype: 'string',\n source: name,\n name: name,\n type: 'object',\n position,\n } satisfies Varient;\n }\n return {\n subtype: 'string',\n source: name,\n name: name,\n type: 'object',\n position,\n } satisfies Varient;\n });\n matrix.push([...new Set(list)].sort((a) => (a.static ? -1 : 1)));\n }\n if (matrix.length === 0) {\n throw new Error(\n 'No valid objects found. Please check your OpenAPI spec.',\n );\n }\n }\n\n for (const row of matrix) {\n for (const prop of row) {\n // check if this prop is unique across all rows\n const isUnique = matrix.every((it) =>\n it === row ? true : !it.some((p) => p.name === prop.name),\n );\n if (isUnique) {\n varients.push(prop);\n break;\n }\n }\n }\n\n // Sort all variants by priority (highest first), then by original position\n return varients.sort((a, b) => {\n const aHasPriority = a.priority !== undefined;\n const bHasPriority = b.priority !== undefined;\n\n if (aHasPriority && bHasPriority) {\n // Both have priority\n if (a.priority !== b.priority) {\n return b.priority! - a.priority!; // Higher priority first\n }\n // Priorities are equal, sort by original position as a tie-breaker\n return a.position - b.position;\n } else if (aHasPriority) {\n return -1; // 'a' comes first\n } else if (bHasPriority) {\n return 1; // 'b' comes first\n } else {\n // Neither has priority. Keep their relative order from before this sort.\n // This relies on a stable sort (standard in ES2019+).\n // Returning 0 preserves the order in which they were added to the 'varients' array.\n return 0;\n }\n });\n}\n\nexport function findPolymorphicVarients(\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n): Varient[] {\n const varients = findVarients(spec, schemas);\n // prepend '-' to prevent key sortings\n return Object.values(groupBy(varients, (it) => '-' + it.position)).map(\n (group) => {\n return (group ?? [])[0];\n },\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,cAAc;AAOhC,SAAS,WAAW,SAAS,OAAO,kBAAkB;AAEtD,SAAS,mBAAmB;AAc5B,MAAM,qBAAqB,CACzB,MACA,YACG;AACH,QAAM,SAAS,QAAQ,OAUrB,CAAC,KAAK,QAAQ,UAAU;AACxB,QAAI,MAAM,MAAM,GAAG;AACjB,YAAM,aAAa,WAAyB,MAAM,MAAM;AACxD,YAAM,CAACA,KAAI,IAAI,YAAY,YAAY,KAAK;AAC5C,UAAIA,KAAI,MAAM,CAAC;AACf,UAAIA,KAAI,EAAE,KAAK,EAAE,QAAQ,YAAY,UAAU,MAAM,CAAC;AACtD,aAAO;AAAA,IACT;AAEA,QAA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E3C,SAAO,OAAO,OAAO,QAAQ,UAAU,CAAC,OAAO,MAAM,GAAG,QAAQ,CAAC,EAAE;AAAA,IACjE,CAAC,UAAU;AACT,cAAQ,SAAS,CAAC,GAAG,CAAC;AAAA,IACxB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["type", "schemas", "schema"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import type { OperationObject, PathItemObject } from 'openapi3-ts/oas31';
|
|
2
|
+
import { type Method } from '@sdk-it/core/paths.js';
|
|
1
3
|
import type { IR, OperationEntry, TunedOperationObject } from './types.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
export interface IteratedOperation {
|
|
5
|
+
entry: Omit<OperationEntry, 'method' | 'tag'> & {
|
|
6
|
+
method: Method;
|
|
7
|
+
tag?: string;
|
|
8
|
+
};
|
|
9
|
+
operation: OperationObject;
|
|
10
|
+
pathItem: PathItemObject;
|
|
11
|
+
}
|
|
12
|
+
export declare function iterateOperations(spec: IR): Generator<IteratedOperation>;
|
|
5
13
|
export declare function forEachOperation<T>(spec: IR, callback: (entry: OperationEntry, operation: TunedOperationObject) => T): T[];
|
|
6
14
|
//# sourceMappingURL=for-each-operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"for-each-operation.d.ts","sourceRoot":"","sources":["../../src/lib/for-each-operation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"for-each-operation.d.ts","sourceRoot":"","sources":["../../src/lib/for-each-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,KAAK,CAAC,GAAG;QAC9C,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,SAAS,EAAE,eAAe,CAAC;IAC3B,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,wBAAiB,iBAAiB,CAAC,IAAI,EAAE,EAAE,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAmBzE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,EAAE,EACR,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,oBAAoB,KAAK,CAAC,OASxE"}
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { methods } from "@sdk-it/core/paths.js";
|
|
2
|
-
function
|
|
3
|
-
const result = [];
|
|
2
|
+
function* iterateOperations(spec) {
|
|
4
3
|
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
5
|
-
for (const
|
|
6
|
-
|
|
4
|
+
for (const method of methods) {
|
|
5
|
+
const operation = pathItem[method];
|
|
6
|
+
if (!operation) {
|
|
7
7
|
continue;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
9
|
+
yield {
|
|
10
|
+
entry: {
|
|
11
|
+
method,
|
|
12
|
+
path,
|
|
13
|
+
tag: operation.tags?.[0]
|
|
14
|
+
},
|
|
15
|
+
operation,
|
|
16
|
+
pathItem
|
|
17
|
+
};
|
|
19
18
|
}
|
|
20
19
|
}
|
|
20
|
+
}
|
|
21
|
+
function forEachOperation(spec, callback) {
|
|
22
|
+
const result = [];
|
|
23
|
+
for (const { entry, operation } of iterateOperations(spec)) {
|
|
24
|
+
result.push(
|
|
25
|
+
callback(entry, operation)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
21
28
|
return result;
|
|
22
29
|
}
|
|
23
30
|
export {
|
|
24
|
-
forEachOperation
|
|
31
|
+
forEachOperation,
|
|
32
|
+
iterateOperations
|
|
25
33
|
};
|
|
26
34
|
//# sourceMappingURL=for-each-operation.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/for-each-operation.ts"],
|
|
4
|
-
"sourcesContent": ["\nimport { type Method, methods } from '@sdk-it/core/paths.js';\n\nimport type { IR, OperationEntry, TunedOperationObject } from './types.js';\n\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { OperationObject, PathItemObject } from 'openapi3-ts/oas31';\n\nimport { type Method, methods } from '@sdk-it/core/paths.js';\n\nimport type { IR, OperationEntry, TunedOperationObject } from './types.js';\n\nexport interface IteratedOperation {\n entry: Omit<OperationEntry, 'method' | 'tag'> & {\n method: Method;\n tag?: string;\n };\n operation: OperationObject;\n pathItem: PathItemObject;\n}\n\nexport function* iterateOperations(spec: IR): Generator<IteratedOperation> {\n for (const [path, pathItem] of Object.entries(spec.paths)) {\n for (const method of methods) {\n const operation = pathItem[method];\n if (!operation) {\n continue;\n }\n\n yield {\n entry: {\n method,\n path,\n tag: operation.tags?.[0],\n },\n operation,\n pathItem,\n };\n }\n }\n}\n\nexport function forEachOperation<T>(\n spec: IR,\n callback: (entry: OperationEntry, operation: TunedOperationObject) => T,\n) {\n const result: T[] = [];\n for (const { entry, operation } of iterateOperations(spec)) {\n result.push(\n callback(entry as OperationEntry, operation as TunedOperationObject),\n );\n }\n return result;\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAsB,eAAe;AAa9B,UAAU,kBAAkB,MAAwC;AACzE,aAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,KAAK,KAAK,GAAG;AACzD,eAAW,UAAU,SAAS;AAC5B,YAAM,YAAY,SAAS,MAAM;AACjC,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AAEA,YAAM;AAAA,QACJ,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,KAAK,UAAU,OAAO,CAAC;AAAA,QACzB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,iBACd,MACA,UACA;AACA,QAAM,SAAc,CAAC;AACrB,aAAW,EAAE,OAAO,UAAU,KAAK,kBAAkB,IAAI,GAAG;AAC1D,WAAO;AAAA,MACL,SAAS,OAAyB,SAAiC;AAAA,IACrE;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-name.d.ts","sourceRoot":"","sources":["../../src/lib/format-name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format-name.d.ts","sourceRoot":"","sources":["../../src/lib/format-name.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,UAAU,GAAI,IAAI,GAAG,KAAG,MAuCpC,CAAC"}
|
package/dist/lib/format-name.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/format-name.ts"],
|
|
4
|
-
"sourcesContent": ["const reservedWords = new Set([\n 'abstract',\n 'as',\n 'assert',\n 'async',\n 'await',\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'default',\n 'deferred',\n 'do',\n 'dynamic',\n 'else',\n 'enum',\n 'export',\n 'extends',\n 'extension',\n 'external',\n 'factory',\n 'final',\n 'finally',\n 'for',\n 'Function',\n 'get',\n 'set',\n 'hide',\n 'if',\n 'default',\n 'new',\n 'implements',\n 'import',\n 'in',\n 'interface',\n 'is',\n 'library',\n 'mixin',\n 'new',\n 'null',\n 'on',\n 'operator',\n 'part',\n 'required',\n 'rethrow',\n 'return',\n 'hide',\n 'show',\n]);\nconst
|
|
5
|
-
"mappings": "AAAA,MAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,MAAM,
|
|
4
|
+
"sourcesContent": ["const reservedWords = new Set([\n 'abstract',\n 'as',\n 'assert',\n 'async',\n 'await',\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'default',\n 'deferred',\n 'do',\n 'dynamic',\n 'else',\n 'enum',\n 'export',\n 'extends',\n 'extension',\n 'external',\n 'factory',\n 'final',\n 'finally',\n 'for',\n 'Function',\n 'get',\n 'set',\n 'hide',\n 'if',\n 'default',\n 'new',\n 'implements',\n 'import',\n 'in',\n 'interface',\n 'is',\n 'library',\n 'mixin',\n 'new',\n 'null',\n 'on',\n 'operator',\n 'part',\n 'required',\n 'rethrow',\n 'return',\n 'hide',\n 'show',\n]);\nconst STARTS_WITH_DIGITS_PATTERN = /^-?\\d/;\nconst FIRST_DASH = /^_/;\nconst LAST_DASH = /_$/;\nconst ONLY_ENGLISH = /(^\\$)|(\\+)|(-)|[^A-Za-z0-9]+/g;\n\nexport const formatName = (it: any): string => {\n if (reservedWords.has(it)) {\n return `$${it}`;\n }\n\n // 1. Handle numbers\n if (typeof it === 'number') {\n if (Math.sign(it) === -1) {\n return `$_${Math.abs(it)}`;\n }\n return `$${it}`;\n }\n\n // 3. Handle other strings\n if (typeof it === 'string') {\n // 3a. Check if the string starts with a digit FIRST\n if (STARTS_WITH_DIGITS_PATTERN.test(it)) {\n if (Math.sign(parseInt(it, 10)) === -1) {\n // if negative number, prefix with $_\n return `$_${Math.abs(parseInt(it, 10))}`;\n }\n // positive number or string starting with digit, prefix with $\n return `$${it}`;\n }\n\n return it\n .replace(ONLY_ENGLISH, (match) => {\n if (match === '-' && match === it[0]) return 'desc_';\n if (match === '+') return '_plus_';\n if (match === '$' && match === it[0]) return '$';\n return '_';\n })\n .replace(FIRST_DASH, '')\n .replace(LAST_DASH, '');\n }\n\n // 4. Fallback for any other types (e.g., null, undefined, objects)\n // Convert to string first, then apply snakecase\n return String(it);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,MAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,MAAM,6BAA6B;AACnC,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,eAAe;AAEd,MAAM,aAAa,CAAC,OAAoB;AAC7C,MAAI,cAAc,IAAI,EAAE,GAAG;AACzB,WAAO,IAAI,EAAE;AAAA,EACf;AAGA,MAAI,OAAO,OAAO,UAAU;AAC1B,QAAI,KAAK,KAAK,EAAE,MAAM,IAAI;AACxB,aAAO,KAAK,KAAK,IAAI,EAAE,CAAC;AAAA,IAC1B;AACA,WAAO,IAAI,EAAE;AAAA,EACf;AAGA,MAAI,OAAO,OAAO,UAAU;AAE1B,QAAI,2BAA2B,KAAK,EAAE,GAAG;AACvC,UAAI,KAAK,KAAK,SAAS,IAAI,EAAE,CAAC,MAAM,IAAI;AAEtC,eAAO,KAAK,KAAK,IAAI,SAAS,IAAI,EAAE,CAAC,CAAC;AAAA,MACxC;AAEA,aAAO,IAAI,EAAE;AAAA,IACf;AAEA,WAAO,GACJ,QAAQ,cAAc,CAAC,UAAU;AAChC,UAAI,UAAU,OAAO,UAAU,GAAG,CAAC,EAAG,QAAO;AAC7C,UAAI,UAAU,IAAK,QAAO;AAC1B,UAAI,UAAU,OAAO,UAAU,GAAG,CAAC,EAAG,QAAO;AAC7C,aAAO;AAAA,IACT,CAAC,EACA,QAAQ,YAAY,EAAE,EACtB,QAAQ,WAAW,EAAE;AAAA,EAC1B;AAIA,SAAO,OAAO,EAAE;AAClB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/ir.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GenerateSdkConfig } from './options.js';
|
|
2
2
|
import type { IR } from './types.js';
|
|
3
|
-
export declare function toIR(config: GenerateSdkConfig, verbose?: boolean): IR
|
|
3
|
+
export declare function toIR(config: GenerateSdkConfig, verbose?: boolean): Promise<IR>;
|
|
4
4
|
//# sourceMappingURL=ir.d.ts.map
|
package/dist/lib/ir.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../../src/lib/ir.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../../src/lib/ir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,wBAAsB,IAAI,CACxB,MAAM,EAAE,iBAAiB,EACzB,OAAO,UAAQ,GACd,OAAO,CAAC,EAAE,CAAC,CAIb"}
|
package/dist/lib/ir.js
CHANGED
|
@@ -1,123 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./options.js";
|
|
8
|
-
import { extractOverviewDocs } from "./overview-docs/overview-docs.js";
|
|
9
|
-
import { toPagination } from "./pagination/pagination.js";
|
|
10
|
-
import { tuneRequestBody } from "./tune-request-body.js";
|
|
11
|
-
import { resolveResponses } from "./tune-response.js";
|
|
12
|
-
import { expandSpec, fixSpec } from "./tune.js";
|
|
13
|
-
function findUniqueOperationId(usedOperationIds, initialId, choices, formatter) {
|
|
14
|
-
let counter = 1;
|
|
15
|
-
let uniqueOperationId = formatter(initialId);
|
|
16
|
-
while (usedOperationIds.has(uniqueOperationId)) {
|
|
17
|
-
const prependIndex = Math.min(counter - 1, choices.length - 1);
|
|
18
|
-
const prefix = choices[prependIndex];
|
|
19
|
-
if (prependIndex < choices.length - 1) {
|
|
20
|
-
uniqueOperationId = formatter(
|
|
21
|
-
`${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}`
|
|
22
|
-
);
|
|
23
|
-
} else {
|
|
24
|
-
uniqueOperationId = formatter(
|
|
25
|
-
`${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}${counter - choices.length + 1}`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
counter++;
|
|
29
|
-
}
|
|
30
|
-
return uniqueOperationId;
|
|
31
|
-
}
|
|
32
|
-
function toIR(config, verbose = false) {
|
|
33
|
-
const coercedConfig = coerceConfig(config);
|
|
34
|
-
if ("x-sdk-augmented" in config.spec) {
|
|
35
|
-
return config.spec;
|
|
36
|
-
}
|
|
37
|
-
const paths = {};
|
|
38
|
-
const usedOperationIds = /* @__PURE__ */ new Set();
|
|
39
|
-
for (const [path, pathItem] of Object.entries(coercedConfig.spec.paths)) {
|
|
40
|
-
const fixedPath = path.replace(/:([^/]+)/g, "{$1}");
|
|
41
|
-
for (const [method, operation] of Object.entries(pathItem)) {
|
|
42
|
-
if (!methods.includes(method)) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const { name } = toResource(operation, fixedPath, method);
|
|
46
|
-
const operationTag = coercedConfig.tag(operation, fixedPath);
|
|
47
|
-
const operationId = findUniqueOperationId(
|
|
48
|
-
usedOperationIds,
|
|
49
|
-
coercedConfig.operationId(operation, fixedPath, method),
|
|
50
|
-
[operationTag, method, fixedPath.split("/").filter(Boolean).join("")],
|
|
51
|
-
(id) => coercedConfig.operationId(
|
|
52
|
-
{ ...operation, operationId: id },
|
|
53
|
-
fixedPath,
|
|
54
|
-
method
|
|
55
|
-
)
|
|
56
|
-
);
|
|
57
|
-
usedOperationIds.add(operationId);
|
|
58
|
-
const parameters = [
|
|
59
|
-
...pathItem.parameters ?? [],
|
|
60
|
-
...operation.parameters ?? []
|
|
61
|
-
].map((it) => resolveRef(coercedConfig.spec, it));
|
|
62
|
-
const tunedOperation = {
|
|
63
|
-
...operation,
|
|
64
|
-
parameters,
|
|
65
|
-
"x-fn-name": name,
|
|
66
|
-
"x-fn-group": operationTag,
|
|
67
|
-
tags: [snakecase(operationTag)],
|
|
68
|
-
// todo: do not transfer casing unless tag cannot be valid identifier
|
|
69
|
-
operationId,
|
|
70
|
-
responses: resolveResponses(
|
|
71
|
-
coercedConfig.spec,
|
|
72
|
-
operationId,
|
|
73
|
-
operation,
|
|
74
|
-
coercedConfig.responses
|
|
75
|
-
),
|
|
76
|
-
requestBody: tuneRequestBody(
|
|
77
|
-
coercedConfig.spec,
|
|
78
|
-
operationId,
|
|
79
|
-
// camelcase(`${name} ${operationTag}`),
|
|
80
|
-
operation,
|
|
81
|
-
parameters,
|
|
82
|
-
operation.security ?? []
|
|
83
|
-
)
|
|
84
|
-
};
|
|
85
|
-
if (coercedConfig.pagination.enabled) {
|
|
86
|
-
if (coercedConfig.pagination.guess) {
|
|
87
|
-
tunedOperation["x-pagination"] = toPagination(
|
|
88
|
-
coercedConfig.spec,
|
|
89
|
-
tunedOperation
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
delete tunedOperation["x-pagination"];
|
|
94
|
-
}
|
|
95
|
-
Object.assign(paths, {
|
|
96
|
-
[fixedPath]: {
|
|
97
|
-
...paths[fixedPath],
|
|
98
|
-
[method]: tunedOperation
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
fixSpec(
|
|
104
|
-
coercedConfig.spec,
|
|
105
|
-
Object.values(coercedConfig.spec.components.schemas)
|
|
106
|
-
);
|
|
107
|
-
if (verbose) {
|
|
108
|
-
const newRefs = [];
|
|
109
|
-
expandSpec(
|
|
110
|
-
coercedConfig.spec,
|
|
111
|
-
coercedConfig.spec.components.schemas,
|
|
112
|
-
newRefs
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
...coercedConfig.spec,
|
|
117
|
-
paths,
|
|
118
|
-
"x-docs": extractOverviewDocs(coercedConfig.spec),
|
|
119
|
-
"x-sdk-augmented": true
|
|
120
|
-
};
|
|
1
|
+
import { createDefaultProcessingPlugins } from "./processing-plugins/index.js";
|
|
2
|
+
import { processSpec } from "./processing.js";
|
|
3
|
+
async function toIR(config, verbose = false) {
|
|
4
|
+
const plugins = config.plugins ?? createDefaultProcessingPlugins({ verbose });
|
|
5
|
+
const result = await processSpec({ ...config, plugins });
|
|
6
|
+
return result.spec;
|
|
121
7
|
}
|
|
122
8
|
export {
|
|
123
9
|
toIR
|
package/dist/lib/ir.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/ir.ts"],
|
|
4
|
-
"sourcesContent": ["import type {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { GenerateSdkConfig } from './options.js';\nimport { createDefaultProcessingPlugins } from './processing-plugins/index.js';\nimport { processSpec } from './processing.js';\nimport type { IR } from './types.js';\n\nexport async function toIR(\n config: GenerateSdkConfig,\n verbose = false,\n): Promise<IR> {\n const plugins = config.plugins ?? createDefaultProcessingPlugins({ verbose });\n const result = await processSpec({ ...config, plugins });\n return result.spec;\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,sCAAsC;AAC/C,SAAS,mBAAmB;AAG5B,eAAsB,KACpB,QACA,UAAU,OACG;AACb,QAAM,UAAU,OAAO,WAAW,+BAA+B,EAAE,QAAQ,CAAC;AAC5E,QAAM,SAAS,MAAM,YAAY,EAAE,GAAG,QAAQ,QAAQ,CAAC;AACvD,SAAO,OAAO;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/is.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../src/lib/is.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAET;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../src/lib/is.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAET;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAkET;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAMxE;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CActE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,iBAuB1E;AAED,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAiBT;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAoBT"}
|
package/dist/lib/is.js
CHANGED
|
@@ -63,9 +63,7 @@ function isBinaryContentType(contentType) {
|
|
|
63
63
|
}
|
|
64
64
|
function isSuccessStatusCode(statusCode) {
|
|
65
65
|
if (typeof statusCode === "string") {
|
|
66
|
-
|
|
67
|
-
const status = Number(statusCode);
|
|
68
|
-
return status >= 200 && status < 300 || status >= 2 && statusGroup <= 3;
|
|
66
|
+
return /^2(?:\d{2}|xx)$/i.test(statusCode.trim());
|
|
69
67
|
}
|
|
70
68
|
statusCode = Number(statusCode);
|
|
71
69
|
return statusCode >= 200 && statusCode < 300;
|
package/dist/lib/is.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/is.ts"],
|
|
4
|
-
"sourcesContent": ["export function isStreamingContentType(\n contentType: string | null | undefined,\n): boolean {\n return contentType === 'application/octet-stream';\n}\n\nexport function isBinaryContentType(\n contentType: string | null | undefined,\n): boolean {\n if (!contentType) {\n return false;\n }\n\n let mainType = contentType.trim();\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n mainType = mainType.substring(0, semicolonIndex).trim();\n }\n mainType = mainType.toLowerCase();\n\n if (mainType.startsWith('text/')) {\n return false;\n }\n if (mainType.endsWith('/json') || mainType.endsWith('+json')) {\n return false;\n }\n if (mainType.endsWith('/xml') || mainType.endsWith('+xml')) {\n return false;\n }\n if (mainType === 'application/xml' || mainType === 'text/xml') {\n return false;\n }\n if (\n mainType === 'application/x-www-form-urlencoded' ||\n mainType === 'multipart/form-data'\n ) {\n return false;\n }\n\n if (mainType.startsWith('image/')) {\n return true;\n }\n if (mainType.startsWith('audio/')) {\n return true;\n }\n if (mainType.startsWith('video/')) {\n return true;\n }\n if (mainType === 'application/pdf') {\n return true;\n }\n if (mainType === 'application/zip') {\n return true;\n }\n if (mainType === 'application/gzip') {\n return true;\n }\n if (mainType === 'application/x-7z-compressed') {\n return true;\n }\n if (mainType === 'application/x-tar') {\n return true;\n }\n if (
|
|
5
|
-
"mappings": "AAAO,SAAS,uBACd,aACS;AACT,SAAO,gBAAgB;AACzB;AAEO,SAAS,oBACd,aACS;AACT,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,YAAY,KAAK;AAChC,QAAM,iBAAiB,SAAS,QAAQ,GAAG;AAC3C,MAAI,mBAAmB,IAAI;AACzB,eAAW,SAAS,UAAU,GAAG,cAAc,EAAE,KAAK;AAAA,EACxD;AACA,aAAW,SAAS,YAAY;AAEhC,MAAI,SAAS,WAAW,OAAO,GAAG;AAChC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,SAAS,OAAO,KAAK,SAAS,SAAS,OAAO,GAAG;AAC5D,WAAO;AAAA,EACT;AACA,MAAI,SAAS,SAAS,MAAM,KAAK,SAAS,SAAS,MAAM,GAAG;AAC1D,WAAO;AAAA,EACT;AACA,MAAI,aAAa,qBAAqB,aAAa,YAAY;AAC7D,WAAO;AAAA,EACT;AACA,MACE,aAAa,uCACb,aAAa,uBACb;AACA,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,WAAW,QAAQ,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,WAAW,QAAQ,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,WAAW,QAAQ,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,aAAa,mBAAmB;AAClC,WAAO;AAAA,EACT;AACA,MAAI,aAAa,mBAAmB;AAClC,WAAO;AAAA,EACT;AACA,MAAI,aAAa,oBAAoB;AACnC,WAAO;AAAA,EACT;AACA,MAAI,aAAa,+BAA+B;AAC9C,WAAO;AAAA,EACT;AACA,MAAI,aAAa,qBAAqB;AACpC,WAAO;AAAA,EACT;AACA,
|
|
4
|
+
"sourcesContent": ["export function isStreamingContentType(\n contentType: string | null | undefined,\n): boolean {\n return contentType === 'application/octet-stream';\n}\n\nexport function isBinaryContentType(\n contentType: string | null | undefined,\n): boolean {\n if (!contentType) {\n return false;\n }\n\n let mainType = contentType.trim();\n const semicolonIndex = mainType.indexOf(';');\n if (semicolonIndex !== -1) {\n mainType = mainType.substring(0, semicolonIndex).trim();\n }\n mainType = mainType.toLowerCase();\n\n if (mainType.startsWith('text/')) {\n return false;\n }\n if (mainType.endsWith('/json') || mainType.endsWith('+json')) {\n return false;\n }\n if (mainType.endsWith('/xml') || mainType.endsWith('+xml')) {\n return false;\n }\n if (mainType === 'application/xml' || mainType === 'text/xml') {\n return false;\n }\n if (\n mainType === 'application/x-www-form-urlencoded' ||\n mainType === 'multipart/form-data'\n ) {\n return false;\n }\n\n if (mainType.startsWith('image/')) {\n return true;\n }\n if (mainType.startsWith('audio/')) {\n return true;\n }\n if (mainType.startsWith('video/')) {\n return true;\n }\n if (mainType === 'application/pdf') {\n return true;\n }\n if (mainType === 'application/zip') {\n return true;\n }\n if (mainType === 'application/gzip') {\n return true;\n }\n if (mainType === 'application/x-7z-compressed') {\n return true;\n }\n if (mainType === 'application/x-tar') {\n return true;\n }\n if (mainType.startsWith('application/vnd.openxmlformats-officedocument.')) {\n return true;\n }\n if (mainType.startsWith('application/vnd.ms-')) {\n return true;\n }\n if (mainType === 'application/msword') {\n return true;\n }\n\n return false;\n}\n\nexport function isSuccessStatusCode(statusCode: number | string): boolean {\n if (typeof statusCode === 'string') {\n return /^2(?:\\d{2}|xx)$/i.test(statusCode.trim());\n }\n statusCode = Number(statusCode);\n return statusCode >= 200 && statusCode < 300;\n}\n\nexport function isErrorStatusCode(statusCode: number | string): boolean {\n if (typeof statusCode === 'string') {\n const statusGroup = +statusCode.slice(0, 1);\n const status = Number(statusCode);\n return (\n status < 200 ||\n status >= 300 ||\n statusGroup >= 4 ||\n statusGroup === 0 ||\n statusGroup === 1\n );\n }\n statusCode = Number(statusCode);\n return statusCode < 200 || statusCode >= 300;\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\nexport function isTextContentType(\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 // 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 // 3. Convert the main type part to lowercase for case-insensitive comparison\n mainType = mainType.toLowerCase();\n // 4. Compare against the standard text MIME types\n return mainType.startsWith('text/'); // Catch-all for other text/* types\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"],
|
|
5
|
+
"mappings": "AAAO,SAAS,uBACd,aACS;AACT,SAAO,gBAAgB;AACzB;AAEO,SAAS,oBACd,aACS;AACT,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,YAAY,KAAK;AAChC,QAAM,iBAAiB,SAAS,QAAQ,GAAG;AAC3C,MAAI,mBAAmB,IAAI;AACzB,eAAW,SAAS,UAAU,GAAG,cAAc,EAAE,KAAK;AAAA,EACxD;AACA,aAAW,SAAS,YAAY;AAEhC,MAAI,SAAS,WAAW,OAAO,GAAG;AAChC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,SAAS,OAAO,KAAK,SAAS,SAAS,OAAO,GAAG;AAC5D,WAAO;AAAA,EACT;AACA,MAAI,SAAS,SAAS,MAAM,KAAK,SAAS,SAAS,MAAM,GAAG;AAC1D,WAAO;AAAA,EACT;AACA,MAAI,aAAa,qBAAqB,aAAa,YAAY;AAC7D,WAAO;AAAA,EACT;AACA,MACE,aAAa,uCACb,aAAa,uBACb;AACA,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,WAAW,QAAQ,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,WAAW,QAAQ,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,WAA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AS,MAAM,GAAG,EAAE,CAAC;AAAA,EAC9B,WAAW,SAAS,SAAS,OAAO,GAAG;AACrC,WAAO,SAAS,MAAM,GAAG,EAAE,CAAC;AAAA,EAC9B;AACA,SAAO;AACT;AAEO,SAAS,kBACd,aACS;AACT,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,YAAY,KAAK;AAEhC,QAAM,iBAAiB,SAAS,QAAQ,GAAG;AAC3C,MAAI,mBAAmB,IAAI;AAEzB,eAAW,SAAS,UAAU,GAAG,cAAc,EAAE,KAAK;AAAA,EACxD;AAEA,aAAW,SAAS,YAAY;AAEhC,SAAO,SAAS,WAAW,OAAO;AACpC;AASO,SAAS,iBACd,aACS;AACT,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,YAAY,KAAK;AAGhC,QAAM,iBAAiB,SAAS,QAAQ,GAAG;AAC3C,MAAI,mBAAmB,IAAI;AAEzB,eAAW,SAAS,UAAU,GAAG,cAAc,EAAE,KAAK;AAAA,EACxD;AAGA,aAAW,SAAS,YAAY;AAGhC,SAAO,aAAa;AACtB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postman-converter.d.ts","sourceRoot":"","sources":["../../../../src/lib/loaders/postman/postman-converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,aAAa,EASd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAQV,iBAAiB,EAOlB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"postman-converter.d.ts","sourceRoot":"","sources":["../../../../src/lib/loaders/postman/postman-converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,aAAa,EASd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAQV,iBAAiB,EAOlB,MAAM,cAAc,CAAC;AA2jBtB,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iBAAiB,GAC5B,aAAa,CA6Bf"}
|
|
@@ -272,7 +272,7 @@ function requestToOperation(item, securitySchemes) {
|
|
|
272
272
|
const contentTypeIdx = headers.findIndex(
|
|
273
273
|
(h) => h.key.toLowerCase() === "content-type"
|
|
274
274
|
);
|
|
275
|
-
|
|
275
|
+
if (acceptHeaderIdx !== -1) headers.splice(acceptHeaderIdx, 1);
|
|
276
276
|
const [contentTypeValue] = contentTypeIdx !== -1 ? headers.splice(contentTypeIdx, 1).map((h) => h.value) : [];
|
|
277
277
|
let security;
|
|
278
278
|
if (item.request.auth) {
|
|
@@ -320,16 +320,6 @@ function requestToOperation(item, securitySchemes) {
|
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
|
-
function inferSchemaType(value) {
|
|
324
|
-
if (!value) return { type: "string" };
|
|
325
|
-
if (!isNaN(Number(value))) {
|
|
326
|
-
return { type: "number" };
|
|
327
|
-
}
|
|
328
|
-
if (value === "true" || value === "false") {
|
|
329
|
-
return { type: "boolean" };
|
|
330
|
-
}
|
|
331
|
-
return { type: "string" };
|
|
332
|
-
}
|
|
333
323
|
function requestBodyToOperationBody(contentType, body) {
|
|
334
324
|
if (body.mode === "raw") {
|
|
335
325
|
return {
|