doc-detective-common 1.15.1-dev.0 → 1.15.1-dev.2

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.
Files changed (52) hide show
  1. package/package.json +1 -1
  2. package/src/schemas/dereferenceSchemas.js +114 -114
  3. package/src/schemas/index.js +5 -5
  4. package/src/schemas/output_schemas/analytics_v1.schema.json +584 -584
  5. package/src/schemas/output_schemas/checkLink_v1.schema.json +41 -41
  6. package/src/schemas/output_schemas/click_v1.schema.json +59 -59
  7. package/src/schemas/output_schemas/config_v2.schema.json +1226 -1226
  8. package/src/schemas/output_schemas/find_v1.schema.json +170 -170
  9. package/src/schemas/output_schemas/goTo_v1.schema.json +29 -29
  10. package/src/schemas/output_schemas/httpRequest_v1.schema.json +114 -114
  11. package/src/schemas/output_schemas/httpRequest_v2.schema.json +189 -189
  12. package/src/schemas/output_schemas/matchText_v1.schema.json +31 -31
  13. package/src/schemas/output_schemas/moveMouse_v1.schema.json +59 -59
  14. package/src/schemas/output_schemas/runShell_v1.schema.json +34 -34
  15. package/src/schemas/output_schemas/screenshot_v1.schema.json +47 -47
  16. package/src/schemas/output_schemas/scroll_v1.schema.json +49 -49
  17. package/src/schemas/output_schemas/spec_v2.schema.json +1435 -1435
  18. package/src/schemas/output_schemas/startRecording_v1.schema.json +54 -54
  19. package/src/schemas/output_schemas/stopRecording_v1.schema.json +19 -19
  20. package/src/schemas/output_schemas/test_v2.schema.json +1177 -1177
  21. package/src/schemas/output_schemas/type_v1.schema.json +61 -61
  22. package/src/schemas/output_schemas/wait_v1.schema.json +41 -41
  23. package/src/schemas/schemas.json +4957 -4957
  24. package/src/schemas/src_schemas/analytics_v1.schema.json +584 -584
  25. package/src/schemas/src_schemas/checkLink_v1.schema.json +41 -41
  26. package/src/schemas/src_schemas/checkLink_v2.schema.json +65 -65
  27. package/src/schemas/src_schemas/click_v1.schema.json +59 -59
  28. package/src/schemas/src_schemas/context_v2.schema.json +90 -90
  29. package/src/schemas/src_schemas/find_v1.schema.json +136 -136
  30. package/src/schemas/src_schemas/find_v2.schema.json +99 -99
  31. package/src/schemas/src_schemas/goTo_v1.schema.json +29 -29
  32. package/src/schemas/src_schemas/goTo_v2.schema.json +57 -57
  33. package/src/schemas/src_schemas/httpRequest_v1.schema.json +114 -114
  34. package/src/schemas/src_schemas/matchText_v1.schema.json +31 -31
  35. package/src/schemas/src_schemas/moveMouse_v1.schema.json +59 -59
  36. package/src/schemas/src_schemas/moveTo_v2.schema.json +89 -89
  37. package/src/schemas/src_schemas/runShell_v1.schema.json +34 -34
  38. package/src/schemas/src_schemas/runShell_v2.schema.json +119 -119
  39. package/src/schemas/src_schemas/saveScreenshot_v2.schema.json +72 -72
  40. package/src/schemas/src_schemas/screenshot_v1.schema.json +47 -47
  41. package/src/schemas/src_schemas/scroll_v1.schema.json +49 -49
  42. package/src/schemas/src_schemas/setVariables_v2.schema.json +37 -37
  43. package/src/schemas/src_schemas/spec_v2.schema.json +130 -130
  44. package/src/schemas/src_schemas/startRecording_v1.schema.json +54 -54
  45. package/src/schemas/src_schemas/startRecording_v2.schema.json +54 -54
  46. package/src/schemas/src_schemas/stopRecording_v1.schema.json +19 -19
  47. package/src/schemas/src_schemas/stopRecording_v2.schema.json +31 -31
  48. package/src/schemas/src_schemas/test_v2.schema.json +159 -159
  49. package/src/schemas/src_schemas/typeKeys_v2.schema.json +63 -63
  50. package/src/schemas/src_schemas/type_v1.schema.json +61 -61
  51. package/src/schemas/src_schemas/wait_v1.schema.json +41 -41
  52. package/src/schemas/src_schemas/wait_v2.schema.json +40 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doc-detective-common",
