@tenonhq/dovetail-core 0.0.134 → 0.0.135

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.
@@ -4,6 +4,15 @@
4
4
  // records live under their scope's folder (src/Core/..., or nested as
5
5
  // src/UIComponents/<scope>/...), so the cleanup silently found nothing. It now
6
6
  // uses the scope's own folder.
7
+ //
8
+ // The folder is the record's manifest key, found by sys_id. It used to be built
9
+ // from the instance's display name, which (a) is another record's folder when a
10
+ // local namesake exists and the deleted record was never refreshed, (b) is not
11
+ // the folder of any record the naming rule suffixed, and (c) is the scope
12
+ // folder itself for a display name of "..".
13
+ //
14
+ // Every assertion is on the real filesystem in a temp dir: the folders and the
15
+ // scope manifest file are real, only the instance call is stubbed.
7
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
18
  };
@@ -29,19 +38,39 @@ jest.mock("../commands", function () {
29
38
  var mockRoot = "";
30
39
  jest.mock("../config", function () {
31
40
  var p = jest.requireActual("path");
41
+ var realFs = jest.requireActual("fs");
42
+ var manifestPath = function (scope) {
43
+ return p.join(mockRoot, "dove.manifest." + scope + ".json");
44
+ };
32
45
  return {
33
46
  getSourcePath: function () { return p.join(mockRoot, "src"); },
34
47
  getSourcePathForScope: function (scope) {
35
48
  return p.join(mockRoot, "src", "UIComponents", scope);
36
49
  },
37
- loadScopeManifest: jest.fn().mockResolvedValue(undefined),
50
+ getScopeManifestPath: manifestPath,
51
+ loadScopeManifest: function (scope) {
52
+ try {
53
+ return Promise.resolve(JSON.parse(realFs.readFileSync(manifestPath(scope), "utf8")));
54
+ }
55
+ catch (e) {
56
+ return Promise.resolve(undefined);
57
+ }
58
+ },
38
59
  getManifest: function () { return undefined; },
60
+ resolveManifestForScope: function () { return undefined; },
39
61
  getConfig: function () { return { scopes: {} }; },
40
62
  isMultiScopeManifest: function () { return false; },
41
63
  };
42
64
  });
43
65
  jest.mock("../FileUtils", function () {
44
- return { writeScopeManifest: jest.fn().mockResolvedValue(undefined) };
66
+ var p = jest.requireActual("path");
67
+ var realFs = jest.requireActual("fs");
68
+ return {
69
+ writeScopeManifest: function (scope, man) {
70
+ realFs.writeFileSync(p.join(mockRoot, "dove.manifest." + scope + ".json"), JSON.stringify(man, null, 2));
71
+ return Promise.resolve();
72
+ },
73
+ };
45
74
  });
46
75
  var mockDelete = jest.fn();
47
76
  jest.mock("../snClient", function () {
@@ -54,42 +83,142 @@ jest.mock("../snClient", function () {
54
83
  const fs_1 = __importDefault(require("fs"));
55
84
  const os_1 = __importDefault(require("os"));
56
85
  const path_1 = __importDefault(require("path"));
86
+ const Logger_1 = require("../Logger");
57
87
  const deleteRecordCommand_1 = require("../deleteRecordCommand");
88
+ var SCOPE = "x_cadso_ui_panel";
89
+ var TABLE = "sys_ux_lib_component";
90
+ var SYS_A = "aaaaaaaa1111111111111111111111a1";
91
+ var SYS_B = "bbbbbbbb2222222222222222222222b2";
92
+ function scopeDir() {
93
+ return path_1.default.join(mockRoot, "src", "UIComponents", SCOPE);
94
+ }
95
+ function recordDir(folder) {
96
+ return path_1.default.join(scopeDir(), TABLE, folder);
97
+ }
98
+ function makeRecordFolder(folder) {
99
+ var dir = recordDir(folder);
100
+ fs_1.default.mkdirSync(dir, { recursive: true });
101
+ fs_1.default.writeFileSync(path_1.default.join(dir, "metaData.json"), "{}");
102
+ return dir;
103
+ }
104
+ function writeManifest(records) {
105
+ var entries = {};
106
+ var keys = Object.keys(records);
107
+ for (var i = 0; i < keys.length; i++) {
108
+ entries[keys[i]] = { name: keys[i], sys_id: records[keys[i]], files: [{ name: "metaData", type: "json" }] };
109
+ }
110
+ var manifest = { scope: SCOPE, tables: {} };
111
+ manifest.tables[TABLE] = { records: entries };
112
+ fs_1.default.writeFileSync(path_1.default.join(mockRoot, "dove.manifest." + SCOPE + ".json"), JSON.stringify(manifest, null, 2));
113
+ }
114
+ function manifestKeys() {
115
+ var man = JSON.parse(fs_1.default.readFileSync(path_1.default.join(mockRoot, "dove.manifest." + SCOPE + ".json"), "utf8"));
116
+ if (!man.tables[TABLE])
117
+ return [];
118
+ return Object.keys(man.tables[TABLE].records).sort();
119
+ }
120
+ function warnings() {
121
+ return Logger_1.logger.warn.mock.calls
122
+ .map(function (c) { return String(c[0]); })
123
+ .join("\n");
124
+ }
125
+ function instanceNames(displayName) {
126
+ mockDelete.mockResolvedValue({ data: { result: { name: displayName } } });
127
+ }
58
128
  describe("deleteRecordCommand local cleanup", function () {
59
129
  beforeEach(function () {
60
130
  mockRoot = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "dove-delete-"));
61
131
  mockDelete.mockReset();
62
- mockDelete.mockResolvedValue({ data: { result: { name: "Panel" } } });
132
+ Logger_1.logger.warn.mockClear();
133
+ instanceNames("Panel");
63
134
  });
64
135
  afterEach(function () {
65
136
  fs_1.default.rmSync(mockRoot, { recursive: true, force: true });
66
137
  });
67
138
  it("removes the record folder under the scope's own folder", async function () {
68
- var recordDir = path_1.default.join(mockRoot, "src", "UIComponents", "x_cadso_ui_panel", "sys_ux_lib_component", "Panel");
69
- fs_1.default.mkdirSync(recordDir, { recursive: true });
70
- fs_1.default.writeFileSync(path_1.default.join(recordDir, "metaData.json"), "{}");
71
- await (0, deleteRecordCommand_1.deleteRecordCommand)({
72
- table: "sys_ux_lib_component",
73
- name: "Panel",
74
- scope: "x_cadso_ui_panel",
75
- sysid: "abc",
76
- ci: true,
77
- logLevel: "info",
78
- });
139
+ var dir = makeRecordFolder("Panel");
140
+ writeManifest({ Panel: SYS_A });
141
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, name: "Panel", scope: SCOPE, sysid: SYS_A, ci: true, logLevel: "info" });
79
142
  expect(mockDelete).toHaveBeenCalledTimes(1);
80
- expect(fs_1.default.existsSync(recordDir)).toBe(false);
143
+ expect(fs_1.default.existsSync(dir)).toBe(false);
144
+ expect(manifestKeys()).toEqual([]);
81
145
  });
82
146
  it("leaves a same-named folder under the top-level source path alone", async function () {
83
- var wrongDir = path_1.default.join(mockRoot, "src", "sys_ux_lib_component", "Panel");
147
+ var wrongDir = path_1.default.join(mockRoot, "src", TABLE, "Panel");
84
148
  fs_1.default.mkdirSync(wrongDir, { recursive: true });
85
- await (0, deleteRecordCommand_1.deleteRecordCommand)({
86
- table: "sys_ux_lib_component",
87
- name: "Panel",
88
- scope: "x_cadso_ui_panel",
89
- sysid: "abc",
90
- ci: true,
91
- logLevel: "info",
92
- });
149
+ writeManifest({ Panel: SYS_A });
150
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, name: "Panel", scope: SCOPE, sysid: SYS_A, ci: true, logLevel: "info" });
93
151
  expect(fs_1.default.existsSync(wrongDir)).toBe(true);
94
152
  });
153
+ it("--sysid only: never touches a local namesake when the deleted record was never refreshed", async function () {
154
+ // Local record A is "Foo". B, also "Foo" on the instance, was created there
155
+ // and never refreshed, so the manifest does not know B.
156
+ var aDir = makeRecordFolder("Foo");
157
+ fs_1.default.writeFileSync(path_1.default.join(aDir, "script.js"), "// uncommitted edit");
158
+ writeManifest({ Foo: SYS_A });
159
+ instanceNames("Foo");
160
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, scope: SCOPE, sysid: SYS_B, ci: true, logLevel: "info" });
161
+ expect(mockDelete).toHaveBeenCalledTimes(1);
162
+ expect(fs_1.default.readFileSync(path_1.default.join(aDir, "script.js"), "utf8")).toBe("// uncommitted edit");
163
+ expect(manifestKeys()).toEqual(["Foo"]);
164
+ expect(warnings()).toContain("is not in the " + SCOPE + " manifest");
165
+ });
166
+ it("--sysid only: removes the suffixed folder the manifest gave the record, and only that one", async function () {
167
+ // Namesakes get " (first 8 of sys_id)" (folderNaming.ts). The display name
168
+ // "Foo" is neither record's folder.
169
+ var aDir = makeRecordFolder("Foo (aaaaaaaa)");
170
+ var bDir = makeRecordFolder("Foo (bbbbbbbb)");
171
+ writeManifest({ "Foo (aaaaaaaa)": SYS_A, "Foo (bbbbbbbb)": SYS_B });
172
+ instanceNames("Foo");
173
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, scope: SCOPE, sysid: SYS_B, ci: true, logLevel: "info" });
174
+ expect(fs_1.default.existsSync(bDir)).toBe(false);
175
+ expect(fs_1.default.existsSync(aDir)).toBe(true);
176
+ expect(manifestKeys()).toEqual(["Foo (aaaaaaaa)"]);
177
+ });
178
+ it("with a name and --sysid that disagree, the sys_id decides which folder goes", async function () {
179
+ var aDir = makeRecordFolder("Panel");
180
+ var bDir = makeRecordFolder("Panel (bbbbbbbb)");
181
+ writeManifest({ Panel: SYS_A, "Panel (bbbbbbbb)": SYS_B });
182
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, name: "Panel", scope: SCOPE, sysid: SYS_B, ci: true, logLevel: "info" });
183
+ expect(fs_1.default.existsSync(aDir)).toBe(true);
184
+ expect(fs_1.default.existsSync(bDir)).toBe(false);
185
+ expect(manifestKeys()).toEqual(["Panel"]);
186
+ });
187
+ it("--sysid only: a display name of '..' cannot point the delete at the scope folder", async function () {
188
+ // ".." is no safe folder name, so the manifest names the record by sys_id.
189
+ var otherDir = makeRecordFolder("Other");
190
+ var ownDir = makeRecordFolder(SYS_B);
191
+ var records = { Other: SYS_A };
192
+ records[SYS_B] = SYS_B;
193
+ writeManifest(records);
194
+ instanceNames("..");
195
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, scope: SCOPE, sysid: SYS_B, ci: true, logLevel: "info" });
196
+ expect(fs_1.default.existsSync(scopeDir())).toBe(true);
197
+ expect(fs_1.default.existsSync(otherDir)).toBe(true);
198
+ expect(fs_1.default.existsSync(ownDir)).toBe(false);
199
+ expect(manifestKeys()).toEqual(["Other"]);
200
+ });
201
+ it("refuses a manifest key that is not a direct child of <scope dir>/<table>", async function () {
202
+ // A hand-edited manifest: the key ".." would resolve to the scope folder.
203
+ var otherDir = makeRecordFolder("Other");
204
+ writeManifest({ Other: SYS_A, "..": SYS_B });
205
+ instanceNames("..");
206
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, scope: SCOPE, sysid: SYS_B, ci: true, logLevel: "info" });
207
+ expect(fs_1.default.existsSync(path_1.default.join(scopeDir(), TABLE))).toBe(true);
208
+ expect(fs_1.default.existsSync(otherDir)).toBe(true);
209
+ expect(warnings()).toContain("Not removing '..'");
210
+ });
211
+ it("leaves local files alone when the scope has no manifest at all", async function () {
212
+ var dir = makeRecordFolder("Panel");
213
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, name: "Panel", scope: SCOPE, sysid: SYS_A, ci: true, logLevel: "info" });
214
+ expect(fs_1.default.existsSync(dir)).toBe(true);
215
+ expect(warnings()).toContain("no local folder was removed");
216
+ });
217
+ it("--keep-local leaves the folder and the manifest as they are", async function () {
218
+ var dir = makeRecordFolder("Panel");
219
+ writeManifest({ Panel: SYS_A });
220
+ await (0, deleteRecordCommand_1.deleteRecordCommand)({ table: TABLE, scope: SCOPE, sysid: SYS_A, ci: true, keepLocal: true, logLevel: "info" });
221
+ expect(fs_1.default.existsSync(dir)).toBe(true);
222
+ expect(manifestKeys()).toEqual(["Panel"]);
223
+ });
95
224
  });
