/** * Import / bootstrap (reverse projection) โ€” walk an existing bucket/prefix in an * {@link ObjectProjection} and build a master collection where each record * anchors one object, restoring the record-anchoring invariant for objects that * pre-date noy-db (or were written by another system). See as-aws-s3 ยง3.8. * * Idempotent: re-running re-adopts the same objects under the same record ids. */ import type { ObjectProjection } from './object-projection.js'; /** Minimal collection surface this utility needs (avoids importing the kernel). */ export interface ImportableCollection { get(id: string): Promise; put(id: string, record: unknown): Promise; blob(id: string): { adoptExternal(slot: string, ref: { key: string; size?: number; contentType?: string; public?: boolean; backlink?: string; }): Promise; }; } export interface ImportExternalOptions { /** Only consider objects under this key prefix. Default `''` (all). */ prefix?: string; /** * Derive the record id for an object key. Default: the path segment before * the last โ€” i.e. `{collection}/{recordId}/{field}` โ†’ `recordId`. Return * `null` to skip the object. */ deriveRecordId?: (key: string) => string | null; /** Build the anchor record for a new id. Default `{ id }`. */ makeRecord?: (id: string) => unknown; } export interface ImportExternalResult { imported: number; skipped: number; recordIds: string[]; } /** * Build/extend `collection` from the objects under `prefix` in `objectStore`, * adopting each as the `field` blob on its derived record. */ export declare function importExternalObjects(args: { collection: ImportableCollection; objectStore: ObjectProjection; field: string; options?: ImportExternalOptions; }): Promise;