@filen/sync 0.1.3 → 0.1.5

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/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { type LocalTreeError, type LocalTreeIgnored } from "./lib/filesystems/local";
2
- import { type Delta } from "./lib/deltas";
3
2
  import { type DoneTask, type TaskError } from "./lib/tasks";
4
3
  import { type RemoteTreeIgnored } from "./lib/filesystems/remote";
5
4
  import { type SerializedError } from "./utils";
6
5
  export type SyncMode = "twoWay" | "localToCloud" | "localBackup" | "cloudToLocal" | "cloudBackup";
7
6
  export type SyncPair = {
7
+ name: string;
8
8
  uuid: string;
9
9
  localPath: string;
10
10
  remotePath: string;
@@ -17,45 +17,188 @@ export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K
17
17
  export type Prettify<T> = {
18
18
  [K in keyof T]: T[K];
19
19
  } & {};
20
- export type CycleState = "cycleStarted" | "cycleFinished" | "cycleError" | "cycleSuccess" | "cycleWaitingForLocalDirectoryChangesStarted" | "cycleWaitingForLocalDirectoryChangesDone" | "cycleGettingTreesStarted" | "cycleGettingTreesDone" | "cycleProcessingDeltasStarted" | "cycleProcessingDeltasDone" | "cycleProcessingTasksStarted" | "cycleProcessingTasksDone" | "cycleApplyingStateStarted" | "cycleApplyingStateDone" | "cycleSavingStateStarted" | "cycleSavingStateDone" | "cycleRestarting" | "cyclePaused";
20
+ export type IPCDoneTask = Prettify<Omit<DoneTask, "stats">>;
21
+ export type IPCTaskError = Prettify<Omit<TaskError, "error"> & {
22
+ error: SerializedError;
23
+ }>;
24
+ export type IPCLocalTreeError = Prettify<Omit<LocalTreeError, "error"> & {
25
+ error: SerializedError;
26
+ }>;
27
+ export type CycleState = "cycleStarted" | "cycleError" | "cycleSuccess" | "cycleWaitingForLocalDirectoryChangesStarted" | "cycleWaitingForLocalDirectoryChangesDone" | "cycleGettingTreesStarted" | "cycleGettingTreesDone" | "cycleProcessingDeltasStarted" | "cycleProcessingDeltasDone" | "cycleProcessingTasksStarted" | "cycleProcessingTasksDone" | "cycleApplyingStateStarted" | "cycleApplyingStateDone" | "cycleSavingStateStarted" | "cycleSavingStateDone" | "cycleRestarting" | "cyclePaused" | "cycleLocalSmokeTestFailed" | "cycleNoChanges" | "cycleRemoteSmokeTestFailed" | "cycleExited" | "cycleAcquiringLockStarted" | "cycleAcquiringLockDone" | "cycleReleasingLockStarted" | "cycleReleasingLockDone" | "cycleLocalSmokeTestFailed" | "cycleRemoteSmokeTestFailed";
28
+ export type TransferData = {
29
+ of: "upload" | "download";
30
+ type: "progress";
31
+ relativePath: string;
32
+ localPath: string;
33
+ bytes: number;
34
+ size: number;
35
+ } | {
36
+ of: "upload" | "download";
37
+ type: "queued";
38
+ relativePath: string;
39
+ localPath: string;
40
+ size: number;
41
+ } | {
42
+ of: "upload" | "download";
43
+ type: "started";
44
+ relativePath: string;
45
+ localPath: string;
46
+ size: number;
47
+ } | {
48
+ of: "upload" | "download";
49
+ type: "finished";
50
+ relativePath: string;
51
+ localPath: string;
52
+ size: number;
53
+ } | {
54
+ of: "upload" | "download";
55
+ type: "error";
56
+ relativePath: string;
57
+ localPath: string;
58
+ error: SerializedError;
59
+ size: number;
60
+ } | {
61
+ of: "createLocalDirectory";
62
+ type: "error";
63
+ relativePath: string;
64
+ localPath: string;
65
+ error: SerializedError;
66
+ } | {
67
+ of: "createLocalDirectory";
68
+ type: "success";
69
+ relativePath: string;
70
+ localPath: string;
71
+ } | {
72
+ of: "createRemoteDirectory";
73
+ type: "error";
74
+ relativePath: string;
75
+ localPath: string;
76
+ error: SerializedError;
77
+ } | {
78
+ of: "createRemoteDirectory";
79
+ type: "success";
80
+ relativePath: string;
81
+ localPath: string;
82
+ } | {
83
+ of: "deleteLocalFile";
84
+ type: "error";
85
+ relativePath: string;
86
+ localPath: string;
87
+ error: SerializedError;
88
+ } | {
89
+ of: "deleteLocalFile";
90
+ type: "success";
91
+ relativePath: string;
92
+ localPath: string;
93
+ } | {
94
+ of: "deleteLocalDirectory";
95
+ type: "error";
96
+ relativePath: string;
97
+ localPath: string;
98
+ error: SerializedError;
99
+ } | {
100
+ of: "deleteLocalDirectory";
101
+ type: "success";
102
+ relativePath: string;
103
+ localPath: string;
104
+ } | {
105
+ of: "deleteRemoteFile";
106
+ type: "error";
107
+ relativePath: string;
108
+ localPath: string;
109
+ error: SerializedError;
110
+ } | {
111
+ of: "deleteRemoteFile";
112
+ type: "success";
113
+ relativePath: string;
114
+ localPath: string;
115
+ } | {
116
+ of: "deleteRemoteDirectory";
117
+ type: "error";
118
+ relativePath: string;
119
+ localPath: string;
120
+ error: SerializedError;
121
+ } | {
122
+ of: "deleteRemoteDirectory";
123
+ type: "success";
124
+ relativePath: string;
125
+ localPath: string;
126
+ } | {
127
+ of: "renameLocalFile";
128
+ type: "error";
129
+ relativePath: string;
130
+ localPath: string;
131
+ error: SerializedError;
132
+ } | {
133
+ of: "renameLocalFile";
134
+ type: "success";
135
+ relativePath: string;
136
+ localPath: string;
137
+ } | {
138
+ of: "renameLocalDirectory";
139
+ type: "error";
140
+ relativePath: string;
141
+ localPath: string;
142
+ error: SerializedError;
143
+ } | {
144
+ of: "renameLocalDirectory";
145
+ type: "success";
146
+ relativePath: string;
147
+ localPath: string;
148
+ } | {
149
+ of: "renameRemoteDirectory";
150
+ type: "error";
151
+ relativePath: string;
152
+ localPath: string;
153
+ error: SerializedError;
154
+ } | {
155
+ of: "renameRemoteDirectory";
156
+ type: "success";
157
+ relativePath: string;
158
+ localPath: string;
159
+ } | {
160
+ of: "renameRemoteFile";
161
+ type: "error";
162
+ relativePath: string;
163
+ localPath: string;
164
+ error: SerializedError;
165
+ } | {
166
+ of: "renameRemoteFile";
167
+ type: "success";
168
+ relativePath: string;
169
+ localPath: string;
170
+ } | {
171
+ of: "downloadFile";
172
+ type: "error";
173
+ relativePath: string;
174
+ localPath: string;
175
+ error: SerializedError;
176
+ } | {
177
+ of: "downloadFile";
178
+ type: "success";
179
+ relativePath: string;
180
+ localPath: string;
181
+ } | {
182
+ of: "uploadFile";
183
+ type: "error";
184
+ relativePath: string;
185
+ localPath: string;
186
+ error: SerializedError;
187
+ } | {
188
+ of: "uploadFile";
189
+ type: "success";
190
+ relativePath: string;
191
+ localPath: string;
192
+ };
21
193
  export type SyncMessage = ({
22
194
  syncPair: SyncPair;
23
195
  } & ({
24
196
  type: "transfer";
25
- data: {
26
- of: "upload" | "download";
27
- type: "progress";
28
- relativePath: string;
29
- localPath: string;
30
- bytes: number;
31
- } | {
32
- of: "upload" | "download";
33
- type: "queued";
34
- relativePath: string;
35
- localPath: string;
36
- } | {
37
- of: "upload" | "download";
38
- type: "started";
39
- relativePath: string;
40
- localPath: string;
41
- } | {
42
- of: "upload" | "download";
43
- type: "finished";
44
- relativePath: string;
45
- localPath: string;
46
- } | {
47
- of: "upload" | "download";
48
- type: "error";
49
- relativePath: string;
50
- localPath: string;
51
- error: SerializedError;
52
- };
197
+ data: TransferData;
53
198
  } | {
54
199
  type: "localTreeErrors";
55
200
  data: {
56
- errors: Prettify<Omit<LocalTreeError, "error"> & {
57
- error: SerializedError;
58
- }>[];
201
+ errors: IPCLocalTreeError[];
59
202
  };
60
203
  } | {
61
204
  type: "localTreeIgnored";
@@ -68,22 +211,12 @@ export type SyncMessage = ({
68
211
  ignored: RemoteTreeIgnored[];
69
212
  };
70
213
  } | {
71
- type: "deltas";
214
+ type: "taskErrors";
72
215
  data: {
73
- deltas: Delta[];
74
- };
75
- } | {
76
- type: "doneTasks";
77
- data: {
78
- tasks: Prettify<Omit<DoneTask, "stats">>[];
79
- errors: Prettify<Omit<TaskError, "error"> & {
80
- error: SerializedError;
81
- }>[];
216
+ errors: IPCTaskError[];
82
217
  };
83
218
  } | {
84
219
  type: "cycleStarted";
85
- } | {
86
- type: "cycleFinished";
87
220
  } | {
88
221
  type: "cycleError";
89
222
  data: {
@@ -91,6 +224,12 @@ export type SyncMessage = ({
91
224
  };
92
225
  } | {
93
226
  type: "cycleSuccess";
227
+ } | {
228
+ type: "cycleLocalSmokeTestFailed";
229
+ } | {
230
+ type: "cycleRemoteSmokeTestFailed";
231
+ } | {
232
+ type: "cycleExited";
94
233
  } | {
95
234
  type: "cycleWaitingForLocalDirectoryChangesStarted";
96
235
  } | {
@@ -103,6 +242,16 @@ export type SyncMessage = ({
103
242
  type: "cycleProcessingDeltasStarted";
104
243
  } | {
105
244
  type: "cycleProcessingDeltasDone";
245
+ } | {
246
+ type: "cycleLocalSmokeTestFailed";
247
+ data: {
248
+ error: SerializedError;
249
+ };
250
+ } | {
251
+ type: "cycleRemoteSmokeTestFailed";
252
+ data: {
253
+ error: SerializedError;
254
+ };
106
255
  } | {
107
256
  type: "cycleNoChanges";
108
257
  } | {
@@ -119,6 +268,14 @@ export type SyncMessage = ({
119
268
  type: "cycleSavingStateDone";
120
269
  } | {
121
270
  type: "cycleRestarting";
271
+ } | {
272
+ type: "cycleAcquiringLockStarted";
273
+ } | {
274
+ type: "cycleAcquiringLockDone";
275
+ } | {
276
+ type: "cycleReleasingLockStarted";
277
+ } | {
278
+ type: "cycleReleasingLockDone";
122
279
  } | {
123
280
  type: "cyclePaused";
124
281
  } | {
@@ -184,4 +341,7 @@ export type SyncMessage = ({
184
341
  } | {
185
342
  type: "syncPairIncludeDotFiles";
186
343
  syncPair: SyncPair;
344
+ } | {
345
+ type: "syncPairRemoved";
346
+ syncPair: SyncPair;
187
347
  };
package/dist/utils.d.ts CHANGED
@@ -46,3 +46,21 @@ export type SerializedError = {
46
46
  };
47
47
  export declare function serializeError(error: Error): SerializedError;
48
48
  export declare function deserializeError(serializedError: SerializedError): Error;
49
+ /**
50
+ * Replace a path with it's new parent path.
51
+ *
52
+ * @export
53
+ * @param {string} path
54
+ * @param {string} from
55
+ * @param {string} to
56
+ * @returns {string}
57
+ */
58
+ export declare function replacePathStartWithFromAndTo(path: string, from: string, to: string): string;
59
+ /**
60
+ * Check if a path includes a dot file.
61
+ *
62
+ * @export
63
+ * @param {string} path
64
+ * @returns {boolean}
65
+ */
66
+ export declare const pathIncludesDotFile: ((path: string) => boolean) & import("lodash").MemoizedFunction;
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.deserializeError = exports.serializeError = exports.isDirectoryPathIgnoredByDefault = exports.isSystemPathIgnoredByDefault = exports.isRelativePathIgnoredByDefault = exports.isNameIgnoredByDefault = exports.isValidPath = exports.isNameOverMaxLength = exports.isPathOverMaxLength = exports.convertTimestampToMs = exports.promiseAllSettledChunked = exports.promiseAllChunked = void 0;
6
+ exports.pathIncludesDotFile = exports.replacePathStartWithFromAndTo = exports.deserializeError = exports.serializeError = exports.isDirectoryPathIgnoredByDefault = exports.isSystemPathIgnoredByDefault = exports.isRelativePathIgnoredByDefault = exports.isNameIgnoredByDefault = exports.isValidPath = exports.isNameOverMaxLength = exports.isPathOverMaxLength = exports.convertTimestampToMs = exports.promiseAllSettledChunked = exports.promiseAllChunked = void 0;
7
7
  const memoize_1 = __importDefault(require("lodash/memoize"));
8
8
  const constants_1 = require("./constants");
9
9
  const path_1 = __importDefault(require("path"));
@@ -135,19 +135,7 @@ exports.isNameIgnoredByDefault = (0, memoize_1.default)((name) => {
135
135
  return false;
136
136
  });
137
137
  exports.isRelativePathIgnoredByDefault = (0, memoize_1.default)((path) => {
138
- if ((0, exports.isNameIgnoredByDefault)(path_1.default.basename(path))) {
139
- return true;
140
- }
141
- const ex = path.split("/");
142
- for (const part of ex) {
143
- if (part.length === 0) {
144
- continue;
145
- }
146
- if ((0, exports.isNameIgnoredByDefault)(part)) {
147
- return true;
148
- }
149
- }
150
- return false;
138
+ return path.split("/").some(part => part.length > 0 && (0, exports.isNameIgnoredByDefault)(part));
151
139
  });
152
140
  exports.isSystemPathIgnoredByDefault = (0, memoize_1.default)((path) => {
153
141
  for (const systemPath of constants_1.DEFAULT_IGNORED.system) {
@@ -181,4 +169,45 @@ function deserializeError(serializedError) {
181
169
  return error;
182
170
  }
183
171
  exports.deserializeError = deserializeError;
172
+ /**
173
+ * Replace a path with it's new parent path.
174
+ *
175
+ * @export
176
+ * @param {string} path
177
+ * @param {string} from
178
+ * @param {string} to
179
+ * @returns {string}
180
+ */
181
+ function replacePathStartWithFromAndTo(path, from, to) {
182
+ if (path.endsWith("/")) {
183
+ path = path.slice(0, path.length - 1);
184
+ }
185
+ if (from.endsWith("/")) {
186
+ from = from.slice(0, from.length - 1);
187
+ }
188
+ if (to.endsWith("/")) {
189
+ to = to.slice(0, to.length - 1);
190
+ }
191
+ if (!path.startsWith("/")) {
192
+ path = `/${path}`;
193
+ }
194
+ if (!from.startsWith("/")) {
195
+ from = `/${from}`;
196
+ }
197
+ if (!to.startsWith("/")) {
198
+ to = `/${to}`;
199
+ }
200
+ return `${to}${path.slice(from.length)}`;
201
+ }
202
+ exports.replacePathStartWithFromAndTo = replacePathStartWithFromAndTo;
203
+ /**
204
+ * Check if a path includes a dot file.
205
+ *
206
+ * @export
207
+ * @param {string} path
208
+ * @returns {boolean}
209
+ */
210
+ exports.pathIncludesDotFile = (0, memoize_1.default)((path) => {
211
+ return path.split("/").some(part => part.length > 0 && part.trimStart().startsWith("."));
212
+ });
184
213
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAoC;AACpC,2CAA6C;AAC7C,gDAA6B;AAE7B;;;;;;;;;;GAUG;AACI,KAAK,UAAU,iBAAiB,CAAI,QAAsB,EAAE,SAAS,GAAG,MAAM;IACpF,MAAM,OAAO,GAAQ,EAAE,CAAA;IAEvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QACrD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,EAAC,CAAC,IAAY,EAAW,EAAE;IACpE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;AACzF,CAAC,CAAC,CAAA"}
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { type SyncMessage } from "./src/types"
2
+
3
+ declare global {
4
+ declare namespace NodeJS {
5
+ interface Process {
6
+ onMessage?: (message: SyncMessage) => void
7
+ }
8
+ }
9
+ }
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ preset: "ts-jest",
3
+ testEnvironment: "node",
4
+ testMatch: ["**/tests/**/*.(spec|test).ts"]
5
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@filen/sync",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Filen Sync",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "private": false,
8
8
  "scripts": {
9
- "test": "jest --forceExit ./__tests__",
9
+ "test": "jest",
10
10
  "lint": "eslint src/**/* --ext .js,.jsx,.ts,.tsx",
11
11
  "emitTypes": "tsc --emitDeclarationOnly",
12
12
  "tsc": "tsc --build",
@@ -34,6 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@jest/globals": "^29.7.0",
36
36
  "@types/fs-extra": "^11.0.4",
37
+ "@types/jest": "^29.5.12",
37
38
  "@types/lodash": "^4.17.6",
38
39
  "@types/mime-types": "^2.1.4",
39
40
  "@types/uuid": "^9.0.8",
@@ -43,13 +44,14 @@
43
44
  "eslint": "^8.56.0",
44
45
  "jest": "^29.7.0",
45
46
  "rimraf": "^5.0.5",
47
+ "ts-jest": "^29.1.5",
46
48
  "ts-node": "^10.9.2",
47
49
  "tsx": "^4.11.0",
48
50
  "typescript": "^5.3.3",
49
51
  "wait-on": "^7.2.0"
50
52
  },
51
53
  "dependencies": {
52
- "@filen/sdk": "^0.1.129",
54
+ "@filen/sdk": "^0.1.134",
53
55
  "@parcel/watcher": "^2.4.1",
54
56
  "fs-extra": "^11.2.0",
55
57
  "ignore": "^5.3.1",
@@ -0,0 +1,33 @@
1
+ import { replacePathStartWithFromAndTo } from "../src/utils"
2
+
3
+ test("replacePathStartWithFromAndTo basic", () => {
4
+ const path = "/foo/bar"
5
+ const from = "/foo"
6
+ const to = "/baz"
7
+
8
+ expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/baz/bar")
9
+ })
10
+
11
+ test("replacePathStartWithFromAndTo basic + extension", () => {
12
+ const path = "/foo/bar.txt"
13
+ const from = "/foo"
14
+ const to = "/baz"
15
+
16
+ expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/baz/bar.txt")
17
+ })
18
+
19
+ test("replacePathStartWithFromAndTo same names", () => {
20
+ const path = "/1/1/1/1"
21
+ const from = "/1"
22
+ const to = "/2"
23
+
24
+ expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/2/1/1/1")
25
+ })
26
+
27
+ test("replacePathStartWithFromAndTo same names + extension", () => {
28
+ const path = "/1/1/1/1.txt"
29
+ const from = "/1"
30
+ const to = "/2"
31
+
32
+ expect(replacePathStartWithFromAndTo(path, from, to)).toBe("/2/1/1/1.txt")
33
+ })
package/tsconfig.json CHANGED
@@ -19,6 +19,6 @@
19
19
  "ts-node": {
20
20
  "files": true
21
21
  },
22
- "include": ["src"],
23
- "exclude": ["node_modules", "dist", "__tests__", "docs", ".github", "dev", ".vscode"]
22
+ "include": ["src", "index.d.ts"],
23
+ "exclude": ["node_modules", "dist", "tests", "docs", ".github", "dev", ".vscode"]
24
24
  }