@tulip-systems/drive 0.8.1 → 0.8.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/client.d.mts +5 -0
- package/dist/client.mjs +6 -0
- package/dist/components/content.d.mts +13 -0
- package/dist/components/content.mjs +17 -0
- package/dist/components/context.client.d.mts +13 -0
- package/dist/components/dnd.client.d.mts +16 -0
- package/dist/components/dnd.client.mjs +29 -0
- package/dist/components/grid-card.client.d.mts +46 -0
- package/dist/components/grid-card.client.mjs +173 -0
- package/dist/components/grid.client.d.mts +53 -0
- package/dist/components/grid.client.mjs +53 -0
- package/dist/components/navigation/breadcrumbs.client.d.mts +25 -0
- package/dist/components/navigation/breadcrumbs.client.mjs +51 -0
- package/dist/components/navigation/header.client.d.mts +27 -0
- package/dist/components/navigation/header.client.mjs +40 -0
- package/dist/components/navigation/toolbar.client.d.mts +23 -0
- package/dist/components/navigation/toolbar.client.mjs +34 -0
- package/dist/components/navigation/view-switcher.client.d.mts +9 -0
- package/dist/components/navigation/view-switcher.client.mjs +35 -0
- package/dist/components/selection.client.d.mts +27 -0
- package/dist/components/selection.client.mjs +36 -0
- package/dist/components/view.client.d.mts +25 -0
- package/dist/components/view.client.mjs +43 -0
- package/dist/config/filters.mjs +14 -0
- package/dist/config/types.mjs +60 -0
- package/dist/google/client.d.mts +8 -0
- package/dist/google/client.mjs +9 -0
- package/dist/google/server.d.mts +3 -0
- package/dist/google/server.mjs +4 -0
- package/dist/google.d.mts +6 -0
- package/dist/google.mjs +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +7 -0
- package/dist/lib/constants.d.mts +11 -0
- package/dist/lib/constants.mjs +20 -0
- package/dist/lib/contracts.d.mts +100 -0
- package/dist/lib/dto.d.mts +117 -0
- package/dist/lib/dto.mjs +57 -0
- package/dist/lib/helpers.d.mts +17 -0
- package/dist/lib/helpers.mjs +36 -0
- package/dist/lib/helpers.server.d.mts +13 -0
- package/dist/lib/helpers.server.mjs +15 -0
- package/dist/lib/search-params.d.mts +8 -0
- package/dist/lib/search-params.mjs +7 -0
- package/dist/lib/validators.d.mts +157 -0
- package/dist/lib/validators.mjs +65 -0
- package/dist/local/client.d.mts +13 -0
- package/dist/local/client.mjs +13 -0
- package/dist/local/server.d.mts +4 -0
- package/dist/local/server.mjs +5 -0
- package/dist/local.d.mts +8 -0
- package/dist/local.mjs +9 -0
- package/dist/providers/google/components/command-file-update.d.mts +21 -0
- package/dist/providers/google/components/command-file-update.mjs +51 -0
- package/dist/providers/google/components/command-folder-create.d.mts +21 -0
- package/dist/providers/google/components/command-folder-create.mjs +58 -0
- package/dist/providers/google/components/command-folder-update.d.mts +21 -0
- package/dist/providers/google/components/command-folder-update.mjs +51 -0
- package/dist/providers/google/components/content.client.d.mts +9 -0
- package/dist/providers/google/components/content.client.mjs +10 -0
- package/dist/providers/google/components/navigation.client.d.mts +15 -0
- package/dist/providers/google/components/navigation.client.mjs +17 -0
- package/dist/providers/google/components/provider.client.d.mts +32 -0
- package/dist/providers/google/components/provider.client.mjs +42 -0
- package/dist/providers/google/components/view.client.d.mts +40 -0
- package/dist/providers/google/components/view.client.mjs +96 -0
- package/dist/providers/google/config/columns-data.d.mts +7 -0
- package/dist/providers/google/config/columns-data.mjs +69 -0
- package/dist/providers/google/config/filters.d.mts +15 -0
- package/dist/providers/google/config/filters.mjs +7 -0
- package/dist/providers/google/lib/constants.mjs +12 -0
- package/dist/providers/google/lib/dto.d.mts +38 -0
- package/dist/providers/google/lib/dto.mjs +65 -0
- package/dist/providers/google/lib/helpers.mjs +38 -0
- package/dist/providers/google/lib/router.server.d.mts +611 -0
- package/dist/providers/google/lib/router.server.mjs +39 -0
- package/dist/providers/google/lib/search-params.d.mts +14 -0
- package/dist/providers/google/lib/search-params.mjs +11 -0
- package/dist/providers/google/lib/service.server.d.mts +185 -0
- package/dist/providers/google/lib/service.server.mjs +610 -0
- package/dist/providers/google/lib/validators.d.mts +302 -0
- package/dist/providers/google/lib/validators.mjs +58 -0
- package/dist/providers/local/components/command-file-update.d.mts +17 -0
- package/dist/providers/local/components/command-file-update.mjs +47 -0
- package/dist/providers/local/components/command-file-upload.d.mts +10 -0
- package/dist/providers/local/components/command-file-upload.mjs +34 -0
- package/dist/providers/local/components/command-folder-create.d.mts +17 -0
- package/dist/providers/local/components/command-folder-create.mjs +54 -0
- package/dist/providers/local/components/command-folder-update.d.mts +17 -0
- package/dist/providers/local/components/command-folder-update.mjs +47 -0
- package/dist/providers/local/components/content.client.d.mts +6 -0
- package/dist/providers/local/components/content.client.mjs +7 -0
- package/dist/providers/local/components/navigation.client.d.mts +15 -0
- package/dist/providers/local/components/navigation.client.mjs +17 -0
- package/dist/providers/local/components/provider.client.d.mts +39 -0
- package/dist/providers/local/components/provider.client.mjs +60 -0
- package/dist/providers/local/components/upload-zone-context.client.d.mts +37 -0
- package/dist/providers/local/components/upload-zone-context.client.mjs +22 -0
- package/dist/providers/local/components/upload-zone.client.d.mts +29 -0
- package/dist/providers/local/components/upload-zone.client.mjs +146 -0
- package/dist/providers/local/components/view.client.d.mts +31 -0
- package/dist/providers/local/components/view.client.mjs +90 -0
- package/dist/providers/local/config/columns-data.d.mts +7 -0
- package/dist/providers/local/config/columns-data.mjs +69 -0
- package/dist/providers/local/config/filters.d.mts +25 -0
- package/dist/providers/local/config/filters.mjs +14 -0
- package/dist/providers/local/lib/constants.d.mts +11 -0
- package/dist/providers/local/lib/constants.mjs +28 -0
- package/dist/providers/local/lib/helpers.d.mts +44 -0
- package/dist/providers/local/lib/helpers.mjs +109 -0
- package/dist/providers/local/lib/route-handler.server.d.mts +33 -0
- package/dist/providers/local/lib/route-handler.server.mjs +113 -0
- package/dist/providers/local/lib/router.server.d.mts +41647 -0
- package/dist/providers/local/lib/router.server.mjs +51 -0
- package/dist/providers/local/lib/schema.d.mts +1112 -0
- package/dist/providers/local/lib/schema.mjs +70 -0
- package/dist/providers/local/lib/search-params.d.mts +13 -0
- package/dist/providers/local/lib/search-params.mjs +8 -0
- package/dist/providers/local/lib/service.server.d.mts +488 -0
- package/dist/providers/local/lib/service.server.mjs +667 -0
- package/dist/providers/local/lib/upload.client.d.mts +61 -0
- package/dist/providers/local/lib/upload.client.mjs +99 -0
- package/dist/providers/local/lib/validators.d.mts +453 -0
- package/dist/providers/local/lib/validators.mjs +95 -0
- package/dist/server.d.mts +2 -0
- package/dist/server.mjs +3 -0
- package/package.json +45 -46
- package/src/components/grid-card.client.tsx +17 -12
- package/src/components/selection.client.tsx +1 -2
- package/src/config/types.tsx +1 -1
- package/src/providers/google/components/command-file-update.tsx +2 -2
- package/src/providers/google/components/command-folder-create.tsx +2 -2
- package/src/providers/google/components/command-folder-update.tsx +2 -2
- package/src/providers/google/components/view.client.tsx +1 -7
- package/src/providers/google/lib/helpers.ts +0 -9
- package/src/providers/google/lib/service.server.ts +1 -3
- package/src/providers/local/components/command-file-update.tsx +2 -2
- package/src/providers/local/components/command-folder-create.tsx +2 -2
- package/src/providers/local/components/command-folder-update.tsx +2 -2
- package/src/providers/local/components/upload-zone.client.tsx +1 -1
- package/src/providers/local/lib/helpers.ts +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DriveBreadcrumbs } from "../../../components/navigation/breadcrumbs.client.mjs";
|
|
2
|
+
import { DriveHeader, DriveHeaderBreadcrumbs, DriveHeaderTools } from "../../../components/navigation/header.client.mjs";
|
|
3
|
+
import { DriveToolbar, DriveToolbarTools } from "../../../components/navigation/toolbar.client.mjs";
|
|
4
|
+
import { DriveViewSwitcher } from "../../../components/navigation/view-switcher.client.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/providers/google/components/navigation.client.d.ts
|
|
7
|
+
declare const GoogleDriveHeader: typeof DriveHeader;
|
|
8
|
+
declare const GoogleDriveHeaderBreadcrumbs: typeof DriveHeaderBreadcrumbs;
|
|
9
|
+
declare const GoogleDriveHeaderTools: typeof DriveHeaderTools;
|
|
10
|
+
declare const GoogleDriveToolbar: typeof DriveToolbar;
|
|
11
|
+
declare const GoogleDriveToolbarBreadcrumbs: typeof DriveBreadcrumbs;
|
|
12
|
+
declare const GoogleDriveToolbarTools: typeof DriveToolbarTools;
|
|
13
|
+
declare const GoogleDriveViewSwitcher: typeof DriveViewSwitcher;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { GoogleDriveHeader, GoogleDriveHeaderBreadcrumbs, GoogleDriveHeaderTools, GoogleDriveToolbar, GoogleDriveToolbarBreadcrumbs, GoogleDriveToolbarTools, GoogleDriveViewSwitcher };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { DriveHeader, DriveHeaderBreadcrumbs, DriveHeaderTools } from "../../../components/navigation/header.client.mjs";
|
|
4
|
+
import { DriveToolbar, DriveToolbarBreadcrumbs, DriveToolbarTools } from "../../../components/navigation/toolbar.client.mjs";
|
|
5
|
+
import { DriveViewSwitcher } from "../../../components/navigation/view-switcher.client.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/providers/google/components/navigation.client.tsx
|
|
8
|
+
const GoogleDriveHeader = DriveHeader;
|
|
9
|
+
const GoogleDriveHeaderBreadcrumbs = DriveHeaderBreadcrumbs;
|
|
10
|
+
const GoogleDriveHeaderTools = DriveHeaderTools;
|
|
11
|
+
const GoogleDriveToolbar = DriveToolbar;
|
|
12
|
+
const GoogleDriveToolbarBreadcrumbs = DriveToolbarBreadcrumbs;
|
|
13
|
+
const GoogleDriveToolbarTools = DriveToolbarTools;
|
|
14
|
+
const GoogleDriveViewSwitcher = DriveViewSwitcher;
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { GoogleDriveHeader, GoogleDriveHeaderBreadcrumbs, GoogleDriveHeaderTools, GoogleDriveToolbar, GoogleDriveToolbarBreadcrumbs, GoogleDriveToolbarTools, GoogleDriveViewSwitcher };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DriveSelectionContextValue } from "../../../components/selection.client.mjs";
|
|
2
|
+
import { DriveViewProviderProps } from "../../../components/view.client.mjs";
|
|
3
|
+
import { DriveContextValue } from "../../../components/context.client.mjs";
|
|
4
|
+
import * as react from "react";
|
|
5
|
+
import { PropsWithChildren } from "react";
|
|
6
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/providers/google/components/provider.client.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* GoogleDriveContextValue
|
|
11
|
+
*/
|
|
12
|
+
type GoogleDriveContextValue = DriveContextValue;
|
|
13
|
+
declare const GoogleDriveContext: react.Context<DriveContextValue>;
|
|
14
|
+
/**
|
|
15
|
+
* useDriveContext
|
|
16
|
+
*/
|
|
17
|
+
declare function useGoogleDriveContext(): DriveContextValue;
|
|
18
|
+
/**
|
|
19
|
+
* DriveContextProvider
|
|
20
|
+
*/
|
|
21
|
+
type GoogleDriveProviderProps = PropsWithChildren<GoogleDriveContextValue & Partial<DriveSelectionContextValue> & Pick<DriveViewProviderProps, "initialView">>;
|
|
22
|
+
declare function GoogleDriveProvider({
|
|
23
|
+
initialView,
|
|
24
|
+
namespace,
|
|
25
|
+
permission,
|
|
26
|
+
meta,
|
|
27
|
+
selection,
|
|
28
|
+
selectionConditions,
|
|
29
|
+
children
|
|
30
|
+
}: GoogleDriveProviderProps): react_jsx_runtime0.JSX.Element;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { GoogleDriveContext, GoogleDriveContextValue, GoogleDriveProvider, useGoogleDriveContext };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { DriveSelectionProvider } from "../../../components/selection.client.mjs";
|
|
4
|
+
import { DriveViewProvider } from "../../../components/view.client.mjs";
|
|
5
|
+
import { DriveDragDropProvider } from "../../../components/dnd.client.mjs";
|
|
6
|
+
import { createContext, use } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Allowed } from "@tulip-systems/core/auth/client";
|
|
9
|
+
|
|
10
|
+
//#region src/providers/google/components/provider.client.tsx
|
|
11
|
+
const GoogleDriveContext = createContext({});
|
|
12
|
+
/**
|
|
13
|
+
* useDriveContext
|
|
14
|
+
*/
|
|
15
|
+
function useGoogleDriveContext() {
|
|
16
|
+
const context = use(GoogleDriveContext);
|
|
17
|
+
if (!context) throw new Error("DriveContext not found!");
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
function GoogleDriveProvider({ initialView = "grid", namespace, permission, meta, selection, selectionConditions, children }) {
|
|
21
|
+
return /* @__PURE__ */ jsx(Allowed, {
|
|
22
|
+
permission,
|
|
23
|
+
children: /* @__PURE__ */ jsx(DriveSelectionProvider, {
|
|
24
|
+
selection,
|
|
25
|
+
selectionConditions,
|
|
26
|
+
children: /* @__PURE__ */ jsx(DriveViewProvider, {
|
|
27
|
+
initialView,
|
|
28
|
+
children: /* @__PURE__ */ jsx(DriveDragDropProvider, { children: /* @__PURE__ */ jsx(GoogleDriveContext, {
|
|
29
|
+
value: {
|
|
30
|
+
namespace,
|
|
31
|
+
permission,
|
|
32
|
+
meta
|
|
33
|
+
},
|
|
34
|
+
children
|
|
35
|
+
}) })
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { GoogleDriveContext, GoogleDriveProvider, useGoogleDriveContext };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GoogleDriveNode } from "../lib/validators.mjs";
|
|
2
|
+
import { TableColumnDef } from "@tulip-systems/core/data-tables";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
import { useInfiniteStrategy } from "@tulip-systems/core/data-tables/client";
|
|
6
|
+
import { CommandDef } from "@tulip-systems/core/commands";
|
|
7
|
+
import { VisibilityState } from "@tanstack/react-table";
|
|
8
|
+
|
|
9
|
+
//#region src/providers/google/components/view.client.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* GoogleDriveContent
|
|
12
|
+
*/
|
|
13
|
+
type GoogleDriveViewProviderProps<TData extends GoogleDriveNode = GoogleDriveNode> = ComponentProps<"div"> & {
|
|
14
|
+
queryData: TData[];
|
|
15
|
+
columns?: TableColumnDef<TData>[];
|
|
16
|
+
strategy: ReturnType<typeof useInfiniteStrategy>;
|
|
17
|
+
commands?: CommandDef<TData>[];
|
|
18
|
+
columnVisibility?: VisibilityState;
|
|
19
|
+
};
|
|
20
|
+
declare function GoogleDriveViewProvider<TData extends GoogleDriveNode = GoogleDriveNode>({
|
|
21
|
+
queryData,
|
|
22
|
+
columns,
|
|
23
|
+
strategy,
|
|
24
|
+
commands,
|
|
25
|
+
columnVisibility,
|
|
26
|
+
children,
|
|
27
|
+
...props
|
|
28
|
+
}: GoogleDriveViewProviderProps<TData>): react_jsx_runtime0.JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* GoogleDriveView
|
|
31
|
+
*/
|
|
32
|
+
declare function GoogleDriveView(): react_jsx_runtime0.JSX.Element | null;
|
|
33
|
+
/**
|
|
34
|
+
* GoogleDriveViewLoading
|
|
35
|
+
*/
|
|
36
|
+
declare function GoogleDriveViewLoading({
|
|
37
|
+
...props
|
|
38
|
+
}: ComponentProps<"div">): react_jsx_runtime0.JSX.Element;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { GoogleDriveView, GoogleDriveViewLoading, GoogleDriveViewProvider };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useDriveSelectionContext } from "../../../components/selection.client.mjs";
|
|
4
|
+
import { DriveGridCard, DriveGridCardSkeleton } from "../../../components/grid-card.client.mjs";
|
|
5
|
+
import { DriveGrid, DriveGridBottombar, DriveGridEmpty, DriveGridLoading } from "../../../components/grid.client.mjs";
|
|
6
|
+
import { useDriveViewContext } from "../../../components/view.client.mjs";
|
|
7
|
+
import { googleDriveColumns } from "../config/columns-data.mjs";
|
|
8
|
+
import { useGoogleDriveContext } from "./provider.client.mjs";
|
|
9
|
+
import { TableLayout, TableSkeleton } from "@tulip-systems/core/data-tables";
|
|
10
|
+
import { useMemo } from "react";
|
|
11
|
+
import { FloatingCommandMenu } from "@tulip-systems/core/commands/client";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { DataTable, TableConfigProvider, createTableConfig, useTableConfigContext } from "@tulip-systems/core/data-tables/client";
|
|
14
|
+
|
|
15
|
+
//#region src/providers/google/components/view.client.tsx
|
|
16
|
+
function GoogleDriveViewProvider({ queryData, columns = googleDriveColumns, strategy, commands, columnVisibility, children, ...props }) {
|
|
17
|
+
const { meta } = useGoogleDriveContext();
|
|
18
|
+
const { selection } = useDriveSelectionContext();
|
|
19
|
+
return /* @__PURE__ */ jsx(TableConfigProvider, {
|
|
20
|
+
config: createTableConfig({
|
|
21
|
+
queryData,
|
|
22
|
+
columns,
|
|
23
|
+
strategy,
|
|
24
|
+
commands,
|
|
25
|
+
meta,
|
|
26
|
+
columnVisibility,
|
|
27
|
+
selection
|
|
28
|
+
}),
|
|
29
|
+
children: /* @__PURE__ */ jsx(TableLayout, {
|
|
30
|
+
...props,
|
|
31
|
+
children
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* GoogleDriveView
|
|
37
|
+
*/
|
|
38
|
+
function GoogleDriveView() {
|
|
39
|
+
const { view } = useDriveViewContext();
|
|
40
|
+
if (view === "grid") return /* @__PURE__ */ jsx(GoogleDriveGrid, {});
|
|
41
|
+
if (view === "list") return /* @__PURE__ */ jsx(GoogleDriveList, {});
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* GoogleDriveGrid
|
|
46
|
+
*/
|
|
47
|
+
function GoogleDriveGrid(props) {
|
|
48
|
+
const { queryData, strategy, commands, selection, meta } = useTableConfigContext();
|
|
49
|
+
const { rowCount, paginationState } = strategy;
|
|
50
|
+
const { isFetching, isFetchingNextPage, fetchNextPage } = strategy.meta;
|
|
51
|
+
const hasNextPage = rowCount == null ? false : queryData.length < rowCount;
|
|
52
|
+
const selectedData = useMemo(() => queryData.filter((node) => selection?.rowSelection?.[node.id] === true), [queryData, selection?.rowSelection]);
|
|
53
|
+
return /* @__PURE__ */ jsxs(DriveGrid, {
|
|
54
|
+
...props,
|
|
55
|
+
children: [
|
|
56
|
+
queryData.length > 0 ? queryData.map((node) => /* @__PURE__ */ jsx(DriveGridCard, {
|
|
57
|
+
node,
|
|
58
|
+
commands,
|
|
59
|
+
unoptimized: true
|
|
60
|
+
}, node.id)) : /* @__PURE__ */ jsx(DriveGridEmpty, { title: "Geen resultaten gevonden" }),
|
|
61
|
+
isFetchingNextPage && Array.from({ length: paginationState?.pageSize ?? 0 }).map((_, index) => /* @__PURE__ */ jsx(DriveGridCardSkeleton, {}, index)),
|
|
62
|
+
/* @__PURE__ */ jsx(DriveGridBottombar, {
|
|
63
|
+
hasNextPage,
|
|
64
|
+
fetchNextPage,
|
|
65
|
+
isFetching,
|
|
66
|
+
isFetchingNextPage
|
|
67
|
+
}),
|
|
68
|
+
commands && commands.length > 0 && /* @__PURE__ */ jsx(FloatingCommandMenu, {
|
|
69
|
+
data: selectedData,
|
|
70
|
+
commands,
|
|
71
|
+
meta,
|
|
72
|
+
state: selectedData.length > 0 ? "open" : "closed",
|
|
73
|
+
onSuccess: () => selection?.setRowSelection?.({})
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* GoogleDriveList
|
|
80
|
+
*/
|
|
81
|
+
function GoogleDriveList(props) {
|
|
82
|
+
return /* @__PURE__ */ jsx(DataTable, { ...props });
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* GoogleDriveViewLoading
|
|
86
|
+
*/
|
|
87
|
+
function GoogleDriveViewLoading({ ...props }) {
|
|
88
|
+
const { view } = useDriveViewContext();
|
|
89
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
90
|
+
...props,
|
|
91
|
+
children: [view === "grid" && /* @__PURE__ */ jsx(DriveGridLoading, { ...props }), view === "list" && /* @__PURE__ */ jsx(TableSkeleton, { ...props })]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { GoogleDriveView, GoogleDriveViewLoading, GoogleDriveViewProvider };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GoogleDriveNode } from "../lib/validators.mjs";
|
|
2
|
+
import { TableColumnDef } from "@tulip-systems/core/data-tables";
|
|
3
|
+
|
|
4
|
+
//#region src/providers/google/config/columns-data.d.ts
|
|
5
|
+
declare const googleDriveColumns: TableColumnDef<GoogleDriveNode>[];
|
|
6
|
+
//#endregion
|
|
7
|
+
export { googleDriveColumns };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { driveTreeSearchParams } from "../../../lib/search-params.mjs";
|
|
4
|
+
import { nodeSubtypeConfig, nodeSubtypeVariants } from "../../../config/types.mjs";
|
|
5
|
+
import { TableColumnHeader } from "@tulip-systems/core/data-tables";
|
|
6
|
+
import { findStatus } from "@tulip-systems/core/components";
|
|
7
|
+
import { FolderIcon } from "lucide-react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@tulip-systems/core/components/client";
|
|
10
|
+
import { TableTextCell, createTableSelectCell } from "@tulip-systems/core/data-tables/client";
|
|
11
|
+
import Link from "next/link";
|
|
12
|
+
import { createSerializer, useQueryStates } from "nuqs";
|
|
13
|
+
|
|
14
|
+
//#region src/providers/google/config/columns-data.tsx
|
|
15
|
+
const googleDriveColumns = [
|
|
16
|
+
createTableSelectCell(),
|
|
17
|
+
{
|
|
18
|
+
id: "icon",
|
|
19
|
+
accessorKey: "icon",
|
|
20
|
+
header: () => null,
|
|
21
|
+
cell: ({ row }) => {
|
|
22
|
+
if (row.original.type === "file") {
|
|
23
|
+
const subtype = findStatus(nodeSubtypeConfig, row.original.subtype);
|
|
24
|
+
if (!subtype) return null;
|
|
25
|
+
return /* @__PURE__ */ jsx(TableTextCell, {
|
|
26
|
+
className: "w-4",
|
|
27
|
+
children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(subtype.icon, { className: nodeSubtypeVariants({
|
|
28
|
+
status: row.original.subtype,
|
|
29
|
+
className: "size-4"
|
|
30
|
+
}) }) }), /* @__PURE__ */ jsx(TooltipContent, { children: subtype.label })] })
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (row.original.type === "folder") return /* @__PURE__ */ jsx(TableTextCell, {
|
|
34
|
+
className: "w-4",
|
|
35
|
+
children: /* @__PURE__ */ jsx(FolderIcon, { className: "w-4 min-w-4" })
|
|
36
|
+
});
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
enableSorting: false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "name",
|
|
43
|
+
accessorKey: "name",
|
|
44
|
+
header: ({ column }) => /* @__PURE__ */ jsx(TableColumnHeader, {
|
|
45
|
+
column,
|
|
46
|
+
title: "Naam"
|
|
47
|
+
}),
|
|
48
|
+
cell: ({ row }) => {
|
|
49
|
+
const [query] = useQueryStates(driveTreeSearchParams);
|
|
50
|
+
const serialize = createSerializer(driveTreeSearchParams);
|
|
51
|
+
return /* @__PURE__ */ jsx(TableTextCell, {
|
|
52
|
+
className: "w-full min-w-64",
|
|
53
|
+
children: /* @__PURE__ */ jsx(Link, {
|
|
54
|
+
href: row.original.type === "file" ? row.original.links.view ?? "#" : serialize({
|
|
55
|
+
...query,
|
|
56
|
+
parentId: row.original.id
|
|
57
|
+
}),
|
|
58
|
+
className: "truncate hover:underline",
|
|
59
|
+
target: row.original.type === "file" ? "_blank" : "_self",
|
|
60
|
+
children: row.getValue("name")
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
enableSorting: false
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
export { googleDriveColumns };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as zod from "zod";
|
|
2
|
+
import * as _tulip_systems_core_data_tables0 from "@tulip-systems/core/data-tables";
|
|
3
|
+
|
|
4
|
+
//#region src/providers/google/config/filters.d.ts
|
|
5
|
+
declare const googleDriveTreeFilters: {
|
|
6
|
+
types: _tulip_systems_core_data_tables0.ParseFilter<zod.ZodArray<zod.ZodEnum<{
|
|
7
|
+
file: "file";
|
|
8
|
+
folder: "folder";
|
|
9
|
+
}>>>;
|
|
10
|
+
contentTypes: _tulip_systems_core_data_tables0.ParseFilter<zod.ZodArray<zod.ZodString>>;
|
|
11
|
+
nodeIds: _tulip_systems_core_data_tables0.ParseFilter<zod.ZodArray<zod.ZodString>>;
|
|
12
|
+
isArchived: _tulip_systems_core_data_tables0.ParseFilter<zod.ZodBoolean>;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { googleDriveTreeFilters };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/providers/google/lib/constants.ts
|
|
2
|
+
const GOOGLE_DRIVE_FOLDER_MIME_TYPE = "application/vnd.google-apps.folder";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal Google file fields needed to build a complete `GoogleDriveNode`.
|
|
5
|
+
*
|
|
6
|
+
* Keeping this list explicit prevents over-fetching large provider payloads and
|
|
7
|
+
* ensures every service method receives metadata with the same expected shape.
|
|
8
|
+
*/
|
|
9
|
+
const GOOGLE_DRIVE_NODE_FIELDS = "id,name,mimeType,size,parents,driveId,createdTime,modifiedTime,trashed,trashedTime,webViewLink,webContentLink,thumbnailLink,contentRestrictions,capabilities";
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { GOOGLE_DRIVE_FOLDER_MIME_TYPE, GOOGLE_DRIVE_NODE_FIELDS };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GoogleDriveNode } from "./validators.mjs";
|
|
2
|
+
import { drive_v3 } from "googleapis";
|
|
3
|
+
|
|
4
|
+
//#region src/providers/google/lib/dto.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Input used by the DTO factory.
|
|
7
|
+
*
|
|
8
|
+
* `namespace` can be supplied by callers when Google metadata does not include
|
|
9
|
+
* enough drive context. Most service calls rely on `driveId` or the first parent
|
|
10
|
+
* from the Google response instead.
|
|
11
|
+
*/
|
|
12
|
+
type GoogleDriveNodeDTOInput = {
|
|
13
|
+
file: drive_v3.Schema$File;
|
|
14
|
+
namespace?: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Factory for mapping Google Drive API file metadata to the provider-neutral node shape.
|
|
18
|
+
* This is the single source of truth for how Google Drive metadata maps to our shared
|
|
19
|
+
* `DriveNode` contract, ensuring consistent mapping across all service methods.
|
|
20
|
+
* The factory also handles missing or partial metadata from Google by applying sensible
|
|
21
|
+
* defaults and fallbacks, so the shared DTO always satisfies the base contract expected
|
|
22
|
+
* by the UI and other consumers.
|
|
23
|
+
*/
|
|
24
|
+
declare const GoogleDriveNodeDTO: {
|
|
25
|
+
/**
|
|
26
|
+
* Maps raw Google Drive file metadata to the provider-neutral Drive node shape.
|
|
27
|
+
*
|
|
28
|
+
* Google models files and folders with the same `drive_v3.Schema$File` object.
|
|
29
|
+
* Folders are detected by their special MIME type, while every other MIME type
|
|
30
|
+
* is treated as a file and mapped to a provider-neutral subtype.
|
|
31
|
+
*/
|
|
32
|
+
create({
|
|
33
|
+
file,
|
|
34
|
+
namespace
|
|
35
|
+
}: GoogleDriveNodeDTOInput): GoogleDriveNode;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { GoogleDriveNodeDTO, GoogleDriveNodeDTOInput };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { inferLocalDriveNodeSubtype } from "../../local/lib/helpers.mjs";
|
|
2
|
+
import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "./constants.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/providers/google/lib/dto.ts
|
|
5
|
+
/**
|
|
6
|
+
* Factory for mapping Google Drive API file metadata to the provider-neutral node shape.
|
|
7
|
+
* This is the single source of truth for how Google Drive metadata maps to our shared
|
|
8
|
+
* `DriveNode` contract, ensuring consistent mapping across all service methods.
|
|
9
|
+
* The factory also handles missing or partial metadata from Google by applying sensible
|
|
10
|
+
* defaults and fallbacks, so the shared DTO always satisfies the base contract expected
|
|
11
|
+
* by the UI and other consumers.
|
|
12
|
+
*/
|
|
13
|
+
const GoogleDriveNodeDTO = { create({ file, namespace }) {
|
|
14
|
+
if (!file.id) throw new Error("Google Drive file has no id");
|
|
15
|
+
const isFolder = file.mimeType === GOOGLE_DRIVE_FOLDER_MIME_TYPE;
|
|
16
|
+
const createdAt = file.createdTime ? new Date(file.createdTime) : /* @__PURE__ */ new Date();
|
|
17
|
+
const updatedAt = file.modifiedTime ? new Date(file.modifiedTime) : createdAt;
|
|
18
|
+
const trashedAt = file.trashedTime ? new Date(file.trashedTime) : null;
|
|
19
|
+
const archivedAt = file.trashed ? trashedAt ?? new Date(file.modifiedTime ?? Date.now()) : null;
|
|
20
|
+
const contentType = isFolder ? null : file.mimeType ?? null;
|
|
21
|
+
const name = file.name ?? "Untitled";
|
|
22
|
+
const googleParents = file.parents ?? [];
|
|
23
|
+
const [googleParentId] = googleParents;
|
|
24
|
+
const nodeNamespace = namespace ?? file.driveId ?? googleParentId;
|
|
25
|
+
if (!nodeNamespace) throw new Error("Google Drive file has no namespace");
|
|
26
|
+
const readonly = file.contentRestrictions?.some((restriction) => restriction.readOnly) ?? file.capabilities?.canEdit === false;
|
|
27
|
+
return {
|
|
28
|
+
id: file.id,
|
|
29
|
+
provider: "google",
|
|
30
|
+
createdAt,
|
|
31
|
+
updatedAt,
|
|
32
|
+
name,
|
|
33
|
+
namespace: nodeNamespace,
|
|
34
|
+
type: isFolder ? "folder" : "file",
|
|
35
|
+
subtype: isFolder ? "other" : inferLocalDriveNodeSubtype({
|
|
36
|
+
name,
|
|
37
|
+
contentType
|
|
38
|
+
}),
|
|
39
|
+
size: file.size ? Number(file.size) : null,
|
|
40
|
+
contentType,
|
|
41
|
+
readonly,
|
|
42
|
+
hidden: false,
|
|
43
|
+
archivedAt,
|
|
44
|
+
parentId: googleParentId && googleParentId !== nodeNamespace ? googleParentId : null,
|
|
45
|
+
links: {
|
|
46
|
+
view: file.webViewLink ?? file.webContentLink ?? null,
|
|
47
|
+
download: file.webContentLink ?? null,
|
|
48
|
+
preview: file.webViewLink ?? null,
|
|
49
|
+
thumbnail: file.thumbnailLink ?? null
|
|
50
|
+
},
|
|
51
|
+
availability: "ready",
|
|
52
|
+
googleDriveId: file.driveId ?? null,
|
|
53
|
+
mimeType: file.mimeType ?? null,
|
|
54
|
+
webViewLink: file.webViewLink ?? null,
|
|
55
|
+
webContentLink: file.webContentLink ?? null,
|
|
56
|
+
thumbnailLink: file.thumbnailLink ?? null,
|
|
57
|
+
trashed: file.trashed ?? false,
|
|
58
|
+
trashedAt,
|
|
59
|
+
googleParents,
|
|
60
|
+
canEdit: file.capabilities?.canEdit ?? null
|
|
61
|
+
};
|
|
62
|
+
} };
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { GoogleDriveNodeDTO };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
|
|
3
|
+
//#region src/providers/google/lib/helpers.ts
|
|
4
|
+
/**
|
|
5
|
+
* Escapes dynamic values before interpolating them into Google Drive `q` strings.
|
|
6
|
+
*
|
|
7
|
+
* Drive query values are wrapped in single quotes. Backslashes and single quotes
|
|
8
|
+
* can otherwise break the query literal or change the meaning of the expression.
|
|
9
|
+
*/
|
|
10
|
+
function escapeGoogleDriveQueryValue(value) {
|
|
11
|
+
return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns true when a Google API error represents a missing file/folder.
|
|
15
|
+
*
|
|
16
|
+
* The Google client throws rich error objects rather than typed exceptions, so
|
|
17
|
+
* the service checks the normalized `code` property and treats only 404 as a
|
|
18
|
+
* nullable not-found result. Permission, quota, and transport failures should
|
|
19
|
+
* keep bubbling up.
|
|
20
|
+
*/
|
|
21
|
+
function isGoogleNotFound(error) {
|
|
22
|
+
return typeof error === "object" && error != null && "code" in error && error.code === 404;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Normalizes supported object body inputs into a readable stream for googleapis.
|
|
26
|
+
*
|
|
27
|
+
* The Drive client accepts a stream-like `media.body`. Local upload flows can
|
|
28
|
+
* provide strings, buffers, array-like chunks, or already-created streams, so we
|
|
29
|
+
* pass through streams and wrap everything else with `Readable.from`.
|
|
30
|
+
*/
|
|
31
|
+
function toGoogleDriveReadable(body) {
|
|
32
|
+
if (body instanceof Readable) return body;
|
|
33
|
+
if (typeof body === "string") return Readable.from([body]);
|
|
34
|
+
return Readable.from([body]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
export { escapeGoogleDriveQueryValue, isGoogleNotFound, toGoogleDriveReadable };
|