@alwith/module-drive 0.1.0-rc.23 → 0.1.1

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.
@@ -30,5 +30,18 @@
30
30
  "tests/resumable_upload.rs": "f8f64f21cac169ef96d3349b0676a4bbccacad5e55bd049b3b6cf66e7afda30f",
31
31
  "tests/skills.rs": "1e1e18fcddfad5bb6ebfd2fbacb5feb66157114e3dc1939bd8aedcdff6a70b98",
32
32
  "tests/sso.rs": "f95e566a55821a8d56b6e6c90cdf8f0f0cd245244f10261877f0340b6841be52"
33
- }
33
+ },
34
+ "patches": [
35
+ {
36
+ "revision": "e2719fd30",
37
+ "purpose": "Snapshot pagination and file/folder publishing",
38
+ "files": {
39
+ "src/client.rs": "8e5d739d0a4ca8148275b7b9feb204ab8ed6759897fafca8a65b718e64480a49",
40
+ "src/engine.rs": "4a6ee592b23cd1adde6c702f22576192337c3800423d8bd0f6edc013266fca45",
41
+ "src/types.rs": "57d92ba71f13511aec5ae0e55cd467b8c3d2f7a50464006d8b8562325a622383",
42
+ "tests/common/mod.rs": "6b82777321500427a5f67b0d8e1f867dc79ee199fbe4c22841ef043afdda7ab2",
43
+ "tests/engine.rs": "c0da8e937be97f39f9576c0cd51c1fc79b20c3b29a438b9d076e8ccf4ee25c08"
44
+ }
45
+ }
46
+ ]
34
47
  }
@@ -1,6 +1,17 @@
1
1
  export type AccessRequestOutcome = "submitted" | "alreadyPending";
2
2
  export type AccessRequestType = "FILE_ACCESS" | "PROJECT_JOIN";
