@twin.org/ts-to-openapi 0.0.1-next.3 → 0.0.1-next.6

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/bin/index.js CHANGED
File without changes
@@ -607,6 +607,7 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
607
607
  }
608
608
  }
609
609
  const substituteSchemas = [];
610
+ const finalExternals = {};
610
611
  // Remove the I, < and > from names
611
612
  const finalSchemas = {};
612
613
  for (const schema in schemas) {
@@ -629,8 +630,10 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
629
630
  // If the schema is external then remove it from the final schemas
630
631
  if (core.Is.object(externalReferences)) {
631
632
  for (const external in externalReferences) {
632
- if (new RegExp(`^${external}$`).test(schema)) {
633
+ const re = new RegExp(`^I?${external}(?<!Request|Response)$`);
634
+ if (re.test(schema)) {
633
635
  skipSchema = true;
636
+ finalExternals[core.StringHelper.stripPrefix(schema)] = schema.replace(re, externalReferences[external]);
634
637
  break;
635
638
  }
636
639
  }
@@ -695,10 +698,8 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
695
698
  // Cleanup the generic markers
696
699
  json = json.replace(/%3Cunknown%3E/g, "");
697
700
  // Remove external references
698
- if (core.Is.objectValue(externalReferences)) {
699
- for (const external in externalReferences) {
700
- json = json.replace(new RegExp(`#/components/schemas/${core.StringHelper.stripPrefix(external)}`, "g"), externalReferences[external]);
701
- }
701
+ for (const finalExternal in finalExternals) {
702
+ json = json.replace(new RegExp(`"#/components/schemas/${core.StringHelper.stripPrefix(finalExternal)}"`, "g"), `"${finalExternals[finalExternal]}"`);
702
703
  }
703
704
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.ts-to-openapi.progress.writingOutputFile"), outputFile);
704
705
  try {
@@ -1098,15 +1099,18 @@ class CLI extends cliCore.CLIBase {
1098
1099
  * Run the app.
1099
1100
  * @param argv The process arguments.
1100
1101
  * @param localesDirectory The directory for the locales, default to relative to the script.
1102
+ * @param options Additional options.
1103
+ * @param options.overrideOutputWidth Override the output width.
1101
1104
  * @returns The exit code.
1102
1105
  */
1103
- async run(argv, localesDirectory) {
1106
+ async run(argv, localesDirectory, options) {
1104
1107
  return this.execute({
1105
1108
  title: "TWIN TypeScript To OpenAPI",
1106
1109
  appName: "ts-to-openapi",
1107
- version: "0.0.1-next.3",
1110
+ version: "0.0.1-next.6",
1108
1111
  icon: "⚙️ ",
1109
- supportsEnvFiles: false
1112
+ supportsEnvFiles: false,
1113
+ overrideOutputWidth: options?.overrideOutputWidth
1110
1114
  }, localesDirectory ?? path.join(path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../locales"), argv);
1111
1115
  }
1112
1116
  /**
@@ -604,6 +604,7 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
604
604
  }
605
605
  }
606
606
  const substituteSchemas = [];
607
+ const finalExternals = {};
607
608
  // Remove the I, < and > from names
608
609
  const finalSchemas = {};
609
610
  for (const schema in schemas) {
@@ -626,8 +627,10 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
626
627
  // If the schema is external then remove it from the final schemas
627
628
  if (Is.object(externalReferences)) {
628
629
  for (const external in externalReferences) {
629
- if (new RegExp(`^${external}$`).test(schema)) {
630
+ const re = new RegExp(`^I?${external}(?<!Request|Response)$`);
631
+ if (re.test(schema)) {
630
632
  skipSchema = true;
633
+ finalExternals[StringHelper.stripPrefix(schema)] = schema.replace(re, externalReferences[external]);
631
634
  break;
632
635
  }
633
636
  }
@@ -692,10 +695,8 @@ async function finaliseOutput(usedCommonResponseTypes, schemas, openApi, securit
692
695
  // Cleanup the generic markers
693
696
  json = json.replace(/%3Cunknown%3E/g, "");
694
697
  // Remove external references
695
- if (Is.objectValue(externalReferences)) {
696
- for (const external in externalReferences) {
697
- json = json.replace(new RegExp(`#/components/schemas/${StringHelper.stripPrefix(external)}`, "g"), externalReferences[external]);
698
- }
698
+ for (const finalExternal in finalExternals) {
699
+ json = json.replace(new RegExp(`"#/components/schemas/${StringHelper.stripPrefix(finalExternal)}"`, "g"), `"${finalExternals[finalExternal]}"`);
699
700
  }
700
701
  CLIDisplay.task(I18n.formatMessage("commands.ts-to-openapi.progress.writingOutputFile"), outputFile);
701
702
  try {
@@ -1095,15 +1096,18 @@ class CLI extends CLIBase {
1095
1096
  * Run the app.
1096
1097
  * @param argv The process arguments.
1097
1098
  * @param localesDirectory The directory for the locales, default to relative to the script.
1099
+ * @param options Additional options.
1100
+ * @param options.overrideOutputWidth Override the output width.
1098
1101
  * @returns The exit code.
1099
1102
  */
1100
- async run(argv, localesDirectory) {
1103
+ async run(argv, localesDirectory, options) {
1101
1104
  return this.execute({
1102
1105
  title: "TWIN TypeScript To OpenAPI",
1103
1106
  appName: "ts-to-openapi",
1104
- version: "0.0.1-next.3",
1107
+ version: "0.0.1-next.6",
1105
1108
  icon: "⚙️ ",
1106
- supportsEnvFiles: false
1109
+ supportsEnvFiles: false,
1110
+ overrideOutputWidth: options?.overrideOutputWidth
1107
1111
  }, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
1108
1112
  }
1109
1113
  /**
@@ -105,6 +105,10 @@
105
105
  "bitString": {
106
106
  "outOfRange": "The index should be >= 0 and less than the length of the bit string"
107
107
  },
108
+ "entitySchemaHelper": {
109
+ "noIsPrimary": "Property \"entitySchema.properties\" must contain a value with isPrimary set",
110
+ "multipleIsPrimary": "Property \"entitySchema.properties\" contains more than one property with isPrimary set"
111
+ },
108
112
  "fetchHelper": {
109
113
  "decodingJSON": "Decoding JSON failed for route \"{route}\"",
110
114
  "failureStatusText": "The request to the API failed: \"{statusText}\"",
@@ -8,9 +8,13 @@ export declare class CLI extends CLIBase {
8
8
  * Run the app.
9
9
  * @param argv The process arguments.
10
10
  * @param localesDirectory The directory for the locales, default to relative to the script.
11
+ * @param options Additional options.
12
+ * @param options.overrideOutputWidth Override the output width.
11
13
  * @returns The exit code.
12
14
  */
13
- run(argv: string[], localesDirectory?: string): Promise<number>;
15
+ run(argv: string[], localesDirectory?: string, options?: {
16
+ overrideOutputWidth?: number;
17
+ }): Promise<number>;
14
18
  /**
15
19
  * Configure any options or actions at the root program level.
16
20
  * @param program The root program command.
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/ts-to-openapi - Changelog
2
2
 
3
- ## v0.0.1-next.3
3
+ ## v0.0.1-next.6
4
4
 
5
5
  - Initial Release
@@ -24,7 +24,7 @@ The main entry point for the CLI.
24
24
 
25
25
  ### run()
26
26
 
27
- > **run**(`argv`, `localesDirectory`?): `Promise`\<`number`\>
27
+ > **run**(`argv`, `localesDirectory`?, `options`?): `Promise`\<`number`\>
28
28
 
29
29
  Run the app.
30
30
 
@@ -38,6 +38,14 @@ The process arguments.
38
38
 
39
39
  The directory for the locales, default to relative to the script.
40
40
 
41
+ • **options?**
42
+
43
+ Additional options.
44
+
45
+ • **options.overrideOutputWidth?**: `number`
46
+
47
+ Override the output width.
48
+
41
49
  #### Returns
42
50
 
43
51
  `Promise`\<`number`\>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/ts-to-openapi",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.6",
4
4
  "description": "Tool to convert TypeScript REST route definitions to OpenAPI Specifications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,46 +13,17 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage",
18
- "build": "tspc",
19
- "merge-locales": "merge-locales",
20
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
21
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
22
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
23
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
24
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
25
- "docs:clean": "rimraf docs/reference",
26
- "docs:generate": "typedoc",
27
- "docs": "npm run docs:clean && npm run docs:generate",
28
- "dist": "npm run clean && npm run build && npm run merge-locales && npm run test && npm run bundle && npm run docs"
29
- },
30
16
  "dependencies": {
31
17
  "@twin.org/api-models": "next",
32
18
  "@twin.org/cli-core": "next",
33
19
  "@twin.org/core": "next",
34
- "@twin.org/nameof": "0.0.1-next.3",
20
+ "@twin.org/nameof": "0.0.1-next.6",
35
21
  "@twin.org/web": "next",
36
22
  "commander": "12.1.0",
37
23
  "glob": "11.0.0",
38
24
  "jsonschema": "1.4.1",
39
25
  "ts-json-schema-generator": "2.4.0-next.1"
40
26
  },
41
- "devDependencies": {
42
- "@twin.org/merge-locales": "0.0.1-next.3",
43
- "@twin.org/nameof-transformer": "0.0.1-next.3",
44
- "@types/node": "22.5.5",
45
- "@vitest/coverage-v8": "2.1.1",
46
- "copyfiles": "2.4.1",
47
- "rimraf": "6.0.1",
48
- "rollup": "4.21.3",
49
- "rollup-plugin-typescript2": "0.36.0",
50
- "ts-patch": "3.2.1",
51
- "typedoc": "0.26.7",
52
- "typedoc-plugin-markdown": "4.2.7",
53
- "typescript": "5.6.2",
54
- "vitest": "2.1.1"
55
- },
56
27
  "main": "./dist/cjs/index.cjs",
57
28
  "module": "./dist/esm/index.mjs",
58
29
  "types": "./dist/types/index.d.ts",