3
- "version": "1.15.1-dev.0",
3
+ "version": "1.15.1-dev.2",
4
4
  "description": "Shared components for Doc Detective projects.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,114 +1,114 @@
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
- * Walks through all schema in src/src_schema
11
- * For each schema, dereferences it and writes it to src/schema
12
- */
13
- async function dereferenceSchemas() {
14
- const inputDir = path.resolve(`${__dirname}/src_schemas`);
15
- const buildDir = path.resolve(`${__dirname}/build`);
16
- fs.mkdir(buildDir, { recursive: true }, (err) => {
17
- if (err) throw err;
18
- });
19
- const outputDir = path.resolve(`${__dirname}/output_schemas`);
20
- var files = [
21
- "checkLink_v2.schema.json",
22
- "config_v2.schema.json",
23
- "context_v2.schema.json",
24
- "find_v2.schema.json",
25
- "goTo_v2.schema.json",
26
- "httpRequest_v2.schema.json",
27
- "moveTo_v2.schema.json",
28
- "runShell_v2.schema.json",
29
- "saveScreenshot_v2.schema.json",
30
- "setVariables_v2.schema.json",
31
- "startRecording_v2.schema.json",
32
- "stopRecording_v2.schema.json",
33
- "spec_v2.schema.json",
34
- "test_v2.schema.json",
35
- "typeKeys_v2.schema.json",
36
- "wait_v2.schema.json",
37
- ];
38
- // Update schema reference paths
39
- for (const file of files) {
40
- // console.log(`File: ${file}`)
41
- const filePath = path.resolve(`${inputDir}/${file}`);
42
- // Load from file
43
- let schema = fs.readFileSync(filePath).toString();
44
- // Convert to JSON
45
- schema = JSON.parse(schema);
46
- // Set ID
47
- schema.$id = `${filePath}`;
48
- // Update references to current relative path
49
- schema = updateRefPaths(schema);
50
- // Write to file
51
- fs.writeFileSync(`${buildDir}/${file}`, JSON.stringify(schema, null, 2));
52
- }
53
- // Dereference schemas
54
- for await (const file of files) {
55
- const filePath = path.resolve(`${buildDir}/${file}`);
56
- // Load from file
57
- let schema = fs.readFileSync(filePath).toString();
58
- // Convert to JSON
59
- schema = JSON.parse(schema);
60
- // Dereference schema
61
- schema = await parser.dereference(schema);
62
- // Delete $id attributes
63
- schema = deleteDollarIds(schema);
64
- // Write to file
65
- fs.writeFileSync(`${outputDir}/${file}`, JSON.stringify(schema, null, 2));
66
- }
67
- // Build final schemas.json file
68
- const schemas = {};
69
- files.forEach(async (file) => {
70
- const key = file.replace(".schema.json", "");
71
- // Load schema from file
72
- let schema = require(`${outputDir}/${file}`);
73
- // Load into `schema` object
74
- schemas[key] = schema;
75
- });
76
- fs.writeFileSync(`${__dirname}/schemas.json`, JSON.stringify(schemas,null,2));
77
-
78
- // Clean up build dir
79
- // fs.rm(buildDir, { recursive: true }, (err) => {
80
- // if (err) throw err;
81
- // });
82
- }
83
-
84
- // Prepend app-root path to referenced relative paths
85
- function updateRefPaths(schema) {
86
- for (let [key, value] of Object.entries(schema)) {
87
- if (typeof value === "object") {
88
- updateRefPaths(value);
89
- }
90
- if (key === "$ref" && !value.startsWith("#")) {
91
- // File name of the referenced schema
92
- valueFile = value.split("#")[0];
93
- // Attribute path in the referenced schema
94
- valueAttribute = value.split("#")[1];
95
- valuePath = path.resolve(`${__dirname}/build/${valueFile}`);
96
- schema[key] = `${valuePath}#${valueAttribute}`;
97
- // console.log({value, valueFile, valueAttribute, final: schema[key]})
98
- }
99
- }
100
- return schema;
101
- }
102
-
103
- // Prepend app-root path to referenced relative paths
104
- function deleteDollarIds(schema) {
105
- for (let [key, value] of Object.entries(schema)) {
106
- if (typeof value === "object") {
107
- deleteDollarIds(value);
108
- }
109
- if (key === "$id") {
110
- delete schema[key]
111
- }
112
- }
113
- return schema;
114
- }
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
+ * Walks through all schema in src/src_schema
11
+ * For each schema, dereferences it and writes it to src/schema
12
+ */
13
+ async function dereferenceSchemas() {
14
+ const inputDir = path.resolve(`${__dirname}/src_schemas`);
15
+ const buildDir = path.resolve(`${__dirname}/build`);
16
+ fs.mkdir(buildDir, { recursive: true }, (err) => {
17
+ if (err) throw err;
18
+ });
19
+ const outputDir = path.resolve(`${__dirname}/output_schemas`);
20
+ var files = [
21
+ "checkLink_v2.schema.json",
22
+ "config_v2.schema.json",
23
+ "context_v2.schema.json",
24
+ "find_v2.schema.json",
25
+ "goTo_v2.schema.json",
26
+ "httpRequest_v2.schema.json",
27
+ "moveTo_v2.schema.json",
28
+ "runShell_v2.schema.json",
29
+ "saveScreenshot_v2.schema.json",
30
+ "setVariables_v2.schema.json",
31
+ "startRecording_v2.schema.json",
32
+ "stopRecording_v2.schema.json",
33
+ "spec_v2.schema.json",
34
+ "test_v2.schema.json",
35
+ "typeKeys_v2.schema.json",
36
+ "wait_v2.schema.json",
37
+ ];
38
+ // Update schema reference paths
39
+ for (const file of files) {
40
+ // console.log(`File: ${file}`)
41
+ const filePath = path.resolve(`${inputDir}/${file}`);
42
+ // Load from file
43
+ let schema = fs.readFileSync(filePath).toString();
44
+ // Convert to JSON
45
+ schema = JSON.parse(schema);
46
+ // Set ID
47
+ schema.$id = `${filePath}`;
48
+ // Update references to current relative path
49
+ schema = updateRefPaths(schema);
50
+ // Write to file
51
+ fs.writeFileSync(`${buildDir}/${file}`, JSON.stringify(schema, null, 2));
52
+ }
53
+ // Dereference schemas
54
+ for await (const file of files) {
55
+ const filePath = path.resolve(`${buildDir}/${file}`);
56
+ // Load from file
57
+ let schema = fs.readFileSync(filePath).toString();
58
+ // Convert to JSON
59
+ schema = JSON.parse(schema);
60
+ // Dereference schema
61
+ schema = await parser.dereference(schema);
62
+ // Delete $id attributes
63
+ schema = deleteDollarIds(schema);
64
+ // Write to file
65
+ fs.writeFileSync(`${outputDir}/${file}`, JSON.stringify(schema, null, 2));
66
+ }
67
+ // Build final schemas.json file
68
+ const schemas = {};
69
+ files.forEach(async (file) => {
70
+ const key = file.replace(".schema.json", "");
71
+ // Load schema from file
72
+ let schema = require(`${outputDir}/${file}`);
73
+ // Load into `schema` object
74
+ schemas[key] = schema;
75
+ });
76
+ fs.writeFileSync(`${__dirname}/schemas.json`, JSON.stringify(schemas,null,2));
77
+
78
+ // Clean up build dir
79
+ // fs.rm(buildDir, { recursive: true }, (err) => {
80
+ // if (err) throw err;
81
+ // });
82
+ }
83
+
84
+ // Prepend app-root path to referenced relative paths
85
+ function updateRefPaths(schema) {
86
+ for (let [key, value] of Object.entries(schema)) {
87
+ if (typeof value === "object") {
88
+ updateRefPaths(value);
89
+ }
90
+ if (key === "$ref" && !value.startsWith("#")) {
91
+ // File name of the referenced schema
92
+ valueFile = value.split("#")[0];
93
+ // Attribute path in the referenced schema
94
+ valueAttribute = value.split("#")[1];
95
+ valuePath = path.resolve(`${__dirname}/build/${valueFile}`);
96
+ schema[key] = `${valuePath}#${valueAttribute}`;
97
+ // console.log({value, valueFile, valueAttribute, final: schema[key]})
98
+ }
99
+ }
100
+ return schema;
101
+ }
102
+
103
+ // Prepend app-root path to referenced relative paths
104
+ function deleteDollarIds(schema) {
105
+ for (let [key, value] of Object.entries(schema)) {
106
+ if (typeof value === "object") {
107
+ deleteDollarIds(value);
108
+ }
109
+ if (key === "$id") {
110
+ delete schema[key]
111
+ }
112
+ }
113
+ return schema;
114
+ }
@@ -1,6 +1,6 @@
1
- const schemas = require("./schemas.json");
2
-
3
- // Exports
4
- exports.schemas = schemas;
5
-
1
+ const schemas = require("./schemas.json");
2
+
3
+ // Exports
4
+ exports.schemas = schemas;
5
+
6
6
  // console.log(schemas);