@twin.org/tools-core 0.0.2-next.1 → 0.0.2-next.10
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/cjs/index.cjs +40 -10
- package/dist/esm/index.mjs +40 -11
- package/dist/types/index.d.ts +7 -0
- package/dist/types/models/IOpenApi.d.ts +54 -0
- package/dist/types/models/IOpenApiExample.d.ts +13 -0
- package/dist/types/models/IOpenApiHeader.d.ts +19 -0
- package/dist/types/models/IOpenApiPathMethod.d.ts +65 -0
- package/dist/types/models/IOpenApiResponse.d.ts +32 -0
- package/dist/types/models/IOpenApiSecurityScheme.d.ts +25 -0
- package/dist/types/utils/jsonSchemaHelper.d.ts +8 -2
- package/dist/types/utils/openApiHelper.d.ts +9 -0
- package/docs/changelog.md +63 -0
- package/docs/reference/classes/JsonSchemaHelper.md +25 -3
- package/docs/reference/classes/OpenApiHelper.md +21 -0
- package/docs/reference/index.md +7 -0
- package/docs/reference/interfaces/IOpenApi.md +103 -0
- package/docs/reference/interfaces/IOpenApiExample.md +19 -0
- package/docs/reference/interfaces/IOpenApiHeader.md +31 -0
- package/docs/reference/interfaces/IOpenApiPathMethod.md +119 -0
- package/docs/reference/interfaces/IOpenApiResponse.md +35 -0
- package/docs/reference/interfaces/IOpenApiSecurityScheme.md +43 -0
- package/package.json +17 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var core = require('@twin.org/core');
|
|
|
5
5
|
// Copyright 2024 IOTA Stiftung.
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0.
|
|
7
7
|
/**
|
|
8
|
-
* Helper class for JSON Schema processing.
|
|
8
|
+
* Helper class for JSON Schema processing.
|
|
9
9
|
*/
|
|
10
10
|
class JsonSchemaHelper {
|
|
11
11
|
/**
|
|
@@ -72,18 +72,21 @@ class JsonSchemaHelper {
|
|
|
72
72
|
*/
|
|
73
73
|
static normaliseTypeName(typeName) {
|
|
74
74
|
// Remove the partial markers
|
|
75
|
-
let sTypeName = typeName.replace(/^Partial<(.*?)>/g, "$1");
|
|
75
|
+
let sTypeName = typeName.replace(/^Partial<I(.*?)>/g, "$1");
|
|
76
76
|
sTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
77
77
|
// Remove the omit markers
|
|
78
|
-
sTypeName = sTypeName.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
78
|
+
sTypeName = sTypeName.replace(/^Omit<I(.*?),.*>/g, "$1");
|
|
79
79
|
sTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
80
80
|
// Remove the pick markers
|
|
81
|
-
sTypeName = sTypeName.replace(/^Pick<(.*?),.*>/g, "$1");
|
|
81
|
+
sTypeName = sTypeName.replace(/^Pick<I(.*?),.*>/g, "$1");
|
|
82
82
|
sTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, "$1");
|
|
83
|
+
// Cleanup the generic markers
|
|
84
|
+
sTypeName = sTypeName.replace(/^(.*?)<I(.*?)>/g, "$1<$2>");
|
|
85
|
+
sTypeName = sTypeName.replace(/(.*?)%3CI(.*?)%3E/g, "$1<$2>");
|
|
83
86
|
// Cleanup the unknown markers
|
|
84
87
|
sTypeName = sTypeName.replace(/<unknown>/g, "");
|
|
85
88
|
sTypeName = sTypeName.replace(/%3Cunknown%3E/g, "");
|
|
86
|
-
// Replace the
|
|
89
|
+
// Replace the other url markers
|
|
87
90
|
sTypeName = sTypeName.replace(/%7C/g, "|").replace(/%3C/g, "<").replace(/%3E/g, ">");
|
|
88
91
|
return sTypeName;
|
|
89
92
|
}
|
|
@@ -147,10 +150,13 @@ class JsonSchemaHelper {
|
|
|
147
150
|
*/
|
|
148
151
|
static extractTypes(allSchemas, requiredTypes, referencedSchemas) {
|
|
149
152
|
for (const typeKey of Object.keys(allSchemas)) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
if (!referencedSchemas[typeKey]) {
|
|
154
|
+
for (const requiredType of requiredTypes) {
|
|
155
|
+
const regex = JsonSchemaHelper.stringToRegEx(requiredType);
|
|
156
|
+
if (regex.test(typeKey)) {
|
|
157
|
+
referencedSchemas[typeKey] = allSchemas[typeKey];
|
|
158
|
+
JsonSchemaHelper.extractTypesFromSchema(allSchemas, allSchemas[typeKey], referencedSchemas);
|
|
159
|
+
}
|
|
154
160
|
}
|
|
155
161
|
}
|
|
156
162
|
}
|
|
@@ -176,7 +182,8 @@ class JsonSchemaHelper {
|
|
|
176
182
|
if (core.Is.stringValue(schema.$ref)) {
|
|
177
183
|
for (const expandedType of expandedTypes) {
|
|
178
184
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
179
|
-
|
|
185
|
+
const regex = JsonSchemaHelper.stringToRegEx(expandedType);
|
|
186
|
+
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
180
187
|
delete schema.$ref;
|
|
181
188
|
Object.assign(schema, allSchemas[typeName]);
|
|
182
189
|
break;
|
|
@@ -221,6 +228,29 @@ class JsonSchemaHelper {
|
|
|
221
228
|
}
|
|
222
229
|
}
|
|
223
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Convert a string pattern to a regular expression.
|
|
233
|
+
* @param matchPattern The pattern to convert.
|
|
234
|
+
* @returns The regular expression.
|
|
235
|
+
*/
|
|
236
|
+
static stringToRegEx(matchPattern) {
|
|
237
|
+
return matchPattern.startsWith("/") && matchPattern.endsWith("/")
|
|
238
|
+
? new RegExp(matchPattern.slice(1, -1))
|
|
239
|
+
: new RegExp(`^${matchPattern}$`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Copyright 2024 IOTA Stiftung.
|
|
244
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
245
|
+
/**
|
|
246
|
+
* Helper class for OpenAPI processing.
|
|
247
|
+
*/
|
|
248
|
+
class OpenApiHelper {
|
|
249
|
+
/**
|
|
250
|
+
* The OpenAPI version used.
|
|
251
|
+
*/
|
|
252
|
+
static API_VERSION = "3.1.1";
|
|
224
253
|
}
|
|
225
254
|
|
|
226
255
|
exports.JsonSchemaHelper = JsonSchemaHelper;
|
|
256
|
+
exports.OpenApiHelper = OpenApiHelper;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { Is, ArrayHelper } from '@twin.org/core';
|
|
|
3
3
|
// Copyright 2024 IOTA Stiftung.
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0.
|
|
5
5
|
/**
|
|
6
|
-
* Helper class for JSON Schema processing.
|
|
6
|
+
* Helper class for JSON Schema processing.
|
|
7
7
|
*/
|
|
8
8
|
class JsonSchemaHelper {
|
|
9
9
|
/**
|
|
@@ -70,18 +70,21 @@ class JsonSchemaHelper {
|
|
|
70
70
|
*/
|
|
71
71
|
static normaliseTypeName(typeName) {
|
|
72
72
|
// Remove the partial markers
|
|
73
|
-
let sTypeName = typeName.replace(/^Partial<(.*?)>/g, "$1");
|
|
73
|
+
let sTypeName = typeName.replace(/^Partial<I(.*?)>/g, "$1");
|
|
74
74
|
sTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
75
75
|
// Remove the omit markers
|
|
76
|
-
sTypeName = sTypeName.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
76
|
+
sTypeName = sTypeName.replace(/^Omit<I(.*?),.*>/g, "$1");
|
|
77
77
|
sTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
78
78
|
// Remove the pick markers
|
|
79
|
-
sTypeName = sTypeName.replace(/^Pick<(.*?),.*>/g, "$1");
|
|
79
|
+
sTypeName = sTypeName.replace(/^Pick<I(.*?),.*>/g, "$1");
|
|
80
80
|
sTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, "$1");
|
|
81
|
+
// Cleanup the generic markers
|
|
82
|
+
sTypeName = sTypeName.replace(/^(.*?)<I(.*?)>/g, "$1<$2>");
|
|
83
|
+
sTypeName = sTypeName.replace(/(.*?)%3CI(.*?)%3E/g, "$1<$2>");
|
|
81
84
|
// Cleanup the unknown markers
|
|
82
85
|
sTypeName = sTypeName.replace(/<unknown>/g, "");
|
|
83
86
|
sTypeName = sTypeName.replace(/%3Cunknown%3E/g, "");
|
|
84
|
-
// Replace the
|
|
87
|
+
// Replace the other url markers
|
|
85
88
|
sTypeName = sTypeName.replace(/%7C/g, "|").replace(/%3C/g, "<").replace(/%3E/g, ">");
|
|
86
89
|
return sTypeName;
|
|
87
90
|
}
|
|
@@ -145,10 +148,13 @@ class JsonSchemaHelper {
|
|
|
145
148
|
*/
|
|
146
149
|
static extractTypes(allSchemas, requiredTypes, referencedSchemas) {
|
|
147
150
|
for (const typeKey of Object.keys(allSchemas)) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
if (!referencedSchemas[typeKey]) {
|
|
152
|
+
for (const requiredType of requiredTypes) {
|
|
153
|
+
const regex = JsonSchemaHelper.stringToRegEx(requiredType);
|
|
154
|
+
if (regex.test(typeKey)) {
|
|
155
|
+
referencedSchemas[typeKey] = allSchemas[typeKey];
|
|
156
|
+
JsonSchemaHelper.extractTypesFromSchema(allSchemas, allSchemas[typeKey], referencedSchemas);
|
|
157
|
+
}
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
160
|
}
|
|
@@ -174,7 +180,8 @@ class JsonSchemaHelper {
|
|
|
174
180
|
if (Is.stringValue(schema.$ref)) {
|
|
175
181
|
for (const expandedType of expandedTypes) {
|
|
176
182
|
const typeName = JsonSchemaHelper.normaliseTypeName(schema.$ref.replace("#/definitions/", ""));
|
|
177
|
-
|
|
183
|
+
const regex = JsonSchemaHelper.stringToRegEx(expandedType);
|
|
184
|
+
if (regex.test(typeName) && allSchemas[typeName]) {
|
|
178
185
|
delete schema.$ref;
|
|
179
186
|
Object.assign(schema, allSchemas[typeName]);
|
|
180
187
|
break;
|
|
@@ -219,6 +226,28 @@ class JsonSchemaHelper {
|
|
|
219
226
|
}
|
|
220
227
|
}
|
|
221
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Convert a string pattern to a regular expression.
|
|
231
|
+
* @param matchPattern The pattern to convert.
|
|
232
|
+
* @returns The regular expression.
|
|
233
|
+
*/
|
|
234
|
+
static stringToRegEx(matchPattern) {
|
|
235
|
+
return matchPattern.startsWith("/") && matchPattern.endsWith("/")
|
|
236
|
+
? new RegExp(matchPattern.slice(1, -1))
|
|
237
|
+
: new RegExp(`^${matchPattern}$`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Copyright 2024 IOTA Stiftung.
|
|
242
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
243
|
+
/**
|
|
244
|
+
* Helper class for OpenAPI processing.
|
|
245
|
+
*/
|
|
246
|
+
class OpenApiHelper {
|
|
247
|
+
/**
|
|
248
|
+
* The OpenAPI version used.
|
|
249
|
+
*/
|
|
250
|
+
static API_VERSION = "3.1.1";
|
|
222
251
|
}
|
|
223
252
|
|
|
224
|
-
export { JsonSchemaHelper };
|
|
253
|
+
export { JsonSchemaHelper, OpenApiHelper };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export * from "./models/IJsonSchema";
|
|
2
|
+
export * from "./models/IOpenApi";
|
|
3
|
+
export * from "./models/IOpenApiExample";
|
|
4
|
+
export * from "./models/IOpenApiHeader";
|
|
5
|
+
export * from "./models/IOpenApiPathMethod";
|
|
6
|
+
export * from "./models/IOpenApiResponse";
|
|
7
|
+
export * from "./models/IOpenApiSecurityScheme";
|
|
2
8
|
export * from "./models/IPackageJson";
|
|
3
9
|
export * from "./models/jsonTypeName";
|
|
4
10
|
export * from "./utils/jsonSchemaHelper";
|
|
11
|
+
export * from "./utils/openApiHelper";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { IJsonSchema } from "./IJsonSchema";
|
|
2
|
+
import type { IOpenApiPathMethod } from "./IOpenApiPathMethod";
|
|
3
|
+
import type { IOpenApiSecurityScheme } from "./IOpenApiSecurityScheme";
|
|
4
|
+
/**
|
|
5
|
+
* The Open API config definition.
|
|
6
|
+
*/
|
|
7
|
+
export interface IOpenApi {
|
|
8
|
+
/**
|
|
9
|
+
* The open api version.
|
|
10
|
+
*/
|
|
11
|
+
openapi: string;
|
|
12
|
+
/**
|
|
13
|
+
* Info.
|
|
14
|
+
*/
|
|
15
|
+
info: {
|
|
16
|
+
title: string;
|
|
17
|
+
version: string;
|
|
18
|
+
description: string;
|
|
19
|
+
license?: {
|
|
20
|
+
name: string;
|
|
21
|
+
url: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The servers for the endpoints.
|
|
26
|
+
*/
|
|
27
|
+
servers?: {
|
|
28
|
+
url: string;
|
|
29
|
+
}[];
|
|
30
|
+
/**
|
|
31
|
+
* Tags for the endpoints.
|
|
32
|
+
*/
|
|
33
|
+
tags?: {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
}[];
|
|
37
|
+
/**
|
|
38
|
+
* The paths.
|
|
39
|
+
*/
|
|
40
|
+
paths: {
|
|
41
|
+
[path: string]: {
|
|
42
|
+
[method: string]: IOpenApiPathMethod;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The components.
|
|
47
|
+
*/
|
|
48
|
+
components?: {
|
|
49
|
+
schemas?: IJsonSchema;
|
|
50
|
+
securitySchemes?: {
|
|
51
|
+
[name: string]: IOpenApiSecurityScheme;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Open API config definition.
|
|
3
|
+
*/
|
|
4
|
+
export interface IOpenApiHeader {
|
|
5
|
+
/**
|
|
6
|
+
* The schema of the header.
|
|
7
|
+
*/
|
|
8
|
+
schema?: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The description of the header.
|
|
13
|
+
*/
|
|
14
|
+
description?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The format of the header.
|
|
17
|
+
*/
|
|
18
|
+
format?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { IJsonSchema } from "./IJsonSchema";
|
|
2
|
+
import type { IOpenApiExample } from "./IOpenApiExample";
|
|
3
|
+
import type { IOpenApiResponse } from "./IOpenApiResponse";
|
|
4
|
+
import type { JsonTypeName } from "./jsonTypeName";
|
|
5
|
+
/**
|
|
6
|
+
* The Open API config definition.
|
|
7
|
+
*/
|
|
8
|
+
export interface IOpenApiPathMethod {
|
|
9
|
+
/**
|
|
10
|
+
* The operation id.
|
|
11
|
+
*/
|
|
12
|
+
operationId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Summary.
|
|
15
|
+
*/
|
|
16
|
+
summary: string;
|
|
17
|
+
/**
|
|
18
|
+
* Tags.
|
|
19
|
+
*/
|
|
20
|
+
tags?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Parameters.
|
|
23
|
+
*/
|
|
24
|
+
parameters?: {
|
|
25
|
+
name: string;
|
|
26
|
+
in: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
required: boolean;
|
|
29
|
+
schema: {
|
|
30
|
+
type?: JsonTypeName | JsonTypeName[];
|
|
31
|
+
enum?: IJsonSchema[];
|
|
32
|
+
$ref?: string;
|
|
33
|
+
};
|
|
34
|
+
style?: string;
|
|
35
|
+
}[];
|
|
36
|
+
/**
|
|
37
|
+
* Request body.
|
|
38
|
+
*/
|
|
39
|
+
requestBody?: {
|
|
40
|
+
required: boolean;
|
|
41
|
+
description?: string;
|
|
42
|
+
content?: {
|
|
43
|
+
[contentType: string]: {
|
|
44
|
+
schema: {
|
|
45
|
+
$ref: string;
|
|
46
|
+
};
|
|
47
|
+
examples?: {
|
|
48
|
+
[id: string]: IOpenApiExample;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Response body.
|
|
55
|
+
*/
|
|
56
|
+
responses?: {
|
|
57
|
+
[code: string]: IOpenApiResponse;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Security model for the API.
|
|
61
|
+
*/
|
|
62
|
+
security?: {
|
|
63
|
+
[name: string]: string[];
|
|
64
|
+
}[];
|
|
65
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IOpenApiExample } from "./IOpenApiExample";
|
|
2
|
+
import type { IOpenApiHeader } from "./IOpenApiHeader";
|
|
3
|
+
/**
|
|
4
|
+
* The Open API config definition.
|
|
5
|
+
*/
|
|
6
|
+
export interface IOpenApiResponse {
|
|
7
|
+
/**
|
|
8
|
+
* Descriptions for the response.
|
|
9
|
+
*/
|
|
10
|
+
description?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Content for the response.
|
|
13
|
+
*/
|
|
14
|
+
content?: {
|
|
15
|
+
[contentType: string]: {
|
|
16
|
+
schema: {
|
|
17
|
+
type?: string;
|
|
18
|
+
format?: string;
|
|
19
|
+
$ref?: string;
|
|
20
|
+
};
|
|
21
|
+
examples?: {
|
|
22
|
+
[id: string]: IOpenApiExample;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The headers for the response.
|
|
28
|
+
*/
|
|
29
|
+
headers?: {
|
|
30
|
+
[id: string]: IOpenApiHeader;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Open API config definition for security scheme.
|
|
3
|
+
*/
|
|
4
|
+
export interface IOpenApiSecurityScheme {
|
|
5
|
+
/**
|
|
6
|
+
* The type of the security schema.
|
|
7
|
+
*/
|
|
8
|
+
type?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The scheme method.
|
|
11
|
+
*/
|
|
12
|
+
scheme?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The bearer format.
|
|
15
|
+
*/
|
|
16
|
+
bearerFormat?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Where is the token located.
|
|
19
|
+
*/
|
|
20
|
+
in?: string;
|
|
21
|
+
/**
|
|
22
|
+
* What is the name of the token.
|
|
23
|
+
*/
|
|
24
|
+
name?: string;
|
|
25
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IJsonSchema } from "../models/IJsonSchema";
|
|
2
2
|
/**
|
|
3
|
-
* Helper class for JSON Schema processing.
|
|
3
|
+
* Helper class for JSON Schema processing.
|
|
4
4
|
*/
|
|
5
5
|
export declare class JsonSchemaHelper {
|
|
6
6
|
/**
|
|
@@ -11,7 +11,7 @@ export declare class JsonSchemaHelper {
|
|
|
11
11
|
* Process arrays in the schema object.
|
|
12
12
|
* @param schemaObject The schema object to process.
|
|
13
13
|
*/
|
|
14
|
-
static processArrays(schemaObject
|
|
14
|
+
static processArrays(schemaObject: IJsonSchema): void;
|
|
15
15
|
/**
|
|
16
16
|
* Process arrays in the schema object.
|
|
17
17
|
* @param schemaDictionary The schema object to process.
|
|
@@ -69,4 +69,10 @@ export declare class JsonSchemaHelper {
|
|
|
69
69
|
static expandSchemaTypes(allSchemas: {
|
|
70
70
|
[id: string]: IJsonSchema;
|
|
71
71
|
}, schema: IJsonSchema, expandedTypes: string[]): void;
|
|
72
|
+
/**
|
|
73
|
+
* Convert a string pattern to a regular expression.
|
|
74
|
+
* @param matchPattern The pattern to convert.
|
|
75
|
+
* @returns The regular expression.
|
|
76
|
+
*/
|
|
77
|
+
static stringToRegEx(matchPattern: string): RegExp;
|
|
72
78
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.10](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.9...tools-core-v0.0.2-next.10) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add validate-locales ([97bb11f](https://github.com/twinfoundation/tools/commit/97bb11fd9e6ed400e7fa69671075ba78f36ca6e6))
|
|
9
|
+
|
|
10
|
+
## [0.0.2-next.9](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.8...tools-core-v0.0.2-next.9) (2025-09-23)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Miscellaneous Chores
|
|
14
|
+
|
|
15
|
+
* **tools-core:** Synchronize repo versions
|
|
16
|
+
|
|
17
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.7...tools-core-v0.0.2-next.8) (2025-09-05)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* tighten the types included with the regex matching ([e54909b](https://github.com/twinfoundation/tools/commit/e54909bded4a19d00560dd3ec783e9146580bda3))
|
|
23
|
+
|
|
24
|
+
## [0.0.2-next.7](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.6...tools-core-v0.0.2-next.7) (2025-08-29)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* eslint migration to flat config ([25acfcf](https://github.com/twinfoundation/tools/commit/25acfcf4c4e0c496fffeaf67659fe171bc15199a))
|
|
30
|
+
|
|
31
|
+
## [0.0.2-next.6](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.5...tools-core-v0.0.2-next.6) (2025-08-21)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* remove auto expanded types from final output ([18e05dc](https://github.com/twinfoundation/tools/commit/18e05dc88f71a0a27b79d1d076b1261b42d2c4c2))
|
|
37
|
+
|
|
38
|
+
## [0.0.2-next.5](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.4...tools-core-v0.0.2-next.5) (2025-08-19)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* correctly handle auto expand types ([57fce0f](https://github.com/twinfoundation/tools/commit/57fce0f9ec4a0876665d70adc6e885f6feb3caf7))
|
|
44
|
+
|
|
45
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.3...tools-core-v0.0.2-next.4) (2025-08-19)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
* update framework core ([559cb98](https://github.com/twinfoundation/tools/commit/559cb98612c05a05458b37462cda806b9591b18a))
|
|
51
|
+
|
|
52
|
+
## [0.0.2-next.3](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.2...tools-core-v0.0.2-next.3) (2025-08-05)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Features
|
|
56
|
+
|
|
57
|
+
* improve type name normalisation ([1fe28e5](https://github.com/twinfoundation/tools/commit/1fe28e567593e46a41a833fbba95fe4cd958f525))
|
|
58
|
+
|
|
59
|
+
## [0.0.2-next.2](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.1...tools-core-v0.0.2-next.2) (2025-07-17)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
|
|
64
|
+
* improve auto expand types ([6181d1d](https://github.com/twinfoundation/tools/commit/6181d1daded1f91323195cf7efbc2f1881f38b41))
|
|
65
|
+
|
|
3
66
|
## [0.0.2-next.1](https://github.com/twinfoundation/tools/compare/tools-core-v0.0.2-next.0...tools-core-v0.0.2-next.1) (2025-07-14)
|
|
4
67
|
|
|
5
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: JsonSchemaHelper
|
|
2
2
|
|
|
3
|
-
Helper class for JSON Schema processing.
|
|
3
|
+
Helper class for JSON Schema processing.
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
@@ -24,13 +24,13 @@ The JSON Schema version used.
|
|
|
24
24
|
|
|
25
25
|
### processArrays()
|
|
26
26
|
|
|
27
|
-
> `static` **processArrays**(`schemaObject
|
|
27
|
+
> `static` **processArrays**(`schemaObject`): `void`
|
|
28
28
|
|
|
29
29
|
Process arrays in the schema object.
|
|
30
30
|
|
|
31
31
|
#### Parameters
|
|
32
32
|
|
|
33
|
-
##### schemaObject
|
|
33
|
+
##### schemaObject
|
|
34
34
|
|
|
35
35
|
`AnySchemaObject`
|
|
36
36
|
|
|
@@ -209,3 +209,25 @@ The types to expand.
|
|
|
209
209
|
#### Returns
|
|
210
210
|
|
|
211
211
|
`void`
|
|
212
|
+
|
|
213
|
+
***
|
|
214
|
+
|
|
215
|
+
### stringToRegEx()
|
|
216
|
+
|
|
217
|
+
> `static` **stringToRegEx**(`matchPattern`): `RegExp`
|
|
218
|
+
|
|
219
|
+
Convert a string pattern to a regular expression.
|
|
220
|
+
|
|
221
|
+
#### Parameters
|
|
222
|
+
|
|
223
|
+
##### matchPattern
|
|
224
|
+
|
|
225
|
+
`string`
|
|
226
|
+
|
|
227
|
+
The pattern to convert.
|
|
228
|
+
|
|
229
|
+
#### Returns
|
|
230
|
+
|
|
231
|
+
`RegExp`
|
|
232
|
+
|
|
233
|
+
The regular expression.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Class: OpenApiHelper
|
|
2
|
+
|
|
3
|
+
Helper class for OpenAPI processing.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new OpenApiHelper**(): `OpenApiHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`OpenApiHelper`
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### API\_VERSION
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **API\_VERSION**: `"3.1.1"` = `"3.1.1"`
|
|
20
|
+
|
|
21
|
+
The OpenAPI version used.
|
package/docs/reference/index.md
CHANGED
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
## Classes
|
|
4
4
|
|
|
5
5
|
- [JsonSchemaHelper](classes/JsonSchemaHelper.md)
|
|
6
|
+
- [OpenApiHelper](classes/OpenApiHelper.md)
|
|
6
7
|
|
|
7
8
|
## Interfaces
|
|
8
9
|
|
|
10
|
+
- [IOpenApi](interfaces/IOpenApi.md)
|
|
11
|
+
- [IOpenApiExample](interfaces/IOpenApiExample.md)
|
|
12
|
+
- [IOpenApiHeader](interfaces/IOpenApiHeader.md)
|
|
13
|
+
- [IOpenApiPathMethod](interfaces/IOpenApiPathMethod.md)
|
|
14
|
+
- [IOpenApiResponse](interfaces/IOpenApiResponse.md)
|
|
15
|
+
- [IOpenApiSecurityScheme](interfaces/IOpenApiSecurityScheme.md)
|
|
9
16
|
- [IPackageJson](interfaces/IPackageJson.md)
|
|
10
17
|
|
|
11
18
|
## Type Aliases
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Interface: IOpenApi
|
|
2
|
+
|
|
3
|
+
The Open API config definition.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### openapi
|
|
8
|
+
|
|
9
|
+
> **openapi**: `string`
|
|
10
|
+
|
|
11
|
+
The open api version.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### info
|
|
16
|
+
|
|
17
|
+
> **info**: `object`
|
|
18
|
+
|
|
19
|
+
Info.
|
|
20
|
+
|
|
21
|
+
#### title
|
|
22
|
+
|
|
23
|
+
> **title**: `string`
|
|
24
|
+
|
|
25
|
+
#### version
|
|
26
|
+
|
|
27
|
+
> **version**: `string`
|
|
28
|
+
|
|
29
|
+
#### description
|
|
30
|
+
|
|
31
|
+
> **description**: `string`
|
|
32
|
+
|
|
33
|
+
#### license?
|
|
34
|
+
|
|
35
|
+
> `optional` **license**: `object`
|
|
36
|
+
|
|
37
|
+
##### license.name
|
|
38
|
+
|
|
39
|
+
> **name**: `string`
|
|
40
|
+
|
|
41
|
+
##### license.url
|
|
42
|
+
|
|
43
|
+
> **url**: `string`
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
### servers?
|
|
48
|
+
|
|
49
|
+
> `optional` **servers**: `object`[]
|
|
50
|
+
|
|
51
|
+
The servers for the endpoints.
|
|
52
|
+
|
|
53
|
+
#### url
|
|
54
|
+
|
|
55
|
+
> **url**: `string`
|
|
56
|
+
|
|
57
|
+
***
|
|
58
|
+
|
|
59
|
+
### tags?
|
|
60
|
+
|
|
61
|
+
> `optional` **tags**: `object`[]
|
|
62
|
+
|
|
63
|
+
Tags for the endpoints.
|
|
64
|
+
|
|
65
|
+
#### name
|
|
66
|
+
|
|
67
|
+
> **name**: `string`
|
|
68
|
+
|
|
69
|
+
#### description
|
|
70
|
+
|
|
71
|
+
> **description**: `string`
|
|
72
|
+
|
|
73
|
+
***
|
|
74
|
+
|
|
75
|
+
### paths
|
|
76
|
+
|
|
77
|
+
> **paths**: `object`
|
|
78
|
+
|
|
79
|
+
The paths.
|
|
80
|
+
|
|
81
|
+
#### Index Signature
|
|
82
|
+
|
|
83
|
+
\[`path`: `string`\]: `object`
|
|
84
|
+
|
|
85
|
+
***
|
|
86
|
+
|
|
87
|
+
### components?
|
|
88
|
+
|
|
89
|
+
> `optional` **components**: `object`
|
|
90
|
+
|
|
91
|
+
The components.
|
|
92
|
+
|
|
93
|
+
#### schemas?
|
|
94
|
+
|
|
95
|
+
> `optional` **schemas**: `AnySchemaObject`
|
|
96
|
+
|
|
97
|
+
#### securitySchemes?
|
|
98
|
+
|
|
99
|
+
> `optional` **securitySchemes**: `object`
|
|
100
|
+
|
|
101
|
+
##### Index Signature
|
|
102
|
+
|
|
103
|
+
\[`name`: `string`\]: [`IOpenApiSecurityScheme`](IOpenApiSecurityScheme.md)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: IOpenApiExample
|
|
2
|
+
|
|
3
|
+
The Open API config definition.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### summary?
|
|
8
|
+
|
|
9
|
+
> `optional` **summary**: `string`
|
|
10
|
+
|
|
11
|
+
The summary of the example.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### value
|
|
16
|
+
|
|
17
|
+
> **value**: `unknown`
|
|
18
|
+
|
|
19
|
+
The value of the example.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Interface: IOpenApiHeader
|
|
2
|
+
|
|
3
|
+
The Open API config definition.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### schema?
|
|
8
|
+
|
|
9
|
+
> `optional` **schema**: `object`
|
|
10
|
+
|
|
11
|
+
The schema of the header.
|
|
12
|
+
|
|
13
|
+
#### type
|
|
14
|
+
|
|
15
|
+
> **type**: `string`
|
|
16
|
+
|
|
17
|
+
***
|
|
18
|
+
|
|
19
|
+
### description?
|
|
20
|
+
|
|
21
|
+
> `optional` **description**: `string`
|
|
22
|
+
|
|
23
|
+
The description of the header.
|
|
24
|
+
|
|
25
|
+
***
|
|
26
|
+
|
|
27
|
+
### format?
|
|
28
|
+
|
|
29
|
+
> `optional` **format**: `string`
|
|
30
|
+
|
|
31
|
+
The format of the header.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Interface: IOpenApiPathMethod
|
|
2
|
+
|
|
3
|
+
The Open API config definition.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### operationId
|
|
8
|
+
|
|
9
|
+
> **operationId**: `string`
|
|
10
|
+
|
|
11
|
+
The operation id.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### summary
|
|
16
|
+
|
|
17
|
+
> **summary**: `string`
|
|
18
|
+
|
|
19
|
+
Summary.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### tags?
|
|
24
|
+
|
|
25
|
+
> `optional` **tags**: `string`[]
|
|
26
|
+
|
|
27
|
+
Tags.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### parameters?
|
|
32
|
+
|
|
33
|
+
> `optional` **parameters**: `object`[]
|
|
34
|
+
|
|
35
|
+
Parameters.
|
|
36
|
+
|
|
37
|
+
#### name
|
|
38
|
+
|
|
39
|
+
> **name**: `string`
|
|
40
|
+
|
|
41
|
+
#### in
|
|
42
|
+
|
|
43
|
+
> **in**: `string`
|
|
44
|
+
|
|
45
|
+
#### description?
|
|
46
|
+
|
|
47
|
+
> `optional` **description**: `string`
|
|
48
|
+
|
|
49
|
+
#### required
|
|
50
|
+
|
|
51
|
+
> **required**: `boolean`
|
|
52
|
+
|
|
53
|
+
#### schema
|
|
54
|
+
|
|
55
|
+
> **schema**: `object`
|
|
56
|
+
|
|
57
|
+
##### schema.type?
|
|
58
|
+
|
|
59
|
+
> `optional` **type**: `"string"` \| `"number"` \| `"boolean"` \| `"object"` \| `"integer"` \| `"null"` \| `"array"` \| (`"string"` \| `"number"` \| `"boolean"` \| `"object"` \| `"integer"` \| `"null"` \| `"array"`)[]
|
|
60
|
+
|
|
61
|
+
##### schema.enum?
|
|
62
|
+
|
|
63
|
+
> `optional` **enum**: `AnySchemaObject`[]
|
|
64
|
+
|
|
65
|
+
##### schema.$ref?
|
|
66
|
+
|
|
67
|
+
> `optional` **$ref**: `string`
|
|
68
|
+
|
|
69
|
+
#### style?
|
|
70
|
+
|
|
71
|
+
> `optional` **style**: `string`
|
|
72
|
+
|
|
73
|
+
***
|
|
74
|
+
|
|
75
|
+
### requestBody?
|
|
76
|
+
|
|
77
|
+
> `optional` **requestBody**: `object`
|
|
78
|
+
|
|
79
|
+
Request body.
|
|
80
|
+
|
|
81
|
+
#### required
|
|
82
|
+
|
|
83
|
+
> **required**: `boolean`
|
|
84
|
+
|
|
85
|
+
#### description?
|
|
86
|
+
|
|
87
|
+
> `optional` **description**: `string`
|
|
88
|
+
|
|
89
|
+
#### content?
|
|
90
|
+
|
|
91
|
+
> `optional` **content**: `object`
|
|
92
|
+
|
|
93
|
+
##### Index Signature
|
|
94
|
+
|
|
95
|
+
\[`contentType`: `string`\]: `object`
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
### responses?
|
|
100
|
+
|
|
101
|
+
> `optional` **responses**: `object`
|
|
102
|
+
|
|
103
|
+
Response body.
|
|
104
|
+
|
|
105
|
+
#### Index Signature
|
|
106
|
+
|
|
107
|
+
\[`code`: `string`\]: [`IOpenApiResponse`](IOpenApiResponse.md)
|
|
108
|
+
|
|
109
|
+
***
|
|
110
|
+
|
|
111
|
+
### security?
|
|
112
|
+
|
|
113
|
+
> `optional` **security**: `object`[]
|
|
114
|
+
|
|
115
|
+
Security model for the API.
|
|
116
|
+
|
|
117
|
+
#### Index Signature
|
|
118
|
+
|
|
119
|
+
\[`name`: `string`\]: `string`[]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Interface: IOpenApiResponse
|
|
2
|
+
|
|
3
|
+
The Open API config definition.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### description?
|
|
8
|
+
|
|
9
|
+
> `optional` **description**: `string`
|
|
10
|
+
|
|
11
|
+
Descriptions for the response.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### content?
|
|
16
|
+
|
|
17
|
+
> `optional` **content**: `object`
|
|
18
|
+
|
|
19
|
+
Content for the response.
|
|
20
|
+
|
|
21
|
+
#### Index Signature
|
|
22
|
+
|
|
23
|
+
\[`contentType`: `string`\]: `object`
|
|
24
|
+
|
|
25
|
+
***
|
|
26
|
+
|
|
27
|
+
### headers?
|
|
28
|
+
|
|
29
|
+
> `optional` **headers**: `object`
|
|
30
|
+
|
|
31
|
+
The headers for the response.
|
|
32
|
+
|
|
33
|
+
#### Index Signature
|
|
34
|
+
|
|
35
|
+
\[`id`: `string`\]: [`IOpenApiHeader`](IOpenApiHeader.md)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Interface: IOpenApiSecurityScheme
|
|
2
|
+
|
|
3
|
+
The Open API config definition for security scheme.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### type?
|
|
8
|
+
|
|
9
|
+
> `optional` **type**: `string`
|
|
10
|
+
|
|
11
|
+
The type of the security schema.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### scheme?
|
|
16
|
+
|
|
17
|
+
> `optional` **scheme**: `string`
|
|
18
|
+
|
|
19
|
+
The scheme method.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### bearerFormat?
|
|
24
|
+
|
|
25
|
+
> `optional` **bearerFormat**: `string`
|
|
26
|
+
|
|
27
|
+
The bearer format.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### in?
|
|
32
|
+
|
|
33
|
+
> `optional` **in**: `string`
|
|
34
|
+
|
|
35
|
+
Where is the token located.
|
|
36
|
+
|
|
37
|
+
***
|
|
38
|
+
|
|
39
|
+
### name?
|
|
40
|
+
|
|
41
|
+
> `optional` **name**: `string`
|
|
42
|
+
|
|
43
|
+
What is the name of the token.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/tools-core",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.10",
|
|
4
4
|
"description": "Shared components for the tools",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,5 +35,20 @@
|
|
|
35
35
|
"dist/types",
|
|
36
36
|
"locales",
|
|
37
37
|
"docs"
|
|
38
|
-
]
|
|
38
|
+
],
|
|
39
|
+
"keywords": [
|
|
40
|
+
"twin",
|
|
41
|
+
"trade",
|
|
42
|
+
"iota",
|
|
43
|
+
"framework",
|
|
44
|
+
"blockchain",
|
|
45
|
+
"tools",
|
|
46
|
+
"core",
|
|
47
|
+
"foundation",
|
|
48
|
+
"utilities"
|
|
49
|
+
],
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "git+https://github.com/twinfoundation/tools/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://twindev.org"
|
|
39
54
|
}
|