@tulip-systems/drive 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/google/server.d.mts +2 -2
- package/dist/google/server.mjs +2 -2
- package/dist/google.d.mts +2 -2
- package/dist/google.mjs +2 -2
- package/dist/local/server.d.mts +2 -2
- package/dist/local/server.mjs +2 -2
- package/dist/local.d.mts +2 -2
- package/dist/local.mjs +2 -2
- package/dist/providers/google/lib/router.server.d.mts +107 -147
- package/dist/providers/google/lib/router.server.mjs +27 -33
- package/dist/providers/google/lib/service.server.d.mts +1 -1
- package/dist/providers/google/lib/validators.d.mts +76 -1
- package/dist/providers/google/lib/validators.mjs +22 -1
- package/dist/providers/local/lib/route-handler.server.d.mts +5 -3
- package/dist/providers/local/lib/route-handler.server.mjs +1 -1
- package/dist/providers/local/lib/router.server.d.mts +1202 -41226
- package/dist/providers/local/lib/router.server.mjs +35 -42
- package/dist/providers/local/lib/schema.mjs +1 -1
- package/dist/providers/local/lib/service.server.d.mts +38 -15
- package/dist/providers/local/lib/upload.client.d.mts +4 -4
- package/dist/providers/local/lib/upload.client.mjs +1 -1
- package/dist/providers/local/lib/validators.d.mts +1385 -9
- package/dist/providers/local/lib/validators.mjs +38 -3
- package/package.json +3 -3
- package/src/providers/google/lib/router.server.ts +55 -51
- package/src/providers/google/lib/service.server.ts +1 -1
- package/src/providers/google/lib/validators.ts +23 -0
- package/src/providers/local/lib/route-handler.server.ts +12 -10
- package/src/providers/local/lib/router.server.ts +211 -117
- package/src/providers/local/lib/schema.ts +1 -1
- package/src/providers/local/lib/service.server.ts +1 -1
- package/src/providers/local/lib/upload.client.ts +6 -6
- package/src/providers/local/lib/validators.ts +58 -5
|
@@ -1,51 +1,44 @@
|
|
|
1
|
-
import { createLocalDriveFolderInputSchema, getLocalDriveNodesByParentIdInputSchema, getLocalFileURLSchema, listLocalDriveFlatInputSchema, listLocalDriveTreeInputSchema, localDriveNodeSchema, localDriveNodeWithChildrenSchema, presignLocalDriveFileInputSchema, updateLocalDriveNodeInputSchema } from "./validators.mjs";
|
|
1
|
+
import { createLocalDriveFolderInputSchema, getLocalDriveNodesByParentIdInputSchema, getLocalFileURLSchema, listLocalDriveFlatInputSchema, listLocalDriveTreeInputSchema, localDriveFileNodeSchema, localDriveFlatResponseSchema, localDriveNodeParentSchema, localDriveNodeSchema, localDriveNodeWithChildrenSchema, localDrivePresignUploadOutputSchema, localDriveTreeResponseSchema, presignLocalDriveFileInputSchema, updateLocalDriveNodeInputSchema } from "./validators.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { oc } from "@orpc/contract";
|
|
4
4
|
import { bulkActionSchema } from "@tulip-systems/core/router";
|
|
5
5
|
|
|
6
6
|
//#region src/providers/local/lib/router.server.ts
|
|
7
7
|
/**
|
|
8
|
+
* Local Drive router contract defines the input and output schemas for local drive-related procedures.
|
|
9
|
+
*/
|
|
10
|
+
const localDriveRouterContract = {
|
|
11
|
+
getNodeWithChildren: oc.input(z.object({
|
|
12
|
+
id: z.string(),
|
|
13
|
+
namespace: z.string()
|
|
14
|
+
})).output(localDriveNodeWithChildrenSchema.nullable()),
|
|
15
|
+
getNodesByParentId: oc.input(getLocalDriveNodesByParentIdInputSchema).output(z.array(localDriveNodeSchema)),
|
|
16
|
+
listTree: oc.input(listLocalDriveTreeInputSchema).output(localDriveTreeResponseSchema),
|
|
17
|
+
listFlat: oc.input(listLocalDriveFlatInputSchema).output(localDriveFlatResponseSchema),
|
|
18
|
+
getFolderParents: oc.input(z.object({
|
|
19
|
+
id: z.string().nullable(),
|
|
20
|
+
namespace: z.string()
|
|
21
|
+
})).output(z.array(localDriveNodeParentSchema)),
|
|
22
|
+
getURL: oc.input(getLocalFileURLSchema.extend({ id: z.string() })).output(z.string().nullable()),
|
|
23
|
+
presignUpload: oc.input(presignLocalDriveFileInputSchema).output(localDrivePresignUploadOutputSchema),
|
|
24
|
+
confirmUpload: oc.input(z.object({ uploadId: z.string() })).output(localDriveFileNodeSchema),
|
|
25
|
+
createFolder: oc.input(createLocalDriveFolderInputSchema).output(localDriveNodeSchema),
|
|
26
|
+
updateNode: oc.input(z.object({
|
|
27
|
+
id: z.string(),
|
|
28
|
+
data: updateLocalDriveNodeInputSchema
|
|
29
|
+
})).output(localDriveNodeSchema),
|
|
30
|
+
setReadonly: oc.input(bulkActionSchema.extend({ readonly: z.boolean() })).output(z.array(localDriveNodeSchema)),
|
|
31
|
+
moveNode: oc.input(z.object({
|
|
32
|
+
id: z.string(),
|
|
33
|
+
parentId: z.string().nullish()
|
|
34
|
+
})).output(localDriveNodeSchema),
|
|
35
|
+
archiveNodes: oc.input(bulkActionSchema).output(z.array(localDriveNodeSchema)),
|
|
36
|
+
restoreNodes: oc.input(bulkActionSchema).output(z.array(localDriveNodeSchema)),
|
|
37
|
+
deleteNodes: oc.input(bulkActionSchema).output(z.void())
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
8
40
|
* Create Drive base procedures
|
|
9
41
|
*/
|
|
10
|
-
function createLocalDriveProcedures(drive) {
|
|
11
|
-
const { protectedProcedure } = initRPC();
|
|
12
|
-
return {
|
|
13
|
-
getNodeWithChildren: protectedProcedure.input(z.object({
|
|
14
|
-
id: z.string(),
|
|
15
|
-
namespace: z.string()
|
|
16
|
-
})).output(localDriveNodeWithChildrenSchema.nullable()).handler(async ({ input }) => drive.getNodeWithChildren(input)),
|
|
17
|
-
getNodesByParentId: protectedProcedure.input(getLocalDriveNodesByParentIdInputSchema).output(z.array(localDriveNodeSchema)).handler(async ({ input }) => drive.getNodesByParentId(input)),
|
|
18
|
-
listTree: protectedProcedure.input(listLocalDriveTreeInputSchema).handler(async ({ input }) => drive.listTree(input)),
|
|
19
|
-
listFlat: protectedProcedure.input(listLocalDriveFlatInputSchema).handler(async ({ input }) => drive.listFlat(input)),
|
|
20
|
-
getFolderParents: protectedProcedure.input(z.object({
|
|
21
|
-
id: z.string().nullable(),
|
|
22
|
-
namespace: z.string()
|
|
23
|
-
})).handler(async ({ input }) => drive.getFolderParents(input)),
|
|
24
|
-
getURL: protectedProcedure.input(getLocalFileURLSchema.extend({ id: z.string() })).output(z.string().nullable()).handler(async ({ input: { id, ...options } }) => {
|
|
25
|
-
const node = await drive.getNodeById(id);
|
|
26
|
-
if (!node) return null;
|
|
27
|
-
return await drive.getURL(node, options);
|
|
28
|
-
}),
|
|
29
|
-
presignUpload: protectedProcedure.input(presignLocalDriveFileInputSchema).handler(async ({ input }) => drive.presignUpload(input)),
|
|
30
|
-
confirmUpload: protectedProcedure.input(z.object({ uploadId: z.string() })).handler(async ({ input }) => drive.confirmUpload(input.uploadId)),
|
|
31
|
-
createFolder: protectedProcedure.input(createLocalDriveFolderInputSchema).output(localDriveNodeSchema).handler(async ({ input }) => drive.createFolder(input)),
|
|
32
|
-
updateNode: protectedProcedure.input(z.object({
|
|
33
|
-
id: z.string(),
|
|
34
|
-
data: updateLocalDriveNodeInputSchema
|
|
35
|
-
})).output(localDriveNodeSchema).handler(async ({ input }) => drive.updateNode(input.id, input.data)),
|
|
36
|
-
setReadonly: protectedProcedure.input(bulkActionSchema.extend({ readonly: z.boolean() })).output(z.array(localDriveNodeSchema)).handler(async ({ input }) => drive.setReadonly(input.ids, input.readonly)),
|
|
37
|
-
moveNode: protectedProcedure.input(z.object({
|
|
38
|
-
id: z.string(),
|
|
39
|
-
parentId: z.string().nullish()
|
|
40
|
-
})).output(localDriveNodeSchema).handler(async ({ input }) => drive.moveNode({
|
|
41
|
-
id: input.id,
|
|
42
|
-
parentId: input.parentId ?? null
|
|
43
|
-
})),
|
|
44
|
-
archiveNodes: protectedProcedure.input(bulkActionSchema).output(z.array(localDriveNodeSchema)).handler(async ({ input }) => drive.archiveNodes(input.ids)),
|
|
45
|
-
restoreNodes: protectedProcedure.input(bulkActionSchema).output(z.array(localDriveNodeSchema)).handler(async ({ input }) => drive.restoreNodes(input.ids)),
|
|
46
|
-
deleteNodes: protectedProcedure.input(bulkActionSchema).output(z.void()).handler(async ({ input }) => drive.deleteNodes(input.ids))
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
42
|
|
|
50
43
|
//#endregion
|
|
51
|
-
export {
|
|
44
|
+
export { localDriveRouterContract };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { imageVariants, nodeSubtypes } from "./constants.mjs";
|
|
2
|
-
import { baseColumns } from "@tulip-systems/core/
|
|
2
|
+
import { baseColumns } from "@tulip-systems/core/database";
|
|
3
3
|
import { imageDispositions, storageAssets } from "@tulip-systems/core/storage";
|
|
4
4
|
import { relations } from "drizzle-orm";
|
|
5
5
|
import { boolean, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DriveArchive, DriveDirectUpload, DriveNodeMutations, DrivePresignedUpload, DrivePreviewGenerator, DriveReader, DriveReadonly } from "../../../lib/contracts.mjs";
|
|
2
2
|
import { CreateLocalDriveFolderSchema, GetLocalDriveNodesByParentIdInput, GetLocalFileURLSchema, ListLocalDriveFlatSchema, ListLocalDriveTreeSchema, LocalDriveFileNode, LocalDriveNode, LocalDriveNodeChild, LocalDriveNodeWithAsset, LocalDriveNodeWithChildren, LocalNode, PresignLocalDriveFileInput, UpdateLocalDriveNodeInput, UploadLocalDriveFileSchema } from "./validators.mjs";
|
|
3
|
-
import { TDatabaseSchema } from "@tulip-systems/core/
|
|
3
|
+
import { TDatabaseSchema } from "@tulip-systems/core/database";
|
|
4
4
|
import { ObjectBodyInput } from "@tulip-systems/core/storage";
|
|
5
5
|
import { TableQueryResponse } from "@tulip-systems/core/data-tables/server";
|
|
6
6
|
import { Database } from "@tulip-systems/core/database/server";
|
|
@@ -106,17 +106,17 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
106
106
|
}): Promise<(Pick<{
|
|
107
107
|
name: string;
|
|
108
108
|
namespace: string;
|
|
109
|
-
|
|
110
|
-
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
111
|
-
size: number | null;
|
|
109
|
+
parentId: string | null;
|
|
112
110
|
contentType: string | null;
|
|
111
|
+
size: number | null;
|
|
112
|
+
type: "file" | "folder" | null;
|
|
113
113
|
readonly: boolean | null;
|
|
114
|
-
hidden: boolean | null;
|
|
115
|
-
archivedAt: Date | null;
|
|
116
|
-
parentId: string | null;
|
|
117
114
|
id: string;
|
|
115
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
118
116
|
createdAt: Date;
|
|
119
117
|
updatedAt: Date;
|
|
118
|
+
hidden: boolean | null;
|
|
119
|
+
archivedAt: Date | null;
|
|
120
120
|
assetId: string | null;
|
|
121
121
|
}, "name" | "parentId" | "id"> & {
|
|
122
122
|
depth: number;
|
|
@@ -247,19 +247,19 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
247
247
|
presignedUrl: string;
|
|
248
248
|
node: LocalDriveFileNode;
|
|
249
249
|
asset: {
|
|
250
|
-
contentType: string | null;
|
|
251
|
-
size: number | null;
|
|
252
|
-
metadata: unknown;
|
|
253
250
|
key: string;
|
|
254
|
-
status: "error" | "pending" | "ready";
|
|
255
251
|
id: string;
|
|
252
|
+
metadata: unknown;
|
|
253
|
+
name: string | null;
|
|
254
|
+
status: "error" | "pending" | "ready";
|
|
255
|
+
contentType: string | null;
|
|
256
|
+
size: number | null;
|
|
256
257
|
createdAt: Date;
|
|
257
258
|
updatedAt: Date;
|
|
258
|
-
name: string | null;
|
|
259
259
|
provider: "s3";
|
|
260
|
-
bucket: string;
|
|
261
|
-
visibility: "private" | "public";
|
|
262
260
|
uploadId: string;
|
|
261
|
+
visibility: "private" | "public";
|
|
262
|
+
bucket: string;
|
|
263
263
|
etag: string | null;
|
|
264
264
|
uploadedAt: Date;
|
|
265
265
|
deletedAt: Date | null;
|
|
@@ -278,7 +278,30 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
278
278
|
* @returns A promise resolving to the finalized file node.
|
|
279
279
|
* @throws {ServerError} If the asset or node cannot be resolved.
|
|
280
280
|
*/
|
|
281
|
-
confirmUpload(uploadId: string): Promise<
|
|
281
|
+
confirmUpload(uploadId: string): Promise<{
|
|
282
|
+
id: string;
|
|
283
|
+
createdAt: Date;
|
|
284
|
+
updatedAt: Date;
|
|
285
|
+
name: string;
|
|
286
|
+
namespace: string;
|
|
287
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
288
|
+
size: number | null;
|
|
289
|
+
contentType: string | null;
|
|
290
|
+
readonly: boolean;
|
|
291
|
+
hidden: boolean;
|
|
292
|
+
archivedAt: Date | null;
|
|
293
|
+
parentId: string | null;
|
|
294
|
+
links: {
|
|
295
|
+
view: string | null;
|
|
296
|
+
download: string | null;
|
|
297
|
+
preview: string | null;
|
|
298
|
+
thumbnail: string | null;
|
|
299
|
+
};
|
|
300
|
+
availability: "ready" | "pending" | "failed";
|
|
301
|
+
provider: "local";
|
|
302
|
+
assetId: string | null;
|
|
303
|
+
type: "file";
|
|
304
|
+
}>;
|
|
282
305
|
/**
|
|
283
306
|
* Generates preview assets for an image node.
|
|
284
307
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LocalDriveFileNode, LocalDriveNode, PresignLocalDriveFileInput, UpdateLocalDriveNodeInput } from "./validators.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { SelectStorageAssetSchema } from "@tulip-systems/core/storage";
|
|
3
3
|
import { BulkActionSchema } from "@tulip-systems/core/router";
|
|
4
4
|
|
|
5
5
|
//#region src/providers/local/lib/upload.client.d.ts
|
|
@@ -13,13 +13,13 @@ type LocalDriveUploadFileRequest = PresignLocalDriveFileInput & {
|
|
|
13
13
|
type LocalDriveUploadHooks = {
|
|
14
14
|
beforePresign?: (input: LocalDriveUploadFileRequest) => Promise<void> | void;
|
|
15
15
|
afterPresign?: (presignResult: {
|
|
16
|
-
asset:
|
|
16
|
+
asset: SelectStorageAssetSchema;
|
|
17
17
|
node: LocalDriveFileNode;
|
|
18
18
|
uploadId: string;
|
|
19
19
|
presignedUrl: string;
|
|
20
20
|
}) => Promise<void> | void;
|
|
21
21
|
beforeConfirm?: (presignResult: {
|
|
22
|
-
asset:
|
|
22
|
+
asset: SelectStorageAssetSchema;
|
|
23
23
|
node: LocalDriveFileNode;
|
|
24
24
|
uploadId: string;
|
|
25
25
|
presignedUrl: string;
|
|
@@ -41,7 +41,7 @@ type LocalDriveUploadClient = {
|
|
|
41
41
|
type CreateLocalDriveUploadClientProps = {
|
|
42
42
|
endpoints: {
|
|
43
43
|
presignUpload: (input: PresignLocalDriveFileInput) => Promise<{
|
|
44
|
-
asset:
|
|
44
|
+
asset: SelectStorageAssetSchema;
|
|
45
45
|
node: LocalDriveFileNode;
|
|
46
46
|
uploadId: string;
|
|
47
47
|
presignedUrl: string;
|