@sdk-it/spec 0.46.10 → 0.47.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/README.md +8 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +2 -2
- package/dist/lib/external-documents.d.ts +10 -0
- package/dist/lib/external-documents.d.ts.map +1 -0
- package/dist/lib/external-documents.js +61 -0
- package/dist/lib/external-documents.js.map +7 -0
- package/dist/lib/finalize-operations.d.ts +8 -0
- package/dist/lib/finalize-operations.d.ts.map +1 -0
- package/dist/lib/finalize-operations.js +134 -0
- package/dist/lib/finalize-operations.js.map +7 -0
- package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
- package/dist/lib/find-polymorphic-varients.js +3 -2
- package/dist/lib/find-polymorphic-varients.js.map +2 -2
- package/dist/lib/find-unique-schema-name.d.ts.map +1 -1
- package/dist/lib/for-each-operation.d.ts +3 -2
- package/dist/lib/for-each-operation.d.ts.map +1 -1
- package/dist/lib/for-each-operation.js +9 -4
- package/dist/lib/for-each-operation.js.map +2 -2
- package/dist/lib/format-name.d.ts.map +1 -1
- package/dist/lib/get-ref-usage.d.ts.map +1 -1
- package/dist/lib/get-ref-usage.js +1 -2
- package/dist/lib/get-ref-usage.js.map +2 -2
- package/dist/lib/guess/guess-resource.d.ts.map +1 -1
- package/dist/lib/guess/guess-resource.js +4 -4
- package/dist/lib/guess/guess-resource.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 +5 -3
- package/dist/lib/ir.js.map +2 -2
- package/dist/lib/is-primitive-schema.d.ts +12 -0
- package/dist/lib/is-primitive-schema.d.ts.map +1 -1
- package/dist/lib/is-primitive-schema.js +34 -1
- package/dist/lib/is-primitive-schema.js.map +2 -2
- package/dist/lib/is.d.ts +10 -1
- package/dist/lib/is.d.ts.map +1 -1
- package/dist/lib/is.js +20 -9
- package/dist/lib/is.js.map +2 -2
- package/dist/lib/loaders/load-spec.d.ts +9 -2
- package/dist/lib/loaders/load-spec.d.ts.map +1 -1
- package/dist/lib/loaders/load-spec.js +15 -20
- package/dist/lib/loaders/load-spec.js.map +2 -2
- package/dist/lib/loaders/local-loader.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.d.ts +1 -1
- package/dist/lib/loaders/postman/postman-converter.d.ts.map +1 -1
- package/dist/lib/loaders/postman/postman-converter.js +2 -3
- package/dist/lib/loaders/postman/postman-converter.js.map +2 -2
- package/dist/lib/loaders/postman/spec-types.d.ts.map +1 -1
- package/dist/lib/loaders/remote-loader.d.ts.map +1 -1
- package/dist/lib/loaders/remote-loader.js +4 -3
- package/dist/lib/loaders/remote-loader.js.map +2 -2
- package/dist/lib/metadata.d.ts +3 -9
- package/dist/lib/metadata.d.ts.map +1 -1
- package/dist/lib/metadata.js +22 -17
- package/dist/lib/metadata.js.map +2 -2
- package/dist/lib/operation-input.d.ts +33 -0
- package/dist/lib/operation-input.d.ts.map +1 -0
- package/dist/lib/operation-input.js +189 -0
- package/dist/lib/operation-input.js.map +7 -0
- package/dist/lib/options.d.ts +5 -6
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +0 -6
- package/dist/lib/options.js.map +2 -2
- package/dist/lib/overview-docs/doc-text-utils.d.ts +13 -13
- package/dist/lib/overview-docs/doc-text-utils.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-auth.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-auth.js.map +2 -2
- package/dist/lib/overview-docs/overview-docs.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-errors.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-errors.js +8 -5
- package/dist/lib/overview-docs/overview-errors.js.map +2 -2
- package/dist/lib/overview-docs/overview-page.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-page.js +2 -3
- package/dist/lib/overview-docs/overview-page.js.map +2 -2
- package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-sdks.d.ts.map +1 -1
- package/dist/lib/overview-docs/overview-sdks.js +2 -1
- package/dist/lib/overview-docs/overview-sdks.js.map +2 -2
- package/dist/lib/overview-docs/types.d.ts.map +1 -1
- package/dist/lib/overview-docs/types.js +1 -1
- package/dist/lib/overview-docs/types.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 +3 -3
- package/dist/lib/pagination/pagination-result.d.ts.map +1 -1
- package/dist/lib/pagination/pagination-result.js +6 -3
- package/dist/lib/pagination/pagination-result.js.map +2 -2
- package/dist/lib/pagination/pagination.d.ts +31 -1
- package/dist/lib/pagination/pagination.d.ts.map +1 -1
- package/dist/lib/pagination/pagination.js +30 -11
- package/dist/lib/pagination/pagination.js.map +2 -2
- package/dist/lib/processing-plugins/bundle-external-refs.d.ts +17 -0
- package/dist/lib/processing-plugins/bundle-external-refs.d.ts.map +1 -0
- package/dist/lib/processing-plugins/bundle-external-refs.js +241 -0
- package/dist/lib/processing-plugins/bundle-external-refs.js.map +7 -0
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts +2 -2
- package/dist/lib/processing-plugins/canonicalize-spec.d.ts.map +1 -1
- package/dist/lib/processing-plugins/canonicalize-spec.js.map +2 -2
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts +4 -3
- package/dist/lib/processing-plugins/create-default-processing-plugins.d.ts.map +1 -1
- package/dist/lib/processing-plugins/create-default-processing-plugins.js +10 -3
- package/dist/lib/processing-plugins/create-default-processing-plugins.js.map +2 -2
- package/dist/lib/processing-plugins/enrich-examples.d.ts +4 -4
- package/dist/lib/processing-plugins/enrich-examples.d.ts.map +1 -1
- package/dist/lib/processing-plugins/enrich-examples.js +1 -1
- package/dist/lib/processing-plugins/enrich-examples.js.map +2 -2
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts +2 -2
- package/dist/lib/processing-plugins/extract-inline-schemas.d.ts.map +1 -1
- package/dist/lib/processing-plugins/extract-inline-schemas.js.map +2 -2
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts +2 -2
- package/dist/lib/processing-plugins/extract-overview-docs.d.ts.map +1 -1
- package/dist/lib/processing-plugins/extract-overview-docs.js +4 -1
- package/dist/lib/processing-plugins/extract-overview-docs.js.map +2 -2
- package/dist/lib/processing-plugins/index.d.ts +1 -0
- package/dist/lib/processing-plugins/index.d.ts.map +1 -1
- package/dist/lib/processing-plugins/index.js +1 -0
- package/dist/lib/processing-plugins/index.js.map +2 -2
- package/dist/lib/processing-plugins/infer-pagination.d.ts +2 -2
- package/dist/lib/processing-plugins/infer-pagination.d.ts.map +1 -1
- package/dist/lib/processing-plugins/infer-pagination.js +5 -6
- package/dist/lib/processing-plugins/infer-pagination.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-operation-ids.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-operation-ids.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-parameters.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-parameters.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-parameters.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-paths.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-paths.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-paths.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts +9 -3
- package/dist/lib/processing-plugins/normalize-request-bodies.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-request-bodies.js +36 -15
- package/dist/lib/processing-plugins/normalize-request-bodies.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-responses.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-responses.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-responses.js +11 -15
- package/dist/lib/processing-plugins/normalize-responses.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-schemas.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-schemas.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-schemas.js +14 -4
- package/dist/lib/processing-plugins/normalize-schemas.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-security.d.ts +2 -2
- package/dist/lib/processing-plugins/normalize-security.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-security.js +6 -5
- package/dist/lib/processing-plugins/normalize-security.js.map +2 -2
- package/dist/lib/processing-plugins/normalize-tags.d.ts +8 -2
- package/dist/lib/processing-plugins/normalize-tags.d.ts.map +1 -1
- package/dist/lib/processing-plugins/normalize-tags.js +35 -1
- package/dist/lib/processing-plugins/normalize-tags.js.map +2 -2
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.d.ts +13 -2
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.d.ts.map +1 -1
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.js +68 -90
- package/dist/lib/processing-plugins/resolve-security-scheme-uris.js.map +2 -2
- package/dist/lib/processing.d.ts +25 -11
- package/dist/lib/processing.d.ts.map +1 -1
- package/dist/lib/processing.js +53 -16
- package/dist/lib/processing.js.map +2 -2
- package/dist/lib/reserved-keywords.d.ts.map +1 -1
- package/dist/lib/sidebar.d.ts +5 -4
- package/dist/lib/sidebar.d.ts.map +1 -1
- package/dist/lib/sidebar.js +46 -23
- package/dist/lib/sidebar.js.map +2 -2
- package/dist/lib/tag.d.ts.map +1 -1
- package/dist/lib/types.d.ts +34 -12
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +11 -0
- package/dist/lib/types.js.map +3 -3
- package/dist/lib/walk-schemas.d.ts +4 -2
- package/dist/lib/walk-schemas.d.ts.map +1 -1
- package/dist/lib/walk-schemas.js +15 -13
- package/dist/lib/walk-schemas.js.map +2 -2
- package/package.json +17 -6
- package/dist/lib/create-operation.d.ts +0 -28
- package/dist/lib/create-operation.d.ts.map +0 -1
- package/dist/lib/create-operation.js +0 -62
- package/dist/lib/create-operation.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/guess/guess-resource.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OperationObject } from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\n\nimport { type Method } from '@sdk-it/core/paths.js';\n\nimport { cleanOperationId } from '../options.js';\n\nconst HTTP_METHOD_ACTIONS = {\n get: { single: 'get', collection: 'list' },\n post: { single: 'create', collection: 'create' },\n put: { single: 'replace', collection: 'replaceAll' },\n patch: { single: 'update', collection: 'updateMany' },\n delete: { single: 'delete', collection: 'deleteMany' },\n head: { single: 'exists', collection: 'checkList' },\n options: { single: 'options', collection: 'optionsList' },\n trace: { single: 'trace', collection: 'traceList' },\n connect: { single: 'connect', collection: 'connectList' },\n} as const;\n\nfunction extractResourceInfo(path: string): {\n resourceName: string;\n isSingleResource: boolean;\n resourceHierarchy: string[];\n} {\n const pathSegments = path.split('/').filter(Boolean);\n\n
|
|
5
|
-
"mappings": "AACA,SAAS,iBAAiB;AAE1B,eAA4B;AAE5B,SAAS,wBAAwB;AAEjC,MAAM,sBAAsB;AAAA,EAC1B,KAAK,EAAE,QAAQ,OAAO,YAAY,OAAO;AAAA,EACzC,MAAM,EAAE,QAAQ,UAAU,YAAY,SAAS;AAAA,EAC/C,KAAK,EAAE,QAAQ,WAAW,YAAY,aAAa;AAAA,EACnD,OAAO,EAAE,QAAQ,UAAU,YAAY,aAAa;AAAA,EACpD,QAAQ,EAAE,QAAQ,UAAU,YAAY,aAAa;AAAA,EACrD,MAAM,EAAE,QAAQ,UAAU,YAAY,YAAY;AAAA,EAClD,SAAS,EAAE,QAAQ,WAAW,YAAY,cAAc;AAAA,EACxD,OAAO,EAAE,QAAQ,SAAS,YAAY,YAAY;AAAA,EAClD,SAAS,EAAE,QAAQ,WAAW,YAAY,cAAc;AAC1D;AAEA,SAAS,oBAAoB,MAI3B;AACA,QAAM,eAAe,KAAK,MAAM,GAAG,EAAE,OAAO,OAAO;AAEnD,
|
|
4
|
+
"sourcesContent": ["import type { OperationObject } from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\n\nimport { type Method } from '@sdk-it/core/paths.js';\n\nimport { cleanOperationId } from '../options.js';\n\nconst HTTP_METHOD_ACTIONS = {\n get: { single: 'get', collection: 'list' },\n post: { single: 'create', collection: 'create' },\n put: { single: 'replace', collection: 'replaceAll' },\n patch: { single: 'update', collection: 'updateMany' },\n delete: { single: 'delete', collection: 'deleteMany' },\n head: { single: 'exists', collection: 'checkList' },\n options: { single: 'options', collection: 'optionsList' },\n trace: { single: 'trace', collection: 'traceList' },\n connect: { single: 'connect', collection: 'connectList' },\n} as const;\n\nfunction extractResourceInfo(path: string): {\n resourceName: string;\n isSingleResource: boolean;\n resourceHierarchy: string[];\n} {\n const pathSegments = path.split('/').filter(Boolean);\n\n const lastSegment = pathSegments.at(-1);\n\n if (lastSegment === undefined) {\n return {\n resourceName: 'root',\n isSingleResource: false,\n resourceHierarchy: ['root'],\n };\n }\n\n const isSingleResource =\n lastSegment.startsWith('{') && lastSegment.endsWith('}');\n\n // For single resources, use the parent resource name\n // For collections, use the last segment\n let resourceName: string;\n let resourceHierarchy: string[];\n\n if (isSingleResource) {\n // Single resource: /users/{id} -> \"users\"\n const parentSegment = pathSegments[pathSegments.length - 2];\n resourceName = parentSegment || 'item';\n resourceHierarchy = pathSegments\n .filter((segment) => !segment.startsWith('{'))\n .map((segment) => segment.replace(/[{}]/g, ''));\n } else {\n // Collection: /users or /users/active -> \"users\" or \"usersActive\"\n resourceName = lastSegment;\n resourceHierarchy = pathSegments\n .filter((segment) => !segment.startsWith('{'))\n .map((segment) => segment.replace(/[{}]/g, ''));\n }\n\n // Clean and normalize resource name\n const cleanResourceName = resourceName\n .replace(/[{}]/g, '')\n .replace(/[-_]/g, ' ')\n .replace(/[^a-zA-Z0-9\\s]/g, '');\n\n // Generate a hierarchy-based group name for better conflict avoidance\n const hierarchicalName =\n resourceHierarchy.length > 1\n ? resourceHierarchy.join(' ')\n : cleanResourceName;\n\n return {\n resourceName: cleanResourceName || 'resource',\n isSingleResource,\n resourceHierarchy: [hierarchicalName],\n };\n}\n\nfunction guessOperationName(\n method: Method,\n {\n isSingleResource,\n resourceHierarchy,\n }: ReturnType<typeof extractResourceInfo>,\n): { name: string; group: string } {\n const methodAction = HTTP_METHOD_ACTIONS[method];\n\n if (!methodAction) {\n // Fallback for unknown HTTP methods\n const fallbackAction = isSingleResource\n ? method.toLowerCase()\n : `${method.toLowerCase()}All`;\n return {\n name: camelcase(fallbackAction),\n group: camelcase(resourceHierarchy[0]),\n };\n }\n\n const actionName = isSingleResource\n ? methodAction.single\n : methodAction.collection;\n\n // Create more descriptive names for complex paths\n const operationName =\n resourceHierarchy.length > 1 && !isSingleResource\n ? `${actionName} ${resourceHierarchy.slice(-1)[0]}` // e.g., \"list activeUsers\"\n : actionName;\n\n return {\n name: camelcase(operationName),\n group: camelcase(resourceHierarchy[0]),\n };\n}\n\nexport function toResource(\n operation: OperationObject,\n path: string,\n method: Method,\n) {\n // Priority 1: Non-guessed operationId\n const resourceInfo = extractResourceInfo(path);\n if (operation.operationId) {\n return {\n name: cleanOperationId(operation.operationId),\n group: camelcase(resourceInfo.resourceName),\n };\n }\n\n // Priority 2: CRUD operation name\n return guessOperationName(method, resourceInfo);\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,iBAAiB;AAE1B,eAA4B;AAE5B,SAAS,wBAAwB;AAEjC,MAAM,sBAAsB;AAAA,EAC1B,KAAK,EAAE,QAAQ,OAAO,YAAY,OAAO;AAAA,EACzC,MAAM,EAAE,QAAQ,UAAU,YAAY,SAAS;AAAA,EAC/C,KAAK,EAAE,QAAQ,WAAW,YAAY,aAAa;AAAA,EACnD,OAAO,EAAE,QAAQ,UAAU,YAAY,aAAa;AA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A,EACtC;AACF;AAEA,SAAS,mBACP,QACA;AAAA,EACE;AAAA,EACA;AACF,GACiC;AACjC,QAAM,eAAe,oBAAoB,MAAM;AAE/C,MAAI,CAAC,cAAc;AAEjB,UAAM,iBAAiB,mBACnB,OAAO,YAAY,IACnB,GAAG,OAAO,YAAY,CAAC;AAC3B,WAAO;AAAA,MACL,MAAM,UAAU,cAAc;AAAA,MAC9B,OAAO,UAAU,kBAAkB,CAAC,CAAC;AAAA,IACvC;AAAA,EACF;AAEA,QAAM,aAAa,mBACf,aAAa,SACb,aAAa;AAGjB,QAAM,gBACJ,kBAAkB,SAAS,KAAK,CAAC,mBAC7B,GAAG,UAAU,IAAI,kBAAkB,MAAM,EAAE,EAAE,CAAC,CAAC,KAC/C;AAEN,SAAO;AAAA,IACL,MAAM,UAAU,aAAa;AAAA,IAC7B,OAAO,UAAU,kBAAkB,CAAC,CAAC;AAAA,EACvC;AACF;AAEO,SAAS,WACd,WACA,MACA,QACA;AAEA,QAAM,eAAe,oBAAoB,IAAI;AAC7C,MAAI,UAAU,aAAa;AACzB,WAAO;AAAA,MACL,MAAM,iBAAiB,UAAU,WAAW;AAAA,MAC5C,OAAO,UAAU,aAAa,YAAY;AAAA,IAC5C;AAAA,EACF;AAGA,SAAO,mBAAmB,QAAQ,YAAY;AAChD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/ir.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProcessSpecConfig } from './processing.js';
|
|
2
2
|
import type { IR } from './types.js';
|
|
3
|
-
export declare function toIR(config:
|
|
3
|
+
export declare function toIR(config: ProcessSpecConfig, 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","
|
|
1
|
+
{"version":3,"file":"ir.d.ts","sources":["../../src/lib/ir.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAe,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,wBAAsB,IAAI,CACxB,MAAM,EAAE,iBAAiB,EACzB,OAAO,UAAQ,GACd,OAAO,CAAC,EAAE,CAAC,CAMb"}
|
package/dist/lib/ir.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDefaultIRPlugins } from "./processing-plugins/create-default-processing-plugins.js";
|
|
2
2
|
import { processSpec } from "./processing.js";
|
|
3
3
|
async function toIR(config, verbose = false) {
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const result = await processSpec({
|
|
5
|
+
...config,
|
|
6
|
+
irPlugins: config.irPlugins ?? createDefaultIRPlugins({ verbose })
|
|
7
|
+
});
|
|
6
8
|
return result.spec;
|
|
7
9
|
}
|
|
8
10
|
export {
|
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
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createDefaultIRPlugins } from './processing-plugins/create-default-processing-plugins.js';\nimport { type ProcessSpecConfig, processSpec } from './processing.js';\nimport type { IR } from './types.js';\n\nexport async function toIR(\n config: ProcessSpecConfig,\n verbose = false,\n): Promise<IR> {\n const result = await processSpec({\n ...config,\n irPlugins: config.irPlugins ?? createDefaultIRPlugins({ verbose }),\n });\n return result.spec;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,8BAA8B;AACvC,SAAiC,mBAAmB;AAGpD,eAAsB,KACpB,QACA,UAAU,OACG;AACb,QAAM,SAAS,MAAM,YAAY;AAAA,IAC/B,GAAG;AAAA,IACH,WAAW,OAAO,aAAa,uBAAuB,EAAE,QAAQ,CAAC;AAAA,EACnE,CAAC;AACD,SAAO,OAAO;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import type { SchemaObject } from 'openapi3-ts/oas31';
|
|
2
|
+
import type { OpenAPIDocument } from '@sdk-it/core';
|
|
2
3
|
export declare function isPrimitiveSchema(schema: SchemaObject): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Whether a generator may write the component `$ref` points at in place
|
|
6
|
+
* instead of naming it: a primitive that does not reach itself through other
|
|
7
|
+
* primitives, since inlining a cycle never ends.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isInlinable(spec: OpenAPIDocument, $ref: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the component `$ref` points at refers back to itself through other
|
|
12
|
+
* components, so a generator must defer the reference that closes the cycle.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isRecursiveRef(spec: OpenAPIDocument, $ref: string): boolean;
|
|
3
15
|
//# sourceMappingURL=is-primitive-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-primitive-schema.d.ts","
|
|
1
|
+
{"version":3,"file":"is-primitive-schema.d.ts","sources":["../../src/lib/is-primitive-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,WAMrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMxE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ3E"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { followRef, isRef } from "@sdk-it/core/ref.js";
|
|
1
2
|
import { coerceTypes } from "./is.js";
|
|
3
|
+
import { subschemas } from "./walk-schemas.js";
|
|
2
4
|
function isPrimitiveSchema(schema) {
|
|
3
5
|
const types = coerceTypes(schema, false);
|
|
4
6
|
if (!types || types.length === 0) {
|
|
@@ -6,7 +8,38 @@ function isPrimitiveSchema(schema) {
|
|
|
6
8
|
}
|
|
7
9
|
return types.includes("object") === false;
|
|
8
10
|
}
|
|
11
|
+
function isInlinable(spec, $ref) {
|
|
12
|
+
const target = followRef(spec, $ref);
|
|
13
|
+
return isPrimitiveSchema(target) && !reaches(spec, target, $ref, /* @__PURE__ */ new Set(), isPrimitiveSchema);
|
|
14
|
+
}
|
|
15
|
+
function isRecursiveRef(spec, $ref) {
|
|
16
|
+
return reaches(
|
|
17
|
+
spec,
|
|
18
|
+
followRef(spec, $ref),
|
|
19
|
+
$ref,
|
|
20
|
+
/* @__PURE__ */ new Set(),
|
|
21
|
+
() => true
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function reaches(spec, schema, $ref, seen, through) {
|
|
25
|
+
for (const [, child] of subschemas(schema)) {
|
|
26
|
+
if (!isRef(child)) {
|
|
27
|
+
if (reaches(spec, child, $ref, seen, through)) return true;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (child.$ref === $ref) return true;
|
|
31
|
+
if (seen.has(child.$ref)) continue;
|
|
32
|
+
seen.add(child.$ref);
|
|
33
|
+
const target = followRef(spec, child.$ref);
|
|
34
|
+
if (through(target) && reaches(spec, target, $ref, seen, through)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
9
40
|
export {
|
|
10
|
-
|
|
41
|
+
isInlinable,
|
|
42
|
+
isPrimitiveSchema,
|
|
43
|
+
isRecursiveRef
|
|
11
44
|
};
|
|
12
45
|
//# sourceMappingURL=is-primitive-schema.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/is-primitive-schema.ts"],
|
|
4
|
-
"sourcesContent": ["import type { SchemaObject } from 'openapi3-ts/oas31';\n\nimport { coerceTypes } from './is.js';\n\nexport function isPrimitiveSchema(schema: SchemaObject) {\n const types = coerceTypes(schema, false);\n if (!types || types.length === 0) {\n return false;\n }\n return types.includes('object') === false;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { SchemaObject } from 'openapi3-ts/oas31';\n\nimport type { OpenAPIDocument } from '@sdk-it/core';\nimport { followRef, isRef } from '@sdk-it/core/ref.js';\n\nimport { coerceTypes } from './is.js';\nimport { subschemas } from './walk-schemas.js';\n\nexport function isPrimitiveSchema(schema: SchemaObject) {\n const types = coerceTypes(schema, false);\n if (!types || types.length === 0) {\n return false;\n }\n return types.includes('object') === false;\n}\n\n/**\n * Whether a generator may write the component `$ref` points at in place\n * instead of naming it: a primitive that does not reach itself through other\n * primitives, since inlining a cycle never ends.\n */\nexport function isInlinable(spec: OpenAPIDocument, $ref: string): boolean {\n const target = followRef<SchemaObject>(spec, $ref);\n return (\n isPrimitiveSchema(target) &&\n !reaches(spec, target, $ref, new Set(), isPrimitiveSchema)\n );\n}\n\n/**\n * Whether the component `$ref` points at refers back to itself through other\n * components, so a generator must defer the reference that closes the cycle.\n */\nexport function isRecursiveRef(spec: OpenAPIDocument, $ref: string): boolean {\n return reaches(\n spec,\n followRef<SchemaObject>(spec, $ref),\n $ref,\n new Set(),\n () => true,\n );\n}\n\n/** Whether `schema` refers to `$ref`, following each component `through` accepts. */\nfunction reaches(\n spec: OpenAPIDocument,\n schema: SchemaObject,\n $ref: string,\n seen: Set<string>,\n through: (component: SchemaObject) => boolean,\n): boolean {\n for (const [, child] of subschemas(schema)) {\n if (!isRef(child)) {\n if (reaches(spec, child, $ref, seen, through)) return true;\n continue;\n }\n if (child.$ref === $ref) return true;\n if (seen.has(child.$ref)) continue;\n seen.add(child.$ref);\n const target = followRef<SchemaObject>(spec, child.$ref);\n if (through(target) && reaches(spec, target, $ref, seen, through)) {\n return true;\n }\n }\n return false;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,WAAW,aAAa;AAEjC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAEpB,SAAS,kBAAkB,QAAsB;AACtD,QAAM,QAAQ,YAAY,QAAQ,KAAK;AACvC,MAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAChC,WAAO;AAAA,EACT;AACA,SAAO,MAAM,SAAS,QAAQ,MAAM;AACtC;AAOO,SAAS,YAAY,MAAuB,MAAuB;AACxE,QAAM,SAAS,UAAwB,MAAM,IAAI;AACjD,SACE,kBAAkB,MAAM,KACxB,CAAC,QAAQ,MAAM,QAAQ,MAAM,oBAAI,IAAI,GAAG,iBAAiB;AAE7D;AAMO,SAAS,eAAe,MAAuB,MAAuB;AAC3E,SAAO;AAAA,IACL;AAAA,IACA,UAAwB,MAAM,IAAI;AAAA,IAClC;AAAA,IACA,oBAAI,IAAI;AAAA,IACR,MAAM;AAAA,EACR;AACF;AAGA,SAAS,QACP,MACA,QACA,MACA,MACA,SACS;AACT,aAAW,CAAC,EAAE,KAAK,KAAK,WAAW,MAAM,GAAG;AAC1C,QAAI,CAAC,MAAM,KAAK,GAAG;AACjB,UAAI,QAAQ,MAAM,OAAO,MAAM,MAAM,OAAO,EAAG,QAAO;AACtD;AAAA,IACF;AACA,QAAI,MAAM,SAAS,KAAM,QAAO;AAChC,QAAI,KAAK,IAAI,MAAM,IAAI,EAAG;AAC1B,SAAK,IAAI,MAAM,IAAI;AACnB,UAAM,SAAS,UAAwB,MAAM,MAAM,IAAI;AACvD,QAAI,QAAQ,MAAM,KAAK,QAAQ,MAAM,QAAQ,MAAM,MAAM,OAAO,GAAG;AACjE,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/is.d.ts
CHANGED
|
@@ -2,9 +2,18 @@ import type { SchemaObject, SchemaObjectType } from 'openapi3-ts/oas31';
|
|
|
2
2
|
export declare function coerceTypes(schema: SchemaObject, excludeNull?: boolean): SchemaObjectType[];
|
|
3
3
|
export declare function isStreamingContentType(contentType: string | null | undefined): boolean;
|
|
4
4
|
export declare function isBinaryContentType(contentType: string | null | undefined): boolean;
|
|
5
|
+
/** Whether `contentType` is an XML media type: `*\/xml` or `*\/*+xml`. */
|
|
6
|
+
export declare function isXmlContentType(contentType: string | null | undefined): boolean;
|
|
7
|
+
/** The status ranges an OpenAPI 3.2 Responses Object may declare. */
|
|
8
|
+
export type StatusRange = '1XX' | '2XX' | '3XX' | '4XX' | '5XX';
|
|
9
|
+
/**
|
|
10
|
+
* The range that a Responses Object key declares, or undefined for an explicit
|
|
11
|
+
* code or `default`. OpenAPI 3.2 allows only the uppercase `X` wildcard.
|
|
12
|
+
*/
|
|
13
|
+
export declare function statusRange(status: string): StatusRange | undefined;
|
|
5
14
|
export declare function isSuccessStatusCode(statusCode: number | string): boolean;
|
|
6
15
|
export declare function isErrorStatusCode(statusCode: number | string): boolean;
|
|
7
|
-
export declare function parseJsonContentType(contentType: string | null | undefined):
|
|
16
|
+
export declare function parseJsonContentType(contentType: string | null | undefined): "json" | null;
|
|
8
17
|
export declare function isTextContentType(contentType: string | null | undefined): boolean;
|
|
9
18
|
/**
|
|
10
19
|
* Checks if a given content type string represents Server-Sent Events (SSE).
|
package/dist/lib/is.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","
|
|
1
|
+
{"version":3,"file":"is.d.ts","sources":["../../src/lib/is.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAExE,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,EACpB,WAAW,UAAO,GACjB,gBAAgB,EAAE,CAOpB;AAED,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,CA+DT;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAGT;AAED,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAUhE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEnE;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
|
@@ -21,10 +21,7 @@ function isBinaryContentType(contentType) {
|
|
|
21
21
|
if (mainType.endsWith("/json") || mainType.endsWith("+json")) {
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
|
-
if (
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (mainType === "application/xml" || mainType === "text/xml") {
|
|
24
|
+
if (isXmlContentType(mainType)) {
|
|
28
25
|
return false;
|
|
29
26
|
}
|
|
30
27
|
if (mainType === "application/x-www-form-urlencoded" || mainType === "multipart/form-data") {
|
|
@@ -65,6 +62,20 @@ function isBinaryContentType(contentType) {
|
|
|
65
62
|
}
|
|
66
63
|
return false;
|
|
67
64
|
}
|
|
65
|
+
function isXmlContentType(contentType) {
|
|
66
|
+
const mainType = contentType?.split(";")[0].trim().toLowerCase();
|
|
67
|
+
return !!mainType && (mainType.endsWith("/xml") || mainType.endsWith("+xml"));
|
|
68
|
+
}
|
|
69
|
+
const statusRanges = [
|
|
70
|
+
"1XX",
|
|
71
|
+
"2XX",
|
|
72
|
+
"3XX",
|
|
73
|
+
"4XX",
|
|
74
|
+
"5XX"
|
|
75
|
+
];
|
|
76
|
+
function statusRange(status) {
|
|
77
|
+
return statusRanges.find((range) => range === status);
|
|
78
|
+
}
|
|
68
79
|
function isSuccessStatusCode(statusCode) {
|
|
69
80
|
if (typeof statusCode === "string") {
|
|
70
81
|
return /^2(?:\d{2}|xx)$/i.test(statusCode.trim());
|
|
@@ -91,10 +102,8 @@ function parseJsonContentType(contentType) {
|
|
|
91
102
|
mainType = mainType.substring(0, semicolonIndex).trim();
|
|
92
103
|
}
|
|
93
104
|
mainType = mainType.toLowerCase();
|
|
94
|
-
if (mainType.endsWith("
|
|
95
|
-
return
|
|
96
|
-
} else if (mainType.endsWith("+json")) {
|
|
97
|
-
return mainType.split("+")[1];
|
|
105
|
+
if (mainType === "application/json" || mainType.endsWith("+json")) {
|
|
106
|
+
return "json";
|
|
98
107
|
}
|
|
99
108
|
return null;
|
|
100
109
|
}
|
|
@@ -130,6 +139,8 @@ export {
|
|
|
130
139
|
isStreamingContentType,
|
|
131
140
|
isSuccessStatusCode,
|
|
132
141
|
isTextContentType,
|
|
133
|
-
|
|
142
|
+
isXmlContentType,
|
|
143
|
+
parseJsonContentType,
|
|
144
|
+
statusRange
|
|
134
145
|
};
|
|
135
146
|
//# sourceMappingURL=is.js.map
|
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": ["import type { SchemaObject, SchemaObjectType } from 'openapi3-ts/oas31';\n\nexport function coerceTypes(\n schema: SchemaObject,\n excludeNull = true,\n): SchemaObjectType[] {\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n return excludeNull ? types.filter((type) => type !== 'null') : types;\n}\n\nexport 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 (
|
|
5
|
-
"mappings": "AAEO,SAAS,YACd,QACA,cAAc,MACM;AACpB,QAAM,QAAQ,MAAM,QAAQ,OAAO,IAAI,IACnC,OAAO,OACP,OAAO,OACL,CAAC,OAAO,IAAI,IACZ,CAAC;AACP,SAAO,cAAc,MAAM,OAAO,CAAC,SAAS,SAAS,MAAM,IAAI;AACjE;AAEO,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,
|
|
4
|
+
"sourcesContent": ["import type { SchemaObject, SchemaObjectType } from 'openapi3-ts/oas31';\n\nexport function coerceTypes(\n schema: SchemaObject,\n excludeNull = true,\n): SchemaObjectType[] {\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n return excludeNull ? types.filter((type) => type !== 'null') : types;\n}\n\nexport 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 (isXmlContentType(mainType)) {\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\n/** Whether `contentType` is an XML media type: `*\\/xml` or `*\\/*+xml`. */\nexport function isXmlContentType(\n contentType: string | null | undefined,\n): boolean {\n const mainType = contentType?.split(';')[0].trim().toLowerCase();\n return !!mainType && (mainType.endsWith('/xml') || mainType.endsWith('+xml'));\n}\n\n/** The status ranges an OpenAPI 3.2 Responses Object may declare. */\nexport type StatusRange = '1XX' | '2XX' | '3XX' | '4XX' | '5XX';\n\nconst statusRanges: readonly StatusRange[] = [\n '1XX',\n '2XX',\n '3XX',\n '4XX',\n '5XX',\n];\n\n/**\n * The range that a Responses Object key declares, or undefined for an explicit\n * code or `default`. OpenAPI 3.2 allows only the uppercase `X` wildcard.\n */\nexport function statusRange(status: string): StatusRange | undefined {\n return statusRanges.find((range) => range === status);\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 // application/json and every media type with the +json suffix (RFC 6839 \u00A73.1)\n // are JSON; text/json and other */json types are not registered as JSON.\n if (mainType === 'application/json' || mainType.endsWith('+json')) {\n return 'json';\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": "AAEO,SAAS,YACd,QACA,cAAc,MACM;AACpB,QAAM,QAAQ,MAAM,QAAQ,OAAO,IAAI,IACnC,OAAO,OACP,OAAO,OACL,CAAC,OAAO,IAAI,IACZ,CAAC;AACP,SAAO,cAAc,MAAM,OAAO,CAAC,SAAS,SAAS,MAAM,IAAI;AACjE;AAEO,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,EAC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I,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,4 +1,11 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Loads the document at `location` and every document it references, bundled
|
|
4
|
+
* into one spec whose references are all local. `documents` lists the URI of
|
|
5
|
+
* each document read, `location` first.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadSpec(location: string): Promise<{
|
|
8
|
+
spec: OpenAPIObject;
|
|
9
|
+
documents: string[];
|
|
10
|
+
}>;
|
|
4
11
|
//# sourceMappingURL=load-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-spec.d.ts","
|
|
1
|
+
{"version":3,"file":"load-spec.d.ts","sources":["../../../src/lib/loaders/load-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAyBvD;;;;GAIG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAiBvD"}
|
|
@@ -1,35 +1,30 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
import {
|
|
3
|
+
import { isRemote, loadFile } from "../external-documents.js";
|
|
4
|
+
import { bundleDocument } from "../processing-plugins/bundle-external-refs.js";
|
|
5
|
+
import { registerExternalSecuritySchemes } from "../processing-plugins/resolve-security-scheme-uris.js";
|
|
4
6
|
import { convertPostmanToOpenAPI } from "./postman/postman-converter.js";
|
|
5
|
-
import { loadRemote } from "./remote-loader.js";
|
|
6
7
|
function isPostman(content) {
|
|
7
8
|
return typeof content === "object" && content !== null && "info" in content && typeof content.info === "object" && content.info !== null && "item" in content && Array.isArray(content.item) && "schema" in content.info && typeof content.info.schema === "string" && content.info.schema.includes("//schema.getpostman.com/");
|
|
8
9
|
}
|
|
9
10
|
async function loadSpec(location) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return loadLocal(location);
|
|
11
|
+
const content = await loadFile(location);
|
|
12
|
+
const spec = isPostman(content) ? convertPostmanToOpenAPI(content) : content;
|
|
13
|
+
const document = spec;
|
|
14
|
+
const entry = documentUri(location);
|
|
15
|
+
document.$self ??= entry;
|
|
16
|
+
const documents = /* @__PURE__ */ new Map();
|
|
17
|
+
await bundleDocument(document, documents);
|
|
18
|
+
await registerExternalSecuritySchemes(document, documents);
|
|
19
|
+
return {
|
|
20
|
+
spec,
|
|
21
|
+
documents: [.../* @__PURE__ */ new Set([entry, ...documents.keys()])]
|
|
22
|
+
};
|
|
23
23
|
}
|
|
24
24
|
function documentUri(location) {
|
|
25
25
|
return isRemote(location) || location.startsWith("file:") ? location : pathToFileURL(resolve(location)).href;
|
|
26
26
|
}
|
|
27
|
-
function isRemote(location) {
|
|
28
|
-
const [protocol] = location.split(":");
|
|
29
|
-
return protocol === "http" || protocol === "https";
|
|
30
|
-
}
|
|
31
27
|
export {
|
|
32
|
-
loadFile,
|
|
33
28
|
loadSpec
|
|
34
29
|
};
|
|
35
30
|
//# sourceMappingURL=load-spec.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/loaders/load-spec.ts"],
|
|
4
|
-
"sourcesContent": ["import { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\n\nimport type { OpenAPIDocument } from '@sdk-it/core';\n\nimport {
|
|
5
|
-
"mappings": "AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAK9B,SAAS,
|
|
4
|
+
"sourcesContent": ["import { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\n\nimport type { OpenAPIDocument } from '@sdk-it/core';\n\nimport { type Documents, isRemote, loadFile } from '../external-documents.js';\nimport { bundleDocument } from '../processing-plugins/bundle-external-refs.js';\nimport { registerExternalSecuritySchemes } from '../processing-plugins/resolve-security-scheme-uris.js';\nimport { convertPostmanToOpenAPI } from './postman/postman-converter.js';\nimport type { PostmanCollection } from './postman/spec-types.js';\n\nfunction isPostman(content: unknown): content is PostmanCollection {\n return (\n typeof content === 'object' &&\n content !== null &&\n 'info' in content &&\n typeof content.info === 'object' &&\n content.info !== null &&\n 'item' in content &&\n Array.isArray(content.item) &&\n 'schema' in content.info &&\n typeof content.info.schema === 'string' &&\n content.info.schema.includes('//schema.getpostman.com/')\n );\n}\n\n/**\n * Loads the document at `location` and every document it references, bundled\n * into one spec whose references are all local. `documents` lists the URI of\n * each document read, `location` first.\n */\nexport async function loadSpec(\n location: string,\n): Promise<{ spec: OpenAPIObject; documents: string[] }> {\n const content = await loadFile<OpenAPIObject | PostmanCollection>(location);\n const spec: OpenAPIObject = isPostman(content)\n ? convertPostmanToOpenAPI(content)\n : content;\n const document: OpenAPIDocument = spec;\n const entry = documentUri(location);\n // Relative references inside the document resolve against where it came from.\n document.$self ??= entry;\n const documents: Documents = new Map();\n await bundleDocument(document, documents);\n // A scheme URI that fails stays a URI key; toIR reports it as a diagnostic.\n await registerExternalSecuritySchemes(document, documents);\n return {\n spec,\n documents: [...new Set([entry, ...documents.keys()])],\n };\n}\n\nfunction documentUri(location: string) {\n return isRemote(location) || location.startsWith('file:')\n ? location\n : pathToFileURL(resolve(location)).href;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAK9B,SAAyB,UAAU,gBAAgB;AACnD,SAAS,sBAAsB;AAC/B,SAAS,uCAAuC;AAChD,SAAS,+BAA+B;AAGxC,SAAS,UAAU,SAAgD;AACjE,SACE,OAAO,YAAY,YACnB,YAAY,QACZ,UAAU,WACV,OAAO,QAAQ,SAAS,YACxB,QAAQ,SAAS,QACjB,UAAU,WACV,MAAM,QAAQ,QAAQ,IAAI,KAC1B,YAAY,QAAQ,QACpB,OAAO,QAAQ,KAAK,WAAW,YAC/B,QAAQ,KAAK,OAAO,SAAS,0BAA0B;AAE3D;AAOA,eAAsB,SACpB,UACuD;AACvD,QAAM,UAAU,MAAM,SAA4C,QAAQ;AAC1E,QAAM,OAAsB,UAAU,OAAO,IACzC,wBAAwB,OAAO,IAC/B;AACJ,QAAM,WAA4B;AAClC,QAAM,QAAQ,YAAY,QAAQ;AAElC,WAAS,UAAU;AACnB,QAAM,YAAuB,oBAAI,IAAI;AACrC,QAAM,eAAe,UAAU,SAAS;AAExC,QAAM,gCAAgC,UAAU,SAAS;AACzD,SAAO;AAAA,IACL;AAAA,IACA,WAAW,CAAC,GAAG,oBAAI,IAAI,CAAC,OAAO,GAAG,UAAU,KAAK,CAAC,CAAC,CAAC;AAAA,EACtD;AACF;AAEA,SAAS,YAAY,UAAkB;AACrC,SAAO,SAAS,QAAQ,KAAK,SAAS,WAAW,OAAO,IACpD,WACA,cAAc,QAAQ,QAAQ,CAAC,EAAE;AACvC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-loader.d.ts","
|
|
1
|
+
{"version":3,"file":"local-loader.d.ts","sources":["../../../src/lib/loaders/local-loader.ts"],"names":[],"mappings":"AAIA,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,gBAY/C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import type { PostmanCollection } from './spec-types';
|
|
2
|
+
import type { PostmanCollection } from './spec-types.js';
|
|
3
3
|
export declare function convertPostmanToOpenAPI(collection: PostmanCollection): OpenAPIObject;
|
|
4
4
|
//# sourceMappingURL=postman-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postman-converter.d.ts","
|
|
1
|
+
{"version":3,"file":"postman-converter.d.ts","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,iBAAiB,CAAC;AA0jBzB,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iBAAiB,GAC5B,aAAa,CA6Bf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MIMEType } from "node:util";
|
|
2
2
|
function descriptionToText(description) {
|
|
3
3
|
if (!description) {
|
|
4
4
|
return void 0;
|
|
@@ -299,8 +299,7 @@ function requestToOperation(item, securitySchemes) {
|
|
|
299
299
|
(h) => h.key.toLowerCase() === "content-type"
|
|
300
300
|
);
|
|
301
301
|
const [contentTypeValue2] = contentTypeIdx2 !== -1 ? headers2.splice(contentTypeIdx2).map((h) => h.value) : [];
|
|
302
|
-
|
|
303
|
-
contentType ??= "application/octet-stream";
|
|
302
|
+
const contentType = response.body ? new MIMEType(contentTypeValue2 || "application/json").essence : "application/octet-stream";
|
|
304
303
|
return {
|
|
305
304
|
...acc,
|
|
306
305
|
[response.code ?? 200]: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/loaders/postman/postman-converter.ts"],
|
|
4
|
-
"sourcesContent": ["import { parse } from 'fast-content-type-parse';\nimport type {\n ContentObject,\n OpenAPIObject,\n OperationObject,\n ParameterObject,\n PathsObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n SecuritySchemeObject,\n TagObject,\n} from 'openapi3-ts/oas31';\n\nimport type {\n Auth,\n Description,\n Folder,\n Header,\n Headers,\n Item,\n Items,\n PostmanCollection,\n PostmanRequest,\n QueryParam,\n Request,\n RequestBody,\n Url,\n Variable,\n} from './spec-types';\n\nfunction descriptionToText(description?: Description) {\n if (!description) {\n return undefined;\n }\n if (typeof description === 'string') {\n return description;\n }\n if (description.content) {\n return description.content;\n }\n return undefined;\n}\n\ntype OurQueryParam = Omit<QueryParam, 'key'> & {\n key: string;\n description?: string;\n};\ntype OurVariable = Omit<QueryParam, 'key'> & {\n key: string;\n description?: string;\n};\ntype OurUrl = {\n path: string[];\n query: OurQueryParam[];\n variable: OurVariable[];\n};\n\nfunction isFolder(item: Items): item is Folder & { name: string } {\n return 'item' in item;\n}\n\nfunction isRequest(\n item: Items,\n): item is Item & { name: string; request: Request } {\n return !!item.request;\n}\n\n/**\n * Recursively processes items and folders in a Postman collection\n * @param items Array of Postman items (requests or folders)\n * @param parentTags Array of parent folder tags for proper nesting\n */\nfunction processItems(\n items: Items[],\n parentTags: string[],\n globalTags: TagObject[],\n paths: PathsObject,\n securitySchemes: Record<string, SecuritySchemeObject>,\n) {\n for (const item of items) {\n if (!isFolder(item) && !isRequest(item)) {\n console.warn(\n `Skipping item ${item.name} because it is not a folder or request`,\n );\n continue;\n }\n\n if (isFolder(item)) {\n // Process folder-level auth if it exists\n if (item.auth) {\n processAuthScheme(item.auth, securitySchemes);\n }\n\n // Add this folder as a tag if not already added\n if (!globalTags.some((tag) => tag.name === item.name)) {\n globalTags.push({\n name: item.name,\n description: descriptionToText(item.description),\n });\n }\n\n const currentTags = [...parentTags, item.name];\n processItems(item.item, currentTags, globalTags, paths, securitySchemes);\n } else if (isRequest(item)) {\n // Process this request\n let operation: ReturnType<typeof requestToOperation>;\n if (typeof item.request === 'string') {\n const url = new URL(item.request);\n operation = requestToOperation(\n {\n name: url.pathname,\n response: [{ code: 200 }],\n request: {\n method: 'get',\n url: {\n path: url.pathname.split('/').slice(1),\n },\n },\n },\n securitySchemes,\n );\n } else {\n const auth = item.request.auth;\n operation = requestToOperation(\n {\n name: item.name,\n request: { ...item.request, auth },\n response: item.response,\n },\n securitySchemes,\n );\n }\n\n paths[operation.path] ??= {};\n Object.assign(paths[operation.path], {\n [operation.method]: {\n tags: parentTags.length ? parentTags : undefined,\n ...operation.operation,\n },\n });\n }\n }\n}\n\nfunction coerceVariable(query: Variable): OurVariable {\n if (!query.key) {\n throw new Error('Invalid query parameter format');\n }\n return {\n key: query.key,\n description: descriptionToText(query.description),\n };\n}\nfunction coerceQuery(query: QueryParam): OurQueryParam {\n if (!query.key) {\n throw new Error('Invalid query parameter format');\n }\n return {\n key: query.key,\n description: descriptionToText(query.description),\n };\n}\nfunction coerceUrl(url?: Url): OurUrl {\n if (!url) {\n throw new Error('Invalid URL format');\n }\n if (typeof url === 'string') {\n return {\n path: url.split('/').slice(1),\n query: [],\n variable: [],\n };\n }\n if (typeof url.path === 'string') {\n return {\n path: url.path.split('/').slice(1),\n query: (url.query ?? []).map(coerceQuery),\n variable: (url.variable ?? []).map(coerceVariable),\n };\n }\n return {\n path: (url.path ?? []).map((p) => {\n if (typeof p === 'string') {\n return p;\n }\n throw new Error('Invalid URL path format');\n }),\n query: (url.query ?? []).map(coerceQuery),\n variable: (url.variable ?? []).map(coerceVariable),\n };\n}\n\nfunction coerceResponseHeader(header?: Headers) {\n if (!header) {\n return [];\n }\n if (typeof header === 'string') {\n throw new Error(`Invalid header format: ${header}`);\n }\n return header.map((h) => {\n if (typeof h === 'string') {\n return {\n key: h,\n value: null,\n };\n }\n return h;\n });\n}\n\n/**\n * Process an auth scheme and add it to securitySchemes\n */\nfunction processAuthScheme(\n auth: Auth,\n securitySchemes: Record<string, SecuritySchemeObject>,\n): string | null {\n if (!auth || auth.type === 'noauth') return null;\n\n const getAuthAttr = (key: string): string | undefined => {\n if (!auth || auth.type === 'noauth') return undefined;\n const authType = auth[auth.type];\n if (!authType) return undefined;\n const attr = authType.find((a) => a.key === key);\n return attr ? String(attr.value) : undefined;\n };\n\n const schemeId = `${auth.type}Auth`;\n\n switch (auth.type) {\n case 'apikey': {\n const key = getAuthAttr('key') || 'api_key';\n const in_ = getAuthAttr('in') || 'header';\n securitySchemes[schemeId] = {\n type: 'apiKey',\n name: key,\n in: in_ as 'header' | 'query' | 'cookie',\n description: 'API key authentication',\n };\n break;\n }\n case 'basic':\n securitySchemes[schemeId] = {\n type: 'http',\n scheme: 'basic',\n description: 'Basic HTTP authentication',\n };\n break;\n case 'bearer': {\n const token = getAuthAttr('token');\n securitySchemes[schemeId] = {\n type: 'http',\n scheme: 'bearer',\n description: 'Bearer token authentication',\n ...(token ? { bearerFormat: 'JWT' } : {}),\n };\n break;\n }\n case 'oauth2': {\n const flowType = getAuthAttr('grant_type') || 'implicit';\n securitySchemes[schemeId] = {\n type: 'oauth2',\n description: 'OAuth 2.0 authentication',\n flows: {\n [flowType === 'authorization_code' ? 'authorizationCode' : flowType]:\n {\n authorizationUrl:\n getAuthAttr('authUrl') || 'https://example.com/oauth/authorize',\n tokenUrl:\n getAuthAttr('tokenUrl') || 'https://example.com/oauth/token',\n scopes: {},\n },\n },\n };\n break;\n }\n case 'digest':\n securitySchemes[schemeId] = {\n type: 'http',\n scheme: 'digest',\n description: 'Digest authentication',\n };\n break;\n case 'awsv4':\n securitySchemes[schemeId] = {\n type: 'apiKey',\n name: 'Authorization',\n in: 'header',\n description: 'AWS Signature v4 authentication',\n };\n break;\n default:\n securitySchemes[schemeId] = {\n type: 'apiKey',\n name: 'Authorization',\n in: 'header',\n description: `${auth.type} authentication`,\n };\n }\n\n return schemeId;\n}\n\nfunction generateSecurityRequirement(\n auth: Auth,\n securitySchemes: Record<string, SecuritySchemeObject>,\n) {\n if (!auth || auth.type === 'noauth') return [];\n\n const schemeId = `${auth.type}Auth`;\n\n // Only include if the scheme was successfully processed\n if (securitySchemes[schemeId]) {\n return [{ [schemeId]: [] }];\n }\n\n return [];\n}\n\nfunction requestToOperation(\n item: Exclude<Item, 'name' | 'request'> & {\n name: string;\n request: PostmanRequest;\n },\n securitySchemes: Record<string, SecuritySchemeObject>,\n) {\n const url = coerceUrl(item.request.url);\n const headers = Array.isArray(item.request.header)\n ? item.request.header\n : ([] as Header[]);\n\n const parameters: ParameterObject[] = [\n ...url.query\n .filter((param) => !param.disabled)\n .map((param) => {\n return {\n in: 'query',\n name: param.key,\n required: false,\n description: param.description,\n schema: {\n ...(param.value && !isNaN(Number(param.value))\n ? { type: 'number' }\n : param.value === 'true' || param.value === 'false'\n ? { type: 'boolean' }\n : { type: 'string' }),\n },\n } satisfies ParameterObject;\n }),\n\n ...url.variable.map((param) => {\n return {\n in: 'path',\n name: param.key,\n required: true,\n description: param.description,\n schema: {\n ...(param.value && !isNaN(Number(param.value))\n ? { type: 'number' }\n : param.value === 'true' || param.value === 'false'\n ? { type: 'boolean' }\n : { type: 'string' }),\n },\n } satisfies ParameterObject;\n }),\n\n ...headers\n .filter(\n (h) =>\n !h.disabled &&\n h.key.toLowerCase() !== 'accept' &&\n h.key.toLowerCase() !== 'content-type',\n )\n .map((header) => {\n return {\n in: 'header',\n name: header.key,\n required: false,\n description: descriptionToText(header.description),\n schema: {\n type: 'string',\n },\n } satisfies ParameterObject;\n }),\n ];\n\n // Extract Accept and Content-Type headers\n const acceptHeaderIdx = headers.findIndex(\n (h) => h.key.toLowerCase() === 'accept',\n );\n const contentTypeIdx = headers.findIndex(\n (h) => h.key.toLowerCase() === 'content-type',\n );\n if (acceptHeaderIdx !== -1) headers.splice(acceptHeaderIdx, 1);\n const [contentTypeValue] =\n contentTypeIdx !== -1\n ? headers.splice(contentTypeIdx, 1).map((h) => h.value)\n : [];\n\n let security;\n if (item.request.auth) {\n const schemeId = processAuthScheme(item.request.auth, securitySchemes);\n if (schemeId) {\n security = [{ [schemeId]: [] }];\n }\n }\n\n return {\n path: `/${url.path.join('/')}`.replace(/:([^/]+)/g, '{$1}'),\n method: (item.request.method ?? 'get').toLowerCase(),\n operation: {\n summary: item.name,\n description: descriptionToText(item.request.description),\n parameters,\n security,\n responses:\n !item.response || item.response.length === 0\n ? {\n 200: {\n description: 'Successful response',\n },\n }\n : item.response.reduce((acc, response) => {\n const headers = coerceResponseHeader(response.header);\n const contentTypeIdx = headers.findIndex(\n (h) => h.key.toLowerCase() === 'content-type',\n );\n const [contentTypeValue] =\n contentTypeIdx !== -1\n ? headers.splice(contentTypeIdx).map((h) => h.value)\n : [];\n\n let contentType = response.body\n ? parse(contentTypeValue || 'application/json')?.type\n : null;\n contentType ??= 'application/octet-stream';\n\n return {\n ...acc,\n [response.code ?? 200]: {\n description: response.name\n ? response.name\n : `Response for ${response.code}`,\n content: {\n [contentType]: {\n schema: bodyToSchema(response.body),\n },\n },\n } satisfies ResponseObject,\n };\n }, {}),\n requestBody: item.request.body\n ? requestBodyToOperationBody(\n contentTypeValue || 'application/json',\n item.request.body,\n )\n : undefined,\n } satisfies OperationObject,\n };\n}\n\nfunction requestBodyToOperationBody(\n contentType: string,\n body: RequestBody,\n): RequestBodyObject {\n if (body.mode === 'raw') {\n return {\n content: {\n [contentType]: {\n schema: bodyToSchema(body.raw),\n },\n },\n };\n } else if (body.mode === 'urlencoded') {\n const properties: Record<string, any> = {};\n (body.urlencoded || [])\n .filter((param) => !param.disabled)\n .forEach((param) => {\n properties[param.key] = {\n type: 'string',\n description: descriptionToText(param.description),\n };\n });\n\n return {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties,\n },\n },\n } satisfies ContentObject,\n };\n } else if (body.mode === 'formdata') {\n const properties: SchemaObject['properties'] = {};\n (body.formdata || [])\n .filter((param) => !param.disabled)\n .forEach((param) => {\n if (param.type === 'text') {\n properties[param.key] = {\n type: 'string',\n description: descriptionToText(param.description),\n };\n } else if (param.type === 'file') {\n properties[param.key] = {\n type: 'string',\n format: 'binary',\n description: descriptionToText(param.description),\n };\n }\n });\n\n return {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties,\n },\n },\n } satisfies ContentObject,\n };\n }\n\n throw new Error(\n `Unsupported request body mode: ${body.mode}. Supported modes are: raw, urlencoded, formdata`,\n );\n}\n\nfunction bodyToSchema(bodyString?: string | null): SchemaObject | undefined {\n if (!bodyString) {\n return undefined;\n }\n\n let body: unknown;\n try {\n body = JSON.parse(bodyString.normalize('NFKD'));\n } catch (error) {\n console.warn(\n `Failed to parse JSON body: ${bodyString}. Treating as plain string.`,\n error,\n );\n return { type: 'string', example: bodyString };\n }\n\n return toSchema(body);\n}\n\nfunction toSchema(body: unknown | unknown[]): any {\n const typeMap: Record<string, string> = {\n '<number>': 'number',\n '<string>': 'string',\n '<boolean>': 'boolean',\n false: 'boolean',\n true: 'boolean',\n };\n if (Array.isArray(body)) {\n return {\n type: 'array',\n items: toSchema(body[0]),\n };\n }\n if (typeof body === 'object' && body !== null) {\n const properties: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(body)) {\n properties[key] = toSchema(value);\n }\n return {\n type: 'object',\n properties,\n };\n }\n if (typeof body === 'string') {\n return {\n type: typeMap[body] ?? 'string',\n };\n }\n if (typeof body === 'number') {\n return {\n type: 'number',\n };\n }\n if (typeof body === 'boolean') {\n return {\n type: 'boolean',\n };\n }\n if (body === null) {\n return {\n type: 'null',\n };\n }\n console.warn(`Unknown type for body: ${body}. Defaulting to string.`, body);\n return {\n type: 'string',\n };\n}\n\nexport function convertPostmanToOpenAPI(\n collection: PostmanCollection,\n): OpenAPIObject {\n const tags: TagObject[] = [];\n const paths: PathsObject = {};\n const securitySchemes: Record<string, SecuritySchemeObject> = {};\n\n if (collection.auth) {\n processAuthScheme(collection.auth, securitySchemes);\n }\n processItems(collection.item, [], tags, paths, securitySchemes);\n return {\n openapi: '3.1.0',\n info: {\n title: collection.info.name,\n version: '1.0.0',\n description: descriptionToText(collection.info.description),\n },\n tags,\n paths,\n // Only add security at top level if there's collection auth\n security: collection.auth\n ? generateSecurityRequirement(collection.auth, securitySchemes)\n : undefined,\n components:\n Object.keys(securitySchemes).length > 0\n ? {\n securitySchemes,\n }\n : undefined,\n };\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { MIMEType } from 'node:util';\nimport type {\n ContentObject,\n OpenAPIObject,\n OperationObject,\n ParameterObject,\n PathsObject,\n RequestBodyObject,\n ResponseObject,\n SchemaObject,\n SecuritySchemeObject,\n TagObject,\n} from 'openapi3-ts/oas31';\n\nimport type {\n Auth,\n Description,\n Folder,\n Header,\n Headers,\n Item,\n Items,\n PostmanCollection,\n PostmanRequest,\n QueryParam,\n Request,\n RequestBody,\n Url,\n Variable,\n} from './spec-types.js';\n\nfunction descriptionToText(description?: Description) {\n if (!description) {\n return undefined;\n }\n if (typeof description === 'string') {\n return description;\n }\n if (description.content) {\n return description.content;\n }\n return undefined;\n}\n\ntype OurQueryParam = Omit<QueryParam, 'key'> & {\n key: string;\n description?: string;\n};\ntype OurVariable = Omit<QueryParam, 'key'> & {\n key: string;\n description?: string;\n};\ntype OurUrl = {\n path: string[];\n query: OurQueryParam[];\n variable: OurVariable[];\n};\n\nfunction isFolder(item: Items): item is Folder & { name: string } {\n return 'item' in item;\n}\n\nfunction isRequest(\n item: Items,\n): item is Item & { name: string; request: Request } {\n return !!item.request;\n}\n\n/**\n * Recursively processes items and folders in a Postman collection\n * @param items Array of Postman items (requests or folders)\n * @param parentTags Array of parent folder tags for proper nesting\n */\nfunction processItems(\n items: Items[],\n parentTags: string[],\n globalTags: TagObject[],\n paths: PathsObject,\n securitySchemes: Record<string, SecuritySchemeObject>,\n) {\n for (const item of items) {\n if (!isFolder(item) && !isRequest(item)) {\n console.warn(\n `Skipping item ${item.name} because it is not a folder or request`,\n );\n continue;\n }\n\n if (isFolder(item)) {\n // Process folder-level auth if it exists\n if (item.auth) {\n processAuthScheme(item.auth, securitySchemes);\n }\n\n // Add this folder as a tag if not already added\n if (!globalTags.some((tag) => tag.name === item.name)) {\n globalTags.push({\n name: item.name,\n description: descriptionToText(item.description),\n });\n }\n\n const currentTags = [...parentTags, item.name];\n processItems(item.item, currentTags, globalTags, paths, securitySchemes);\n } else if (isRequest(item)) {\n // Process this request\n let operation: ReturnType<typeof requestToOperation>;\n if (typeof item.request === 'string') {\n const url = new URL(item.request);\n operation = requestToOperation(\n {\n name: url.pathname,\n response: [{ code: 200 }],\n request: {\n method: 'get',\n url: {\n path: url.pathname.split('/').slice(1),\n },\n },\n },\n securitySchemes,\n );\n } else {\n const auth = item.request.auth;\n operation = requestToOperation(\n {\n name: item.name,\n request: { ...item.request, auth },\n response: item.response,\n },\n securitySchemes,\n );\n }\n\n paths[operation.path] ??= {};\n Object.assign(paths[operation.path], {\n [operation.method]: {\n tags: parentTags.length ? parentTags : undefined,\n ...operation.operation,\n },\n });\n }\n }\n}\n\nfunction coerceVariable(query: Variable): OurVariable {\n if (!query.key) {\n throw new Error('Invalid query parameter format');\n }\n return {\n key: query.key,\n description: descriptionToText(query.description),\n };\n}\nfunction coerceQuery(query: QueryParam): OurQueryParam {\n if (!query.key) {\n throw new Error('Invalid query parameter format');\n }\n return {\n key: query.key,\n description: descriptionToText(query.description),\n };\n}\nfunction coerceUrl(url?: Url): OurUrl {\n if (!url) {\n throw new Error('Invalid URL format');\n }\n if (typeof url === 'string') {\n return {\n path: url.split('/').slice(1),\n query: [],\n variable: [],\n };\n }\n if (typeof url.path === 'string') {\n return {\n path: url.path.split('/').slice(1),\n query: (url.query ?? []).map(coerceQuery),\n variable: (url.variable ?? []).map(coerceVariable),\n };\n }\n return {\n path: (url.path ?? []).map((p) => {\n if (typeof p === 'string') {\n return p;\n }\n throw new Error('Invalid URL path format');\n }),\n query: (url.query ?? []).map(coerceQuery),\n variable: (url.variable ?? []).map(coerceVariable),\n };\n}\n\nfunction coerceResponseHeader(header?: Headers) {\n if (!header) {\n return [];\n }\n if (typeof header === 'string') {\n throw new Error(`Invalid header format: ${header}`);\n }\n return header.map((h) => {\n if (typeof h === 'string') {\n return {\n key: h,\n value: null,\n };\n }\n return h;\n });\n}\n\n/**\n * Process an auth scheme and add it to securitySchemes\n */\nfunction processAuthScheme(\n auth: Auth,\n securitySchemes: Record<string, SecuritySchemeObject>,\n): string | null {\n if (!auth || auth.type === 'noauth') return null;\n\n const getAuthAttr = (key: string): string | undefined => {\n if (!auth || auth.type === 'noauth') return undefined;\n const authType = auth[auth.type];\n if (!authType) return undefined;\n const attr = authType.find((a) => a.key === key);\n return attr ? String(attr.value) : undefined;\n };\n\n const schemeId = `${auth.type}Auth`;\n\n switch (auth.type) {\n case 'apikey': {\n const key = getAuthAttr('key') || 'api_key';\n const in_ = getAuthAttr('in') || 'header';\n securitySchemes[schemeId] = {\n type: 'apiKey',\n name: key,\n in: in_,\n description: 'API key authentication',\n };\n break;\n }\n case 'basic':\n securitySchemes[schemeId] = {\n type: 'http',\n scheme: 'basic',\n description: 'Basic HTTP authentication',\n };\n break;\n case 'bearer': {\n const token = getAuthAttr('token');\n securitySchemes[schemeId] = {\n type: 'http',\n scheme: 'bearer',\n description: 'Bearer token authentication',\n ...(token ? { bearerFormat: 'JWT' } : {}),\n };\n break;\n }\n case 'oauth2': {\n const flowType = getAuthAttr('grant_type') || 'implicit';\n securitySchemes[schemeId] = {\n type: 'oauth2',\n description: 'OAuth 2.0 authentication',\n flows: {\n [flowType === 'authorization_code' ? 'authorizationCode' : flowType]:\n {\n authorizationUrl:\n getAuthAttr('authUrl') || 'https://example.com/oauth/authorize',\n tokenUrl:\n getAuthAttr('tokenUrl') || 'https://example.com/oauth/token',\n scopes: {},\n },\n },\n };\n break;\n }\n case 'digest':\n securitySchemes[schemeId] = {\n type: 'http',\n scheme: 'digest',\n description: 'Digest authentication',\n };\n break;\n case 'awsv4':\n securitySchemes[schemeId] = {\n type: 'apiKey',\n name: 'Authorization',\n in: 'header',\n description: 'AWS Signature v4 authentication',\n };\n break;\n default:\n securitySchemes[schemeId] = {\n type: 'apiKey',\n name: 'Authorization',\n in: 'header',\n description: `${auth.type} authentication`,\n };\n }\n\n return schemeId;\n}\n\nfunction generateSecurityRequirement(\n auth: Auth,\n securitySchemes: Record<string, SecuritySchemeObject>,\n) {\n if (!auth || auth.type === 'noauth') return [];\n\n const schemeId = `${auth.type}Auth`;\n\n // Only include if the scheme was successfully processed\n if (securitySchemes[schemeId]) {\n return [{ [schemeId]: [] }];\n }\n\n return [];\n}\n\nfunction requestToOperation(\n item: Exclude<Item, 'name' | 'request'> & {\n name: string;\n request: PostmanRequest;\n },\n securitySchemes: Record<string, SecuritySchemeObject>,\n) {\n const url = coerceUrl(item.request.url);\n const headers: Header[] = Array.isArray(item.request.header)\n ? item.request.header\n : [];\n\n const parameters: ParameterObject[] = [\n ...url.query\n .filter((param) => !param.disabled)\n .map((param) => {\n return {\n in: 'query',\n name: param.key,\n required: false,\n description: param.description,\n schema: {\n ...(param.value && !isNaN(Number(param.value))\n ? { type: 'number' }\n : param.value === 'true' || param.value === 'false'\n ? { type: 'boolean' }\n : { type: 'string' }),\n },\n } satisfies ParameterObject;\n }),\n\n ...url.variable.map((param) => {\n return {\n in: 'path',\n name: param.key,\n required: true,\n description: param.description,\n schema: {\n ...(param.value && !isNaN(Number(param.value))\n ? { type: 'number' }\n : param.value === 'true' || param.value === 'false'\n ? { type: 'boolean' }\n : { type: 'string' }),\n },\n } satisfies ParameterObject;\n }),\n\n ...headers\n .filter(\n (h) =>\n !h.disabled &&\n h.key.toLowerCase() !== 'accept' &&\n h.key.toLowerCase() !== 'content-type',\n )\n .map((header) => {\n return {\n in: 'header',\n name: header.key,\n required: false,\n description: descriptionToText(header.description),\n schema: {\n type: 'string',\n },\n } satisfies ParameterObject;\n }),\n ];\n\n // Extract Accept and Content-Type headers\n const acceptHeaderIdx = headers.findIndex(\n (h) => h.key.toLowerCase() === 'accept',\n );\n const contentTypeIdx = headers.findIndex(\n (h) => h.key.toLowerCase() === 'content-type',\n );\n if (acceptHeaderIdx !== -1) headers.splice(acceptHeaderIdx, 1);\n const [contentTypeValue] =\n contentTypeIdx !== -1\n ? headers.splice(contentTypeIdx, 1).map((h) => h.value)\n : [];\n\n let security;\n if (item.request.auth) {\n const schemeId = processAuthScheme(item.request.auth, securitySchemes);\n if (schemeId) {\n security = [{ [schemeId]: [] }];\n }\n }\n\n return {\n path: `/${url.path.join('/')}`.replace(/:([^/]+)/g, '{$1}'),\n method: (item.request.method ?? 'get').toLowerCase(),\n operation: {\n summary: item.name,\n description: descriptionToText(item.request.description),\n parameters,\n security,\n responses:\n !item.response || item.response.length === 0\n ? {\n 200: {\n description: 'Successful response',\n },\n }\n : item.response.reduce((acc, response) => {\n const headers = coerceResponseHeader(response.header);\n const contentTypeIdx = headers.findIndex(\n (h) => h.key.toLowerCase() === 'content-type',\n );\n const [contentTypeValue] =\n contentTypeIdx !== -1\n ? headers.splice(contentTypeIdx).map((h) => h.value)\n : [];\n\n const contentType = response.body\n ? new MIMEType(contentTypeValue || 'application/json').essence\n : 'application/octet-stream';\n\n return {\n ...acc,\n [response.code ?? 200]: {\n description: response.name\n ? response.name\n : `Response for ${response.code}`,\n content: {\n [contentType]: {\n schema: bodyToSchema(response.body),\n },\n },\n } satisfies ResponseObject,\n };\n }, {}),\n requestBody: item.request.body\n ? requestBodyToOperationBody(\n contentTypeValue || 'application/json',\n item.request.body,\n )\n : undefined,\n } satisfies OperationObject,\n };\n}\n\nfunction requestBodyToOperationBody(\n contentType: string,\n body: RequestBody,\n): RequestBodyObject {\n if (body.mode === 'raw') {\n return {\n content: {\n [contentType]: {\n schema: bodyToSchema(body.raw),\n },\n },\n };\n } else if (body.mode === 'urlencoded') {\n const properties: Record<string, any> = {};\n (body.urlencoded || [])\n .filter((param) => !param.disabled)\n .forEach((param) => {\n properties[param.key] = {\n type: 'string',\n description: descriptionToText(param.description),\n };\n });\n\n return {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties,\n },\n },\n } satisfies ContentObject,\n };\n } else if (body.mode === 'formdata') {\n const properties: SchemaObject['properties'] = {};\n (body.formdata || [])\n .filter((param) => !param.disabled)\n .forEach((param) => {\n if (param.type === 'text') {\n properties[param.key] = {\n type: 'string',\n description: descriptionToText(param.description),\n };\n } else if (param.type === 'file') {\n properties[param.key] = {\n type: 'string',\n format: 'binary',\n description: descriptionToText(param.description),\n };\n }\n });\n\n return {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties,\n },\n },\n } satisfies ContentObject,\n };\n }\n\n throw new Error(\n `Unsupported request body mode: ${body.mode}. Supported modes are: raw, urlencoded, formdata`,\n );\n}\n\nfunction bodyToSchema(bodyString?: string | null): SchemaObject | undefined {\n if (!bodyString) {\n return undefined;\n }\n\n let body: unknown;\n try {\n body = JSON.parse(bodyString.normalize('NFKD'));\n } catch (error) {\n console.warn(\n `Failed to parse JSON body: ${bodyString}. Treating as plain string.`,\n error,\n );\n return { type: 'string', example: bodyString };\n }\n\n return toSchema(body);\n}\n\nfunction toSchema(body: unknown | unknown[]): any {\n const typeMap: Record<string, string> = {\n '<number>': 'number',\n '<string>': 'string',\n '<boolean>': 'boolean',\n false: 'boolean',\n true: 'boolean',\n };\n if (Array.isArray(body)) {\n return {\n type: 'array',\n items: toSchema(body[0]),\n };\n }\n if (typeof body === 'object' && body !== null) {\n const properties: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(body)) {\n properties[key] = toSchema(value);\n }\n return {\n type: 'object',\n properties,\n };\n }\n if (typeof body === 'string') {\n return {\n type: typeMap[body] ?? 'string',\n };\n }\n if (typeof body === 'number') {\n return {\n type: 'number',\n };\n }\n if (typeof body === 'boolean') {\n return {\n type: 'boolean',\n };\n }\n if (body === null) {\n return {\n type: 'null',\n };\n }\n console.warn(`Unknown type for body: ${body}. Defaulting to string.`, body);\n return {\n type: 'string',\n };\n}\n\nexport function convertPostmanToOpenAPI(\n collection: PostmanCollection,\n): OpenAPIObject {\n const tags: TagObject[] = [];\n const paths: PathsObject = {};\n const securitySchemes: Record<string, SecuritySchemeObject> = {};\n\n if (collection.auth) {\n processAuthScheme(collection.auth, securitySchemes);\n }\n processItems(collection.item, [], tags, paths, securitySchemes);\n return {\n openapi: '3.1.0',\n info: {\n title: collection.info.name,\n version: '1.0.0',\n description: descriptionToText(collection.info.description),\n },\n tags,\n paths,\n // Only add security at top level if there's collection auth\n security: collection.auth\n ? generateSecurityRequirement(collection.auth, securitySchemes)\n : undefined,\n components:\n Object.keys(securitySchemes).length > 0\n ? {\n securitySchemes,\n }\n : undefined,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AA+BzB,SAAS,kBAAkB,aAA2B;AACpD,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,gBAAgB,UAAU;AACnC,WAAO;AAAA,EACT;AACA,MAAI,YAAY,SAAS;AACvB,WAAO,YAAY;AAAA,EACrB;AACA,SAAO;AACT;AAgBA,SAAS,SAAS,MAAgD;AAChE,SAAO,UAAU;AACnB;AAEA,SAAS,UACP,MACmD;AACnD,SAAO,CAAC,CAAC,KAAK;AAChB;AAOA,SAAS,aACP,OACA,YACA,YACA,OACA,iBACA;AACA,aAAW,QAAQ,OAAO;AACxB,QAAI,CAAC,SAAS,IAAI,KAAK,CAAC,UAAU,IAAI,GAAG;AACvC,cAAQ;AAAA,QACN,iBAAiB,KAAK,IAAI;AAAA,MAC5B;AACA;AAAA,IACF;AAEA,QAAI,SAAS,IAAI,GAAG;AAElB,UAAI,KAAK,MAAM;AACb,0BAAkB,KAAK,MAAM,eAAe;AAAA,MAC9C;AAGA,UAAI,CAAC,WAAW,KAAK,CAAC,QAAQ,IAAI,SAAS,KAAK,IAAI,GAAG;AACrD,mBAAW,KAAK;AAAA,UACd,MAAM,KAAK;AAAA,UACX,aAAa,kBAAkB,KAAK,WAAW;AAAA,QACjD,CAAC;AAAA,MACH;AAEA,YAAM,cAAc,CAAC,GAAG,YAAY,KAAK,IAAI;AAC7C,mBAAa,KAAK,MAAM,aAAa,YAAY,OAAO,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