doc-detective-common 1.2.6 → 1.2.8

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 (68) hide show
  1. package/.devcontainer/devcontainer.json +28 -16
  2. package/dev/dev.js +3 -0
  3. package/package.json +4 -4
  4. package/src/index.js +5 -0
  5. package/src/schemas/dereferenceSchemas.js +46 -0
  6. package/src/schemas/index.js +22 -0
  7. package/src/schemas/output_schemas/analytics_v1.schema.json +586 -0
  8. package/src/schemas/output_schemas/checkLink_v1.schema.json +43 -0
  9. package/src/schemas/output_schemas/checkLink_v2.schema.json +65 -0
  10. package/src/schemas/output_schemas/click_v1.schema.json +61 -0
  11. package/src/schemas/output_schemas/config_v2.schema.json +780 -0
  12. package/src/schemas/output_schemas/context_v2.schema.json +76 -0
  13. package/src/schemas/output_schemas/find_v1.schema.json +172 -0
  14. package/src/schemas/output_schemas/find_v2.schema.json +97 -0
  15. package/src/schemas/output_schemas/goTo_v1.schema.json +31 -0
  16. package/src/schemas/output_schemas/goTo_v2.schema.json +49 -0
  17. package/src/schemas/output_schemas/httpRequest_v1.schema.json +116 -0
  18. package/src/schemas/output_schemas/httpRequest_v2.schema.json +192 -0
  19. package/src/schemas/output_schemas/matchText_v1.schema.json +33 -0
  20. package/src/schemas/output_schemas/moveMouse_v1.schema.json +61 -0
  21. package/src/schemas/output_schemas/runShell_v1.schema.json +36 -0
  22. package/src/schemas/output_schemas/runShell_v2.schema.json +63 -0
  23. package/src/schemas/output_schemas/saveScreenshot_v2.schema.json +42 -0
  24. package/src/schemas/output_schemas/screenshot_v1.schema.json +49 -0
  25. package/src/schemas/output_schemas/scroll_v1.schema.json +51 -0
  26. package/src/schemas/output_schemas/setVariables_v2.schema.json +39 -0
  27. package/src/schemas/output_schemas/spec_v2.schema.json +1078 -0
  28. package/src/schemas/output_schemas/startRecording_v1.schema.json +56 -0
  29. package/src/schemas/output_schemas/startRecording_v2.schema.json +48 -0
  30. package/src/schemas/output_schemas/stopRecording_v1.schema.json +21 -0
  31. package/src/schemas/output_schemas/test_v2.schema.json +859 -0
  32. package/src/schemas/output_schemas/typeKeys_v2.schema.json +56 -0
  33. package/src/schemas/output_schemas/type_v1.schema.json +63 -0
  34. package/src/schemas/output_schemas/wait_v1.schema.json +43 -0
  35. package/src/schemas/output_schemas/wait_v2.schema.json +42 -0
  36. package/src/validate.js +1 -1
  37. package/test/schema.test.js +1 -2
  38. package/index.js +0 -5
  39. package/src/schema.js +0 -46
  40. /package/src/schemas/{analytics_v1.schema.json → src_schemas/analytics_v1.schema.json} +0 -0
  41. /package/src/schemas/{checkLink_v1.schema.json → src_schemas/checkLink_v1.schema.json} +0 -0
  42. /package/src/schemas/{checkLink_v2.schema.json → src_schemas/checkLink_v2.schema.json} +0 -0
  43. /package/src/schemas/{click_v1.schema.json → src_schemas/click_v1.schema.json} +0 -0
  44. /package/src/schemas/{config_v2.schema.json → src_schemas/config_v2.schema.json} +0 -0
  45. /package/src/schemas/{context_v2.schema.json → src_schemas/context_v2.schema.json} +0 -0
  46. /package/src/schemas/{find_v1.schema.json → src_schemas/find_v1.schema.json} +0 -0
  47. /package/src/schemas/{find_v2.schema.json → src_schemas/find_v2.schema.json} +0 -0
  48. /package/src/schemas/{goTo_v1.schema.json → src_schemas/goTo_v1.schema.json} +0 -0
  49. /package/src/schemas/{goTo_v2.schema.json → src_schemas/goTo_v2.schema.json} +0 -0
  50. /package/src/schemas/{httpRequest_v1.schema.json → src_schemas/httpRequest_v1.schema.json} +0 -0
  51. /package/src/schemas/{httpRequest_v2.schema.json → src_schemas/httpRequest_v2.schema.json} +0 -0
  52. /package/src/schemas/{matchText_v1.schema.json → src_schemas/matchText_v1.schema.json} +0 -0
  53. /package/src/schemas/{moveMouse_v1.schema.json → src_schemas/moveMouse_v1.schema.json} +0 -0
  54. /package/src/schemas/{runShell_v1.schema.json → src_schemas/runShell_v1.schema.json} +0 -0
  55. /package/src/schemas/{runShell_v2.schema.json → src_schemas/runShell_v2.schema.json} +0 -0
  56. /package/src/schemas/{saveScreenshot_v2.schema.json → src_schemas/saveScreenshot_v2.schema.json} +0 -0
  57. /package/src/schemas/{screenshot_v1.schema.json → src_schemas/screenshot_v1.schema.json} +0 -0
  58. /package/src/schemas/{scroll_v1.schema.json → src_schemas/scroll_v1.schema.json} +0 -0
  59. /package/src/schemas/{setVariables_v2.schema.json → src_schemas/setVariables_v2.schema.json} +0 -0
  60. /package/src/schemas/{spec_v2.schema.json → src_schemas/spec_v2.schema.json} +0 -0
  61. /package/src/schemas/{startRecording_v1.schema.json → src_schemas/startRecording_v1.schema.json} +0 -0
  62. /package/src/schemas/{startRecording_v2.schema.json → src_schemas/startRecording_v2.schema.json} +0 -0
  63. /package/src/schemas/{stopRecording_v1.schema.json → src_schemas/stopRecording_v1.schema.json} +0 -0
  64. /package/src/schemas/{test_v2.schema.json → src_schemas/test_v2.schema.json} +0 -0
  65. /package/src/schemas/{typeKeys_v2.schema.json → src_schemas/typeKeys_v2.schema.json} +0 -0
  66. /package/src/schemas/{type_v1.schema.json → src_schemas/type_v1.schema.json} +0 -0
  67. /package/src/schemas/{wait_v1.schema.json → src_schemas/wait_v1.schema.json} +0 -0
  68. /package/src/schemas/{wait_v2.schema.json → src_schemas/wait_v2.schema.json} +0 -0
