@tulip-systems/drive 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/grid-card.client.d.mts +1 -1
- package/dist/lib/dto.d.mts +2 -2
- package/dist/lib/validators.d.mts +9 -9
- package/dist/providers/google/components/view.client.d.mts +1 -1
- package/dist/providers/google/components/view.client.mjs +2 -2
- package/dist/providers/google/config/filters.d.mts +1 -1
- package/dist/providers/google/lib/router.server.d.mts +18 -18
- package/dist/providers/google/lib/search-params.d.mts +1 -1
- package/dist/providers/google/lib/validators.d.mts +12 -12
- package/dist/providers/local/components/view.client.d.mts +1 -1
- package/dist/providers/local/components/view.client.mjs +2 -2
- package/dist/providers/local/config/filters.d.mts +1 -1
- package/dist/providers/local/config/sorting.mjs +16 -0
- package/dist/providers/local/lib/router.server.d.mts +101 -101
- package/dist/providers/local/lib/schema.d.mts +2 -2
- package/dist/providers/local/lib/search-params.d.mts +1 -1
- package/dist/providers/local/lib/service.server.d.mts +11 -11
- package/dist/providers/local/lib/service.server.mjs +9 -8
- package/dist/providers/local/lib/validators.d.mts +18 -18
- package/package.json +2 -2
- package/src/components/grid-card.client.tsx +1 -1
- package/src/providers/google/components/view.client.tsx +4 -3
- package/src/providers/local/components/view.client.tsx +4 -3
- package/src/providers/local/config/sorting.ts +16 -0
- package/src/providers/local/lib/service.server.ts +8 -19
|
@@ -49,7 +49,7 @@ declare const nodes: drizzle_orm_pg_core0.PgTableWithColumns<{
|
|
|
49
49
|
tableName: "nodes";
|
|
50
50
|
dataType: "string";
|
|
51
51
|
columnType: "PgEnumColumn";
|
|
52
|
-
data: "
|
|
52
|
+
data: "folder" | "file";
|
|
53
53
|
driverParam: string;
|
|
54
54
|
notNull: false;
|
|
55
55
|
hasDefault: false;
|
|
@@ -604,7 +604,7 @@ declare const driveSchema: {
|
|
|
604
604
|
tableName: "nodes";
|
|
605
605
|
dataType: "string";
|
|
606
606
|
columnType: "PgEnumColumn";
|
|
607
|
-
data: "
|
|
607
|
+
data: "folder" | "file";
|
|
608
608
|
driverParam: string;
|
|
609
609
|
notNull: false;
|
|
610
610
|
hasDefault: false;
|
|
@@ -4,7 +4,7 @@ import * as nuqs_server0 from "nuqs/server";
|
|
|
4
4
|
declare const localDriveTreeFilterSearchParams: {
|
|
5
5
|
readonly subtypes: nuqs_server0.SingleParserBuilder<("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null>;
|
|
6
6
|
readonly hidden: nuqs_server0.SingleParserBuilder<boolean | null>;
|
|
7
|
-
readonly types: nuqs_server0.SingleParserBuilder<("
|
|
7
|
+
readonly types: nuqs_server0.SingleParserBuilder<("folder" | "file")[] | null>;
|
|
8
8
|
readonly contentTypes: nuqs_server0.SingleParserBuilder<string[] | null>;
|
|
9
9
|
readonly nodeIds: nuqs_server0.SingleParserBuilder<string[] | null>;
|
|
10
10
|
readonly isArchived: nuqs_server0.SingleParserBuilder<boolean | null>;
|
|
@@ -104,16 +104,16 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
104
104
|
id: string | null;
|
|
105
105
|
namespace: string;
|
|
106
106
|
}): Promise<(Pick<{
|
|
107
|
+
type: "folder" | "file" | null;
|
|
108
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
107
109
|
id: string;
|
|
108
110
|
createdAt: Date;
|
|
109
111
|
updatedAt: Date;
|
|
110
112
|
name: string;
|
|
111
|
-
|
|
112
|
-
readonly: boolean | null;
|
|
113
|
+
namespace: string;
|
|
113
114
|
size: number | null;
|
|
114
115
|
contentType: string | null;
|
|
115
|
-
|
|
116
|
-
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
116
|
+
readonly: boolean | null;
|
|
117
117
|
hidden: boolean | null;
|
|
118
118
|
archivedAt: Date | null;
|
|
119
119
|
parentId: string | null;
|
|
@@ -172,7 +172,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
172
172
|
updatedAt: Date;
|
|
173
173
|
name: string;
|
|
174
174
|
namespace: string;
|
|
175
|
-
type: "
|
|
175
|
+
type: "folder" | "file";
|
|
176
176
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
177
177
|
size: number | null;
|
|
178
178
|
contentType: string | null;
|
|
@@ -211,7 +211,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
211
211
|
updatedAt: Date;
|
|
212
212
|
name: string;
|
|
213
213
|
namespace: string;
|
|
214
|
-
type: "
|
|
214
|
+
type: "folder" | "file";
|
|
215
215
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
216
216
|
size: number | null;
|
|
217
217
|
contentType: string | null;
|
|
@@ -309,7 +309,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
309
309
|
updatedAt: Date;
|
|
310
310
|
name: string;
|
|
311
311
|
namespace: string;
|
|
312
|
-
type: "
|
|
312
|
+
type: "folder" | "file";
|
|
313
313
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
314
314
|
size: number | null;
|
|
315
315
|
contentType: string | null;
|
|
@@ -344,7 +344,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
344
344
|
updatedAt: Date;
|
|
345
345
|
name: string;
|
|
346
346
|
namespace: string;
|
|
347
|
-
type: "
|
|
347
|
+
type: "folder" | "file";
|
|
348
348
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
349
349
|
size: number | null;
|
|
350
350
|
contentType: string | null;
|
|
@@ -378,7 +378,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
378
378
|
updatedAt: Date;
|
|
379
379
|
name: string;
|
|
380
380
|
namespace: string;
|
|
381
|
-
type: "
|
|
381
|
+
type: "folder" | "file";
|
|
382
382
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
383
383
|
size: number | null;
|
|
384
384
|
contentType: string | null;
|
|
@@ -412,7 +412,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
412
412
|
updatedAt: Date;
|
|
413
413
|
name: string;
|
|
414
414
|
namespace: string;
|
|
415
|
-
type: "
|
|
415
|
+
type: "folder" | "file";
|
|
416
416
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
417
417
|
size: number | null;
|
|
418
418
|
contentType: string | null;
|
|
@@ -443,7 +443,7 @@ declare class LocalDrive<TSchema extends TDatabaseSchema> implements DriveReader
|
|
|
443
443
|
updatedAt: Date;
|
|
444
444
|
name: string;
|
|
445
445
|
namespace: string;
|
|
446
|
-
type: "
|
|
446
|
+
type: "folder" | "file";
|
|
447
447
|
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
448
448
|
size: number | null;
|
|
449
449
|
contentType: string | null;
|
|
@@ -2,12 +2,13 @@ import { deviceSizes } from "./constants.mjs";
|
|
|
2
2
|
import { inferLocalDriveNodeSubtype, isLocalDriveFile, isLocalDriveFolder, toLocalDriveNode } from "./helpers.mjs";
|
|
3
3
|
import { nodePresignedUrls, nodeVariants, nodes } from "./schema.mjs";
|
|
4
4
|
import { getLocalFileURLSchemaDefaults } from "./validators.mjs";
|
|
5
|
+
import { parseLocalDriveTableQuerySorting } from "../config/sorting.mjs";
|
|
5
6
|
import { storageAssets } from "@tulip-systems/core/storage";
|
|
6
|
-
import { and,
|
|
7
|
+
import { and, eq, getTableColumns, inArray, isNotNull, isNull, sql } from "drizzle-orm";
|
|
7
8
|
import { ServerError } from "@tulip-systems/core/router/server";
|
|
8
9
|
import { after } from "next/server";
|
|
9
10
|
import stream from "node:stream/consumers";
|
|
10
|
-
import {
|
|
11
|
+
import { convertSearchToQueryParams, createTableQueryResponse } from "@tulip-systems/core/data-tables/server";
|
|
11
12
|
import { addSeconds } from "date-fns";
|
|
12
13
|
|
|
13
14
|
//#region src/providers/local/lib/service.server.ts
|
|
@@ -105,11 +106,11 @@ var LocalDrive = class {
|
|
|
105
106
|
* @returns A promise resolving to the matching child nodes.
|
|
106
107
|
*/
|
|
107
108
|
async getNodesByParentId({ filters, ...query }) {
|
|
108
|
-
const orderBy =
|
|
109
|
+
const orderBy = parseLocalDriveTableQuerySorting.parse(query);
|
|
109
110
|
const search = convertSearchToQueryParams(query, [nodes.name]);
|
|
110
111
|
const archivedFilter = filters.isArchived === true ? isNotNull(nodes.archivedAt) : filters.isArchived === false ? isNull(nodes.archivedAt) : void 0;
|
|
111
112
|
const parentFilter = filters.parentId ? eq(nodes.parentId, filters.parentId) : isNull(nodes.parentId);
|
|
112
|
-
return (await this.#db.select().from(nodes).where(and(filters.nodeIds != null ? inArray(nodes.id, filters.nodeIds) : void 0, filters.types != null ? inArray(nodes.type, filters.types) : void 0, archivedFilter, filters.hidden != null ? eq(nodes.hidden, filters.hidden) : void 0, parentFilter, eq(nodes.namespace, filters.namespace), search)).orderBy(orderBy)).map(toLocalDriveNode);
|
|
113
|
+
return (await this.#db.select().from(nodes).where(and(filters.nodeIds != null ? inArray(nodes.id, filters.nodeIds) : void 0, filters.types != null ? inArray(nodes.type, filters.types) : void 0, archivedFilter, filters.hidden != null ? eq(nodes.hidden, filters.hidden) : void 0, parentFilter, eq(nodes.namespace, filters.namespace), search)).orderBy(...orderBy)).map(toLocalDriveNode);
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
115
116
|
* Lists tree-scoped nodes with pagination, search, and richer local filters.
|
|
@@ -121,7 +122,7 @@ var LocalDrive = class {
|
|
|
121
122
|
* @returns A paginated table-query response.
|
|
122
123
|
*/
|
|
123
124
|
async listTree({ filters, ...query }) {
|
|
124
|
-
const orderBy =
|
|
125
|
+
const orderBy = parseLocalDriveTableQuerySorting.parse(query);
|
|
125
126
|
const search = convertSearchToQueryParams(query, [nodes.name]);
|
|
126
127
|
const archivedFilter = filters.isArchived === true ? isNotNull(nodes.archivedAt) : filters.isArchived === false ? isNull(nodes.archivedAt) : void 0;
|
|
127
128
|
const parentFilter = filters.parentId ? eq(nodes.parentId, filters.parentId) : isNull(nodes.parentId);
|
|
@@ -132,7 +133,7 @@ var LocalDrive = class {
|
|
|
132
133
|
return [await tx.select({
|
|
133
134
|
...getTableColumns(nodes),
|
|
134
135
|
asset: storageAssets
|
|
135
|
-
}).from(nodes).where(where).leftJoin(storageAssets, eq(nodes.assetId, storageAssets.id)).orderBy(orderBy).limit(limit).offset(offset), await tx.$count(nodes, where)];
|
|
136
|
+
}).from(nodes).where(where).leftJoin(storageAssets, eq(nodes.assetId, storageAssets.id)).orderBy(...orderBy).limit(limit).offset(offset), await tx.$count(nodes, where)];
|
|
136
137
|
});
|
|
137
138
|
return createTableQueryResponse({
|
|
138
139
|
data: data.map(({ asset, ...node }) => ({
|
|
@@ -153,7 +154,7 @@ var LocalDrive = class {
|
|
|
153
154
|
* @returns A paginated table-query response.
|
|
154
155
|
*/
|
|
155
156
|
async listFlat({ filters, ...query }) {
|
|
156
|
-
const orderBy =
|
|
157
|
+
const orderBy = parseLocalDriveTableQuerySorting.parse(query);
|
|
157
158
|
const search = convertSearchToQueryParams(query, [nodes.name]);
|
|
158
159
|
const archivedFilter = filters.isArchived === true ? isNotNull(nodes.archivedAt) : filters.isArchived === false ? isNull(nodes.archivedAt) : void 0;
|
|
159
160
|
const limit = query.limit;
|
|
@@ -163,7 +164,7 @@ var LocalDrive = class {
|
|
|
163
164
|
return [await tx.select({
|
|
164
165
|
...getTableColumns(nodes),
|
|
165
166
|
asset: storageAssets
|
|
166
|
-
}).from(nodes).where(where).leftJoin(storageAssets, eq(nodes.assetId, storageAssets.id)).orderBy(orderBy).limit(limit).offset(offset), await tx.$count(nodes, where)];
|
|
167
|
+
}).from(nodes).where(where).leftJoin(storageAssets, eq(nodes.assetId, storageAssets.id)).orderBy(...orderBy).limit(limit).offset(offset), await tx.$count(nodes, where)];
|
|
167
168
|
});
|
|
168
169
|
return createTableQueryResponse({
|
|
169
170
|
data: data.map(({ asset, ...node }) => ({
|
|
@@ -15,8 +15,8 @@ declare const localDriveNodeSchema: z.ZodObject<{
|
|
|
15
15
|
name: z.ZodString;
|
|
16
16
|
namespace: z.ZodString;
|
|
17
17
|
type: z.ZodEnum<{
|
|
18
|
-
file: "file";
|
|
19
18
|
folder: "folder";
|
|
19
|
+
file: "file";
|
|
20
20
|
}>;
|
|
21
21
|
subtype: z.ZodEnum<{
|
|
22
22
|
image: "image";
|
|
@@ -68,8 +68,8 @@ declare const localDriveNodeWithChildrenSchema: z.ZodObject<{
|
|
|
68
68
|
name: z.ZodString;
|
|
69
69
|
namespace: z.ZodString;
|
|
70
70
|
type: z.ZodEnum<{
|
|
71
|
-
file: "file";
|
|
72
71
|
folder: "folder";
|
|
72
|
+
file: "file";
|
|
73
73
|
}>;
|
|
74
74
|
subtype: z.ZodEnum<{
|
|
75
75
|
image: "image";
|
|
@@ -106,8 +106,8 @@ declare const localDriveNodeWithChildrenSchema: z.ZodObject<{
|
|
|
106
106
|
name: z.ZodString;
|
|
107
107
|
namespace: z.ZodString;
|
|
108
108
|
type: z.ZodEnum<{
|
|
109
|
-
file: "file";
|
|
110
109
|
folder: "folder";
|
|
110
|
+
file: "file";
|
|
111
111
|
}>;
|
|
112
112
|
subtype: z.ZodEnum<{
|
|
113
113
|
image: "image";
|
|
@@ -227,8 +227,8 @@ declare const localDriveTreeFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
227
227
|
}>>>>;
|
|
228
228
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
229
229
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
230
|
-
file: "file";
|
|
231
230
|
folder: "folder";
|
|
231
|
+
file: "file";
|
|
232
232
|
}>>>>;
|
|
233
233
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
234
234
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -241,7 +241,7 @@ declare const localDriveTreeFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
241
241
|
namespace: string;
|
|
242
242
|
parentId: string | null;
|
|
243
243
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
244
|
-
types?: ("
|
|
244
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
245
245
|
contentTypes?: string[] | null | undefined;
|
|
246
246
|
nodeIds?: string[] | null | undefined;
|
|
247
247
|
}, {
|
|
@@ -249,7 +249,7 @@ declare const localDriveTreeFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
249
249
|
parentId: string | null;
|
|
250
250
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
251
251
|
hidden?: boolean | null | undefined;
|
|
252
|
-
types?: ("
|
|
252
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
253
253
|
contentTypes?: string[] | null | undefined;
|
|
254
254
|
nodeIds?: string[] | null | undefined;
|
|
255
255
|
isArchived?: boolean | null | undefined;
|
|
@@ -270,8 +270,8 @@ declare const localDriveFlatFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
270
270
|
}>>>>;
|
|
271
271
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
272
272
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
273
|
-
file: "file";
|
|
274
273
|
folder: "folder";
|
|
274
|
+
file: "file";
|
|
275
275
|
}>>>>;
|
|
276
276
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
277
277
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -281,14 +281,14 @@ declare const localDriveFlatFiltersSchema: z.ZodPipe<z.ZodObject<{
|
|
|
281
281
|
hidden: boolean;
|
|
282
282
|
isArchived: boolean;
|
|
283
283
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
284
|
-
types?: ("
|
|
284
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
285
285
|
contentTypes?: string[] | null | undefined;
|
|
286
286
|
nodeIds?: string[] | null | undefined;
|
|
287
287
|
namespace?: string | undefined;
|
|
288
288
|
}, {
|
|
289
289
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
290
290
|
hidden?: boolean | null | undefined;
|
|
291
|
-
types?: ("
|
|
291
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
292
292
|
contentTypes?: string[] | null | undefined;
|
|
293
293
|
nodeIds?: string[] | null | undefined;
|
|
294
294
|
isArchived?: boolean | null | undefined;
|
|
@@ -318,8 +318,8 @@ declare const listLocalDriveTreeInputSchema: z.ZodObject<{
|
|
|
318
318
|
}>>>>;
|
|
319
319
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
320
320
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
321
|
-
file: "file";
|
|
322
321
|
folder: "folder";
|
|
322
|
+
file: "file";
|
|
323
323
|
}>>>>;
|
|
324
324
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
325
325
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -332,7 +332,7 @@ declare const listLocalDriveTreeInputSchema: z.ZodObject<{
|
|
|
332
332
|
namespace: string;
|
|
333
333
|
parentId: string | null;
|
|
334
334
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
335
|
-
types?: ("
|
|
335
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
336
336
|
contentTypes?: string[] | null | undefined;
|
|
337
337
|
nodeIds?: string[] | null | undefined;
|
|
338
338
|
}, {
|
|
@@ -340,7 +340,7 @@ declare const listLocalDriveTreeInputSchema: z.ZodObject<{
|
|
|
340
340
|
parentId: string | null;
|
|
341
341
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
342
342
|
hidden?: boolean | null | undefined;
|
|
343
|
-
types?: ("
|
|
343
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
344
344
|
contentTypes?: string[] | null | undefined;
|
|
345
345
|
nodeIds?: string[] | null | undefined;
|
|
346
346
|
isArchived?: boolean | null | undefined;
|
|
@@ -372,8 +372,8 @@ declare const listLocalDriveFlatInputSchema: z.ZodObject<{
|
|
|
372
372
|
}>>>>;
|
|
373
373
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
374
374
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
375
|
-
file: "file";
|
|
376
375
|
folder: "folder";
|
|
376
|
+
file: "file";
|
|
377
377
|
}>>>>;
|
|
378
378
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
379
379
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -383,14 +383,14 @@ declare const listLocalDriveFlatInputSchema: z.ZodObject<{
|
|
|
383
383
|
hidden: boolean;
|
|
384
384
|
isArchived: boolean;
|
|
385
385
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
386
|
-
types?: ("
|
|
386
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
387
387
|
contentTypes?: string[] | null | undefined;
|
|
388
388
|
nodeIds?: string[] | null | undefined;
|
|
389
389
|
namespace?: string | undefined;
|
|
390
390
|
}, {
|
|
391
391
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
392
392
|
hidden?: boolean | null | undefined;
|
|
393
|
-
types?: ("
|
|
393
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
394
394
|
contentTypes?: string[] | null | undefined;
|
|
395
395
|
nodeIds?: string[] | null | undefined;
|
|
396
396
|
isArchived?: boolean | null | undefined;
|
|
@@ -420,8 +420,8 @@ declare const getLocalDriveNodesByParentIdInputSchema: z.ZodObject<{
|
|
|
420
420
|
}>>>>;
|
|
421
421
|
hidden: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
422
422
|
types: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
423
|
-
file: "file";
|
|
424
423
|
folder: "folder";
|
|
424
|
+
file: "file";
|
|
425
425
|
}>>>>;
|
|
426
426
|
contentTypes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
427
427
|
nodeIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -434,7 +434,7 @@ declare const getLocalDriveNodesByParentIdInputSchema: z.ZodObject<{
|
|
|
434
434
|
namespace: string;
|
|
435
435
|
parentId: string | null;
|
|
436
436
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
437
|
-
types?: ("
|
|
437
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
438
438
|
contentTypes?: string[] | null | undefined;
|
|
439
439
|
nodeIds?: string[] | null | undefined;
|
|
440
440
|
}, {
|
|
@@ -442,7 +442,7 @@ declare const getLocalDriveNodesByParentIdInputSchema: z.ZodObject<{
|
|
|
442
442
|
parentId: string | null;
|
|
443
443
|
subtypes?: ("image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other")[] | null | undefined;
|
|
444
444
|
hidden?: boolean | null | undefined;
|
|
445
|
-
types?: ("
|
|
445
|
+
types?: ("folder" | "file")[] | null | undefined;
|
|
446
446
|
contentTypes?: string[] | null | undefined;
|
|
447
447
|
nodeIds?: string[] | null | undefined;
|
|
448
448
|
isArchived?: boolean | null | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tulip-systems/drive",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -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.
|
|
68
|
+
"@tulip-systems/core": "0.9.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@tailwindcss/typography": "^0.5.19",
|
|
@@ -29,7 +29,7 @@ import { useDriveSelectionContext } from "./selection.client";
|
|
|
29
29
|
*/
|
|
30
30
|
type DriveGridCardProps<TData extends DriveNode> = ComponentProps<"div"> & {
|
|
31
31
|
node: TData;
|
|
32
|
-
commands?: CommandDef
|
|
32
|
+
commands?: CommandDef[];
|
|
33
33
|
imageLoader?: (props: ImageLoaderProps) => string;
|
|
34
34
|
unoptimized?: boolean;
|
|
35
35
|
};
|
|
@@ -34,7 +34,7 @@ type GoogleDriveViewProviderProps<TData extends GoogleDriveNode = GoogleDriveNod
|
|
|
34
34
|
queryData: TData[];
|
|
35
35
|
columns?: TableColumnDef<TData>[];
|
|
36
36
|
strategy: ReturnType<typeof useInfiniteStrategy>;
|
|
37
|
-
commands?: CommandDef
|
|
37
|
+
commands?: CommandDef[];
|
|
38
38
|
columnVisibility?: VisibilityState;
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -48,7 +48,7 @@ export function GoogleDriveViewProvider<TData extends GoogleDriveNode = GoogleDr
|
|
|
48
48
|
...props
|
|
49
49
|
}: GoogleDriveViewProviderProps<TData>) {
|
|
50
50
|
const { meta } = useGoogleDriveContext();
|
|
51
|
-
const
|
|
51
|
+
const selectionContext = useDriveSelectionContext();
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Table
|
|
@@ -56,11 +56,12 @@ export function GoogleDriveViewProvider<TData extends GoogleDriveNode = GoogleDr
|
|
|
56
56
|
const config = createTableConfig<TData>({
|
|
57
57
|
queryData,
|
|
58
58
|
columns,
|
|
59
|
+
getRowId: (row) => row.id,
|
|
59
60
|
strategy,
|
|
60
61
|
commands,
|
|
61
62
|
meta,
|
|
62
63
|
columnVisibility,
|
|
63
|
-
selection,
|
|
64
|
+
selection: selectionContext?.selection,
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
return (
|
|
@@ -33,7 +33,7 @@ type LocalDriveViewProviderProps<TData extends LocalDriveNodeWithAsset = LocalDr
|
|
|
33
33
|
queryData: TData[];
|
|
34
34
|
columns?: TableColumnDef<TData>[];
|
|
35
35
|
strategy: ReturnType<typeof useInfiniteStrategy>;
|
|
36
|
-
commands?: CommandDef
|
|
36
|
+
commands?: CommandDef[];
|
|
37
37
|
columnVisibility?: VisibilityState;
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -49,16 +49,17 @@ export function LocalDriveViewProvider<
|
|
|
49
49
|
...props
|
|
50
50
|
}: LocalDriveViewProviderProps<TData>) {
|
|
51
51
|
const { meta } = useLocalDriveContext();
|
|
52
|
-
const
|
|
52
|
+
const selectionContext = useDriveSelectionContext();
|
|
53
53
|
|
|
54
54
|
const config = createTableConfig<TData>({
|
|
55
55
|
queryData,
|
|
56
56
|
columns,
|
|
57
|
+
getRowId: (row) => row.id,
|
|
57
58
|
strategy,
|
|
58
59
|
commands,
|
|
59
60
|
meta,
|
|
60
61
|
columnVisibility,
|
|
61
|
-
selection,
|
|
62
|
+
selection: selectionContext?.selection,
|
|
62
63
|
});
|
|
63
64
|
|
|
64
65
|
return (
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createTableQuerySortingParser } from "@tulip-systems/core/data-tables/server";
|
|
2
|
+
import { asc, getTableColumns } from "drizzle-orm";
|
|
3
|
+
import { nodes } from "../lib/schema";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Local Drive specific sorting config
|
|
7
|
+
*/
|
|
8
|
+
const localDriveTableQuerySortingConfig = getTableColumns(nodes);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Local Drive specific sorting parser
|
|
12
|
+
*/
|
|
13
|
+
export const parseLocalDriveTableQuerySorting = createTableQuerySortingParser(
|
|
14
|
+
localDriveTableQuerySortingConfig,
|
|
15
|
+
{ fallback: asc(nodes.createdAt) },
|
|
16
|
+
);
|
|
@@ -2,7 +2,6 @@ import stream from "node:stream/consumers";
|
|
|
2
2
|
import type { TDatabaseSchema } from "@tulip-systems/core/config";
|
|
3
3
|
import type { TableQueryResponse } from "@tulip-systems/core/data-tables/server";
|
|
4
4
|
import {
|
|
5
|
-
convertOrderByToQueryParams,
|
|
6
5
|
convertSearchToQueryParams,
|
|
7
6
|
createTableQueryResponse,
|
|
8
7
|
} from "@tulip-systems/core/data-tables/server";
|
|
@@ -11,18 +10,7 @@ import { ServerError } from "@tulip-systems/core/router/server";
|
|
|
11
10
|
import { type ObjectBodyInput, storageAssets } from "@tulip-systems/core/storage";
|
|
12
11
|
import type { Storage } from "@tulip-systems/core/storage/server";
|
|
13
12
|
import { addSeconds } from "date-fns";
|
|
14
|
-
import {
|
|
15
|
-
and,
|
|
16
|
-
asc,
|
|
17
|
-
desc,
|
|
18
|
-
eq,
|
|
19
|
-
getTableColumns,
|
|
20
|
-
inArray,
|
|
21
|
-
isNotNull,
|
|
22
|
-
isNull,
|
|
23
|
-
type SQL,
|
|
24
|
-
sql,
|
|
25
|
-
} from "drizzle-orm";
|
|
13
|
+
import { and, eq, getTableColumns, inArray, isNotNull, isNull, sql } from "drizzle-orm";
|
|
26
14
|
import { after } from "next/server";
|
|
27
15
|
import type { QueryResult } from "pg";
|
|
28
16
|
import type {
|
|
@@ -34,6 +22,7 @@ import type {
|
|
|
34
22
|
DriveReader,
|
|
35
23
|
DriveReadonly,
|
|
36
24
|
} from "../../../lib/contracts";
|
|
25
|
+
import { parseLocalDriveTableQuerySorting } from "../config/sorting";
|
|
37
26
|
import { deviceSizes } from "./constants";
|
|
38
27
|
import {
|
|
39
28
|
inferLocalDriveNodeSubtype,
|
|
@@ -221,7 +210,7 @@ export class LocalDrive<TSchema extends TDatabaseSchema>
|
|
|
221
210
|
filters,
|
|
222
211
|
...query
|
|
223
212
|
}: GetLocalDriveNodesByParentIdInput): Promise<LocalDriveNode[]> {
|
|
224
|
-
const orderBy =
|
|
213
|
+
const orderBy = parseLocalDriveTableQuerySorting.parse(query);
|
|
225
214
|
const search = convertSearchToQueryParams(query, [nodes.name]);
|
|
226
215
|
const archivedFilter =
|
|
227
216
|
filters.isArchived === true
|
|
@@ -247,7 +236,7 @@ export class LocalDrive<TSchema extends TDatabaseSchema>
|
|
|
247
236
|
search,
|
|
248
237
|
),
|
|
249
238
|
)
|
|
250
|
-
.orderBy(orderBy
|
|
239
|
+
.orderBy(...orderBy);
|
|
251
240
|
|
|
252
241
|
return items.map(toLocalDriveNode);
|
|
253
242
|
}
|
|
@@ -265,7 +254,7 @@ export class LocalDrive<TSchema extends TDatabaseSchema>
|
|
|
265
254
|
filters,
|
|
266
255
|
...query
|
|
267
256
|
}: ListLocalDriveTreeSchema): Promise<TableQueryResponse<LocalDriveNodeWithAsset>> {
|
|
268
|
-
const orderBy =
|
|
257
|
+
const orderBy = parseLocalDriveTableQuerySorting.parse(query);
|
|
269
258
|
const search = convertSearchToQueryParams(query, [nodes.name]);
|
|
270
259
|
|
|
271
260
|
const archivedFilter =
|
|
@@ -303,7 +292,7 @@ export class LocalDrive<TSchema extends TDatabaseSchema>
|
|
|
303
292
|
.from(nodes)
|
|
304
293
|
.where(where)
|
|
305
294
|
.leftJoin(storageAssets, eq(nodes.assetId, storageAssets.id))
|
|
306
|
-
.orderBy(orderBy
|
|
295
|
+
.orderBy(...orderBy)
|
|
307
296
|
.limit(limit)
|
|
308
297
|
.offset(offset);
|
|
309
298
|
|
|
@@ -331,7 +320,7 @@ export class LocalDrive<TSchema extends TDatabaseSchema>
|
|
|
331
320
|
filters,
|
|
332
321
|
...query
|
|
333
322
|
}: ListLocalDriveFlatSchema): Promise<TableQueryResponse<LocalDriveNodeWithAsset>> {
|
|
334
|
-
const orderBy =
|
|
323
|
+
const orderBy = parseLocalDriveTableQuerySorting.parse(query);
|
|
335
324
|
const search = convertSearchToQueryParams(query, [nodes.name]);
|
|
336
325
|
const archivedFilter =
|
|
337
326
|
filters.isArchived === true
|
|
@@ -363,7 +352,7 @@ export class LocalDrive<TSchema extends TDatabaseSchema>
|
|
|
363
352
|
.from(nodes)
|
|
364
353
|
.where(where)
|
|
365
354
|
.leftJoin(storageAssets, eq(nodes.assetId, storageAssets.id))
|
|
366
|
-
.orderBy(orderBy
|
|
355
|
+
.orderBy(...orderBy)
|
|
367
356
|
.limit(limit)
|
|
368
357
|
.offset(offset);
|
|
369
358
|
|