import { SmrtObject } from '@happyvertical/smrt-core'; import { Tag } from '@happyvertical/smrt-tags'; import { AssetAssociation } from './asset-association'; import { AssetStatus } from './asset-status'; import { AssetType } from './asset-type'; import { AssetOptions } from './types'; export interface AssetExternalReference { provider: string; assetId?: string | null; externalId?: string | null; sourceRef?: Record | null; status?: string | null; metadata?: Record | null; syncedAt?: string | null; [key: string]: unknown; } export declare class Asset extends SmrtObject { tenantId: string | null; name: string; sourceUri: string; mimeType: string; description: string; metadata: string; version: number; primaryVersionId: string | null; typeSlug: string; statusSlug: string; ownerProfileId: string | null; /** * FK to the source Asset this one was derived from (e.g. thumbnail * derived from an original image, transcoded video, AI variation). * * Renamed from `parentId` in R3-D to make the derivation semantics * explicit and free `parentId` to mean exactly structural hierarchy * (SmrtHierarchical) across the framework. The column on the assets * table is `source_asset_id`. */ sourceAssetId: string | null; folderId: string | null; sourceType: string; externalId: string; externalRefs: string; createdAt: Date; updatedAt: Date; constructor(options?: AssetOptions); getMetadata(): Record; setMetadata(metadata: Record): void; mergeMetadata(metadata: Record): void; getExternalRefs(): Record; getExternalRef(provider: string): AssetExternalReference | null; setExternalRef(provider: string, reference: Omit & { provider?: string; }): void; /** * Get all tags for this asset from @happyvertical/smrt-tags * * @returns Array of Tag instances from @happyvertical/smrt-tags package */ getTags(): Promise; /** * Check if this asset has a specific tag * * @param tagSlug - The slug of the tag to check * @returns True if the asset has this tag */ hasTag(tagSlug: string): Promise; /** * Resolve the AssetCollection lazily. Going through `ObjectRegistry` * mirrors the pattern used by `SmrtHierarchical._hierarchyCollection` * so source/derivative lookups inherit tenant scoping and ORM * hydration without hard-coding an import of `./assets` (which would * create a module-import cycle). * * The return type is `SmrtCollection` (the framework base, type- * only import from core) rather than the concrete `AssetCollection` — * importing the concrete class is what would create the cycle, but the * base-class shape gives callers full `.get()` / `.list()` type * safety here. * * R5-canon: hardcode the base Asset's qualified key so a different * package also registering a class called `Asset` can't be picked * by `findClass`'s multi-strategy fallback. Crucially we DON'T * resolve via `this.constructor._smrtQualifiedName` — for an STI * subclass like `Image`, that would yield the Image collection * (which auto-filters `_meta_type = '...:Image'` on `get`/`list`), * and `getSource()` / `getDerivatives()` would miss cross-type * derivation links (Image derived from a plain Asset, etc.). * `sourceAssetId` is a base-table derivation link, so it always * resolves through the base Asset collection. */ private _assetCollection; /** * Get the source asset this one was derived from, if any. * * Renamed from `getParent` in R3-D. The relationship is "I was produced * from that asset" (e.g. a thumbnail's source is its original image), * not a structural-hierarchy parent. * * Goes through the AssetCollection so tenant interceptors and ORM * hydration apply — important because a tenant-scoped consumer with * cross-tenant derivative chains would otherwise return assets from * tenants the caller cannot see, and a raw `db.get` returns * snake_case rows that leave camelCase props (e.g. `sourceUri`) at * their constructor defaults. * * @returns Source Asset instance, or null if this asset has no source */ getSource(): Promise; /** * Get all assets derived from this one (e.g. thumbnails, variants, * transcodes, AI edits). * * Renamed from `getChildren` in R3-D to match the derivation * semantics. Goes through the AssetCollection so tenant interceptors * and ORM hydration apply (see `getSource` for why this matters — * the pre-R3-D `getChildren` used raw `db.list`, which both bypassed * tenant scoping and dropped camelCase property hydration; that * latent breakage is fixed here). * * @returns Array of derivative Asset instances */ getDerivatives(): Promise; /** * Get the type of this asset * * @returns AssetType instance or null */ getType(): Promise; /** * Get the status of this asset * * @returns AssetStatus instance or null */ getStatus(): Promise; /** * Get all associations for this asset * * @returns Array of AssetAssociation instances */ getAssociations(): Promise; /** * Associate this asset with a target object * * @param metaType - Target class name or qualified name (e.g., 'Article' or '@pkg:Article') * @param metaId - Target object ID * @param role - Association role (default: 'default') * @returns The created AssetAssociation */ associateWith(metaType: string, metaId: string, role?: string): Promise; /** * Get asset by slug * * @param slug - The slug to search for * @returns Asset instance or null */ static getBySlug(_slug: string): Promise; } //# sourceMappingURL=asset.d.ts.map