@@ -1,25 +1,37 @@
1
1
  // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
2
  // README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
3
3
  {
4
- "name": "Ubuntu",
5
- // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
- "image": "mcr.microsoft.com/devcontainers/base:jammy",
7
- "features": {
8
- "ghcr.io/devcontainers/features/node:1": {}
9
- }
4
+ "name": "Ubuntu",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "image": "mcr.microsoft.com/devcontainers/base:jammy",
7
+ "features": {
8
+ "ghcr.io/devcontainers/features/node:1": {}
9
+ },
10
10
 
11
- // Features to add to the dev container. More info: https://containers.dev/features.
12
- // "features": {},
11
+ // Features to add to the dev container. More info: https://containers.dev/features.
12
+ // "features": {},
13
13
 
14
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
15
- // "forwardPorts": [],
14
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
15
+ // "forwardPorts": [],
16
16
 
17
- // Use 'postCreateCommand' to run commands after the container is created.
18
- // "postCreateCommand": "uname -a",
17
+ // Use 'postCreateCommand' to run commands after the container is created.
18
+ "postCreateCommand": "npm i",
19
19
 
20
- // Configure tool-specific properties.
21
- // "customizations": {},
20
+ // Configure tool-specific properties.
21
+ "customizations": {
22
+ // Configure properties specific to VS Code.
23
+ "vscode": {
24
+ // Add the IDs of extensions you want installed when the container is created.
25
+ "extensions": [
26
+ "github.copilot",
27
+ "aaron-bond.better-comments",
28
+ "esbenp.prettier-vscode",
29
+ "GitHub.vscode-pull-request-github",
30
+ "streetsidesoftware.code-spell-checker"
31
+ ]
32
+ }
33
+ }
22
34
 
23
- // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
24
- // "remoteUser": "root"
35
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
36
+ // "remoteUser": "root"
25
37
  }
