@tulip-systems/drive-local 0.11.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.
Files changed (61) hide show
  1. package/LICENSE +662 -0
  2. package/dist/client.d.mts +12 -0
  3. package/dist/client.mjs +12 -0
  4. package/dist/database/drizzle/lib/adapter.d.mts +310 -0
  5. package/dist/database/drizzle/lib/adapter.mjs +520 -0
  6. package/dist/database/drizzle/lib/compilers.d.mts +395 -0
  7. package/dist/database/drizzle/lib/compilers.mjs +21 -0
  8. package/dist/database/drizzle/lib/schema.d.mts +61 -0
  9. package/dist/drizzle.d.mts +4 -0
  10. package/dist/drizzle.mjs +3 -0
  11. package/dist/index.d.mts +8 -0
  12. package/dist/index.mjs +8 -0
  13. package/dist/root/components/command-file-update.d.mts +11 -0
  14. package/dist/root/components/command-file-update.mjs +44 -0
  15. package/dist/root/components/command-file-upload.d.mts +5 -0
  16. package/dist/root/components/command-file-upload.mjs +31 -0
  17. package/dist/root/components/command-folder-create.d.mts +11 -0
  18. package/dist/root/components/command-folder-create.mjs +50 -0
  19. package/dist/root/components/command-folder-update.d.mts +11 -0
  20. package/dist/root/components/command-folder-update.mjs +44 -0
  21. package/dist/root/components/content.client.d.mts +5 -0
  22. package/dist/root/components/content.client.mjs +5 -0
  23. package/dist/root/components/navigation.client.d.mts +11 -0
  24. package/dist/root/components/navigation.client.mjs +12 -0
  25. package/dist/root/components/provider.client.d.mts +16 -0
  26. package/dist/root/components/provider.client.mjs +65 -0
  27. package/dist/root/components/upload-zone-context.client.d.mts +36 -0
  28. package/dist/root/components/upload-zone-context.client.mjs +19 -0
  29. package/dist/root/components/upload-zone.client.d.mts +16 -0
  30. package/dist/root/components/upload-zone.client.mjs +147 -0
  31. package/dist/root/components/view.client.d.mts +20 -0
  32. package/dist/root/components/view.client.mjs +86 -0
  33. package/dist/root/config/columns-data.d.mts +6 -0
  34. package/dist/root/config/columns-data.mjs +62 -0
  35. package/dist/root/config/filters.d.mts +404 -0
  36. package/dist/root/config/filters.mjs +122 -0
  37. package/dist/root/config/sorting.d.mts +38 -0
  38. package/dist/root/config/sorting.mjs +26 -0
  39. package/dist/root/lib/constants.d.mts +12 -0
  40. package/dist/root/lib/constants.mjs +27 -0
  41. package/dist/root/lib/database/contracts.d.mts +112 -0
  42. package/dist/root/lib/database/filters.d.mts +28 -0
  43. package/dist/root/lib/database/filters.mjs +73 -0
  44. package/dist/root/lib/helpers.d.mts +33 -0
  45. package/dist/root/lib/helpers.mjs +78 -0
  46. package/dist/root/lib/route-handler.server.d.mts +36 -0
  47. package/dist/root/lib/route-handler.server.mjs +111 -0
  48. package/dist/root/lib/router.server.d.mts +819 -0
  49. package/dist/root/lib/router.server.mjs +87 -0
  50. package/dist/root/lib/search-params.d.mts +15 -0
  51. package/dist/root/lib/search-params.mjs +6 -0
  52. package/dist/root/lib/service.server.d.mts +522 -0
  53. package/dist/root/lib/service.server.mjs +613 -0
  54. package/dist/root/lib/upload.client.d.mts +60 -0
  55. package/dist/root/lib/upload.client.mjs +97 -0
  56. package/dist/root/lib/validators.d.mts +710 -0
  57. package/dist/root/lib/validators.mjs +116 -0
  58. package/dist/server.d.mts +5 -0
  59. package/dist/server.mjs +4 -0
  60. package/package.json +83 -0
  61. package/styles.css +1 -0
