doc-detective-common 4.0.0-beta.0-dev.4 → 4.0.0-beta.0-dev.5
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/package.json +1 -1
- package/.c8rc.json +0 -8
- package/.mocharc.yml +0 -1
- package/icon.png +0 -0
- package/scripts/check-coverage-ratchet.cjs +0 -123
- package/scripts/createCjsWrapper.js +0 -25
- package/scripts/generateTypes.cjs +0 -54
- package/src/detectTests.ts +0 -660
- package/src/index.ts +0 -3
- package/src/schemas/build/checkLink_v2.schema.json +0 -81
- package/src/schemas/build/checkLink_v3.schema.json +0 -92
- package/src/schemas/build/click_v3.schema.json +0 -145
- package/src/schemas/build/config_v2.schema.json +0 -1079
- package/src/schemas/build/config_v3.schema.json +0 -696
- package/src/schemas/build/context_v2.schema.json +0 -135
- package/src/schemas/build/context_v3.schema.json +0 -229
- package/src/schemas/build/dragAndDrop_v3.schema.json +0 -189
- package/src/schemas/build/find_v2.schema.json +0 -168
- package/src/schemas/build/find_v3.schema.json +0 -214
- package/src/schemas/build/goTo_v2.schema.json +0 -63
- package/src/schemas/build/goTo_v3.schema.json +0 -257
- package/src/schemas/build/httpRequest_v2.schema.json +0 -321
- package/src/schemas/build/httpRequest_v3.schema.json +0 -439
- package/src/schemas/build/loadCookie_v3.schema.json +0 -138
- package/src/schemas/build/loadVariables_v3.schema.json +0 -10
- package/src/schemas/build/moveTo_v2.schema.json +0 -99
- package/src/schemas/build/openApi_v2.schema.json +0 -76
- package/src/schemas/build/openApi_v3.schema.json +0 -161
- package/src/schemas/build/record_v3.schema.json +0 -70
- package/src/schemas/build/report_v3.schema.json +0 -53
- package/src/schemas/build/resolvedTests_v3.schema.json +0 -238
- package/src/schemas/build/runCode_v2.schema.json +0 -201
- package/src/schemas/build/runCode_v3.schema.json +0 -138
- package/src/schemas/build/runShell_v2.schema.json +0 -189
- package/src/schemas/build/runShell_v3.schema.json +0 -156
- package/src/schemas/build/saveCookie_v3.schema.json +0 -149
- package/src/schemas/build/saveScreenshot_v2.schema.json +0 -150
- package/src/schemas/build/screenshot_v3.schema.json +0 -250
- package/src/schemas/build/setVariables_v2.schema.json +0 -39
- package/src/schemas/build/sourceIntegration_v3.schema.json +0 -51
- package/src/schemas/build/spec_v2.schema.json +0 -199
- package/src/schemas/build/spec_v3.schema.json +0 -213
- package/src/schemas/build/startRecording_v2.schema.json +0 -57
- package/src/schemas/build/step_v3.schema.json +0 -669
- package/src/schemas/build/stopRecord_v3.schema.json +0 -13
- package/src/schemas/build/stopRecording_v2.schema.json +0 -33
- package/src/schemas/build/test_v2.schema.json +0 -244
- package/src/schemas/build/test_v3.schema.json +0 -292
- package/src/schemas/build/typeKeys_v2.schema.json +0 -72
- package/src/schemas/build/type_v3.schema.json +0 -131
- package/src/schemas/build/wait_v2.schema.json +0 -42
- package/src/schemas/build/wait_v3.schema.json +0 -37
- package/src/schemas/dereferenceSchemas.cjs +0 -208
- package/src/schemas/index.ts +0 -6
- package/src/schemas/output_schemas/analytics_v1.schema.json +0 -585
- package/src/schemas/output_schemas/checkLink_v1.schema.json +0 -42
- package/src/schemas/output_schemas/checkLink_v2.schema.json +0 -80
- package/src/schemas/output_schemas/checkLink_v3.schema.json +0 -145
- package/src/schemas/output_schemas/click_v1.schema.json +0 -60
- package/src/schemas/output_schemas/click_v3.schema.json +0 -252
- package/src/schemas/output_schemas/config_v2.schema.json +0 -2628
- package/src/schemas/output_schemas/config_v3.schema.json +0 -16470
- package/src/schemas/output_schemas/context_v2.schema.json +0 -134
- package/src/schemas/output_schemas/context_v3.schema.json +0 -374
- package/src/schemas/output_schemas/dragAndDrop_v3.schema.json +0 -496
- package/src/schemas/output_schemas/endRecord_v3.schema.json +0 -12
- package/src/schemas/output_schemas/find_v1.schema.json +0 -171
- package/src/schemas/output_schemas/find_v2.schema.json +0 -184
- package/src/schemas/output_schemas/find_v3.schema.json +0 -1349
- package/src/schemas/output_schemas/goTo_v1.schema.json +0 -30
- package/src/schemas/output_schemas/goTo_v2.schema.json +0 -62
- package/src/schemas/output_schemas/goTo_v3.schema.json +0 -419
- package/src/schemas/output_schemas/httpRequest_v1.schema.json +0 -115
- package/src/schemas/output_schemas/httpRequest_v2.schema.json +0 -392
- package/src/schemas/output_schemas/httpRequest_v3.schema.json +0 -994
- package/src/schemas/output_schemas/loadCookie_v3.schema.json +0 -228
- package/src/schemas/output_schemas/loadVariables_v3.schema.json +0 -9
- package/src/schemas/output_schemas/matchText_v1.schema.json +0 -32
- package/src/schemas/output_schemas/moveMouse_v1.schema.json +0 -60
- package/src/schemas/output_schemas/moveTo_v2.schema.json +0 -98
- package/src/schemas/output_schemas/openApi_v2.schema.json +0 -75
- package/src/schemas/output_schemas/openApi_v3.schema.json +0 -162
- package/src/schemas/output_schemas/record_v3.schema.json +0 -101
- package/src/schemas/output_schemas/report_v3.schema.json +0 -16826
- package/src/schemas/output_schemas/resolvedTests_v3.schema.json +0 -33331
- package/src/schemas/output_schemas/runCode_v2.schema.json +0 -200
- package/src/schemas/output_schemas/runCode_v3.schema.json +0 -222
- package/src/schemas/output_schemas/runShell_v1.schema.json +0 -35
- package/src/schemas/output_schemas/runShell_v2.schema.json +0 -188
- package/src/schemas/output_schemas/runShell_v3.schema.json +0 -236
- package/src/schemas/output_schemas/saveCookie_v3.schema.json +0 -245
- package/src/schemas/output_schemas/saveScreenshot_v2.schema.json +0 -149
- package/src/schemas/output_schemas/screenshot_v1.schema.json +0 -48
- package/src/schemas/output_schemas/screenshot_v3.schema.json +0 -681
- package/src/schemas/output_schemas/scroll_v1.schema.json +0 -50
- package/src/schemas/output_schemas/setVariables_v2.schema.json +0 -38
- package/src/schemas/output_schemas/sourceIntegration_v3.schema.json +0 -50
- package/src/schemas/output_schemas/spec_v2.schema.json +0 -2301
- package/src/schemas/output_schemas/spec_v3.schema.json +0 -16630
- package/src/schemas/output_schemas/startRecording_v1.schema.json +0 -55
- package/src/schemas/output_schemas/startRecording_v2.schema.json +0 -56
- package/src/schemas/output_schemas/step_v3.schema.json +0 -7317
- package/src/schemas/output_schemas/stopRecord_v3.schema.json +0 -12
- package/src/schemas/output_schemas/stopRecording_v1.schema.json +0 -20
- package/src/schemas/output_schemas/stopRecording_v2.schema.json +0 -32
- package/src/schemas/output_schemas/test_v2.schema.json +0 -1903
- package/src/schemas/output_schemas/test_v3.schema.json +0 -15863
- package/src/schemas/output_schemas/typeKeys_v2.schema.json +0 -71
- package/src/schemas/output_schemas/type_v1.schema.json +0 -62
- package/src/schemas/output_schemas/type_v3.schema.json +0 -244
- package/src/schemas/output_schemas/wait_v1.schema.json +0 -42
- package/src/schemas/output_schemas/wait_v2.schema.json +0 -41
- package/src/schemas/output_schemas/wait_v3.schema.json +0 -41
- package/src/schemas/schemas.json +0 -121331
- package/src/schemas/src_schemas/analytics_v1.schema.json +0 -585
- package/src/schemas/src_schemas/checkLink_v1.schema.json +0 -42
- package/src/schemas/src_schemas/checkLink_v2.schema.json +0 -65
- package/src/schemas/src_schemas/checkLink_v3.schema.json +0 -91
- package/src/schemas/src_schemas/click_v1.schema.json +0 -60
- package/src/schemas/src_schemas/click_v3.schema.json +0 -144
- package/src/schemas/src_schemas/config_v2.schema.json +0 -929
- package/src/schemas/src_schemas/config_v3.schema.json +0 -633
- package/src/schemas/src_schemas/context_v2.schema.json +0 -108
- package/src/schemas/src_schemas/context_v3.schema.json +0 -202
- package/src/schemas/src_schemas/dragAndDrop_v3.schema.json +0 -185
- package/src/schemas/src_schemas/find_v1.schema.json +0 -137
- package/src/schemas/src_schemas/find_v2.schema.json +0 -155
- package/src/schemas/src_schemas/find_v3.schema.json +0 -210
- package/src/schemas/src_schemas/goTo_v1.schema.json +0 -30
- package/src/schemas/src_schemas/goTo_v2.schema.json +0 -58
- package/src/schemas/src_schemas/goTo_v3.schema.json +0 -232
- package/src/schemas/src_schemas/httpRequest_v1.schema.json +0 -115
- package/src/schemas/src_schemas/httpRequest_v2.schema.json +0 -284
- package/src/schemas/src_schemas/httpRequest_v3.schema.json +0 -402
- package/src/schemas/src_schemas/loadCookie_v3.schema.json +0 -113
- package/src/schemas/src_schemas/loadVariables_v3.schema.json +0 -9
- package/src/schemas/src_schemas/matchText_v1.schema.json +0 -32
- package/src/schemas/src_schemas/moveMouse_v1.schema.json +0 -60
- package/src/schemas/src_schemas/moveTo_v2.schema.json +0 -89
- package/src/schemas/src_schemas/openApi_v2.schema.json +0 -64
- package/src/schemas/src_schemas/openApi_v3.schema.json +0 -161
- package/src/schemas/src_schemas/record_v3.schema.json +0 -69
- package/src/schemas/src_schemas/report_v3.schema.json +0 -52
- package/src/schemas/src_schemas/resolvedTests_v3.schema.json +0 -237
- package/src/schemas/src_schemas/runCode_v2.schema.json +0 -181
- package/src/schemas/src_schemas/runCode_v3.schema.json +0 -137
- package/src/schemas/src_schemas/runShell_v1.schema.json +0 -35
- package/src/schemas/src_schemas/runShell_v2.schema.json +0 -166
- package/src/schemas/src_schemas/runShell_v3.schema.json +0 -155
- package/src/schemas/src_schemas/saveCookie_v3.schema.json +0 -124
- package/src/schemas/src_schemas/saveScreenshot_v2.schema.json +0 -129
- package/src/schemas/src_schemas/screenshot_v1.schema.json +0 -48
- package/src/schemas/src_schemas/screenshot_v3.schema.json +0 -249
- package/src/schemas/src_schemas/scroll_v1.schema.json +0 -50
- package/src/schemas/src_schemas/setVariables_v2.schema.json +0 -38
- package/src/schemas/src_schemas/sourceIntegration_v3.schema.json +0 -45
- package/src/schemas/src_schemas/spec_v2.schema.json +0 -175
- package/src/schemas/src_schemas/spec_v3.schema.json +0 -212
- package/src/schemas/src_schemas/startRecording_v1.schema.json +0 -55
- package/src/schemas/src_schemas/startRecording_v2.schema.json +0 -54
- package/src/schemas/src_schemas/step_v3.schema.json +0 -632
- package/src/schemas/src_schemas/stopRecord_v3.schema.json +0 -9
- package/src/schemas/src_schemas/stopRecording_v1.schema.json +0 -20
- package/src/schemas/src_schemas/stopRecording_v2.schema.json +0 -32
- package/src/schemas/src_schemas/test_v2.schema.json +0 -200
- package/src/schemas/src_schemas/test_v3.schema.json +0 -268
- package/src/schemas/src_schemas/typeKeys_v2.schema.json +0 -63
- package/src/schemas/src_schemas/type_v1.schema.json +0 -62
- package/src/schemas/src_schemas/type_v3.schema.json +0 -118
- package/src/schemas/src_schemas/wait_v1.schema.json +0 -42
- package/src/schemas/src_schemas/wait_v2.schema.json +0 -41
- package/src/schemas/src_schemas/wait_v3.schema.json +0 -36
- package/src/types/generated/checkLink_v3.ts +0 -29
- package/src/types/generated/click_v3.ts +0 -17
- package/src/types/generated/config_v3.ts +0 -405
- package/src/types/generated/context_v3.ts +0 -112
- package/src/types/generated/dragAndDrop_v3.ts +0 -39
- package/src/types/generated/endRecord_v3.ts +0 -10
- package/src/types/generated/find_v3.ts +0 -17
- package/src/types/generated/goTo_v3.ts +0 -48
- package/src/types/generated/httpRequest_v3.ts +0 -17
- package/src/types/generated/loadCookie_v3.ts +0 -17
- package/src/types/generated/loadVariables_v3.ts +0 -10
- package/src/types/generated/openApi_v3.ts +0 -64
- package/src/types/generated/record_v3.ts +0 -34
- package/src/types/generated/report_v3.ts +0 -183
- package/src/types/generated/resolvedTests_v3.ts +0 -585
- package/src/types/generated/runCode_v3.ts +0 -59
- package/src/types/generated/runShell_v3.ts +0 -58
- package/src/types/generated/saveCookie_v3.ts +0 -17
- package/src/types/generated/screenshot_v3.ts +0 -76
- package/src/types/generated/sourceIntegration_v3.ts +0 -31
- package/src/types/generated/spec_v3.ts +0 -166
- package/src/types/generated/step_v3.ts +0 -1288
- package/src/types/generated/stopRecord_v3.ts +0 -10
- package/src/types/generated/test_v3.ts +0 -3048
- package/src/types/generated/type_v3.ts +0 -56
- package/src/types/generated/wait_v3.ts +0 -13
- package/src/validate.ts +0 -627
- package/tsconfig.json +0 -22
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "typeKeys",
|
|
4
|
-
"description": "Type keys. To type special keys, begin and end the string with `$` and use the special key's keyword. For example, to type the Escape key, enter `$ESCAPE$`.",
|
|
5
|
-
"anyOf": [
|
|
6
|
-
{
|
|
7
|
-
"$ref": "#/components/schemas/keys"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"$ref": "#/components/schemas/object"
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"components": {
|
|
14
|
-
"schemas": {
|
|
15
|
-
"keys": {
|
|
16
|
-
"title": "Type keys (simple)",
|
|
17
|
-
"description": "Sequence of keys to enter.",
|
|
18
|
-
"anyOf": [
|
|
19
|
-
{
|
|
20
|
-
"type": "string"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"type": "array",
|
|
24
|
-
"items": {
|
|
25
|
-
"anyOf": [
|
|
26
|
-
{
|
|
27
|
-
"type": "string"
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
"object": {
|
|
35
|
-
"title": "Type keys (detailed)",
|
|
36
|
-
"type": "object",
|
|
37
|
-
"properties": {
|
|
38
|
-
"keys": {
|
|
39
|
-
"$ref": "#/components/schemas/keys"
|
|
40
|
-
},
|
|
41
|
-
"inputDelay": {
|
|
42
|
-
"type": "number",
|
|
43
|
-
"description": "Delay in milliseconds between each key press during a recording",
|
|
44
|
-
"default": 100
|
|
45
|
-
},
|
|
46
|
-
"selector": {
|
|
47
|
-
"type": "string",
|
|
48
|
-
"description": "Selector for the element to type into. If not specified, the typing occurs in the active element."
|
|
49
|
-
},
|
|
50
|
-
"elementText": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"description": "Display text of the element to type into. If combined with other element finding fields, the element must match all specified criteria."
|
|
53
|
-
},
|
|
54
|
-
"elementId": {
|
|
55
|
-
"type": "string",
|
|
56
|
-
"description": "ID attribute of the element to find. Supports exact match or regex pattern using /pattern/ syntax."
|
|
57
|
-
},
|
|
58
|
-
"elementTestId": {
|
|
59
|
-
"type": "string",
|
|
60
|
-
"description": "data-testid attribute of the element to find. Supports exact match or regex pattern using /pattern/ syntax."
|
|
61
|
-
},
|
|
62
|
-
"elementClass": {
|
|
63
|
-
"anyOf": [
|
|
64
|
-
{
|
|
65
|
-
"type": "string"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"type": "array",
|
|
69
|
-
"items": {
|
|
70
|
-
"type": "string"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
"description": "Class or array of classes that the element must have. Each class supports exact match or regex pattern using /pattern/ syntax. Element must have all specified classes."
|
|
75
|
-
},
|
|
76
|
-
"elementAttribute": {
|
|
77
|
-
"type": "object",
|
|
78
|
-
"description": "Object of attribute key-value pairs that the element must have. Values can be strings (supporting /pattern/ regex), numbers, or booleans. Boolean true matches attribute presence, false matches absence.",
|
|
79
|
-
"additionalProperties": {
|
|
80
|
-
"anyOf": [
|
|
81
|
-
{
|
|
82
|
-
"type": "string"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
"type": "number"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"type": "boolean"
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
"elementAria": {
|
|
94
|
-
"type": "string",
|
|
95
|
-
"description": "Computed accessible name of the element per ARIA specification. Supports exact match or regex pattern using /pattern/ syntax."
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
"required": [
|
|
99
|
-
"keys"
|
|
100
|
-
],
|
|
101
|
-
"additionalProperties": false
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
"examples": [
|
|
106
|
-
"kittens",
|
|
107
|
-
[
|
|
108
|
-
"$ENTER$"
|
|
109
|
-
],
|
|
110
|
-
[
|
|
111
|
-
"kittens",
|
|
112
|
-
"$ENTER$"
|
|
113
|
-
],
|
|
114
|
-
{
|
|
115
|
-
"keys": "kittens"
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"keys": [
|
|
119
|
-
"$ENTER$"
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"keys": [
|
|
124
|
-
"kittens",
|
|
125
|
-
"$ENTER$"
|
|
126
|
-
],
|
|
127
|
-
"inputDelay": 500
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
"$id": "/home/runner/work/doc-detective/doc-detective/src/common/src/schemas/src_schemas/type_v3.schema.json"
|
|
131
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "wait",
|
|
3
|
-
"type": "object",
|
|
4
|
-
"description": "Pause before performing the next action.",
|
|
5
|
-
"properties": {
|
|
6
|
-
"id": {
|
|
7
|
-
"type": "string",
|
|
8
|
-
"description": "ID of the step."
|
|
9
|
-
},
|
|
10
|
-
"description": {
|
|
11
|
-
"type": "string",
|
|
12
|
-
"description": "Description of the step."
|
|
13
|
-
},
|
|
14
|
-
"action": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"const": "wait",
|
|
17
|
-
"description": "The action to perform."
|
|
18
|
-
},
|
|
19
|
-
"duration": {
|
|
20
|
-
"type": "number",
|
|
21
|
-
"description": "Milliseconds to wait.",
|
|
22
|
-
"default": 5000
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"dynamicDefaults": {
|
|
26
|
-
"id": "uuid"
|
|
27
|
-
},
|
|
28
|
-
"required": [
|
|
29
|
-
"action"
|
|
30
|
-
],
|
|
31
|
-
"additionalProperties": false,
|
|
32
|
-
"examples": [
|
|
33
|
-
{
|
|
34
|
-
"action": "wait"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"action": "wait",
|
|
38
|
-
"duration": 5000
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"$id": "/home/runner/work/doc-detective/doc-detective/src/common/src/schemas/src_schemas/wait_v2.schema.json"
|
|
42
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "wait",
|
|
4
|
-
"description": "Pause (in milliseconds) before performing the next action.",
|
|
5
|
-
"default": 5000,
|
|
6
|
-
"anyOf": [
|
|
7
|
-
{
|
|
8
|
-
"type": "number",
|
|
9
|
-
"title": "Wait (simple)"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"$ref": "#/components/schemas/string"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"type": "boolean",
|
|
16
|
-
"title": "Wait (boolean)"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"components": {
|
|
20
|
-
"schemas": {
|
|
21
|
-
"string": {
|
|
22
|
-
"title": "Wait (environment variable)",
|
|
23
|
-
"type": "string",
|
|
24
|
-
"pattern": "^\\$[A-Za-z0-9_]+$",
|
|
25
|
-
"transform": [
|
|
26
|
-
"trim"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"examples": [
|
|
32
|
-
5000,
|
|
33
|
-
"$WAIT_DURATION",
|
|
34
|
-
true
|
|
35
|
-
],
|
|
36
|
-
"$id": "/home/runner/work/doc-detective/doc-detective/src/common/src/schemas/src_schemas/wait_v3.schema.json"
|
|
37
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
const parser = require("@apidevtools/json-schema-ref-parser");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
|
|
5
|
-
(async () => {
|
|
6
|
-
await dereferenceSchemas();
|
|
7
|
-
})();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Processes JSON schema files by updating reference paths, dereferencing all `$ref` pointers, and generating fully resolved schema outputs.
|
|
11
|
-
*
|
|
12
|
-
* For each schema in the input directory, this function updates reference paths, writes intermediate schemas to a build directory, dereferences all references, removes `$id` properties, and writes the final schemas to an output directory. It also creates a consolidated `schemas.json` file containing all dereferenced schemas keyed by filename.
|
|
13
|
-
*
|
|
14
|
-
* @remark The function assumes all schema files listed exist in the input directory and does not handle missing files or invalid JSON beyond throwing synchronous errors.
|
|
15
|
-
*/
|
|
16
|
-
async function dereferenceSchemas() {
|
|
17
|
-
const inputDir = path.resolve(`${__dirname}/src_schemas`);
|
|
18
|
-
const buildDir = path.resolve(`${__dirname}/build`);
|
|
19
|
-
fs.mkdirSync(buildDir, { recursive: true });
|
|
20
|
-
const outputDir = path.resolve(`${__dirname}/output_schemas`);
|
|
21
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
22
|
-
const distDir = path.resolve(__dirname, `../../dist/schemas`);
|
|
23
|
-
fs.mkdirSync(distDir, { recursive: true });
|
|
24
|
-
|
|
25
|
-
// List of schema files to process
|
|
26
|
-
// These files should be present in the input directory
|
|
27
|
-
const files = [
|
|
28
|
-
// v3 schemas
|
|
29
|
-
"checkLink_v3.schema.json",
|
|
30
|
-
"click_v3.schema.json",
|
|
31
|
-
"config_v3.schema.json",
|
|
32
|
-
"context_v3.schema.json",
|
|
33
|
-
"dragAndDrop_v3.schema.json",
|
|
34
|
-
"find_v3.schema.json",
|
|
35
|
-
"goTo_v3.schema.json",
|
|
36
|
-
"loadCookie_v3.schema.json",
|
|
37
|
-
"loadVariables_v3.schema.json",
|
|
38
|
-
"httpRequest_v3.schema.json",
|
|
39
|
-
"openApi_v3.schema.json",
|
|
40
|
-
"record_v3.schema.json",
|
|
41
|
-
"resolvedTests_v3.schema.json",
|
|
42
|
-
"report_v3.schema.json",
|
|
43
|
-
"runCode_v3.schema.json",
|
|
44
|
-
"runShell_v3.schema.json",
|
|
45
|
-
"saveCookie_v3.schema.json",
|
|
46
|
-
"screenshot_v3.schema.json",
|
|
47
|
-
"sourceIntegration_v3.schema.json",
|
|
48
|
-
"spec_v3.schema.json",
|
|
49
|
-
"step_v3.schema.json",
|
|
50
|
-
"stopRecord_v3.schema.json",
|
|
51
|
-
"test_v3.schema.json",
|
|
52
|
-
"type_v3.schema.json",
|
|
53
|
-
"wait_v3.schema.json",
|
|
54
|
-
// v2 schemas
|
|
55
|
-
"checkLink_v2.schema.json",
|
|
56
|
-
"config_v2.schema.json",
|
|
57
|
-
"context_v2.schema.json",
|
|
58
|
-
"find_v2.schema.json",
|
|
59
|
-
"goTo_v2.schema.json",
|
|
60
|
-
"httpRequest_v2.schema.json",
|
|
61
|
-
"moveTo_v2.schema.json",
|
|
62
|
-
"openApi_v2.schema.json",
|
|
63
|
-
"runShell_v2.schema.json",
|
|
64
|
-
"runCode_v2.schema.json",
|
|
65
|
-
"saveScreenshot_v2.schema.json",
|
|
66
|
-
"setVariables_v2.schema.json",
|
|
67
|
-
"startRecording_v2.schema.json",
|
|
68
|
-
"stopRecording_v2.schema.json",
|
|
69
|
-
"spec_v2.schema.json",
|
|
70
|
-
"test_v2.schema.json",
|
|
71
|
-
"typeKeys_v2.schema.json",
|
|
72
|
-
"wait_v2.schema.json",
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
// Update schema reference paths
|
|
76
|
-
console.log("Updating schema reference paths...");
|
|
77
|
-
for (const file of files) {
|
|
78
|
-
console.log(`File: ${file}`);
|
|
79
|
-
const filePath = path.resolve(`${inputDir}/${file}`);
|
|
80
|
-
const buildFilePath = path.resolve(`${buildDir}/${file}`);
|
|
81
|
-
try {
|
|
82
|
-
// Check if file exists
|
|
83
|
-
if (!fs.existsSync(filePath)) {
|
|
84
|
-
throw new Error(`File not found: ${filePath}`);
|
|
85
|
-
}
|
|
86
|
-
// Load schema
|
|
87
|
-
let schema = fs.readFileSync(filePath).toString();
|
|
88
|
-
schema = JSON.parse(schema);
|
|
89
|
-
|
|
90
|
-
// Update references to current relative path
|
|
91
|
-
schema.$id = `${filePath}`;
|
|
92
|
-
schema = updateRefPaths(schema);
|
|
93
|
-
|
|
94
|
-
// Write to build directory
|
|
95
|
-
fs.writeFileSync(buildFilePath, JSON.stringify(schema, null, 2));
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error(`Error processing ${file}:`, err);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Dereference schemas
|
|
102
|
-
console.log("Dereferencing schemas...");
|
|
103
|
-
for await (const file of files) {
|
|
104
|
-
console.log(`Processing file: ${file}`);
|
|
105
|
-
const filePath = path.resolve(`${buildDir}/${file}`);
|
|
106
|
-
const outputFilePath = path.resolve(`${outputDir}/${file}`);
|
|
107
|
-
try {
|
|
108
|
-
// Check if file exists
|
|
109
|
-
if (!fs.existsSync(filePath))
|
|
110
|
-
throw new Error(`File not found: ${filePath}`);
|
|
111
|
-
|
|
112
|
-
// Load schema
|
|
113
|
-
let schema = fs.readFileSync(filePath).toString();
|
|
114
|
-
schema = JSON.parse(schema);
|
|
115
|
-
|
|
116
|
-
// Dereference schema
|
|
117
|
-
schema = await parser.dereference(schema);
|
|
118
|
-
// Delete $id attributes
|
|
119
|
-
schema = deleteDollarIds(schema);
|
|
120
|
-
|
|
121
|
-
// Write to file
|
|
122
|
-
fs.writeFileSync(outputFilePath, JSON.stringify(schema, null, 2));
|
|
123
|
-
} catch (err) {
|
|
124
|
-
console.error(`Error processing ${file}:`, err);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// Build final schemas.json file
|
|
128
|
-
console.log("Building schemas.json file...");
|
|
129
|
-
const schemas = {};
|
|
130
|
-
for (const file of files) {
|
|
131
|
-
const key = file.replace(".schema.json", "");
|
|
132
|
-
// Load schema from file
|
|
133
|
-
const schema = require(`${outputDir}/${file}`);
|
|
134
|
-
// Load into `schema` object
|
|
135
|
-
schemas[key] = schema;
|
|
136
|
-
}
|
|
137
|
-
fs.writeFileSync(
|
|
138
|
-
`${__dirname}/schemas.json`,
|
|
139
|
-
JSON.stringify(schemas, null, 2)
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
// Clean up build dir
|
|
143
|
-
// fs.rm(buildDir, { recursive: true }, (err) => {
|
|
144
|
-
// if (err) throw err;
|
|
145
|
-
// });
|
|
146
|
-
|
|
147
|
-
// Publish v3 schemas to distribution directory
|
|
148
|
-
const publishedSchemas = files.filter(file => file.includes('_v3.schema.json'));
|
|
149
|
-
|
|
150
|
-
console.log("Publishing schemas to dist/schemas directory...");
|
|
151
|
-
publishedSchemas.forEach((file) => {
|
|
152
|
-
try {
|
|
153
|
-
console.log(`Publishing file: ${file}`);
|
|
154
|
-
const srcPath = path.resolve(`${outputDir}/${file}`);
|
|
155
|
-
const destPath = path.resolve(`${distDir}/${file}`);
|
|
156
|
-
|
|
157
|
-
// Verify source file exists before copying
|
|
158
|
-
if (!fs.existsSync(srcPath)) {
|
|
159
|
-
throw new Error(`Source file not found: ${srcPath}`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
fs.copyFileSync(srcPath, destPath);
|
|
163
|
-
} catch (err) {
|
|
164
|
-
console.error(`Error publishing ${file}:`, err);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Prepend app-root path to referenced relative paths
|
|
170
|
-
function updateRefPaths(schema) {
|
|
171
|
-
if (schema === null || typeof schema !== "object") return schema;
|
|
172
|
-
for (let [key, value] of Object.entries(schema)) {
|
|
173
|
-
if (typeof value === "object") {
|
|
174
|
-
updateRefPaths(value);
|
|
175
|
-
}
|
|
176
|
-
if (key === "$ref" && !value.startsWith("#")) {
|
|
177
|
-
// File name of the referenced schema
|
|
178
|
-
const valueFile = value.split("#")[0];
|
|
179
|
-
// Attribute path in the referenced schema
|
|
180
|
-
const valueAttribute = value.split("#")[1];
|
|
181
|
-
const valuePath = path.resolve(`${__dirname}/build/${valueFile}`);
|
|
182
|
-
schema[key] = valueAttribute !== undefined
|
|
183
|
-
? `${valuePath}#${valueAttribute}`
|
|
184
|
-
: valuePath;
|
|
185
|
-
// console.log({value, valueFile, valueAttribute, final: schema[key]})
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return schema;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Recursively removes all `$id` properties from a JSON schema object.
|
|
193
|
-
*
|
|
194
|
-
* @param {object} schema - The JSON schema object to process.
|
|
195
|
-
* @returns {object} The schema object with all `$id` properties deleted.
|
|
196
|
-
*/
|
|
197
|
-
function deleteDollarIds(schema) {
|
|
198
|
-
if (schema === null || typeof schema !== "object") return schema;
|
|
199
|
-
for (let [key, value] of Object.entries(schema)) {
|
|
200
|
-
if (typeof value === "object") {
|
|
201
|
-
deleteDollarIds(value);
|
|
202
|
-
}
|
|
203
|
-
if (key === "$id") {
|
|
204
|
-
delete schema[key];
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return schema;
|
|
208
|
-
}
|
package/src/schemas/index.ts
DELETED