@narumitw/pi-sync 0.30.0 → 0.34.0
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 +159 -236
- package/package.json +14 -6
- package/src/backend-factory.ts +20 -0
- package/src/command.ts +39 -39
- package/src/config-errors.ts +7 -0
- package/src/config-file.ts +64 -8
- package/src/config.ts +605 -476
- package/src/file-selection.ts +121 -140
- package/src/git-backend.ts +832 -0
- package/src/git-config.ts +136 -0
- package/src/git-runner.ts +276 -0
- package/src/git-storage.ts +288 -0
- package/src/git-ui.ts +307 -0
- package/src/manager-helpers.ts +64 -0
- package/src/manager-ui.ts +537 -542
- package/src/paths.ts +4 -1
- package/src/s3-backend.ts +498 -0
- package/src/s3-client.ts +147 -64
- package/src/s3-credentials-ui.ts +92 -0
- package/src/secret-input.ts +199 -0
- package/src/settings-management.ts +191 -277
- package/src/settings-ui.ts +94 -115
- package/src/setup-switch.ts +150 -0
- package/src/snapshot-apply.ts +13 -7
- package/src/snapshot-codec.ts +48 -0
- package/src/snapshot-transaction.ts +3 -1
- package/src/snapshot.ts +63 -32
- package/src/storage-connections-ui.ts +308 -0
- package/src/sync-backend.ts +97 -0
- package/src/sync-format.ts +31 -33
- package/src/sync-operations.ts +912 -0
- package/src/sync-policy.ts +137 -61
- package/src/sync-setups-ui.ts +177 -0
- package/src/sync-state.ts +48 -48
- package/src/sync.ts +180 -739
- package/src/types.ts +177 -53
- package/src/webdav-backend.ts +678 -0
- package/src/webdav-client.ts +390 -0
- package/src/webdav-config.ts +92 -0
- package/src/webdav-ui.ts +421 -0
- package/src/target-switch.ts +0 -119
package/src/types.ts
CHANGED
|
@@ -1,72 +1,190 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
export interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
region?: string;
|
|
8
|
-
accessKeyId?: string;
|
|
9
|
-
secretAccessKey?: string;
|
|
1
|
+
export type StorageConnectionType = "s3" | "git" | "webdav";
|
|
2
|
+
export type OnSwitchAction = "ask-before-pull" | "pull-after-switch" | "switch-only";
|
|
3
|
+
|
|
4
|
+
export interface S3CredentialsSettings {
|
|
5
|
+
accessKeyId: string;
|
|
6
|
+
secretAccessKey: string;
|
|
10
7
|
sessionToken?: string;
|
|
8
|
+
[key: string]: unknown;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
namespace?: string;
|
|
18
|
-
autoSync?: boolean;
|
|
19
|
-
syncFiles?: unknown;
|
|
20
|
-
syncSessions?: boolean;
|
|
21
|
-
extraFiles?: unknown;
|
|
11
|
+
export interface WebDavCredentialsSettings {
|
|
12
|
+
username: string;
|
|
13
|
+
password: string;
|
|
14
|
+
[key: string]: unknown;
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
export interface
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
export interface S3StorageConnectionSettings {
|
|
18
|
+
type: "s3";
|
|
19
|
+
endpoint: string;
|
|
20
|
+
region: string;
|
|
21
|
+
credentials: S3CredentialsSettings;
|
|
22
|
+
remote?: never;
|
|
23
|
+
url?: never;
|
|
30
24
|
[key: string]: unknown;
|
|
31
25
|
}
|
|
32
26
|
|
|
33
|
-
export interface
|
|
34
|
-
|
|
27
|
+
export interface GitStorageConnectionSettings {
|
|
28
|
+
type: "git";
|
|
29
|
+
remote: string;
|
|
30
|
+
endpoint?: never;
|
|
31
|
+
region?: never;
|
|
32
|
+
credentials?: never;
|
|
33
|
+
url?: never;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface WebDavStorageConnectionSettings {
|
|
38
|
+
type: "webdav";
|
|
39
|
+
url: string;
|
|
40
|
+
credentials: WebDavCredentialsSettings;
|
|
41
|
+
endpoint?: never;
|
|
42
|
+
region?: never;
|
|
43
|
+
remote?: never;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type StorageConnectionSettings =
|
|
48
|
+
| S3StorageConnectionSettings
|
|
49
|
+
| GitStorageConnectionSettings
|
|
50
|
+
| WebDavStorageConnectionSettings;
|
|
51
|
+
|
|
52
|
+
export interface CommonSyncSetupStorageSettings {
|
|
53
|
+
connection: string;
|
|
54
|
+
path: string;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface S3SyncSetupStorageSettings extends CommonSyncSetupStorageSettings {
|
|
35
59
|
bucket: string;
|
|
60
|
+
branch?: never;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface GitSyncSetupStorageSettings extends CommonSyncSetupStorageSettings {
|
|
64
|
+
branch: string;
|
|
65
|
+
bucket?: never;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface WebDavSyncSetupStorageSettings extends CommonSyncSetupStorageSettings {
|
|
69
|
+
bucket?: never;
|
|
70
|
+
branch?: never;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type SyncSetupStorageSettings =
|
|
74
|
+
| S3SyncSetupStorageSettings
|
|
75
|
+
| GitSyncSetupStorageSettings
|
|
76
|
+
| WebDavSyncSetupStorageSettings;
|
|
77
|
+
|
|
78
|
+
export interface SyncPolicySettings {
|
|
79
|
+
include: string[];
|
|
80
|
+
automatic: boolean;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SyncSetupSettings {
|
|
85
|
+
storage: SyncSetupStorageSettings;
|
|
86
|
+
sync: SyncPolicySettings;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface PiSyncSettingsV3 {
|
|
91
|
+
version: 3;
|
|
92
|
+
activeSyncSetup?: string;
|
|
93
|
+
onSwitch: OnSwitchAction;
|
|
94
|
+
storageConnections: Record<string, StorageConnectionSettings>;
|
|
95
|
+
syncSetups: Record<string, SyncSetupSettings>;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Backend-only resolved S3 connection fields. */
|
|
100
|
+
export interface ResolvedS3StorageProfile {
|
|
101
|
+
kind: "r2" | "s3-compatible";
|
|
102
|
+
endpoint: string;
|
|
36
103
|
region: string;
|
|
37
104
|
accessKeyId: string;
|
|
38
105
|
secretAccessKey: string;
|
|
39
106
|
sessionToken?: string;
|
|
40
|
-
|
|
41
|
-
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Backend-only coordinates. `prefix` is the complete reviewed v3 storage path. */
|
|
110
|
+
export interface ResolvedS3Destination {
|
|
111
|
+
bucket: string;
|
|
42
112
|
prefix: string;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
113
|
+
/** Snapshot/wire identity; never derived from the local setup name. */
|
|
114
|
+
namespace: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface ResolvedS3Backend {
|
|
118
|
+
type: "s3";
|
|
119
|
+
profile: ResolvedS3StorageProfile;
|
|
120
|
+
destination: ResolvedS3Destination;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface ResolvedWebDavStorageProfile {
|
|
124
|
+
kind: "webdav";
|
|
125
|
+
url: string;
|
|
126
|
+
username: string;
|
|
127
|
+
password: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Backend-only coordinates. `path` is the complete reviewed v3 storage path. */
|
|
131
|
+
export interface ResolvedWebDavDestination {
|
|
132
|
+
path: string;
|
|
133
|
+
namespace: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ResolvedWebDavBackend {
|
|
137
|
+
type: "webdav";
|
|
138
|
+
profile: ResolvedWebDavStorageProfile;
|
|
139
|
+
destination: ResolvedWebDavDestination;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface ResolvedGitStorageProfile {
|
|
143
|
+
kind: "git";
|
|
144
|
+
remote: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Backend-only coordinates. `directory` is the complete reviewed v3 storage path. */
|
|
148
|
+
export interface ResolvedGitDestination {
|
|
149
|
+
branch: string;
|
|
150
|
+
directory: string;
|
|
151
|
+
namespace: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface ResolvedGitBackend {
|
|
155
|
+
type: "git";
|
|
156
|
+
profile: ResolvedGitStorageProfile;
|
|
157
|
+
destination: ResolvedGitDestination;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type ResolvedSyncBackend = ResolvedS3Backend | ResolvedWebDavBackend | ResolvedGitBackend;
|
|
161
|
+
|
|
162
|
+
export interface SyncConfig<Backend extends ResolvedSyncBackend = ResolvedS3Backend> {
|
|
163
|
+
setupName: string;
|
|
164
|
+
connectionName: string;
|
|
165
|
+
storagePath: string;
|
|
166
|
+
/** Snapshot/wire identity retained behind the settings normalization boundary. */
|
|
167
|
+
snapshotIdentity: string;
|
|
168
|
+
include: string[];
|
|
169
|
+
automatic: boolean;
|
|
170
|
+
onSwitch: OnSwitchAction;
|
|
171
|
+
backend: Backend;
|
|
51
172
|
}
|
|
52
173
|
|
|
174
|
+
export type AnySyncConfig = SyncConfig<ResolvedSyncBackend>;
|
|
175
|
+
export type CommonSyncConfig = Omit<AnySyncConfig, "backend">;
|
|
176
|
+
|
|
177
|
+
/** UI projection over a fully validated v3 setup; it is never persisted directly. */
|
|
53
178
|
export interface PartialConfig {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
storageKind
|
|
57
|
-
|
|
58
|
-
|
|
179
|
+
setupName: string;
|
|
180
|
+
connectionName: string;
|
|
181
|
+
storageKind: StorageConnectionType;
|
|
182
|
+
storagePath: string;
|
|
183
|
+
include: string[];
|
|
184
|
+
automatic: boolean;
|
|
185
|
+
onSwitch: OnSwitchAction;
|
|
59
186
|
bucket?: string;
|
|
60
|
-
|
|
61
|
-
accessKeyId?: string;
|
|
62
|
-
secretAccessKey?: string;
|
|
63
|
-
sessionToken?: string;
|
|
64
|
-
profile?: string;
|
|
65
|
-
prefix?: string;
|
|
66
|
-
autoSync?: boolean | string;
|
|
67
|
-
syncFiles?: unknown;
|
|
68
|
-
syncSessions?: boolean | string;
|
|
69
|
-
extraFiles?: unknown;
|
|
187
|
+
branch?: string;
|
|
70
188
|
}
|
|
71
189
|
|
|
72
190
|
export interface SnapshotFile {
|
|
@@ -80,6 +198,7 @@ export interface Snapshot {
|
|
|
80
198
|
id: string;
|
|
81
199
|
createdAt: string;
|
|
82
200
|
machine: string;
|
|
201
|
+
/** Backend-scoped remote identity retained in the snapshot wire format. */
|
|
83
202
|
profile: string;
|
|
84
203
|
syncSessions?: boolean;
|
|
85
204
|
files: SnapshotFile[];
|
|
@@ -105,8 +224,11 @@ export interface SyncState {
|
|
|
105
224
|
version: number;
|
|
106
225
|
profile: string;
|
|
107
226
|
lastAppliedSnapshot?: string;
|
|
227
|
+
lastRemoteRevision?: string;
|
|
108
228
|
lastRemoteEtag?: string;
|
|
109
229
|
lastFileHashes: Record<string, string>;
|
|
230
|
+
include?: string[];
|
|
231
|
+
/** Legacy state fields are read only so v3 can detect and replace stale policy state. */
|
|
110
232
|
syncFiles?: string[];
|
|
111
233
|
syncSessions?: boolean;
|
|
112
234
|
extraFiles?: string[];
|
|
@@ -126,7 +248,7 @@ export interface CommandOptions {
|
|
|
126
248
|
silent: boolean;
|
|
127
249
|
reload: boolean;
|
|
128
250
|
auto: boolean;
|
|
129
|
-
|
|
251
|
+
setup?: string;
|
|
130
252
|
signal?: AbortSignal;
|
|
131
253
|
onCommit?: () => void;
|
|
132
254
|
args: string[];
|
|
@@ -139,9 +261,11 @@ export interface CommandArgumentCompletion {
|
|
|
139
261
|
}
|
|
140
262
|
|
|
141
263
|
export interface SnapshotOptions {
|
|
264
|
+
include?: string[];
|
|
265
|
+
sessionDir?: string;
|
|
266
|
+
/** Temporary internal projections while snapshot storage remains wire-compatible. */
|
|
142
267
|
syncFiles?: string[];
|
|
143
268
|
syncSessions?: boolean;
|
|
144
|
-
sessionDir?: string;
|
|
145
269
|
extraFiles?: string[];
|
|
146
270
|
}
|
|
147
271
|
|