@tulip-systems/drive 0.10.1 → 0.10.3
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/lib/dto.d.mts +2 -2
- package/dist/lib/validators.d.mts +9 -9
- 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/config/filters.d.mts +1 -1
- package/dist/providers/google/lib/router.server.d.mts +121 -161
- package/dist/providers/google/lib/router.server.mjs +27 -33
- package/dist/providers/google/lib/search-params.d.mts +1 -1
- package/dist/providers/google/lib/service.server.d.mts +1 -1
- package/dist/providers/google/lib/validators.d.mts +88 -13
- package/dist/providers/google/lib/validators.mjs +22 -1
- package/dist/providers/local/config/filters.d.mts +1 -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 +1248 -41272
- package/dist/providers/local/lib/router.server.mjs +35 -42
- package/dist/providers/local/lib/schema.d.mts +2 -2
- package/dist/providers/local/lib/schema.mjs +1 -1
- package/dist/providers/local/lib/search-params.d.mts +1 -1
- package/dist/providers/local/lib/service.server.d.mts +39 -16
- 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 +1403 -27
- 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
|
@@ -3,8 +3,8 @@ import { createDriveFolderInputSchema, presignDriveFileInputSchema, updateDriveN
|
|
|
3
3
|
import { imageVariants } from "./constants.mjs";
|
|
4
4
|
import { localDriveFilters } from "../config/filters.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import { resolveFiltersSchema, tableQuerySchema } from "@tulip-systems/core/data-tables";
|
|
7
|
-
import { getAssetURLSchema, storageAssetVisibilitySchema } from "@tulip-systems/core/storage";
|
|
6
|
+
import { resolveFiltersSchema, tableQueryPaginationResponseSchema, tableQuerySchema } from "@tulip-systems/core/data-tables";
|
|
7
|
+
import { getAssetURLSchema, selectStorageAssetSchema, storageAssetVisibilitySchema } from "@tulip-systems/core/storage";
|
|
8
8
|
|
|
9
9
|
//#region src/providers/local/lib/validators.ts
|
|
10
10
|
const localDriveNodeSchema = driveNodeSchema.extend({
|
|
@@ -12,6 +12,41 @@ const localDriveNodeSchema = driveNodeSchema.extend({
|
|
|
12
12
|
assetId: z.string().nullable()
|
|
13
13
|
});
|
|
14
14
|
/**
|
|
15
|
+
* File node & folder node
|
|
16
|
+
*/
|
|
17
|
+
const localDriveFileNodeSchema = localDriveNodeSchema.extend({ type: z.literal("file") });
|
|
18
|
+
const localDriveFolderNodeSchema = localDriveNodeSchema.extend({ type: z.literal("folder") });
|
|
19
|
+
/**
|
|
20
|
+
* Node with asset
|
|
21
|
+
*/
|
|
22
|
+
const localDriveNodeWithAssetSchema = localDriveNodeSchema.extend({ asset: selectStorageAssetSchema.nullable() });
|
|
23
|
+
/**
|
|
24
|
+
* Presign upload response
|
|
25
|
+
*/
|
|
26
|
+
const localDrivePresignUploadOutputSchema = z.object({
|
|
27
|
+
uploadId: z.string(),
|
|
28
|
+
presignedUrl: z.string(),
|
|
29
|
+
node: localDriveFileNodeSchema,
|
|
30
|
+
asset: selectStorageAssetSchema
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Node parent
|
|
34
|
+
*/
|
|
35
|
+
const localDriveNodeParentSchema = z.object({
|
|
36
|
+
id: z.string(),
|
|
37
|
+
name: z.string(),
|
|
38
|
+
parentId: z.string().nullable(),
|
|
39
|
+
depth: z.number()
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Tree response
|
|
43
|
+
*/
|
|
44
|
+
const localDriveTreeResponseSchema = z.object({
|
|
45
|
+
data: z.array(localDriveNodeWithAssetSchema),
|
|
46
|
+
pagination: tableQueryPaginationResponseSchema
|
|
47
|
+
});
|
|
48
|
+
const localDriveFlatResponseSchema = localDriveTreeResponseSchema;
|
|
49
|
+
/**
|
|
15
50
|
* Node with children
|
|
16
51
|
*/
|
|
17
52
|
const localDriveNodeWithChildrenSchema = localDriveNodeSchema.extend({ children: z.array(localDriveNodeSchema) });
|
|
@@ -92,4 +127,4 @@ const getLocalDriveNodesByParentIdInputSchema = tableQuerySchema.pick({
|
|
|
92
127
|
}).extend({ filters: localDriveTreeFiltersSchema });
|
|
93
128
|
|
|
94
129
|
//#endregion
|
|
95
|
-
export { createLocalDriveFolderInputSchema, getLocalDriveNodesByParentIdInputSchema, getLocalFileURLSchema, getLocalFileURLSchemaDefaults, listLocalDriveFlatInputSchema, listLocalDriveTreeInputSchema, localDriveFlatFiltersSchema, localDriveNodeSchema, localDriveNodeWithChildrenSchema, localDriveTreeFiltersSchema, presignLocalDriveFileInputSchema, updateLocalDriveNodeInputSchema, uploadLocalDriveFileInputSchema };
|
|
130
|
+
export { createLocalDriveFolderInputSchema, getLocalDriveNodesByParentIdInputSchema, getLocalFileURLSchema, getLocalFileURLSchemaDefaults, listLocalDriveFlatInputSchema, listLocalDriveTreeInputSchema, localDriveFileNodeSchema, localDriveFlatFiltersSchema, localDriveFlatResponseSchema, localDriveFolderNodeSchema, localDriveNodeParentSchema, localDriveNodeSchema, localDriveNodeWithAssetSchema, localDriveNodeWithChildrenSchema, localDrivePresignUploadOutputSchema, localDriveTreeFiltersSchema, localDriveTreeResponseSchema, presignLocalDriveFileInputSchema, updateLocalDriveNodeInputSchema, uploadLocalDriveFileInputSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tulip-systems/drive",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@dnd-kit/utilities": "^3.2.2",
|
|
29
29
|
"@hookform/resolvers": "^5.2.2",
|
|
30
30
|
"@orpc/client": "^1.14.2",
|
|
31
|
-
"@orpc/contract": "
|
|
31
|
+
"@orpc/contract": "1.14.2",
|
|
32
32
|
"@orpc/server": "^1.14.2",
|
|
33
33
|
"@orpc/tanstack-query": "^1.14.2",
|
|
34
34
|
"@tanstack/react-query": "^5.100.9",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"uuid": "^14.0.0",
|
|
66
66
|
"vaul": "^1.1.2",
|
|
67
67
|
"zod": "^4.4.3",
|
|
68
|
-
"@tulip-systems/core": "0.10.
|
|
68
|
+
"@tulip-systems/core": "0.10.3"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@tailwindcss/typography": "^0.5.19",
|
|
@@ -1,62 +1,66 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { oc } from "@orpc/contract";
|
|
2
2
|
import { bulkActionSchema } from "@tulip-systems/core/router";
|
|
3
|
-
import { initRPC } from "@tulip-systems/core/router/server";
|
|
4
3
|
import { z } from "zod";
|
|
5
|
-
import type { GoogleDrive } from "./service.server";
|
|
6
4
|
import {
|
|
7
5
|
createGoogleDriveFolderInputSchema,
|
|
8
6
|
getGoogleDriveNodesByParentIdInputSchema,
|
|
7
|
+
googleDriveNodeParentSchema,
|
|
9
8
|
googleDriveNodeSchema,
|
|
10
9
|
googleDriveNodeWithChildrenSchema,
|
|
10
|
+
googleDriveTreeResponseSchema,
|
|
11
11
|
listGoogleDriveTreeInputSchema,
|
|
12
12
|
updateGoogleDriveNodeInputSchema,
|
|
13
13
|
} from "./validators";
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
15
|
+
export const googleDriveRouterContract = {
|
|
16
|
+
/**
|
|
17
|
+
* Get node with children
|
|
18
|
+
*/
|
|
19
|
+
getNodeWithChildren: oc
|
|
20
|
+
.input(z.object({ id: z.string(), namespace: z.string() }))
|
|
21
|
+
.output(googleDriveNodeWithChildrenSchema.nullable()),
|
|
22
|
+
/**
|
|
23
|
+
* Get folders by parent id
|
|
24
|
+
*/
|
|
25
|
+
getNodesByParentId: oc
|
|
26
|
+
.input(getGoogleDriveNodesByParentIdInputSchema)
|
|
27
|
+
.output(z.array(googleDriveNodeSchema)),
|
|
28
|
+
/**
|
|
29
|
+
* List tree nodes with pagination and search.
|
|
30
|
+
*/
|
|
31
|
+
listTree: oc.input(listGoogleDriveTreeInputSchema).output(googleDriveTreeResponseSchema),
|
|
32
|
+
/**
|
|
33
|
+
* Get parents of a folder
|
|
34
|
+
*/
|
|
35
|
+
getFolderParents: oc
|
|
36
|
+
.input(z.object({ id: z.string().nullable(), namespace: z.string() }))
|
|
37
|
+
.output(z.array(googleDriveNodeParentSchema)),
|
|
38
|
+
/**
|
|
39
|
+
* Create a folder
|
|
40
|
+
*/
|
|
41
|
+
createFolder: oc.input(createGoogleDriveFolderInputSchema).output(googleDriveNodeSchema),
|
|
42
|
+
/**
|
|
43
|
+
* Update node
|
|
44
|
+
*/
|
|
45
|
+
updateNode: oc
|
|
46
|
+
.input(z.object({ id: z.string(), data: updateGoogleDriveNodeInputSchema }))
|
|
47
|
+
.output(googleDriveNodeSchema),
|
|
48
|
+
/**
|
|
49
|
+
* Move node
|
|
50
|
+
*/
|
|
51
|
+
moveNode: oc
|
|
52
|
+
.input(z.object({ id: z.string(), parentId: z.string().nullish() }))
|
|
53
|
+
.output(googleDriveNodeSchema),
|
|
54
|
+
/**
|
|
55
|
+
* Archive nodes
|
|
56
|
+
*/
|
|
57
|
+
archiveNodes: oc.input(bulkActionSchema).output(z.array(googleDriveNodeSchema)),
|
|
58
|
+
/**
|
|
59
|
+
* Restore nodes
|
|
60
|
+
*/
|
|
61
|
+
restoreNodes: oc.input(bulkActionSchema).output(z.array(googleDriveNodeSchema)),
|
|
62
|
+
/**
|
|
63
|
+
* Delete nodes
|
|
64
|
+
*/
|
|
65
|
+
deleteNodes: oc.input(bulkActionSchema).output(z.void()),
|
|
66
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { TDatabaseSchema } from "@tulip-systems/core/config";
|
|
2
1
|
import type { TableQuerySchema } from "@tulip-systems/core/data-tables";
|
|
3
2
|
import type { TableQueryResponse } from "@tulip-systems/core/data-tables/server";
|
|
3
|
+
import type { TDatabaseSchema } from "@tulip-systems/core/database";
|
|
4
4
|
import type { Database } from "@tulip-systems/core/database/server";
|
|
5
5
|
import { ServerError } from "@tulip-systems/core/router/server";
|
|
6
6
|
import type { ObjectBodyInput } from "@tulip-systems/core/storage";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tableQueryPaginationResponseSchema } from "@tulip-systems/core/data-tables";
|
|
1
2
|
import z from "zod";
|
|
2
3
|
import { type DriveNodeChild, driveNodeSchema } from "@/lib/dto";
|
|
3
4
|
import {
|
|
@@ -78,6 +79,28 @@ export const googleDriveNodeSchema = driveNodeSchema.extend({
|
|
|
78
79
|
export type GoogleDriveNode = z.infer<typeof googleDriveNodeSchema>;
|
|
79
80
|
export type GoogleDriveNodeChild = DriveNodeChild<GoogleDriveNode>;
|
|
80
81
|
|
|
82
|
+
/**
|
|
83
|
+
* GoogleDriveNodeParent schema
|
|
84
|
+
* @description zod schema for validating the shape of a GoogleDriveNode parent
|
|
85
|
+
*/
|
|
86
|
+
export const googleDriveNodeParentSchema = z.object({
|
|
87
|
+
id: z.string(),
|
|
88
|
+
name: z.string(),
|
|
89
|
+
parentId: z.string().nullable(),
|
|
90
|
+
depth: z.number(),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* GoogleDriveTreeResponse schema
|
|
95
|
+
* @description zod schema for validating the shape of a GoogleDriveTreeResponse
|
|
96
|
+
* @see TableQueryResponse<TData> for the common response shape
|
|
97
|
+
* @see TableQueryPaginationResponse for the common pagination shape
|
|
98
|
+
*/
|
|
99
|
+
export const googleDriveTreeResponseSchema = z.object({
|
|
100
|
+
data: z.array(googleDriveNodeSchema),
|
|
101
|
+
pagination: tableQueryPaginationResponseSchema,
|
|
102
|
+
});
|
|
103
|
+
|
|
81
104
|
/**
|
|
82
105
|
* GoogleDriveNodeWithChildren schema
|
|
83
106
|
* @description zod schema for validating the shape of a GoogleDriveNode with children
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { getSession } from "@tulip-systems/core/auth/server";
|
|
2
|
-
import type {
|
|
1
|
+
import { getSession, type TAuthServerOptions } from "@tulip-systems/core/auth/server";
|
|
2
|
+
import type { TulipContext } from "@tulip-systems/core/config";
|
|
3
|
+
import type { TDatabaseSchema } from "@tulip-systems/core/database";
|
|
3
4
|
import { ServerError } from "@tulip-systems/core/router/server";
|
|
4
5
|
import { connection, type NextRequest } from "next/server";
|
|
5
6
|
import z from "zod";
|
|
@@ -10,10 +11,10 @@ type RouteCtx = {
|
|
|
10
11
|
params: Promise<{ rest?: string[] }>;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
type CreateLocalDriveRouteHandlerProps<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
> & {
|
|
14
|
+
type CreateLocalDriveRouteHandlerProps<
|
|
15
|
+
TSchema extends TDatabaseSchema,
|
|
16
|
+
TAuthOptions extends TAuthServerOptions,
|
|
17
|
+
> = Pick<TulipContext<TSchema, TAuthOptions>, "auth"> & {
|
|
17
18
|
drive: LocalDrive<TSchema>;
|
|
18
19
|
};
|
|
19
20
|
|
|
@@ -28,9 +29,10 @@ type CreateLocalDriveRouteHandlerProps<TSchema extends TDatabaseSchema> = Pick<
|
|
|
28
29
|
* @param props - Route handler dependencies.
|
|
29
30
|
* @returns Next.js route handlers for GET, POST, PUT, PATCH, and DELETE.
|
|
30
31
|
*/
|
|
31
|
-
export function createLocalDriveRouteHandler<
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
export function createLocalDriveRouteHandler<
|
|
33
|
+
TSchema extends TDatabaseSchema,
|
|
34
|
+
TAuthOptions extends TAuthServerOptions,
|
|
35
|
+
>(context: CreateLocalDriveRouteHandlerProps<TSchema, TAuthOptions>) {
|
|
34
36
|
/**
|
|
35
37
|
* GET /api/drive/[[...rest]]
|
|
36
38
|
*
|
|
@@ -76,7 +78,7 @@ export function createLocalDriveRouteHandler<TSchema extends TDatabaseSchema>(
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
if (asset.visibility === "private") {
|
|
79
|
-
const session = await getSession(context);
|
|
81
|
+
const session = await getSession(context.auth);
|
|
80
82
|
|
|
81
83
|
if (!session) {
|
|
82
84
|
return Response.json(
|
|
@@ -1,137 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type InferContractRouterInputs,
|
|
3
|
+
type InferContractRouterOutputs,
|
|
4
|
+
oc,
|
|
5
|
+
} from "@orpc/contract";
|
|
1
6
|
import { bulkActionSchema } from "@tulip-systems/core/router";
|
|
2
|
-
import { initRPC } from "@tulip-systems/core/router/server";
|
|
3
7
|
import { z } from "zod";
|
|
4
|
-
import type { DriveSchema } from "./schema";
|
|
5
|
-
import type { LocalDrive } from "./service.server";
|
|
6
8
|
import {
|
|
7
9
|
createLocalDriveFolderInputSchema,
|
|
8
10
|
getLocalDriveNodesByParentIdInputSchema,
|
|
9
11
|
getLocalFileURLSchema,
|
|
10
12
|
listLocalDriveFlatInputSchema,
|
|
11
13
|
listLocalDriveTreeInputSchema,
|
|
14
|
+
localDriveFileNodeSchema,
|
|
15
|
+
localDriveFlatResponseSchema,
|
|
16
|
+
localDriveNodeParentSchema,
|
|
12
17
|
localDriveNodeSchema,
|
|
13
18
|
localDriveNodeWithChildrenSchema,
|
|
19
|
+
localDrivePresignUploadOutputSchema,
|
|
20
|
+
localDriveTreeResponseSchema,
|
|
14
21
|
presignLocalDriveFileInputSchema,
|
|
15
22
|
updateLocalDriveNodeInputSchema,
|
|
16
23
|
} from "./validators";
|
|
17
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Local Drive router contract defines the input and output schemas for local drive-related procedures.
|
|
27
|
+
*/
|
|
28
|
+
export const localDriveRouterContract = {
|
|
29
|
+
/**
|
|
30
|
+
* Get node with children
|
|
31
|
+
*/
|
|
32
|
+
getNodeWithChildren: oc
|
|
33
|
+
.input(z.object({ id: z.string(), namespace: z.string() }))
|
|
34
|
+
.output(localDriveNodeWithChildrenSchema.nullable()),
|
|
35
|
+
/**
|
|
36
|
+
* Get folders by parent id
|
|
37
|
+
*/
|
|
38
|
+
getNodesByParentId: oc
|
|
39
|
+
.input(getLocalDriveNodesByParentIdInputSchema)
|
|
40
|
+
.output(z.array(localDriveNodeSchema)),
|
|
41
|
+
/**
|
|
42
|
+
* List tree nodes with pagination and search.
|
|
43
|
+
*/
|
|
44
|
+
listTree: oc.input(listLocalDriveTreeInputSchema).output(localDriveTreeResponseSchema),
|
|
45
|
+
/**
|
|
46
|
+
* List flat nodes with pagination and search.
|
|
47
|
+
*/
|
|
48
|
+
listFlat: oc.input(listLocalDriveFlatInputSchema).output(localDriveFlatResponseSchema),
|
|
49
|
+
/**
|
|
50
|
+
* Get parents of a folder
|
|
51
|
+
*/
|
|
52
|
+
getFolderParents: oc
|
|
53
|
+
.input(z.object({ id: z.string().nullable(), namespace: z.string() }))
|
|
54
|
+
.output(z.array(localDriveNodeParentSchema)),
|
|
55
|
+
/**
|
|
56
|
+
* Get url for opening a file
|
|
57
|
+
*/
|
|
58
|
+
getURL: oc.input(getLocalFileURLSchema.extend({ id: z.string() })).output(z.string().nullable()),
|
|
59
|
+
/**
|
|
60
|
+
* Create a direct upload intent for a file
|
|
61
|
+
*/
|
|
62
|
+
presignUpload: oc
|
|
63
|
+
.input(presignLocalDriveFileInputSchema)
|
|
64
|
+
.output(localDrivePresignUploadOutputSchema),
|
|
65
|
+
/**
|
|
66
|
+
* Confirm a direct upload intent
|
|
67
|
+
*/
|
|
68
|
+
confirmUpload: oc.input(z.object({ uploadId: z.string() })).output(localDriveFileNodeSchema),
|
|
69
|
+
/**
|
|
70
|
+
* Create a folder
|
|
71
|
+
*/
|
|
72
|
+
createFolder: oc.input(createLocalDriveFolderInputSchema).output(localDriveNodeSchema),
|
|
73
|
+
/**
|
|
74
|
+
* Update node
|
|
75
|
+
*/
|
|
76
|
+
updateNode: oc
|
|
77
|
+
.input(z.object({ id: z.string(), data: updateLocalDriveNodeInputSchema }))
|
|
78
|
+
.output(localDriveNodeSchema),
|
|
79
|
+
/**
|
|
80
|
+
* Set readonly
|
|
81
|
+
*/
|
|
82
|
+
setReadonly: oc
|
|
83
|
+
.input(bulkActionSchema.extend({ readonly: z.boolean() }))
|
|
84
|
+
.output(z.array(localDriveNodeSchema)),
|
|
85
|
+
/**
|
|
86
|
+
* Move node
|
|
87
|
+
*/
|
|
88
|
+
moveNode: oc
|
|
89
|
+
.input(z.object({ id: z.string(), parentId: z.string().nullish() }))
|
|
90
|
+
.output(localDriveNodeSchema),
|
|
91
|
+
/**
|
|
92
|
+
* Archive nodes
|
|
93
|
+
*/
|
|
94
|
+
archiveNodes: oc.input(bulkActionSchema).output(z.array(localDriveNodeSchema)),
|
|
95
|
+
/**
|
|
96
|
+
* Restore nodes
|
|
97
|
+
*/
|
|
98
|
+
restoreNodes: oc.input(bulkActionSchema).output(z.array(localDriveNodeSchema)),
|
|
99
|
+
/**
|
|
100
|
+
* Delete nodes
|
|
101
|
+
*/
|
|
102
|
+
deleteNodes: oc.input(bulkActionSchema).output(z.void()),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type LocalDriveRouterContractInputs = InferContractRouterInputs<
|
|
106
|
+
typeof localDriveRouterContract
|
|
107
|
+
>;
|
|
108
|
+
export type LocalDriveRouterContractOutputs = InferContractRouterOutputs<
|
|
109
|
+
typeof localDriveRouterContract
|
|
110
|
+
>;
|
|
111
|
+
|
|
18
112
|
/**
|
|
19
113
|
* Create Drive base procedures
|
|
20
114
|
*/
|
|
21
|
-
export function createLocalDriveProcedures(drive: LocalDrive<DriveSchema>) {
|
|
22
|
-
|
|
115
|
+
// export function createLocalDriveProcedures(drive: LocalDrive<DriveSchema>) {
|
|
116
|
+
// const rpc = RPC.init<DriveSchema, TAuthServerOptions>();
|
|
23
117
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
118
|
+
// return {
|
|
119
|
+
// /**
|
|
120
|
+
// * Get node with children
|
|
121
|
+
// */
|
|
122
|
+
// getNodeWithChildren: rpc
|
|
123
|
+
// .input(z.object({ id: z.string(), namespace: z.string() }))
|
|
124
|
+
// .output(localDriveNodeWithChildrenSchema.nullable())
|
|
125
|
+
// .handler(async ({ input }) => drive.getNodeWithChildren(input)),
|
|
126
|
+
// /**
|
|
127
|
+
// * Get folders by parent id
|
|
128
|
+
// */
|
|
129
|
+
// getNodesByParentId: rpc
|
|
130
|
+
// .input(getLocalDriveNodesByParentIdInputSchema)
|
|
131
|
+
// .output(z.array(localDriveNodeSchema))
|
|
132
|
+
// .handler(async ({ input }) => drive.getNodesByParentId(input)),
|
|
133
|
+
// /**
|
|
134
|
+
// * List tree nodes with pagination and search.
|
|
135
|
+
// */
|
|
136
|
+
// listTree: rpc
|
|
137
|
+
// .input(listLocalDriveTreeInputSchema)
|
|
138
|
+
// .handler(async ({ input }) => drive.listTree(input)),
|
|
139
|
+
// /**
|
|
140
|
+
// * List flat nodes with pagination and search.
|
|
141
|
+
// */
|
|
142
|
+
// listFlat: rpc
|
|
143
|
+
// .input(listLocalDriveFlatInputSchema)
|
|
144
|
+
// .handler(async ({ input }) => drive.listFlat(input)),
|
|
145
|
+
// /**
|
|
146
|
+
// * Get parents of a folder
|
|
147
|
+
// */
|
|
148
|
+
// getFolderParents: rpc
|
|
149
|
+
// .input(z.object({ id: z.string().nullable(), namespace: z.string() }))
|
|
150
|
+
// .handler(async ({ input }) => drive.getFolderParents(input)),
|
|
151
|
+
// /**
|
|
152
|
+
// * Get url for opening a file
|
|
153
|
+
// */
|
|
154
|
+
// getURL: rpc
|
|
155
|
+
// .input(getLocalFileURLSchema.extend({ id: z.string() }))
|
|
156
|
+
// .output(z.string().nullable())
|
|
157
|
+
// .handler(async ({ input: { id, ...options } }) => {
|
|
158
|
+
// const node = await drive.getNodeById(id);
|
|
159
|
+
// if (!node) return null;
|
|
66
160
|
|
|
67
|
-
|
|
68
|
-
|
|
161
|
+
// return await drive.getURL(node, options);
|
|
162
|
+
// }),
|
|
69
163
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
164
|
+
// /**
|
|
165
|
+
// * Create a direct upload intent for a file
|
|
166
|
+
// */
|
|
167
|
+
// presignUpload: rpc
|
|
168
|
+
// .input(presignLocalDriveFileInputSchema)
|
|
169
|
+
// .handler(async ({ input }) => drive.presignUpload(input)),
|
|
170
|
+
// /**
|
|
171
|
+
// * Confirm a direct upload intent
|
|
172
|
+
// */
|
|
173
|
+
// confirmUpload: rpc
|
|
174
|
+
// .input(z.object({ uploadId: z.string() }))
|
|
175
|
+
// .handler(async ({ input }) => drive.confirmUpload(input.uploadId)),
|
|
176
|
+
// /**
|
|
177
|
+
// * Create a folder
|
|
178
|
+
// */
|
|
179
|
+
// createFolder: rpc
|
|
180
|
+
// .input(createLocalDriveFolderInputSchema)
|
|
181
|
+
// .output(localDriveNodeSchema)
|
|
182
|
+
// .handler(async ({ input }) => drive.createFolder(input)),
|
|
183
|
+
// /**
|
|
184
|
+
// * Update node
|
|
185
|
+
// */
|
|
186
|
+
// updateNode: rpc
|
|
187
|
+
// .input(z.object({ id: z.string(), data: updateLocalDriveNodeInputSchema }))
|
|
188
|
+
// .output(localDriveNodeSchema)
|
|
189
|
+
// .handler(async ({ input }) => drive.updateNode(input.id, input.data)),
|
|
190
|
+
// /**
|
|
191
|
+
// * Set readonly
|
|
192
|
+
// */
|
|
193
|
+
// setReadonly: rpc
|
|
194
|
+
// .input(bulkActionSchema.extend({ readonly: z.boolean() }))
|
|
195
|
+
// .output(z.array(localDriveNodeSchema))
|
|
196
|
+
// .handler(async ({ input }) => drive.setReadonly(input.ids, input.readonly)),
|
|
197
|
+
// /**
|
|
198
|
+
// * Move node
|
|
199
|
+
// */
|
|
200
|
+
// moveNode: rpc
|
|
201
|
+
// .input(z.object({ id: z.string(), parentId: z.string().nullish() }))
|
|
202
|
+
// .output(localDriveNodeSchema)
|
|
203
|
+
// .handler(async ({ input }) =>
|
|
204
|
+
// drive.moveNode({
|
|
205
|
+
// id: input.id,
|
|
206
|
+
// parentId: input.parentId ?? null,
|
|
207
|
+
// }),
|
|
208
|
+
// ),
|
|
209
|
+
// /**
|
|
210
|
+
// * Archive nodes
|
|
211
|
+
// */
|
|
212
|
+
// archiveNodes: rpc
|
|
213
|
+
// .input(bulkActionSchema)
|
|
214
|
+
// .output(z.array(localDriveNodeSchema))
|
|
215
|
+
// .handler(async ({ input }) => drive.archiveNodes(input.ids)),
|
|
216
|
+
// /**
|
|
217
|
+
// * Restore nodes
|
|
218
|
+
// */
|
|
219
|
+
// restoreNodes: rpc
|
|
220
|
+
// .input(bulkActionSchema)
|
|
221
|
+
// .output(z.array(localDriveNodeSchema))
|
|
222
|
+
// .handler(async ({ input }) => drive.restoreNodes(input.ids)),
|
|
223
|
+
// /**
|
|
224
|
+
// * Delete nodes
|
|
225
|
+
// */
|
|
226
|
+
// deleteNodes: rpc
|
|
227
|
+
// .input(bulkActionSchema)
|
|
228
|
+
// .output(z.void())
|
|
229
|
+
// .handler(async ({ input }) => drive.deleteNodes(input.ids)),
|
|
230
|
+
// };
|
|
231
|
+
// }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { baseColumns } from "@tulip-systems/core/
|
|
1
|
+
import { baseColumns } from "@tulip-systems/core/database";
|
|
2
2
|
import { imageDispositions, storageAssets } from "@tulip-systems/core/storage";
|
|
3
3
|
import { relations } from "drizzle-orm";
|
|
4
4
|
import { type AnyPgColumn, boolean, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
|