chore: oapi

This commit is contained in:
izzy 2026-05-18 16:32:30 +01:00
parent cb87a39b3a
commit a41aa623da
No known key found for this signature in database
17 changed files with 9352 additions and 18 deletions

View file

@ -0,0 +1,9 @@
{
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "2.17.0",
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c",
"integrity": "sha256:25b9f05705ffba7dbe503230ac76081419306f8c8bc88e0ce78c4ecd99a0c78c"
}
}
}

View file

@ -235,6 +235,7 @@ Class | Method | HTTP request | Description
*RepositoryApi* | [**getSnapshots**](doc//RepositoryApi.md#getsnapshots) | **GET** /yucca/repository/{id}/snapshots |
*RepositoryApi* | [**importRepository**](doc//RepositoryApi.md#importrepository) | **POST** /yucca/repository/{id}/import |
*RepositoryApi* | [**inspectRepositories**](doc//RepositoryApi.md#inspectrepositories) | **GET** /yucca/repository/inspect |
*RepositoryApi* | [**pruneRepository**](doc//RepositoryApi.md#prunerepository) | **POST** /yucca/repository/{id}/snapshots/prune |
*RepositoryApi* | [**restoreFromPoint**](doc//RepositoryApi.md#restorefrompoint) | **POST** /yucca/repository/{id}/snapshots/{snapshot}/restore-from-point |
*RepositoryApi* | [**restoreSnapshot**](doc//RepositoryApi.md#restoresnapshot) | **POST** /yucca/repository/{id}/snapshots/{snapshot} |
*RepositoryApi* | [**updateRepository**](doc//RepositoryApi.md#updaterepository) | **PATCH** /yucca/repository/{id} |
@ -392,7 +393,6 @@ Class | Method | HTTP request | Description
- [AssetFaceResponseDto](doc//AssetFaceResponseDto.md)
- [AssetFaceUpdateDto](doc//AssetFaceUpdateDto.md)
- [AssetFaceUpdateItem](doc//AssetFaceUpdateItem.md)
- [AssetFaceWithoutPersonResponseDto](doc//AssetFaceWithoutPersonResponseDto.md)
- [AssetIdErrorReason](doc//AssetIdErrorReason.md)
- [AssetIdsDto](doc//AssetIdsDto.md)
- [AssetIdsResponseDto](doc//AssetIdsResponseDto.md)
@ -411,6 +411,7 @@ Class | Method | HTTP request | Description
- [AssetMetadataUpsertItemDto](doc//AssetMetadataUpsertItemDto.md)
- [AssetOcrResponseDto](doc//AssetOcrResponseDto.md)
- [AssetOrder](doc//AssetOrder.md)
- [AssetOrderBy](doc//AssetOrderBy.md)
- [AssetRejectReason](doc//AssetRejectReason.md)
- [AssetResponseDto](doc//AssetResponseDto.md)
- [AssetStackResponseDto](doc//AssetStackResponseDto.md)
@ -540,7 +541,6 @@ Class | Method | HTTP request | Description
- [PersonResponseDto](doc//PersonResponseDto.md)
- [PersonStatisticsResponseDto](doc//PersonStatisticsResponseDto.md)
- [PersonUpdateDto](doc//PersonUpdateDto.md)
- [PersonWithFacesResponseDto](doc//PersonWithFacesResponseDto.md)
- [PinCodeChangeDto](doc//PinCodeChangeDto.md)
- [PinCodeResetDto](doc//PinCodeResetDto.md)
- [PinCodeSetupDto](doc//PinCodeSetupDto.md)
@ -587,6 +587,7 @@ Class | Method | HTTP request | Description
- [RepositorySnapshotRestoreRequestDto](doc//RepositorySnapshotRestoreRequestDto.md)
- [RepositoryUpdateRequestDto](doc//RepositoryUpdateRequestDto.md)
- [RepositoryUpdateResponseDto](doc//RepositoryUpdateResponseDto.md)
- [RetentionPolicyDto](doc//RetentionPolicyDto.md)
- [ReverseGeocodingStateResponseDto](doc//ReverseGeocodingStateResponseDto.md)
- [RotateParameters](doc//RotateParameters.md)
- [RunDto](doc//RunDto.md)

View file

@ -116,7 +116,6 @@ part 'model/asset_face_delete_dto.dart';
part 'model/asset_face_response_dto.dart';
part 'model/asset_face_update_dto.dart';
part 'model/asset_face_update_item.dart';
part 'model/asset_face_without_person_response_dto.dart';
part 'model/asset_id_error_reason.dart';
part 'model/asset_ids_dto.dart';
part 'model/asset_ids_response_dto.dart';
@ -135,6 +134,7 @@ part 'model/asset_metadata_upsert_dto.dart';
part 'model/asset_metadata_upsert_item_dto.dart';
part 'model/asset_ocr_response_dto.dart';
part 'model/asset_order.dart';
part 'model/asset_order_by.dart';
part 'model/asset_reject_reason.dart';
part 'model/asset_response_dto.dart';
part 'model/asset_stack_response_dto.dart';
@ -264,7 +264,6 @@ part 'model/person_create_dto.dart';
part 'model/person_response_dto.dart';
part 'model/person_statistics_response_dto.dart';
part 'model/person_update_dto.dart';
part 'model/person_with_faces_response_dto.dart';
part 'model/pin_code_change_dto.dart';
part 'model/pin_code_reset_dto.dart';
part 'model/pin_code_setup_dto.dart';
@ -311,6 +310,7 @@ part 'model/repository_snapshot_restore_from_point_request_dto.dart';
part 'model/repository_snapshot_restore_request_dto.dart';
part 'model/repository_update_request_dto.dart';
part 'model/repository_update_response_dto.dart';
part 'model/retention_policy_dto.dart';
part 'model/reverse_geocoding_state_response_dto.dart';
part 'model/rotate_parameters.dart';
part 'model/run_dto.dart';

View file

@ -559,6 +559,54 @@ class RepositoryApi {
return null;
}
/// Performs an HTTP 'POST /yucca/repository/{id}/snapshots/prune' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
Future<Response> pruneRepositoryWithHttpInfo(String id,) async {
// ignore: prefer_const_declarations
final apiPath = r'/yucca/repository/{id}/snapshots/prune'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
apiPath,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
Future<LogResponseDto?> pruneRepository(String id,) async {
final response = await pruneRepositoryWithHttpInfo(id,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'LogResponseDto',) as LogResponseDto;
}
return null;
}
/// Performs an HTTP 'POST /yucca/repository/{id}/snapshots/{snapshot}/restore-from-point' operation and returns the [Response].
/// Parameters:
///

View file

@ -258,8 +258,6 @@ class ApiClient {
return AssetFaceUpdateDto.fromJson(value);
case 'AssetFaceUpdateItem':
return AssetFaceUpdateItem.fromJson(value);
case 'AssetFaceWithoutPersonResponseDto':
return AssetFaceWithoutPersonResponseDto.fromJson(value);
case 'AssetIdErrorReason':
return AssetIdErrorReasonTypeTransformer().decode(value);
case 'AssetIdsDto':
@ -296,6 +294,8 @@ class ApiClient {
return AssetOcrResponseDto.fromJson(value);
case 'AssetOrder':
return AssetOrderTypeTransformer().decode(value);
case 'AssetOrderBy':
return AssetOrderByTypeTransformer().decode(value);
case 'AssetRejectReason':
return AssetRejectReasonTypeTransformer().decode(value);
case 'AssetResponseDto':
@ -554,8 +554,6 @@ class ApiClient {
return PersonStatisticsResponseDto.fromJson(value);
case 'PersonUpdateDto':
return PersonUpdateDto.fromJson(value);
case 'PersonWithFacesResponseDto':
return PersonWithFacesResponseDto.fromJson(value);
case 'PinCodeChangeDto':
return PinCodeChangeDto.fromJson(value);
case 'PinCodeResetDto':
@ -648,6 +646,8 @@ class ApiClient {
return RepositoryUpdateRequestDto.fromJson(value);
case 'RepositoryUpdateResponseDto':
return RepositoryUpdateResponseDto.fromJson(value);
case 'RetentionPolicyDto':
return RetentionPolicyDto.fromJson(value);
case 'ReverseGeocodingStateResponseDto':
return ReverseGeocodingStateResponseDto.fromJson(value);
case 'RotateParameters':

View file

@ -76,6 +76,9 @@ String parameterToString(dynamic value) {
if (value is AssetOrder) {
return AssetOrderTypeTransformer().encode(value).toString();
}
if (value is AssetOrderBy) {
return AssetOrderByTypeTransformer().encode(value).toString();
}
if (value is AssetRejectReason) {
return AssetRejectReasonTypeTransformer().encode(value).toString();
}

View file

@ -18,6 +18,7 @@ class ConfigureImmichIntegrationRequestDto {
this.dataFolders = const [],
required this.libraries,
required this.name,
this.retentionPolicy,
required this.worm,
});
@ -31,6 +32,8 @@ class ConfigureImmichIntegrationRequestDto {
String name;
RetentionPolicyDto? retentionPolicy;
bool worm;
@override
@ -40,6 +43,7 @@ class ConfigureImmichIntegrationRequestDto {
_deepEquality.equals(other.dataFolders, dataFolders) &&
other.libraries == libraries &&
other.name == name &&
other.retentionPolicy == retentionPolicy &&
other.worm == worm;
@override
@ -50,10 +54,11 @@ class ConfigureImmichIntegrationRequestDto {
(dataFolders.hashCode) +
(libraries.hashCode) +
(name.hashCode) +
(retentionPolicy == null ? 0 : retentionPolicy!.hashCode) +
(worm.hashCode);
@override
String toString() => 'ConfigureImmichIntegrationRequestDto[backupConfiguration=$backupConfiguration, cron=$cron, dataFolders=$dataFolders, libraries=$libraries, name=$name, worm=$worm]';
String toString() => 'ConfigureImmichIntegrationRequestDto[backupConfiguration=$backupConfiguration, cron=$cron, dataFolders=$dataFolders, libraries=$libraries, name=$name, retentionPolicy=$retentionPolicy, worm=$worm]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -62,6 +67,11 @@ class ConfigureImmichIntegrationRequestDto {
json[r'dataFolders'] = this.dataFolders;
json[r'libraries'] = this.libraries;
json[r'name'] = this.name;
if (this.retentionPolicy != null) {
json[r'retentionPolicy'] = this.retentionPolicy;
} else {
// json[r'retentionPolicy'] = null;
}
json[r'worm'] = this.worm;
return json;
}
@ -82,6 +92,7 @@ class ConfigureImmichIntegrationRequestDto {
: const [],
libraries: ConfigureImmichIntegrationRequestDtoLibraries.fromJson(json[r'libraries'])!,
name: mapValueOfType<String>(json, r'name')!,
retentionPolicy: RetentionPolicyDto.fromJson(json[r'retentionPolicy']),
worm: mapValueOfType<bool>(json, r'worm')!,
);
}

View file

@ -14,25 +14,35 @@ class RepositoryConfigurationDto {
/// Returns a new [RepositoryConfigurationDto] instance.
RepositoryConfigurationDto({
this.paths = const [],
this.retentionPolicy,
});
List<String> paths;
RetentionPolicyDto? retentionPolicy;
@override
bool operator ==(Object other) => identical(this, other) || other is RepositoryConfigurationDto &&
_deepEquality.equals(other.paths, paths);
_deepEquality.equals(other.paths, paths) &&
other.retentionPolicy == retentionPolicy;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(paths.hashCode);
(paths.hashCode) +
(retentionPolicy == null ? 0 : retentionPolicy!.hashCode);
@override
String toString() => 'RepositoryConfigurationDto[paths=$paths]';
String toString() => 'RepositoryConfigurationDto[paths=$paths, retentionPolicy=$retentionPolicy]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'paths'] = this.paths;
if (this.retentionPolicy != null) {
json[r'retentionPolicy'] = this.retentionPolicy;
} else {
// json[r'retentionPolicy'] = null;
}
return json;
}
@ -48,6 +58,7 @@ class RepositoryConfigurationDto {
paths: json[r'paths'] is Iterable
? (json[r'paths'] as Iterable).cast<String>().toList(growable: false)
: const [],
retentionPolicy: RetentionPolicyDto.fromJson(json[r'retentionPolicy']),
);
}
return null;

View file

@ -15,6 +15,7 @@ class RepositoryUpdateRequestDto {
RepositoryUpdateRequestDto({
this.name,
this.paths = const [],
this.retentionPolicy,
});
///
@ -27,19 +28,23 @@ class RepositoryUpdateRequestDto {
List<String> paths;
RetentionPolicyDto? retentionPolicy;
@override
bool operator ==(Object other) => identical(this, other) || other is RepositoryUpdateRequestDto &&
other.name == name &&
_deepEquality.equals(other.paths, paths);
_deepEquality.equals(other.paths, paths) &&
other.retentionPolicy == retentionPolicy;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(name == null ? 0 : name!.hashCode) +
(paths.hashCode);
(paths.hashCode) +
(retentionPolicy == null ? 0 : retentionPolicy!.hashCode);
@override
String toString() => 'RepositoryUpdateRequestDto[name=$name, paths=$paths]';
String toString() => 'RepositoryUpdateRequestDto[name=$name, paths=$paths, retentionPolicy=$retentionPolicy]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -49,6 +54,11 @@ class RepositoryUpdateRequestDto {
// json[r'name'] = null;
}
json[r'paths'] = this.paths;
if (this.retentionPolicy != null) {
json[r'retentionPolicy'] = this.retentionPolicy;
} else {
// json[r'retentionPolicy'] = null;
}
return json;
}
@ -65,6 +75,7 @@ class RepositoryUpdateRequestDto {
paths: json[r'paths'] is Iterable
? (json[r'paths'] as Iterable).cast<String>().toList(growable: false)
: const [],
retentionPolicy: RetentionPolicyDto.fromJson(json[r'retentionPolicy']),
);
}
return null;

View file

@ -0,0 +1,210 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class RetentionPolicyDto {
/// Returns a new [RetentionPolicyDto] instance.
RetentionPolicyDto({
this.keepLast,
this.keepWithin,
this.keepWithinDaily,
this.keepWithinHourly,
this.keepWithinMonthly,
this.keepWithinWeekly,
this.keepWithinYearly,
});
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
num? keepLast;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? keepWithin;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? keepWithinDaily;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? keepWithinHourly;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? keepWithinMonthly;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? keepWithinWeekly;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
String? keepWithinYearly;
@override
bool operator ==(Object other) => identical(this, other) || other is RetentionPolicyDto &&
other.keepLast == keepLast &&
other.keepWithin == keepWithin &&
other.keepWithinDaily == keepWithinDaily &&
other.keepWithinHourly == keepWithinHourly &&
other.keepWithinMonthly == keepWithinMonthly &&
other.keepWithinWeekly == keepWithinWeekly &&
other.keepWithinYearly == keepWithinYearly;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(keepLast == null ? 0 : keepLast!.hashCode) +
(keepWithin == null ? 0 : keepWithin!.hashCode) +
(keepWithinDaily == null ? 0 : keepWithinDaily!.hashCode) +
(keepWithinHourly == null ? 0 : keepWithinHourly!.hashCode) +
(keepWithinMonthly == null ? 0 : keepWithinMonthly!.hashCode) +
(keepWithinWeekly == null ? 0 : keepWithinWeekly!.hashCode) +
(keepWithinYearly == null ? 0 : keepWithinYearly!.hashCode);
@override
String toString() => 'RetentionPolicyDto[keepLast=$keepLast, keepWithin=$keepWithin, keepWithinDaily=$keepWithinDaily, keepWithinHourly=$keepWithinHourly, keepWithinMonthly=$keepWithinMonthly, keepWithinWeekly=$keepWithinWeekly, keepWithinYearly=$keepWithinYearly]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.keepLast != null) {
json[r'keepLast'] = this.keepLast;
} else {
// json[r'keepLast'] = null;
}
if (this.keepWithin != null) {
json[r'keepWithin'] = this.keepWithin;
} else {
// json[r'keepWithin'] = null;
}
if (this.keepWithinDaily != null) {
json[r'keepWithinDaily'] = this.keepWithinDaily;
} else {
// json[r'keepWithinDaily'] = null;
}
if (this.keepWithinHourly != null) {
json[r'keepWithinHourly'] = this.keepWithinHourly;
} else {
// json[r'keepWithinHourly'] = null;
}
if (this.keepWithinMonthly != null) {
json[r'keepWithinMonthly'] = this.keepWithinMonthly;
} else {
// json[r'keepWithinMonthly'] = null;
}
if (this.keepWithinWeekly != null) {
json[r'keepWithinWeekly'] = this.keepWithinWeekly;
} else {
// json[r'keepWithinWeekly'] = null;
}
if (this.keepWithinYearly != null) {
json[r'keepWithinYearly'] = this.keepWithinYearly;
} else {
// json[r'keepWithinYearly'] = null;
}
return json;
}
/// Returns a new [RetentionPolicyDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static RetentionPolicyDto? fromJson(dynamic value) {
upgradeDto(value, "RetentionPolicyDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return RetentionPolicyDto(
keepLast: num.parse('${json[r'keepLast']}'),
keepWithin: mapValueOfType<String>(json, r'keepWithin'),
keepWithinDaily: mapValueOfType<String>(json, r'keepWithinDaily'),
keepWithinHourly: mapValueOfType<String>(json, r'keepWithinHourly'),
keepWithinMonthly: mapValueOfType<String>(json, r'keepWithinMonthly'),
keepWithinWeekly: mapValueOfType<String>(json, r'keepWithinWeekly'),
keepWithinYearly: mapValueOfType<String>(json, r'keepWithinYearly'),
);
}
return null;
}
static List<RetentionPolicyDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <RetentionPolicyDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = RetentionPolicyDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, RetentionPolicyDto> mapFromJson(dynamic json) {
final map = <String, RetentionPolicyDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = RetentionPolicyDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of RetentionPolicyDto-objects as value to a dart map
static Map<String, List<RetentionPolicyDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<RetentionPolicyDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = RetentionPolicyDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
};
}

View file

@ -23,13 +23,17 @@ class RunType {
String toJson() => value;
static const backup = RunType._(r'backup');
static const schedule = RunType._(r'schedule');
static const restore = RunType._(r'restore');
static const backup = RunType._(r'backup');
static const forget = RunType._(r'forget');
/// List of all possible values in this [enum][RunType].
static const values = <RunType>[
backup,
schedule,
restore,
backup,
forget,
];
static RunType? fromJson(dynamic value) => RunTypeTypeTransformer().decode(value);
@ -68,8 +72,10 @@ class RunTypeTypeTransformer {
RunType? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'backup': return RunType.backup;
case r'schedule': return RunType.schedule;
case r'restore': return RunType.restore;
case r'backup': return RunType.backup;
case r'forget': return RunType.forget;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
import { HttpError } from '@oazapfts/runtime';
export interface ApiValidationError {
code: string;
path: (string | number)[];
message: string;
}
export interface ApiExceptionResponse {
message: string;
error?: string;
statusCode: number;
errors?: ApiValidationError[];
}
export interface ApiHttpError extends HttpError {
data: ApiExceptionResponse;
}
export declare function isHttpError(error: unknown): error is ApiHttpError;

View file

@ -0,0 +1,4 @@
import { HttpError } from '@oazapfts/runtime';
export function isHttpError(error) {
return error instanceof HttpError;
}

View file

@ -0,0 +1,18 @@
export * from './fetch-client.js';
export * from './fetch-errors.js';
export interface InitOptions {
baseUrl: string;
apiKey: string;
headers?: Record<string, string>;
}
export declare const init: ({ baseUrl, apiKey, headers }: InitOptions) => void;
export declare const getBaseUrl: () => string;
export declare const setBaseUrl: (baseUrl: string) => void;
export declare const setApiKey: (apiKey: string) => void;
export declare const setHeader: (key: string, value: string) => void;
export declare const setHeaders: (headers: Record<string, string>) => void;
export declare const getAssetOriginalPath: (id: string) => string;
export declare const getAssetThumbnailPath: (id: string) => string;
export declare const getAssetPlaybackPath: (id: string) => string;
export declare const getUserProfileImagePath: (userId: string) => string;
export declare const getPeopleThumbnailPath: (personId: string) => string;

View file

@ -0,0 +1,40 @@
import { defaults } from './fetch-client.js';
export * from './fetch-client.js';
export * from './fetch-errors.js';
export const init = ({ baseUrl, apiKey, headers }) => {
setBaseUrl(baseUrl);
setApiKey(apiKey);
if (headers) {
setHeaders(headers);
}
};
export const getBaseUrl = () => defaults.baseUrl;
export const setBaseUrl = (baseUrl) => {
defaults.baseUrl = baseUrl;
};
export const setApiKey = (apiKey) => {
defaults.headers = defaults.headers || {};
defaults.headers['x-api-key'] = apiKey;
};
export const setHeader = (key, value) => {
assertNoApiKey(key);
defaults.headers = defaults.headers || {};
defaults.headers[key] = value;
};
export const setHeaders = (headers) => {
defaults.headers = defaults.headers || {};
for (const [key, value] of Object.entries(headers)) {
assertNoApiKey(key);
defaults.headers[key] = value;
}
};
const assertNoApiKey = (headerKey) => {
if (headerKey.toLowerCase() === 'x-api-key') {
throw new Error('The API key header can only be set using setApiKey().');
}
};
export const getAssetOriginalPath = (id) => `/assets/${id}/original`;
export const getAssetThumbnailPath = (id) => `/assets/${id}/thumbnail`;
export const getAssetPlaybackPath = (id) => `/assets/${id}/video/playback`;
export const getUserProfileImagePath = (userId) => `/users/${userId}/profile-image`;
export const getPeopleThumbnailPath = (personId) => `/people/${personId}/thumbnail`;