3
- export type ArchiveStatus = {
3
+ export type ArchiveStatus = ArchiveStatus_Serialize;
4
+ export type ArchiveStatus_Deserialize = {
5
+ enabled: boolean;
6
+ syncing: boolean;
7
+ lastRunAt?: string | null;
8
+ lastUploadAt?: string | null;
9
+ synced: number;
10
+ lastUploaded: number;
11
+ lastError?: string | null;
12
+ mode?: string | null;
13
+ };
14
+ export type ArchiveStatus_Serialize = {
4
15
  enabled: boolean;
5
16
  syncing: boolean;
6
17
  lastRunAt: string | null;
@@ -31,7 +42,8 @@ export type CleanupSkipped = {
31
42
  localPath: string;
32
43
  reason: CleanupSkipReason;
33
44
  };
34
- export type ClientConfig = {
45
+ export type ClientConfig = ClientConfig_Serialize;
46
+ export type ClientConfig_Deserialize = {
35
47
  collabRelayUrl?: string | null;
36
48
  webBaseUrl?: string | null;
37
49
  serverVersion?: string | null;
@@ -41,6 +53,16 @@ export type ClientConfig = {
41
53
  [key in string]: boolean;
42
54
  };
43
55
  };
56
+ export type ClientConfig_Serialize = {
57
+ collabRelayUrl: string | null;
58
+ webBaseUrl: string | null;
59
+ serverVersion: string | null;
60
+ largeFileThresholdBytes: number | null;
61
+ maxUploadBytes: number | null;
62
+ features: {
63
+ [key in string]: boolean;
64
+ };
65
+ };
44
66
  export type CloudFolder = {
45
67
  path: string;
46
68
  folderId: RemoteId;
@@ -57,26 +79,57 @@ export type CommentContext = {
57
79
  currentUserId: RemoteId;
58
80
  isOwner: boolean;
59
81
  };
60
- export type CommentEvent = {
82
+ export type CommentEvent = CommentEvent_Serialize;
83
+ export type CommentEvent_Deserialize = {
84
+ fileId: RemoteId;
85
+ commentId: RemoteId;
86
+ action: string;
87
+ actorId?: RemoteId | null;
88
+ at?: string | null;
89
+ };
90
+ export type CommentEvent_Serialize = {
61
91
  fileId: RemoteId;
62
92
  commentId: RemoteId;
63
93
  action: string;
64
94
  actorId: RemoteId | null;
65
95
  at: string | null;
66
96
  };
67
- export type CondenseResult = {
97
+ export type CondenseResult = CondenseResult_Serialize;
98
+ export type CondenseResult_Deserialize = {
68
99
  knowledgeFileId: RemoteId;
69
100
  knowledgeTitle?: string | null;
70
101
  sourcesLinked?: number | null;
71
102
  humanUrl?: string | null;
72
103
  };
73
- export type Configuration = {
104
+ export type CondenseResult_Serialize = {
105
+ knowledgeFileId: RemoteId;
106
+ knowledgeTitle: string | null;
107
+ sourcesLinked: number | null;
108
+ humanUrl: string | null;
109
+ };
110
+ export type Configuration = Configuration_Serialize;
111
+ export type Configuration_Deserialize = {
112
+ deviceId?: string | null;
113
+ userName?: string | null;
114
+ userId?: string | null;
115
+ clientConfig?: ClientConfig_Deserialize | null;
116
+ };
117
+ export type Configuration_Serialize = {
74
118
  deviceId: string | null;
75
119
  userName: string | null;
76
120
  userId: string | null;
77
- clientConfig: ClientConfig | null;
121
+ clientConfig: ClientConfig_Serialize | null;
78
122
  };
79
- export type ConflictRecord = {
123
+ export type ConflictRecord = ConflictRecord_Serialize;
124
+ export type ConflictRecord_Deserialize = {
125
+ projectId: RemoteId;
126
+ path: string;
127
+ localPath: string;
128
+ conflictCopyPath?: string | null;
129
+ remoteUpdatedBy?: string | null;
130
+ at: string;
131
+ };
132
+ export type ConflictRecord_Serialize = {
80
133
  projectId: RemoteId;
81
134
  path: string;
82
135
  localPath: string;
@@ -84,7 +137,16 @@ export type ConflictRecord = {
84
137
  remoteUpdatedBy: string | null;
85
138
  at: string;
86
139
  };
87
- export type CreateCommentRequest = {
140
+ export type CreateCommentRequest = CreateCommentRequest_Deserialize;
141
+ export type CreateCommentRequest_Deserialize = {
142
+ body: string;
143
+ mentionedUserIds?: RemoteId[] | null;
144
+ parentId?: RemoteId | null;
145
+ quote?: string | null;
146
+ quoteOffset?: number | null;
147
+ suggestedReplacement?: string | null;
148
+ };
149
+ export type CreateCommentRequest_Serialize = {
88
150
  body: string;
89
151
  mentionedUserIds: RemoteId[] | null;
90
152
  parentId: RemoteId | null;
@@ -92,14 +154,23 @@ export type CreateCommentRequest = {
92
154
  quoteOffset: number | null;
93
155
  suggestedReplacement: string | null;
94
156
  };
95
- export type CreateProjectFromTemplateRequest = {
157
+ export type CreateProjectFromTemplateRequest = CreateProjectFromTemplateRequest_Deserialize;
158
+ export type CreateProjectFromTemplateRequest_Deserialize = {
96
159
  templateId: RemoteId;
97
160
  name: string;
98
161
  scope: ProjectScope;
99
162
  departmentId?: RemoteId | null;
100
163
  topicId?: RemoteId | null;
101
164
  };
102
- export type Department = {
165
+ export type CreateProjectFromTemplateRequest_Serialize = {
166
+ templateId: RemoteId;
167
+ name: string;
168
+ scope: ProjectScope;
169
+ departmentId: RemoteId | null;
170
+ topicId: RemoteId | null;
171
+ };
172
+ export type Department = Department_Serialize;
173
+ export type Department_Deserialize = {
103
174
  id: RemoteId;
104
175
  code?: string | null;
105
176
  name: string;
@@ -107,6 +178,14 @@ export type Department = {
107
178
  type?: string | null;
108
179
  path?: string | null;
109
180
  };
181
+ export type Department_Serialize = {
182
+ id: RemoteId;
183
+ code: string | null;
184
+ name: string;
185
+ parentId: RemoteId | null;
186
+ type: string | null;
187
+ path: string | null;
188
+ };
110
189
  export type DiskUsage = {
111
190
  totalBytes: number;
112
191
  totalFiles: number;
@@ -128,13 +207,21 @@ export type DiskUsageProject = {
128
207
  bytes: number;
129
208
  files: number;
130
209
  };
131
- export type DriveEvent = {
210
+ export type DriveEvent = DriveEvent_Serialize;
211
+ export type DriveEvent_Deserialize = {
212
+ version: number;
213
+ generation: number;
214
+ sequence: number;
215
+ payload: Payload_Deserialize;
216
+ };
217
+ export type DriveEvent_Serialize = {
132
218
  version: number;
133
219
  generation: number;
134
220
  sequence: number;
135
- payload: Payload;
221
+ payload: Payload_Serialize;
136
222
  };
137
- export type DriveRequest = {
223
+ export type DriveRequest = DriveRequest_Deserialize;
224
+ export type DriveRequest_Deserialize = {
138
225
  type: "preferences";
139
226
  } | {
140
227
  type: "archivePrivateSessions";
@@ -183,7 +270,238 @@ export type DriveRequest = {
183
270
  } | {
184
271
  type: "commentCreate";
185
272
  fileId: RemoteId;
186
- request: CreateCommentRequest;
273
+ request: CreateCommentRequest_Deserialize;
274
+ } | {
275
+ type: "commentUpdate";
276
+ commentId: RemoteId;
277
+ body: string;
278
+ } | {
279
+ type: "commentDelete";
280
+ commentId: RemoteId;
281
+ } | {
282
+ type: "commentApply";
283
+ commentId: RemoteId;
284
+ } | {
285
+ type: "commentWatch";
286
+ ownerId: string;
287
+ fileIds: RemoteId[];
288
+ } | {
289
+ type: "collabSession";
290
+ path: string;
291
+ ownerId: string;
292
+ } | {
293
+ type: "collabEnd";
294
+ path: string;
295
+ ownerId: string;
296
+ } | {
297
+ type: "condensePreflight";
298
+ projectId: RemoteId;
299
+ scopePath?: string | null;
300
+ } | {
301
+ type: "condenseStart";
302
+ projectId: RemoteId;
303
+ scopePath?: string | null;
304
+ } | {
305
+ type: "job";
306
+ jobId: RemoteId;
307
+ } | {
308
+ type: "proposedCondense";
309
+ projectId: RemoteId;
310
+ } | {
311
+ type: "approveJob";
312
+ jobId: RemoteId;
313
+ } | {
314
+ type: "cancelJob";
315
+ jobId: RemoteId;
316
+ } | {
317
+ type: "knowledgeContext";
318
+ cwd: string;
319
+ } | {
320
+ type: "skillMirrors";
321
+ } | {
322
+ type: "archiveStatus";
323
+ } | {
324
+ type: "syncProject";
325
+ projectId: RemoteId;
326
+ } | {
327
+ type: "snapshot";
328
+ } | {
329
+ type: "publishBetweenProjects";
330
+ source: string;
331
+ destination: string;
332
+ isDirectory: boolean;
333
+ } | {
334
+ type: "moveBetweenProjects";
335
+ source: string;
336
+ destination: string;
337
+ } | {
338
+ type: "login";
339
+ baseUrl: string;
340
+ token: string;
341
+ localRoot: string;
342
+ } | {
343
+ type: "ssoConfig";
344
+ baseUrl: string;
345
+ } | {
346
+ type: "ssoLogin";
347
+ baseUrl: string;
348
+ localRoot: string;
349
+ } | {
350
+ type: "resolveRootOwnership";
351
+ generation: number;
352
+ accept: boolean;
353
+ } | {
354
+ type: "logout";
355
+ } | {
356
+ type: "start";
357
+ } | {
358
+ type: "stop";
359
+ } | {
360
+ type: "maxAutoDownloadMb";
361
+ } | {
362
+ type: "setMaxAutoDownloadMb";
363
+ megabytes: number;
364
+ } | {
365
+ type: "pause";
366
+ paused: boolean;
367
+ } | {
368
+ type: "sync";
369
+ } | {
370
+ type: "roots";
371
+ } | {
372
+ type: "pin";
373
+ projectId: RemoteId;
374
+ pinned: boolean;
375
+ } | {
376
+ type: "land";
377
+ projectId: RemoteId;
378
+ } | {
379
+ type: "file";
380
+ path: string;
381
+ } | {
382
+ type: "download";
383
+ projectId: RemoteId;
384
+ path: string;
385
+ } | {
386
+ type: "confirmDeletes";
387
+ projectId: RemoteId;
388
+ } | {
389
+ type: "cancelDeletes";
390
+ projectId: RemoteId;
391
+ } | {
392
+ type: "templates";
393
+ } | {
394
+ type: "departments";
395
+ } | {
396
+ type: "createProject";
397
+ request: CreateProjectFromTemplateRequest_Deserialize;
398
+ } | {
399
+ type: "shared";
400
+ } | {
401
+ type: "failedUploads";
402
+ } | {
403
+ type: "retryUploads";
404
+ } | {
405
+ type: "reconcile";
406
+ projectId?: RemoteId | null;
407
+ } | {
408
+ type: "recheckCloudOnly";
409
+ } | {
410
+ type: "diskUsage";
411
+ limit: number;
412
+ } | {
413
+ type: "cleanupScan";
414
+ } | {
415
+ type: "cleanup";
416
+ paths: string[];
417
+ } | {
418
+ type: "ownershipGuard";
419
+ } | {
420
+ type: "syncAllPersonal";
421
+ enabled: boolean;
422
+ } | {
423
+ type: "grantTarget";
424
+ path: string;
425
+ } | {
426
+ type: "grants";
427
+ target: GrantTarget;
428
+ } | {
429
+ type: "setGrant";
430
+ target: GrantTarget;
431
+ request: SetGrantRequest;
432
+ } | {
433
+ type: "removeGrant";
434
+ target: GrantTarget;
435
+ subjectType: string;
436
+ subjectId: RemoteId;
437
+ } | {
438
+ type: "searchUsers";
439
+ query: string;
440
+ } | {
441
+ type: "searchDepartments";
442
+ query: string;
443
+ } | {
444
+ type: "requestAccess";
445
+ requestType: AccessRequestType;
446
+ targetId: RemoteId;
447
+ message?: string | null;
448
+ } | {
449
+ type: "saveVersion";
450
+ path: string;
451
+ } | {
452
+ type: "localPath";
453
+ fileId: RemoteId;
454
+ };
455
+ export type DriveRequest_Serialize = {
456
+ type: "preferences";
457
+ } | {
458
+ type: "archivePrivateSessions";
459
+ } | {
460
+ type: "setArchivePrivate";
461
+ sessionId: string;
462
+ private: boolean;
463
+ } | {
464
+ type: "setPreferences";
465
+ sessionArchive: boolean;
466
+ knowledgeInject: boolean;
467
+ } | {
468
+ type: "archiveSession";
469
+ expectedGeneration: number;
470
+ sessionId: string;
471
+ cwd: string;
472
+ title: string;
473
+ updatedAt: string;
474
+ content: string;
475
+ } | {
476
+ type: "configuration";
477
+ } | {
478
+ type: "reconfigure";
479
+ localRoot: string;
480
+ userName: string;
481
+ } | {
482
+ type: "refreshClientConfig";
483
+ } | {
484
+ type: "mcpSessionConfig";
485
+ } | {
486
+ type: "retryUpload";
487
+ projectId: RemoteId;
488
+ path: string;
489
+ } | {
490
+ type: "cloudFolders";
491
+ projectId: RemoteId;
492
+ } | {
493
+ type: "fileRemoteId";
494
+ path: string;
495
+ } | {
496
+ type: "commentContext";
497
+ path: string;
498
+ } | {
499
+ type: "comments";
500
+ fileId: RemoteId;
501
+ } | {
502
+ type: "commentCreate";
503
+ fileId: RemoteId;
504
+ request: CreateCommentRequest_Serialize;
187
505
  } | {
188
506
  type: "commentUpdate";
189
507
  commentId: RemoteId;
@@ -238,6 +556,11 @@ export type DriveRequest = {
238
556
  projectId: RemoteId;
239
557
  } | {
240
558
  type: "snapshot";
559
+ } | {
560
+ type: "publishBetweenProjects";
561
+ source: string;
562
+ destination: string;
563
+ isDirectory: boolean;
241
564
  } | {
242
565
  type: "moveBetweenProjects";
243
566
  source: string;
@@ -302,7 +625,7 @@ export type DriveRequest = {
302
625
  type: "departments";
303
626
  } | {
304
627
  type: "createProject";
305
- request: CreateProjectFromTemplateRequest;
628
+ request: CreateProjectFromTemplateRequest_Serialize;
306
629
  } | {
307
630
  type: "shared";
308
631
  } | {
@@ -360,7 +683,128 @@ export type DriveRequest = {
360
683
  type: "localPath";
361
684
  fileId: RemoteId;
362
685
  };
363
- export type DriveResponse = {
686
+ export type DriveResponse = DriveResponse_Serialize;
687
+ export type DriveResponse_Deserialize = {
688
+ type: "rootOwnershipConfirmation";
689
+ data: {
690
+ generation: number;
691
+ localRoot: string;
692
+ };
693
+ } | {
694
+ type: "archivePrivateSessions";
695
+ data: string[];
696
+ } | {
697
+ type: "preferences";
698
+ data: Preferences;
699
+ } | {
700
+ type: "configuration";
701
+ data: Configuration_Deserialize;
702
+ } | {
703
+ type: "clientConfig";
704
+ data: ClientConfig_Deserialize;
705
+ } | {
706
+ type: "mcpSessionConfig";
707
+ data?: McpSessionConfig | null;
708
+ } | {
709
+ type: "cloudFolders";
710
+ data: CloudFolder[];
711
+ } | {
712
+ type: "commentContext";
713
+ data?: CommentContext | null;
714
+ } | {
715
+ type: "comments";
716
+ data: FileComment_Deserialize[];
717
+ } | {
718
+ type: "comment";
719
+ data: FileComment_Deserialize;
720
+ } | {
721
+ type: "collabSession";
722
+ data?: CollabSession | null;
723
+ } | {
724
+ type: "unsynced";
725
+ data: UnsyncedSummary;
726
+ } | {
727
+ type: "job";
728
+ data: Job_Deserialize;
729
+ } | {
730
+ type: "jobs";
731
+ data: Job_Deserialize[];
732
+ } | {
733
+ type: "text";
734
+ data?: string | null;
735
+ } | {
736
+ type: "skillMirrors";
737
+ data: SkillMirror_Deserialize[];
738
+ } | {
739
+ type: "archiveStatus";
740
+ data: ArchiveStatus_Deserialize;
741
+ } | {
742
+ type: "count";
743
+ data: number;
744
+ } | {
745
+ type: "maxAutoDownloadMb";
746
+ data: number;
747
+ } | {
748
+ type: "snapshot";
749
+ data: Snapshot_Deserialize;
750
+ } | {
751
+ type: "ssoConfig";
752
+ data: SsoConfig_Deserialize;
753
+ } | {
754
+ type: "roots";
755
+ data: RootInfo_Deserialize[];
756
+ } | {
757
+ type: "root";
758
+ data: RootInfo_Deserialize;
759
+ } | {
760
+ type: "file";
761
+ data?: FileStateEvent_Deserialize | null;
762
+ } | {
763
+ type: "templates";
764
+ data: ProjectTemplate_Deserialize[];
765
+ } | {
766
+ type: "departments";
767
+ data: Department_Deserialize[];
768
+ } | {
769
+ type: "shared";
770
+ data: SharedItem_Deserialize[];
771
+ } | {
772
+ type: "failedUploads";
773
+ data: FailedUpload[];
774
+ } | {
775
+ type: "diskUsage";
776
+ data: DiskUsage;
777
+ } | {
778
+ type: "cleanup";
779
+ data: CleanupReport;
780
+ } | {
781
+ type: "ownershipGuard";
782
+ data: OwnershipGuard;
783
+ } | {
784
+ type: "grantTarget";
785
+ data?: GrantTarget | null;
786
+ } | {
787
+ type: "grants";
788
+ data: GrantList_Deserialize;
789
+ } | {
790
+ type: "grantWrite";
791
+ data: GrantWriteOutcome_Deserialize;
792
+ } | {
793
+ type: "users";
794
+ data: UserBrief_Deserialize[];
795
+ } | {
796
+ type: "accessRequest";
797
+ data: AccessRequestOutcome;
798
+ } | {
799
+ type: "id";
800
+ data?: RemoteId | null;
801
+ } | {
802
+ type: "path";
803
+ data?: string | null;
804
+ } | {
805
+ type: "done";
806
+ };
807
+ export type DriveResponse_Serialize = {
364
808
  type: "rootOwnershipConfirmation";
365
809
  data: {
366
810
  generation: number;
@@ -374,10 +818,10 @@ export type DriveResponse = {
374
818
  data: Preferences;
375
819
  } | {
376
820
  type: "configuration";
377
- data: Configuration;
821
+ data: Configuration_Serialize;
378
822
  } | {
379
823
  type: "clientConfig";
380
- data: ClientConfig;
824
+ data: ClientConfig_Serialize;
381
825
  } | {
382
826
  type: "mcpSessionConfig";
383
827
  data: McpSessionConfig | null;
@@ -389,10 +833,10 @@ export type DriveResponse = {
389
833
  data: CommentContext | null;
390
834
  } | {
391
835
  type: "comments";
392
- data: FileComment[];
836
+ data: FileComment_Serialize[];
393
837
  } | {
394
838
  type: "comment";
395
- data: FileComment;
839
+ data: FileComment_Serialize;
396
840
  } | {
397
841
  type: "collabSession";
398
842
  data: CollabSession | null;
@@ -401,19 +845,19 @@ export type DriveResponse = {
401
845
  data: UnsyncedSummary;
402
846
  } | {
403
847
  type: "job";
404
- data: Job;
848
+ data: Job_Serialize;
405
849
  } | {
406
850
  type: "jobs";
407
- data: Job[];
851
+ data: Job_Serialize[];
408
852
  } | {
409
853
  type: "text";
410
854
  data: string | null;
411
855
  } | {
412
856
  type: "skillMirrors";
413
- data: SkillMirror[];
857
+ data: SkillMirror_Serialize[];
414
858
  } | {
415
859
  type: "archiveStatus";
416
- data: ArchiveStatus;
860
+ data: ArchiveStatus_Serialize;
417
861
  } | {
418
862
  type: "count";
419
863
  data: number;
@@ -422,28 +866,28 @@ export type DriveResponse = {
422
866
  data: number;
423
867
  } | {
424
868
  type: "snapshot";
425
- data: Snapshot;
869
+ data: Snapshot_Serialize;
426
870
  } | {
427
871
  type: "ssoConfig";
428
- data: SsoConfig;
872
+ data: SsoConfig_Serialize;
429
873
  } | {
430
874
  type: "roots";
431
- data: RootInfo[];
875
+ data: RootInfo_Serialize[];
432
876
  } | {
433
877
  type: "root";
434
- data: RootInfo;
878
+ data: RootInfo_Serialize;
435
879
  } | {
436
880
  type: "file";
437
- data: FileStateEvent | null;
881
+ data: FileStateEvent_Serialize | null;
438
882
  } | {
439
883
  type: "templates";
440
- data: ProjectTemplate[];
884
+ data: ProjectTemplate_Serialize[];
441
885
  } | {
442
886
  type: "departments";
443
- data: Department[];
887
+ data: Department_Serialize[];
444
888
  } | {
445
889
  type: "shared";
446
- data: SharedItem[];
890
+ data: SharedItem_Serialize[];
447
891
  } | {
448
892
  type: "failedUploads";
449
893
  data: FailedUpload[];
@@ -461,13 +905,13 @@ export type DriveResponse = {
461
905
  data: GrantTarget | null;
462
906
  } | {
463
907
  type: "grants";
464
- data: GrantList;
908
+ data: GrantList_Serialize;
465
909
  } | {
466
910
  type: "grantWrite";
467
- data: GrantWriteOutcome;
911
+ data: GrantWriteOutcome_Serialize;
468
912
  } | {
469
913
  type: "users";
470
- data: UserBrief[];
914
+ data: UserBrief_Serialize[];
471
915
  } | {
472
916
  type: "accessRequest";
473
917
  data: AccessRequestOutcome;
@@ -506,7 +950,8 @@ export type FailedUpload = {
506
950
  nextAttemptAt: string;
507
951
  retryable: boolean;
508
952
  };
509
- export type FileComment = {
953
+ export type FileComment = FileComment_Serialize;
954
+ export type FileComment_Deserialize = {
510
955
  id: RemoteId;
511
956
  fileId: RemoteId;
512
957
  parentId?: RemoteId | null;
@@ -517,42 +962,66 @@ export type FileComment = {
517
962
  quote?: string | null;
518
963
  quoteOffset?: number | null;
519
964
  isAi?: boolean;
520
- mentions?: UserBrief[] | null;
965
+ mentions?: UserBrief_Deserialize[] | null;
521
966
  deleted?: boolean;
522
967
  createdAt: string;
523
968
  updatedAt?: string | null;
524
- replies?: FileComment[];
969
+ replies?: FileComment_Deserialize[];
525
970
  suggestedReplacement?: string | null;
526
971
  appliedAt?: string | null;
527
- appliedBy?: UserBrief | null;
972
+ appliedBy?: UserBrief_Deserialize | null;
528
973
  appliedVersionId?: RemoteId | null;
529
974
  };
975
+ export type FileComment_Serialize = {
976
+ id: RemoteId;
977
+ fileId: RemoteId;
978
+ parentId: RemoteId | null;
979
+ authorId: RemoteId;
980
+ authorName: string | null;
981
+ authorEmployeeNo: string | null;
982
+ body: string | null;
983
+ quote: string | null;
984
+ quoteOffset: number | null;
985
+ isAi: boolean;
986
+ mentions: UserBrief_Serialize[] | null;
987
+ deleted: boolean;
988
+ createdAt: string;
989
+ updatedAt: string | null;
990
+ replies: FileComment_Serialize[];
991
+ suggestedReplacement: string | null;
992
+ appliedAt: string | null;
993
+ appliedBy: UserBrief_Serialize | null;
994
+ appliedVersionId: RemoteId | null;
995
+ };
530
996
  export type FileState = "synced" | "pending" | "uploading" | "conflict" | "cloudOnly" | "ignored" | "skippedTooLarge" | "notDownloaded" | "downloading" | "forbidden" | "readOnly" | "error" | "collab";
531
- export type FileStateEvent = {
997
+ export type FileStateEvent = FileStateEvent_Serialize;
998
+ export type FileStateEvent_Deserialize = {
532
999
  projectId: RemoteId;
533
1000
  path: string;
534
1001
  localPath: string;
535
1002
  state: FileState;
536
1003
  size?: number;
537
1004
  };
538
- export type Grant = {
539
- subjectType: string;
540
- subjectId: RemoteId;
541
- subjectDisplay?: string | null;
542
- level: GrantLevel;
543
- actions?: string[];
544
- source?: GrantSource | null;
545
- sourceResourceId?: RemoteId | null;
546
- sourceDisplay?: string | null;
547
- inherited?: boolean;
548
- editable?: boolean;
1005
+ export type FileStateEvent_Serialize = {
1006
+ projectId: RemoteId;
1007
+ path: string;
1008
+ localPath: string;
1009
+ state: FileState;
1010
+ size: number;
549
1011
  };
1012
+ export type Grant = Grant_Serialize;
550
1013
  export type GrantLevel = "VIEW" | "EDIT" | "MANAGE" | "CUSTOM";
551
- export type GrantList = {
552
- grants?: Grant[];
553
- implicit?: ImplicitGrant[];
1014
+ export type GrantList = GrantList_Serialize;
1015
+ export type GrantList_Deserialize = {
1016
+ grants?: Grant_Deserialize[];
1017
+ implicit?: ImplicitGrant_Deserialize[];
554
1018
  callerLevel?: GrantLevel | null;
555
1019
  };
1020
+ export type GrantList_Serialize = {
1021
+ grants: Grant_Serialize[];
1022
+ implicit: ImplicitGrant_Serialize[];
1023
+ callerLevel: GrantLevel | null;
1024
+ };
556
1025
  export type GrantResourceKind = "FILE" | "FOLDER";
557
1026
  export type GrantSource = "FILE" | "FOLDER" | "SPACE";
558
1027
  export type GrantSubjectType = "USER" | "DEPT" | "ALL";
@@ -560,27 +1029,76 @@ export type GrantTarget = {
560
1029
  kind: GrantResourceKind;
561
1030
  id: RemoteId;
562
1031
  };
563
- export type GrantWriteOutcome = {
1032
+ export type GrantWriteOutcome = GrantWriteOutcome_Serialize;
1033
+ export type GrantWriteOutcome_Deserialize = {
1034
+ kind: "applied";
1035
+ list: GrantList_Deserialize;
1036
+ } | {
1037
+ kind: "inherited";
1038
+ inheritedFrom: InheritedFrom_Deserialize;
1039
+ } | {
1040
+ kind: "custom";
1041
+ };
1042
+ export type GrantWriteOutcome_Serialize = {
564
1043
  kind: "applied";
565
- list: GrantList;
1044
+ list: GrantList_Serialize;
566
1045
  } | {
567
1046
  kind: "inherited";
568
- inheritedFrom: InheritedFrom;
1047
+ inheritedFrom: InheritedFrom_Serialize;
569
1048
  } | {
570
1049
  kind: "custom";
571
1050
  };
572
- export type ImplicitGrant = {
1051
+ export type Grant_Deserialize = {
1052
+ subjectType: string;
1053
+ subjectId: RemoteId;
1054
+ subjectDisplay?: string | null;
1055
+ level: GrantLevel;
1056
+ actions?: string[];
1057
+ source?: GrantSource | null;
1058
+ sourceResourceId?: RemoteId | null;
1059
+ sourceDisplay?: string | null;
1060
+ inherited?: boolean;
1061
+ editable?: boolean;
1062
+ };
1063
+ export type Grant_Serialize = {
1064
+ subjectType: string;
1065
+ subjectId: RemoteId;
1066
+ subjectDisplay: string | null;
1067
+ level: GrantLevel;
1068
+ actions: string[];
1069
+ source: GrantSource | null;
1070
+ sourceResourceId: RemoteId | null;
1071
+ sourceDisplay: string | null;
1072
+ inherited: boolean;
1073
+ editable: boolean;
1074
+ };
1075
+ export type ImplicitGrant = ImplicitGrant_Serialize;
1076
+ export type ImplicitGrant_Deserialize = {
573
1077
  subjectDisplay?: string | null;
574
1078
  level: GrantLevel;
575
1079
  reason?: string | null;
576
1080
  };
577
- export type InheritedFrom = {
1081
+ export type ImplicitGrant_Serialize = {
1082
+ subjectDisplay: string | null;
1083
+ level: GrantLevel;
1084
+ reason: string | null;
1085
+ };
1086
+ export type InheritedFrom = InheritedFrom_Serialize;
1087
+ export type InheritedFrom_Deserialize = {
578
1088
  source?: GrantSource | null;
579
1089
  resourceId?: RemoteId | null;
580
1090
  projectKey?: string | null;
581
1091
  display?: string | null;
582
1092
  };
583
- export type Job = {
1093
+ export type InheritedFrom_Serialize = {
1094
+ source: GrantSource | null;
1095
+ resourceId: RemoteId | null;
1096
+ projectKey: string | null;
1097
+ display: string | null;
1098
+ };
1099
+ export type Job = Job_Serialize;
1100
+ export type JobStatus = "PENDING" | "CLAIMED" | "RUNNING" | "SUCCEEDED" | "FAILED" | "CANCELLED" | "PROPOSED";
1101
+ export type Job_Deserialize = {
584
1102
  id: RemoteId;
585
1103
  type?: string | null;
586
1104
  status: JobStatus;
@@ -588,9 +1106,18 @@ export type Job = {
588
1106
  progress?: number | null;
589
1107
  message?: string | null;
590
1108
  error?: string | null;
591
- result?: CondenseResult | null;
1109
+ result?: CondenseResult_Deserialize | null;
1110
+ };
1111
+ export type Job_Serialize = {
1112
+ id: RemoteId;
1113
+ type: string | null;
1114
+ status: JobStatus;
1115
+ projectId: RemoteId | null;
1116
+ progress: number | null;
1117
+ message: string | null;
1118
+ error: string | null;
1119
+ result: CondenseResult_Serialize | null;
592
1120
  };
593
- export type JobStatus = "PENDING" | "CLAIMED" | "RUNNING" | "SUCCEEDED" | "FAILED" | "CANCELLED" | "PROPOSED";
594
1121
  export type McpHeader = {
595
1122
  name: string;
596
1123
  value: string;
@@ -605,24 +1132,55 @@ export type OwnershipGuard = {
605
1132
  syncAllPersonal: boolean;
606
1133
  active: boolean;
607
1134
  };
608
- export type Payload = {
1135
+ export type Payload = Payload_Serialize;
1136
+ export type Payload_Deserialize = {
1137
+ type: "snapshot";
1138
+ data: Snapshot_Deserialize;
1139
+ } | {
1140
+ type: "status";
1141
+ data: StatusSnapshot_Deserialize;
1142
+ } | {
1143
+ type: "file";
1144
+ data: FileStateEvent_Deserialize;
1145
+ } | {
1146
+ type: "project";
1147
+ data: ProjectProgress_Deserialize;
1148
+ } | {
1149
+ type: "conflict";
1150
+ data: ConflictRecord_Deserialize;
1151
+ } | {
1152
+ type: "readOnly";
1153
+ data: ReadOnlyChange_Deserialize;
1154
+ } | {
1155
+ type: "changed";
1156
+ data: string[];
1157
+ } | {
1158
+ type: "reconcile";
1159
+ } | {
1160
+ type: "comment";
1161
+ data: CommentEvent_Deserialize;
1162
+ } | {
1163
+ type: "error";
1164
+ data: string;
1165
+ };
1166
+ export type Payload_Serialize = {
609
1167
  type: "snapshot";
610
- data: Snapshot;
1168
+ data: Snapshot_Serialize;
611
1169
  } | {
612
1170
  type: "status";
613
- data: StatusSnapshot;
1171
+ data: StatusSnapshot_Serialize;
614
1172
  } | {
615
1173
  type: "file";
616
- data: FileStateEvent;
1174
+ data: FileStateEvent_Serialize;
617
1175
  } | {
618
1176
  type: "project";
619
- data: ProjectProgress;
1177
+ data: ProjectProgress_Serialize;
620
1178
  } | {
621
1179
  type: "conflict";
622
- data: ConflictRecord;
1180
+ data: ConflictRecord_Serialize;
623
1181
  } | {
624
1182
  type: "readOnly";
625
- data: ReadOnlyChange;
1183
+ data: ReadOnlyChange_Serialize;
626
1184
  } | {
627
1185
  type: "changed";
628
1186
  data: string[];
@@ -630,7 +1188,7 @@ export type Payload = {
630
1188
  type: "reconcile";
631
1189
  } | {
632
1190
  type: "comment";
633
- data: CommentEvent;
1191
+ data: CommentEvent_Serialize;
634
1192
  } | {
635
1193
  type: "error";
636
1194
  data: string;
@@ -646,7 +1204,17 @@ export type Preferences = {
646
1204
  };
647
1205
  export type ProjectKind = "MATERIAL" | "KNOWLEDGE" | "SKILL";
648
1206
  export type ProjectPhase = "queued" | "syncing" | "done" | "failed";
649
- export type ProjectProgress = {
1207
+ export type ProjectProgress = ProjectProgress_Serialize;
1208
+ export type ProjectProgress_Deserialize = {
1209
+ projectId: RemoteId;
1210
+ phase: ProjectPhase;
1211
+ done: number;
1212
+ total: number;
1213
+ failed: number;
1214
+ message?: string | null;
1215
+ at: string;
1216
+ };
1217
+ export type ProjectProgress_Serialize = {
650
1218
  projectId: RemoteId;
651
1219
  phase: ProjectPhase;
652
1220
  done: number;
@@ -656,7 +1224,8 @@ export type ProjectProgress = {
656
1224
  at: string;
657
1225
  };
658
1226
  export type ProjectScope = "PERSONAL" | "DEPT" | "TEAM" | "COMPANY";
659
- export type ProjectTemplate = {
1227
+ export type ProjectTemplate = ProjectTemplate_Serialize;
1228
+ export type ProjectTemplate_Deserialize = {
660
1229
  id: RemoteId;
661
1230
  code?: string | null;
662
1231
  name: string;
@@ -665,7 +1234,24 @@ export type ProjectTemplate = {
665
1234
  icon?: string | null;
666
1235
  builtin?: boolean;
667
1236
  };
668
- export type ReadOnlyChange = {
1237
+ export type ProjectTemplate_Serialize = {
1238
+ id: RemoteId;
1239
+ code: string | null;
1240
+ name: string;
1241
+ description: string | null;
1242
+ kind: string | null;
1243
+ icon: string | null;
1244
+ builtin: boolean;
1245
+ };
1246
+ export type ReadOnlyChange = ReadOnlyChange_Serialize;
1247
+ export type ReadOnlyChange_Deserialize = {
1248
+ projectId: RemoteId;
1249
+ path: string;
1250
+ localPath: string;
1251
+ name: string;
1252
+ fileId?: RemoteId | null;
1253
+ };
1254
+ export type ReadOnlyChange_Serialize = {
669
1255
  projectId: RemoteId;
670
1256
  path: string;
671
1257
  localPath: string;
@@ -673,7 +1259,31 @@ export type ReadOnlyChange = {
673
1259
  fileId: RemoteId | null;
674
1260
  };
675
1261
  export type RemoteId = number | string;
676
- export type RootInfo = {
1262
+ export type RootInfo = RootInfo_Serialize;
1263
+ export type RootInfo_Deserialize = {
1264
+ projectId: RemoteId;
1265
+ projectKey: string;
1266
+ name: string;
1267
+ kind: ProjectKind;
1268
+ scope: ProjectScope;
1269
+ deptName?: string | null;
1270
+ drivePath: string;
1271
+ node?: string | null;
1272
+ container?: string | null;
1273
+ nodePath?: string | null;
1274
+ skillsPath?: string | null;
1275
+ syncEnabled: boolean;
1276
+ canWrite: boolean;
1277
+ cloudOnly: boolean;
1278
+ cursor?: string | null;
1279
+ pinned: boolean;
1280
+ departmentId?: RemoteId | null;
1281
+ ownerId?: RemoteId | null;
1282
+ isMine?: boolean | null;
1283
+ localPath: string;
1284
+ selected: boolean;
1285
+ };
1286
+ export type RootInfo_Serialize = {
677
1287
  projectId: RemoteId;
678
1288
  projectKey: string;
679
1289
  name: string;
@@ -701,7 +1311,8 @@ export type SetGrantRequest = {
701
1311
  subjectId: RemoteId;
702
1312
  level: GrantLevel;
703
1313
  };
704
- export type SharedItem = {
1314
+ export type SharedItem = SharedItem_Serialize;
1315
+ export type SharedItem_Deserialize = {
705
1316
  resourceType: GrantResourceKind;
706
1317
  resourceId: RemoteId;
707
1318
  name: string;
@@ -713,7 +1324,31 @@ export type SharedItem = {
713
1324
  folderPath?: string | null;
714
1325
  localPath?: string | null;
715
1326
  };
716
- export type SkillMirror = {
1327
+ export type SharedItem_Serialize = {
1328
+ resourceType: GrantResourceKind;
1329
+ resourceId: RemoteId;
1330
+ name: string;
1331
+ projectId: RemoteId | null;
1332
+ projectName: string | null;
1333
+ level: GrantLevel;
1334
+ grantedByName: string | null;
1335
+ grantedAt: string | null;
1336
+ folderPath: string | null;
1337
+ localPath: string | null;
1338
+ };
1339
+ export type SkillMirror = SkillMirror_Serialize;
1340
+ export type SkillMirror_Deserialize = {
1341
+ projectId: RemoteId;
1342
+ projectKey: string;
1343
+ name: string;
1344
+ autoInstalled: boolean;
1345
+ pinned: boolean;
1346
+ deptName?: string | null;
1347
+ localPath: string;
1348
+ skillsPath?: string | null;
1349
+ installed: boolean;
1350
+ };
1351
+ export type SkillMirror_Serialize = {
717
1352
  projectId: RemoteId;
718
1353
  projectKey: string;
719
1354
  name: string;
@@ -724,7 +1359,24 @@ export type SkillMirror = {
724
1359
  skillsPath: string | null;
725
1360
  installed: boolean;
726
1361
  };
727
- export type Snapshot = {
1362
+ export type Snapshot = Snapshot_Serialize;
1363
+ export type Snapshot_Deserialize = {
1364
+ version: number;
1365
+ generation: number;
1366
+ sequence: number;
1367
+ configured: boolean;
1368
+ running: boolean;
1369
+ baseUrl: string;
1370
+ localRoot: string;
1371
+ webBaseUrl?: string | null;
1372
+ status?: StatusSnapshot_Deserialize | null;
1373
+ roots: RootInfo_Deserialize[];
1374
+ pendingDeletes: PendingDeletes[];
1375
+ files: FileStateEvent_Deserialize[];
1376
+ projects: ProjectProgress_Deserialize[];
1377
+ error?: string | null;
1378
+ };
1379
+ export type Snapshot_Serialize = {
728
1380
  version: number;
729
1381
  generation: number;
730
1382
  sequence: number;
@@ -733,14 +1385,15 @@ export type Snapshot = {
733
1385
  baseUrl: string;
734
1386
  localRoot: string;
735
1387
  webBaseUrl: string | null;
736
- status: StatusSnapshot | null;
737
- roots: RootInfo[];
1388
+ status: StatusSnapshot_Serialize | null;
1389
+ roots: RootInfo_Serialize[];
738
1390
  pendingDeletes: PendingDeletes[];
739
- files: FileStateEvent[];
740
- projects: ProjectProgress[];
1391
+ files: FileStateEvent_Serialize[];
1392
+ projects: ProjectProgress_Serialize[];
741
1393
  error: string | null;
742
1394
  };
743
- export type SsoConfig = {
1395
+ export type SsoConfig = SsoConfig_Serialize;
1396
+ export type SsoConfig_Deserialize = {
744
1397
  enabled: boolean;
745
1398
  issuer?: string | null;
746
1399
  clientId?: string | null;
@@ -749,20 +1402,49 @@ export type SsoConfig = {
749
1402
  redirectUris?: string[];
750
1403
  scopes?: string[];
751
1404
  };
752
- export type StatusSnapshot = {
1405
+ export type SsoConfig_Serialize = {
1406
+ enabled: boolean;
1407
+ issuer: string | null;
1408
+ clientId: string | null;
1409
+ authorizationEndpoint: string | null;
1410
+ tokenEndpoint: string | null;
1411
+ redirectUris: string[];
1412
+ scopes: string[];
1413
+ };
1414
+ export type StatusSnapshot = StatusSnapshot_Serialize;
1415
+ export type StatusSnapshot_Deserialize = {
753
1416
  state: EngineState;
754
1417
  pending: number;
755
1418
  uploading: number;
756
1419
  downloading: number;
757
1420
  synced: number;
758
1421
  failed: number;
759
- conflicts: ConflictRecord[];
760
- errors: SyncError[];
1422
+ conflicts: ConflictRecord_Deserialize[];
1423
+ errors: SyncError_Deserialize[];
1424
+ lastSyncAt?: string | null;
1425
+ pushConnected: boolean;
1426
+ };
1427
+ export type StatusSnapshot_Serialize = {
1428
+ state: EngineState;
1429
+ pending: number;
1430
+ uploading: number;
1431
+ downloading: number;
1432
+ synced: number;
1433
+ failed: number;
1434
+ conflicts: ConflictRecord_Serialize[];
1435
+ errors: SyncError_Serialize[];
761
1436
  lastSyncAt: string | null;
762
1437
  pushConnected: boolean;
763
1438
  };
764
1439
  export type SyncDirection = "upload" | "download";
765
- export type SyncError = {
1440
+ export type SyncError = SyncError_Serialize;
1441
+ export type SyncError_Deserialize = {
1442
+ projectId?: RemoteId | null;
1443
+ path?: string | null;
1444
+ message: string;
1445
+ at: string;
1446
+ };
1447
+ export type SyncError_Serialize = {
766
1448
  projectId: RemoteId | null;
767
1449
  path: string | null;
768
1450
  message: string;
@@ -773,8 +1455,14 @@ export type UnsyncedSummary = {
773
1455
  failed: number;
774
1456
  paths: string[];
775
1457
  };
776
- export type UserBrief = {
1458
+ export type UserBrief = UserBrief_Serialize;
1459
+ export type UserBrief_Deserialize = {
777
1460
  id: RemoteId;
778
1461
  employeeNo?: string | null;
779
1462
  name?: string | null;
780
1463
  };
1464
+ export type UserBrief_Serialize = {
1465
+ id: RemoteId;
1466
+ employeeNo: string | null;
1467
+ name: string | null;
1468
+ };
package/dist/launcher.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as p,Fragment as G}from"react/jsx-runtime";import{useEffect as B,useMemo as H,useRef as K,useState as m}from"react";import{containerKey as Y,groupsOf as J,isBrowsable as _,rowStatusOf as X}from"./browse.js";import{collectDriveEntries as Z,filterDriveEntries as ee}from"./global-search.js";import{DriveIcon as F}from"./icons.js";import{driveTranslator as R}from"./locales.js";import{DriveNotice as V}from"./notifications.js";import{DrivePinnedDocs as ne}from"./pinned.js";import{togglePinned as te}from"./pinned-docs.js";import{DriveChoice as W,DriveMenu as A,DriveModal as re,requireHost as L,useDrive as U,useDriveAction as M}from"./ui.js";function ye(n){let{controller:s,controls:g,host:c,locale:O="en",onOpenSettings:b}=n,{Button:P}=g,{snapshot:u}=U(s),{busy:h,error:f,run:w}=M(),[S,k]=m(!1),[D,a]=m(null),[T,j]=m(null),[N,x]=m([]),[I,y]=m(null),d=R(O);B(()=>{if(x([]),a(null),y(null),!u?.running)return;let r=!0;return Promise.all([s.request({type:"ownershipGuard"}),s.request({type:"shared"})]).then(([i,v])=>{if(i.type!=="ownershipGuard"||v.type!=="shared")throw Error("Invalid Drive launcher response");if(r)a(i.data),x(v.data),y(null)}).catch((i)=>{if(r)y(String(i))}),()=>{r=!1}},[s,u?.generation,u?.running]);let o=u?.webBaseUrl?.replace(/\/+$/,""),q=async(r)=>{let i=L(c),v=u?.roots.find((E)=>String(E.projectId)===String(r.projectId)),l=async()=>{if(!o)throw Error(d("shared.notInDrive",{name:r.name}));await i.onOpenExternal(r.resourceType==="FILE"?`${o}/file/${encodeURIComponent(String(r.resourceId))}`:`${o}/shared`)};if(!v){await l();return}if(await s.request({type:"land",projectId:v.projectId}),r.localPath&&await i.pathExists(r.localPath)){await i.onOpenEntry({path:r.localPath,isDirectory:r.resourceType==="FOLDER"});return}if(r.resourceType==="FILE"){let E=await s.request({type:"localPath",fileId:r.resourceId});if(E.type!=="path")throw Error("Invalid Drive file path response");if(E.data&&await i.pathExists(E.data)){await i.onOpenEntry({path:E.data,isDirectory:!1});return}await l();return}let t=r.folderPath?`${v.localPath}/${r.folderPath}`:null;if(t&&await i.pathExists(t)){await i.onOpenEntry({path:t,isDirectory:!0});return}throw await i.onOpenEntry({path:v.localPath,isDirectory:!0}),Error(d("shared.folderMissing",{name:r.name}))};return p(G,{children:[p("header",{className:"alwith-drive-toolbar",children:[e("strong",{children:d("title")}),p("div",{className:"alwith-drive-actions",children:[e(A,{controls:g,label:d("panel.new"),items:[{label:d("newProject.title"),onSelect:()=>k(!0)},...o?[{label:d("panel.importFromFeishu"),onSelect:()=>w(()=>L(c).onOpenExternal(`${o}/admin/mirrors`))}]:[]],children:e(F,{name:"plus"})}),e(A,{controls:g,label:d("panel.more"),items:[{label:d("panel.refresh"),disabled:h,onSelect:()=>w(()=>s.request({type:"sync"}))},...o?[{label:d("panel.openWeb"),onSelect:()=>w(()=>L(c).onOpenExternal(o))},{label:d("panel.importFromFeishu"),onSelect:()=>w(()=>L(c).onOpenExternal(`${o}/admin/mirrors`))}]:[],...b?[{label:d("openSettings"),onSelect:b}]:[]]})]})]}),e(oe,{...n}),e(V,{message:f||I}),D?.active&&p("aside",{className:"alwith-drive-notice",children:[e("p",{children:d("panel.guard.notice",{count:D.unknownPersonalRoots})}),e(P,{variant:"ghost",disabled:h,onClick:()=>w(async()=>{if(await n.confirm(d("panel.guard.confirmDesc",{count:D.unknownPersonalRoots})))await s.request({type:"syncAllPersonal",enabled:!0}),a({...D,active:!1,syncAllPersonal:!0})}),children:d("panel.guard.syncAll")})]}),p("div",{className:"alwith-drive-navigation",children:[c&&e(ne,{controller:s,onOpenProject:n.onOpenProject,host:c,controls:g,locale:O,generation:u?.generation}),N.length>0&&p("details",{open:!0,className:"alwith-drive-group",children:[p("summary",{children:[d("shared.title")," ",e("span",{children:N.length})]}),N.map((r)=>{let i=`${r.resourceType}:${r.resourceId}`,v=()=>w(async()=>{j(i);try{await q(r)}finally{j(null)}});return e(A,{controls:g,context:!0,label:r.name,items:[{label:d("shared.open"),onSelect:v,disabled:h},...o?[{label:d("shared.openWeb"),onSelect:()=>w(()=>L(c).onOpenExternal(`${o}/shared`))}]:[]],children:p(P,{variant:"ghost",className:"alwith-drive-nav-open",disabled:h,title:d("shared.rowTitle",{name:r.name,project:r.projectName??"",by:r.grantedByName??""}),onClick:v,children:[e(F,{name:T===i?"loading":r.resourceType==="FOLDER"?"folder":"file"}),e("span",{children:r.name}),e("small",{children:d(`grants.level.${r.level}`)})]})},i)})]}),J(u?.roots??[]).map((r)=>e(ae,{...n,group:r},r.nodePath??r.legacy)),!(u?.roots??[]).some(_)&&e("p",{children:d("panel.empty")})]}),S&&e(se,{...n,onClose:()=>k(!1)})]})}function ae({group:n,...s}){let[g,c]=m(n.items.length<=30),[O,b]=m(g),[P,u]=m(""),h=R(s.locale),f=n.legacy==="shared",w=f?n.items.filter((a)=>a.scope==="PERSONAL"):[],S=f?n.items.filter((a)=>a.scope!=="PERSONAL"):n.items,k=S.filter((a)=>a.name.toLowerCase().includes(P.trim().toLowerCase())),{Input:D}=s.controls;return p("details",{className:"alwith-drive-group",open:g,onToggle:(a)=>{if(c(a.currentTarget.open),a.currentTarget.open)b(!0)},children:[p("summary",{children:[n.label??h(`panel.groups.${n.legacy??"shared"}`),e("span",{children:n.items.length})]}),O&&p(G,{children:[S.length>30&&e(D,{placeholder:h("panel.filter"),"aria-label":h("panel.filter"),value:P,onChange:(a)=>u(a.target.value)}),k.map((a)=>e(z,{...s,root:a},String(a.projectId))),!k.length&&!w.length&&e("p",{children:h("panel.filterEmpty")}),w.length>0&&e(le,{...s,roots:w})]})]})}function le({roots:n,...s}){let[g,c]=m(""),[O,b]=m(!1),{Input:P}=s.controls,u=R(s.locale);return p("details",{className:"alwith-drive-group",onToggle:(h)=>{if(h.currentTarget.open)b(!0)},children:[p("summary",{children:[u("panel.groups.otherPersonal"),e("span",{children:n.length})]}),O&&p(G,{children:[e(P,{"aria-label":u("panel.filter"),placeholder:u("panel.filter"),value:g,onChange:(h)=>c(h.target.value)}),n.filter((h)=>h.name.toLowerCase().includes(g.toLowerCase())).map((h)=>e(z,{...s,root:h},String(h.projectId)))]})]})}function z({root:n,controller:s,controls:g,host:c,onOpenProject:O,currentProject:b,locale:P}){let{Button:u}=g,{snapshot:h}=U(s),{busy:f,error:w,run:S}=M(),[k,D]=m(!1),a=R(P),T=h?.projects.find((y)=>String(y.projectId)===String(n.projectId)),j=k?X(T,f):null,N=()=>S(async()=>{if(D(!0),c&&await c.pathExists(n.localPath)&&(await c.readDirectory(n.localPath)).length>0){await O(n),D(!1);return}let y=await s.request({type:"land",projectId:n.projectId});if(y.type!=="root")throw Error("Drive did not return a landed project");await O(y.data),D(!1)}),x=h?.webBaseUrl?.replace(/\/+$/,""),I=[{label:a("panel.open"),onSelect:N},{label:a("condense.action"),disabled:f,onSelect:()=>S(()=>{let y=L(c);if(!y.onCondense)throw Error("Knowledge integration is unavailable");return y.onCondense(n)})},{label:a("pinned.pin"),onSelect:()=>S(()=>L(c).onPinnedDocsChange(te(L(c).pinnedDocs,{path:n.localPath,name:n.name,kind:"dir"})))},...n.cursor!==null?[{label:a("panel.reveal"),onSelect:()=>S(()=>L(c).onRevealPath(n.localPath))}]:[],...x?[{label:a("panel.openWeb"),onSelect:()=>S(()=>L(c).onOpenExternal(`${x}/project/${encodeURIComponent(n.projectKey)}`))}]:[]];return p(G,{children:[e(A,{controls:g,context:!0,label:n.name,items:I,children:p("div",{className:"alwith-drive-nav-row","data-active":b===n.localPath,children:[p(u,{variant:"ghost",className:"alwith-drive-nav-open",title:n.drivePath,"aria-label":n.name,disabled:f,onClick:N,children:[e(F,{name:f?"loading":n.kind==="KNOWLEDGE"?"book":"folder"}),e("span",{children:n.name}),e("small",{children:j?a(`panel.status.${j.kind==="syncing"&&j.total>0?"syncingProgress":j.kind}`,j.kind==="syncing"?{done:j.done,total:j.total}:j.kind==="partial"?{count:j.failed}:{}):a(`panel.containers.${Y(n)}`)})]}),e(u,{variant:"ghost",size:"icon-xs",className:"alwith-drive-condense-trigger",title:a("condense.action"),"aria-label":a("condense.action"),disabled:f,onClick:I[1].onSelect,children:e(F,{name:"sparkles"})}),e(A,{controls:g,label:`${n.name} ${a("panel.more")}`,items:I})]})}),e(V,{message:w})]})}function oe({controller:n,controls:{Input:s,Button:g},host:c,locale:O}){let{snapshot:b}=U(n),[P,u]=m(""),[h,f]=m([]),[w,S]=m(!1),{error:k,run:D}=M(),[a,T]=m(!1),[j,N]=m(null),x=K(0),I=K(!1),y=K(null),d=K(null),o=R(O),q=(b?.roots??[]).filter((l)=>l.selected).map((l)=>l.localPath).toSorted().join("\x00"),r=()=>{if(I.current||d.current?.signature===q&&Date.now()-d.current.at<60000)return;let l=++x.current,t=b?.generation,E=()=>l===x.current&&t===n.getSnapshot().snapshot?.generation;I.current=!0,T(!0),N(null),Z((b?.roots??[]).filter(_),async(C)=>{if(!E())return[];return L(c).readDirectory(C)}).then((C)=>{if(!E())return;f(C.entries),S(C.truncated),N(C.errors.length?C.errors.map((Q)=>`${Q.path}: ${Q.message}`).join(`
2
- `):null),d.current={signature:q,at:Date.now()}}).catch((C)=>{if(E())N(C instanceof Error?C.message:String(C))}).finally(()=>{if(E())I.current=!1,T(!1)})};B(()=>{let l=(t)=>{if(t.key.toLowerCase()==="k"&&(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey)t.preventDefault(),y.current?.querySelector("input")?.focus()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),B(()=>{let l=x;return x.current++,I.current=!1,T(!1),N(null),f([]),u(""),S(!1),d.current=null,()=>{l.current++}},[n,q,b?.generation]);let i=H(()=>ee(h,P),[h,P]),v=(l)=>D(async()=>{await L(c).onOpenEntry({path:l.path,isDirectory:l.isDirectory}),u("")});return p("div",{ref:y,className:"alwith-drive-search",children:[e(s,{placeholder:`${o("search.placeholder")} ⌘K`,"aria-label":o("search.placeholder"),value:P,onFocus:r,onChange:(l)=>u(l.target.value),onKeyDown:(l)=>{if(l.key==="Escape")u("");if(l.key==="Enter"&&i[0])v(i[0])}}),e(V,{message:k||j}),P.trim()&&p("div",{className:"alwith-drive-search-results",children:[!i.length&&e("p",{children:o(a?"search.indexing":"search.empty")}),i.map((l)=>e(g,{variant:"ghost",className:"alwith-drive-search-result",onClick:()=>v(l),children:p("span",{children:[e(F,{name:l.isDirectory?"folder":"file"})," ",l.name,p("small",{children:[l.projectName," · ",l.relPath]})]})},l.path)),w&&e("p",{children:o("search.truncated")})]})]})}function se({controller:n,controls:s,onOpenProject:g,onClose:c,locale:O}){let[b,P]=m([]),[u,h]=m([]),[f,w]=m("PERSONAL"),[S,k]=m(""),[D,a]=m(""),[T,j]=m(""),[N,x]=m(null),{busy:I,error:y,run:d}=M(),o=R(O),{Button:q,Input:r}=s;B(()=>{let t=!0;return Promise.all([n.request({type:"templates"}),n.request({type:"departments"})]).then(([E,C])=>{if(E.type!=="templates"||C.type!=="departments")throw Error("Invalid project choices");if(t)P(E.data),h(C.data),k(String(E.data[0]?.id??"")),a(String(C.data[0]?.id??""))}).catch((E)=>{if(t)x(String(E))}),()=>{t=!1}},[n]);let i=b.find((t)=>String(t.id)===S),v=u.find((t)=>String(t.id)===D),l=f==="DEPT"||f==="TEAM";return e(re,{controls:s,open:!0,onOpenChange:(t)=>{if(!t&&!I)c()},title:o("newProject.title"),description:o("newProject.desc"),children:p("div",{className:"alwith-drive-form",children:[(y||N)&&e("p",{role:"alert",className:"alwith-drive-error",children:y||N}),p("label",{children:[o("newProject.name"),e(r,{autoFocus:!0,placeholder:o("newProject.namePlaceholder"),value:T,onChange:(t)=>j(t.target.value)})]}),p("label",{children:[o("newProject.scope"),e(W,{controls:s,value:f,onValueChange:(t)=>w(t),options:["PERSONAL","DEPT","TEAM","COMPANY"].map((t)=>({value:t,label:o(`newProject.scopes.${t}`)}))})]}),l&&p("label",{children:[o("newProject.department"),e(W,{controls:s,value:D,onValueChange:a,options:u.map((t)=>({value:String(t.id),label:t.name}))})]}),p("label",{children:[o("newProject.template"),e(W,{controls:s,value:S,onValueChange:k,options:b.map((t)=>({value:String(t.id),label:`${o(`panel.containers.${t.kind==="KNOWLEDGE"?"knowledge":"material"}`)} · ${t.name}${t.description?` · ${t.description}`:""}`}))})]}),i&&e("p",{children:o("newProject.preview",{node:l?v?.name??o(`newProject.scopes.${f}`):o(`newProject.scopes.${f}`),container:o(`panel.containers.${i.kind==="KNOWLEDGE"?"knowledge":"material"}`)})}),p("div",{className:"alwith-drive-actions",children:[e(q,{variant:"outline",disabled:I,onClick:c,children:o("newProject.cancel")}),e(q,{disabled:I||!T.trim()||!i||l&&!v,onClick:()=>d(async()=>{if(!i)throw Error("Select a template");let t=await n.request({type:"createProject",request:{templateId:i.id,name:T.trim(),scope:f,departmentId:l?v?.id:null,topicId:null}});if(t.type!=="root")throw Error("Created project is unavailable");await g(t.data),c()}),children:o(I?"newProject.creating":"newProject.create")})]})]})})}export{ye as DriveLauncher};
1
+ import{jsx as n,jsxs as p,Fragment as G}from"react/jsx-runtime";import{useEffect as B,useMemo as H,useRef as K,useState as m}from"react";import{containerKey as Y,groupsOf as J,isBrowsable as _,rowStatusOf as X}from"./browse.js";import{collectDriveEntries as Z,filterDriveEntries as ee}from"./global-search.js";import{DriveIcon as F}from"./icons.js";import{driveTranslator as R}from"./locales.js";import{DriveNotice as V}from"./notifications.js";import{DrivePinnedDocs as ne}from"./pinned.js";import{togglePinned as te}from"./pinned-docs.js";import{DriveChoice as W,DriveMenu as A,DriveModal as re,requireHost as L,useDrive as U,useDriveAction as M}from"./ui.js";function ye(e){let{controller:s,controls:g,host:i,locale:O="en",onOpenSettings:b}=e,{Button:P}=g,{snapshot:u}=U(s),{busy:h,error:f,run:w}=M(),[S,k]=m(!1),[D,a]=m(null),[T,j]=m(null),[N,x]=m([]),[I,y]=m(null),d=R(O);B(()=>{if(x([]),a(null),y(null),!u?.running)return;let r=!0;return Promise.all([s.request({type:"ownershipGuard"}),s.request({type:"shared"})]).then(([c,v])=>{if(c.type!=="ownershipGuard"||v.type!=="shared")throw Error("Invalid Drive launcher response");if(r)a(c.data),x(v.data),y(null)}).catch((c)=>{if(r)y(String(c))}),()=>{r=!1}},[s,u?.generation,u?.running]);let o=u?.webBaseUrl?.replace(/\/+$/,""),q=async(r)=>{let c=L(i),v=u?.roots.find((E)=>String(E.projectId)===String(r.projectId)),l=async()=>{if(!o)throw Error(d("shared.notInDrive",{name:r.name}));await c.onOpenExternal(r.resourceType==="FILE"?`${o}/file/${encodeURIComponent(String(r.resourceId))}`:`${o}/shared`)};if(!v){await l();return}if(await s.request({type:"land",projectId:v.projectId}),r.localPath&&await c.pathExists(r.localPath)){await c.onOpenEntry({path:r.localPath,isDirectory:r.resourceType==="FOLDER"});return}if(r.resourceType==="FILE"){let E=await s.request({type:"localPath",fileId:r.resourceId});if(E.type!=="path")throw Error("Invalid Drive file path response");if(E.data&&await c.pathExists(E.data)){await c.onOpenEntry({path:E.data,isDirectory:!1});return}await l();return}let t=r.folderPath?`${v.localPath}/${r.folderPath}`:null;if(t&&await c.pathExists(t)){await c.onOpenEntry({path:t,isDirectory:!0});return}throw await c.onOpenEntry({path:v.localPath,isDirectory:!0}),Error(d("shared.folderMissing",{name:r.name}))};return p(G,{children:[p("header",{className:"alwith-drive-toolbar",children:[n("strong",{children:d("title")}),p("div",{className:"alwith-drive-actions",children:[n(A,{controls:g,label:d("panel.new"),items:[{label:d("newProject.title"),onSelect:()=>k(!0)},...o?[{label:d("panel.importFromFeishu"),onSelect:()=>w(()=>L(i).onOpenExternal(`${o}/admin/mirrors`))}]:[]],children:n(F,{name:"plus"})}),n(A,{controls:g,label:d("panel.more"),items:[{label:d("panel.refresh"),disabled:h,onSelect:()=>w(()=>s.request({type:"sync"}))},...o?[{label:d("panel.openWeb"),onSelect:()=>w(()=>L(i).onOpenExternal(o))},{label:d("panel.importFromFeishu"),onSelect:()=>w(()=>L(i).onOpenExternal(`${o}/admin/mirrors`))}]:[],...b?[{label:d("openSettings"),onSelect:b}]:[]]})]})]}),n(oe,{...e}),n(V,{message:f||I}),D?.active&&p("aside",{className:"alwith-drive-notice",children:[n("p",{children:d("panel.guard.notice",{count:D.unknownPersonalRoots})}),n(P,{variant:"ghost",disabled:h,onClick:()=>w(async()=>{if(await e.confirm(d("panel.guard.confirmDesc",{count:D.unknownPersonalRoots})))await s.request({type:"syncAllPersonal",enabled:!0}),a({...D,active:!1,syncAllPersonal:!0})}),children:d("panel.guard.syncAll")})]}),p("div",{className:"alwith-drive-navigation",children:[i&&n(ne,{controller:s,onOpenProject:e.onOpenProject,host:i,controls:g,locale:O,generation:u?.generation}),N.length>0&&p("details",{open:!0,className:"alwith-drive-group",children:[p("summary",{children:[d("shared.title")," ",n("span",{children:N.length})]}),N.map((r)=>{let c=`${r.resourceType}:${r.resourceId}`,v=()=>w(async()=>{j(c);try{await q(r)}finally{j(null)}});return n(A,{controls:g,context:!0,label:r.name,items:[{label:d("shared.open"),onSelect:v,disabled:h},...o?[{label:d("shared.openWeb"),onSelect:()=>w(()=>L(i).onOpenExternal(`${o}/shared`))}]:[]],children:p(P,{variant:"ghost",className:"alwith-drive-nav-open",disabled:h,title:d("shared.rowTitle",{name:r.name,project:r.projectName??"",by:r.grantedByName??""}),onClick:v,children:[n(F,{name:T===c?"loading":r.resourceType==="FOLDER"?"folder":"file"}),n("span",{children:r.name}),n("small",{children:d(`grants.level.${r.level}`)})]})},c)})]}),J(u?.roots??[]).map((r)=>n(ae,{...e,group:r},r.nodePath??r.legacy)),!(u?.roots??[]).some(_)&&n("p",{children:d("panel.empty")})]}),S&&n(se,{...e,onClose:()=>k(!1)})]})}function ae({group:e,...s}){let[g,i]=m(e.items.length<=30),[O,b]=m(g),[P,u]=m(""),h=R(s.locale),f=e.legacy==="shared",w=f?e.items.filter((a)=>a.scope==="PERSONAL"):[],S=f?e.items.filter((a)=>a.scope!=="PERSONAL"):e.items,k=S.filter((a)=>a.name.toLowerCase().includes(P.trim().toLowerCase())),{Input:D}=s.controls;return p("details",{className:"alwith-drive-group",open:g,onToggle:(a)=>{if(i(a.currentTarget.open),a.currentTarget.open)b(!0)},children:[p("summary",{children:[e.label??h(`panel.groups.${e.legacy??"shared"}`),n("span",{children:e.items.length})]}),O&&p(G,{children:[S.length>30&&n(D,{placeholder:h("panel.filter"),"aria-label":h("panel.filter"),value:P,onChange:(a)=>u(a.target.value)}),k.map((a)=>n(z,{...s,root:a},String(a.projectId))),!k.length&&!w.length&&n("p",{children:h("panel.filterEmpty")}),w.length>0&&n(le,{...s,roots:w})]})]})}function le({roots:e,...s}){let[g,i]=m(""),[O,b]=m(!1),{Input:P}=s.controls,u=R(s.locale);return p("details",{className:"alwith-drive-group",onToggle:(h)=>{if(h.currentTarget.open)b(!0)},children:[p("summary",{children:[u("panel.groups.otherPersonal"),n("span",{children:e.length})]}),O&&p(G,{children:[n(P,{"aria-label":u("panel.filter"),placeholder:u("panel.filter"),value:g,onChange:(h)=>i(h.target.value)}),e.filter((h)=>h.name.toLowerCase().includes(g.toLowerCase())).map((h)=>n(z,{...s,root:h},String(h.projectId)))]})]})}function z({root:e,controller:s,controls:g,host:i,onOpenProject:O,currentProject:b,locale:P}){let{Button:u}=g,{snapshot:h}=U(s),{busy:f,error:w,run:S}=M(),[k,D]=m(!1),a=R(P),T=h?.projects.find((y)=>String(y.projectId)===String(e.projectId)),j=k?X(T,f):null,N=()=>S(async()=>{if(D(!0),i&&await i.pathExists(e.localPath)&&(await i.readDirectory(e.localPath)).length>0){await O(e),D(!1);return}let y=await s.request({type:"land",projectId:e.projectId});if(y.type!=="root")throw Error("Drive did not return a landed project");await O(y.data),D(!1)}),x=h?.webBaseUrl?.replace(/\/+$/,""),I=[{label:a("panel.open"),onSelect:N},{label:a("condense.action"),disabled:f,onSelect:()=>S(()=>{let y=L(i);if(!y.onCondense)throw Error("Knowledge integration is unavailable");return y.onCondense(e)})},{label:a("pinned.pin"),onSelect:()=>S(()=>L(i).onPinnedDocsChange(te(L(i).pinnedDocs,{path:e.localPath,name:e.name,kind:"dir"})))},...e.cursor!==null?[{label:a("panel.reveal"),onSelect:()=>S(()=>L(i).onRevealPath(e.localPath))}]:[],...x?[{label:a("panel.openWeb"),onSelect:()=>S(()=>L(i).onOpenExternal(`${x}/project/${encodeURIComponent(e.projectKey)}`))}]:[]];return p(G,{children:[n(A,{controls:g,context:!0,label:e.name,items:I,children:p("div",{className:"alwith-drive-nav-row","data-active":b===e.localPath,children:[p(u,{variant:"ghost",className:"alwith-drive-nav-open",title:e.drivePath,"aria-label":e.name,disabled:f,onClick:N,children:[n(F,{name:f?"loading":e.kind==="KNOWLEDGE"?"book":"folder"}),n("span",{children:e.name}),n("small",{children:j?a(`panel.status.${j.kind==="syncing"&&j.total>0?"syncingProgress":j.kind}`,j.kind==="syncing"?{done:j.done,total:j.total}:j.kind==="partial"?{count:j.failed}:{}):a(`panel.containers.${Y(e)}`)})]}),e.cursor!==null&&i?.renderProjectActions?.(e),n(u,{variant:"ghost",size:"icon-xs",className:"alwith-drive-condense-trigger",title:a("condense.action"),"aria-label":a("condense.action"),disabled:f,onClick:I[1].onSelect,children:n(F,{name:"sparkles"})}),n(A,{controls:g,label:`${e.name} ${a("panel.more")}`,items:I})]})}),n(V,{message:w})]})}function oe({controller:e,controls:{Input:s,Button:g},host:i,locale:O}){let{snapshot:b}=U(e),[P,u]=m(""),[h,f]=m([]),[w,S]=m(!1),{error:k,run:D}=M(),[a,T]=m(!1),[j,N]=m(null),x=K(0),I=K(!1),y=K(null),d=K(null),o=R(O),q=(b?.roots??[]).filter((l)=>l.selected).map((l)=>l.localPath).toSorted().join("\x00"),r=()=>{if(I.current||d.current?.signature===q&&Date.now()-d.current.at<60000)return;let l=++x.current,t=b?.generation,E=()=>l===x.current&&t===e.getSnapshot().snapshot?.generation;I.current=!0,T(!0),N(null),Z((b?.roots??[]).filter(_),async(C)=>{if(!E())return[];return L(i).readDirectory(C)}).then((C)=>{if(!E())return;f(C.entries),S(C.truncated),N(C.errors.length?C.errors.map((Q)=>`${Q.path}: ${Q.message}`).join(`
2
+ `):null),d.current={signature:q,at:Date.now()}}).catch((C)=>{if(E())N(C instanceof Error?C.message:String(C))}).finally(()=>{if(E())I.current=!1,T(!1)})};B(()=>{let l=(t)=>{if(t.key.toLowerCase()==="k"&&(t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey)t.preventDefault(),y.current?.querySelector("input")?.focus()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),B(()=>{let l=x;return x.current++,I.current=!1,T(!1),N(null),f([]),u(""),S(!1),d.current=null,()=>{l.current++}},[e,q,b?.generation]);let c=H(()=>ee(h,P),[h,P]),v=(l)=>D(async()=>{await L(i).onOpenEntry({path:l.path,isDirectory:l.isDirectory}),u("")});return p("div",{ref:y,className:"alwith-drive-search",children:[n(s,{placeholder:`${o("search.placeholder")} ⌘K`,"aria-label":o("search.placeholder"),value:P,onFocus:r,onChange:(l)=>u(l.target.value),onKeyDown:(l)=>{if(l.key==="Escape")u("");if(l.key==="Enter"&&c[0])v(c[0])}}),n(V,{message:k||j}),P.trim()&&p("div",{className:"alwith-drive-search-results",children:[!c.length&&n("p",{children:o(a?"search.indexing":"search.empty")}),c.map((l)=>n(g,{variant:"ghost",className:"alwith-drive-search-result",onClick:()=>v(l),children:p("span",{children:[n(F,{name:l.isDirectory?"folder":"file"})," ",l.name,p("small",{children:[l.projectName," · ",l.relPath]})]})},l.path)),w&&n("p",{children:o("search.truncated")})]})]})}function se({controller:e,controls:s,onOpenProject:g,onClose:i,locale:O}){let[b,P]=m([]),[u,h]=m([]),[f,w]=m("PERSONAL"),[S,k]=m(""),[D,a]=m(""),[T,j]=m(""),[N,x]=m(null),{busy:I,error:y,run:d}=M(),o=R(O),{Button:q,Input:r}=s;B(()=>{let t=!0;return Promise.all([e.request({type:"templates"}),e.request({type:"departments"})]).then(([E,C])=>{if(E.type!=="templates"||C.type!=="departments")throw Error("Invalid project choices");if(t)P(E.data),h(C.data),k(String(E.data[0]?.id??"")),a(String(C.data[0]?.id??""))}).catch((E)=>{if(t)x(String(E))}),()=>{t=!1}},[e]);let c=b.find((t)=>String(t.id)===S),v=u.find((t)=>String(t.id)===D),l=f==="DEPT"||f==="TEAM";return n(re,{controls:s,open:!0,onOpenChange:(t)=>{if(!t&&!I)i()},title:o("newProject.title"),description:o("newProject.desc"),children:p("div",{className:"alwith-drive-form",children:[(y||N)&&n("p",{role:"alert",className:"alwith-drive-error",children:y||N}),p("label",{children:[o("newProject.name"),n(r,{autoFocus:!0,placeholder:o("newProject.namePlaceholder"),value:T,onChange:(t)=>j(t.target.value)})]}),p("label",{children:[o("newProject.scope"),n(W,{controls:s,value:f,onValueChange:(t)=>w(t),options:["PERSONAL","DEPT","TEAM","COMPANY"].map((t)=>({value:t,label:o(`newProject.scopes.${t}`)}))})]}),l&&p("label",{children:[o("newProject.department"),n(W,{controls:s,value:D,onValueChange:a,options:u.map((t)=>({value:String(t.id),label:t.name}))})]}),p("label",{children:[o("newProject.template"),n(W,{controls:s,value:S,onValueChange:k,options:b.map((t)=>({value:String(t.id),label:`${o(`panel.containers.${t.kind==="KNOWLEDGE"?"knowledge":"material"}`)} · ${t.name}${t.description?` · ${t.description}`:""}`}))})]}),c&&n("p",{children:o("newProject.preview",{node:l?v?.name??o(`newProject.scopes.${f}`):o(`newProject.scopes.${f}`),container:o(`panel.containers.${c.kind==="KNOWLEDGE"?"knowledge":"material"}`)})}),p("div",{className:"alwith-drive-actions",children:[n(q,{variant:"outline",disabled:I,onClick:i,children:o("newProject.cancel")}),n(q,{disabled:I||!T.trim()||!c||l&&!v,onClick:()=>d(async()=>{if(!c)throw Error("Select a template");let t=await e.request({type:"createProject",request:{templateId:c.id,name:T.trim(),scope:f,departmentId:l?v?.id:null,topicId:null}});if(t.type!=="root")throw Error("Created project is unavailable");await g(t.data),i()}),children:o(I?"newProject.creating":"newProject.create")})]})]})})}export{ye as DriveLauncher};
package/dist/ui.d.ts CHANGED
@@ -55,6 +55,7 @@ export interface DriveHost {
55
55
  pinnedDocs: PinnedDoc[];
56
56
  onPinnedDocsChange: (docs: PinnedDoc[]) => Promise<void>;
57
57
  onCondense?: (root: RootInfo) => Promise<void>;
58
+ renderProjectActions?: (root: RootInfo) => ReactNode;
58
59
  integrations?: ReactNode;
59
60
  }
60
61
  export declare function useDrive(controller: DriveController): DriveState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwith/module-drive",
3
- "version": "0.1.0-rc.23",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "files": [
@@ -115,5 +115,10 @@
115
115
  },
116
116
  "dependencies": {
117
117
  "@alwith/native-kit": "0.1.0"
118
+ },
119
+ "repository": {
120
+ "type": "git",
121
+ "url": "git+https://github.com/ALwith-ai/alwith-modules.git",
122
+ "directory": "packages/drive"
118
123
  }
119
124
  }
package/rust/Cargo.toml CHANGED
@@ -2,7 +2,7 @@
2
2
  autobins = false
3
3
  autotests = false
4
4
  name = "alwith-drive"
5
- version = "0.1.0-rc.22"
5
+ version = "0.1.1"
6
6
  edition = "2024"
7
7
  publish = false
8
8
  [workspace]
@@ -201,6 +201,11 @@ pub enum DriveRequest {
201
201
  project_id: RemoteId,
202
202
  },
203
203
  Snapshot,
204
+ PublishBetweenProjects {
205
+ source: String,
206
+ destination: String,
207
+ is_directory: bool,
208
+ },
204
209
  MoveBetweenProjects {
205
210
  source: String,
206
211
  destination: String,
package/rust/src/sync.rs CHANGED
@@ -164,6 +164,10 @@ pub struct Snapshot {
164
164
  pub files: Vec<SnapshotFile>,
165
165
  pub folders: Vec<SnapshotFolder>,
166
166
  pub cursor: String,
167
+ #[serde(default)]
168
+ pub has_more: bool,
169
+ #[serde(default)]
170
+ pub next_after: Option<i64>,
167
171
  }
168
172
 
169
173
  #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]