@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,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useDriveViewContext } from "../view.client.mjs";
|
|
4
|
+
import { LayoutGridIcon, StretchVerticalIcon } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { ToggleGroup, ToggleGroupItem } from "@tulip-systems/core/components/client";
|
|
7
|
+
|
|
8
|
+
//#region src/components/navigation/view-switcher.client.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Drive view switcher
|
|
11
|
+
*/
|
|
12
|
+
function DriveViewSwitcher() {
|
|
13
|
+
const { view, onViewChange } = useDriveViewContext();
|
|
14
|
+
return /* @__PURE__ */ jsxs(ToggleGroup, {
|
|
15
|
+
type: "single",
|
|
16
|
+
variant: "outline",
|
|
17
|
+
value: view,
|
|
18
|
+
onValueChange: (value) => {
|
|
19
|
+
console.log("DriveViewSwitcher: Changing view to", value);
|
|
20
|
+
onViewChange(value ? value : "grid");
|
|
21
|
+
},
|
|
22
|
+
children: [/* @__PURE__ */ jsx(ToggleGroupItem, {
|
|
23
|
+
value: "grid",
|
|
24
|
+
"aria-label": "Toggle grid view",
|
|
25
|
+
children: /* @__PURE__ */ jsx(LayoutGridIcon, {})
|
|
26
|
+
}), /* @__PURE__ */ jsx(ToggleGroupItem, {
|
|
27
|
+
value: "list",
|
|
28
|
+
"aria-label": "Toggle list view",
|
|
29
|
+
children: /* @__PURE__ */ jsx(StretchVerticalIcon, {})
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { DriveViewSwitcher };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DriveNode } from "../lib/dto.mjs";
|
|
2
|
+
import { Selection } from "@tulip-systems/core/data-tables";
|
|
3
|
+
import { PropsWithChildren } from "react";
|
|
4
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/selection.client.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* DriveSelectionContextValue
|
|
9
|
+
*/
|
|
10
|
+
type DriveSelectionContextValue = {
|
|
11
|
+
selection?: Selection;
|
|
12
|
+
selectionConditions?: (node: DriveNode) => boolean | boolean[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* useDriveSelectionContext
|
|
16
|
+
*/
|
|
17
|
+
declare function useDriveSelectionContext(): DriveSelectionContextValue | null;
|
|
18
|
+
/**
|
|
19
|
+
* DriveSelectionProvider
|
|
20
|
+
*/
|
|
21
|
+
declare function DriveSelectionProvider({
|
|
22
|
+
selection,
|
|
23
|
+
selectionConditions,
|
|
24
|
+
children
|
|
25
|
+
}: PropsWithChildren<DriveSelectionContextValue>): react_jsx_runtime0.JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { DriveSelectionContextValue, DriveSelectionProvider, useDriveSelectionContext };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, use, useMemo, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/selection.client.tsx
|
|
7
|
+
const DriveSelectionContext = createContext(null);
|
|
8
|
+
/**
|
|
9
|
+
* useDriveSelectionContext
|
|
10
|
+
*/
|
|
11
|
+
function useDriveSelectionContext() {
|
|
12
|
+
return use(DriveSelectionContext) ?? null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DriveSelectionProvider
|
|
16
|
+
*/
|
|
17
|
+
function DriveSelectionProvider({ selection, selectionConditions, children }) {
|
|
18
|
+
const [_rowSelection, _setRowSelection] = useState({});
|
|
19
|
+
return /* @__PURE__ */ jsx(DriveSelectionContext, {
|
|
20
|
+
value: useMemo(() => ({
|
|
21
|
+
selection: {
|
|
22
|
+
rowSelection: selection?.rowSelection ?? _rowSelection,
|
|
23
|
+
setRowSelection: selection?.setRowSelection ?? _setRowSelection
|
|
24
|
+
},
|
|
25
|
+
selectionConditions
|
|
26
|
+
}), [
|
|
27
|
+
selection,
|
|
28
|
+
selectionConditions,
|
|
29
|
+
_rowSelection
|
|
30
|
+
]),
|
|
31
|
+
children
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { DriveSelectionProvider, useDriveSelectionContext };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/view.client.d.ts
|
|
5
|
+
type DriveViewMode = "grid" | "list";
|
|
6
|
+
/**
|
|
7
|
+
* DriveViewContextValue
|
|
8
|
+
*/
|
|
9
|
+
type DriveViewContextValue = {
|
|
10
|
+
view: DriveViewMode;
|
|
11
|
+
onViewChange: (view: DriveViewMode) => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* useDriveViewContext
|
|
15
|
+
*/
|
|
16
|
+
declare function useDriveViewContext(): DriveViewContextValue;
|
|
17
|
+
/**
|
|
18
|
+
* DriveViewProvider
|
|
19
|
+
*/
|
|
20
|
+
type DriveViewProviderProps = PropsWithChildren<Partial<DriveViewContextValue>> & {
|
|
21
|
+
initialView?: DriveViewMode;
|
|
22
|
+
};
|
|
23
|
+
declare function DriveViewProvider(props: DriveViewProviderProps): react_jsx_runtime0.JSX.Element;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { DriveViewContextValue, DriveViewMode, DriveViewProvider, DriveViewProviderProps, useDriveViewContext };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { DRIVE_VIEW_COOKIE, DRIVE_VIEW_COOKIE_MAX_AGE } from "../lib/constants.mjs";
|
|
4
|
+
import { createContext, use, useCallback, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/components/view.client.tsx
|
|
8
|
+
const DriveViewContext = createContext(null);
|
|
9
|
+
/**
|
|
10
|
+
* useDriveViewContext
|
|
11
|
+
*/
|
|
12
|
+
function useDriveViewContext() {
|
|
13
|
+
const context = use(DriveViewContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
console.warn("DriveViewContext not found!");
|
|
16
|
+
return {
|
|
17
|
+
view: "grid",
|
|
18
|
+
onViewChange: () => {
|
|
19
|
+
throw new Error("DriveViewContext not found!");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return context;
|
|
24
|
+
}
|
|
25
|
+
function DriveViewProvider(props) {
|
|
26
|
+
const [_view, _setView] = useState(props.view ?? props.initialView ?? "grid");
|
|
27
|
+
const view = props.view ?? _view;
|
|
28
|
+
return /* @__PURE__ */ jsx(DriveViewContext, {
|
|
29
|
+
value: {
|
|
30
|
+
view,
|
|
31
|
+
onViewChange: useCallback((value) => {
|
|
32
|
+
const viewState = typeof value === "function" ? value(view) : value;
|
|
33
|
+
if (props.onViewChange) props.onViewChange(viewState);
|
|
34
|
+
else _setView(viewState);
|
|
35
|
+
document.cookie = `${DRIVE_VIEW_COOKIE}=${viewState}; path=/; max-age=${DRIVE_VIEW_COOKIE_MAX_AGE}`;
|
|
36
|
+
}, [props.onViewChange, view])
|
|
37
|
+
},
|
|
38
|
+
children: props.children
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { DriveViewProvider, useDriveViewContext };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DRIVE_NODE_TYPES } from "../lib/constants.mjs";
|
|
2
|
+
import z$1 from "zod";
|
|
3
|
+
import { createTableFilters, parseFilterArray, parseFilterBoolean } from "@tulip-systems/core/data-tables";
|
|
4
|
+
|
|
5
|
+
//#region src/config/filters.ts
|
|
6
|
+
const driveTreeFilters = createTableFilters({
|
|
7
|
+
types: parseFilterArray(z$1.array(z$1.enum(DRIVE_NODE_TYPES))),
|
|
8
|
+
contentTypes: parseFilterArray(z$1.array(z$1.string())),
|
|
9
|
+
nodeIds: parseFilterArray(z$1.array(z$1.string())),
|
|
10
|
+
isArchived: parseFilterBoolean(z$1.boolean())
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { driveTreeFilters };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createStatusConfig, createStatusVariants } from "@tulip-systems/core/components";
|
|
2
|
+
import { FileArchiveIcon, FileAudioIcon, FileIcon, FileImageIcon, FileSpreadsheetIcon, FileTextIcon, FileVideoIcon } from "lucide-react";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/config/types.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Node subtype config
|
|
9
|
+
*/
|
|
10
|
+
const nodeSubtypeConfig = createStatusConfig([
|
|
11
|
+
{
|
|
12
|
+
value: "image",
|
|
13
|
+
label: "Afbeelding",
|
|
14
|
+
icon: FileImageIcon,
|
|
15
|
+
className: "stroke-blue-500"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: "document",
|
|
19
|
+
label: "Document",
|
|
20
|
+
icon: FileTextIcon,
|
|
21
|
+
className: "stroke-red-600"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: "archive",
|
|
25
|
+
label: "Archief",
|
|
26
|
+
icon: FileArchiveIcon,
|
|
27
|
+
className: "stroke-yellow-500"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: "audio",
|
|
31
|
+
label: "Audio",
|
|
32
|
+
icon: FileAudioIcon,
|
|
33
|
+
className: "stroke-pink-500"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: "video",
|
|
37
|
+
label: "Video",
|
|
38
|
+
icon: FileVideoIcon,
|
|
39
|
+
className: "stroke-purple-500"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
value: "spreadsheet",
|
|
43
|
+
label: "Tabel",
|
|
44
|
+
icon: FileSpreadsheetIcon,
|
|
45
|
+
className: "stroke-green-600"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: "other",
|
|
49
|
+
label: "Bestand",
|
|
50
|
+
icon: FileIcon,
|
|
51
|
+
className: "stroke-gray-400"
|
|
52
|
+
}
|
|
53
|
+
]);
|
|
54
|
+
/**
|
|
55
|
+
* Node subtype variants
|
|
56
|
+
*/
|
|
57
|
+
const nodeSubtypeVariants = cva("", { variants: { status: createStatusVariants(nodeSubtypeConfig) } });
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { nodeSubtypeConfig, nodeSubtypeVariants };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GoogleDriveFileUpdateCommand, GoogleDriveFileUpdateCommandProps } from "../providers/google/components/command-file-update.mjs";
|
|
2
|
+
import { GoogleDriveFoldersCreateCommand, GoogleDriveFoldersCreateCommandProps } from "../providers/google/components/command-folder-create.mjs";
|
|
3
|
+
import { GoogleDriveFoldersUpdateCommand, GoogleDriveFoldersUpdateCommandProps } from "../providers/google/components/command-folder-update.mjs";
|
|
4
|
+
import { GoogleDriveContent } from "../providers/google/components/content.client.mjs";
|
|
5
|
+
import { GoogleDriveHeader, GoogleDriveHeaderBreadcrumbs, GoogleDriveHeaderTools, GoogleDriveToolbar, GoogleDriveToolbarBreadcrumbs, GoogleDriveToolbarTools, GoogleDriveViewSwitcher } from "../providers/google/components/navigation.client.mjs";
|
|
6
|
+
import { GoogleDriveContext, GoogleDriveContextValue, GoogleDriveProvider, useGoogleDriveContext } from "../providers/google/components/provider.client.mjs";
|
|
7
|
+
import { GoogleDriveView, GoogleDriveViewLoading, GoogleDriveViewProvider } from "../providers/google/components/view.client.mjs";
|
|
8
|
+
export { GoogleDriveContent, GoogleDriveContext, GoogleDriveContextValue, GoogleDriveFileUpdateCommand, GoogleDriveFileUpdateCommandProps, GoogleDriveFoldersCreateCommand, GoogleDriveFoldersCreateCommandProps, GoogleDriveFoldersUpdateCommand, GoogleDriveFoldersUpdateCommandProps, GoogleDriveHeader, GoogleDriveHeaderBreadcrumbs, GoogleDriveHeaderTools, GoogleDriveProvider, GoogleDriveToolbar, GoogleDriveToolbarBreadcrumbs, GoogleDriveToolbarTools, GoogleDriveView, GoogleDriveViewLoading, GoogleDriveViewProvider, GoogleDriveViewSwitcher, useGoogleDriveContext };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GoogleDriveFileUpdateCommand } from "../providers/google/components/command-file-update.mjs";
|
|
2
|
+
import { GoogleDriveFoldersCreateCommand } from "../providers/google/components/command-folder-create.mjs";
|
|
3
|
+
import { GoogleDriveFoldersUpdateCommand } from "../providers/google/components/command-folder-update.mjs";
|
|
4
|
+
import { GoogleDriveContent } from "../providers/google/components/content.client.mjs";
|
|
5
|
+
import { GoogleDriveHeader, GoogleDriveHeaderBreadcrumbs, GoogleDriveHeaderTools, GoogleDriveToolbar, GoogleDriveToolbarBreadcrumbs, GoogleDriveToolbarTools, GoogleDriveViewSwitcher } from "../providers/google/components/navigation.client.mjs";
|
|
6
|
+
import { GoogleDriveContext, GoogleDriveProvider, useGoogleDriveContext } from "../providers/google/components/provider.client.mjs";
|
|
7
|
+
import { GoogleDriveView, GoogleDriveViewLoading, GoogleDriveViewProvider } from "../providers/google/components/view.client.mjs";
|
|
8
|
+
|
|
9
|
+
export { GoogleDriveContent, GoogleDriveContext, GoogleDriveFileUpdateCommand, GoogleDriveFoldersCreateCommand, GoogleDriveFoldersUpdateCommand, GoogleDriveHeader, GoogleDriveHeaderBreadcrumbs, GoogleDriveHeaderTools, GoogleDriveProvider, GoogleDriveToolbar, GoogleDriveToolbarBreadcrumbs, GoogleDriveToolbarTools, GoogleDriveView, GoogleDriveViewLoading, GoogleDriveViewProvider, GoogleDriveViewSwitcher, useGoogleDriveContext };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CreateGoogleDriveFolderInput, CreateGoogleDriveFolderSchema, GetGoogleDriveNodesByParentIdInput, GetGoogleDriveNodesByParentIdSchema, GoogleDriveNode, GoogleDriveNodeChild, GoogleDriveNodeWithChildren, GoogleDriveTableFilters, GoogleDriveTableFiltersInput, ListGoogleDriveTreeInput, ListGoogleDriveTreeSchema, UpdateGoogleDriveNodeInput, UpdateGoogleDriveNodeSchema, UploadGoogleDriveFileInput, UploadGoogleDriveFileSchema, createGoogleDriveFolderInputSchema, getGoogleDriveNodesByParentIdInputSchema, googleDriveNodeSchema, googleDriveNodeWithChildrenSchema, googleDriveTableFiltersSchema, listGoogleDriveTreeInputSchema, updateGoogleDriveNodeInputSchema, uploadGoogleDriveFileInputSchema } from "./providers/google/lib/validators.mjs";
|
|
2
|
+
import { googleDriveColumns } from "./providers/google/config/columns-data.mjs";
|
|
3
|
+
import { googleDriveTreeFilters } from "./providers/google/config/filters.mjs";
|
|
4
|
+
import { GoogleDriveNodeDTO, GoogleDriveNodeDTOInput } from "./providers/google/lib/dto.mjs";
|
|
5
|
+
import { googleDriveTreeFilterSearchParams } from "./providers/google/lib/search-params.mjs";
|
|
6
|
+
export { CreateGoogleDriveFolderInput, CreateGoogleDriveFolderSchema, GetGoogleDriveNodesByParentIdInput, GetGoogleDriveNodesByParentIdSchema, GoogleDriveNode, GoogleDriveNodeChild, GoogleDriveNodeDTO, GoogleDriveNodeDTOInput, GoogleDriveNodeWithChildren, GoogleDriveTableFilters, GoogleDriveTableFiltersInput, ListGoogleDriveTreeInput, ListGoogleDriveTreeSchema, UpdateGoogleDriveNodeInput, UpdateGoogleDriveNodeSchema, UploadGoogleDriveFileInput, UploadGoogleDriveFileSchema, createGoogleDriveFolderInputSchema, getGoogleDriveNodesByParentIdInputSchema, googleDriveColumns, googleDriveNodeSchema, googleDriveNodeWithChildrenSchema, googleDriveTableFiltersSchema, googleDriveTreeFilterSearchParams, googleDriveTreeFilters, listGoogleDriveTreeInputSchema, updateGoogleDriveNodeInputSchema, uploadGoogleDriveFileInputSchema };
|
package/dist/google.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { googleDriveColumns } from "./providers/google/config/columns-data.mjs";
|
|
2
|
+
import { googleDriveTreeFilters } from "./providers/google/config/filters.mjs";
|
|
3
|
+
import { GoogleDriveNodeDTO } from "./providers/google/lib/dto.mjs";
|
|
4
|
+
import { googleDriveTreeFilterSearchParams } from "./providers/google/lib/search-params.mjs";
|
|
5
|
+
import { createGoogleDriveFolderInputSchema, getGoogleDriveNodesByParentIdInputSchema, googleDriveNodeSchema, googleDriveNodeWithChildrenSchema, googleDriveTableFiltersSchema, listGoogleDriveTreeInputSchema, updateGoogleDriveNodeInputSchema, uploadGoogleDriveFileInputSchema } from "./providers/google/lib/validators.mjs";
|
|
6
|
+
|
|
7
|
+
export { GoogleDriveNodeDTO, createGoogleDriveFolderInputSchema, getGoogleDriveNodesByParentIdInputSchema, googleDriveColumns, googleDriveNodeSchema, googleDriveNodeWithChildrenSchema, googleDriveTableFiltersSchema, googleDriveTreeFilterSearchParams, googleDriveTreeFilters, listGoogleDriveTreeInputSchema, updateGoogleDriveNodeInputSchema, uploadGoogleDriveFileInputSchema };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DriveFolderParent, DriveNode, DriveNodeAvailability, DriveNodeBase, DriveNodeChild, DriveNodeLinks, DriveNodeProvider, DriveNodeSubtype, DriveNodeType, DriveNodeWithChildren, driveNodeAvailabilitySchema, driveNodeLinksSchema, driveNodeProviderSchema, driveNodeSchema, driveNodeSubtypeSchema, driveNodeTypeSchema } from "./lib/dto.mjs";
|
|
2
|
+
import { DRIVE_NODE_SUBTYPES, DRIVE_NODE_TYPES, DRIVE_PROVIDERS, DRIVE_VIEW_COOKIE, DRIVE_VIEW_COOKIE_MAX_AGE } from "./lib/constants.mjs";
|
|
3
|
+
import { CreateDriveFolderInput, CreateDriveFolderSchema, GetDriveNodesByParentIdInput, GetDriveNodesByParentIdSchema, ListDriveTreeInput, ListDriveTreeSchema, NodesTableFilters, PresignDriveFileInput, PresignDriveFileSchema, UpdateDriveNodeInput, UpdateDriveNodeSchema, UploadDriveFileInput, UploadDriveFileSchema, createDriveFolderInputSchema, driveTableFiltersSchema, getNodesByParentIdInputSchema, listDriveTreeInputSchema, presignDriveFileInputSchema, updateDriveNodeInputSchema, uploadDriveFileInputSchema } from "./lib/validators.mjs";
|
|
4
|
+
import { Drive, DriveArchive, DriveDirectUpload, DriveNodeMutations, DrivePresignedUpload, DrivePresignedUploadResult, DrivePreviewGenerator, DriveReader, DriveReadonly } from "./lib/contracts.mjs";
|
|
5
|
+
import { isFile, isFolder, renderBytes } from "./lib/helpers.mjs";
|
|
6
|
+
import { driveTreeSearchParams } from "./lib/search-params.mjs";
|
|
7
|
+
export { CreateDriveFolderInput, CreateDriveFolderSchema, DRIVE_NODE_SUBTYPES, DRIVE_NODE_TYPES, DRIVE_PROVIDERS, DRIVE_VIEW_COOKIE, DRIVE_VIEW_COOKIE_MAX_AGE, Drive, DriveArchive, DriveDirectUpload, DriveFolderParent, DriveNode, DriveNodeAvailability, DriveNodeBase, DriveNodeChild, DriveNodeLinks, DriveNodeMutations, DriveNodeProvider, DriveNodeSubtype, DriveNodeType, DriveNodeWithChildren, DrivePresignedUpload, DrivePresignedUploadResult, DrivePreviewGenerator, DriveReader, DriveReadonly, GetDriveNodesByParentIdInput, GetDriveNodesByParentIdSchema, ListDriveTreeInput, ListDriveTreeSchema, NodesTableFilters, PresignDriveFileInput, PresignDriveFileSchema, UpdateDriveNodeInput, UpdateDriveNodeSchema, UploadDriveFileInput, UploadDriveFileSchema, createDriveFolderInputSchema, driveNodeAvailabilitySchema, driveNodeLinksSchema, driveNodeProviderSchema, driveNodeSchema, driveNodeSubtypeSchema, driveNodeTypeSchema, driveTableFiltersSchema, driveTreeSearchParams, getNodesByParentIdInputSchema, isFile, isFolder, listDriveTreeInputSchema, presignDriveFileInputSchema, renderBytes, updateDriveNodeInputSchema, uploadDriveFileInputSchema };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DRIVE_NODE_SUBTYPES, DRIVE_NODE_TYPES, DRIVE_PROVIDERS, DRIVE_VIEW_COOKIE, DRIVE_VIEW_COOKIE_MAX_AGE } from "./lib/constants.mjs";
|
|
2
|
+
import { driveNodeAvailabilitySchema, driveNodeLinksSchema, driveNodeProviderSchema, driveNodeSchema, driveNodeSubtypeSchema, driveNodeTypeSchema } from "./lib/dto.mjs";
|
|
3
|
+
import { isFile, isFolder, renderBytes } from "./lib/helpers.mjs";
|
|
4
|
+
import { driveTreeSearchParams } from "./lib/search-params.mjs";
|
|
5
|
+
import { createDriveFolderInputSchema, driveTableFiltersSchema, getNodesByParentIdInputSchema, listDriveTreeInputSchema, presignDriveFileInputSchema, updateDriveNodeInputSchema, uploadDriveFileInputSchema } from "./lib/validators.mjs";
|
|
6
|
+
|
|
7
|
+
export { DRIVE_NODE_SUBTYPES, DRIVE_NODE_TYPES, DRIVE_PROVIDERS, DRIVE_VIEW_COOKIE, DRIVE_VIEW_COOKIE_MAX_AGE, createDriveFolderInputSchema, driveNodeAvailabilitySchema, driveNodeLinksSchema, driveNodeProviderSchema, driveNodeSchema, driveNodeSubtypeSchema, driveNodeTypeSchema, driveTableFiltersSchema, driveTreeSearchParams, getNodesByParentIdInputSchema, isFile, isFolder, listDriveTreeInputSchema, presignDriveFileInputSchema, renderBytes, updateDriveNodeInputSchema, uploadDriveFileInputSchema };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/lib/constants.d.ts
|
|
2
|
+
declare const DRIVE_PROVIDERS: readonly ["local", "google"];
|
|
3
|
+
declare const DRIVE_NODE_TYPES: readonly ["folder", "file"];
|
|
4
|
+
declare const DRIVE_NODE_SUBTYPES: readonly ["image", "document", "spreadsheet", "video", "audio", "archive", "other"];
|
|
5
|
+
/**
|
|
6
|
+
* The cookie name for storing the drive view mode (grid or list).
|
|
7
|
+
*/
|
|
8
|
+
declare const DRIVE_VIEW_COOKIE: "tulip.drive_view_mode";
|
|
9
|
+
declare const DRIVE_VIEW_COOKIE_MAX_AGE: number;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DRIVE_NODE_SUBTYPES, DRIVE_NODE_TYPES, DRIVE_PROVIDERS, DRIVE_VIEW_COOKIE, DRIVE_VIEW_COOKIE_MAX_AGE };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/lib/constants.ts
|
|
2
|
+
const DRIVE_PROVIDERS = ["local", "google"];
|
|
3
|
+
const DRIVE_NODE_TYPES = ["folder", "file"];
|
|
4
|
+
const DRIVE_NODE_SUBTYPES = [
|
|
5
|
+
"image",
|
|
6
|
+
"document",
|
|
7
|
+
"spreadsheet",
|
|
8
|
+
"video",
|
|
9
|
+
"audio",
|
|
10
|
+
"archive",
|
|
11
|
+
"other"
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* The cookie name for storing the drive view mode (grid or list).
|
|
15
|
+
*/
|
|
16
|
+
const DRIVE_VIEW_COOKIE = "tulip.drive_view_mode";
|
|
17
|
+
const DRIVE_VIEW_COOKIE_MAX_AGE = 3600 * 24 * 7;
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { DRIVE_NODE_SUBTYPES, DRIVE_NODE_TYPES, DRIVE_PROVIDERS, DRIVE_VIEW_COOKIE, DRIVE_VIEW_COOKIE_MAX_AGE };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { DriveFolderParent, DriveNode, DriveNodeBase, DriveNodeChild, DriveNodeWithChildren } from "./dto.mjs";
|
|
2
|
+
import { CreateDriveFolderInput, GetDriveNodesByParentIdInput, ListDriveTreeInput, PresignDriveFileInput, UpdateDriveNodeInput, UploadDriveFileInput } from "./validators.mjs";
|
|
3
|
+
import { TableQueryResponse } from "@tulip-systems/core/data-tables/server";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/contracts.d.ts
|
|
6
|
+
type DrivePresignedUploadResult<TNode extends DriveNodeBase = DriveNode> = {
|
|
7
|
+
uploadId: string;
|
|
8
|
+
presignedUrl: string;
|
|
9
|
+
node: TNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Read-only drive operations every provider should be able to support.
|
|
13
|
+
* This is the base contract for provider-agnostic consumers and intentionally
|
|
14
|
+
* excludes storage, upload, preview generation, readonly, and soft-delete
|
|
15
|
+
* behavior because those are provider capabilities, not universal drive reads.
|
|
16
|
+
*/
|
|
17
|
+
interface DriveReader<TNode extends DriveNodeBase = DriveNodeBase, TNodeWithChildren extends DriveNodeWithChildren<TNode> = DriveNodeWithChildren<TNode>, TNodeChild extends DriveNodeChild<TNode> = DriveNodeChild<TNode>> {
|
|
18
|
+
getNodeById(id: string): Promise<TNode | null>;
|
|
19
|
+
getNodeWithChildren(input: {
|
|
20
|
+
id: string;
|
|
21
|
+
namespace: string;
|
|
22
|
+
}): Promise<TNodeWithChildren | null>;
|
|
23
|
+
getNodesByParentId(input: GetDriveNodesByParentIdInput): Promise<TNode[]>;
|
|
24
|
+
listTree(input: ListDriveTreeInput): Promise<TableQueryResponse<TNode>>;
|
|
25
|
+
getFolderParents(input: {
|
|
26
|
+
id: string | null;
|
|
27
|
+
namespace: string;
|
|
28
|
+
}): Promise<Array<DriveFolderParent<TNode>>>;
|
|
29
|
+
getNodeChildren(ids: string[]): Promise<TNodeChild[]>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Optional capability for providers that can mutate the node tree.
|
|
33
|
+
* Providers that are read-only, remote-index-only, or permission-limited should
|
|
34
|
+
* not implement this contract.
|
|
35
|
+
*/
|
|
36
|
+
interface DriveNodeMutations<TNode extends DriveNodeBase = DriveNodeBase> {
|
|
37
|
+
createFolder(input: CreateDriveFolderInput): Promise<TNode>;
|
|
38
|
+
updateNode(id: string, data: UpdateDriveNodeInput): Promise<TNode>;
|
|
39
|
+
moveNode(input: {
|
|
40
|
+
id: string;
|
|
41
|
+
parentId: string | null;
|
|
42
|
+
}): Promise<TNode>;
|
|
43
|
+
deleteNode(id: string): Promise<void>;
|
|
44
|
+
deleteNodes(ids: string[]): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Optional capability for providers that accept a file body directly.
|
|
48
|
+
* The body type is provider-specific so the base contracts do not depend on any
|
|
49
|
+
* storage package or runtime upload representation.
|
|
50
|
+
*/
|
|
51
|
+
interface DriveDirectUpload<TNode extends DriveNodeBase = DriveNodeBase, TBody = unknown> {
|
|
52
|
+
uploadFile(input: UploadDriveFileInput & {
|
|
53
|
+
body: TBody;
|
|
54
|
+
}): Promise<TNode>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Optional capability for providers that create upload sessions/URLs.
|
|
58
|
+
* The returned metadata is provider-specific; local/object-storage providers can
|
|
59
|
+
* expose asset metadata here without leaking storage concepts into the base Drive
|
|
60
|
+
* contract.
|
|
61
|
+
*/
|
|
62
|
+
interface DrivePresignedUpload<TNode extends DriveNodeBase = DriveNodeBase, TResult extends DrivePresignedUploadResult<TNode> = DrivePresignedUploadResult<TNode>> {
|
|
63
|
+
presignUpload(input: PresignDriveFileInput): Promise<TResult>;
|
|
64
|
+
confirmUpload(uploadId: string): Promise<TNode>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Optional capability for providers that generate and persist preview variants.
|
|
68
|
+
* This is useful for local/object-storage providers. Providers with native
|
|
69
|
+
* previews, such as Google Drive, should not implement this just as a no-op.
|
|
70
|
+
*/
|
|
71
|
+
interface DrivePreviewGenerator {
|
|
72
|
+
generatePreviews(input: {
|
|
73
|
+
id: string;
|
|
74
|
+
}): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Optional capability for providers that can lock/unlock nodes.
|
|
78
|
+
* Google Drive maps this to `contentRestrictions.readOnly`; local drive maps it
|
|
79
|
+
* to its readonly flag. This is intentionally not part of the base reader
|
|
80
|
+
* contract because not every provider can honestly enforce it.
|
|
81
|
+
*/
|
|
82
|
+
interface DriveReadonly<TNode extends DriveNodeBase = DriveNodeBase> {
|
|
83
|
+
setReadonly(ids: string[], readonly: boolean): Promise<TNode[]>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Optional capability for providers that support soft removal.
|
|
87
|
+
* Local drive maps this to archive state; Google Drive maps this to trash.
|
|
88
|
+
*/
|
|
89
|
+
interface DriveArchive<TNode extends DriveNodeBase = DriveNodeBase> {
|
|
90
|
+
archiveNodes(ids: string[]): Promise<TNode[]>;
|
|
91
|
+
restoreNodes(ids: string[]): Promise<TNode[]>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Base provider-agnostic Drive contract.
|
|
95
|
+
* Additional behavior should be composed by intersecting optional capability
|
|
96
|
+
* contracts, for example `Drive<TNode> & DriveNodeMutations<TNode>`.
|
|
97
|
+
*/
|
|
98
|
+
type Drive<TNode extends DriveNodeBase = DriveNodeBase> = DriveReader<TNode>;
|
|
99
|
+
//#endregion
|
|
100
|
+
export { Drive, DriveArchive, DriveDirectUpload, DriveNodeMutations, DrivePresignedUpload, DrivePresignedUploadResult, DrivePreviewGenerator, DriveReader, DriveReadonly };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/dto.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Drive node provider
|
|
6
|
+
*/
|
|
7
|
+
declare const driveNodeProviderSchema: z.ZodEnum<{
|
|
8
|
+
local: "local";
|
|
9
|
+
google: "google";
|
|
10
|
+
}>;
|
|
11
|
+
type DriveNodeProvider = z.infer<typeof driveNodeProviderSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* Drive node type
|
|
14
|
+
*/
|
|
15
|
+
declare const driveNodeTypeSchema: z.ZodEnum<{
|
|
16
|
+
file: "file";
|
|
17
|
+
folder: "folder";
|
|
18
|
+
}>;
|
|
19
|
+
type DriveNodeType = z.infer<typeof driveNodeTypeSchema>;
|
|
20
|
+
/**
|
|
21
|
+
* Drive node subtype
|
|
22
|
+
*/
|
|
23
|
+
declare const driveNodeSubtypeSchema: z.ZodEnum<{
|
|
24
|
+
image: "image";
|
|
25
|
+
document: "document";
|
|
26
|
+
spreadsheet: "spreadsheet";
|
|
27
|
+
video: "video";
|
|
28
|
+
audio: "audio";
|
|
29
|
+
archive: "archive";
|
|
30
|
+
other: "other";
|
|
31
|
+
}>;
|
|
32
|
+
type DriveNodeSubtype = z.infer<typeof driveNodeSubtypeSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* Node availability
|
|
35
|
+
*/
|
|
36
|
+
declare const driveNodeAvailabilitySchema: z.ZodEnum<{
|
|
37
|
+
ready: "ready";
|
|
38
|
+
pending: "pending";
|
|
39
|
+
failed: "failed";
|
|
40
|
+
}>;
|
|
41
|
+
type DriveNodeAvailability = z.infer<typeof driveNodeAvailabilitySchema>;
|
|
42
|
+
/**
|
|
43
|
+
* Node links
|
|
44
|
+
*/
|
|
45
|
+
declare const driveNodeLinksSchema: z.ZodObject<{
|
|
46
|
+
view: z.ZodNullable<z.ZodString>;
|
|
47
|
+
download: z.ZodNullable<z.ZodString>;
|
|
48
|
+
preview: z.ZodNullable<z.ZodString>;
|
|
49
|
+
thumbnail: z.ZodNullable<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
type DriveNodeLinks = z.infer<typeof driveNodeLinksSchema>;
|
|
52
|
+
/**
|
|
53
|
+
* Node
|
|
54
|
+
*/
|
|
55
|
+
declare const driveNodeSchema: z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
provider: z.ZodEnum<{
|
|
58
|
+
local: "local";
|
|
59
|
+
google: "google";
|
|
60
|
+
}>;
|
|
61
|
+
createdAt: z.ZodDate;
|
|
62
|
+
updatedAt: z.ZodDate;
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
namespace: z.ZodString;
|
|
65
|
+
type: z.ZodEnum<{
|
|
66
|
+
file: "file";
|
|
67
|
+
folder: "folder";
|
|
68
|
+
}>;
|
|
69
|
+
subtype: z.ZodEnum<{
|
|
70
|
+
image: "image";
|
|
71
|
+
document: "document";
|
|
72
|
+
spreadsheet: "spreadsheet";
|
|
73
|
+
video: "video";
|
|
74
|
+
audio: "audio";
|
|
75
|
+
archive: "archive";
|
|
76
|
+
other: "other";
|
|
77
|
+
}>;
|
|
78
|
+
size: z.ZodNullable<z.ZodNumber>;
|
|
79
|
+
contentType: z.ZodNullable<z.ZodString>;
|
|
80
|
+
readonly: z.ZodBoolean;
|
|
81
|
+
hidden: z.ZodBoolean;
|
|
82
|
+
archivedAt: z.ZodNullable<z.ZodDate>;
|
|
83
|
+
parentId: z.ZodNullable<z.ZodString>;
|
|
84
|
+
links: z.ZodObject<{
|
|
85
|
+
view: z.ZodNullable<z.ZodString>;
|
|
86
|
+
download: z.ZodNullable<z.ZodString>;
|
|
87
|
+
preview: z.ZodNullable<z.ZodString>;
|
|
88
|
+
thumbnail: z.ZodNullable<z.ZodString>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
availability: z.ZodEnum<{
|
|
91
|
+
ready: "ready";
|
|
92
|
+
pending: "pending";
|
|
93
|
+
failed: "failed";
|
|
94
|
+
}>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
type DriveNode = z.infer<typeof driveNodeSchema>;
|
|
97
|
+
type DriveNodeBase = Omit<DriveNode, "provider">;
|
|
98
|
+
/**
|
|
99
|
+
* Node with children
|
|
100
|
+
*/
|
|
101
|
+
type DriveNodeWithChildren<TNode extends DriveNodeBase = DriveNode> = TNode & {
|
|
102
|
+
children: TNode[];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Node parent and child types
|
|
106
|
+
*/
|
|
107
|
+
type DriveFolderParent<TNode extends DriveNodeBase = DriveNode> = Pick<TNode, "id" | "name" | "parentId"> & {
|
|
108
|
+
depth: number;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Node child type
|
|
112
|
+
*/
|
|
113
|
+
type DriveNodeChild<TNode extends DriveNodeBase = DriveNode> = TNode & {
|
|
114
|
+
depth: number;
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
export { DriveFolderParent, DriveNode, DriveNodeAvailability, DriveNodeBase, DriveNodeChild, DriveNodeLinks, DriveNodeProvider, DriveNodeSubtype, DriveNodeType, DriveNodeWithChildren, driveNodeAvailabilitySchema, driveNodeLinksSchema, driveNodeProviderSchema, driveNodeSchema, driveNodeSubtypeSchema, driveNodeTypeSchema };
|
package/dist/lib/dto.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DRIVE_NODE_SUBTYPES, DRIVE_NODE_TYPES, DRIVE_PROVIDERS } from "./constants.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/dto.ts
|
|
5
|
+
/**
|
|
6
|
+
* Drive node provider
|
|
7
|
+
*/
|
|
8
|
+
const driveNodeProviderSchema = z.enum(DRIVE_PROVIDERS);
|
|
9
|
+
/**
|
|
10
|
+
* Drive node type
|
|
11
|
+
*/
|
|
12
|
+
const driveNodeTypeSchema = z.enum(DRIVE_NODE_TYPES);
|
|
13
|
+
/**
|
|
14
|
+
* Drive node subtype
|
|
15
|
+
*/
|
|
16
|
+
const driveNodeSubtypeSchema = z.enum(DRIVE_NODE_SUBTYPES);
|
|
17
|
+
/**
|
|
18
|
+
* Node availability
|
|
19
|
+
*/
|
|
20
|
+
const driveNodeAvailabilitySchema = z.enum([
|
|
21
|
+
"ready",
|
|
22
|
+
"pending",
|
|
23
|
+
"failed"
|
|
24
|
+
]);
|
|
25
|
+
/**
|
|
26
|
+
* Node links
|
|
27
|
+
*/
|
|
28
|
+
const driveNodeLinksSchema = z.object({
|
|
29
|
+
view: z.string().nullable(),
|
|
30
|
+
download: z.string().nullable(),
|
|
31
|
+
preview: z.string().nullable(),
|
|
32
|
+
thumbnail: z.string().nullable()
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Node
|
|
36
|
+
*/
|
|
37
|
+
const driveNodeSchema = z.object({
|
|
38
|
+
id: z.string(),
|
|
39
|
+
provider: driveNodeProviderSchema,
|
|
40
|
+
createdAt: z.date(),
|
|
41
|
+
updatedAt: z.date(),
|
|
42
|
+
name: z.string(),
|
|
43
|
+
namespace: z.string(),
|
|
44
|
+
type: driveNodeTypeSchema,
|
|
45
|
+
subtype: driveNodeSubtypeSchema,
|
|
46
|
+
size: z.number().nullable(),
|
|
47
|
+
contentType: z.string().nullable(),
|
|
48
|
+
readonly: z.boolean(),
|
|
49
|
+
hidden: z.boolean(),
|
|
50
|
+
archivedAt: z.date().nullable(),
|
|
51
|
+
parentId: z.string().nullable(),
|
|
52
|
+
links: driveNodeLinksSchema,
|
|
53
|
+
availability: driveNodeAvailabilitySchema
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { driveNodeAvailabilitySchema, driveNodeLinksSchema, driveNodeProviderSchema, driveNodeSchema, driveNodeSubtypeSchema, driveNodeTypeSchema };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DriveNode } from "./dto.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Check if the node is a file
|
|
6
|
+
*/
|
|
7
|
+
declare function isFile(node: Pick<DriveNode, "type">): node is DriveNode;
|
|
8
|
+
/**
|
|
9
|
+
* Check if the node is a folder
|
|
10
|
+
*/
|
|
11
|
+
declare function isFolder(node: Pick<DriveNode, "type">): node is DriveNode;
|
|
12
|
+
/**
|
|
13
|
+
* Render bytes
|
|
14
|
+
*/
|
|
15
|
+
declare function renderBytes(bytes: number): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { isFile, isFolder, renderBytes };
|