@@ -0,0 +1,87 @@
1
+ import { createLocalDriveFolderInputSchema, getLocalDriveNodesByParentIdInputSchema, getLocalFileURLSchema, listLocalDriveFlatInputSchema, listLocalDriveTreeInputSchema, localDriveFileNodeSchema, localDriveFlatResponseSchema, localDriveNodeParentSchema, localDriveNodeSchema, localDriveNodeWithChildrenSchema, localDrivePresignUploadOutputSchema, localDriveTreeResponseSchema, presignLocalDriveFileInputSchema, updateLocalDriveNodeInputSchema } from "./validators.mjs";
2
+ import { bulkActionSchema } from "@tulip-systems/query";
3
+ import { z as z$1 } from "zod";
4
+ import { oc } from "@orpc/contract";
5
+ //#region src/root/lib/router.server.ts
6
+ /**
7
+ * Local Drive router contract defines the input and output schemas for local drive-related procedures.
8
+ */
9
+ const localDriveRouterContract = {
10
+ /**
11
+ * Get node with children
12
+ */
13
+ getNodeWithChildren: oc.input(z$1.object({
14
+ id: z$1.string(),
15
+ namespace: z$1.string()
16
+ })).output(localDriveNodeWithChildrenSchema.nullable()),
17
+ /**
18
+ * Get folders by parent id
19
+ */
20
+ getNodesByParentId: oc.input(getLocalDriveNodesByParentIdInputSchema).output(z$1.array(localDriveNodeSchema)),
21
+ /**
22
+ * List tree nodes with pagination and search.
23
+ */
24
+ listTree: oc.input(listLocalDriveTreeInputSchema).output(localDriveTreeResponseSchema),
25
+ /**
26
+ * List flat nodes with pagination and search.
27
+ */
28
+ listFlat: oc.input(listLocalDriveFlatInputSchema).output(localDriveFlatResponseSchema),
29
+ /**
30
+ * Get parents of a folder
31
+ */
32
+ getFolderParents: oc.input(z$1.object({
33
+ id: z$1.string().nullable(),
34
+ namespace: z$1.string()
35
+ })).output(z$1.array(localDriveNodeParentSchema)),
36
+ /**
37
+ * Get url for opening a file
38
+ */
39
+ getURL: oc.input(getLocalFileURLSchema.extend({ id: z$1.string() })).output(z$1.string().nullable()),
40
+ /**
41
+ * Create a direct upload intent for a file
42
+ */
43
+ presignUpload: oc.input(presignLocalDriveFileInputSchema).output(localDrivePresignUploadOutputSchema),
44
+ /**
45
+ * Confirm a direct upload intent
46
+ */
47
+ confirmUpload: oc.input(z$1.object({ uploadId: z$1.string() })).output(localDriveFileNodeSchema),
48
+ /**
49
+ * Create a folder
50
+ */
51
+ createFolder: oc.input(createLocalDriveFolderInputSchema).output(localDriveNodeSchema),
52
+ /**
53
+ * Update node
54
+ */
55
+ updateNode: oc.input(z$1.object({
56
+ id: z$1.string(),
57
+ data: updateLocalDriveNodeInputSchema
58
+ })).output(localDriveNodeSchema),
59
+ /**
60
+ * Set readonly
61
+ */
62
+ setReadonly: oc.input(bulkActionSchema.extend({ readonly: z$1.boolean() })).output(z$1.array(localDriveNodeSchema)),
63
+ /**
64
+ * Move node
65
+ */
66
+ moveNode: oc.input(z$1.object({
67
+ id: z$1.string(),
68
+ parentId: z$1.string().nullish()
69
+ })).output(localDriveNodeSchema),
70
+ /**
71
+ * Archive nodes
72
+ */
73
+ archiveNodes: oc.input(bulkActionSchema).output(z$1.array(localDriveNodeSchema)),
74
+ /**
75
+ * Restore nodes
76
+ */
77
+ restoreNodes: oc.input(bulkActionSchema).output(z$1.array(localDriveNodeSchema)),
78
+ /**
79
+ * Delete nodes
80
+ */
81
+ deleteNodes: oc.input(bulkActionSchema).output(z$1.void())
82
+ };
83
+ /**
84
+ * Create Drive base procedures
85
+ */
86
+ //#endregion
87
+ export { localDriveRouterContract };
@@ -0,0 +1,15 @@
1
+ //#region src/root/lib/search-params.d.ts
2
+ declare const localDriveTreeFilterSearchParams: {
3
+ readonly search: import("nuqs/server").SingleParserBuilder<string>;
4
+ readonly types: import("nuqs/server").SingleParserBuilder<("folder" | "file")[]>;
5
+ readonly contentTypes: import("nuqs/server").SingleParserBuilder<string[]>;
6
+ readonly nodeIds: import("nuqs/server").SingleParserBuilder<string[]>;
7
+ readonly assetIds: import("nuqs/server").SingleParserBuilder<string[]>;
8
+ readonly namespace: import("nuqs/server").SingleParserBuilder<string>;
9
+ readonly parentId: import("nuqs/server").SingleParserBuilder<string | null>;
10
+ readonly subtypes: import("nuqs/server").SingleParserBuilder<("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[]>;
11
+ readonly isArchived: import("nuqs/server").SingleParserBuilder<boolean>;
12
+ readonly hidden: import("nuqs/server").SingleParserBuilder<boolean>;
13
+ };
14
+ //#endregion
15
+ export { localDriveTreeFilterSearchParams };
@@ -0,0 +1,6 @@
1
+ import { localDriveFilters } from "../config/filters.mjs";
2
+ import { resolveFilteringSearchParams } from "@tulip-systems/query";
3
+ //#region src/root/lib/search-params.ts
4
+ const localDriveTreeFilterSearchParams = resolveFilteringSearchParams(localDriveFilters);
5
+ //#endregion
6
+ export { localDriveTreeFilterSearchParams };
@@ -0,0 +1,522 @@
1
+ import { CreateLocalDriveFolderSchema, GetLocalDriveNodesByParentIdInput, GetLocalFileURLSchema, ListLocalDriveFlatSchema, ListLocalDriveTreeSchema, LocalDriveFileNode, LocalDriveNode, LocalDriveNodeChild, LocalDriveNodeWithAsset, LocalDriveNodeWithChildren, LocalNode, PresignLocalDriveFileInput, UpdateLocalDriveNodeInput, UploadLocalDriveFileSchema } from "./validators.mjs";
2
+ import { LocalDriveDatabaseProvider } from "./database/contracts.mjs";
3
+ import { DriveAdapterTypes, DriveArchive, DriveDirectUpload, DriveNodeMutations, DriveNodeQueries, DriveNodeReader, DrivePresignedUpload, DrivePreviewGenerator, DriveReadonly } from "@tulip-systems/drive";
4
+ import { OffsetPaginatedResponse } from "@tulip-systems/query";
5
+ import { ObjectBodyInput } from "@tulip-systems/storage";
6
+ import { Storage } from "@tulip-systems/storage/server";
7
+ //#region src/root/lib/service.server.d.ts
8
+ /**
9
+ * Drive Service Config
10
+ */
11
+ type LocalDriveConfig = {
12
+ database: LocalDriveDatabaseProvider;
13
+ storage: Storage;
14
+ };
15
+ type LocalDriveTypes = DriveAdapterTypes<LocalDriveNode, {
16
+ createFolderInput: CreateLocalDriveFolderSchema;
17
+ getNodesByParentIdInput: GetLocalDriveNodesByParentIdInput;
18
+ listTreeInput: ListLocalDriveTreeSchema;
19
+ listTreeNode: LocalDriveNodeWithAsset;
20
+ nodeChild: LocalDriveNodeChild;
21
+ nodeWithChildren: LocalDriveNodeWithChildren;
22
+ presignUploadInput: PresignLocalDriveFileInput;
23
+ presignUploadNode: LocalDriveFileNode;
24
+ updateNodeInput: UpdateLocalDriveNodeInput;
25
+ uploadBody: ObjectBodyInput;
26
+ uploadFileInput: UploadLocalDriveFileSchema;
27
+ }>;
28
+ /**
29
+ * Drive Service
30
+ */
31
+ declare class LocalDrive implements DriveNodeReader<LocalDriveTypes>, DriveNodeQueries<LocalDriveTypes>, DriveNodeMutations<LocalDriveTypes>, DriveDirectUpload<LocalDriveTypes>, DrivePresignedUpload<LocalDriveTypes>, DrivePreviewGenerator, DriveReadonly<LocalDriveTypes>, DriveArchive<LocalDriveTypes> {
32
+ #private;
33
+ storage: Storage;
34
+ constructor({ database, storage }: LocalDriveConfig);
35
+ /**
36
+ * Retrieves the node row for a given id.
37
+ *
38
+ * This is a thin lookup helper that returns the raw database result for the
39
+ * matching node. It does not load children, variants, or perform namespace
40
+ * validation.
41
+ *
42
+ * @param id - The node identifier.
43
+ * @returns A promise resolving to the matching node row as a single-item array,
44
+ * or an empty array when no node exists.
45
+ */
46
+ getNodeById(id: string): Promise<LocalDriveNode | null>;
47
+ /**
48
+ * Retrieves a node together with its direct children for a namespace.
49
+ *
50
+ * This is used by the drive UI when opening a node detail view that expects
51
+ * the immediate child this.#nodes in the same payload.
52
+ *
53
+ * @param input - The target node id and namespace.
54
+ * @returns The node with its children when found, otherwise `null`.
55
+ */
56
+ getNodeWithChildren(input: {
57
+ id: string;
58
+ namespace: string;
59
+ }): Promise<LocalDriveNodeWithChildren | null>;
60
+ /**
61
+ * Lists this.#nodes within a folder scope using the current table-query filters.
62
+ *
63
+ * Behavior:
64
+ * - Scopes results to a namespace
65
+ * - Resolves either root this.#nodes (`parentId = null`) or a specific parent folder
66
+ * - Applies optional filters such as ids, types, hidden state, and archive state
67
+ * - Applies search and sorting through the shared table-query utilities
68
+ *
69
+ * @param input - Table query input containing drive filters, search, and sorting.
70
+ * @returns A promise resolving to the matching child this.#nodes.
71
+ */
72
+ getNodesByParentId(input: GetLocalDriveNodesByParentIdInput): Promise<LocalDriveNode[]>;
73
+ /**
74
+ * Lists tree-scoped this.#nodes with pagination, search, and richer local filters.
75
+ *
76
+ * This query is intended for admin table views where additional local fields
77
+ * such as subtype and contentType are part of the filtering contract.
78
+ *
79
+ * @param input - Table query input with tree filters.
80
+ * @returns A paginated table-query response.
81
+ */
82
+ listTree({ filters, ...query }: ListLocalDriveTreeSchema): Promise<OffsetPaginatedResponse<LocalDriveNodeWithAsset>>;
83
+ /**
84
+ * Lists flat this.#nodes with pagination, search, and richer local filters.
85
+ *
86
+ * Unlike `listTree`, this query ignores parent scoping and is intended for
87
+ * flat file-manager style views.
88
+ *
89
+ * @param input - Table query input with flat filters.
90
+ * @returns A paginated table-query response.
91
+ */
92
+ listFlat({ filters, ...query }: ListLocalDriveFlatSchema): Promise<OffsetPaginatedResponse<LocalDriveNodeWithAsset>>;
93
+ /**
94
+ * Resolves the ancestor chain for a folder or file node.
95
+ *
96
+ * The returned list starts with the root-most ancestor and ends with the
97
+ * requested node. This is primarily used for breadcrumb navigation.
98
+ *
99
+ * @param input - The node id and namespace to resolve.
100
+ * @returns A promise resolving to the ordered ancestor chain.
101
+ */
102
+ getFolderParents(input: {
103
+ id: string | null;
104
+ namespace: string;
105
+ }): Promise<{
106
+ depth: number;
107
+ name: string;
108
+ id: string;
109
+ parentId: string | null;
110
+ }[]>;
111
+ /**
112
+ * Retrieves the structural subtree for one or more root node ids.
113
+ *
114
+ * The result includes the provided start this.#nodes and all descendant this.#nodes,
115
+ * returned as a lightweight shape containing only the fields needed for
116
+ * recursive drive operations such as delete, archive, and validation.
117
+ *
118
+ * Depth starts at `0` for the provided root this.#nodes and increases for each
119
+ * descendant level. Duplicate paths are collapsed by keeping the minimum depth.
120
+ *
121
+ * @param ids - Root node ids to traverse from.
122
+ * @returns A promise resolving to the subtree rows for the provided this.#nodes.
123
+ */
124
+ getNodeChildren(ids: string[]): Promise<{
125
+ depth: number;
126
+ id: string;
127
+ createdAt: Date;
128
+ updatedAt: Date;
129
+ name: string;
130
+ namespace: string;
131
+ type: "folder" | "file";
132
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
133
+ size: number | null;
134
+ contentType: string | null;
135
+ readonly: boolean;
136
+ hidden: boolean;
137
+ archivedAt: Date | null;
138
+ parentId: string | null;
139
+ links: {
140
+ view: string | null;
141
+ download: string | null;
142
+ preview: string | null;
143
+ thumbnail: string | null;
144
+ };
145
+ availability: "pending" | "ready" | "failed";
146
+ provider: "local";
147
+ assetId: string | null;
148
+ }[]>;
149
+ /**
150
+ * Resolves an access URL for a file node and the requested variant.
151
+ *
152
+ * Behavior:
153
+ * - Rejects folder this.#nodes because only file this.#nodes can resolve a file URL
154
+ * - Reuses a cached URL when an unexpired entry exists for the requested
155
+ * variant and disposition
156
+ * - Resolves the requested preview variant asset when available
157
+ * - Falls back to the main file asset when the requested variant does not exist
158
+ * - Delegates final URL generation to the storage service
159
+ * - Stores the generated URL in the local cache table for future reuse
160
+ *
161
+ * @param node - The file node to resolve.
162
+ * @param options - URL options such as variant and content disposition.
163
+ * @returns A promise resolving to a temporary file URL.
164
+ */
165
+ getURL(node: LocalNode, options?: GetLocalFileURLSchema): Promise<string>;
166
+ /**
167
+ * Moves a node to a different parent folder.
168
+ *
169
+ * The target parent is validated before the move is persisted. Moving a node
170
+ * into itself or into one of its descendants is rejected to keep the tree
171
+ * structure valid.
172
+ *
173
+ * @param input - The node id and the target parent id.
174
+ * @returns A promise resolving to the updated node.
175
+ * @throws {ORPCError} If the move is invalid.
176
+ */
177
+ moveNode(input: {
178
+ id: string;
179
+ parentId: string | null;
180
+ }): Promise<{
181
+ id: string;
182
+ createdAt: Date;
183
+ updatedAt: Date;
184
+ name: string;
185
+ namespace: string;
186
+ type: "folder" | "file";
187
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
188
+ size: number | null;
189
+ contentType: string | null;
190
+ readonly: boolean;
191
+ hidden: boolean;
192
+ archivedAt: Date | null;
193
+ parentId: string | null;
194
+ links: {
195
+ view: string | null;
196
+ download: string | null;
197
+ preview: string | null;
198
+ thumbnail: string | null;
199
+ };
200
+ availability: "pending" | "ready" | "failed";
201
+ provider: "local";
202
+ assetId: string | null;
203
+ }>;
204
+ /**
205
+ * Uploads a file through the storage service and creates the matching node.
206
+ *
207
+ * Behavior:
208
+ * - Validates the parent folder when `parentId` is provided
209
+ * - Uploads the file bytes through the storage service
210
+ * - Persists the created storage asset id on the node
211
+ * - Cleans up the uploaded asset when node creation fails
212
+ *
213
+ * @param input - File metadata and body.
214
+ * @returns A promise resolving to the created file node.
215
+ * @throws {ORPCError} If validation or persistence fails.
216
+ */
217
+ uploadFile(input: UploadLocalDriveFileSchema & {
218
+ body: ObjectBodyInput;
219
+ }): Promise<{
220
+ id: string;
221
+ createdAt: Date;
222
+ updatedAt: Date;
223
+ name: string;
224
+ namespace: string;
225
+ type: "folder" | "file";
226
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
227
+ size: number | null;
228
+ contentType: string | null;
229
+ readonly: boolean;
230
+ hidden: boolean;
231
+ archivedAt: Date | null;
232
+ parentId: string | null;
233
+ links: {
234
+ view: string | null;
235
+ download: string | null;
236
+ preview: string | null;
237
+ thumbnail: string | null;
238
+ };
239
+ availability: "pending" | "ready" | "failed";
240
+ provider: "local";
241
+ assetId: string | null;
242
+ }>;
243
+ /**
244
+ * Creates a direct upload intent and the matching file node.
245
+ *
246
+ * Behavior:
247
+ * - Validates the parent folder when `parentId` is provided
248
+ * - Requests a presigned upload from the storage service
249
+ * - Creates the file node linked to the pending storage asset
250
+ * - Purges the pending asset when node creation fails
251
+ *
252
+ * @param input - File metadata used to create the upload intent.
253
+ * @returns The created asset intent, presigned URL, and file node.
254
+ * @throws {ORPCError} If validation or node creation fails.
255
+ */
256
+ presignUpload(input: PresignLocalDriveFileInput): Promise<{
257
+ uploadId: string;
258
+ presignedUrl: string;
259
+ node: LocalDriveFileNode;
260
+ asset: {
261
+ id: string;
262
+ createdAt: Date;
263
+ updatedAt: Date;
264
+ provider: "s3";
265
+ bucket: string;
266
+ key: string;
267
+ status: "pending" | "ready" | "error";
268
+ visibility: "private" | "public";
269
+ size: number | null;
270
+ contentType: string | null;
271
+ uploadId: string;
272
+ name: string | null;
273
+ metadata: Record<string, unknown> | null;
274
+ etag: string | null;
275
+ uploadedAt: Date;
276
+ deletedAt: Date | null;
277
+ };
278
+ }>;
279
+ /**
280
+ * Finalizes a presigned upload and synchronizes the node metadata.
281
+ *
282
+ * Behavior:
283
+ * - Confirms the pending asset through the storage service
284
+ * - Finds the matching node by `assetId`
285
+ * - Synchronizes final asset metadata onto the node
286
+ * - Schedules preview generation for image files
287
+ *
288
+ * @param uploadId - The storage upload id returned by the presign step.
289
+ * @returns A promise resolving to the finalized file node.
290
+ * @throws {ORPCError} If the asset or node cannot be resolved.
291
+ */
292
+ confirmUpload(uploadId: string): Promise<{
293
+ id: string;
294
+ createdAt: Date;
295
+ updatedAt: Date;
296
+ name: string;
297
+ namespace: string;
298
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
299
+ size: number | null;
300
+ contentType: string | null;
301
+ readonly: boolean;
302
+ hidden: boolean;
303
+ archivedAt: Date | null;
304
+ parentId: string | null;
305
+ links: {
306
+ view: string | null;
307
+ download: string | null;
308
+ preview: string | null;
309
+ thumbnail: string | null;
310
+ };
311
+ availability: "pending" | "ready" | "failed";
312
+ provider: "local";
313
+ assetId: string | null;
314
+ type: "file";
315
+ }>;
316
+ /**
317
+ * Generates preview assets for an image node.
318
+ *
319
+ * The original file is loaded from storage, resized to the configured device
320
+ * widths, uploaded as separate storage assets, and linked through
321
+ * `node_variants`. Existing preview variants are skipped.
322
+ *
323
+ * @param input - The target file node identifier.
324
+ * @returns A promise that resolves once preview generation completes.
325
+ * @throws {ORPCError} If the source node or asset cannot be resolved.
326
+ */
327
+ generatePreviews(input: {
328
+ id: string;
329
+ }): Promise<void>;
330
+ /**
331
+ * Creates a folder node in the drive tree.
332
+ *
333
+ * The parent folder is validated before the folder is inserted. Folders do
334
+ * not own a storage asset and are stored purely as drive metadata.
335
+ *
336
+ * @param input - Folder metadata.
337
+ * @returns A promise resolving to the created folder node.
338
+ * @throws {ORPCError} If validation or insertion fails.
339
+ */
340
+ createFolder(input: CreateLocalDriveFolderSchema): Promise<{
341
+ id: string;
342
+ createdAt: Date;
343
+ updatedAt: Date;
344
+ name: string;
345
+ namespace: string;
346
+ type: "folder" | "file";
347
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
348
+ size: number | null;
349
+ contentType: string | null;
350
+ readonly: boolean;
351
+ hidden: boolean;
352
+ archivedAt: Date | null;
353
+ parentId: string | null;
354
+ links: {
355
+ view: string | null;
356
+ download: string | null;
357
+ preview: string | null;
358
+ thumbnail: string | null;
359
+ };
360
+ availability: "pending" | "ready" | "failed";
361
+ provider: "local";
362
+ assetId: string | null;
363
+ }>;
364
+ /**
365
+ * Updates mutable node metadata.
366
+ *
367
+ * Supported updates currently include renaming, reparenting, visibility flags,
368
+ * and archive state. Structural updates are validated before being persisted.
369
+ *
370
+ * @param id - The target node id.
371
+ * @param data - Partial node fields to update.
372
+ * @returns A promise resolving to the updated node.
373
+ * @throws {ORPCError} If the node does not exist or the update is invalid.
374
+ */
375
+ updateNode(id: string, data: UpdateLocalDriveNodeInput): Promise<{
376
+ id: string;
377
+ createdAt: Date;
378
+ updatedAt: Date;
379
+ name: string;
380
+ namespace: string;
381
+ type: "folder" | "file";
382
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
383
+ size: number | null;
384
+ contentType: string | null;
385
+ readonly: boolean;
386
+ hidden: boolean;
387
+ archivedAt: Date | null;
388
+ parentId: string | null;
389
+ links: {
390
+ view: string | null;
391
+ download: string | null;
392
+ preview: string | null;
393
+ thumbnail: string | null;
394
+ };
395
+ availability: "pending" | "ready" | "failed";
396
+ provider: "local";
397
+ assetId: string | null;
398
+ }>;
399
+ /**
400
+ * Sets the readonly state for multiple this.#nodes.
401
+ *
402
+ * This method is intended for bulk lock and unlock operations in the drive UI.
403
+ *
404
+ * @param ids - The node ids to update.
405
+ * @param readonly - The readonly state to apply.
406
+ * @returns A promise resolving to the updated this.#nodes.
407
+ * @throws {ORPCError} If no ids are provided or no matching this.#nodes are found.
408
+ */
409
+ setReadonly(ids: string[], readonly: boolean): Promise<{
410
+ id: string;
411
+ createdAt: Date;
412
+ updatedAt: Date;
413
+ name: string;
414
+ namespace: string;
415
+ type: "folder" | "file";
416
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
417
+ size: number | null;
418
+ contentType: string | null;
419
+ readonly: boolean;
420
+ hidden: boolean;
421
+ archivedAt: Date | null;
422
+ parentId: string | null;
423
+ links: {
424
+ view: string | null;
425
+ download: string | null;
426
+ preview: string | null;
427
+ thumbnail: string | null;
428
+ };
429
+ availability: "pending" | "ready" | "failed";
430
+ provider: "local";
431
+ assetId: string | null;
432
+ }[]>;
433
+ /**
434
+ * Archives this.#nodes by setting their archive timestamp.
435
+ *
436
+ * This is a drive-level archive state and does not delete the underlying
437
+ * storage assets.
438
+ *
439
+ * @param ids - The node ids to archive.
440
+ * @returns A promise resolving to the archived this.#nodes.
441
+ * @throws {ORPCError} If no ids are provided or no matching this.#nodes are found.
442
+ */
443
+ archiveNodes(ids: string[]): Promise<{
444
+ id: string;
445
+ createdAt: Date;
446
+ updatedAt: Date;
447
+ name: string;
448
+ namespace: string;
449
+ type: "folder" | "file";
450
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
451
+ size: number | null;
452
+ contentType: string | null;
453
+ readonly: boolean;
454
+ hidden: boolean;
455
+ archivedAt: Date | null;
456
+ parentId: string | null;
457
+ links: {
458
+ view: string | null;
459
+ download: string | null;
460
+ preview: string | null;
461
+ thumbnail: string | null;
462
+ };
463
+ availability: "pending" | "ready" | "failed";
464
+ provider: "local";
465
+ assetId: string | null;
466
+ }[]>;
467
+ /**
468
+ * Restores archived this.#nodes by clearing their archive timestamp.
469
+ *
470
+ * @param ids - The node ids to restore.
471
+ * @returns A promise resolving to the restored this.#nodes.
472
+ * @throws {ORPCError} If no ids are provided or no matching this.#nodes are found.
473
+ */
474
+ restoreNodes(ids: string[]): Promise<{
475
+ id: string;
476
+ createdAt: Date;
477
+ updatedAt: Date;
478
+ name: string;
479
+ namespace: string;
480
+ type: "folder" | "file";
481
+ subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
482
+ size: number | null;
483
+ contentType: string | null;
484
+ readonly: boolean;
485
+ hidden: boolean;
486
+ archivedAt: Date | null;
487
+ parentId: string | null;
488
+ links: {
489
+ view: string | null;
490
+ download: string | null;
491
+ preview: string | null;
492
+ thumbnail: string | null;
493
+ };
494
+ availability: "pending" | "ready" | "failed";
495
+ provider: "local";
496
+ assetId: string | null;
497
+ }[]>;
498
+ /**
499
+ * Permanently deletes a node subtree and all linked assets.
500
+ *
501
+ * The subtree includes the provided node and all descendants. Associated file
502
+ * assets and generated preview assets are purged from storage after the this.#nodes
503
+ * are removed from the drive catalog.
504
+ *
505
+ * @param id - The root node id to delete.
506
+ * @throws {ORPCError} If the node does not exist.
507
+ */
508
+ deleteNode(id: string): Promise<void>;
509
+ /**
510
+ * Permanently deletes multiple node subtrees and their linked assets.
511
+ *
512
+ * Each provided id is treated as a subtree root. All descendant this.#nodes are
513
+ * removed together with their main file assets and generated preview assets.
514
+ *
515
+ * @param ids - Root node ids to delete.
516
+ * @returns A promise that resolves when deletion completes.
517
+ * @throws {ORPCError} If no ids are provided or no matching this.#nodes are found.
518
+ */
519
+ deleteNodes(ids: string[]): Promise<void>;
520
+ }
521
+ //#endregion
522
+ export { LocalDrive, LocalDriveConfig };