Skip to content

Commit ad86886

Browse files
committed
generate Workflow interfaces from json-schema via jjson2ts
1 parent 5f166e8 commit ad86886

File tree

4 files changed

+233
-2
lines changed

4 files changed

+233
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ dev/*.ipynb
135135
# Jest coverage reports and a side effect
136136
coverage
137137
junit.xml
138+
139+
# Interfaces generated from json-schema
140+
src/workflows/_interface

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"build:labextension": "jupyter labextension build .",
3434
"build:labextension:dev": "jupyter labextension build --development True .",
3535
"build:lib": "tsc",
36+
"build:schema:js": "json2ts -i src/workflows/schema -o src/workflows/_interface --no-unknownAny --unreachableDefinitions --cwd ./src/workflows/schema",
3637
"clean": "jlpm clean:lib",
3738
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
3839
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
@@ -74,6 +75,7 @@
7475
"@mui/system": "^5.10.6",
7576
"@types/react-dom": "^18.0.5",
7677
"cronstrue": "^2.12.0",
78+
"json-schema-to-typescript": "^15.0.3",
7779
"react": "^18.2.0",
7880
"react-dom": "^18.2.0",
7981
"tzdata": "^1.0.33"
@@ -141,4 +143,4 @@
141143
]
142144
}
143145
}
144-
}
146+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Workflow",
4+
"type": "object",
5+
"properties": {
6+
"schemaVersion": {
7+
"type": "string",
8+
"default": "0.0.1"
9+
},
10+
"tasks": {
11+
"type": "array",
12+
"items": {
13+
"$ref": "#/definitions/Task"
14+
},
15+
"description": "Worfklow tasks."
16+
},
17+
"name": {
18+
"type": "string",
19+
"description": "The name of the workflow."
20+
},
21+
"parameters": {
22+
"type": "object",
23+
"additionalProperties": {
24+
"type": "string"
25+
},
26+
"description": "Optional parameters for the workflow."
27+
},
28+
"schedule": {
29+
"type": "string",
30+
"description": "Optional schedule in cron format."
31+
},
32+
"timezone": {
33+
"type": "string",
34+
"description": "Timezone for the schedule."
35+
}
36+
},
37+
"required": [
38+
"tasks",
39+
"name"
40+
],
41+
"definitions": {
42+
"Task": {
43+
"type": "object",
44+
"properties": {
45+
"input_uri": {
46+
"type": "string",
47+
"description": "The URI of the input file."
48+
},
49+
"runtime_environment_name": {
50+
"type": "string",
51+
"description": "Name of the runtime environment."
52+
},
53+
"runtime_environment_parameters": {
54+
"type": "object",
55+
"additionalProperties": {
56+
"type": "string"
57+
},
58+
"description": "Parameters for the runtime environment."
59+
},
60+
"output_formats": {
61+
"type": "array",
62+
"items": {
63+
"type": "string"
64+
}
65+
},
66+
"parameters": {
67+
"type": "object",
68+
"additionalProperties": {
69+
"type": "string"
70+
},
71+
"description": "Task-specific parameters."
72+
},
73+
"tags": {
74+
"type": "array",
75+
"items": {
76+
"type": "string"
77+
},
78+
"description": "Tags for categorizing the job."
79+
},
80+
"name": {
81+
"type": "string",
82+
"description": "Name of the job."
83+
},
84+
"compute_type": {
85+
"type": "string",
86+
"description": "Type of compute resource to use."
87+
},
88+
"package_input_folder": {
89+
"type": "boolean",
90+
"description": "Whether to package the input folder."
91+
},
92+
"depends_on": {
93+
"type": "array",
94+
"items": {
95+
"type": "string"
96+
},
97+
"description": "DAG node IDs of tasks this task depends on."
98+
},
99+
"node_id": {
100+
"type": "string",
101+
"description": "DAG node ID of this task."
102+
}
103+
},
104+
"required": [
105+
"input_uri",
106+
"name",
107+
"node_id"
108+
]
109+
}
110+
}
111+
}

yarn.lock

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ __metadata:
2525
languageName: node
2626
linkType: hard
2727

28+
"@apidevtools/json-schema-ref-parser@npm:^11.5.5":
29+
version: 11.7.2
30+
resolution: "@apidevtools/json-schema-ref-parser@npm:11.7.2"
31+
dependencies:
32+
"@jsdevtools/ono": ^7.1.3
33+
"@types/json-schema": ^7.0.15
34+
js-yaml: ^4.1.0
35+
checksum: 44096e5cd5a03b17ee5eb0a3b9e9a4db85d87da8ae2abda264eae615f2a43e3e6ba5ca208e1161d4d946755b121c10a9550e88792a725951f2c4cff6df0d8a19
36+
languageName: node
37+
linkType: hard
38+
2839
"@babel/code-frame@npm:7.12.11":
2940
version: 7.12.11
3041
resolution: "@babel/code-frame@npm:7.12.11"
@@ -3321,6 +3332,13 @@ __metadata:
33213332
languageName: node
33223333
linkType: hard
33233334

3335+
"@jsdevtools/ono@npm:^7.1.3":
3336+
version: 7.1.3
3337+
resolution: "@jsdevtools/ono@npm:7.1.3"
3338+
checksum: 2297fcd472ba810bffe8519d2249171132844c7174f3a16634f9260761c8c78bc0428a4190b5b6d72d45673c13918ab9844d706c3ed4ef8f62ab11a2627a08ad
3339+
languageName: node
3340+
linkType: hard
3341+
33243342
"@jupyter/ydoc@npm:^1.0.2":
33253343
version: 1.0.2
33263344
resolution: "@jupyter/ydoc@npm:1.0.2"
@@ -3839,6 +3857,7 @@ __metadata:
38393857
eslint-config-prettier: ^6.15.0
38403858
eslint-plugin-prettier: ^3.1.4
38413859
jest: ^29
3860+
json-schema-to-typescript: ^15.0.3
38423861
mkdirp: ^1.0.3
38433862
npm-run-all: ^4.1.5
38443863
prettier: ^2.1.1
@@ -4751,13 +4770,27 @@ __metadata:
47514770
languageName: node
47524771
linkType: hard
47534772

4773+
"@types/json-schema@npm:^7.0.15":
4774+
version: 7.0.15
4775+
resolution: "@types/json-schema@npm:7.0.15"
4776+
checksum: 97ed0cb44d4070aecea772b7b2e2ed971e10c81ec87dd4ecc160322ffa55ff330dace1793489540e3e318d90942064bb697cc0f8989391797792d919737b3b98
4777+
languageName: node
4778+
linkType: hard
4779+
47544780
"@types/json-schema@npm:^7.0.9":
47554781
version: 7.0.12
47564782
resolution: "@types/json-schema@npm:7.0.12"
47574783
checksum: 00239e97234eeb5ceefb0c1875d98ade6e922bfec39dd365ec6bd360b5c2f825e612ac4f6e5f1d13601b8b30f378f15e6faa805a3a732f4a1bbe61915163d293
47584784
languageName: node
47594785
linkType: hard
47604786

4787+
"@types/lodash@npm:^4.17.7":
4788+
version: 4.17.13
4789+
resolution: "@types/lodash@npm:4.17.13"
4790+
checksum: d0bf8fbd950be71946e0076b30fd40d492293baea75f05931b6b5b906fd62583708c6229abdb95b30205ad24ce1ed2f48bc9d419364f682320edd03405cc0c7e
4791+
languageName: node
4792+
linkType: hard
4793+
47614794
"@types/minimist@npm:^1.2.0":
47624795
version: 1.2.2
47634796
resolution: "@types/minimist@npm:1.2.2"
@@ -5465,6 +5498,13 @@ __metadata:
54655498
languageName: node
54665499
linkType: hard
54675500

5501+
"argparse@npm:^2.0.1":
5502+
version: 2.0.1
5503+
resolution: "argparse@npm:2.0.1"
5504+
checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced
5505+
languageName: node
5506+
linkType: hard
5507+
54685508
"array-union@npm:^2.1.0":
54695509
version: 2.1.0
54705510
resolution: "array-union@npm:2.1.0"
@@ -6967,6 +7007,18 @@ __metadata:
69677007
languageName: node
69687008
linkType: hard
69697009

7010+
"fdir@npm:^6.4.2":
7011+
version: 6.4.2
7012+
resolution: "fdir@npm:6.4.2"
7013+
peerDependencies:
7014+
picomatch: ^3 || ^4
7015+
peerDependenciesMeta:
7016+
picomatch:
7017+
optional: true
7018+
checksum: 517ad31c495f1c0778238eef574a7818788efaaf2ce1969ffa18c70793e2951a9763dfa2e6720b8fcef615e602a3cbb47f9b8aea9da0b02147579ab36043f22f
7019+
languageName: node
7020+
linkType: hard
7021+
69707022
"file-entry-cache@npm:^6.0.1":
69717023
version: 6.0.1
69727024
resolution: "file-entry-cache@npm:6.0.1"
@@ -7722,7 +7774,7 @@ __metadata:
77227774
languageName: node
77237775
linkType: hard
77247776

7725-
"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1":
7777+
"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3":
77267778
version: 4.0.3
77277779
resolution: "is-glob@npm:4.0.3"
77287780
dependencies:
@@ -8446,6 +8498,17 @@ __metadata:
84468498
languageName: node
84478499
linkType: hard
84488500

8501+
"js-yaml@npm:^4.1.0":
8502+
version: 4.1.0
8503+
resolution: "js-yaml@npm:4.1.0"
8504+
dependencies:
8505+
argparse: ^2.0.1
8506+
bin:
8507+
js-yaml: bin/js-yaml.js
8508+
checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a
8509+
languageName: node
8510+
linkType: hard
8511+
84498512
"jsdom@npm:^20.0.0":
84508513
version: 20.0.3
84518514
resolution: "jsdom@npm:20.0.3"
@@ -8537,6 +8600,25 @@ __metadata:
85378600
languageName: node
85388601
linkType: hard
85398602

8603+
"json-schema-to-typescript@npm:^15.0.3":
8604+
version: 15.0.3
8605+
resolution: "json-schema-to-typescript@npm:15.0.3"
8606+
dependencies:
8607+
"@apidevtools/json-schema-ref-parser": ^11.5.5
8608+
"@types/json-schema": ^7.0.15
8609+
"@types/lodash": ^4.17.7
8610+
is-glob: ^4.0.3
8611+
js-yaml: ^4.1.0
8612+
lodash: ^4.17.21
8613+
minimist: ^1.2.8
8614+
prettier: ^3.2.5
8615+
tinyglobby: ^0.2.9
8616+
bin:
8617+
json2ts: dist/src/cli.js
8618+
checksum: e2337655d4a6f9ec0baccecda1e6d29bfdc5c04afed03d27669e87652334c1db5b8f7b3ad84623ad987ebe3e83e931dc181380bcd8b03d21ee3812a1f8a56239
8619+
languageName: node
8620+
linkType: hard
8621+
85408622
"json-schema-traverse@npm:^0.4.1":
85418623
version: 0.4.1
85428624
resolution: "json-schema-traverse@npm:0.4.1"
@@ -9022,6 +9104,13 @@ __metadata:
90229104
languageName: node
90239105
linkType: hard
90249106

9107+
"minimist@npm:^1.2.8":
9108+
version: 1.2.8
9109+
resolution: "minimist@npm:1.2.8"
9110+
checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0
9111+
languageName: node
9112+
linkType: hard
9113+
90259114
"minimist@npm:~1.2.0":
90269115
version: 1.2.6
90279116
resolution: "minimist@npm:1.2.6"
@@ -9571,6 +9660,13 @@ __metadata:
95719660
languageName: node
95729661
linkType: hard
95739662

9663+
"picomatch@npm:^4.0.2":
9664+
version: 4.0.2
9665+
resolution: "picomatch@npm:4.0.2"
9666+
checksum: a7a5188c954f82c6585720e9143297ccd0e35ad8072231608086ca950bee672d51b0ef676254af0788205e59bd4e4deb4e7708769226bed725bf13370a7d1464
9667+
languageName: node
9668+
linkType: hard
9669+
95749670
"pidtree@npm:^0.3.0":
95759671
version: 0.3.1
95769672
resolution: "pidtree@npm:0.3.1"
@@ -9730,6 +9826,15 @@ __metadata:
97309826
languageName: node
97319827
linkType: hard
97329828

9829+
"prettier@npm:^3.2.5":
9830+
version: 3.4.2
9831+
resolution: "prettier@npm:3.4.2"
9832+
bin:
9833+
prettier: bin/prettier.cjs
9834+
checksum: 061c84513db62d3944c8dc8df36584dad82883ce4e49efcdbedd8703dce5b173c33fd9d2a4e1725d642a3b713c932b55418342eaa347479bc4a9cca114a04cd0
9835+
languageName: node
9836+
linkType: hard
9837+
97339838
"pretty-format@npm:^29.0.0, pretty-format@npm:^29.6.1":
97349839
version: 29.6.1
97359840
resolution: "pretty-format@npm:29.6.1"
@@ -11004,6 +11109,16 @@ __metadata:
1100411109
languageName: node
1100511110
linkType: hard
1100611111

11112+
"tinyglobby@npm:^0.2.9":
11113+
version: 0.2.10
11114+
resolution: "tinyglobby@npm:0.2.10"
11115+
dependencies:
11116+
fdir: ^6.4.2
11117+
picomatch: ^4.0.2
11118+
checksum: 7e2ffe262ebc149036bdef37c56b32d02d52cf09efa7d43dbdab2ea3c12844a4da881058835ce4c74d1891190e5ad5ec5133560a11ec8314849b68ad0d99d3f4
11119+
languageName: node
11120+
linkType: hard
11121+
1100711122
"tmpl@npm:1.0.5":
1100811123
version: 1.0.5
1100911124
resolution: "tmpl@npm:1.0.5"

0 commit comments

Comments
 (0)