feat: asset metadata (#20446)

This commit is contained in:
Jason Rasmussen
2025-08-27 14:31:23 -04:00
committed by GitHub
parent 25a94bd117
commit 88072910da
37 changed files with 1999 additions and 21 deletions

View File

@@ -2245,6 +2245,203 @@
"description": "This endpoint requires the `asset.update` permission."
}
},
"/assets/{id}/metadata": {
"get": {
"operationId": "getAssetMetadata",
"parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"format": "uuid",
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/AssetMetadataResponseDto"
},
"type": "array"
}
}
},
"description": ""
}
},
"security": [
{
"bearer": []
},
{
"cookie": []
},
{
"api_key": []
}
],
"tags": [
"Assets"
],
"x-immich-permission": "asset.read",
"description": "This endpoint requires the `asset.read` permission."
},
"put": {
"operationId": "updateAssetMetadata",
"parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"format": "uuid",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AssetMetadataUpsertDto"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/AssetMetadataResponseDto"
},
"type": "array"
}
}
},
"description": ""
}
},
"security": [
{
"bearer": []
},
{
"cookie": []
},
{
"api_key": []
}
],
"tags": [
"Assets"
],
"x-immich-permission": "asset.update",
"description": "This endpoint requires the `asset.update` permission."
}
},
"/assets/{id}/metadata/{key}": {
"delete": {
"operationId": "deleteAssetMetadata",
"parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"format": "uuid",
"type": "string"
}
},
{
"name": "key",
"required": true,
"in": "path",
"schema": {
"$ref": "#/components/schemas/AssetMetadataKey"
}
}
],
"responses": {
"204": {
"description": ""
}
},
"security": [
{
"bearer": []
},
{
"cookie": []
},
{
"api_key": []
}
],
"tags": [
"Assets"
],
"x-immich-permission": "asset.update",
"description": "This endpoint requires the `asset.update` permission."
},
"get": {
"operationId": "getAssetMetadataByKey",
"parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"format": "uuid",
"type": "string"
}
},
{
"name": "key",
"required": true,
"in": "path",
"schema": {
"$ref": "#/components/schemas/AssetMetadataKey"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AssetMetadataResponseDto"
}
}
},
"description": ""
}
},
"security": [
{
"bearer": []
},
{
"cookie": []
},
{
"api_key": []
}
],
"tags": [
"Assets"
],
"x-immich-permission": "asset.read",
"description": "This endpoint requires the `asset.read` permission."
}
},
"/assets/{id}/original": {
"get": {
"operationId": "downloadAsset",
@@ -10615,6 +10812,12 @@
"format": "uuid",
"type": "string"
},
"metadata": {
"items": {
"$ref": "#/components/schemas/AssetMetadataUpsertItemDto"
},
"type": "array"
},
"sidecarData": {
"format": "binary",
"type": "string"
@@ -10632,7 +10835,8 @@
"deviceAssetId",
"deviceId",
"fileCreatedAt",
"fileModifiedAt"
"fileModifiedAt",
"metadata"
],
"type": "object"
},
@@ -10707,6 +10911,69 @@
],
"type": "string"
},
"AssetMetadataKey": {
"enum": [
"mobile-app"
],
"type": "string"
},
"AssetMetadataResponseDto": {
"properties": {
"key": {
"allOf": [
{
"$ref": "#/components/schemas/AssetMetadataKey"
}
]
},
"updatedAt": {
"format": "date-time",
"type": "string"
},
"value": {
"type": "object"
}
},
"required": [
"key",
"updatedAt",
"value"
],
"type": "object"
},
"AssetMetadataUpsertDto": {
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/AssetMetadataUpsertItemDto"
},
"type": "array"
}
},
"required": [
"items"
],
"type": "object"
},
"AssetMetadataUpsertItemDto": {
"properties": {
"key": {
"allOf": [
{
"$ref": "#/components/schemas/AssetMetadataKey"
}
]
},
"value": {
"type": "object"
}
},
"required": [
"key",
"value"
],
"type": "object"
},
"AssetOrder": {
"enum": [
"asc",
@@ -14944,6 +15211,48 @@
],
"type": "object"
},
"SyncAssetMetadataDeleteV1": {
"properties": {
"assetId": {
"type": "string"
},
"key": {
"allOf": [
{
"$ref": "#/components/schemas/AssetMetadataKey"
}
]
}
},
"required": [
"assetId",
"key"
],
"type": "object"
},
"SyncAssetMetadataV1": {
"properties": {
"assetId": {
"type": "string"
},
"key": {
"allOf": [
{
"$ref": "#/components/schemas/AssetMetadataKey"
}
]
},
"value": {
"type": "object"
}
},
"required": [
"assetId",
"key",
"value"
],
"type": "object"
},
"SyncAssetV1": {
"properties": {
"checksum": {
@@ -15114,6 +15423,8 @@
"AssetV1",
"AssetDeleteV1",
"AssetExifV1",
"AssetMetadataV1",
"AssetMetadataDeleteV1",
"PartnerV1",
"PartnerDeleteV1",
"PartnerAssetV1",
@@ -15373,6 +15684,7 @@
"AlbumAssetExifsV1",
"AssetsV1",
"AssetExifsV1",
"AssetMetadataV1",
"AuthUsersV1",
"MemoriesV1",
"MemoryToAssetsV1",

View File

@@ -447,6 +447,10 @@ export type AssetBulkDeleteDto = {
force?: boolean;
ids: string[];
};
export type AssetMetadataUpsertItemDto = {
key: AssetMetadataKey;
value: object;
};
export type AssetMediaCreateDto = {
assetData: Blob;
deviceAssetId: string;
@@ -457,6 +461,7 @@ export type AssetMediaCreateDto = {
filename?: string;
isFavorite?: boolean;
livePhotoVideoId?: string;
metadata: AssetMetadataUpsertItemDto[];
sidecarData?: Blob;
visibility?: AssetVisibility;
};
@@ -516,6 +521,14 @@ export type UpdateAssetDto = {
rating?: number;
visibility?: AssetVisibility;
};
export type AssetMetadataResponseDto = {
key: AssetMetadataKey;
updatedAt: string;
value: object;
};
export type AssetMetadataUpsertDto = {
items: AssetMetadataUpsertItemDto[];
};
export type AssetMediaReplaceDto = {
assetData: Blob;
deviceAssetId: string;
@@ -2273,6 +2286,61 @@ export function updateAsset({ id, updateAssetDto }: {
body: updateAssetDto
})));
}
/**
* This endpoint requires the `asset.read` permission.
*/
export function getAssetMetadata({ id }: {
id: string;
}, opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchJson<{
status: 200;
data: AssetMetadataResponseDto[];
}>(`/assets/${encodeURIComponent(id)}/metadata`, {
...opts
}));
}
/**
* This endpoint requires the `asset.update` permission.
*/
export function updateAssetMetadata({ id, assetMetadataUpsertDto }: {
id: string;
assetMetadataUpsertDto: AssetMetadataUpsertDto;
}, opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchJson<{
status: 200;
data: AssetMetadataResponseDto[];
}>(`/assets/${encodeURIComponent(id)}/metadata`, oazapfts.json({
...opts,
method: "PUT",
body: assetMetadataUpsertDto
})));
}
/**
* This endpoint requires the `asset.update` permission.
*/
export function deleteAssetMetadata({ id, key }: {
id: string;
key: AssetMetadataKey;
}, opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchText(`/assets/${encodeURIComponent(id)}/metadata/${encodeURIComponent(key)}`, {
...opts,
method: "DELETE"
}));
}
/**
* This endpoint requires the `asset.read` permission.
*/
export function getAssetMetadataByKey({ id, key }: {
id: string;
key: AssetMetadataKey;
}, opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchJson<{
status: 200;
data: AssetMetadataResponseDto;
}>(`/assets/${encodeURIComponent(id)}/metadata/${encodeURIComponent(key)}`, {
...opts
}));
}
/**
* This endpoint requires the `asset.download` permission.
*/
@@ -4725,6 +4793,9 @@ export enum Permission {
AdminUserDelete = "adminUser.delete",
AdminAuthUnlinkAll = "adminAuth.unlinkAll"
}
export enum AssetMetadataKey {
MobileApp = "mobile-app"
}
export enum AssetMediaStatus {
Created = "created",
Replaced = "replaced",
@@ -4811,6 +4882,8 @@ export enum SyncEntityType {
AssetV1 = "AssetV1",
AssetDeleteV1 = "AssetDeleteV1",
AssetExifV1 = "AssetExifV1",
AssetMetadataV1 = "AssetMetadataV1",
AssetMetadataDeleteV1 = "AssetMetadataDeleteV1",
PartnerV1 = "PartnerV1",
PartnerDeleteV1 = "PartnerDeleteV1",
PartnerAssetV1 = "PartnerAssetV1",
@@ -4858,6 +4931,7 @@ export enum SyncRequestType {
AlbumAssetExifsV1 = "AlbumAssetExifsV1",
AssetsV1 = "AssetsV1",
AssetExifsV1 = "AssetExifsV1",
AssetMetadataV1 = "AssetMetadataV1",
AuthUsersV1 = "AuthUsersV1",
MemoriesV1 = "MemoriesV1",
MemoryToAssetsV1 = "MemoryToAssetsV1",