@filen/sync 0.1.3 → 0.1.4

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
@@ -5,6 +5,7 @@ import { type RemoteTreeIgnored } from "./lib/filesystems/remote";
5
5
  import { type SerializedError } from "./utils";
6
6
  export type SyncMode = "twoWay" | "localToCloud" | "localBackup" | "cloudToLocal" | "cloudBackup";
7
7
  export type SyncPair = {
8
+ name: string;
8
9
  uuid: string;
9
10
  localPath: string;
10
11
  remotePath: string;
@@ -17,45 +18,188 @@ export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K
17
18
  export type Prettify<T> = {
18
19
  [K in keyof T]: T[K];
19
20
  } & {};
20
- export type CycleState = "cycleStarted" | "cycleFinished" | "cycleError" | "cycleSuccess" | "cycleWaitingForLocalDirectoryChangesStarted" | "cycleWaitingForLocalDirectoryChangesDone" | "cycleGettingTreesStarted" | "cycleGettingTreesDone" | "cycleProcessingDeltasStarted" | "cycleProcessingDeltasDone" | "cycleProcessingTasksStarted" | "cycleProcessingTasksDone" | "cycleApplyingStateStarted" | "cycleApplyingStateDone" | "cycleSavingStateStarted" | "cycleSavingStateDone" | "cycleRestarting" | "cyclePaused";
21
+ export type IPCDoneTask = Prettify<Omit<DoneTask, "stats">>;
22
+ export type IPCTaskError = Prettify<Omit<TaskError, "error"> & {
23
+ error: SerializedError;
24
+ }>;
25
+ export type IPCLocalTreeError = Prettify<Omit<LocalTreeError, "error"> & {
26
+ error: SerializedError;
27
+ }>;
28
+ export type CycleState = "cycleStarted" | "cycleFinished" | "cycleError" | "cycleSuccess" | "cycleWaitingForLocalDirectoryChangesStarted" | "cycleWaitingForLocalDirectoryChangesDone" | "cycleGettingTreesStarted" | "cycleGettingTreesDone" | "cycleProcessingDeltasStarted" | "cycleProcessingDeltasDone" | "cycleProcessingTasksStarted" | "cycleProcessingTasksDone" | "cycleApplyingStateStarted" | "cycleApplyingStateDone" | "cycleSavingStateStarted" | "cycleSavingStateDone" | "cycleRestarting" | "cyclePaused" | "cycleLocalSmokeTestFailed" | "cycleNoChanges" | "cycleRemoteSmokeTestFailed" | "cycleExited" | "cycleAcquiringLockStarted" | "cycleAcquiringLockDone" | "cycleReleasingLockStarted" | "cycleReleasingLockDone";
29
+ export type TransferData = {
30
+ of: "upload" | "download";
31
+ type: "progress";
32
+ relativePath: string;
33
+ localPath: string;
34
+ bytes: number;
35
+ size: number;
36
+ } | {
37
+ of: "upload" | "download";
38
+ type: "queued";
39
+ relativePath: string;
40
+ localPath: string;
41
+ size: number;
42
+ } | {
43
+ of: "upload" | "download";
44
+ type: "started";
45
+ relativePath: string;
46
+ localPath: string;
47
+ size: number;
48
+ } | {
49
+ of: "upload" | "download";
50
+ type: "finished";
51
+ relativePath: string;
52
+ localPath: string;
53
+ size: number;
54
+ } | {
55
+ of: "upload" | "download";
56
+ type: "error";
57
+ relativePath: string;
58
+ localPath: string;
59
+ error: SerializedError;
60
+ size: number;
61
+ } | {
62
+ of: "createLocalDirectory";
63
+ type: "error";
64
+ relativePath: string;
65
+ localPath: string;
66
+ error: SerializedError;
67
+ } | {
68
+ of: "createLocalDirectory";
69
+ type: "success";
70
+ relativePath: string;
71
+ localPath: string;
72
+ } | {
73
+ of: "createRemoteDirectory";
74
+ type: "error";
75
+ relativePath: string;
76
+ localPath: string;
77
+ error: SerializedError;
78
+ } | {
79
+ of: "createRemoteDirectory";
80
+ type: "success";
81
+ relativePath: string;
82
+ localPath: string;
83
+ } | {
84
+ of: "deleteLocalFile";
85
+ type: "error";
86
+ relativePath: string;
87
+ localPath: string;
88
+ error: SerializedError;
89
+ } | {
90
+ of: "deleteLocalFile";
91
+ type: "success";
92
+ relativePath: string;
93
+ localPath: string;
94
+ } | {
95
+ of: "deleteLocalDirectory";
96
+ type: "error";
97
+ relativePath: string;
98
+ localPath: string;
99
+ error: SerializedError;
100
+ } | {
101
+ of: "deleteLocalDirectory";
102
+ type: "success";
103
+ relativePath: string;
104
+ localPath: string;
105
+ } | {
106
+ of: "deleteRemoteFile";
107
+ type: "error";
108
+ relativePath: string;
109
+ localPath: string;
110
+ error: SerializedError;
111
+ } | {
112
+ of: "deleteRemoteFile";
113
+ type: "success";
114
+ relativePath: string;
115
+ localPath: string;
116
+ } | {
117
+ of: "deleteRemoteDirectory";
118
+ type: "error";
119
+ relativePath: string;
120
+ localPath: string;
121
+ error: SerializedError;
122
+ } | {
123
+ of: "deleteRemoteDirectory";
124
+ type: "success";
125
+ relativePath: string;
126
+ localPath: string;
127
+ } | {
128
+ of: "renameLocalFile";
129
+ type: "error";
130
+ relativePath: string;
131
+ localPath: string;
132
+ error: SerializedError;
133
+ } | {
134
+ of: "renameLocalFile";
135
+ type: "success";
136
+ relativePath: string;
137
+ localPath: string;
138
+ } | {
139
+ of: "renameLocalDirectory";
140
+ type: "error";
141
+ relativePath: string;
142
+ localPath: string;
143
+ error: SerializedError;
144
+ } | {
145
+ of: "renameLocalDirectory";
146
+ type: "success";
147
+ relativePath: string;
148
+ localPath: string;
149
+ } | {
150
+ of: "renameRemoteDirectory";
151
+ type: "error";
152
+ relativePath: string;
153
+ localPath: string;
154
+ error: SerializedError;
155
+ } | {
156
+ of: "renameRemoteDirectory";
157
+ type: "success";
158
+ relativePath: string;
159
+ localPath: string;
160
+ } | {
161
+ of: "renameRemoteFile";
162
+ type: "error";
163
+ relativePath: string;
164
+ localPath: string;
165
+ error: SerializedError;
166
+ } | {
167
+ of: "renameRemoteFile";
168
+ type: "success";
169
+ relativePath: string;
170
+ localPath: string;
171
+ } | {
172
+ of: "downloadFile";
173
+ type: "error";
174
+ relativePath: string;
175
+ localPath: string;
176
+ error: SerializedError;
177
+ } | {
178
+ of: "downloadFile";
179
+ type: "success";
180
+ relativePath: string;
181
+ localPath: string;
182
+ } | {
183
+ of: "uploadFile";
184
+ type: "error";
185
+ relativePath: string;
186
+ localPath: string;
187
+ error: SerializedError;
188
+ } | {
189
+ of: "uploadFile";
190
+ type: "success";
191
+ relativePath: string;
192
+ localPath: string;
193
+ };
21
194
  export type SyncMessage = ({
22
195
  syncPair: SyncPair;
23
196
  } & ({
24
197
  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
- };
198
+ data: TransferData;
53
199
  } | {
54
200
  type: "localTreeErrors";
55
201
  data: {
56
- errors: Prettify<Omit<LocalTreeError, "error"> & {
57
- error: SerializedError;
58
- }>[];
202
+ errors: IPCLocalTreeError[];
59
203
  };
60
204
  } | {
61
205
  type: "localTreeIgnored";
@@ -75,10 +219,8 @@ export type SyncMessage = ({
75
219
  } | {
76
220
  type: "doneTasks";
77
221
  data: {
78
- tasks: Prettify<Omit<DoneTask, "stats">>[];
79
- errors: Prettify<Omit<TaskError, "error"> & {
80
- error: SerializedError;
81
- }>[];
222
+ tasks: IPCDoneTask[];
223
+ errors: IPCTaskError[];
82
224
  };
83
225
  } | {
84
226
  type: "cycleStarted";
@@ -91,6 +233,8 @@ export type SyncMessage = ({
91
233
  };
92
234
  } | {
93
235
  type: "cycleSuccess";
236
+ } | {
237
+ type: "cycleExited";
94
238
  } | {
95
239
  type: "cycleWaitingForLocalDirectoryChangesStarted";
96
240
  } | {
@@ -103,6 +247,16 @@ export type SyncMessage = ({
103
247
  type: "cycleProcessingDeltasStarted";
104
248
  } | {
105
249
  type: "cycleProcessingDeltasDone";
250
+ } | {
251
+ type: "cycleLocalSmokeTestFailed";
252
+ data: {
253
+ error: SerializedError;
254
+ };
255
+ } | {
256
+ type: "cycleRemoteSmokeTestFailed";
257
+ data: {
258
+ error: SerializedError;
259
+ };
106
260
  } | {
107
261
  type: "cycleNoChanges";
108
262
  } | {
@@ -119,6 +273,14 @@ export type SyncMessage = ({
119
273
  type: "cycleSavingStateDone";
120
274
  } | {
121
275
  type: "cycleRestarting";
276
+ } | {
277
+ type: "cycleAcquiringLockStarted";
278
+ } | {
279
+ type: "cycleAcquiringLockDone";
280
+ } | {
281
+ type: "cycleReleasingLockStarted";
282
+ } | {
283
+ type: "cycleReleasingLockDone";
122
284
  } | {
123
285
  type: "cyclePaused";
124
286
  } | {
@@ -184,4 +346,7 @@ export type SyncMessage = ({
184
346
  } | {
185
347
  type: "syncPairIncludeDotFiles";
186
348
  syncPair: SyncPair;
349
+ } | {
350
+ type: "syncPairRemoved";
351
+ syncPair: SyncPair;
187
352
  };
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"));
@@ -138,16 +138,7 @@ exports.isRelativePathIgnoredByDefault = (0, memoize_1.default)((path) => {
138
138
  if ((0, exports.isNameIgnoredByDefault)(path_1.default.basename(path))) {
139
139
  return true;
140
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;
141
+ return path.split("/").some(part => part.length > 0 && (0, exports.isNameIgnoredByDefault)(part));
151
142
  });
152
143
  exports.isSystemPathIgnoredByDefault = (0, memoize_1.default)((path) => {
153
144
  for (const systemPath of constants_1.DEFAULT_IGNORED.system) {
@@ -181,4 +172,45 @@ function deserializeError(serializedError) {
181
172
  return error;
182
173
  }
183
174
  exports.deserializeError = deserializeError;
175
+ /**
176
+ * Replace a path with it's new parent path.
177
+ *
178
+ * @export
179
+ * @param {string} path
180
+ * @param {string} from
181
+ * @param {string} to
182
+ * @returns {string}
183
+ */
184
+ function replacePathStartWithFromAndTo(path, from, to) {
185
+ if (path.endsWith("/")) {
186
+ path = path.slice(0, path.length - 1);
187
+ }
188
+ if (from.endsWith("/")) {
189
+ from = from.slice(0, from.length - 1);
190
+ }
191
+ if (to.endsWith("/")) {
192
+ to = to.slice(0, to.length - 1);
193
+ }
194
+ if (!path.startsWith("/")) {
195
+ path = `/${path}`;
196
+ }
197
+ if (!from.startsWith("/")) {
198
+ from = `/${from}`;
199
+ }
200
+ if (!to.startsWith("/")) {
201
+ to = `/${to}`;
202
+ }
203
+ return `${to}${path.slice(from.length)}`;
204
+ }
205
+ exports.replacePathStartWithFromAndTo = replacePathStartWithFromAndTo;
206
+ /**
207
+ * Check if a path includes a dot file.
208
+ *
209
+ * @export
210
+ * @param {string} path
211
+ * @returns {boolean}
212
+ */
213
+ exports.pathIncludesDotFile = (0, memoize_1.default)((path) => {
214
+ return path.split("/").some(part => part.length > 0 && part.trimStart().startsWith("."));
215
+ });
184
216
  //# 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,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAA;QAExE,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,OAAO,CAAA;AACf,CAAC;AAVD,8CAUC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,wBAAwB,CAAI,QAAsB,EAAE,SAAS,GAAG,MAAM;IAC3F,MAAM,OAAO,GAAQ,EAAE,CAAA;IAEvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAA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"
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.4",
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
  }