@tenonhq/dovetail-core 0.0.130 → 0.0.132
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/README.md +38 -0
- package/dist/FileUtils.js +7 -0
- package/dist/MultiScopeWatcher.js +7 -5
- package/dist/authFailure.js +243 -0
- package/dist/bootstrap.js +4 -0
- package/dist/config.js +17 -4
- package/dist/deleteRecordCommand.js +5 -2
- package/dist/fingerprint.js +169 -0
- package/dist/index.js +4 -0
- package/dist/reconcileCommand.js +10 -0
- package/dist/snClient.js +103 -8
- package/dist/tests/authExitCode.process.test.js +81 -0
- package/dist/tests/authFailure.test.js +227 -0
- package/dist/tests/deleteRecordLocalCleanup.test.js +95 -0
- package/dist/tests/fileContextSkipReason.test.js +19 -0
- package/dist/tests/fingerprint.test.js +144 -0
- package/dist/tests/reconcileFingerprintCreate.test.js +79 -0
- package/dist/tests/resolveScopeFromPath.test.js +83 -0
- package/dist/tests/retryOnHttpErr.test.js +37 -2
- package/dist/tests/snClient.authInterceptor.test.js +250 -0
- package/dist/tests/snClient.fingerprint.test.js +83 -0
- package/package.json +3 -3
- package/release-manifest.json +617 -723
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// getManifest and getMissingFiles (bulkDownload) are the two reads every
|
|
3
|
+
// refresh/download/pull path uses, so fingerprinting is applied there once.
|
|
4
|
+
// Checks that `fingerprint` never reaches the instance and that the response
|
|
5
|
+
// comes back rewritten.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
jest.mock("../Logger", function () {
|
|
8
|
+
return {
|
|
9
|
+
logger: {
|
|
10
|
+
info: jest.fn(),
|
|
11
|
+
debug: jest.fn(),
|
|
12
|
+
warn: jest.fn(),
|
|
13
|
+
error: jest.fn(),
|
|
14
|
+
getLogLevel: function () { return "debug"; },
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
jest.mock("../FileLogger", function () {
|
|
19
|
+
return { fileLogger: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() } };
|
|
20
|
+
});
|
|
21
|
+
const snClient_1 = require("../snClient");
|
|
22
|
+
const fingerprint_1 = require("../fingerprint");
|
|
23
|
+
const BUNDLE = "!function(){}();";
|
|
24
|
+
function okResponse(result) {
|
|
25
|
+
return { status: 200, data: { result: result }, headers: {}, statusText: "OK", config: {} };
|
|
26
|
+
}
|
|
27
|
+
function makeClient(post) {
|
|
28
|
+
var c = (0, snClient_1.snClient)("https://x.service-now.com/", "u", "p");
|
|
29
|
+
c.client.post = post;
|
|
30
|
+
return c;
|
|
31
|
+
}
|
|
32
|
+
const TABLE_OPTIONS = {
|
|
33
|
+
sys_ux_lib_source_script: { fingerprint: ["script"], query: "active=true" },
|
|
34
|
+
};
|
|
35
|
+
describe("snClient fingerprint hook", function () {
|
|
36
|
+
it("getManifest strips fingerprint from the request and renames the field in the manifest", async function () {
|
|
37
|
+
var post = jest.fn().mockResolvedValue(okResponse({
|
|
38
|
+
scope: "x_cadso_ui_form",
|
|
39
|
+
tables: {
|
|
40
|
+
sys_ux_lib_source_script: {
|
|
41
|
+
records: { a: { name: "a", sys_id: "1", files: [{ name: "script", type: "js" }] } },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
var c = makeClient(post);
|
|
46
|
+
var config = { includes: {}, excludes: {}, tableOptions: TABLE_OPTIONS };
|
|
47
|
+
var resp = await c.getManifest("x_cadso_ui_form", config);
|
|
48
|
+
var body = post.mock.calls[0][1];
|
|
49
|
+
expect(body.tableOptions).toEqual({ sys_ux_lib_source_script: { query: "active=true" } });
|
|
50
|
+
expect(JSON.stringify(body)).not.toContain("fingerprint");
|
|
51
|
+
expect(resp.data.result.tables.sys_ux_lib_source_script.records.a.files[0]).toEqual({
|
|
52
|
+
name: "script",
|
|
53
|
+
type: "sha256",
|
|
54
|
+
});
|
|
55
|
+
// The caller's config is not mutated.
|
|
56
|
+
expect(TABLE_OPTIONS.sys_ux_lib_source_script.fingerprint).toEqual(["script"]);
|
|
57
|
+
});
|
|
58
|
+
it("getMissingFiles strips fingerprint from the request and hashes the downloaded content", async function () {
|
|
59
|
+
var post = jest.fn().mockResolvedValue(okResponse({
|
|
60
|
+
sys_ux_lib_source_script: {
|
|
61
|
+
records: {
|
|
62
|
+
a: { name: "a", sys_id: "1", files: [{ name: "script", type: "sha256", content: BUNDLE }] },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
}));
|
|
66
|
+
var c = makeClient(post);
|
|
67
|
+
var resp = await c.getMissingFiles({ sys_ux_lib_source_script: { "1": [{ name: "script", type: "sha256" }] } }, TABLE_OPTIONS);
|
|
68
|
+
var body = post.mock.calls[0][1];
|
|
69
|
+
expect(JSON.stringify(body.tableOptions)).not.toContain("fingerprint");
|
|
70
|
+
expect(resp.data.result.sys_ux_lib_source_script.records.a.files[0].content).toBe((0, fingerprint_1.formatFingerprint)(BUNDLE));
|
|
71
|
+
});
|
|
72
|
+
it("passes responses through untouched when nothing is fingerprinted", async function () {
|
|
73
|
+
var result = {
|
|
74
|
+
sys_script_include: {
|
|
75
|
+
records: { a: { name: "a", sys_id: "1", files: [{ name: "script", type: "js", content: "x" }] } },
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
var post = jest.fn().mockResolvedValue(okResponse(result));
|
|
79
|
+
var c = makeClient(post);
|
|
80
|
+
var resp = await c.getMissingFiles({ sys_script_include: { "1": [{ name: "script", type: "js" }] } }, {});
|
|
81
|
+
expect(resp.data.result).toEqual(result);
|
|
82
|
+
});
|
|
83
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenonhq/dovetail-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.132",
|
|
4
4
|
"description": "Next-gen file syncer",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=22"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@tenonhq/dovetail-types": "~0.0.
|
|
25
|
+
"@tenonhq/dovetail-types": "~0.0.24",
|
|
26
26
|
"@types/dotenv": "^6.1.1",
|
|
27
27
|
"@types/inquirer": "^8.2.10",
|
|
28
28
|
"@types/jest": "^29.5.5",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@tenonhq/dovetail-clickup": "~0.0.15",
|
|
42
|
-
"@tenonhq/dovetail-schema": "~0.0.
|
|
42
|
+
"@tenonhq/dovetail-schema": "~0.0.17",
|
|
43
43
|
"axios": "^1.20.0",
|
|
44
44
|
"axios-cookiejar-support": "^4.0.7",
|
|
45
45
|
"axios-rate-limit": "^1.3.0",
|