@@ -126,6 +126,47 @@ describe("getFileContextWithSkipReason", function () {
126
126
  expect(result.context).toBeUndefined();
127
127
  expect(result.skipReason).toBe("fingerprint only, read-only");
128
128
  });
129
+ it("refuses a content file whose field the manifest lists as a fingerprint", function () {
130
+ // script.js left from before `fingerprint` was set: refresh never deletes
131
+ // it, and the manifest field `script` matches it by name.
132
+ mockManifest = {
133
+ scope: "x_cadso_ui_form",
134
+ tables: {
135
+ sys_ux_lib_source_script: {
136
+ records: {
137
+ Bundle: {
138
+ sys_id: "f9cd",
139
+ files: [{ name: "script", type: "sha256" }, { name: "metaData", type: "json" }],
140
+ },
141
+ },
142
+ },
143
+ },
144
+ };
145
+ mockIsMultiScope = false;
146
+ var result = (0, FileUtils_1.getFileContextWithSkipReason)("/project/src/UIComponents/x_cadso_ui_form/sys_ux_lib_source_script/Bundle/script.js");
147
+ expect(result.context).toBeUndefined();
148
+ expect(result.skipReason).toBe("fingerprinted field, read-only");
149
+ });
150
+ it("still pushes the other fields of a record that has a fingerprinted field", function () {
151
+ mockManifest = {
152
+ scope: "x_cadso_ui_form",
153
+ tables: {
154
+ sys_ux_lib_source_script: {
155
+ records: {
156
+ Bundle: {
157
+ sys_id: "f9cd",
158
+ files: [{ name: "script", type: "sha256" }, { name: "source_map", type: "js" }],
159
+ },
160
+ },
161
+ },
162
+ },
163
+ };
164
+ mockIsMultiScope = false;
165
+ var result = (0, FileUtils_1.getFileContextWithSkipReason)("/project/src/UIComponents/x_cadso_ui_form/sys_ux_lib_source_script/Bundle/source_map.js");
166
+ expect(result.skipReason).toBeUndefined();
167
+ expect(result.context).toBeDefined();
168
+ expect(result.context.targetField).toBe("source_map");
169
+ });
129
170
  it("throws when no manifest is loaded", function () {
130
171
  mockManifest = null;
131
172
  expect(function () {
@@ -56,6 +56,43 @@ describe("fingerprintFieldsFor", function () {
56
56
  expect((0, fingerprint_1.fingerprintFieldsFor)(bad, "t2")).toEqual(["script"]);
57
57
  });
58
58
  });
59
+ describe("checkFingerprintOptions", function () {
60
+ function warningsFor(opts) {
61
+ const warnings = [];
62
+ (0, fingerprint_1.checkFingerprintOptions)(opts, function (m) { warnings.push(m); });
63
+ return warnings;
64
+ }
65
+ it("says nothing for a well-formed option, an empty array, or no option", function () {
66
+ expect(warningsFor(OPTIONS)).toEqual([]);
67
+ expect(warningsFor({ t: { fingerprint: [] } })).toEqual([]);
68
+ expect(warningsFor({ t: { fingerprint: undefined, query: "active=true" } })).toEqual([]);
69
+ expect(warningsFor(undefined)).toEqual([]);
70
+ expect(warningsFor(null)).toEqual([]);
71
+ });
72
+ it("warns when the option is not an array, so the bundle would be mirrored in full", function () {
73
+ const warnings = warningsFor({ sys_ux_lib_source_script: { fingerprint: "script" } });
74
+ expect(warnings.length).toBe(1);
75
+ expect(warnings[0]).toContain("tableOptions.sys_ux_lib_source_script.fingerprint is ignored");
76
+ expect(warnings[0]).toContain("array of field names");
77
+ });
78
+ it("names each entry that is not a field name", function () {
79
+ const warnings = warningsFor({ t2: { fingerprint: ["", " ", 5, " script", "script", null] } });
80
+ expect(warnings.length).toBe(1);
81
+ expect(warnings[0]).toContain("tableOptions.t2.fingerprint ignores");
82
+ expect(warnings[0]).toContain('"", " ", 5, " script", null');
83
+ expect(warnings[0]).not.toContain('"script",');
84
+ });
85
+ it("reports every malformed table, in table order", function () {
86
+ const warnings = warningsFor({
87
+ zz: { fingerprint: { script: true } },
88
+ aa: { fingerprint: 7 },
89
+ ok: { fingerprint: ["script"] },
90
+ });
91
+ expect(warnings.length).toBe(2);
92
+ expect(warnings[0]).toContain("tableOptions.aa.");
93
+ expect(warnings[1]).toContain("tableOptions.zz.");
94
+ });
95
+ });
59
96
  describe("stripClientOnlyTableOptions", function () {
60
97
  it("removes fingerprint and keeps every other option", function () {
61
98
  var out = (0, fingerprint_1.stripClientOnlyTableOptions)(OPTIONS);
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ // A field mirrored as a fingerprint has no content file on disk. A content file
3
+ // for it (script.js left from before `fingerprint` was set; refresh never
4
+ // deletes) used to match the manifest field by name and be pushed over the live
5
+ // bundle. Push now skips it with a warning, through the real getAppFileList and
6
+ // getFileContextWithSkipReason.
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ jest.mock("../Logger", function () {
9
+ return {
10
+ logger: {
11
+ info: jest.fn(),
12
+ debug: jest.fn(),
13
+ warn: jest.fn(),
14
+ error: jest.fn(),
15
+ success: jest.fn(),
16
+ getLogLevel: function () { return "info"; },
17
+ },
18
+ };
19
+ });
20
+ jest.mock("../FileLogger", function () {
21
+ return { fileLogger: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn(), log: jest.fn() } };
22
+ });
23
+ var mockManifest = null;
24
+ jest.mock("../config", function () {
25
+ return {
26
+ getManifest: function () { return mockManifest; },
27
+ isMultiScopeManifest: function () { return false; },
28
+ resolveScopeFromPath: function () { return undefined; },
29
+ resolveManifestForScope: function () { return undefined; },
30
+ };
31
+ });
32
+ const Logger_1 = require("../Logger");
33
+ const appUtils_1 = require("../appUtils");
34
+ describe("push skips a content file of a fingerprinted field", function () {
35
+ beforeEach(function () {
36
+ Logger_1.logger.warn.mockClear();
37
+ mockManifest = {
38
+ scope: "x_cadso_ui_form",
39
+ tables: {
40
+ sys_ux_lib_source_script: {
41
+ records: {
42
+ Bundle: {
43
+ name: "Bundle",
44
+ sys_id: "f9cd",
45
+ files: [{ name: "script", type: "sha256" }, { name: "source_map", type: "js" }],
46
+ },
47
+ },
48
+ },
49
+ },
50
+ };
51
+ });
52
+ it("warns and pushes nothing for script.js beside a fingerprinted script field", async function () {
53
+ var stale = "/project/src/sys_ux_lib_source_script/Bundle/script.js";
54
+ var records = await (0, appUtils_1.getAppFileList)([stale]);
55
+ expect(records).toEqual([]);
56
+ expect(Logger_1.logger.warn).toHaveBeenCalledWith("Skipped: " + stale + " (fingerprinted field, read-only)");
57
+ });
58
+ it("keeps the record's other fields in the push", async function () {
59
+ var records = await (0, appUtils_1.getAppFileList)(["/project/src/sys_ux_lib_source_script/Bundle/source_map.js"]);
60
+ expect(records.length).toBe(1);
61
+ expect(Object.keys(records[0].fields)).toEqual(["source_map"]);
62
+ expect(Logger_1.logger.warn).not.toHaveBeenCalled();
63
+ });
64
+ });
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ // recordFolder: the manifest key (= folder) of a record by sys_id, and the
3
+ // guard that keeps a destructive caller inside <scope dir>/<table>.
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const path_1 = __importDefault(require("path"));
9
+ const recordFolder_1 = require("../recordFolder");
10
+ var SYS_A = "aaaaaaaa1111111111111111111111a1";
11
+ var SYS_B = "bbbbbbbb2222222222222222222222b2";
12
+ function manifestWith(records) {
13
+ var entries = {};
14
+ var keys = Object.keys(records);
15
+ for (var i = 0; i < keys.length; i++) {
16
+ entries[keys[i]] = { name: keys[i], sys_id: records[keys[i]], files: [] };
17
+ }
18
+ return { scope: "x_test", tables: { sys_script_include: { records: entries } } };
19
+ }
20
+ describe("recordFoldersBySysId", function () {
21
+ it("returns the manifest key, not the display name, of the record", function () {
22
+ var man = manifestWith({ "Foo (aaaaaaaa)": SYS_A, "Foo (bbbbbbbb)": SYS_B });
23
+ expect((0, recordFolder_1.recordFoldersBySysId)(man, "sys_script_include", SYS_B)).toEqual(["Foo (bbbbbbbb)"]);
24
+ });
25
+ it("returns nothing for a sys_id, table or manifest it does not have", function () {
26
+ var man = manifestWith({ Foo: SYS_A });
27
+ expect((0, recordFolder_1.recordFoldersBySysId)(man, "sys_script_include", SYS_B)).toEqual([]);
28
+ expect((0, recordFolder_1.recordFoldersBySysId)(man, "sys_script", SYS_A)).toEqual([]);
29
+ expect((0, recordFolder_1.recordFoldersBySysId)(man, "constructor", SYS_A)).toEqual([]);
30
+ expect((0, recordFolder_1.recordFoldersBySysId)(undefined, "sys_script_include", SYS_A)).toEqual([]);
31
+ expect((0, recordFolder_1.recordFoldersBySysId)(man, "sys_script_include", "")).toEqual([]);
32
+ });
33
+ it("returns every key when a corrupt manifest lists the sys_id twice", function () {
34
+ var man = manifestWith({ Foo: SYS_A, Bar: SYS_A });
35
+ expect((0, recordFolder_1.recordFoldersBySysId)(man, "sys_script_include", SYS_A).sort()).toEqual(["Bar", "Foo"]);
36
+ });
37
+ });
38
+ describe("recordDirFor", function () {
39
+ var scopeDir = path_1.default.resolve("/project/src/UIComponents/x_test");
40
+ it("returns <scope dir>/<table>/<folder> for a record folder", function () {
41
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", "Foo (aaaaaaaa)")).toBe(path_1.default.join(scopeDir, "sys_script_include", "Foo (aaaaaaaa)"));
42
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", "..Foo")).toBe(path_1.default.join(scopeDir, "sys_script_include", "..Foo"));
43
+ });
44
+ it("refuses a folder that is not a direct child of <scope dir>/<table>", function () {
45
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", "..")).toBeUndefined();
46
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", ".")).toBeUndefined();
47
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", "")).toBeUndefined();
48
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", "a/b")).toBeUndefined();
49
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", "../../x_other")).toBeUndefined();
50
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "sys_script_include", path_1.default.resolve("/etc"))).toBeUndefined();
51
+ });
52
+ it("refuses a table that is not a direct child of the scope folder", function () {
53
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "..", "x_other")).toBeUndefined();
54
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "", "Foo")).toBeUndefined();
55
+ expect((0, recordFolder_1.recordDirFor)(scopeDir, "a/b", "Foo")).toBeUndefined();
56
+ });
57
+ });
@@ -18,6 +18,7 @@ jest.mock("../Logger", function () {
18
18
  jest.mock("../FileLogger", function () {
19
19
  return { fileLogger: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() } };
20
20
  });
21
+ const Logger_1 = require("../Logger");
21
22
  const snClient_1 = require("../snClient");
22
23
  const fingerprint_1 = require("../fingerprint");
23
24
  const BUNDLE = "!function(){}();";
@@ -55,6 +56,25 @@ describe("snClient fingerprint hook", function () {
55
56
  // The caller's config is not mutated.
56
57
  expect(TABLE_OPTIONS.sys_ux_lib_source_script.fingerprint).toEqual(["script"]);
57
58
  });
59
+ it("getManifest warns about a malformed fingerprint option instead of dropping it silently", async function () {
60
+ Logger_1.logger.warn.mockClear();
61
+ var manifest = {
62
+ scope: "x_cadso_ui_form",
63
+ tables: {
64
+ sys_ux_lib_source_script: {
65
+ records: { a: { name: "a", sys_id: "1", files: [{ name: "script", type: "js" }] } },
66
+ },
67
+ },
68
+ };
69
+ var post = jest.fn().mockResolvedValue(okResponse(manifest));
70
+ var c = makeClient(post);
71
+ var options = { sys_ux_lib_source_script: { fingerprint: "script" } };
72
+ var config = { includes: {}, excludes: {}, tableOptions: options };
73
+ var resp = await c.getManifest("x_cadso_ui_form", config);
74
+ expect(Logger_1.logger.warn).toHaveBeenCalledWith(expect.stringContaining("tableOptions.sys_ux_lib_source_script.fingerprint is ignored"));
75
+ // Still ignored: the field is mirrored as content, as before.
76
+ expect(resp.data.result.tables.sys_ux_lib_source_script.records.a.files[0].type).toBe("js");
77
+ });
58
78
  it("getMissingFiles strips fingerprint from the request and hashes the downloaded content", async function () {
59
79
  var post = jest.fn().mockResolvedValue(okResponse({
60
80
  sys_ux_lib_source_script: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenonhq/dovetail-core",
3
- "version": "0.0.134",
3
+ "version": "0.0.135",
4
4
  "description": "Next-gen file syncer",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/index.js",