SDK: files and storage
The methods are on app.files, app.trash and app.jobs (see app and connection); this page has the types they take and return. Paths are relative to a location with / as separator; an app never sees a path on the host.
Generated from the TSDoc comments of @pithyx/sdk 1.0.0-rc.9 at build time; the text below the headings is the comment in the source.
Interfaces
Section titled “Interfaces”ShareLocation
Section titled “ShareLocation”A share from files.shares, the only location the versions and the recycle bin take: a storage request is a folder
inside a share, without snapshots or a bin of its own.
Properties
Section titled “Properties”share: string;The id of a share from files.shares.
FileEntry
Section titled “FileEntry”One entry of a folder.
Properties
Section titled “Properties”name: string;Name within its folder.
kind: FileKind;What the entry is.
size: number;Bytes for files, 0 for folders.
modified
Section titled “modified”modified: string;Last change of the content, ISO 8601 UTC.
ShareInfo
Section titled “ShareInfo”A share the user can use, with the user’s own access.
Properties
Section titled “Properties”id: string;Stable id, used as { share: id }.
name: string;Name shown to users.
access
Section titled “access”access: 'read' | 'readWrite';The user’s access: read, or readWrite to change files.
unavailable?
Section titled “unavailable?”optional unavailable?: "poolMissing" | "poolUnavailable" | "notMounted";Set while the share’s files cannot be reached: poolMissing (its disks are not connected), poolUnavailable (its
pool stopped because disks are missing) or notMounted. Calls on it fail with fs.share.unavailable until the
share is back, which sharesChanged announces.
optional kind?: "home" | "userHome";Set for a home instead of a shared folder: home is the user’s own (named home), userHome another user’s home
(named after its folder), which only the core apps of administrators see. Left out for a shared folder.
FolderPage
Section titled “FolderPage”One page of a folder.
Properties
Section titled “Properties”path: string;The folder, relative to its location (“” for the root).
folderId
Section titled “folderId”folderId: string;Stable id of the folder, also after a rename.
total: number;Entries in the folder when the page was read.
entries
Section titled “entries”entries: FileEntry[];This page, in the requested order.
nextCursor
Section titled “nextCursor”nextCursor: string | null;Pass as cursor for the next page; null on the last page. The cursor stays valid while the folder changes.
FileSelection
Section titled “FileSelection”A selection in one folder.
Properties
Section titled “Properties”location
Section titled “location”location: FileLocation;Where the folder is: a share, or a storage request of the manifest.
folder
Section titled “folder”folder: string;The folder the names are in.
items: FileItems;The entries of the folder that are meant.
FileOperation
Section titled “FileOperation”A copy, move or delete that runs as a job.
Properties
Section titled “Properties”kind: 'copy' | 'move' | 'delete';What to do. A move within one file system is a rename; across file systems it copies, then deletes.
source
Section titled “source”source: FileSelection;The entries to work on, all in one folder.
target?
Section titled “target?”optional target?: object;The folder to copy or move into. Required for copy and move, not allowed for delete.
location
Section titled “location”location: FileLocation;Where the target folder is: a share, or a storage request of the manifest.
path: string;The target folder, relative to its location.
onConflict?
Section titled “onConflict?”optional onConflict?: ConflictPolicy;For copy and move; fail when left out.
permanent?
Section titled “permanent?”optional permanent?: boolean;For delete: remove for good instead of moving to the share’s recycle bin. Set it only when the user explicitly asked for it.
JobInfo
Section titled “JobInfo”A long operation of the user, and its progress.
Properties
Section titled “Properties”id: number;Id for jobs.cancel and in jobChanged events.
kind: string;For example files.copy, files.trash, files.restore.
state: JobState;Where the job is.
progress
Section titled “progress”progress: object;Entries and bytes done and in total; totals grow while a job still counts what it works on.
itemsDone
Section titled “itemsDone”itemsDone: number;Entries finished.
itemsTotal
Section titled “itemsTotal”itemsTotal: number;Entries counted so far.
bytesDone
Section titled “bytesDone”bytesDone: number;Bytes copied or moved.
bytesTotal
Section titled “bytesTotal”bytesTotal: number;Bytes counted so far.
current
Section titled “current”current: string | null;The entry being worked on, relative to its location.
problem
Section titled “problem”problem: Problem | null;Why the job failed, with the stable code and its params.
result
Section titled “result”result: | { done: number; skipped: string[];} | null;When it finished: entries done and paths left out (conflicts with skip, symlinks, which are never copied).
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ done: number; skipped: string[];}done: number;Entries the job finished.
skipped
Section titled “skipped”skipped: string[];Paths it left out.
null
TrashEntry
Section titled “TrashEntry”An item in a share’s recycle bin.
Properties
Section titled “Properties”id: number;Id for restoring or deleting it for good.
name: string;Its name when it was deleted.
originalPath
Section titled “originalPath”originalPath: string;Where it was, relative to the share; restoring puts it back there.
kind: FileKind;What it was.
size: number;Bytes, for a folder everything inside it.
deletedAt
Section titled “deletedAt”deletedAt: string;When it was deleted, ISO 8601 UTC.
deletedBy
Section titled “deletedBy”deletedBy: string | null;User name of who deleted it, if that user still exists.
expiresAt
Section titled “expiresAt”expiresAt: string | null;When it is deleted for good, or null when the share keeps items until the bin is emptied.
TrashPage
Section titled “TrashPage”One page of a recycle bin, newest first.
Properties
Section titled “Properties”items: TrashEntry[];This page of the bin.
nextCursor
Section titled “nextCursor”nextCursor: string | null;Pass as cursor for the next page; null on the last page.
retentionDays
Section titled “retentionDays”retentionDays: number;Days the share keeps deleted items; 0 keeps them until the bin is emptied.
FileVersion
Section titled “FileVersion”An earlier version of a file or folder, from a snapshot of the share’s dataset.
Properties
Section titled “Properties”snapshot
Section titled “snapshot”snapshot: string;The snapshot it is in; pass it to files.restoreVersion.
createdAt
Section titled “createdAt”createdAt: string;When the snapshot was taken, ISO 8601 UTC.
kind: FileKind;File or folder.
size: number;Bytes for files, 0 for folders.
modified
Section titled “modified”modified: string;Last change of the content in that version, ISO 8601 UTC.
FolderChange
Section titled “FolderChange”Changes of a watched folder since the last event.
Properties
Section titled “Properties”watch: string;The id files.watch returned.
changed
Section titled “changed”changed: FileEntry[];Entries that appeared or changed, with their current metadata.
removed
Section titled “removed”removed: string[];Names that are gone.
resync
Section titled “resync”resync: boolean;Changes were lost (the kernel queue overflowed): list the folder again.
gone: boolean;The folder itself was deleted or moved away; no more events come for this watch.
UploadProgress
Section titled “UploadProgress”Progress of an upload started with an upload id.
Properties
Section titled “Properties”upload
Section titled “upload”upload: string;The id given to files.upload.
loaded
Section titled “loaded”loaded: number;Bytes sent so far.
total: number;Size of the file in bytes.
StorageRequest
Section titled “StorageRequest”A place for files the app needs, declared by name and shown to the administrator with its name, for example “Photo library”. At install an administrator maps it to a folder in a shared folder (and can change that later). The app only ever sees the name and paths inside it: the window reaches it through the SDK file API as { storage: id }, the backend services listed in services find it as the Compose volume named id. Users reach it with their own rights on the mapped folder, never with more than access.
Properties
Section titled “Properties”id: string;Unique within the app.
name: LocalizedName;description?
Section titled “description?”optional description?: LocalizedText;access
Section titled “access”access: 'read' | 'readWrite';The most the app may do with the mapped folder: read or readWrite. Users never get more than their own rights on the folder, and with read every backend service mounts it read-only.
required
Section titled “required”required: boolean;The app cannot start until this storage is mapped.
services?
Section titled “services?”optional services?: string[];Backend services that mount this storage. Needs a backend.
Min Items
Section titled “Min Items”1
FileHandler
Section titled “FileHandler”Files the app can open. The desktop offers the app in “Open with” only for these types and sends it only such files (launch, openFile). An extension belongs to one handler only.
Properties
Section titled “Properties”extensions
Section titled “extensions”extensions: string[];Lowercase extensions without the leading dot, for example png or tar.gz.
Min Items
Section titled “Min Items”1
Max Items
Section titled “Max Items”32
mimeTypes?
Section titled “mimeTypes?”optional mimeTypes?: string[];MIME types, for example image/png.
Min Items
Section titled “Min Items”1
Max Items
Section titled “Max Items”32
isDefault?
Section titled “isDefault?”optional isDefault?: boolean;Whether the app is the default for these files when it is the only handler.
FileRef
Section titled “FileRef”A file the user handed to the app (opened with it, or picked in a desktop dialog). The app never learns where the
file is: ref is an opaque handle, valid for this user and app, that only the SDK file API accepts.
Properties
Section titled “Properties”ref: string;Opaque handle; only the SDK file API accepts it.
name: string;File name with extension, for display.
optional type?: string;MIME type, when known.
size: number;Size in bytes.
modified
Section titled “modified”modified: string;Last change, ISO 8601 UTC.
writable
Section titled “writable”writable: boolean;Whether the app may write it (files.write and the user’s rights on it).
StorageInfo
Section titled “StorageInfo”A storage request of the manifest and where it stands.
Properties
Section titled “Properties”id: string;The id of the request in the manifest; reach it as { storage: id }.
state: StorageState;Whether the storage can be used now.
access
Section titled “access”access: 'read' | 'readWrite' | null;What the mapping allows (never more than the manifest requests), or null while it is unmapped.
Type Aliases
Section titled “Type Aliases”FileKind
Section titled “FileKind”type FileKind = 'file' | 'folder' | 'symlink' | 'other';What an entry is. Symlinks are listed as themselves and never followed in listings.
FileLocation
Section titled “FileLocation”type FileLocation = | { storage: string; } | ShareLocation;Where paths start: a named storage from the manifest, or a share by its id (needs files.shares). Paths inside are
relative, with / as separator, and never leave it; . and .. are refused.
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ storage: string;}storage
Section titled “storage”storage: string;The id of a storage request in the manifest.
SortKey
Section titled “SortKey”type SortKey = 'name' | 'size' | 'modified';Order of a folder listing. Name order is natural (“file2” before “file10”) and ignores case.
SortOrder
Section titled “SortOrder”type SortOrder = 'asc' | 'desc';Ascending or descending; folders count as the smallest size.
FileItems
Section titled “FileItems”type FileItems = | { names: string[]; } | { all: true; except: string[]; };Entries of one folder that an operation works on. all with except names a whole folder without listing it, so
selecting everything in a folder of 100,000 entries never sends 100,000 names.
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ names: string[];}names: string[];The names of the entries, 1 to 1000.
Type Literal
Section titled “Type Literal”{ all: true; except: string[];}all: true;Every entry of the folder.
except
Section titled “except”except: string[];Names to leave out, at most 1000.
ConflictPolicy
Section titled “ConflictPolicy”type ConflictPolicy = 'fail' | 'skip' | 'overwrite' | 'rename';What happens when the target already has an entry of the same name: fail stops the job with fs.entry.exists,
skip leaves the entry out, overwrite replaces files and merges folders, rename picks a free name such as
“Report (2).pdf”.
JobState
Section titled “JobState”type JobState = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'interrupted';Where a job is: waiting, running, or finished in one of four ways (interrupted by a daemon restart).
StorageState
Section titled “StorageState”type StorageState = 'ready' | 'unmapped' | 'locked' | 'unavailable';The state of a storage the manifest requests: ready (mapped to a folder that can be reached), unmapped (no
administrator assigned a folder yet), locked (its pool is encrypted and locked) or unavailable (its pool or
folder is missing).