@twin.org/ts-to-schema 0.0.1-next.7 → 0.0.1-next.9

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.
@@ -90,7 +90,10 @@ async function tsToSchema(config, outputFolder, workingDirectory) {
90
90
  content = content.replace(new RegExp(`#/definitions/${external}`, "g"), config.externalReferences[external]);
91
91
  }
92
92
  }
93
- content = content.replace(/#\/definitions\/I?/g, config.baseUrl);
93
+ // First replace all types that start with II to a single I with the new base url
94
+ content = content.replace(/#\/definitions\/II(.*)/g, `${config.baseUrl}I$1`);
95
+ // Then other types starting with capitals (optionally interfaces starting with I)
96
+ content = content.replace(/#\/definitions\/I?([A-Z].*)/g, `${config.baseUrl}$1`);
94
97
  const filename = path.join(outputFolder, `${core.StringHelper.stripPrefix(type)}.json`);
95
98
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.ts-to-schema.progress.writingSchema"), filename, 1);
96
99
  await promises.writeFile(filename, content);
@@ -235,7 +238,7 @@ class CLI extends cliCore.CLIBase {
235
238
  return this.execute({
236
239
  title: "TWIN TypeScript To Schema",
237
240
  appName: "ts-to-schema",
238
- version: "0.0.1-next.7",
241
+ version: "0.0.1-next.9",
239
242
  icon: "⚙️ ",
240
243
  supportsEnvFiles: false,
241
244
  overrideOutputWidth: options?.overrideOutputWidth
@@ -87,7 +87,10 @@ async function tsToSchema(config, outputFolder, workingDirectory) {
87
87
  content = content.replace(new RegExp(`#/definitions/${external}`, "g"), config.externalReferences[external]);
88
88
  }
89
89
  }
90
- content = content.replace(/#\/definitions\/I?/g, config.baseUrl);
90
+ // First replace all types that start with II to a single I with the new base url
91
+ content = content.replace(/#\/definitions\/II(.*)/g, `${config.baseUrl}I$1`);
92
+ // Then other types starting with capitals (optionally interfaces starting with I)
93
+ content = content.replace(/#\/definitions\/I?([A-Z].*)/g, `${config.baseUrl}$1`);
91
94
  const filename = path.join(outputFolder, `${StringHelper.stripPrefix(type)}.json`);
92
95
  CLIDisplay.value(I18n.formatMessage("commands.ts-to-schema.progress.writingSchema"), filename, 1);
93
96
  await writeFile(filename, content);
@@ -232,7 +235,7 @@ class CLI extends CLIBase {
232
235
  return this.execute({
233
236
  title: "TWIN TypeScript To Schema",
234
237
  appName: "ts-to-schema",
235
- version: "0.0.1-next.7",
238
+ version: "0.0.1-next.9",
236
239
  icon: "⚙️ ",
237
240
  supportsEnvFiles: false,
238
241
  overrideOutputWidth: options?.overrideOutputWidth
@@ -1,10 +1,6 @@
1
1
  {
2
2
  "error": {
3
3
  "commands": {
4
- "ts-to-schema": {
5
- "configFailed": "Configuration failed to load.",
6
- "schemaNotFound": "Could not find the requested schema in the generated types \"{type}\"."
7
- },
8
4
  "common": {
9
5
  "missingEnv": "The \"{option}\" option is configured as an environment variable, but there is no environment variable with the name \"{value}\" set.",
10
6
  "optionInvalidHex": "The \"{option}\" does not appear to be hex. \"{value}\"",
@@ -13,6 +9,10 @@
13
9
  "optionInvalidBech32": "The \"{option}\" does not appear to be bech32. \"{value}\"",
14
10
  "optionMinValue": "The \"{option}\" option must be greater than or equal to {minValue}, it is {value}.",
15
11
  "optionMaxValue": "The \"{option}\" option must be less than or equal to {maxValue}, it is {value}."
12
+ },
13
+ "ts-to-schema": {
14
+ "configFailed": "Configuration failed to load.",
15
+ "schemaNotFound": "Could not find the requested schema in the generated types \"{type}\"."
16
16
  }
17
17
  },
18
18
  "validation": {
@@ -160,34 +160,6 @@
160
160
  "invalidSeed": "The seed is invalid \"{seed}\""
161
161
  }
162
162
  },
163
- "commands": {
164
- "ts-to-schema": {
165
- "options": {
166
- "config": {
167
- "param": "'<'config'>'",
168
- "description": "Path to the JSON configuration file."
169
- },
170
- "output-folder": {
171
- "param": "'<'output-folder'>'",
172
- "description": "The folder to write the schema files."
173
- }
174
- },
175
- "progress": {
176
- "loadingConfigJson": "Loading Config JSON",
177
- "creatingWorkingDir": "Creating Working Directory",
178
- "generatingSchemas": "Generating Schemas",
179
- "finalisingSchemas": "Finalising Schemas",
180
- "writingSchemas": "Writing Schemas",
181
- "writingSchema": "Writing Schema",
182
- "models": "Models"
183
- },
184
- "labels": {
185
- "configJson": "Config JSON",
186
- "outputFolder": "Output Folder",
187
- "outputWorkingDir": "Output Working Directory"
188
- }
189
- }
190
- },
191
163
  "cli": {
192
164
  "progress": {
193
165
  "done": "Done.",
@@ -244,5 +216,33 @@
244
216
  },
245
217
  "validation": {
246
218
  "defaultFieldName": "The field"
219
+ },
220
+ "commands": {
221
+ "ts-to-schema": {
222
+ "options": {
223
+ "config": {
224
+ "param": "'<'config'>'",
225
+ "description": "Path to the JSON configuration file."
226
+ },
227
+ "output-folder": {
228
+ "param": "'<'output-folder'>'",
229
+ "description": "The folder to write the schema files."
230
+ }
231
+ },
232
+ "progress": {
233
+ "loadingConfigJson": "Loading Config JSON",
234
+ "creatingWorkingDir": "Creating Working Directory",
235
+ "generatingSchemas": "Generating Schemas",
236
+ "finalisingSchemas": "Finalising Schemas",
237
+ "writingSchemas": "Writing Schemas",
238
+ "writingSchema": "Writing Schema",
239
+ "models": "Models"
240
+ },
241
+ "labels": {
242
+ "configJson": "Config JSON",
243
+ "outputFolder": "Output Folder",
244
+ "outputWorkingDir": "Output Working Directory"
245
+ }
246
+ }
247
247
  }
248
248
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/ts-to-schema - Changelog
2
2
 
3
- ## v0.0.1-next.7
3
+ ## v0.0.1-next.9
4
4
 
5
5
  - Initial Release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/ts-to-schema",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
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": "0.0.1-next.7",
19
+ "@twin.org/nameof": "0.0.1-next.9",
20
20
  "commander": "12.1.0",
21
21
  "glob": "11.0.0",
22
22
  "jsonschema": "1.4.1",