@twin.org/ts-to-schema 0.0.1-next.27 → 0.0.1-next.29
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 +22 -5
- package/dist/esm/index.mjs +22 -5
- package/docs/changelog.md +25 -0
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -132,10 +132,7 @@ async function generateSchemas(typeSource, type, outputWorkingDir) {
|
|
|
132
132
|
const schema = generator.createSchema("*");
|
|
133
133
|
if (schema.definitions) {
|
|
134
134
|
for (const def in schema.definitions) {
|
|
135
|
-
|
|
136
|
-
let defSub = def.replace(/^Partial<(.*?)>/g, "$1");
|
|
137
|
-
// Cleanup the generic markers
|
|
138
|
-
defSub = defSub.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
135
|
+
const defSub = normaliseTypeName(def);
|
|
139
136
|
allSchemas[defSub] = schema.definitions[def];
|
|
140
137
|
}
|
|
141
138
|
}
|
|
@@ -281,6 +278,26 @@ function processSchemaArray(schemaArray) {
|
|
|
281
278
|
}
|
|
282
279
|
}
|
|
283
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Cleanup TypeScript markers from the type name.
|
|
283
|
+
* @param typeName The definition string to clean up.
|
|
284
|
+
* @returns The cleaned up definition string.
|
|
285
|
+
*/
|
|
286
|
+
function normaliseTypeName(typeName) {
|
|
287
|
+
// Remove the partial markers
|
|
288
|
+
let sTypeName = typeName.replace(/^Partial<(.*?)>/g, "$1");
|
|
289
|
+
sTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
290
|
+
// Remove the omit markers
|
|
291
|
+
sTypeName = sTypeName.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
292
|
+
sTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
293
|
+
// Remove the pick markers
|
|
294
|
+
sTypeName = sTypeName.replace(/^Pick<(.*?),.*>/g, "$1");
|
|
295
|
+
sTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, "$1");
|
|
296
|
+
// Cleanup the generic markers
|
|
297
|
+
sTypeName = sTypeName.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
298
|
+
sTypeName = sTypeName.replace(/%3Cunknown%3E/g, "");
|
|
299
|
+
return sTypeName;
|
|
300
|
+
}
|
|
284
301
|
|
|
285
302
|
// Copyright 2024 IOTA Stiftung.
|
|
286
303
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -300,7 +317,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
300
317
|
return this.execute({
|
|
301
318
|
title: "TWIN TypeScript To Schema",
|
|
302
319
|
appName: "ts-to-schema",
|
|
303
|
-
version: "0.0.1-next.
|
|
320
|
+
version: "0.0.1-next.29", // x-release-please-version
|
|
304
321
|
icon: "⚙️ ",
|
|
305
322
|
supportsEnvFiles: false,
|
|
306
323
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/dist/esm/index.mjs
CHANGED
|
@@ -129,10 +129,7 @@ async function generateSchemas(typeSource, type, outputWorkingDir) {
|
|
|
129
129
|
const schema = generator.createSchema("*");
|
|
130
130
|
if (schema.definitions) {
|
|
131
131
|
for (const def in schema.definitions) {
|
|
132
|
-
|
|
133
|
-
let defSub = def.replace(/^Partial<(.*?)>/g, "$1");
|
|
134
|
-
// Cleanup the generic markers
|
|
135
|
-
defSub = defSub.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
132
|
+
const defSub = normaliseTypeName(def);
|
|
136
133
|
allSchemas[defSub] = schema.definitions[def];
|
|
137
134
|
}
|
|
138
135
|
}
|
|
@@ -278,6 +275,26 @@ function processSchemaArray(schemaArray) {
|
|
|
278
275
|
}
|
|
279
276
|
}
|
|
280
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Cleanup TypeScript markers from the type name.
|
|
280
|
+
* @param typeName The definition string to clean up.
|
|
281
|
+
* @returns The cleaned up definition string.
|
|
282
|
+
*/
|
|
283
|
+
function normaliseTypeName(typeName) {
|
|
284
|
+
// Remove the partial markers
|
|
285
|
+
let sTypeName = typeName.replace(/^Partial<(.*?)>/g, "$1");
|
|
286
|
+
sTypeName = sTypeName.replace(/Partial%3CI(.*?)%3E/g, "$1");
|
|
287
|
+
// Remove the omit markers
|
|
288
|
+
sTypeName = sTypeName.replace(/^Omit<(.*?),.*>/g, "$1");
|
|
289
|
+
sTypeName = sTypeName.replace(/Omit%3CI(.*?)%2C.*%3E/g, "$1");
|
|
290
|
+
// Remove the pick markers
|
|
291
|
+
sTypeName = sTypeName.replace(/^Pick<(.*?),.*>/g, "$1");
|
|
292
|
+
sTypeName = sTypeName.replace(/Pick%3CI(.*?)%2C.*%3E/g, "$1");
|
|
293
|
+
// Cleanup the generic markers
|
|
294
|
+
sTypeName = sTypeName.replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
295
|
+
sTypeName = sTypeName.replace(/%3Cunknown%3E/g, "");
|
|
296
|
+
return sTypeName;
|
|
297
|
+
}
|
|
281
298
|
|
|
282
299
|
// Copyright 2024 IOTA Stiftung.
|
|
283
300
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -297,7 +314,7 @@ class CLI extends CLIBase {
|
|
|
297
314
|
return this.execute({
|
|
298
315
|
title: "TWIN TypeScript To Schema",
|
|
299
316
|
appName: "ts-to-schema",
|
|
300
|
-
version: "0.0.1-next.
|
|
317
|
+
version: "0.0.1-next.29", // x-release-please-version
|
|
301
318
|
icon: "⚙️ ",
|
|
302
319
|
supportsEnvFiles: false,
|
|
303
320
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @twin.org/ts-to-schema - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.29](https://github.com/twinfoundation/tools/compare/ts-to-schema-v0.0.1-next.28...ts-to-schema-v0.0.1-next.29) (2025-07-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* move package to framework repo ([4490bda](https://github.com/twinfoundation/tools/commit/4490bda472d4dc8ddfe931e2fce81f3411de9ab3))
|
|
9
|
+
|
|
10
|
+
## [0.0.1-next.28](https://github.com/twinfoundation/tools/compare/ts-to-schema-v0.0.1-next.27...ts-to-schema-v0.0.1-next.28) (2025-06-18)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* improve schema type name normalisation ([1a18b26](https://github.com/twinfoundation/tools/commit/1a18b267d87e9179bda01b396b256c450ae2889e))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* The following workspace dependencies were updated
|
|
21
|
+
* dependencies
|
|
22
|
+
* @twin.org/nameof bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
23
|
+
* devDependencies
|
|
24
|
+
* @twin.org/merge-locales bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
25
|
+
* @twin.org/nameof-transformer bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
26
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.27 to 0.0.1-next.28
|
|
27
|
+
|
|
3
28
|
## [0.0.1-next.27](https://github.com/twinfoundation/tools/compare/ts-to-schema-v0.0.1-next.26...ts-to-schema-v0.0.1-next.27) (2025-06-17)
|
|
4
29
|
|
|
5
30
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/ts-to-schema",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.29",
|
|
4
4
|
"description": "Tool to convert TypeScript definitions to JSON schemas",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/cli-core": "next",
|
|
18
18
|
"@twin.org/core": "next",
|
|
19
|
-
"@twin.org/nameof": "
|
|
19
|
+
"@twin.org/nameof": "next",
|
|
20
20
|
"ajv": "8.17.1",
|
|
21
21
|
"commander": "14.0.0",
|
|
22
22
|
"glob": "11.0.2",
|