Skip to content

TypeScript API / laikacms/assets / AssetSchema

Variable: AssetSchema ​

ts
const AssetSchema: StandardSchemaV1<{
  content: {
   [key: string]: any;
  };
  createdAt?: string;
  key: string;
  type: "asset";
  updatedAt?: string;
  version?: string;
}, {
  content: {
   [key: string]: any;
  };
  createdAt?: string;
  key: string;
  type: "asset";
  updatedAt?: string;
  version?: string;
}> & Struct<{
  content: $Record<String, Any>;
  createdAt: optional<String>;
  key: String;
  type: Literal<"asset">;
  updatedAt: optional<String>;
  version: optional<String>;
}>;

Asset extends StorageObject with a different type discriminator.

The content field is inherited from StorageObject and contains implementation-specific data. The implementation decides what to store.

Previews, URLs, and metadata are NOT stored in the asset itself. Instead, use the repository methods:

  • getPreviews(key) - Get preview URLs for an asset
  • getUrls(key) - Get access URLs for an asset
  • getMetadata(key) - Get metadata for an asset

This decoupling allows:

  1. Implementations to generate URLs/previews on-demand
  2. Different caching strategies for different data types
  3. Lazy loading of expensive-to-compute data

Released under the MIT License.