@skmtc/core 0.0.804 → 0.0.806
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/helpers/strings.d.ts +44 -0
- package/esm/helpers/strings.d.ts.map +1 -1
- package/esm/helpers/strings.js +44 -0
- package/esm/oas/contact/Contact.d.ts +42 -0
- package/esm/oas/contact/Contact.d.ts.map +1 -1
- package/esm/oas/contact/Contact.js +36 -0
- package/esm/oas/info/Info.d.ts +36 -0
- package/esm/oas/info/Info.d.ts.map +1 -1
- package/esm/oas/info/Info.js +37 -0
- package/esm/oas/mediaType/MediaType.d.ts +17 -0
- package/esm/oas/mediaType/MediaType.d.ts.map +1 -1
- package/esm/oas/mediaType/MediaType.js +17 -0
- package/esm/run/toV3JsonDocument.d.ts +54 -0
- package/esm/run/toV3JsonDocument.d.ts.map +1 -1
- package/esm/run/toV3JsonDocument.js +54 -0
- package/esm/types/Brand.d.ts +41 -0
- package/esm/types/Brand.d.ts.map +1 -1
- package/esm/types/Brand.js +41 -0
- package/esm/types/Enrichments.d.ts +58 -0
- package/esm/types/Enrichments.d.ts.map +1 -1
- package/esm/types/Enrichments.js +58 -0
- package/esm/types/Settings.d.ts +50 -0
- package/esm/types/Settings.d.ts.map +1 -1
- package/esm/types/Settings.js +50 -0
- package/package.json +1 -1
- package/script/helpers/strings.d.ts +44 -0
- package/script/helpers/strings.d.ts.map +1 -1
- package/script/helpers/strings.js +44 -0
- package/script/oas/contact/Contact.d.ts +42 -0
- package/script/oas/contact/Contact.d.ts.map +1 -1
- package/script/oas/contact/Contact.js +36 -0
- package/script/oas/info/Info.d.ts +36 -0
- package/script/oas/info/Info.d.ts.map +1 -1
- package/script/oas/info/Info.js +37 -0
- package/script/oas/mediaType/MediaType.d.ts +17 -0
- package/script/oas/mediaType/MediaType.d.ts.map +1 -1
- package/script/oas/mediaType/MediaType.js +17 -0
- package/script/run/toV3JsonDocument.d.ts +54 -0
- package/script/run/toV3JsonDocument.d.ts.map +1 -1
- package/script/run/toV3JsonDocument.js +54 -0
- package/script/types/Brand.d.ts +41 -0
- package/script/types/Brand.d.ts.map +1 -1
- package/script/types/Brand.js +41 -0
- package/script/types/Enrichments.d.ts +58 -0
- package/script/types/Enrichments.d.ts.map +1 -1
- package/script/types/Enrichments.js +58 -0
- package/script/types/Settings.d.ts +50 -0
- package/script/types/Settings.d.ts.map +1 -1
- package/script/types/Settings.js +50 -0
package/esm/helpers/strings.d.ts
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview String Manipulation Utilities for SKMTC Core
|
|
3
|
+
*
|
|
4
|
+
* This module provides a comprehensive collection of string manipulation utilities
|
|
5
|
+
* commonly needed for code generation, identifier transformation, and text processing
|
|
6
|
+
* within the SKMTC pipeline. These utilities handle case conversions, pluralization,
|
|
7
|
+
* sanitization, and various text transformations.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Features
|
|
10
|
+
*
|
|
11
|
+
* - **Case Conversion**: camelCase, PascalCase, snake_case, kebab-case, and more
|
|
12
|
+
* - **Pluralization**: Smart singular/plural transformations with irregular forms
|
|
13
|
+
* - **Sanitization**: Clean strings for use as identifiers and file names
|
|
14
|
+
* - **Text Processing**: Trimming, padding, wrapping, and formatting utilities
|
|
15
|
+
* - **Unicode Support**: Proper handling of international characters
|
|
16
|
+
*
|
|
17
|
+
* @example Case conversions
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { capitalize, camelCase, pascalCase } from '@skmtc/core/strings';
|
|
20
|
+
*
|
|
21
|
+
* capitalize('hello world'); // 'Hello world'
|
|
22
|
+
* camelCase('user_profile_data'); // 'userProfileData'
|
|
23
|
+
* pascalCase('api-response-type'); // 'ApiResponseType'
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Pluralization
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { pluralize, singularize } from '@skmtc/core/strings';
|
|
29
|
+
*
|
|
30
|
+
* pluralize('user'); // 'users'
|
|
31
|
+
* pluralize('child'); // 'children'
|
|
32
|
+
* singularize('categories'); // 'category'
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Identifier sanitization
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { sanitizeIdentifier, toFileName } from '@skmtc/core/strings';
|
|
38
|
+
*
|
|
39
|
+
* sanitizeIdentifier('123-invalid name!'); // 'invalid_name'
|
|
40
|
+
* toFileName('My API Response'); // 'my-api-response'
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @module strings
|
|
44
|
+
*/
|
|
1
45
|
/**
|
|
2
46
|
* Capitalizes the first character of a string.
|
|
3
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/helpers/strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,sBAAsB,CAAC;AAE9B,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAExC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAE1C,CAAA;AAED;;GAEG;AACH,KAAK,gBAAgB,GAAG;IACtB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,iBAAgB,gBAAqB,KAAG,MAgB9E,CAAA"}
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/helpers/strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH;;;;;;;;;;;;GAYG;AACH,OAAO,sBAAsB,CAAC;AAE9B,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAExC,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAE1C,CAAA;AAED;;GAEG;AACH,KAAK,gBAAgB,GAAG;IACtB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,iBAAgB,gBAAqB,KAAG,MAgB9E,CAAA"}
|
package/esm/helpers/strings.js
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview String Manipulation Utilities for SKMTC Core
|
|
3
|
+
*
|
|
4
|
+
* This module provides a comprehensive collection of string manipulation utilities
|
|
5
|
+
* commonly needed for code generation, identifier transformation, and text processing
|
|
6
|
+
* within the SKMTC pipeline. These utilities handle case conversions, pluralization,
|
|
7
|
+
* sanitization, and various text transformations.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Features
|
|
10
|
+
*
|
|
11
|
+
* - **Case Conversion**: camelCase, PascalCase, snake_case, kebab-case, and more
|
|
12
|
+
* - **Pluralization**: Smart singular/plural transformations with irregular forms
|
|
13
|
+
* - **Sanitization**: Clean strings for use as identifiers and file names
|
|
14
|
+
* - **Text Processing**: Trimming, padding, wrapping, and formatting utilities
|
|
15
|
+
* - **Unicode Support**: Proper handling of international characters
|
|
16
|
+
*
|
|
17
|
+
* @example Case conversions
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { capitalize, camelCase, pascalCase } from '@skmtc/core/strings';
|
|
20
|
+
*
|
|
21
|
+
* capitalize('hello world'); // 'Hello world'
|
|
22
|
+
* camelCase('user_profile_data'); // 'userProfileData'
|
|
23
|
+
* pascalCase('api-response-type'); // 'ApiResponseType'
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Pluralization
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { pluralize, singularize } from '@skmtc/core/strings';
|
|
29
|
+
*
|
|
30
|
+
* pluralize('user'); // 'users'
|
|
31
|
+
* pluralize('child'); // 'children'
|
|
32
|
+
* singularize('categories'); // 'category'
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Identifier sanitization
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { sanitizeIdentifier, toFileName } from '@skmtc/core/strings';
|
|
38
|
+
*
|
|
39
|
+
* sanitizeIdentifier('123-invalid name!'); // 'invalid_name'
|
|
40
|
+
* toFileName('My API Response'); // 'my-api-response'
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @module strings
|
|
44
|
+
*/
|
|
1
45
|
/**
|
|
2
46
|
* Capitalizes the first character of a string.
|
|
3
47
|
*
|
|
@@ -1,15 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructor fields for {@link OasContact}.
|
|
3
|
+
*
|
|
4
|
+
* Defines the configuration options for creating contact information,
|
|
5
|
+
* including name, URL, email, and extension fields.
|
|
6
|
+
*/
|
|
1
7
|
export type ContactFields = {
|
|
2
8
|
name?: string;
|
|
3
9
|
url?: string;
|
|
4
10
|
email?: string;
|
|
5
11
|
extensionFields?: Record<string, unknown>;
|
|
6
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Represents a Contact Object in the OpenAPI Specification.
|
|
15
|
+
*
|
|
16
|
+
* The `OasContact` class encapsulates contact information for the API,
|
|
17
|
+
* providing details about who to contact for support, questions, or issues.
|
|
18
|
+
* This information is typically displayed in API documentation.
|
|
19
|
+
*
|
|
20
|
+
* @example Basic contact information
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { OasContact } from '@skmtc/core';
|
|
23
|
+
*
|
|
24
|
+
* const contact = new OasContact({
|
|
25
|
+
* name: 'API Support Team',
|
|
26
|
+
* email: 'support@example.com'
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Complete contact details
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const fullContact = new OasContact({
|
|
33
|
+
* name: 'John Doe',
|
|
34
|
+
* url: 'https://example.com/contact',
|
|
35
|
+
* email: 'john@example.com'
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
7
39
|
export declare class OasContact {
|
|
40
|
+
/** Type identifier for this OAS contact object */
|
|
8
41
|
oasType: "contact";
|
|
42
|
+
/** The identifying name of the contact person/organization */
|
|
9
43
|
name: string | undefined;
|
|
44
|
+
/** URL pointing to the contact information */
|
|
10
45
|
url: string | undefined;
|
|
46
|
+
/** Email address of the contact person/organization */
|
|
11
47
|
email: string | undefined;
|
|
48
|
+
/** Custom extension fields (x-* properties) for additional contact metadata */
|
|
12
49
|
extensionFields: Record<string, unknown> | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new OasContact instance.
|
|
52
|
+
*
|
|
53
|
+
* @param fields - Contact information fields including name, URL, and email
|
|
54
|
+
*/
|
|
13
55
|
constructor(fields?: ContactFields);
|
|
14
56
|
}
|
|
15
57
|
//# sourceMappingURL=Contact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contact.d.ts","sourceRoot":"","sources":["../../../src/oas/contact/Contact.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,qBAAa,UAAU;IACrB,OAAO,EAAG,SAAS,CAAS;IAE5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"Contact.d.ts","sourceRoot":"","sources":["../../../src/oas/contact/Contact.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,UAAU;IACrB,kDAAkD;IAClD,OAAO,EAAG,SAAS,CAAS;IAE5B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,8CAA8C;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,uDAAuD;IACvD,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,+EAA+E;IAC/E,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IAEpD;;;;OAIG;gBACS,MAAM,GAAE,aAAkB;CAMvC"}
|
|
@@ -1,29 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a Contact Object in the OpenAPI Specification.
|
|
3
|
+
*
|
|
4
|
+
* The `OasContact` class encapsulates contact information for the API,
|
|
5
|
+
* providing details about who to contact for support, questions, or issues.
|
|
6
|
+
* This information is typically displayed in API documentation.
|
|
7
|
+
*
|
|
8
|
+
* @example Basic contact information
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { OasContact } from '@skmtc/core';
|
|
11
|
+
*
|
|
12
|
+
* const contact = new OasContact({
|
|
13
|
+
* name: 'API Support Team',
|
|
14
|
+
* email: 'support@example.com'
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example Complete contact details
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const fullContact = new OasContact({
|
|
21
|
+
* name: 'John Doe',
|
|
22
|
+
* url: 'https://example.com/contact',
|
|
23
|
+
* email: 'john@example.com'
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
1
27
|
export class OasContact {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new OasContact instance.
|
|
30
|
+
*
|
|
31
|
+
* @param fields - Contact information fields including name, URL, and email
|
|
32
|
+
*/
|
|
2
33
|
constructor(fields = {}) {
|
|
34
|
+
/** Type identifier for this OAS contact object */
|
|
3
35
|
Object.defineProperty(this, "oasType", {
|
|
4
36
|
enumerable: true,
|
|
5
37
|
configurable: true,
|
|
6
38
|
writable: true,
|
|
7
39
|
value: 'contact'
|
|
8
40
|
});
|
|
41
|
+
/** The identifying name of the contact person/organization */
|
|
9
42
|
Object.defineProperty(this, "name", {
|
|
10
43
|
enumerable: true,
|
|
11
44
|
configurable: true,
|
|
12
45
|
writable: true,
|
|
13
46
|
value: void 0
|
|
14
47
|
});
|
|
48
|
+
/** URL pointing to the contact information */
|
|
15
49
|
Object.defineProperty(this, "url", {
|
|
16
50
|
enumerable: true,
|
|
17
51
|
configurable: true,
|
|
18
52
|
writable: true,
|
|
19
53
|
value: void 0
|
|
20
54
|
});
|
|
55
|
+
/** Email address of the contact person/organization */
|
|
21
56
|
Object.defineProperty(this, "email", {
|
|
22
57
|
enumerable: true,
|
|
23
58
|
configurable: true,
|
|
24
59
|
writable: true,
|
|
25
60
|
value: void 0
|
|
26
61
|
});
|
|
62
|
+
/** Custom extension fields (x-* properties) for additional contact metadata */
|
|
27
63
|
Object.defineProperty(this, "extensionFields", {
|
|
28
64
|
enumerable: true,
|
|
29
65
|
configurable: true,
|
package/esm/oas/info/Info.d.ts
CHANGED
|
@@ -84,13 +84,49 @@ export type InfoFields = {
|
|
|
84
84
|
*/
|
|
85
85
|
export declare class OasInfo {
|
|
86
86
|
#private;
|
|
87
|
+
/** Type identifier for this OAS info object */
|
|
87
88
|
oasType: 'info';
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new OasInfo instance.
|
|
91
|
+
*
|
|
92
|
+
* @param fields - API information fields including title, version, description, and contact details
|
|
93
|
+
*/
|
|
88
94
|
constructor(fields: InfoFields);
|
|
95
|
+
/**
|
|
96
|
+
* Gets the API title.
|
|
97
|
+
*
|
|
98
|
+
* @returns The title of the API
|
|
99
|
+
*/
|
|
89
100
|
get title(): string;
|
|
101
|
+
/**
|
|
102
|
+
* Gets the API description.
|
|
103
|
+
*
|
|
104
|
+
* @returns Optional detailed description of the API's purpose and functionality
|
|
105
|
+
*/
|
|
90
106
|
get description(): string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Gets the terms of service URL.
|
|
109
|
+
*
|
|
110
|
+
* @returns Optional URL pointing to the API's terms of service
|
|
111
|
+
*/
|
|
91
112
|
get termsOfService(): string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Gets the contact information.
|
|
115
|
+
*
|
|
116
|
+
* @returns Optional contact information for API support and inquiries
|
|
117
|
+
*/
|
|
92
118
|
get contact(): OasContact | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Gets the license information.
|
|
121
|
+
*
|
|
122
|
+
* @returns Optional license information governing API usage
|
|
123
|
+
*/
|
|
93
124
|
get license(): OasLicense | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Gets the API version.
|
|
127
|
+
*
|
|
128
|
+
* @returns The version string of the API (e.g., '1.0.0', '2.1.3')
|
|
129
|
+
*/
|
|
94
130
|
get version(): string;
|
|
95
131
|
/** Specification Extension fields */
|
|
96
132
|
get extensionFields(): Record<string, unknown> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Info.d.ts","sourceRoot":"","sources":["../../../src/oas/info/Info.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,M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,CAAA;IAChC,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,qBAAa,OAAO;;IAClB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAS;IAIxB;;;;OAIG;gBACS,MAAM,EAAE,UAAU;IAI9B;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACH,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED;;;;OAIG;IACH,IAAI,cAAc,IAAI,MAAM,GAAG,SAAS,CAEvC;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,UAAU,GAAG,SAAS,CAEpC;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,UAAU,GAAG,SAAS,CAEpC;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,qCAAqC;IACrC,IAAI,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEzD;CACF"}
|
package/esm/oas/info/Info.js
CHANGED
|
@@ -74,31 +74,68 @@ import "../../_dnt.polyfills.js";
|
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
76
|
export class OasInfo {
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new OasInfo instance.
|
|
79
|
+
*
|
|
80
|
+
* @param fields - API information fields including title, version, description, and contact details
|
|
81
|
+
*/
|
|
77
82
|
constructor(fields) {
|
|
83
|
+
/** Type identifier for this OAS info object */
|
|
78
84
|
Object.defineProperty(this, "oasType", {
|
|
79
85
|
enumerable: true,
|
|
80
86
|
configurable: true,
|
|
81
87
|
writable: true,
|
|
82
88
|
value: 'info'
|
|
83
89
|
});
|
|
90
|
+
/** Private storage for all info fields */
|
|
84
91
|
_OasInfo_fields.set(this, void 0);
|
|
85
92
|
__classPrivateFieldSet(this, _OasInfo_fields, fields, "f");
|
|
86
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the API title.
|
|
96
|
+
*
|
|
97
|
+
* @returns The title of the API
|
|
98
|
+
*/
|
|
87
99
|
get title() {
|
|
88
100
|
return __classPrivateFieldGet(this, _OasInfo_fields, "f").title;
|
|
89
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets the API description.
|
|
104
|
+
*
|
|
105
|
+
* @returns Optional detailed description of the API's purpose and functionality
|
|
106
|
+
*/
|
|
90
107
|
get description() {
|
|
91
108
|
return __classPrivateFieldGet(this, _OasInfo_fields, "f").description;
|
|
92
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets the terms of service URL.
|
|
112
|
+
*
|
|
113
|
+
* @returns Optional URL pointing to the API's terms of service
|
|
114
|
+
*/
|
|
93
115
|
get termsOfService() {
|
|
94
116
|
return __classPrivateFieldGet(this, _OasInfo_fields, "f").termsOfService;
|
|
95
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Gets the contact information.
|
|
120
|
+
*
|
|
121
|
+
* @returns Optional contact information for API support and inquiries
|
|
122
|
+
*/
|
|
96
123
|
get contact() {
|
|
97
124
|
return __classPrivateFieldGet(this, _OasInfo_fields, "f").contact;
|
|
98
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Gets the license information.
|
|
128
|
+
*
|
|
129
|
+
* @returns Optional license information governing API usage
|
|
130
|
+
*/
|
|
99
131
|
get license() {
|
|
100
132
|
return __classPrivateFieldGet(this, _OasInfo_fields, "f").license;
|
|
101
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets the API version.
|
|
136
|
+
*
|
|
137
|
+
* @returns The version string of the API (e.g., '1.0.0', '2.1.3')
|
|
138
|
+
*/
|
|
102
139
|
get version() {
|
|
103
140
|
return __classPrivateFieldGet(this, _OasInfo_fields, "f").version;
|
|
104
141
|
}
|
|
@@ -96,13 +96,30 @@ export type MediaTypeFields = {
|
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
98
|
export declare class OasMediaType {
|
|
99
|
+
/** Type identifier for this OAS media type */
|
|
99
100
|
oasType: 'mediaType';
|
|
101
|
+
/** The media type identifier (e.g., 'application/json', 'text/xml') */
|
|
100
102
|
mediaType: string;
|
|
103
|
+
/** The schema defining the structure and validation rules for the content */
|
|
101
104
|
schema: OasSchema | OasRef<'schema'> | undefined;
|
|
105
|
+
/** Example values demonstrating the media type content */
|
|
102
106
|
examples: Record<string, OasExample | OasRef<'example'>> | undefined;
|
|
107
|
+
/** Custom extension fields (x-* properties) defined for this media type */
|
|
103
108
|
extensionFields: Record<string, unknown> | undefined;
|
|
109
|
+
/** Encoding information for multipart and form data serialization */
|
|
104
110
|
encoding?: Record<string, unknown> | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a new OasMediaType instance.
|
|
113
|
+
*
|
|
114
|
+
* @param fields - Media type configuration including content schema, examples, and encoding
|
|
115
|
+
*/
|
|
105
116
|
constructor(fields: MediaTypeFields);
|
|
117
|
+
/**
|
|
118
|
+
* Converts this OAS media type to an OpenAPI v3 JSON schema representation.
|
|
119
|
+
*
|
|
120
|
+
* @param options - Conversion options including reference handling and formatting preferences
|
|
121
|
+
* @returns OpenAPI v3 media type object with schema and examples
|
|
122
|
+
*/
|
|
106
123
|
toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.MediaTypeObject;
|
|
107
124
|
}
|
|
108
125
|
//# sourceMappingURL=MediaType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaType.d.ts","sourceRoot":"","sources":["../../../src/oas/mediaType/MediaType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAA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AAC,GAAG,SAAS,CAAA;IACpD,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IAC9C;;;;OAIG;gBACS,MAAM,EAAE,eAAe;IAQnC;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,eAAe;CAMtE"}
|
|
@@ -76,37 +76,48 @@
|
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
78
|
export class OasMediaType {
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new OasMediaType instance.
|
|
81
|
+
*
|
|
82
|
+
* @param fields - Media type configuration including content schema, examples, and encoding
|
|
83
|
+
*/
|
|
79
84
|
constructor(fields) {
|
|
85
|
+
/** Type identifier for this OAS media type */
|
|
80
86
|
Object.defineProperty(this, "oasType", {
|
|
81
87
|
enumerable: true,
|
|
82
88
|
configurable: true,
|
|
83
89
|
writable: true,
|
|
84
90
|
value: 'mediaType'
|
|
85
91
|
});
|
|
92
|
+
/** The media type identifier (e.g., 'application/json', 'text/xml') */
|
|
86
93
|
Object.defineProperty(this, "mediaType", {
|
|
87
94
|
enumerable: true,
|
|
88
95
|
configurable: true,
|
|
89
96
|
writable: true,
|
|
90
97
|
value: void 0
|
|
91
98
|
});
|
|
99
|
+
/** The schema defining the structure and validation rules for the content */
|
|
92
100
|
Object.defineProperty(this, "schema", {
|
|
93
101
|
enumerable: true,
|
|
94
102
|
configurable: true,
|
|
95
103
|
writable: true,
|
|
96
104
|
value: void 0
|
|
97
105
|
});
|
|
106
|
+
/** Example values demonstrating the media type content */
|
|
98
107
|
Object.defineProperty(this, "examples", {
|
|
99
108
|
enumerable: true,
|
|
100
109
|
configurable: true,
|
|
101
110
|
writable: true,
|
|
102
111
|
value: void 0
|
|
103
112
|
});
|
|
113
|
+
/** Custom extension fields (x-* properties) defined for this media type */
|
|
104
114
|
Object.defineProperty(this, "extensionFields", {
|
|
105
115
|
enumerable: true,
|
|
106
116
|
configurable: true,
|
|
107
117
|
writable: true,
|
|
108
118
|
value: void 0
|
|
109
119
|
});
|
|
120
|
+
/** Encoding information for multipart and form data serialization */
|
|
110
121
|
Object.defineProperty(this, "encoding", {
|
|
111
122
|
enumerable: true,
|
|
112
123
|
configurable: true,
|
|
@@ -119,6 +130,12 @@ export class OasMediaType {
|
|
|
119
130
|
this.encoding = fields.encoding;
|
|
120
131
|
this.extensionFields = fields.extensionFields;
|
|
121
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Converts this OAS media type to an OpenAPI v3 JSON schema representation.
|
|
135
|
+
*
|
|
136
|
+
* @param options - Conversion options including reference handling and formatting preferences
|
|
137
|
+
* @returns OpenAPI v3 media type object with schema and examples
|
|
138
|
+
*/
|
|
122
139
|
toJsonSchema(options) {
|
|
123
140
|
return {
|
|
124
141
|
schema: this.schema?.toJsonSchema(options),
|
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview OpenAPI Document Conversion Utilities
|
|
3
|
+
*
|
|
4
|
+
* This module provides robust utilities for converting OpenAPI documents between
|
|
5
|
+
* different versions (v2/Swagger, v3.0, v3.1) and formats (JSON, YAML). It handles
|
|
6
|
+
* the complexities of version migration, format detection, and schema validation
|
|
7
|
+
* to ensure seamless OpenAPI document processing within the SKMTC pipeline.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Features
|
|
10
|
+
*
|
|
11
|
+
* - **Multi-Version Support**: Convert between Swagger v2, OpenAPI v3.0, and v3.1
|
|
12
|
+
* - **Format Detection**: Automatic detection of JSON vs YAML input formats
|
|
13
|
+
* - **Version Migration**: Safe migration with schema validation and error handling
|
|
14
|
+
* - **Type Safety**: Full TypeScript support with proper type guards
|
|
15
|
+
* - **Error Recovery**: Comprehensive error handling for malformed documents
|
|
16
|
+
*
|
|
17
|
+
* @example Converting Swagger v2 to OpenAPI v3
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { toV3JsonDocument } from '@skmtc/core/toV3JsonDocument';
|
|
20
|
+
*
|
|
21
|
+
* const swaggerV2 = {
|
|
22
|
+
* swagger: '2.0',
|
|
23
|
+
* info: { title: 'My API', version: '1.0.0' },
|
|
24
|
+
* paths: { '/users': { get: { responses: { '200': { description: 'Success' } } } } }
|
|
25
|
+
* };
|
|
26
|
+
*
|
|
27
|
+
* const openApiV3 = await toV3JsonDocument(swaggerV2);
|
|
28
|
+
* console.log(openApiV3.openapi); // '3.0.0'
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Converting from YAML string
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const yamlContent = `
|
|
34
|
+
* openapi: 3.1.0
|
|
35
|
+
* info:
|
|
36
|
+
* title: My API
|
|
37
|
+
* version: 1.0.0
|
|
38
|
+
* paths: {}
|
|
39
|
+
* `;
|
|
40
|
+
*
|
|
41
|
+
* const openApiV3 = await toV3JsonDocument(yamlContent);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Handling conversion errors
|
|
45
|
+
* ```typescript
|
|
46
|
+
* try {
|
|
47
|
+
* const result = await toV3JsonDocument(malformedDocument);
|
|
48
|
+
* } catch (error) {
|
|
49
|
+
* console.error('Conversion failed:', error.message);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @module toV3JsonDocument
|
|
54
|
+
*/
|
|
1
55
|
import "../_dnt.polyfills.js";
|
|
2
56
|
import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
3
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toV3JsonDocument.d.ts","sourceRoot":"","sources":["../../src/run/toV3JsonDocument.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"toV3JsonDocument.d.ts","sourceRoot":"","sources":["../../src/run/toV3JsonDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,OAAO,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAUtE;;;;;GAKG;AACH,KAAK,cAAc,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,cAM/C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,YAAY,GAAU,QAAQ,cAAc,KAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CA0BrF,CAAA"}
|
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview OpenAPI Document Conversion Utilities
|
|
3
|
+
*
|
|
4
|
+
* This module provides robust utilities for converting OpenAPI documents between
|
|
5
|
+
* different versions (v2/Swagger, v3.0, v3.1) and formats (JSON, YAML). It handles
|
|
6
|
+
* the complexities of version migration, format detection, and schema validation
|
|
7
|
+
* to ensure seamless OpenAPI document processing within the SKMTC pipeline.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Features
|
|
10
|
+
*
|
|
11
|
+
* - **Multi-Version Support**: Convert between Swagger v2, OpenAPI v3.0, and v3.1
|
|
12
|
+
* - **Format Detection**: Automatic detection of JSON vs YAML input formats
|
|
13
|
+
* - **Version Migration**: Safe migration with schema validation and error handling
|
|
14
|
+
* - **Type Safety**: Full TypeScript support with proper type guards
|
|
15
|
+
* - **Error Recovery**: Comprehensive error handling for malformed documents
|
|
16
|
+
*
|
|
17
|
+
* @example Converting Swagger v2 to OpenAPI v3
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { toV3JsonDocument } from '@skmtc/core/toV3JsonDocument';
|
|
20
|
+
*
|
|
21
|
+
* const swaggerV2 = {
|
|
22
|
+
* swagger: '2.0',
|
|
23
|
+
* info: { title: 'My API', version: '1.0.0' },
|
|
24
|
+
* paths: { '/users': { get: { responses: { '200': { description: 'Success' } } } } }
|
|
25
|
+
* };
|
|
26
|
+
*
|
|
27
|
+
* const openApiV3 = await toV3JsonDocument(swaggerV2);
|
|
28
|
+
* console.log(openApiV3.openapi); // '3.0.0'
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Converting from YAML string
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const yamlContent = `
|
|
34
|
+
* openapi: 3.1.0
|
|
35
|
+
* info:
|
|
36
|
+
* title: My API
|
|
37
|
+
* version: 1.0.0
|
|
38
|
+
* paths: {}
|
|
39
|
+
* `;
|
|
40
|
+
*
|
|
41
|
+
* const openApiV3 = await toV3JsonDocument(yamlContent);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Handling conversion errors
|
|
45
|
+
* ```typescript
|
|
46
|
+
* try {
|
|
47
|
+
* const result = await toV3JsonDocument(malformedDocument);
|
|
48
|
+
* } catch (error) {
|
|
49
|
+
* console.error('Conversion failed:', error.message);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @module toV3JsonDocument
|
|
54
|
+
*/
|
|
1
55
|
import "../_dnt.polyfills.js";
|
|
2
56
|
import { parse as parseYaml } from '../deps/jsr.io/@std/yaml/1.0.9/parse.js';
|
|
3
57
|
import { Converter as ThreeOneToThreeZeroConverter } from '@apiture/openapi-down-convert';
|
package/esm/types/Brand.d.ts
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Brand Type System for SKMTC Core
|
|
3
|
+
*
|
|
4
|
+
* This module provides TypeScript branded types for creating type-safe identifiers
|
|
5
|
+
* and values that are structurally identical but nominally distinct. Branded types
|
|
6
|
+
* help prevent mixing up similar primitive types and provide better type safety
|
|
7
|
+
* across the SKMTC codebase.
|
|
8
|
+
*
|
|
9
|
+
* ## Key Features
|
|
10
|
+
*
|
|
11
|
+
* - **Type Safety**: Prevents accidental mixing of similar primitive types
|
|
12
|
+
* - **Nominal Typing**: Creates distinct types from the same underlying type
|
|
13
|
+
* - **Zero Runtime Cost**: Pure TypeScript compile-time construct
|
|
14
|
+
* - **Developer Experience**: Better IntelliSense and error messages
|
|
15
|
+
*
|
|
16
|
+
* @example Creating branded types
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import type { Brand } from '@skmtc/core/Brand';
|
|
19
|
+
*
|
|
20
|
+
* type UserId = Brand<string, 'UserId'>;
|
|
21
|
+
* type ProductId = Brand<string, 'ProductId'>;
|
|
22
|
+
*
|
|
23
|
+
* const userId: UserId = 'user-123' as UserId;
|
|
24
|
+
* const productId: ProductId = 'prod-456' as ProductId;
|
|
25
|
+
*
|
|
26
|
+
* // TypeScript will prevent this error:
|
|
27
|
+
* // const wrong: UserId = productId; // Type error!
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Using with numbers
|
|
31
|
+
* ```typescript
|
|
32
|
+
* type Score = Brand<number, 'Score'>;
|
|
33
|
+
* type Percentage = Brand<number, 'Percentage'>;
|
|
34
|
+
*
|
|
35
|
+
* function calculateGrade(score: Score, total: Score): Percentage {
|
|
36
|
+
* return ((score / total) * 100) as Percentage;
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @module Brand
|
|
41
|
+
*/
|
|
1
42
|
/**
|
|
2
43
|
* Unique symbol used for branding types.
|
|
3
44
|
*
|
package/esm/types/Brand.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../src/types/Brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,sBAAsB,CAAC;AAE9B,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,GAAG;IAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../src/types/Brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;;;;GAQG;AACH,OAAO,sBAAsB,CAAC;AAE9B,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,GAAG;IAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
|