Files
recap/node_modules/@start9labs/start-sdk/package/lib/mainFn/Mounts.d.ts
T

88 lines
3.7 KiB
TypeScript

import * as T from '../../../base/lib/types';
import { MountOptions } from '../util/SubContainer';
type MountArray = {
mountpoint: string;
options: MountOptions;
}[];
type SharedOptions = {
/** The path within the resource to mount. Use `null` to mount the entire resource */
subpath: string | null;
/** Where to mount the resource. e.g. /data */
mountpoint: string;
/**
* Whether to mount this as a file or directory
*
* defaults to "directory"
* */
type?: 'file' | 'directory' | 'infer';
};
type VolumeOpts<Manifest extends T.SDKManifest> = {
/** The ID of the volume to mount. Must be one of the volume IDs defined in the manifest */
volumeId: Manifest['volumes'][number];
/** Whether or not the resource should be readonly for this subcontainer */
readonly: boolean;
} & SharedOptions;
type DependencyOpts<Manifest extends T.SDKManifest> = {
/** The ID of the dependency */
dependencyId: Manifest['id'];
/** The ID of the volume to mount. Must be one of the volume IDs defined in the manifest of the dependency */
volumeId: Manifest['volumes'][number];
/** Whether or not the resource should be readonly for this subcontainer */
readonly: boolean;
} & SharedOptions;
/**
* Immutable builder for declaring filesystem mounts into a subcontainer.
*
* Supports mounting volumes, static assets, dependency volumes, and backup directories.
* Each `mount*` method returns a new `Mounts` instance (immutable builder pattern).
*
* @typeParam Manifest - The service manifest type
* @typeParam Backups - Tracks whether backup mounts have been added (type-level flag)
*/
export declare class Mounts<Manifest extends T.SDKManifest, Backups extends SharedOptions = never> {
readonly volumes: VolumeOpts<Manifest>[];
readonly assets: SharedOptions[];
readonly dependencies: DependencyOpts<T.SDKManifest>[];
readonly backups: Backups[];
private constructor();
/**
* Create an empty Mounts builder with no mounts configured.
* @returns A new Mounts instance ready for chaining mount declarations
*/
static of<Manifest extends T.SDKManifest>(): Mounts<Manifest, never>;
/**
* Add a volume mount from the service's own volumes.
* @param options - Volume ID, mountpoint, readonly flag, and optional subpath
* @returns A new Mounts instance with this volume added
*/
mountVolume(options: VolumeOpts<Manifest>): Mounts<Manifest, Backups>;
/**
* Add a read-only mount of the service's packaged static assets.
* @param options - Mountpoint and optional subpath within the assets directory
* @returns A new Mounts instance with this asset mount added
*/
mountAssets(options: SharedOptions): Mounts<Manifest, Backups>;
/**
* Add a mount from a dependency package's volume.
* @param options - Dependency ID, volume ID, mountpoint, readonly flag, and optional subpath
* @returns A new Mounts instance with this dependency mount added
*/
mountDependency<DependencyManifest extends T.SDKManifest>(options: DependencyOpts<DependencyManifest>): Mounts<Manifest, Backups>;
/**
* Add a mount of the backup directory. Only valid during backup/restore operations.
* @param options - Mountpoint and optional subpath within the backup directory
* @returns A new Mounts instance with this backup mount added
*/
mountBackups(options: SharedOptions): Mounts<Manifest, {
subpath: string | null;
mountpoint: string;
}>;
/**
* Compile all declared mounts into the low-level mount array consumed by the subcontainer runtime.
* @throws If any two mounts share the same mountpoint
* @returns An array of `{ mountpoint, options }` objects
*/
build(): MountArray;
}
export {};