doc-detective-common 1.1.0 → 1.2.3
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/.devcontainer/devcontainer.json +25 -0
- package/package.json +9 -3
- package/src/schema.js +41 -14
- package/src/schemas/checkLink_v2.schema.json +54 -0
- package/src/schemas/config_v2.schema.json +544 -0
- package/src/schemas/context_v2.schema.json +55 -0
- package/src/schemas/find_v1.schema.json +13 -47
- package/src/schemas/find_v2.schema.json +78 -0
- package/src/schemas/goTo_v2.schema.json +46 -0
- package/src/schemas/httpRequest_v1.schema.json +5 -1
- package/src/schemas/httpRequest_v2.schema.json +168 -0
- package/src/schemas/runShell_v2.schema.json +54 -0
- package/src/schemas/saveScreenshot_v2.schema.json +41 -0
- package/src/schemas/setVariables_v2.schema.json +38 -0
- package/src/schemas/spec_v2.schema.json +125 -0
- package/src/schemas/startRecording_v2.schema.json +47 -0
- package/src/schemas/test_v2.schema.json +138 -0
- package/src/schemas/typeKeys_v2.schema.json +50 -0
- package/src/schemas/wait_v2.schema.json +41 -0
- package/src/validate.js +24 -4
- package/test/schema.test.js +6 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
|
|
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
|
+
}
|
|
10
|
+
|
|
11
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
12
|
+
// "features": {},
|
|
13
|
+
|
|
14
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
15
|
+
// "forwardPorts": [],
|
|
16
|
+
|
|
17
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
|
18
|
+
// "postCreateCommand": "uname -a",
|
|
19
|
+
|
|
20
|
+
// Configure tool-specific properties.
|
|
21
|
+
// "customizations": {},
|
|
22
|
+
|
|
23
|
+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
|
24
|
+
// "remoteUser": "root"
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doc-detective-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Shared components for Doc Detective projects.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest"
|
|
8
8
|
},
|
|
9
|
+
"precommit": "test",
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "git+https://github.com/doc-detective/doc-detective-common.git"
|
|
@@ -20,7 +21,12 @@
|
|
|
20
21
|
"jest": "^29.4.1"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"ajv": "^8.12.0"
|
|
24
|
+
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
25
|
+
"ajv": "^8.12.0",
|
|
26
|
+
"ajv-errors": "^3.0.0",
|
|
27
|
+
"ajv-formats": "^2.1.1",
|
|
28
|
+
"ajv-keywords": "^5.1.0",
|
|
29
|
+
"pre-commit": "^1.2.2",
|
|
30
|
+
"uuid": "^9.0.0"
|
|
25
31
|
}
|
|
26
32
|
}
|
package/src/schema.js
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
|
-
const approot = require("app-root-path")
|
|
2
1
|
const fs = require("fs");
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
//// Init
|
|
4
|
+
const schemas = {};
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
//// Process
|
|
7
|
+
loadSchemas();
|
|
8
|
+
// console.log(schemas.find_v1)
|
|
9
|
+
//// Export
|
|
10
|
+
exports.schemas = schemas;
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
files.forEach(file => {
|
|
11
|
-
// Exit early for files that don't match naming pattern
|
|
12
|
-
if (!file.includes(".schema.json")) return;
|
|
13
|
-
key = file.replace(".schema.json","");
|
|
14
|
-
path = `./schemas/${file}`;
|
|
15
|
-
// Load into `schema` object
|
|
16
|
-
schemas[key] = require(path);
|
|
17
|
-
})
|
|
12
|
+
//// Functions
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
// Load schemas from file
|
|
15
|
+
function loadSchemas() {
|
|
16
|
+
// Read files from schema directory
|
|
17
|
+
path = `${__dirname}/schemas`;
|
|
18
|
+
var files = fs.readdirSync(path);
|
|
19
|
+
// Loop through all schema files
|
|
20
|
+
files.forEach(async (file) => {
|
|
21
|
+
// Exit early for files that don't match naming pattern
|
|
22
|
+
if (!file.includes(".schema.json")) return;
|
|
23
|
+
const key = file.replace(".schema.json", "");
|
|
24
|
+
// Load schema from file
|
|
25
|
+
let schema = require(`./schemas/${file}`);
|
|
26
|
+
// Add dynamic ID based on file path
|
|
27
|
+
schema.$id = `file://${__dirname}/schemas/${file}`;
|
|
28
|
+
// Recursively update relative references with app root path
|
|
29
|
+
schema = updateRefPaths(schema);
|
|
30
|
+
// Load into `schema` object
|
|
31
|
+
schemas[key] = schema;
|
|
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] = `file://${__dirname}/schemas/${value}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return schema;
|
|
46
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "checkLink",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"description": "Check if a URL returns an acceptable status code from a GET request.",
|
|
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": "checkLink",
|
|
17
|
+
"description": "Action to perform."
|
|
18
|
+
},
|
|
19
|
+
"url": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"format": "uri",
|
|
22
|
+
"description": "URL to check.",
|
|
23
|
+
"pattern": "^(http://|https://).*",
|
|
24
|
+
"transform": ["trim"]
|
|
25
|
+
},
|
|
26
|
+
"statusCodes": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"items": {
|
|
29
|
+
"oneOf": [
|
|
30
|
+
{
|
|
31
|
+
"type": "integer"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"default": [200]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"dynamicDefaults": {
|
|
39
|
+
"id": "uuid"
|
|
40
|
+
},
|
|
41
|
+
"required": ["action", "url"],
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"examples": [
|
|
44
|
+
{
|
|
45
|
+
"action": "checkLink",
|
|
46
|
+
"url": "https://www.google.com"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"action": "checkLink",
|
|
50
|
+
"url": "https://www.google.com",
|
|
51
|
+
"statusCodes": [200]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|