@tenonhq/dovetail-core 0.0.93 → 0.0.94

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/dist/appUtils.js CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.createAndAssignUpdateSet = exports.swapScope = exports.buildFiles = exports.summarizeRecord = exports.pushFiles = exports.getAppFileList = exports.groupAppFiles = exports.processMissingFiles = exports.refreshAllFiles = exports.findMissingFiles = exports.syncManifest = exports.processManifest = exports.normalizeManifestKeys = void 0;
39
+ exports.createAndAssignUpdateSet = exports.swapScope = exports.buildFiles = exports.summarizeRecord = exports.pushFiles = exports.getAppFileList = exports.groupAppFiles = exports.processMissingFiles = exports.refreshAllFiles = exports.findMissingFiles = exports.syncManifest = exports.processManifest = exports.normalizeManifestKeys = exports.toSafeFolderName = void 0;
40
40
  const path_1 = __importDefault(require("path"));
41
41
  const fs_1 = __importDefault(require("fs"));
42
42
  const progress_1 = __importDefault(require("progress"));
@@ -171,9 +171,29 @@ const processTablesInManifest = async (tables, forceWrite, sourcePath, onRecordP
171
171
  });
172
172
  };
173
173
  /**
174
- * Re-keys manifest records from sys_id to record.name (display value).
174
+ * Returns a filesystem-safe folder name for a record.
175
+ *
176
+ * Dovetail names each record's on-disk folder after the record's display name.
177
+ * Windows/NTFS forbids these characters in a path component — `< > : " | ? * \ /`
178
+ * — and forbids a trailing space or trailing dot. A folder whose name violates
179
+ * this cannot be checked out on Windows (`git clone` aborts with "invalid path"),
180
+ * even though macOS/Linux accept it. When the display name is unsafe we fall back
181
+ * to the record's sys_id, which is hex and safe on every OS. The true display name
182
+ * is unaffected here and is still carried by the server-provided metaData.json.
183
+ */
184
+ const toSafeFolderName = (record) => {
185
+ var name = record.name || "";
186
+ var isUnsafe = /[<>:"|?*\\/]/.test(name) || /[ .]$/.test(name) || name === "";
187
+ return isUnsafe ? record.sys_id : name;
188
+ };
189
+ exports.toSafeFolderName = toSafeFolderName;
190
+ /**
191
+ * Re-keys manifest records from sys_id to a filesystem-safe folder name.
175
192
  * Some ServiceNow tables return records keyed by sys_id instead of display name.
176
- * This ensures consistent naming for directories and manifest lookups.
193
+ * This ensures consistent naming for directories and manifest lookups, and keeps
194
+ * the on-disk folder name (which every writer derives from `record.name`) equal to
195
+ * the manifest key that `dove push` looks records up by — so the key ≡ folder
196
+ * invariant holds even when an unsafe display name forces a sys_id fallback.
177
197
  */
178
198
  const normalizeManifestKeys = (manifest) => {
179
199
  var tables = manifest.tables || {};
@@ -186,11 +206,15 @@ const normalizeManifestKeys = (manifest) => {
186
206
  for (var j = 0; j < recordKeys.length; j++) {
187
207
  var key = recordKeys[j];
188
208
  var record = records[key];
189
- var displayKey = record.name || key;
190
- // Handle duplicate display names by appending sys_id suffix
209
+ var displayKey = (0, exports.toSafeFolderName)(record);
210
+ // Handle duplicate folder names by appending sys_id suffix
191
211
  if (normalized[displayKey]) {
192
212
  displayKey = displayKey + " (" + record.sys_id.substring(0, 8) + ")";
193
213
  }
214
+ // Keep record.name === manifest key so all writers (which build the folder
215
+ // path from record.name) and push (which looks up by folder name) agree.
216
+ // The real display name lives in the server-provided metaData.json snapshot.
217
+ record.name = displayKey;
194
218
  normalized[displayKey] = record;
195
219
  }
196
220
  tables[tableName].records = normalized;
@@ -199,6 +223,9 @@ const normalizeManifestKeys = (manifest) => {
199
223
  };
200
224
  exports.normalizeManifestKeys = normalizeManifestKeys;
201
225
  const processManifest = async (manifest, forceWrite = false, sourcePath) => {
226
+ // Idempotent: guarantees filesystem-safe folder names + key ≡ record.name on
227
+ // every write path, including downloadCommand which does not normalize upstream.
228
+ (0, exports.normalizeManifestKeys)(manifest);
202
229
  const tableCount = Object.keys(manifest.tables).length;
203
230
  FileLogger_1.fileLogger.debug("Processing manifest: " + (manifest.scope || "legacy") + " (" + tableCount + " tables)");
204
231
  var recordCount = countRecordsInTables(manifest.tables);
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ // Tests for filesystem-safe folder naming.
3
+ //
4
+ // Dovetail names each record's folder after its ServiceNow display name. Windows
5
+ // forbids `< > : " | ? * \ /`, a trailing space, and a trailing dot in a path
6
+ // component, so a record named "Email Status Change " (trailing space) or an ACL
7
+ // named "x_cadso_work_task.*" cannot be checked out on Windows. toSafeFolderName
8
+ // falls back to the always-safe sys_id for such names; normalizeManifestKeys keeps
9
+ // the on-disk folder name (record.name) equal to the manifest key push looks up by.
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ const appUtils_1 = require("../appUtils");
12
+ const rec = (name, sys_id) => ({
13
+ name,
14
+ sys_id,
15
+ files: [{ name: "metaData", type: "json" }],
16
+ });
17
+ describe("toSafeFolderName", () => {
18
+ it("leaves a safe display name unchanged", () => {
19
+ expect((0, appUtils_1.toSafeFolderName)(rec("Send Email", "abc123"))).toBe("Send Email");
20
+ expect((0, appUtils_1.toSafeFolderName)(rec("Prevent delete - WorkGroup", "abc123"))).toBe("Prevent delete - WorkGroup");
21
+ });
22
+ it("falls back to sys_id for a trailing space", () => {
23
+ expect((0, appUtils_1.toSafeFolderName)(rec("Email Status Change ", "fefb8758"))).toBe("fefb8758");
24
+ });
25
+ it("falls back to sys_id for a trailing dot", () => {
26
+ expect((0, appUtils_1.toSafeFolderName)(rec("weird.", "sid1"))).toBe("sid1");
27
+ });
28
+ it("falls back to sys_id for each Windows-illegal character", () => {
29
+ const illegal = ["<", ">", ":", '"', "|", "?", "*", "\\", "/"];
30
+ illegal.forEach((ch) => {
31
+ expect((0, appUtils_1.toSafeFolderName)(rec("name" + ch + "x", "sidX"))).toBe("sidX");
32
+ });
33
+ });
34
+ it("treats the wildcard ACL name as unsafe", () => {
35
+ expect((0, appUtils_1.toSafeFolderName)(rec("x_cadso_work_task.*", "aclsid"))).toBe("aclsid");
36
+ });
37
+ it("falls back to sys_id for an empty name", () => {
38
+ expect((0, appUtils_1.toSafeFolderName)(rec("", "emptysid"))).toBe("emptysid");
39
+ });
40
+ });
41
+ describe("normalizeManifestKeys", () => {
42
+ const buildManifest = (records) => {
43
+ const byKey = {};
44
+ records.forEach((r) => {
45
+ byKey[r.sys_id] = r; // simulate a server manifest keyed by sys_id
46
+ });
47
+ return { scope: "x_cadso_test", tables: { sys_script: { records: byKey } } };
48
+ };
49
+ it("keys unsafe records by sys_id and safe records by name", () => {
50
+ const manifest = buildManifest([
51
+ rec("Send Email", "safe1"),
52
+ rec("Email Status Change ", "fefb8758330ede107b18bc534d5c7bfb"),
53
+ rec("x_cadso_work_task.*", "acl9999"),
54
+ ]);
55
+ (0, appUtils_1.normalizeManifestKeys)(manifest);
56
+ const keys = Object.keys(manifest.tables.sys_script.records);
57
+ expect(keys).toContain("Send Email");
58
+ expect(keys).toContain("fefb8758330ede107b18bc534d5c7bfb");
59
+ expect(keys).toContain("acl9999");
60
+ expect(keys).not.toContain("Email Status Change ");
61
+ expect(keys).not.toContain("x_cadso_work_task.*");
62
+ });
63
+ it("keeps record.name === manifest key for every record (push invariant)", () => {
64
+ const manifest = buildManifest([
65
+ rec("Send Email", "safe1"),
66
+ rec("Email Status Change ", "unsafe1"),
67
+ rec("h:extended", "unsafe2"),
68
+ ]);
69
+ (0, appUtils_1.normalizeManifestKeys)(manifest);
70
+ const records = manifest.tables.sys_script.records;
71
+ Object.keys(records).forEach((key) => {
72
+ expect(records[key].name).toBe(key);
73
+ });
74
+ });
75
+ it("preserves sys_id so push can still resolve the record", () => {
76
+ const manifest = buildManifest([rec("Email Status Change ", "fefb8758")]);
77
+ (0, appUtils_1.normalizeManifestKeys)(manifest);
78
+ const record = manifest.tables.sys_script.records["fefb8758"];
79
+ expect(record).toBeDefined();
80
+ expect(record.sys_id).toBe("fefb8758");
81
+ });
82
+ it("disambiguates duplicate folder names with a sys_id suffix", () => {
83
+ const manifest = buildManifest([
84
+ rec("Duplicate", "1111111111111111"),
85
+ rec("Duplicate", "2222222222222222"),
86
+ ]);
87
+ (0, appUtils_1.normalizeManifestKeys)(manifest);
88
+ const keys = Object.keys(manifest.tables.sys_script.records);
89
+ expect(keys).toContain("Duplicate");
90
+ expect(keys).toContain("Duplicate (22222222)");
91
+ // invariant still holds for the suffixed record
92
+ expect(manifest.tables.sys_script.records["Duplicate (22222222)"].name).toBe("Duplicate (22222222)");
93
+ });
94
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenonhq/dovetail-core",
3
- "version": "0.0.93",
3
+ "version": "0.0.94",
4
4
  "description": "Next-gen file syncer",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/index.js",
@@ -1,5 +1,84 @@
1
1
  {
2
2
  "$schema": "dovetail-manifest/v1",
3
- "generated_at": "2026-05-28T00:00:00Z",
4
- "events": []
3
+ "generated_at": "2026-05-28T15:54:22.498Z",
4
+ "events": [
5
+ {
6
+ "$schema": "dovetail-release-event/v1",
7
+ "event_id": "dovetail-claude-plans@0.0.19",
8
+ "package": "@tenonhq/dovetail-claude-plans",
9
+ "version": "0.0.19",
10
+ "prev_version": "0.0.18",
11
+ "published_at": "2026-05-28T15:54:22.483Z",
12
+ "git": {
13
+ "sha": "0247ef6e75093c95359413725977df07bd5bff70",
14
+ "tag": "dovetail-claude-plans@0.0.19"
15
+ },
16
+ "semver_bump": "patch",
17
+ "commits": [
18
+ {
19
+ "sha": "0247ef6e7",
20
+ "subject": "feat(dashboard): Prompt Lints filters + merged-PR filter for Claude Plans (#116)",
21
+ "pr": 116
22
+ },
23
+ {
24
+ "sha": "5f14a3421",
25
+ "subject": "chore(release): @tenonhq/dovetail-claude-plans@0.0.18 [skip ci]"
26
+ }
27
+ ],
28
+ "exports_delta": null,
29
+ "narrative": null
30
+ },
31
+ {
32
+ "$schema": "dovetail-release-event/v1",
33
+ "event_id": "dovetail-dashboard@0.0.31",
34
+ "package": "@tenonhq/dovetail-dashboard",
35
+ "version": "0.0.31",
36
+ "prev_version": "0.0.30",
37
+ "published_at": "2026-05-28T15:54:22.483Z",
38
+ "git": {
39
+ "sha": "0247ef6e75093c95359413725977df07bd5bff70",
40
+ "tag": "dovetail-dashboard@0.0.31"
41
+ },
42
+ "semver_bump": "patch",
43
+ "commits": [
44
+ {
45
+ "sha": "0247ef6e7",
46
+ "subject": "feat(dashboard): Prompt Lints filters + merged-PR filter for Claude Plans (#116)",
47
+ "pr": 116
48
+ },
49
+ {
50
+ "sha": "c35d549c4",
51
+ "subject": "chore(release): @tenonhq/dovetail-dashboard@0.0.30 [skip ci]"
52
+ }
53
+ ],
54
+ "exports_delta": null,
55
+ "narrative": null
56
+ },
57
+ {
58
+ "$schema": "dovetail-release-event/v1",
59
+ "event_id": "dovetail-core@0.0.93",
60
+ "package": "@tenonhq/dovetail-core",
61
+ "version": "0.0.93",
62
+ "prev_version": "0.0.92",
63
+ "published_at": "2026-05-28T08:23:44.072Z",
64
+ "git": {
65
+ "sha": "f2f4d29e5fbd6197fc501bc803a864ed605cd54a",
66
+ "tag": "dovetail-core@0.0.93"
67
+ },
68
+ "semver_bump": "patch",
69
+ "commits": [
70
+ {
71
+ "sha": "f2f4d29e5",
72
+ "subject": "feat: release manifest emit + dove knowledge-diff (downstream doc sync) (#114)",
73
+ "pr": 114
74
+ },
75
+ {
76
+ "sha": "16e4c0cc2",
77
+ "subject": "chore(release): @tenonhq/dovetail-core@0.0.92 [skip ci]"
78
+ }
79
+ ],
80
+ "exports_delta": null,
81
+ "narrative": null
82
+ }
83
+ ]
5
84
  }