@sdk-it/spec 0.25.0 → 0.26.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 +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/dist/lib/create-operation.d.ts +28 -0
- package/dist/lib/create-operation.d.ts.map +1 -0
- package/dist/lib/create-operation.js +62 -0
- package/dist/lib/create-operation.js.map +7 -0
- package/dist/lib/for-each-operation.d.ts.map +1 -1
- package/dist/lib/for-each-operation.js +0 -3
- package/dist/lib/for-each-operation.js.map +2 -2
- package/dist/lib/guess/guess-resource.d.ts +7 -0
- package/dist/lib/guess/guess-resource.d.ts.map +1 -0
- package/dist/lib/guess/guess-resource.js +76 -0
- package/dist/lib/guess/guess-resource.js.map +7 -0
- package/dist/lib/metadata.test.js +359 -0
- package/dist/lib/metadata.test.js.map +7 -0
- package/dist/lib/operation.d.ts +1 -32
- package/dist/lib/operation.d.ts.map +1 -1
- package/dist/lib/operation.js +32 -312
- package/dist/lib/operation.js.map +2 -2
- package/dist/lib/options.d.ts +42 -1
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/options.js +23 -8
- package/dist/lib/options.js.map +2 -2
- package/dist/lib/pagination/guess-pagination.d.ts +50 -0
- package/dist/lib/pagination/guess-pagination.d.ts.map +1 -0
- package/dist/lib/pagination/guess-pagination.js +222 -0
- package/dist/lib/pagination/guess-pagination.js.map +7 -0
- package/dist/lib/pagination/pagination.d.ts +2 -49
- package/dist/lib/pagination/pagination.d.ts.map +1 -1
- package/dist/lib/pagination/pagination.js +43 -209
- package/dist/lib/pagination/pagination.js.map +2 -2
- package/dist/lib/pagination/pagination.test.js +2 -1
- package/dist/lib/pagination/pagination.test.js.map +2 -2
- package/dist/lib/sidebar.d.ts +4 -23
- package/dist/lib/sidebar.d.ts.map +1 -1
- package/dist/lib/sidebar.js +22 -65
- package/dist/lib/sidebar.js.map +3 -3
- package/dist/lib/tune-request-body.d.ts +5 -0
- package/dist/lib/tune-request-body.d.ts.map +1 -0
- package/dist/lib/tune-request-body.js +88 -0
- package/dist/lib/tune-request-body.js.map +7 -0
- package/dist/lib/tune-response.d.ts +5 -0
- package/dist/lib/tune-response.d.ts.map +1 -0
- package/dist/lib/tune-response.js +102 -0
- package/dist/lib/tune-response.js.map +7 -0
- package/dist/lib/types.d.ts +8 -3
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/lib/tune-response.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n MediaTypeObject,\n OperationObject,\n ResponseObject,\n} from 'openapi3-ts/oas31';\n\nimport { isRef, parseRef, resolveRef } from '@sdk-it/core/ref.js';\nimport { isEmpty, pascalcase } from '@sdk-it/core/utils.js';\n\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport {\n isSseContentType,\n isSuccessStatusCode,\n isTextContentType,\n parseJsonContentType,\n} from './is.js';\nimport { type ResponsesConfig } from './options.js';\nimport type { OurOpenAPIObject } from './types.js';\n\nexport function resolveResponses(\n spec: OurOpenAPIObject,\n operationId: string,\n operation: OperationObject,\n responsesConfig?: ResponsesConfig,\n) {\n const responses = operation.responses ?? {};\n operation.responses ??= {};\n let foundSuccessResponse = false;\n for (const status in responses) {\n if (status === 'default') {\n delete responses[status]; // Skip default response\n continue;\n }\n // use structuredClone to avoid mutating a response object\n // that is referenced by multiple operations\n operation.responses[status] = structuredClone(\n resolveRef<ResponseObject>(spec, responses[status]),\n );\n\n if (isSuccessStatusCode(status)) {\n foundSuccessResponse = true;\n }\n }\n\n if (!foundSuccessResponse) {\n operation.responses['200'] = {\n description: 'OK',\n content: {\n 'application/json': {\n schema: {},\n },\n },\n };\n }\n\n for (const status in operation.responses) {\n const response = operation.responses[status] as ResponseObject;\n const statusCode = +status;\n\n const outputName =\n statusCode !== 200\n ? pascalcase(operationId) + status\n : findUniqueSchemaName(spec, operationId, [\n 'output',\n 'payload',\n 'result',\n ]);\n\n if (!responsesConfig?.flattenErrorResponses) {\n if (!isSuccessStatusCode(status)) {\n continue;\n }\n }\n\n if (isEmpty(response.content)) {\n response.content = {\n 'application/octet-stream': {},\n };\n }\n\n response['x-response-name'] = outputName;\n\n // if (isErrorStatusCode(status)) {\n // const mediaType = response.content?.['application/json'];\n // if (mediaType && isRef(mediaType.schema)) {\n // const { model } = parseRef(mediaType.schema.$ref);\n // Object.assign(config.spec.components.schemas[model], {\n // 'x-responsebody': true,\n // // do not assign response ref to a group\n // // because they are supposed to be in a separate file only inlined\n // // schemas are grouped by operationId\n // });\n // response['x-response-name'] = model;\n // }\n // continue;\n // }\n\n for (const [contentType, mediaType] of Object.entries(\n response.content as Record<string, MediaTypeObject>,\n )) {\n if (isRef(mediaType.schema)) {\n const { model } = parseRef(mediaType.schema.$ref);\n Object.assign(spec.components.schemas[model], {\n 'x-responsebody': true,\n // do not assign response ref to a group\n // because they are supposed to be in a separate file only inlined\n // schemas are grouped by operationId\n });\n response['x-response-name'] = model;\n continue;\n }\n if (isSseContentType(contentType)) {\n continue; // Skip SSE content types\n }\n if (parseJsonContentType(contentType)) {\n if (isEmpty(mediaType.schema)) {\n // add \"additionalProperties\" because we're certain this is a response body is of json type\n spec.components.schemas[outputName] = {\n type: 'object',\n additionalProperties: true,\n };\n }\n } else {\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n 'x-stream': !isTextContentType(contentType),\n };\n }\n\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n ...mediaType.schema,\n 'x-responsebody': true,\n 'x-response-group': operationId,\n };\n operation.responses[status].content[contentType].schema = {\n $ref: `#/components/schemas/${outputName}`,\n };\n }\n }\n\n return operation.responses;\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,OAAO,UAAU,kBAAkB;AAC5C,SAAS,SAAS,kBAAkB;AAEpC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IAAI,SAAS,UAAU,OAAO,IAAI;AAChD,eAAO,OAAO,KAAK,WAAW,QAAQ,KAAK,GAAG;AAAA,UAC5C,kBAAkB;AAAA;AAAA;AAAA;AAAA,QAIpB,CAAC;AACD,iBAAS,iBAAiB,IAAI;AAC9B;AAAA,MACF;AACA,UAAI,iBAAiB,WAAW,GAAG;AACjC;AAAA,MACF;AACA,UAAI,qBAAqB,WAAW,GAAG;AACrC,YAAI,QAAQ,UAAU,MAAM,GAAG;AAE7B,eAAK,WAAW,QAAQ,UAAU,IAAI;AAAA,YACpC,MAAM;AAAA,YACN,sBAAsB;AAAA,UACxB;AAAA,QACF;AAAA,MACF,OAAO;AACL,aAAK,WAAW,QAAQ,UAAU,IAAI;AAAA,UACpC,GAAG,KAAK,WAAW,QAAQ,UAAU;AAAA,UACrC,YAAY,CAAC,kBAAkB,WAAW;AAAA,QAC5C;AAAA,MACF;AAEA,WAAK,WAAW,QAAQ,UAAU,IAAI;AAAA,QACpC,GAAG,KAAK,WAAW,QAAQ,UAAU;AAAA,QACrC,GAAG,UAAU;AAAA,QACb,kBAAkB;AAAA,QAClB,oBAAoB;AAAA,MACtB;AACA,gBAAU,UAAU,MAAM,EAAE,QAAQ,WAAW,EAAE,SAAS;AAAA,QACxD,MAAM,wBAAwB,UAAU;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,SAAO,UAAU;AACnB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ComponentsObject, MediaTypeObject, OpenAPIObject, OperationObject, ParameterObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject, SecuritySchemeObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PaginationGuess } from './pagination/guess-pagination.js';
|
|
3
|
+
import type { SidebarData, TagGroups } from './sidebar.js';
|
|
3
4
|
export interface OurOpenAPIObject extends OpenAPIObject {
|
|
4
5
|
'x-sdk-augmented'?: boolean;
|
|
5
6
|
'x-docs': SidebarData;
|
|
7
|
+
'x-tagGroups': TagGroups[];
|
|
6
8
|
components: Omit<ComponentsObject, 'schemas'> & {
|
|
7
9
|
schemas: Record<string, SchemaObject | ReferenceObject>;
|
|
8
10
|
securitySchemes: Record<string, SecuritySchemeObject | ReferenceObject>;
|
|
@@ -18,20 +20,23 @@ export type TunedOperationObject = Omit<OperationObject, 'operationId' | 'tags'
|
|
|
18
20
|
tags: string[];
|
|
19
21
|
operationId: string;
|
|
20
22
|
parameters: ParameterObject[];
|
|
23
|
+
['x-fn-name']: string;
|
|
24
|
+
['x-fn-group']?: string;
|
|
21
25
|
responses: Record<string, Omit<ResponseObject, 'content'> & {
|
|
22
26
|
content: Record<string, MediaTypeObject>;
|
|
23
27
|
}>;
|
|
24
28
|
requestBody: OurRequestBodyObject;
|
|
25
29
|
};
|
|
26
30
|
export interface OperationEntry {
|
|
27
|
-
name?: string;
|
|
28
31
|
method: string;
|
|
29
32
|
path: string;
|
|
30
|
-
groupName: string;
|
|
31
33
|
tag: string;
|
|
32
34
|
}
|
|
33
35
|
export type Operation = {
|
|
34
36
|
entry: OperationEntry;
|
|
35
37
|
operation: TunedOperationObject;
|
|
36
38
|
};
|
|
39
|
+
export type OperationPagination = PaginationGuess & {
|
|
40
|
+
items: string;
|
|
41
|
+
};
|
|
37
42
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,eAAe,EACf,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM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,CAAC;IACtB,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CACf,MAAM,EACN,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG;QAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;KAC1C,CACF,CAAC;IACF,WAAW,EAAE,oBAAoB,CAAC;CACnC,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AACD,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG;IAClD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdk-it/spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"!**/*.tsbuildinfo"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sdk-it/core": "0.
|
|
29
|
+
"@sdk-it/core": "0.26.0",
|
|
30
30
|
"openapi3-ts": "4.4.0",
|
|
31
31
|
"pluralize": "^8.0.0",
|
|
32
32
|
"stringcase": "^4.3.1",
|