@skmtc/core 0.0.790 → 0.0.791
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/esm/oas/number/Number.d.ts +179 -1
- package/esm/oas/number/Number.d.ts.map +1 -1
- package/esm/oas/number/Number.js +161 -1
- package/esm/oas/response/Response.d.ts +190 -0
- package/esm/oas/response/Response.d.ts.map +1 -1
- package/esm/oas/response/Response.js +183 -0
- package/esm/oas/void/Void.d.ts +130 -3
- package/esm/oas/void/Void.d.ts.map +1 -1
- package/esm/oas/void/Void.js +125 -3
- package/package.json +1 -1
- package/script/oas/number/Number.d.ts +179 -1
- package/script/oas/number/Number.d.ts.map +1 -1
- package/script/oas/number/Number.js +161 -1
- package/script/oas/response/Response.d.ts +190 -0
- package/script/oas/response/Response.d.ts.map +1 -1
- package/script/oas/response/Response.js +183 -0
- package/script/oas/void/Void.d.ts +130 -3
- package/script/oas/void/Void.d.ts.map +1 -1
- package/script/oas/void/Void.js +125 -3
|
@@ -1,13 +1,140 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
2
|
import type { OasRef } from '../ref/Ref.js';
|
|
3
|
+
/**
|
|
4
|
+
* Constructor fields for {@link OasVoid}.
|
|
5
|
+
*/
|
|
3
6
|
export type VoidFields = {
|
|
7
|
+
/** A short summary of the void schema */
|
|
4
8
|
title?: string;
|
|
9
|
+
/** A description of what the void represents */
|
|
5
10
|
description?: string;
|
|
6
11
|
};
|
|
7
12
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
13
|
+
* Represents a void (empty) schema in the OpenAPI Specification.
|
|
14
|
+
*
|
|
15
|
+
* The `OasVoid` class represents the absence of a value or content, commonly used
|
|
16
|
+
* in scenarios where operations don't return any content (like HTTP 204 No Content
|
|
17
|
+
* responses), optional properties that might not be present, or fallback cases
|
|
18
|
+
* in schema processing where no specific type is defined.
|
|
19
|
+
*
|
|
20
|
+
* This class serves as a type-safe representation of "nothing" in the OpenAPI
|
|
21
|
+
* type system, enabling proper handling of void responses and empty schemas
|
|
22
|
+
* throughout the SKMTC pipeline.
|
|
23
|
+
*
|
|
24
|
+
* ## Key Features
|
|
25
|
+
*
|
|
26
|
+
* - **Empty Content Representation**: Models operations that return no content
|
|
27
|
+
* - **Type Safety**: Provides a concrete type for void/empty scenarios
|
|
28
|
+
* - **Schema Processing**: Handles missing or undefined schema definitions
|
|
29
|
+
* - **Factory Pattern**: Convenient `empty()` static method for common usage
|
|
30
|
+
* - **Pipeline Integration**: Works seamlessly with the SKMTC processing pipeline
|
|
31
|
+
*
|
|
32
|
+
* @example Basic void schema for empty responses
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { OasVoid } from '@skmtc/core';
|
|
35
|
+
*
|
|
36
|
+
* const emptyResponse = new OasVoid({
|
|
37
|
+
* title: 'No Content',
|
|
38
|
+
* description: 'Operation completed successfully with no response body'
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Used for HTTP 204 No Content responses
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Using the empty factory method
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const voidSchema = OasVoid.empty();
|
|
47
|
+
*
|
|
48
|
+
* // Equivalent to new OasVoid({})
|
|
49
|
+
* // Commonly used as a fallback or placeholder
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example In operation responses
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const deleteOperation = new OasOperation({
|
|
55
|
+
* path: '/users/{id}',
|
|
56
|
+
* method: 'delete',
|
|
57
|
+
* responses: {
|
|
58
|
+
* '204': new OasResponse({
|
|
59
|
+
* description: 'User deleted successfully',
|
|
60
|
+
* content: {
|
|
61
|
+
* // No content for successful deletion
|
|
62
|
+
* }
|
|
63
|
+
* }),
|
|
64
|
+
* '404': new OasResponse({
|
|
65
|
+
* description: 'User not found'
|
|
66
|
+
* })
|
|
67
|
+
* }
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // The void response indicates successful deletion with no return value
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example As a schema fallback
|
|
74
|
+
* ```typescript
|
|
75
|
+
* function processSchema(schema: OasSchema | undefined): OasSchema {
|
|
76
|
+
* if (!schema) {
|
|
77
|
+
* return OasVoid.empty(); // Fallback for missing schemas
|
|
78
|
+
* }
|
|
79
|
+
* return schema;
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* // Ensures type safety even when schemas are missing
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example In optional object properties
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const userProfile = new OasObject({
|
|
88
|
+
* properties: {
|
|
89
|
+
* name: new OasString({ description: 'User name' }),
|
|
90
|
+
* avatar: new OasString({
|
|
91
|
+
* description: 'Avatar URL',
|
|
92
|
+
* nullable: true
|
|
93
|
+
* }),
|
|
94
|
+
* // Some properties might be processed as void if not defined
|
|
95
|
+
* metadata: processOptionalSchema(rawSchema.metadata) // might return OasVoid
|
|
96
|
+
* }
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example HTTP operations with void responses
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // Common HTTP operations that return void/empty content:
|
|
103
|
+
*
|
|
104
|
+
* // DELETE - Resource removal
|
|
105
|
+
* const deleteResponse = new OasVoid({
|
|
106
|
+
* title: 'Deletion Successful',
|
|
107
|
+
* description: 'Resource was successfully deleted'
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // PUT - Update with no response body
|
|
111
|
+
* const updateResponse = new OasVoid({
|
|
112
|
+
* title: 'Update Successful',
|
|
113
|
+
* description: 'Resource was successfully updated'
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // POST - Action with no return value
|
|
117
|
+
* const actionResponse = new OasVoid({
|
|
118
|
+
* title: 'Action Completed',
|
|
119
|
+
* description: 'Action was successfully performed'
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example In code generation
|
|
124
|
+
* ```typescript
|
|
125
|
+
* class TypeScriptGenerator extends ModelBase {
|
|
126
|
+
* generateType(schema: OasSchema): string {
|
|
127
|
+
* if (schema.type === 'void') {
|
|
128
|
+
* return 'void'; // TypeScript void type
|
|
129
|
+
* }
|
|
130
|
+
* // Handle other types...
|
|
131
|
+
* return 'unknown';
|
|
132
|
+
* }
|
|
133
|
+
* }
|
|
134
|
+
*
|
|
135
|
+
* // Generates:
|
|
136
|
+
* // async function deleteUser(id: string): Promise<void>
|
|
137
|
+
* ```
|
|
11
138
|
*/
|
|
12
139
|
export declare class OasVoid {
|
|
13
140
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Void.d.ts","sourceRoot":"","sources":["../../../src/oas/void/Void.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"Void.d.ts","sourceRoot":"","sources":["../../../src/oas/void/Void.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8HG;AACH,qBAAa,OAAO;IAClB;;;OAGG;IACH,OAAO,EAAG,QAAQ,CAAS;IAC3B;;OAEG;IACH,IAAI,EAAG,MAAM,CAAS;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEnB,MAAM,GAAE,UAAe;IAKnC,MAAM,CAAC,KAAK,IAAI,OAAO;IAIvB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,OAAO;IAIlB,WAAW,IAAI,OAAO;CAGvB"}
|
package/script/oas/void/Void.js
CHANGED
|
@@ -3,9 +3,131 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OasVoid = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Represents a void (empty) schema in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* The `OasVoid` class represents the absence of a value or content, commonly used
|
|
9
|
+
* in scenarios where operations don't return any content (like HTTP 204 No Content
|
|
10
|
+
* responses), optional properties that might not be present, or fallback cases
|
|
11
|
+
* in schema processing where no specific type is defined.
|
|
12
|
+
*
|
|
13
|
+
* This class serves as a type-safe representation of "nothing" in the OpenAPI
|
|
14
|
+
* type system, enabling proper handling of void responses and empty schemas
|
|
15
|
+
* throughout the SKMTC pipeline.
|
|
16
|
+
*
|
|
17
|
+
* ## Key Features
|
|
18
|
+
*
|
|
19
|
+
* - **Empty Content Representation**: Models operations that return no content
|
|
20
|
+
* - **Type Safety**: Provides a concrete type for void/empty scenarios
|
|
21
|
+
* - **Schema Processing**: Handles missing or undefined schema definitions
|
|
22
|
+
* - **Factory Pattern**: Convenient `empty()` static method for common usage
|
|
23
|
+
* - **Pipeline Integration**: Works seamlessly with the SKMTC processing pipeline
|
|
24
|
+
*
|
|
25
|
+
* @example Basic void schema for empty responses
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { OasVoid } from '@skmtc/core';
|
|
28
|
+
*
|
|
29
|
+
* const emptyResponse = new OasVoid({
|
|
30
|
+
* title: 'No Content',
|
|
31
|
+
* description: 'Operation completed successfully with no response body'
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Used for HTTP 204 No Content responses
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example Using the empty factory method
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const voidSchema = OasVoid.empty();
|
|
40
|
+
*
|
|
41
|
+
* // Equivalent to new OasVoid({})
|
|
42
|
+
* // Commonly used as a fallback or placeholder
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example In operation responses
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const deleteOperation = new OasOperation({
|
|
48
|
+
* path: '/users/{id}',
|
|
49
|
+
* method: 'delete',
|
|
50
|
+
* responses: {
|
|
51
|
+
* '204': new OasResponse({
|
|
52
|
+
* description: 'User deleted successfully',
|
|
53
|
+
* content: {
|
|
54
|
+
* // No content for successful deletion
|
|
55
|
+
* }
|
|
56
|
+
* }),
|
|
57
|
+
* '404': new OasResponse({
|
|
58
|
+
* description: 'User not found'
|
|
59
|
+
* })
|
|
60
|
+
* }
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* // The void response indicates successful deletion with no return value
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example As a schema fallback
|
|
67
|
+
* ```typescript
|
|
68
|
+
* function processSchema(schema: OasSchema | undefined): OasSchema {
|
|
69
|
+
* if (!schema) {
|
|
70
|
+
* return OasVoid.empty(); // Fallback for missing schemas
|
|
71
|
+
* }
|
|
72
|
+
* return schema;
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* // Ensures type safety even when schemas are missing
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example In optional object properties
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const userProfile = new OasObject({
|
|
81
|
+
* properties: {
|
|
82
|
+
* name: new OasString({ description: 'User name' }),
|
|
83
|
+
* avatar: new OasString({
|
|
84
|
+
* description: 'Avatar URL',
|
|
85
|
+
* nullable: true
|
|
86
|
+
* }),
|
|
87
|
+
* // Some properties might be processed as void if not defined
|
|
88
|
+
* metadata: processOptionalSchema(rawSchema.metadata) // might return OasVoid
|
|
89
|
+
* }
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example HTTP operations with void responses
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Common HTTP operations that return void/empty content:
|
|
96
|
+
*
|
|
97
|
+
* // DELETE - Resource removal
|
|
98
|
+
* const deleteResponse = new OasVoid({
|
|
99
|
+
* title: 'Deletion Successful',
|
|
100
|
+
* description: 'Resource was successfully deleted'
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* // PUT - Update with no response body
|
|
104
|
+
* const updateResponse = new OasVoid({
|
|
105
|
+
* title: 'Update Successful',
|
|
106
|
+
* description: 'Resource was successfully updated'
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* // POST - Action with no return value
|
|
110
|
+
* const actionResponse = new OasVoid({
|
|
111
|
+
* title: 'Action Completed',
|
|
112
|
+
* description: 'Action was successfully performed'
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @example In code generation
|
|
117
|
+
* ```typescript
|
|
118
|
+
* class TypeScriptGenerator extends ModelBase {
|
|
119
|
+
* generateType(schema: OasSchema): string {
|
|
120
|
+
* if (schema.type === 'void') {
|
|
121
|
+
* return 'void'; // TypeScript void type
|
|
122
|
+
* }
|
|
123
|
+
* // Handle other types...
|
|
124
|
+
* return 'unknown';
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* // Generates:
|
|
129
|
+
* // async function deleteUser(id: string): Promise<void>
|
|
130
|
+
* ```
|
|
9
131
|
*/
|
|
10
132
|
class OasVoid {
|
|
11
133
|
constructor(fields = {}) {
|