package/dev/dev.js ADDED
@@ -0,0 +1,3 @@
1
+ const { validate, schemas } = require("../src/index");
2
+
3
+ console.log(validate("find_v2",schemas.find_v2.examples[0]))
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "doc-detective-common",
3
- "version": "1.2.6",
4
-
3
+ "version": "1.2.8",
5
4
  "description": "Shared components for Doc Detective projects.",
6
- "main": "index.js",
5
+ "main": "src/index.js",
7
6
  "scripts": {
8
- "test": "jest"
7
+ "dereferenceSchemas": "node ./src/schemas/dereferenceSchemas.js",
8
+ "test": "npm run dereferenceSchemas && jest"
9
9
  },
10
10
  "precommit": "test",
11
11
  "repository": {
package/src/index.js ADDED
@@ -0,0 +1,5 @@
1
+ const { schemas } = require("./schemas");
2
+ const { validate } = require("./validate");
3
+
4
+ exports.schemas = schemas;
5
+ exports.validate = validate;
@@ -0,0 +1,46 @@
1
+ const parser = require("@apidevtools/json-schema-ref-parser");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+ const { exit } = require("process");
5
+
6
+ (async () => {
7
+ await dereferenceSchemas();
8
+ })();
9
+
10
+ /*
11
+ * Walks through all schema in src/src_schema
12
+ * For each schema, dereferences it and writes it to src/schema
13
+ */
14
+ async function dereferenceSchemas() {
15
+ const inputDir = path.resolve(`${__dirname}/src_schemas`);
16
+ const outputDir = path.resolve(`${__dirname}/output_schemas`);
17
+ const files = fs.readdirSync(inputDir);
18
+ for await (const file of files) {
19
+ const filePath = path.resolve(`${inputDir}/${file}`);
20
+ // Load from file
21
+ let schema = fs.readFileSync(filePath).toString();
22
+ // Convert to JSON
23
+ schema = JSON.parse(schema);
24
+ // Set ID
25
+ schema.$id = `${filePath}`;
26
+ // Update references to current relative path
27
+ schema = updateRefPaths(schema, inputDir);
28
+ // Dereference schema
29
+ schema = await parser.dereference(schema);
30
+ // Write to file
31
+ fs.writeFileSync(`${outputDir}/${file}`, JSON.stringify(schema, null, 2));
32
+ }
33
+ }
34
+
35
+ // Prepend app-root path to referenced relative paths
36
+ function updateRefPaths(schema) {
37
+ for (let [key, value] of Object.entries(schema)) {
38
+ if (typeof value === "object") {
39
+ updateRefPaths(value);
40
+ }
41
+ if (key === "$ref") {
42
+ schema[key] = path.resolve(`${__dirname}/src_schemas/${value}`);
43
+ }
44
+ }
45
+ return schema;
46
+ }
@@ -0,0 +1,22 @@
1
+ const fs = require("fs");
2
+
3
+ exports.schemas = loadSchemas();
4
+
5
+ // Load schemas from file
6
+ function loadSchemas() {
7
+ const schemas = {};
8
+ // Read files from schema directory
9
+ path = `${__dirname}/output_schemas`;
10
+ var files = fs.readdirSync(path);
11
+ // Loop through all schema files
12
+ files.forEach(async (file) => {
13
+ // Exit early for files that don't match naming pattern
14
+ if (!file.includes(".schema.json")) return;
15
+ const key = file.replace(".schema.json", "");
16
+ // Load schema from file
17
+ let schema = require(`./output_schemas/${file}`);
18
+ // Load into `schema` object
19
+ schemas[key] = schema;
20
+ });
21
+ return schemas;
22
+ }