TypeScript API / laikacms/assets/jsonapi-proxy / AssetsJsonApiProxyRepository
Class: AssetsJsonApiProxyRepository
Proxies all assets operations through a remote JSON:API endpoint.
Extends
Constructors
Constructor
new AssetsJsonApiProxyRepository(options): AssetsJsonApiProxyRepository;Parameters
| Parameter | Type |
|---|---|
options | AssetsJsonApiProxyRepositoryOptions |
Returns
AssetsJsonApiProxyRepository
Overrides
Methods
createAsset()
createAsset(create): LaikaTask<{
content: {
[key: string]: any;
};
createdAt?: string;
key: string;
type: "asset";
updatedAt?: string;
version?: string;
}>;Parameters
| Parameter | Type | Description |
|---|---|---|
create | { cacheControl?: string; content: BinaryContent; customMetadata?: { [key: string]: string; }; filename?: string; key: string; mimeType: string; } | - |
create.cacheControl? | string | Cache control header value |
create.content | BinaryContent | The binary content of the asset. Accepts Uint8Array, ArrayBuffer, or ReadableStream<Uint8Array>. |
create.customMetadata? | { [key: string]: string; } | Custom metadata to store with the asset |
create.filename? | string | Original filename (optional) |
create.key | string | Key/path for the asset (without extension) |
create.mimeType | string | MIME type of the asset |
Returns
LaikaTask<{ content: { [key: string]: any; }; createdAt?: string; key: string; type: "asset"; updatedAt?: string; version?: string; }>
Overrides
createFolder()
createFolder(folderCreate): LaikaTask<{
createdAt?: string;
key: string;
type: "folder";
updatedAt?: string;
}>;Parameters
| Parameter | Type |
|---|---|
folderCreate | { key: string; type?: "folder"; } |
folderCreate.key | string |
folderCreate.type? | "folder" |
Returns
LaikaTask<{ createdAt?: string; key: string; type: "folder"; updatedAt?: string; }>
Overrides
deleteAsset()
deleteAsset(key): LaikaTask<void>;Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
LaikaTask<void>
Overrides
deleteAssets()
deleteAssets(keys): LaikaStream<string, DeleteAssetsDone>;Batch-remove several assets in a single POST /operations call instead of one DELETE per key. Follows the upstream assets-api server's fail-fast contract (ADR-004): ops apply in order and processing stops at the first repository failure, so results may be shorter than keys when a mid-batch failure occurred. Unlike the fail-fast server contract itself, this method's own contract (mirrors storage-jsonapi-proxy's removeAtoms) is best-effort per key — every key is resolved to either a data (removed) or recoverableError (skipped) outcome, including keys left unprocessed by a fail-fast stop.
Parameters
| Parameter | Type |
|---|---|
keys | readonly string[] |
Returns
LaikaStream<string, DeleteAssetsDone>
Overrides
deleteFolder()
deleteFolder(key, recursive?): LaikaTask<void>;Parameters
| Parameter | Type |
|---|---|
key | string |
recursive? | boolean |
Returns
LaikaTask<void>
Overrides
getAsset()
getAsset(key, options?): LaikaTask<{
content: {
[key: string]: any;
};
createdAt?: string;
key: string;
type: "asset";
updatedAt?: string;
version?: string;
}>;Parameters
| Parameter | Type |
|---|---|
key | string |
options? | GetResourceOptions |
Returns
LaikaTask<{ content: { [key: string]: any; }; createdAt?: string; key: string; type: "asset"; updatedAt?: string; version?: string; }>
Overrides
getCapabilities()
getCapabilities(): LaikaTask<{
changes: | {
description: string;
supported: false;
}
| {
changeFeed: boolean;
description: string;
supported: true;
syncToken: boolean;
};
compatibilityDate: string & Brand<"AssetsRepositoryCompatibilityDate">;
filtering?: | {
description: string;
supported: false;
}
| {
description: string;
filters: readonly object[];
supported: true;
};
pagination: | {
description: string;
supported: false;
}
| {
description: string;
styles: {
cursor: boolean;
offset: boolean;
page: boolean;
};
supported: true;
};
versionTracking: | {
description: string;
supported: false;
}
| {
description: string;
supported: true;
};
}>;Returns
LaikaTask<{ changes: | { description: string; supported: false; } | { changeFeed: boolean; description: string; supported: true; syncToken: boolean; }; compatibilityDate: string & Brand<"AssetsRepositoryCompatibilityDate">; filtering?: | { description: string; supported: false; } | { description: string; filters: readonly object[]; supported: true; }; pagination: | { description: string; supported: false; } | { description: string; styles: { cursor: boolean; offset: boolean; page: boolean; }; supported: true; }; versionTracking: | { description: string; supported: false; } | { description: string; supported: true; }; }>
Overrides
AssetsRepository.getCapabilities
getFolder()
getFolder(key): LaikaTask<{
createdAt?: string;
key: string;
type: "folder";
updatedAt?: string;
}>;Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
LaikaTask<{ createdAt?: string; key: string; type: "folder"; updatedAt?: string; }>
Overrides
getMetadata()
getMetadata(assets): LaikaStream<{
key: string;
metadata: | {
animated?: boolean;
bitDepth?: number;
colorSpace?: string;
createdAt?: Utc;
exif?: {
[key: string]: any;
};
extension?: string;
filename?: string;
hasAlpha?: boolean;
hash?: string;
hashAlgorithm?: string;
height: number;
kind: "image";
mimeType: string;
modifiedAt?: Utc;
size: number;
width: number;
}
| {
audioBitrate?: number;
audioChannels?: number;
audioCodec?: string;
audioSampleRate?: number;
createdAt?: Utc;
duration: number;
extension?: string;
filename?: string;
frameRate?: number;
hash?: string;
hashAlgorithm?: string;
height: number;
kind: "video";
mimeType: string;
modifiedAt?: Utc;
size: number;
videoBitrate?: number;
videoCodec?: string;
width: number;
}
| {
bitrate?: number;
channels?: number;
codec?: string;
createdAt?: Utc;
duration: number;
extension?: string;
filename?: string;
hash?: string;
hashAlgorithm?: string;
kind: "audio";
mimeType: string;
modifiedAt?: Utc;
sampleRate?: number;
size: number;
tags?: {
[key: string]: string;
};
}
| {
author?: string;
createdAt?: Utc;
documentCreatedAt?: Utc;
documentModifiedAt?: Utc;
extension?: string;
filename?: string;
hash?: string;
hashAlgorithm?: string;
keywords?: readonly string[];
kind: "document";
mimeType: string;
modifiedAt?: Utc;
pageCount?: number;
size: number;
subject?: string;
title?: string;
}
| {
createdAt?: Utc;
extension?: string;
filename?: string;
hash?: string;
hashAlgorithm?: string;
kind: "binary";
mimeType: string;
modifiedAt?: Utc;
size: number;
};
}, LaikaDone>;Parameters
| Parameter | Type |
|---|---|
assets | object[] |
Returns
LaikaStream<{ key: string; metadata: | { animated?: boolean; bitDepth?: number; colorSpace?: string; createdAt?: Utc; exif?: { [key: string]: any; }; extension?: string; filename?: string; hasAlpha?: boolean; hash?: string; hashAlgorithm?: string; height: number; kind: "image"; mimeType: string; modifiedAt?: Utc; size: number; width: number; } | { audioBitrate?: number; audioChannels?: number; audioCodec?: string; audioSampleRate?: number; createdAt?: Utc; duration: number; extension?: string; filename?: string; frameRate?: number; hash?: string; hashAlgorithm?: string; height: number; kind: "video"; mimeType: string; modifiedAt?: Utc; size: number; videoBitrate?: number; videoCodec?: string; width: number; } | { bitrate?: number; channels?: number; codec?: string; createdAt?: Utc; duration: number; extension?: string; filename?: string; hash?: string; hashAlgorithm?: string; kind: "audio"; mimeType: string; modifiedAt?: Utc; sampleRate?: number; size: number; tags?: { [key: string]: string; }; } | { author?: string; createdAt?: Utc; documentCreatedAt?: Utc; documentModifiedAt?: Utc; extension?: string; filename?: string; hash?: string; hashAlgorithm?: string; keywords?: readonly string[]; kind: "document"; mimeType: string; modifiedAt?: Utc; pageCount?: number; size: number; subject?: string; title?: string; } | { createdAt?: Utc; extension?: string; filename?: string; hash?: string; hashAlgorithm?: string; kind: "binary"; mimeType: string; modifiedAt?: Utc; size: number; }; }, LaikaDone>
Overrides
getResource()
getResource(key, options?): LaikaTask<readonly (
| {
content: {
[key: string]: any;
};
createdAt?: string;
key: string;
type: "asset";
updatedAt?: string;
version?: string;
}
| {
createdAt?: string;
key: string;
type: "folder";
updatedAt?: string;
})[]>;Get a resource (asset or folder) by key. Returns an array because a single key may resolve to multiple resources (e.g. variations included via hints).
Parameters
| Parameter | Type |
|---|---|
key | string |
options? | GetResourceOptions |
Returns
LaikaTask<readonly ( | { content: { [key: string]: any; }; createdAt?: string; key: string; type: "asset"; updatedAt?: string; version?: string; } | { createdAt?: string; key: string; type: "folder"; updatedAt?: string; })[]>
Overrides
getSyncToken()
getSyncToken(options?): LaikaTask<string & Brand<"SyncToken">>;Return an opaque token for the given scope (a folder, or the whole store when omitted) that changes whenever anything inside the scope changes. Compare tokens only by equality.
Non-abstract on purpose: existing subclasses stay source-compatible. The base implementation fails with NotImplementedError; check getCapabilities().changes before calling.
Parameters
| Parameter | Type |
|---|---|
options? | GetSyncTokenOptions |
Returns
LaikaTask<string & Brand<"SyncToken">>
Overrides
getUrls()
getUrls(assets): LaikaStream<{
expiresAt?: Utc;
key: string;
url?: string;
}, LaikaDone>;Parameters
| Parameter | Type |
|---|---|
assets | object[] |
Returns
LaikaStream<{ expiresAt?: Utc; key: string; url?: string; }, LaikaDone>
Overrides
getVariations()
getVariations(assets): LaikaStream<{
key: string;
variations: {
[key: string]: object;
};
}, LaikaDone>;Compute variation URLs for the given assets, one entry per asset. Per-asset failures (e.g. unsupported format) surface as recoverable errors.
Parameters
| Parameter | Type |
|---|---|
assets | object[] |
Returns
LaikaStream<{ key: string; variations: { [key: string]: object; }; }, LaikaDone>
Overrides
AssetsRepository.getVariations
listChanges()
listChanges(options): LaikaStream<{
deleted: boolean;
key: string;
version?: string;
}, ListChangesDone>;Enumerate what changed inside the scope since a previously obtained sync token. The done value carries the new sync token to resume from.
Non-abstract on purpose: existing subclasses stay source-compatible. The base implementation fails with NotImplementedError; check getCapabilities().changes before calling.
Parameters
| Parameter | Type |
|---|---|
options | ListChangesOptions |
Returns
LaikaStream<{ deleted: boolean; key: string; version?: string; }, ListChangesDone>
Overrides
listResources()
listResources(folderKey, options): LaikaStream<
| {
content: {
[key: string]: any;
};
createdAt?: string;
key: string;
type: "asset";
updatedAt?: string;
version?: string;
}
| {
createdAt?: string;
key: string;
type: "folder";
updatedAt?: string;
}, LaikaDone>;Parameters
| Parameter | Type |
|---|---|
folderKey | string |
options | ListResourcesOptions |
Returns
LaikaStream< | { content: { [key: string]: any; }; createdAt?: string; key: string; type: "asset"; updatedAt?: string; version?: string; } | { createdAt?: string; key: string; type: "folder"; updatedAt?: string; }, LaikaDone>
Overrides
AssetsRepository.listResources
updateAsset()
updateAsset(update): LaikaTask<{
content: {
[key: string]: any;
};
createdAt?: string;
key: string;
type: "asset";
updatedAt?: string;
version?: string;
}>;Parameters
| Parameter | Type | Description |
|---|---|---|
update | { cacheControl?: string; customMetadata?: { [key: string]: string; }; key: string; mimeType?: string; } | - |
update.cacheControl? | string | Updated cache control header value |
update.customMetadata? | { [key: string]: string; } | Updated custom metadata (replaces existing) |
update.key | string | Key/path of the asset to update |
update.mimeType? | string | Updated MIME type (if content type needs correction) |
Returns
LaikaTask<{ content: { [key: string]: any; }; createdAt?: string; key: string; type: "asset"; updatedAt?: string; version?: string; }>