@twin.org/ts-to-schema 0.0.1-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/LICENSE +201 -0
- package/README.md +21 -0
- package/bin/index.js +8 -0
- package/dist/cjs/index.cjs +259 -0
- package/dist/esm/index.mjs +253 -0
- package/dist/locales/en.json +259 -0
- package/dist/types/cli.d.ts +23 -0
- package/dist/types/commands/tsToSchema.d.ts +21 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/models/ITsToSchemaConfig.d.ts +23 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +55 -0
- package/docs/reference/classes/CLI.md +75 -0
- package/docs/reference/functions/actionCommandTsToSchema.md +23 -0
- package/docs/reference/functions/buildCommandTsToSchema.md +15 -0
- package/docs/reference/functions/tsToSchema.md +23 -0
- package/docs/reference/index.md +15 -0
- package/docs/reference/interfaces/ITsToSchemaConfig.md +39 -0
- package/locales/en.json +38 -0
- package/package.json +47 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Class: CLI
|
|
2
|
+
|
|
3
|
+
The main entry point for the CLI.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `CLIBase`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new CLI()
|
|
12
|
+
|
|
13
|
+
> **new CLI**(): [`CLI`](CLI.md)
|
|
14
|
+
|
|
15
|
+
#### Returns
|
|
16
|
+
|
|
17
|
+
[`CLI`](CLI.md)
|
|
18
|
+
|
|
19
|
+
#### Inherited from
|
|
20
|
+
|
|
21
|
+
`CLIBase.constructor`
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### run()
|
|
26
|
+
|
|
27
|
+
> **run**(`argv`, `localesDirectory`?, `options`?): `Promise`\<`number`\>
|
|
28
|
+
|
|
29
|
+
Run the app.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
• **argv**: `string`[]
|
|
34
|
+
|
|
35
|
+
The process arguments.
|
|
36
|
+
|
|
37
|
+
• **localesDirectory?**: `string`
|
|
38
|
+
|
|
39
|
+
The directory for the locales, default to relative to the script.
|
|
40
|
+
|
|
41
|
+
• **options?**
|
|
42
|
+
|
|
43
|
+
Additional options.
|
|
44
|
+
|
|
45
|
+
• **options.overrideOutputWidth?**: `number`
|
|
46
|
+
|
|
47
|
+
Override the output width.
|
|
48
|
+
|
|
49
|
+
#### Returns
|
|
50
|
+
|
|
51
|
+
`Promise`\<`number`\>
|
|
52
|
+
|
|
53
|
+
The exit code.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### configureRoot()
|
|
58
|
+
|
|
59
|
+
> `protected` **configureRoot**(`program`): `void`
|
|
60
|
+
|
|
61
|
+
Configure any options or actions at the root program level.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
• **program**: `Command`
|
|
66
|
+
|
|
67
|
+
The root program command.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`void`
|
|
72
|
+
|
|
73
|
+
#### Overrides
|
|
74
|
+
|
|
75
|
+
`CLIBase.configureRoot`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Function: actionCommandTsToSchema()
|
|
2
|
+
|
|
3
|
+
> **actionCommandTsToSchema**(`configFile`, `outputFolder`, `opts`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Action the root command.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
• **configFile**: `string`
|
|
10
|
+
|
|
11
|
+
The optional configuration file.
|
|
12
|
+
|
|
13
|
+
• **outputFolder**: `string`
|
|
14
|
+
|
|
15
|
+
The output folder for the schemas.
|
|
16
|
+
|
|
17
|
+
• **opts**: `unknown`
|
|
18
|
+
|
|
19
|
+
The options for the command.
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Function: tsToSchema()
|
|
2
|
+
|
|
3
|
+
> **tsToSchema**(`config`, `outputFolder`, `workingDirectory`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Convert the TypeScript definitions to JSON Schemas.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
• **config**: [`ITsToSchemaConfig`](../interfaces/ITsToSchemaConfig.md)
|
|
10
|
+
|
|
11
|
+
The configuration for the app.
|
|
12
|
+
|
|
13
|
+
• **outputFolder**: `string`
|
|
14
|
+
|
|
15
|
+
The location of the folder to output the JSON schemas.
|
|
16
|
+
|
|
17
|
+
• **workingDirectory**: `string`
|
|
18
|
+
|
|
19
|
+
The folder the app was run from.
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @twin.org/ts-to-schema
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [CLI](classes/CLI.md)
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [ITsToSchemaConfig](interfaces/ITsToSchemaConfig.md)
|
|
10
|
+
|
|
11
|
+
## Functions
|
|
12
|
+
|
|
13
|
+
- [buildCommandTsToSchema](functions/buildCommandTsToSchema.md)
|
|
14
|
+
- [actionCommandTsToSchema](functions/actionCommandTsToSchema.md)
|
|
15
|
+
- [tsToSchema](functions/tsToSchema.md)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Interface: ITsToSchemaConfig
|
|
2
|
+
|
|
3
|
+
Configuration for the tool.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### baseUrl
|
|
8
|
+
|
|
9
|
+
> **baseUrl**: `string`
|
|
10
|
+
|
|
11
|
+
The base url for the type references e.g. https://schema.twindev.org/my-namespace/.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### sources
|
|
16
|
+
|
|
17
|
+
> **sources**: `string`[]
|
|
18
|
+
|
|
19
|
+
The list of glob sources that can be used to generate the schemas.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### types
|
|
24
|
+
|
|
25
|
+
> **types**: `string`[]
|
|
26
|
+
|
|
27
|
+
The list of types to generate.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### externalReferences?
|
|
32
|
+
|
|
33
|
+
> `optional` **externalReferences**: `object`
|
|
34
|
+
|
|
35
|
+
External type references
|
|
36
|
+
|
|
37
|
+
#### Index Signature
|
|
38
|
+
|
|
39
|
+
\[`id`: `string`\]: `string`
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"error": {
|
|
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
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"commands": {
|
|
11
|
+
"ts-to-schema": {
|
|
12
|
+
"options": {
|
|
13
|
+
"config": {
|
|
14
|
+
"param": "'<'config'>'",
|
|
15
|
+
"description": "Path to the JSON configuration file."
|
|
16
|
+
},
|
|
17
|
+
"output-folder": {
|
|
18
|
+
"param": "'<'output-folder'>'",
|
|
19
|
+
"description": "The folder to write the schema files."
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"progress": {
|
|
23
|
+
"loadingConfigJson": "Loading Config JSON",
|
|
24
|
+
"creatingWorkingDir": "Creating Working Directory",
|
|
25
|
+
"generatingSchemas": "Generating Schemas",
|
|
26
|
+
"finalisingSchemas": "Finalising Schemas",
|
|
27
|
+
"writingSchemas": "Writing Schemas",
|
|
28
|
+
"writingSchema": "Writing Schema",
|
|
29
|
+
"models": "Models"
|
|
30
|
+
},
|
|
31
|
+
"labels": {
|
|
32
|
+
"configJson": "Config JSON",
|
|
33
|
+
"outputFolder": "Output Folder",
|
|
34
|
+
"outputWorkingDir": "Output Working Directory"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@twin.org/ts-to-schema",
|
|
3
|
+
"version": "0.0.1-next.10",
|
|
4
|
+
"description": "Tool to convert TypeScript definitions to JSON schemas",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/twinfoundation/tools.git",
|
|
8
|
+
"directory": "packages/ts-to-schema"
|
|
9
|
+
},
|
|
10
|
+
"author": "martyn.janes@iota.org",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@twin.org/cli-core": "next",
|
|
18
|
+
"@twin.org/core": "next",
|
|
19
|
+
"@twin.org/nameof": "0.0.1-next.10",
|
|
20
|
+
"commander": "12.1.0",
|
|
21
|
+
"glob": "11.0.0",
|
|
22
|
+
"jsonschema": "1.4.1",
|
|
23
|
+
"ts-json-schema-generator": "2.4.0-next.1"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/cjs/index.cjs",
|
|
26
|
+
"module": "./dist/esm/index.mjs",
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"require": "./dist/cjs/index.cjs",
|
|
31
|
+
"import": "./dist/esm/index.mjs",
|
|
32
|
+
"types": "./dist/types/index.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"bin",
|
|
37
|
+
"dist/cjs",
|
|
38
|
+
"dist/esm",
|
|
39
|
+
"dist/locales",
|
|
40
|
+
"dist/types",
|
|
41
|
+
"locales",
|
|
42
|
+
"docs"
|
|
43
|
+
],
|
|
44
|
+
"bin": {
|
|
45
|
+
"ts-to-schema": "bin/index.js"
|
|
46
|
+
}
|
|
47
|
+
}
|