@mgamadeus/ddd-clouddrive 0.0.0-stage → 0.1.0-rc.21

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/screen/CloudDriveScreen.tsx","../../src/screen/CloudDriveSpacePicker.tsx","../../src/screen/driveFileMapping.ts","../../src/screen/useCloudDriveFileAdapter.ts","../../src/screen/driveFileActions.ts","../../src/screen/upload.ts"],"sourcesContent":["'use client';\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { FileManager, type FileAreaMaintenanceSlotProps, type FileAreaSettingsSlotProps } from '@mgamadeus/ddd-admin-ui/files';\nimport type { PdfJsLoader } from '@mgamadeus/ddd-admin-ui/files';\nimport { useTranslate } from '@mgamadeus/ddd-admin-ui/i18n';\nimport type { EntityDrawerUrlAdapter } from '@mgamadeus/ddd-admin-ui/logic/pure';\nimport type { UrlStateAdapter } from '@mgamadeus/ddd-admin-ui/logic/pure';\nimport { useMemoryUrlState } from '@mgamadeus/ddd-admin-ui/logic';\nimport { PageHeader } from '@mgamadeus/ddd-admin-ui/page';\nimport { Card, CardContent } from '@mgamadeus/ddd-admin-ui/primitives';\nimport { Skeleton } from '@mgamadeus/ddd-admin-ui/primitives';\nimport type { CloudDriveApi } from '../api.ts';\nimport { CloudDriveSpacePicker } from './CloudDriveSpacePicker.tsx';\nimport { DRIVE_EVENT_LABELS, driveAreaRefOf, driveFolderIdOf } from './driveFileMapping.ts';\nimport { useCloudDriveFileAdapter } from './useCloudDriveFileAdapter.ts';\n\n/**\n * The URL parameters of the drive screen: `space`, `path` (`/a/b`; a folder node id still works), `file` (the details),\n * `fileTab` (`accesses`), `tab` (`trash`), `view`, `q`, the filters and `sort`.\n */\nexport const CLOUD_DRIVE_URL_KEYS = { area: 'space', folder: 'path', order: 'sort', file: 'file', fileTab: 'fileTab', tab: 'tab' } as const;\n\n/** A deep link by node id (`?node=<id>`): replaced by `space` + `path` + `file` once the node is known. */\nexport const CLOUD_DRIVE_NODE_KEY = 'node';\n\n/** One folder of a path (`null` id: the root). Kept for hosts that typed deep links with it. */\nexport interface CloudDriveFolderStep {\n id: number | null;\n name: string;\n}\n\nexport interface CloudDriveScreenProps {\n api: CloudDriveApi;\n /** The page title; default \"Drive\". */\n title?: ReactNode;\n description?: ReactNode;\n /** The space shown first; default the first space in the picker's order. */\n initialSpaceId?: number;\n /** A folder to open first (a deep link); its space is read from the server. */\n initialFolderNodeId?: number;\n /** A file to open first (a deep link): its folder opens and its details drawer. */\n initialNodeId?: number;\n /** Actions next to the title. */\n headerActions?: ReactNode;\n /** The host's URL adapters (`useNextUrlStateAdapter`, `useNextDrawerUrlAdapter`); component state otherwise. */\n urlStateAdapter?: UrlStateAdapter;\n drawerUrlAdapter?: EntityDrawerUrlAdapter;\n /** pdf.js of the host for the PDF preview (without it a PDF offers its download only). */\n loadPdfJs?: PdfJsLoader;\n /** Host controls next to the page actions (a usage link, a maintenance action). */\n renderAreaMaintenance?: (props: FileAreaMaintenanceSlotProps) => ReactNode;\n /** The space's settings (a drawer of the host): the manager adds a \"Space settings\" button that opens it. */\n renderAreaSettings?: (props: FileAreaSettingsSlotProps) => ReactNode;\n /** The label of an event type the drive does not know (host events); `null` = the built-in label. */\n formatEventType?: (type: string) => string | null | undefined;\n /** Grid or table first; default grid. */\n defaultView?: 'grid' | 'table';\n /** `page` (default): a full-height page with its header; `embedded`: inside a tab or a preview, header-less. */\n variant?: 'page' | 'embedded';\n}\n\n/**\n * The drive screen: the file manager of `./files` on the drive (`useCloudDriveFileAdapter`) with a grouped, searchable\n * space picker. Folders, grid and table, upload straight to the store, details with preview, versions (restore) and\n * history, the malware status, the agents' unsaved changes, filters and orders, the trash (purge and empty for\n * managers). Needs mgamadeus/ddd-clouddrive ≥ 0.1.0-rc.10.\n */\nexport const CloudDriveScreen = ({\n api,\n title,\n description,\n initialSpaceId,\n initialFolderNodeId,\n initialNodeId,\n headerActions,\n urlStateAdapter,\n drawerUrlAdapter,\n loadPdfJs,\n renderAreaMaintenance,\n renderAreaSettings,\n formatEventType,\n defaultView,\n variant,\n}: CloudDriveScreenProps) => {\n const { t } = useTranslate();\n const spacesQuery = api.useDriveSpacesQuery();\n const spaceItems = spacesQuery.data?.items?.elements;\n const areas = useMemo(() => (spaceItems ?? []).map(driveAreaRefOf), [spaceItems]);\n const memory = useMemoryUrlState();\n const listUrl = urlStateAdapter ?? memory.urlStateAdapter;\n const drawerUrl = drawerUrlAdapter ?? memory.drawerUrlAdapter;\n\n // The open space lives in the URL (`space`; the first space when absent), like the folder (`path`) and the file.\n const urlSpace = Number(listUrl.get(CLOUD_DRIVE_URL_KEYS.area));\n const urlSpaceId = Number.isInteger(urlSpace) && urlSpace > 0 && spaceItems?.some(item => item.id === urlSpace) ? urlSpace : null;\n const initialSpace = initialSpaceId !== undefined && spaceItems?.some(item => item.id === initialSpaceId) ? initialSpaceId : null;\n const spaceId = urlSpaceId ?? initialSpace ?? (areas[0] ? Number(areas[0].key) : null);\n const spaceItem = spaceItems?.find(item => item.id === spaceId);\n const adapter = useCloudDriveFileAdapter({ api, spaceId: spaceId ?? 0 });\n const isPartner = api.audience === 'shared';\n\n // A deep link by node (`?node=<id>`, `initialNodeId` / `initialFolderNodeId`): its space, folder and (for a file)\n // the details drawer, once the node is known; the `node` parameter is then replaced by `space` + `path` + `file`.\n const urlNode = Number(listUrl.get(CLOUD_DRIVE_NODE_KEY));\n const deepLinkNodeId = Number.isInteger(urlNode) && urlNode > 0 ? urlNode : (initialNodeId ?? initialFolderNodeId);\n const [appliedNodeId, setAppliedNodeId] = useState<number | null>(null);\n const deepLinkPending = deepLinkNodeId !== undefined && appliedNodeId !== deepLinkNodeId;\n const deepLinkQuery = api.useDriveNodeQuery({ driveNodeId: deepLinkNodeId ?? 0 }, { skip: !deepLinkPending });\n const deepLinkSpace = spaceItems?.find(item => item.id === deepLinkQuery.data?.driveNode.driveSpaceId);\n useEffect(() => {\n if (!deepLinkPending || deepLinkNodeId === undefined) return;\n if (deepLinkQuery.isError) {\n setAppliedNodeId(deepLinkNodeId);\n listUrl.replace({ [CLOUD_DRIVE_NODE_KEY]: null });\n return;\n }\n if (!deepLinkQuery.data || !deepLinkSpace) return;\n const { driveNode } = deepLinkQuery.data;\n const isFolder = driveNode.nodeType === 'FOLDER';\n const folderId = isFolder ? driveFolderIdOf(driveNode.id, deepLinkSpace.rootNodeId) : driveFolderIdOf(driveNode.parentNodeId, deepLinkSpace.rootNodeId);\n listUrl.replace({\n [CLOUD_DRIVE_NODE_KEY]: null,\n [CLOUD_DRIVE_URL_KEYS.area]: String(driveNode.driveSpaceId),\n [CLOUD_DRIVE_URL_KEYS.folder]: folderId === null ? null : String(folderId),\n });\n if (!isFolder) drawerUrl.replace({ [CLOUD_DRIVE_URL_KEYS.file]: String(driveNode.id) });\n setAppliedNodeId(deepLinkNodeId);\n }, [deepLinkPending, deepLinkNodeId, deepLinkQuery.data, deepLinkQuery.isError, deepLinkSpace, listUrl, drawerUrl]);\n\n const eventLabel = useCallback(\n (type: string) => formatEventType?.(type) ?? (DRIVE_EVENT_LABELS[type] ? t(DRIVE_EVENT_LABELS[type]) : null),\n [formatEventType, t]\n );\n const heading = title ?? t('Drive');\n\n if (spacesQuery.isLoading || (deepLinkPending && deepLinkQuery.isLoading)) {\n return (\n <div className=\"space-y-4\">\n <PageHeader title={heading} description={description} actions={headerActions} />\n <Skeleton className=\"h-10 w-72\" />\n <Skeleton className=\"h-64 w-full\" />\n </div>\n );\n }\n if (spaceId === null || spaceItems === undefined) {\n return (\n <div className=\"space-y-4\">\n <PageHeader title={heading} description={description} actions={headerActions} />\n <Card>\n <CardContent className=\"py-10 text-center text-sm text-muted-foreground\">\n {spacesQuery.isError\n ? t('The spaces could not be loaded.')\n : spaceItems === undefined && spacesQuery.data\n ? t('This drive needs mgamadeus/ddd-clouddrive 0.1.0-rc.10 or newer on the server.')\n : t('There is no space you may read.')}\n </CardContent>\n </Card>\n </div>\n );\n }\n\n return (\n <FileManager\n adapter={adapter}\n variant={variant}\n areas={areas}\n urlKeys={CLOUD_DRIVE_URL_KEYS}\n title={heading}\n description={description}\n headerActions={headerActions}\n canWrite={spaceItem?.canWrite ?? false}\n urlStateAdapter={listUrl}\n drawerUrlAdapter={drawerUrl}\n loadPdfJs={loadPdfJs}\n defaultView={defaultView}\n renderAreaPicker={props => <CloudDriveSpacePicker {...props} spaces={spaceItems} />}\n renderAreaMaintenance={isPartner ? undefined : renderAreaMaintenance}\n renderAreaSettings={isPartner ? undefined : renderAreaSettings}\n formatEventType={eventLabel}\n readOnlyNotice={t('You may read this space, but not change it.')}\n />\n );\n};\n","'use client';\n\nimport { Check, ChevronsUpDown, HardDrive } from 'lucide-react';\nimport { useMemo, useState } from 'react';\n\nimport { type FileAreaKey, type FileAreaRefView, formatBytes } from '@mgamadeus/ddd-admin-ui/files';\nimport { useTranslate } from '@mgamadeus/ddd-admin-ui/i18n';\nimport { Button } from '@mgamadeus/ddd-admin-ui/primitives';\nimport { cn } from '@mgamadeus/ddd-admin-ui/primitives';\nimport { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@mgamadeus/ddd-admin-ui/primitives';\nimport { Popover, PopoverContent, PopoverTrigger } from '@mgamadeus/ddd-admin-ui/primitives';\nimport { groupDriveSpaces } from './driveFileMapping.ts';\nimport type { DriveSpaceListItem } from '../types.ts';\n\nexport interface CloudDriveSpacePickerProps {\n /** The spaces (`driveAreaRefOf` of the space list): name and group. */\n areas: readonly FileAreaRefView[];\n areaKey: FileAreaKey;\n onSelectArea: (areaKey: FileAreaKey) => void;\n /** The space list items: each entry then shows its file count and used size on a second line. */\n spaces?: readonly DriveSpaceListItem[];\n className?: string;\n}\n\n/** The space picker of the drive screen: one button, a searchable list grouped by the space's group. */\nexport const CloudDriveSpacePicker = ({ areas, areaKey, onSelectArea, spaces, className }: CloudDriveSpacePickerProps) => {\n const { t } = useTranslate();\n const [open, setOpen] = useState(false);\n const groups = useMemo(() => groupDriveSpaces(areas), [areas]);\n const current = areas.find(area => String(area.key) === String(areaKey));\n const detailOf = (key: FileAreaKey): string | null => {\n const space = spaces?.find(item => String(item.id) === String(key));\n if (!space) return null;\n return `${t('{count, plural, one {# file} other {# files}}', { count: space.quota.fileCount })} · ${formatBytes(space.quota.usedBytes)}`;\n };\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button variant=\"outline\" role=\"combobox\" aria-expanded={open} className={cn('w-full max-w-sm justify-between gap-2', className)}>\n <span className=\"flex min-w-0 items-center gap-2\">\n <HardDrive className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"truncate\">{current?.name ?? t('Choose a space')}</span>\n {current?.groupLabel && <span className=\"truncate text-xs text-muted-foreground\">· {current.groupLabel}</span>}\n </span>\n <ChevronsUpDown className=\"size-4 shrink-0 opacity-50\" aria-hidden />\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-(--radix-popover-trigger-width) min-w-72 p-0\" align=\"start\">\n <Command>\n <CommandInput placeholder={t('Search spaces…')} />\n <CommandList>\n <CommandEmpty>{t('No space matches.')}</CommandEmpty>\n {groups.map(group => (\n <CommandGroup key={group.label || '__ungrouped__'} heading={group.label || undefined}>\n {group.areas.map(area => (\n <CommandItem\n key={String(area.key)}\n value={`${area.name} ${area.groupLabel ?? ''} ${String(area.key)}`}\n onSelect={() => {\n onSelectArea(area.key);\n setOpen(false);\n }}\n >\n <Check className={cn('size-4 shrink-0', String(area.key) === String(areaKey) ? 'opacity-100' : 'opacity-0')} aria-hidden />\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"truncate\">{area.name}</span>\n {detailOf(area.key) && <span className=\"truncate text-xs text-muted-foreground tabular-nums\">{detailOf(area.key)}</span>}\n </span>\n </CommandItem>\n ))}\n </CommandGroup>\n ))}\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n );\n};\n","// The drive's list payloads (mgamadeus/ddd-clouddrive ≥ 0.1.0-rc.10) as the view models of `./files`. Pure: no React,\n// no request; the adapter hook (`useCloudDriveFileAdapter`) and the tests use them.\nimport { m, translateText } from '@mgamadeus/ddd-admin-ui/i18n';\nimport type { FileListOrder, FileListQuery, FileLocationMiss, FileLocationResolution } from '@mgamadeus/ddd-admin-ui/files';\nimport {\n type FileAreaRefView,\n type FileAreaUsagePart,\n type FileAreaView,\n type FileEventView,\n type FileFamily,\n type FileScanStatus,\n type FileVersionSystemNote,\n type FileVersionView,\n type FileView,\n type FolderView,\n fileFamilyOfContentType,\n fileFamilyOfExtension,\n} from '@mgamadeus/ddd-admin-ui/files';\nimport type {\n DriveChangeEventListItem,\n DriveChildrenArg,\n DriveFileFamily,\n DriveFileVersionListItem,\n DriveLocationNotFoundBody,\n DriveLocationResolveResponse,\n DriveNodeBulkResult,\n DriveNodeListItem,\n DriveScanStatus,\n DriveSpaceListItem,\n} from '../types.ts';\n\n/** The page size of a growing list; each \"more\" asks for one page more, up to `DRIVE_LIST_MAX_LIMIT`. */\nexport const DRIVE_LIST_PAGE_SIZE = 100;\n\n/** The largest `limit` the drive answers in one call. */\nexport const DRIVE_LIST_MAX_LIMIT = 1000;\n\n/** The most calls one \"empty trash\" makes (each removes one batch of the server). */\nexport const DRIVE_EMPTY_TRASH_MAX_CALLS = 200;\n\nconst DRIVE_FAMILIES: readonly DriveFileFamily[] = ['PDF', 'SPREADSHEET', 'DOCUMENT', 'PRESENTATION', 'TEXT', 'IMAGE', 'VECTOR', 'VIDEO', 'ARCHIVE'];\n\n/** The labels of the drive's own event types the file manager does not know. */\nexport const DRIVE_EVENT_LABELS: Readonly<Record<string, string>> = {\n READ_BY_AGENT: m('Read by the agent'),\n VIEWED: m('Viewed', { context: 'file-event' }),\n DOWNLOADED: m('Downloaded', { context: 'file-event' }),\n};\n\n/** The scan state the file manager shows: `PURGING` (the content is being removed) reads as not available. */\nexport const driveScanStatusOf = (scanStatus: DriveScanStatus | null | undefined): FileScanStatus => {\n switch (scanStatus) {\n case 'CLEAN':\n case 'PENDING':\n case 'UPLOADING':\n case 'INFECTED':\n case 'BLOCKED':\n case 'FAILED':\n return scanStatus;\n case 'PURGING':\n return 'FAILED';\n default:\n return 'PENDING';\n }\n};\n\n/** The family of a drive item: the server's family, else from the extension, else from the content type. */\nexport const driveFamilyOf = (item: Pick<DriveNodeListItem, 'family' | 'extension' | 'contentType' | 'name'>): FileFamily => {\n if (item.family && (DRIVE_FAMILIES as readonly string[]).includes(item.family)) return item.family;\n const extension = (item.extension ?? '') || extensionOfName(item.name);\n const byExtension = fileFamilyOfExtension(extension);\n if (byExtension !== 'OTHER') return byExtension;\n return fileFamilyOfContentType(item.contentType) ?? 'OTHER';\n};\n\nconst extensionOfName = (name: string): string => {\n const dot = name.lastIndexOf('.');\n return dot > 0 && dot < name.length - 1 ? name.slice(dot + 1).toLowerCase() : '';\n};\n\n/** The folder a node sits in as the file manager names it: the space's root is `null`. */\nexport const driveFolderIdOf = (parentNodeId: number | null | undefined, rootNodeId: number | null | undefined): number | null =>\n parentNodeId === null || parentNodeId === undefined || parentNodeId === rootNodeId ? null : parentNodeId;\n\n/** A file of the drive as a `FileView` (trash facts included when present; a trashed folder is marked `isFolder`). */\nexport const driveFileViewOf = (item: DriveNodeListItem, rootNodeId: number | null | undefined): FileView => ({\n id: item.id,\n areaKey: item.driveSpaceId,\n folderId: driveFolderIdOf(item.parentNodeId, rootNodeId),\n name: item.name,\n extension: (item.extension ?? '') || extensionOfName(item.name),\n family: driveFamilyOf(item),\n mimeType: item.contentType ?? null,\n sizeBytes: item.sizeBytes ?? 0,\n contentVersion: item.versionNumber ?? null,\n description: item.description ?? null,\n scanStatus: item.scanStatus ? driveScanStatusOf(item.scanStatus) : 'UPLOADING',\n hasPendingVersion: item.hasPendingVersion === true,\n newestVersionStatus: item.latestVersionScanStatus ? driveScanStatusOf(item.latestVersionScanStatus) : null,\n newestVersionNumber: item.latestVersionNumber ?? null,\n newestVersionReason: item.latestVersionStateReason ?? null,\n hasWorkingCopyChanges: item.hasWorkingCopyChanges === true,\n thumbnailUrl: item.thumbnailUrl ?? null,\n uploadedBy: item.createdByName ?? null,\n uploadedOnBehalfOf: item.createdOnBehalfOfName ?? null,\n createdAt: item.createdAt ?? null,\n updatedAt: item.updatedAt ?? null,\n deletedAt: item.trashedAt ?? null,\n deletedBy: item.trashedByName ?? null,\n purgeAfter: item.purgeAfter ?? null,\n ...(item.nodeType === 'FOLDER' ? { isFolder: true } : {}),\n});\n\n/** The folders of a space as the tree reads them: the root itself is left out, its children hang at `null`. */\nexport const driveFolderViewsOf = (items: readonly DriveNodeListItem[], rootNodeId: number | null | undefined): FolderView[] =>\n items\n .filter(item => item.nodeType === 'FOLDER' && item.parentNodeId !== null && item.parentNodeId !== undefined && item.id !== rootNodeId)\n .map(item => ({\n id: item.id,\n areaKey: item.driveSpaceId,\n parentId: driveFolderIdOf(item.parentNodeId, rootNodeId),\n name: item.name,\n entryCount: item.childCount ?? null,\n createdBy: item.createdByName ?? null,\n createdOnBehalfOf: item.createdOnBehalfOfName ?? null,\n createdAt: item.createdAt ?? null,\n updatedAt: item.updatedAt ?? null,\n }));\n\n/** The drive's note codes as the file manager names them (a move between spaces is a move from another area). */\nconst DRIVE_VERSION_NOTE_CODES: Readonly<Record<string, string>> = {\n RESTORED_FROM_VERSION: 'RESTORED_FROM_VERSION',\n TRANSFERRED_FROM_SPACE: 'MOVED_FROM_AREA',\n COPIED_FROM_PATH: 'COPIED_FROM_PATH',\n};\n\n/** A version's system note; null for free text or a code this package does not know (then `comment` is drawn). */\nexport const driveVersionNoteOf = (item: DriveFileVersionListItem): FileVersionSystemNote | null => {\n const code = item.commentCode ? DRIVE_VERSION_NOTE_CODES[item.commentCode] : undefined;\n if (!code) return null;\n return {\n code,\n versionNumber: item.commentParameters?.versionNumber ?? null,\n sourceAreaName: item.commentParameters?.sourceSpaceDisplayName ?? null,\n sourcePath: item.commentParameters?.sourcePath ?? null,\n };\n};\n\n/** A version of a file as the drawer lists it. */\nexport const driveVersionViewOf = (item: DriveFileVersionListItem): FileVersionView => ({\n id: item.id,\n versionNumber: item.versionNumber,\n sizeBytes: item.sizeBytes ?? 0,\n scanStatus: driveScanStatusOf(item.scanStatus),\n scanResultDetail: item.scanDetail ?? null,\n isCurrent: item.isCurrent,\n uploadedBy: item.authorName ?? null,\n uploadedOnBehalfOf: item.onBehalfOfName ?? null,\n createdAt: item.createdAt ?? null,\n comment: item.comment ?? null,\n systemNote: driveVersionNoteOf(item),\n});\n\n/** A change of a node as the drawer's activity lists it; a move or rename shows `old path → new path`. */\nexport const driveEventViewOf = (item: DriveChangeEventListItem): FileEventView => ({\n id: item.eventSource ? `${item.eventSource}-${item.id}` : item.id,\n type: item.eventType,\n occurredAt: item.occurredAt ?? null,\n actor: item.actorName ?? null,\n impersonatedBy: item.onBehalfOfName ?? null,\n detail: item.previousPath && item.path && item.previousPath !== item.path ? `${item.previousPath} → ${item.path}` : (item.detail ?? null),\n audience: item.audience ?? null,\n variant: item.contentVariant ?? null,\n clientIp: item.clientIp ?? null,\n});\n\n/**\n * Where a resolve answer leads, for the file manager: the space, the folder to open (a file's folder; `null` = the\n * root), the file whose details open, and the path with a leading slash.\n */\nexport const driveLocationResolutionOf = (response: DriveLocationResolveResponse): FileLocationResolution => {\n const item = response.item ?? null;\n const rootNodeId = response.ancestors?.elements?.[0]?.id ?? (item && (item.parentNodeId === null || item.parentNodeId === undefined) ? item.id : null);\n const isFile = item !== null && item.nodeType === 'FILE';\n const folderId = item === null ? null : isFile ? driveFolderIdOf(item.parentNodeId, rootNodeId) : item.id === rootNodeId ? null : item.id;\n return {\n found: true,\n areaKey: response.driveSpaceId,\n folderId,\n fileId: isFile && item ? item.id : null,\n path: `/${response.path.replace(/^\\/+/, '')}`,\n };\n};\n\n/** The miss of a resolve request (its 404 body), for the path bar's message. */\nexport const driveLocationMissOf = (error: unknown): FileLocationMiss | null => {\n const failure = error as { status?: unknown; data?: DriveLocationNotFoundBody } | null;\n if (!failure || failure.status !== 404) return null;\n const body = failure.data ?? {};\n const deepest = body.deepestFolder ?? null;\n return {\n found: false,\n deepestFolderPath: deepest ? (deepest.parentNodeId === null || deepest.parentNodeId === undefined ? '/' : deepest.name) : null,\n missingSegment: body.missingSegment ?? null,\n message: body.error ?? null,\n };\n};\n\n/** The labels of the usage split of a space (the quota pill's tooltip). */\nexport const DRIVE_USAGE_PART_LABELS = {\n currentVersionBytes: m('Current versions'),\n olderVersionBytes: m('Older versions'),\n trashedBytes: m('Trash', { context: 'drive-usage' }),\n pendingBytes: m('Uploads being checked'),\n} as const;\n\n/** The usage split of a space when the server sends it (ddd-clouddrive ≥ rc.12), translated; `null` otherwise. */\nexport const driveUsagePartsOf = (quota: DriveSpaceListItem['quota']): FileAreaUsagePart[] | null => {\n const parts: FileAreaUsagePart[] = [];\n for (const key of Object.keys(DRIVE_USAGE_PART_LABELS) as (keyof typeof DRIVE_USAGE_PART_LABELS)[]) {\n const bytes = quota[key];\n if (typeof bytes === 'number') parts.push({ label: translateText(DRIVE_USAGE_PART_LABELS[key], key === 'trashedBytes' ? { context: 'drive-usage' } : {}), bytes });\n }\n return parts.length > 0 ? parts : null;\n};\n\n/** The quota that applies (`effectiveQuotaBytes`, else `quotaBytes`); `null` = no limit. */\nexport const effectiveQuotaOf = (quota: DriveSpaceListItem['quota']): number | null => {\n const quotaBytes = quota.effectiveQuotaBytes ?? quota.quotaBytes;\n return typeof quotaBytes === 'number' && quotaBytes > 0 ? quotaBytes : null;\n};\n\n/** A space as the file manager's area facts. */\nexport const driveAreaViewOf = (item: DriveSpaceListItem): FileAreaView => ({\n areaKey: item.id,\n isEnabled: true,\n quotaBytes: effectiveQuotaOf(item.quota),\n usedBytes: item.quota.usedBytes,\n maxFileSizeBytes: item.quota.maxFileSizeBytes > 0 ? item.quota.maxFileSizeBytes : null,\n trashRetentionDays: item.quota.trashRetentionDays > 0 ? item.quota.trashRetentionDays : null,\n fileCount: item.quota.fileCount,\n folderCount: item.quota.folderCount,\n usageParts: driveUsagePartsOf(item.quota),\n});\n\n/** A space as an entry of the area picker and the manager's `areas`. */\nexport const driveAreaRefOf = (item: DriveSpaceListItem): FileAreaRefView => ({\n key: item.id,\n name: item.displayName || item.title || `#${item.id}`,\n // `groupLabel` is the translated heading; `displayGroup` is an ordering code (`LIBRARY`), shown only without a label.\n groupLabel: item.groupLabel ?? item.displayGroup ?? null,\n});\n\nconst DRIVE_ORDERS: readonly FileListOrder[] = ['name', 'created', 'size'];\n\n/**\n * The `children` request of a file manager query. A folder (or `'root'`) lists that folder; no folder, a name search\n * or a filter lists the whole space (`recursive`).\n */\nexport const driveChildrenArgOf = (query: FileListQuery, rootNodeId: number | null | undefined, limit: number): DriveChildrenArg => {\n const q = query.q?.trim() ?? '';\n const isFolderView = query.folderId !== undefined && q === '';\n const folderNodeId = !isFolderView ? null : query.folderId === 'root' ? (rootNodeId ?? null) : Number(query.folderId);\n return {\n driveSpaceId: Number(query.areaKey),\n folderNodeId: folderNodeId ?? undefined,\n recursive: isFolderView ? undefined : true,\n query: q === '' ? undefined : q,\n family: query.family && (DRIVE_FAMILIES as readonly string[]).includes(query.family) ? (query.family as DriveFileFamily) : undefined,\n createdFrom: query.createdFrom || undefined,\n createdTo: query.createdTo || undefined,\n createdByMe: query.uploadedByMe ? true : undefined,\n orderBy: query.orderBy && DRIVE_ORDERS.includes(query.orderBy) ? query.orderBy : undefined,\n orderDirection: query.orderDirection,\n limit,\n includeSystem: false,\n };\n};\n\n/** The files of a list answer (folders, links and system nodes are left out). */\nexport const driveFileItemsOf = (items: readonly DriveNodeListItem[] | undefined): DriveNodeListItem[] =>\n (items ?? []).filter(item => item.nodeType === 'FILE' && item.isSystem !== true);\n\n/** The next `limit` of a growing list, or `null` when the drive answers no more in one call. */\nexport const nextDriveListLimit = (limit: number): number | null => (limit >= DRIVE_LIST_MAX_LIMIT ? null : Math.min(DRIVE_LIST_MAX_LIMIT, limit + DRIVE_LIST_PAGE_SIZE));\n\n/** What an \"empty trash\" removed over all its calls. */\nexport interface DriveEmptyTrashOutcome {\n calls: number;\n processedCount: number;\n fileCount: number;\n folderCount: number;\n /** The call limit was reached with more left (rare; the user empties again). */\n hasMore: boolean;\n}\n\n/** Empties a trash batch by batch: calls `emptyOnce` while the server answers `hasMore`, at most `maxCalls` times. */\nexport const emptyDriveTrashFully = async (\n emptyOnce: () => Promise<DriveNodeBulkResult>,\n maxCalls: number = DRIVE_EMPTY_TRASH_MAX_CALLS\n): Promise<DriveEmptyTrashOutcome> => {\n const outcome: DriveEmptyTrashOutcome = { calls: 0, processedCount: 0, fileCount: 0, folderCount: 0, hasMore: false };\n for (;;) {\n const result = await emptyOnce();\n outcome.calls += 1;\n outcome.processedCount += result.processedCount;\n outcome.fileCount += result.fileCount;\n outcome.folderCount += result.folderCount;\n outcome.hasMore = result.hasMore;\n if (!result.hasMore || result.processedCount === 0 || outcome.calls >= maxCalls) return outcome;\n }\n};\n\n/** One group of the space picker. */\nexport interface DriveSpaceGroup {\n /** `''` = spaces without a group. */\n label: string;\n areas: FileAreaRefView[];\n}\n\n/** Groups the spaces by `groupLabel` in the server's order (it sorts by group, then name): nothing is re-sorted. */\nexport const groupDriveSpaces = (areas: readonly FileAreaRefView[]): DriveSpaceGroup[] => {\n const groups = new Map<string, FileAreaRefView[]>();\n for (const area of areas) {\n const label = area.groupLabel ?? '';\n const group = groups.get(label);\n if (group) group.push(area);\n else groups.set(label, [area]);\n }\n return [...groups.entries()].map(([label, groupAreas]) => ({ label, areas: groupAreas }));\n};\n","'use client';\n\n// The file manager of `./files` on the drive's endpoints (`createCloudDriveApi`, mgamadeus/ddd-clouddrive ≥ 0.1.0-rc.10).\nimport { useMemo, useState } from 'react';\n\nimport { translateText } from '@mgamadeus/ddd-admin-ui/i18n';\n\nimport type {\n FileListQuery,\n FileLocationMiss,\n FileLocationResolution,\n FileListState,\n FileManagerActions,\n FileManagerAdapter,\n FileManagerCapabilities,\n FileQueryOptions,\n FileQueryState,\n FileTrashQuery,\n} from '@mgamadeus/ddd-admin-ui/files';\nimport type { FileAreaKey, FileAreaView, FileDetailView, FileEventView, FileItemId, FolderView } from '@mgamadeus/ddd-admin-ui/files';\nimport type { CloudDriveApi } from '../api.ts';\nimport { buildCloudDriveFileActions, type CloudDriveFileActionTriggers, type DriveNodeFact, rememberDriveNodes } from './driveFileActions.ts';\nimport {\n DRIVE_LIST_PAGE_SIZE,\n driveAreaViewOf,\n driveChildrenArgOf,\n driveEventViewOf,\n driveFileItemsOf,\n driveFileViewOf,\n driveFolderViewsOf,\n driveLocationMissOf,\n driveLocationResolutionOf,\n driveVersionViewOf,\n nextDriveListLimit,\n} from './driveFileMapping.ts';\nimport type { DriveNodeListItem, DriveSpaceListItem } from '../types.ts';\n\n/** How many changes the drawer shows. */\nexport const DRIVE_ACTIVITY_LIMIT = 20;\n\nexport interface UseCloudDriveFileAdapterOptions {\n /** `createCloudDriveApi(…)` of the host. */\n api: CloudDriveApi;\n /** The open space; writes without an area (move, trash, restore, purge) go to it. */\n spaceId: number;\n}\n\n/**\n * The capabilities of the drive besides the trash (which `createCloudDriveFileAdapter` adds with its own hook): the\n * same set for every space; the actions say what a viewer may do.\n */\nexport const CLOUD_DRIVE_FILE_CAPABILITIES: Omit<FileManagerCapabilities, 'trash'> = {\n versions: { replacementExtension: 'same' },\n activity: { limit: DRIVE_ACTIVITY_LIMIT },\n filters: { family: true, created: true, uploadedByMe: true, orders: ['name', 'created', 'size'] },\n workingCopy: {},\n malwareScan: { enabled: true },\n};\n\nconst EMPTY_LIST: FileListState = { items: [], isLoading: false, isFetchingMore: false, hasMore: false, loadMore: () => undefined, isError: false };\n\nconst toSpaceId = (areaKey: FileAreaKey | null | undefined): number => {\n const spaceId = Number(areaKey);\n return Number.isInteger(spaceId) && spaceId > 0 ? spaceId : 0;\n};\n\n/** A list that grows by one page per \"more\" (one request each time, so a write's refetch keeps every row current). */\nconst useGrowingLimit = (key: string): readonly [number, (next: number) => void] => {\n const [state, setState] = useState({ key, limit: DRIVE_LIST_PAGE_SIZE });\n const limit = state.key === key ? state.limit : DRIVE_LIST_PAGE_SIZE;\n return [limit, (next: number) => setState({ key, limit: next })] as const;\n};\n\n/**\n * A `FileManagerAdapter` on the drive: area = space, folder and file ids = node ids. Every space offers trash,\n * versions, activity, filters (family, created, mine, three orders), the working-copy mark and the malware status;\n * purge and empty trash appear only for a viewer with the space's manage right. Create it with\n * `useCloudDriveFileAdapter`; its identity changes only with `api` and `spaceId`.\n */\nexport const createCloudDriveFileAdapter = (api: CloudDriveApi, spaceId: number): FileManagerAdapter => {\n const nodeFacts = new Map<number, DriveNodeFact>();\n // The resolve trigger of the last render (`useActions` runs on every render of the manager): the location capability\n // is a plain function, the request a mutation hook.\n let resolveTrigger: ReturnType<CloudDriveApi['useResolveDriveLocationMutation']>[0] | null = null;\n const rememberNodes = (items: readonly DriveNodeListItem[]) => rememberDriveNodes(nodeFacts, items);\n\n const useSpaceItem = (areaKey: FileAreaKey | null | undefined): { item: DriveSpaceListItem | undefined; isLoading: boolean; isError: boolean } => {\n const driveSpaceId = toSpaceId(areaKey);\n const spaceQuery = api.useDriveSpaceQuery({ driveSpaceId }, { skip: driveSpaceId === 0 });\n // while another space loads, the hook still holds the previous space: never hand out its root or quota\n const loadedItem = spaceQuery.data?.item ?? undefined;\n const item = loadedItem !== undefined && loadedItem.id === driveSpaceId ? loadedItem : undefined;\n return { item, isLoading: spaceQuery.isLoading || (driveSpaceId !== 0 && item === undefined && !spaceQuery.isError), isError: spaceQuery.isError };\n };\n\n const useArea = (areaKey: FileAreaKey): FileQueryState<FileAreaView> => {\n const space = useSpaceItem(areaKey);\n return { data: space.item ? driveAreaViewOf(space.item) : undefined, isLoading: space.isLoading, isError: space.isError };\n };\n\n const useFolders = (areaKey: FileAreaKey): FileQueryState<readonly FolderView[]> => {\n const space = useSpaceItem(areaKey);\n const driveSpaceId = toSpaceId(areaKey);\n const foldersQuery = api.useDriveFoldersQuery({ driveSpaceId, includeSystem: false }, { skip: driveSpaceId === 0 });\n // the previous space's tree while this one loads is no tree of this space (its folder ids would be asked here)\n const isStale = foldersQuery.isFetching && foldersQuery.currentData === undefined;\n const foldersData = isStale ? undefined : foldersQuery.data;\n const data = useMemo(\n () => (foldersData && space.item ? driveFolderViewsOf(foldersData.items.elements ?? [], space.item.rootNodeId) : undefined),\n [foldersData, space.item]\n );\n return { data, isLoading: foldersQuery.isLoading || space.isLoading, isFetching: foldersQuery.isFetching, isError: foldersQuery.isError };\n };\n\n const useFiles = (query: FileListQuery | null): FileListState => {\n const space = useSpaceItem(query?.areaKey);\n const [limit, setLimit] = useGrowingLimit(JSON.stringify(query));\n const rootNodeId = space.item?.rootNodeId;\n const skip = query === null || space.item === undefined;\n const childrenQuery = api.useDriveChildrenQuery(\n query && !skip ? driveChildrenArgOf(query, rootNodeId, limit) : { driveSpaceId: 0 },\n { skip }\n );\n const items = useMemo(() => {\n const fileItems = driveFileItemsOf(childrenQuery.data?.items?.elements);\n rememberNodes(fileItems);\n return fileItems.map(item => driveFileViewOf(item, rootNodeId));\n }, [childrenQuery.data, rootNodeId]);\n const nextLimit = nextDriveListLimit(limit);\n const hasMore = Boolean(childrenQuery.data?.nextCursor) && nextLimit !== null;\n if (skip) return EMPTY_LIST;\n return {\n items,\n isLoading: childrenQuery.isLoading || space.isLoading,\n isRefetching: childrenQuery.isFetching && childrenQuery.data !== undefined && childrenQuery.currentData !== undefined,\n isFetchingMore: childrenQuery.isFetching && childrenQuery.data !== undefined && childrenQuery.currentData === undefined,\n hasMore,\n loadMore: () => {\n if (nextLimit !== null) setLimit(nextLimit);\n },\n isError: childrenQuery.isError,\n refetch: () => void childrenQuery.refetch(),\n };\n };\n\n const useTrash = (query: FileTrashQuery | null): FileListState => {\n const space = useSpaceItem(query?.areaKey);\n const [limit, setLimit] = useGrowingLimit(JSON.stringify(query));\n const driveSpaceId = toSpaceId(query?.areaKey);\n const skip = query === null || driveSpaceId === 0;\n const trashQuery = api.useDriveTrashQuery({ driveSpaceId, limit }, { skip });\n const rootNodeId = space.item?.rootNodeId;\n const items = useMemo(\n () => (trashQuery.data?.items?.elements ?? []).filter(item => item.nodeType === 'FILE' || item.nodeType === 'FOLDER').map(item => driveFileViewOf(item, rootNodeId)),\n [trashQuery.data, rootNodeId]\n );\n const nextLimit = nextDriveListLimit(limit);\n if (skip) return EMPTY_LIST;\n return {\n items,\n isLoading: trashQuery.isLoading,\n isRefetching: trashQuery.isFetching && trashQuery.currentData !== undefined,\n isFetchingMore: trashQuery.isFetching && trashQuery.data !== undefined && trashQuery.currentData === undefined,\n hasMore: Boolean(trashQuery.data?.nextCursor) && nextLimit !== null,\n loadMore: () => {\n if (nextLimit !== null) setLimit(nextLimit);\n },\n isError: trashQuery.isError,\n };\n };\n\n const useFile = (fileId: FileItemId | null, options?: FileQueryOptions): FileQueryState<FileDetailView> => {\n const driveNodeId = fileId === null ? 0 : Number(fileId);\n const skip = !Number.isInteger(driveNodeId) || driveNodeId <= 0;\n const pollingInterval = skip ? 0 : Math.max(0, options?.pollingIntervalMs ?? 0);\n const nodeQuery = api.useDriveNodeQuery({ driveNodeId }, { skip, pollingInterval });\n const versionsQuery = api.useDriveVersionsQuery({ driveNodeId }, { skip, pollingInterval });\n const eventsQuery = api.useDriveEventsQuery({ driveNodeId, limit: DRIVE_ACTIVITY_LIMIT, eventGroup: 'changes' }, { skip });\n const item = nodeQuery.data?.item ?? undefined;\n const space = useSpaceItem(item?.driveSpaceId);\n const data = useMemo((): FileDetailView | undefined => {\n if (!item || item.nodeType !== 'FILE') return undefined;\n rememberNodes([item]);\n return {\n ...driveFileViewOf(item, space.item?.rootNodeId),\n sha256: nodeQuery.data?.driveNode.sha256 ?? null,\n versions: versionsQuery.data?.items?.elements?.map(driveVersionViewOf),\n events: eventsQuery.data?.items?.elements?.map(driveEventViewOf),\n };\n }, [item, nodeQuery.data, versionsQuery.data, eventsQuery.data, space.item]);\n return {\n data,\n isLoading: nodeQuery.isLoading,\n isFetching: nodeQuery.isFetching || versionsQuery.isFetching,\n isError: nodeQuery.isError,\n refetch: () => {\n if (skip) return;\n void nodeQuery.refetch();\n void versionsQuery.refetch();\n },\n };\n };\n\n const useAccessEvents = (fileId: FileItemId | null): FileQueryState<readonly FileEventView[]> => {\n const driveNodeId = fileId === null ? 0 : Number(fileId);\n const skip = !Number.isInteger(driveNodeId) || driveNodeId <= 0;\n const accessesQuery = api.useDriveEventsQuery({ driveNodeId, limit: DRIVE_ACTIVITY_LIMIT, eventGroup: 'accesses' }, { skip });\n const data = useMemo(() => accessesQuery.data?.items?.elements?.map(driveEventViewOf), [accessesQuery.data]);\n return { data, isLoading: accessesQuery.isLoading, isFetching: accessesQuery.isFetching, isError: accessesQuery.isError };\n };\n\n const resolveLocation = async (areaKey: FileAreaKey, input: string): Promise<FileLocationResolution | FileLocationMiss> => {\n if (!resolveTrigger) throw new Error(translateText('The location could not be opened.'));\n try {\n return driveLocationResolutionOf(await resolveTrigger({ driveSpaceId: toSpaceId(areaKey) || spaceId, path: input.trim() }).unwrap());\n } catch (error) {\n const miss = driveLocationMissOf(error);\n if (miss) return miss;\n throw error;\n }\n };\n\n const useActions = (): FileManagerActions => {\n const space = useSpaceItem(spaceId);\n const [resolve] = api.useResolveDriveLocationMutation();\n resolveTrigger = resolve;\n const [reserveUpload] = api.useReserveDriveUploadMutation();\n const [completeUpload] = api.useCompleteDriveUploadMutation();\n const [requestContent] = api.useDriveContentMutation();\n const [moveNode] = api.useMoveDriveNodeMutation();\n const [updateMetadata] = api.useUpdateDriveNodeMetadataMutation();\n const [createFolder] = api.useCreateDriveFolderMutation();\n const [moveNodes] = api.useMoveDriveNodesMutation();\n const [trashNodes] = api.useTrashDriveNodesMutation();\n const [restoreNodes] = api.useRestoreDriveNodesMutation();\n const [purgeNodes] = api.usePurgeDriveNodesMutation();\n const [emptyTrash] = api.useEmptyDriveTrashMutation();\n const [restoreVersion] = api.useRestoreDriveVersionMutation();\n const rootNodeId = space.item?.rootNodeId ?? null;\n const canManage = space.item?.canManage === true;\n\n const triggers: CloudDriveFileActionTriggers = {\n reserveUpload, completeUpload, requestContent, moveNode, updateMetadata, createFolder, moveNodes, trashNodes, restoreNodes,\n purgeNodes, emptyTrash, restoreVersion,\n };\n return useMemo(\n () => buildCloudDriveFileActions(triggers, { spaceId, rootNodeId, canManage, nodeFacts }),\n [canManage, rootNodeId, reserveUpload, completeUpload, requestContent, moveNode, updateMetadata, createFolder, moveNodes, trashNodes, restoreNodes, purgeNodes, emptyTrash, restoreVersion]\n );\n };\n\n return {\n useArea,\n useFolders,\n useFiles,\n useFile,\n useActions,\n capabilities: {\n ...CLOUD_DRIVE_FILE_CAPABILITIES,\n trash: { useTrash },\n activity: { limit: DRIVE_ACTIVITY_LIMIT, useAccessEvents },\n location: { resolveLocation },\n ...(api.audience === 'shared' ? { audience: 'partner' as const } : {}),\n },\n };\n};\n\n/** The drive's file manager adapter for one space; stable while `api` and `spaceId` stay the same. */\nexport const useCloudDriveFileAdapter = ({ api, spaceId }: UseCloudDriveFileAdapterOptions): FileManagerAdapter =>\n useMemo(() => createCloudDriveFileAdapter(api, spaceId), [api, spaceId]);\n","// The writes of the drive's file manager adapter, built from the mutation triggers of `createCloudDriveApi`. Pure: no\n// React; `useCloudDriveFileAdapter` binds the triggers, the tests pass fakes.\nimport { translateText } from '@mgamadeus/ddd-admin-ui/i18n';\nimport type { FileDownloadOptions, FileManagerActions } from '@mgamadeus/ddd-admin-ui/files';\nimport type { FileAreaKey, FileItemId, FileView } from '@mgamadeus/ddd-admin-ui/files';\nimport type { UploadProgressCallbacks } from '@mgamadeus/ddd-admin-ui/files';\nimport type { CloudDriveApi } from '../api.ts';\nimport { driveFileViewOf, driveFolderIdOf, emptyDriveTrashFully } from './driveFileMapping.ts';\nimport type { DriveContentPurpose, DriveNodeListItem, DriveNodeResponse } from '../types.ts';\nimport { sendDriveUpload } from './upload.ts';\n\ntype TriggerOf<THook> = THook extends () => readonly [infer TTrigger, unknown] ? TTrigger : never;\n\n/** The mutation triggers the writes call (the first element of each mutation hook). */\nexport interface CloudDriveFileActionTriggers {\n reserveUpload: TriggerOf<CloudDriveApi['useReserveDriveUploadMutation']>;\n completeUpload: TriggerOf<CloudDriveApi['useCompleteDriveUploadMutation']>;\n requestContent: TriggerOf<CloudDriveApi['useDriveContentMutation']>;\n moveNode: TriggerOf<CloudDriveApi['useMoveDriveNodeMutation']>;\n updateMetadata: TriggerOf<CloudDriveApi['useUpdateDriveNodeMetadataMutation']>;\n createFolder: TriggerOf<CloudDriveApi['useCreateDriveFolderMutation']>;\n moveNodes: TriggerOf<CloudDriveApi['useMoveDriveNodesMutation']>;\n trashNodes: TriggerOf<CloudDriveApi['useTrashDriveNodesMutation']>;\n restoreNodes: TriggerOf<CloudDriveApi['useRestoreDriveNodesMutation']>;\n purgeNodes: TriggerOf<CloudDriveApi['usePurgeDriveNodesMutation']>;\n emptyTrash: TriggerOf<CloudDriveApi['useEmptyDriveTrashMutation']>;\n restoreVersion: TriggerOf<CloudDriveApi['useRestoreDriveVersionMutation']>;\n}\n\n/** The folder and name of a node the writes need and the views do not carry (a new version of a file). */\nexport interface DriveNodeFact {\n parentNodeId: number | null;\n name: string;\n}\n\nexport interface CloudDriveFileActionContext {\n /** The open space: writes without an area (move, trash, restore, purge) go to it. */\n spaceId: number;\n /** The space's root folder (`null` folder of the file manager). */\n rootNodeId: number | null;\n /** The viewer may purge and empty the trash (the space's manage right). */\n canManage: boolean;\n /** Facts of the nodes the lists showed, by id. */\n nodeFacts: Map<number, DriveNodeFact>;\n}\n\nconst toSpaceId = (areaKey: FileAreaKey): number => {\n const spaceId = Number(areaKey);\n return Number.isInteger(spaceId) && spaceId > 0 ? spaceId : 0;\n};\n\nconst toNodeIds = (ids: readonly FileItemId[]): number[] => ids.map(id => Number(id)).filter(id => Number.isInteger(id) && id > 0);\n\n/** Remembers the folder and name of listed nodes (for a new version of a file). */\nexport const rememberDriveNodes = (nodeFacts: Map<number, DriveNodeFact>, items: readonly DriveNodeListItem[]): void => {\n for (const item of items) nodeFacts.set(item.id, { parentNodeId: item.parentNodeId ?? null, name: item.name });\n};\n\n/**\n * The writes of the drive's file manager. Purge and empty trash exist only with `canManage` (so the manager offers\n * them only to managers); every other write is offered and the server checks the space's write right.\n */\n/**\n * The content purpose of a download request: a list picture is a `THUMBNAIL` (never recorded), a preview `INLINE`\n * (recorded as viewed; the server serves non-raster types as attachment anyway), an original `DOWNLOAD` (recorded as\n * downloaded).\n */\nexport const drivePurposeOf = (options: FileDownloadOptions): DriveContentPurpose =>\n options.variant === 'THUMBNAIL'\n ? 'THUMBNAIL'\n : options.variant === 'PREVIEW' || (options.variant === undefined && options.disposition === 'inline')\n ? 'INLINE'\n : 'DOWNLOAD';\n\nexport const buildCloudDriveFileActions = (triggers: CloudDriveFileActionTriggers, context: CloudDriveFileActionContext): FileManagerActions => {\n const { reserveUpload, completeUpload, requestContent, moveNode, updateMetadata, createFolder, moveNodes, trashNodes, restoreNodes, purgeNodes, emptyTrash, restoreVersion } = triggers;\n const { spaceId, rootNodeId, canManage, nodeFacts } = context;\n const rememberNodes = (items: readonly DriveNodeListItem[]) => rememberDriveNodes(nodeFacts, items);\n const folderNodeIdOf = (folderId: FileItemId | null): number | null => (folderId === null ? rootNodeId : Number(folderId));\n const fileViewOfResponse = (response: DriveNodeResponse): FileView => {\n if (response.isConflict) {\n throw new Error(translateText('A file with this name exists already in this folder.'));\n }\n const item = response.item;\n if (!item) throw new Error(translateText('The drive answered without the file.'));\n rememberNodes([item]);\n return driveFileViewOf(item, rootNodeId);\n };\n const uploadInto = async (\n driveSpaceId: number,\n folderNodeId: number | null,\n file: File,\n callbacks: UploadProgressCallbacks,\n options: { comment?: string | null; replaceExisting?: boolean }\n ): Promise<FileView> => {\n const { reservation } = await reserveUpload({ driveSpaceId, sizeBytes: file.size, contentType: file.type || null }).unwrap();\n await sendDriveUpload(reservation, file, (sent, total) => callbacks.onProgress?.(sent, total), callbacks.signal);\n const response = await completeUpload({\n driveBlobId: reservation.driveBlobId,\n folderNodeId,\n name: file.name,\n comment: options.comment ?? null,\n replaceExisting: options.replaceExisting ?? false,\n }).unwrap();\n return fileViewOfResponse(response);\n };\n\n const actions: FileManagerActions = {\n upload: (input, callbacks) =>\n uploadInto(toSpaceId(input.areaKey), folderNodeIdOf(input.folderId), input.file, callbacks, { comment: input.description }),\n uploadVersion: async (fileId, file, callbacks) => {\n const fact = nodeFacts.get(Number(fileId));\n if (!fact) throw new Error(translateText('Open the file again and retry.'));\n return uploadInto(spaceId, fact.parentNodeId, new File([file], fact.name, { type: file.type }), callbacks, { replaceExisting: true });\n },\n getDownload: async (fileId, options) => {\n const { grant } = await requestContent({\n driveNodeId: Number(fileId),\n purpose: drivePurposeOf(options),\n versionId: options.versionId === undefined ? null : Number(options.versionId),\n }).unwrap();\n return { url: grant.url, fileName: grant.fileName, expiresAt: grant.expiresAt ?? null };\n },\n patchFile: async (fileId, patch) => {\n const driveNodeId = Number(fileId);\n if (patch.name !== undefined || patch.folderId !== undefined) {\n await moveNode({\n driveNodeId,\n targetFolderNodeId: patch.folderId === undefined ? null : folderNodeIdOf(patch.folderId),\n name: patch.name ?? null,\n }).unwrap();\n }\n if (patch.description !== undefined) {\n await updateMetadata({ driveNodeId, description: patch.description }).unwrap();\n }\n },\n moveFiles: async (fileIds, folderId) =>\n (await moveNodes({ driveSpaceId: spaceId, driveNodeIds: toNodeIds(fileIds), targetFolderNodeId: folderNodeIdOf(folderId) }).unwrap()).result,\n trashFiles: async fileIds => (await trashNodes({ driveSpaceId: spaceId, driveNodeIds: toNodeIds(fileIds) }).unwrap()).result,\n restoreFiles: async fileIds => (await restoreNodes({ driveSpaceId: spaceId, driveNodeIds: toNodeIds(fileIds) }).unwrap()).result,\n createFolder: async input => {\n const response = await createFolder({\n driveSpaceId: toSpaceId(input.areaKey),\n parentNodeId: input.parentFolderId === null ? null : Number(input.parentFolderId),\n name: input.name,\n }).unwrap();\n const node = response.item ?? null;\n return {\n id: node?.id ?? response.driveNode.id,\n areaKey: toSpaceId(input.areaKey),\n parentId: driveFolderIdOf(node?.parentNodeId ?? response.driveNode.parentNodeId, rootNodeId),\n name: node?.name ?? response.driveNode.name,\n fileCount: 0,\n };\n },\n patchFolder: async (folderId, patch) => {\n await moveNode({\n driveNodeId: Number(folderId),\n targetFolderNodeId: patch.parentFolderId === undefined ? null : folderNodeIdOf(patch.parentFolderId),\n name: patch.name ?? null,\n }).unwrap();\n },\n deleteFolder: async folderId => {\n const { result } = await trashNodes({ driveSpaceId: spaceId, driveNodeIds: toNodeIds([folderId]) }).unwrap();\n return { trashedFiles: result.fileCount, deletedFolders: result.folderCount };\n },\n restoreVersion: async (fileId, versionId) =>\n restoreVersion({ driveNodeId: Number(fileId), driveFileVersionId: Number(versionId) }).unwrap(),\n };\n if (canManage) {\n actions.purgeFiles = async fileIds => (await purgeNodes({ driveSpaceId: spaceId, driveNodeIds: toNodeIds(fileIds) }).unwrap()).result;\n actions.emptyTrash = async areaKey =>\n emptyDriveTrashFully(async () => (await emptyTrash({ driveSpaceId: toSpaceId(areaKey) }).unwrap()).result);\n }\n return actions;\n};\n","// Sends the bytes of a reserved upload straight to the object store (presigned PUTs; PHP never proxies bytes).\nimport type { DrivePresignedRequest, DriveUploadReservation } from '../types.ts';\n\n/** The progress of one upload in bytes. */\nexport type DriveUploadProgress = (sentBytes: number, totalBytes: number) => void;\n\nconst sendRequest = async (request: DrivePresignedRequest, body: Blob, signal?: AbortSignal): Promise<void> => {\n const response = await fetch(request.url, { method: request.method, headers: request.headers ?? {}, body, signal });\n if (!response.ok) {\n throw new Error(`Upload refused by the store (${response.status})`);\n }\n};\n\n/**\n * Sends a file along a reservation: one PUT, or every part of a multipart upload one after the other. Every header of\n * a request goes out unchanged (they are signed into the URL). Content the space knows needs nothing. `signal` aborts\n * the running request (the fetch rejects with an `AbortError`).\n */\nexport const sendDriveUpload = async (\n reservation: DriveUploadReservation,\n file: Blob,\n onProgress?: DriveUploadProgress,\n signal?: AbortSignal\n): Promise<void> => {\n if (reservation.isContentKnown) {\n onProgress?.(file.size, file.size);\n return;\n }\n if (!reservation.isMultipart) {\n if (!reservation.uploadRequest) throw new Error('The reservation has no upload request');\n await sendRequest(reservation.uploadRequest, file, signal);\n onProgress?.(file.size, file.size);\n return;\n }\n const partSize = reservation.partSizeBytes ?? 0;\n let sentBytes = 0;\n for (const part of reservation.partRequests?.elements ?? []) {\n const start = (part.partNumber - 1) * partSize;\n const chunk = file.slice(start, Math.min(file.size, start + partSize));\n await sendRequest(part.request, chunk, signal);\n sentBytes += chunk.size;\n onProgress?.(sentBytes, file.size);\n }\n};\n\n/** Human-readable size: `512 B`, `1.2 KB`, `3.4 MB`, `1.25 GB`. */\nexport const formatDriveSize = (sizeBytes: number | null | undefined): string => {\n if (sizeBytes === null || sizeBytes === undefined) return '';\n if (sizeBytes < 1024) return `${sizeBytes} B`;\n if (sizeBytes < 1024 * 1024) return `${(sizeBytes / 1024).toFixed(1)} KB`;\n if (sizeBytes < 1024 * 1024 * 1024) return `${(sizeBytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(sizeBytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n};\n\n/** A backend time `Y-m-d H:i:s` without an offset is UTC; one with an offset is read as it is. */\nexport const parseDriveTime = (value: string | null | undefined): Date | null => {\n if (!value) return null;\n const isoValue = value.includes('T') ? value : value.replace(' ', 'T');\n const date = new Date(/(Z|[+-]\\d{2}:?\\d{2})$/.test(isoValue) ? isoValue : `${isoValue}Z`);\n return Number.isNaN(date.getTime()) ? null : date;\n};\n"],"mappings":";;;AAEA,SAAyB,aAAa,WAAW,WAAAA,UAAS,YAAAC,iBAAgB;AAE1E,SAAS,mBAAsF;AAE/F,SAAS,gBAAAC,qBAAoB;AAG7B,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,MAAM,mBAAmB;AAClC,SAAS,gBAAgB;;;ACVzB,SAAS,OAAO,gBAAgB,iBAAiB;AACjD,SAAS,SAAS,gBAAgB;AAElC,SAAiD,mBAAmB;AACpE,SAAS,oBAAoB;AAC7B,SA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mB,cAAc,WAAY;AACzE,WACE,gBAAAH,MAAC,SAAI,WAAU,aACb;AAAA,sBAAAD,KAAC,cAAW,OAAO,SAAS,aAA0B,SAAS,eAAe;AAAA,MAC9E,gBAAAA,KAAC,YAAS,WAAU,aAAY;AAAA,MAChC,gBAAAA,KAAC,YAAS,WAAU,eAAc;AAAA,OACpC;AAAA,EAEJ;AACA,MAAI,YAAY,QAAQ,eAAe,QAAW;AAChD,WACE,gBAAAC,MAAC,SAAI,WAAU,aACb;AAAA,sBAAAD,KAAC,cAAW,OAAO,SAAS,aAA0B,SAAS,eAAe;AAAA,MAC9E,gBAAAA,KAAC,QACC,0BAAAA,KAAC,eAAY,WAAU,mDACpB,sBAAY,UACT,EAAE,iCAAiC,IACnC,eAAe,UAAa,YAAY,OACtC,EAAE,+EAA+E,IACjF,EAAE,iCAAiC,GAC3C,GACF;AAAA,OACF;AAAA,EAEJ;AAEA,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,UAAU,WAAW,YAAY;AAAA,MACjC,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA,kBAAkB,WAAS,gBAAAA,KAAC,yBAAuB,GAAG,OAAO,QAAQ,YAAY;AAAA,MACjF,uBAAuB,YAAY,SAAY;AAAA,MAC/C,oBAAoB,YAAY,SAAY;AAAA,MAC5C,iBAAiB;AAAA,MACjB,gBAAgB,EAAE,6CAA6C;AAAA;AAAA,EACjE;AAEJ;","names":["useMemo","useState","useTranslate","useMemo","useState","translateText","translateText","translateText","toSpaceId","useState","useMemo","translateText","jsx","jsxs","useTranslate","useMemo","useState"]}
package/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@mgamadeus/ddd-clouddrive",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-rc.21",
4
+ "description": "React frontend of the cloud drive for backends built with mgamadeus/ddd (Composer package mgamadeus/ddd-clouddrive): the RTK Query client of the drive routes, the drive screen on the file manager of @mgamadeus/ddd-admin-ui (spaces, folders, upload, versions, trash, activity, URL state) and the source of the DriveFiles cards of @mgamadeus/ddd-agents.",
5
+ "keywords": [
6
+ "ddd",
7
+ "mgamadeus",
8
+ "cloud-drive",
9
+ "file-manager",
10
+ "react",
11
+ "rtk-query"
12
+ ],
13
+ "homepage": "https://github.com/ddd-framework/ddd-clouddrive/tree/main/web#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/ddd-framework/ddd-clouddrive/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/ddd-framework/ddd-clouddrive.git",
20
+ "directory": "web"
21
+ },
22
+ "license": "MIT",
23
+ "author": "Marius-Eugen Gerdan <marius@gerdan.net>",
24
+ "type": "module",
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./screen": {
32
+ "types": "./dist/screen/index.d.ts",
33
+ "import": "./dist/screen/index.js"
34
+ },
35
+ "./agents": {
36
+ "types": "./dist/agents/index.d.ts",
37
+ "import": "./dist/agents/index.js"
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "engines": {
47
+ "node": ">=20"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "peerDependencies": {
53
+ "@mgamadeus/ddd-admin-ui": ">=0.5.5 <1",
54
+ "@mgamadeus/ddd-agents": ">=0.1.38 <1",
55
+ "lucide-react": ">=0.550.0 <2",
56
+ "react": "^19.0.0",
57
+ "react-dom": "^19.0.0"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "@mgamadeus/ddd-agents": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "devDependencies": {
65
+ "@mgamadeus/ddd-admin-ui": "^0.5.5",
66
+ "@mgamadeus/ddd-agents": "^0.1.38",
67
+ "@mgamadeus/ddd-web": "^0.13.0",
68
+ "@reduxjs/toolkit": "^2.13.0",
69
+ "@types/node": "^24.0.0",
70
+ "@types/react": "^19.3.0",
71
+ "@types/react-dom": "^19.3.0",
72
+ "lucide-react": "^1.66.0",
73
+ "radix-ui": "^1.8.1",
74
+ "react": "^19.3.1",
75
+ "react-dom": "^19.3.1",
76
+ "react-redux": "^9.3.1",
77
+ "tsup": "^9.0.0",
78
+ "typescript": "^6.0.3"
79
+ },
80
+ "scripts": {
81
+ "build": "node scripts/clean.mjs && tsup && node scripts/check-package.mjs .",
82
+ "typecheck": "tsc -p .",
83
+ "test": "node --experimental-strip-types --no-warnings --test \"src/**/*.test.ts\""
84
+ }
6
85
  }