@freqhole/api-client 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/codegen/routes.ts +1 -0
- package/src/codegen/schema.ts +37 -2
- package/src/domains/video.ts +12 -0
- package/src/permissions.ts +13 -3
package/package.json
CHANGED
package/src/codegen/routes.ts
CHANGED
|
@@ -261,6 +261,7 @@ export const routes = {
|
|
|
261
261
|
query_video_series: { method: 'POST', path: '/api/video/series/query', req: s.QueryParamsSchema, resp: s.SeriesQueryResultSchema, auth: { type: 'authenticated' } as const },
|
|
262
262
|
query_videos: { method: 'POST', path: '/api/video/videos/query', req: s.QueryVideosRequestSchema, resp: s.VideosQueryResultSchema, auth: { type: 'authenticated' } as const },
|
|
263
263
|
recently_added_videos: { method: 'POST', path: '/api/video/relations/recently-added-videos', req: s.RecentlyAddedVideosRequestSchema, resp: s.RecentlyAddedVideosResponseSchema, auth: { type: 'authenticated' } as const },
|
|
264
|
+
reprocess_video: { method: 'POST', path: '/api/video/videos/reprocess', req: s.ReprocessVideoRequestSchema, resp: s.ReprocessVideoResultSchema, auth: { type: 'role', role: 'admin' } as const },
|
|
264
265
|
sync_video_by_blake3: { method: 'POST', path: '/api/sync/video-by-blake3', req: s.SyncVideoByBlake3RequestSchema, resp: s.SyncVideoByBlake3ResponseSchema, auth: { type: 'role', role: 'member' } as const },
|
|
265
266
|
unassigned_videos: { method: 'POST', path: '/api/video/relations/unassigned-videos', req: s.UnassignedVideosRequestSchema, resp: s.UnassignedVideosResponseSchema, auth: { type: 'authenticated' } as const },
|
|
266
267
|
update_video_season: { method: 'POST', path: '/api/video/seasons/update', req: s.UpdateVideoSeasonRequestSchema, resp: s.VideoSeasonSchema, auth: { type: 'role', role: 'admin' } as const },
|
package/src/codegen/schema.ts
CHANGED
|
@@ -2340,6 +2340,8 @@ export const FavoriteItemSchema = z.union([z.intersection(z.object({
|
|
|
2340
2340
|
title: z.string(),
|
|
2341
2341
|
description: z.string().nullish(),
|
|
2342
2342
|
is_public: z.number(),
|
|
2343
|
+
collaborative: z.number(),
|
|
2344
|
+
private: z.number(),
|
|
2343
2345
|
images: z.array(z.object({
|
|
2344
2346
|
blob_id: z.string(),
|
|
2345
2347
|
is_primary: z.number(),
|
|
@@ -2357,6 +2359,7 @@ export const FavoriteItemSchema = z.union([z.intersection(z.object({
|
|
|
2357
2359
|
deleted_by: z.string().nullish(),
|
|
2358
2360
|
created_by: z.string().nullish(),
|
|
2359
2361
|
updated_by: z.string().nullish(),
|
|
2362
|
+
created_by_username: z.string().nullish(),
|
|
2360
2363
|
song_count: z.number()
|
|
2361
2364
|
}),
|
|
2362
2365
|
song_count: z.number(),
|
|
@@ -2420,6 +2423,8 @@ export const FavoritePlaylistResultSchema = z.object({
|
|
|
2420
2423
|
title: z.string(),
|
|
2421
2424
|
description: z.string().nullish(),
|
|
2422
2425
|
is_public: z.number(),
|
|
2426
|
+
collaborative: z.number(),
|
|
2427
|
+
private: z.number(),
|
|
2423
2428
|
images: z.array(z.object({
|
|
2424
2429
|
blob_id: z.string(),
|
|
2425
2430
|
is_primary: z.number(),
|
|
@@ -2437,6 +2442,7 @@ export const FavoritePlaylistResultSchema = z.object({
|
|
|
2437
2442
|
deleted_by: z.string().nullish(),
|
|
2438
2443
|
created_by: z.string().nullish(),
|
|
2439
2444
|
updated_by: z.string().nullish(),
|
|
2445
|
+
created_by_username: z.string().nullish(),
|
|
2440
2446
|
song_count: z.number()
|
|
2441
2447
|
}),
|
|
2442
2448
|
song_count: z.number(),
|
|
@@ -3630,6 +3636,8 @@ export const ListFavoritesResponseSchema = z.object({
|
|
|
3630
3636
|
title: z.string(),
|
|
3631
3637
|
description: z.string().nullish(),
|
|
3632
3638
|
is_public: z.number(),
|
|
3639
|
+
collaborative: z.number(),
|
|
3640
|
+
private: z.number(),
|
|
3633
3641
|
images: z.array(z.object({
|
|
3634
3642
|
blob_id: z.string(),
|
|
3635
3643
|
is_primary: z.number(),
|
|
@@ -3647,6 +3655,7 @@ export const ListFavoritesResponseSchema = z.object({
|
|
|
3647
3655
|
deleted_by: z.string().nullish(),
|
|
3648
3656
|
created_by: z.string().nullish(),
|
|
3649
3657
|
updated_by: z.string().nullish(),
|
|
3658
|
+
created_by_username: z.string().nullish(),
|
|
3650
3659
|
song_count: z.number()
|
|
3651
3660
|
}),
|
|
3652
3661
|
song_count: z.number(),
|
|
@@ -4628,6 +4637,8 @@ export const PlaylistSchema = z.object({
|
|
|
4628
4637
|
title: z.string(),
|
|
4629
4638
|
description: z.string().nullish(),
|
|
4630
4639
|
is_public: z.number(),
|
|
4640
|
+
collaborative: z.number(),
|
|
4641
|
+
private: z.number(),
|
|
4631
4642
|
images: z.array(z.object({
|
|
4632
4643
|
blob_id: z.string(),
|
|
4633
4644
|
is_primary: z.number(),
|
|
@@ -4645,6 +4656,7 @@ export const PlaylistSchema = z.object({
|
|
|
4645
4656
|
deleted_by: z.string().nullish(),
|
|
4646
4657
|
created_by: z.string().nullish(),
|
|
4647
4658
|
updated_by: z.string().nullish(),
|
|
4659
|
+
created_by_username: z.string().nullish(),
|
|
4648
4660
|
song_count: z.number()
|
|
4649
4661
|
});
|
|
4650
4662
|
export type Playlist = z.infer<typeof PlaylistSchema>;
|
|
@@ -4672,6 +4684,8 @@ export const PlaylistQueryResultSchema = z.object({
|
|
|
4672
4684
|
title: z.string(),
|
|
4673
4685
|
description: z.string().nullish(),
|
|
4674
4686
|
is_public: z.number(),
|
|
4687
|
+
collaborative: z.number(),
|
|
4688
|
+
private: z.number(),
|
|
4675
4689
|
images: z.array(z.object({
|
|
4676
4690
|
blob_id: z.string(),
|
|
4677
4691
|
is_primary: z.number(),
|
|
@@ -4689,6 +4703,7 @@ export const PlaylistQueryResultSchema = z.object({
|
|
|
4689
4703
|
deleted_by: z.string().nullish(),
|
|
4690
4704
|
created_by: z.string().nullish(),
|
|
4691
4705
|
updated_by: z.string().nullish(),
|
|
4706
|
+
created_by_username: z.string().nullish(),
|
|
4692
4707
|
song_count: z.number()
|
|
4693
4708
|
}),
|
|
4694
4709
|
song_count: z.number(),
|
|
@@ -5009,6 +5024,8 @@ export const PlaylistsQueryResultSchema = z.object({
|
|
|
5009
5024
|
title: z.string(),
|
|
5010
5025
|
description: z.string().nullish(),
|
|
5011
5026
|
is_public: z.number(),
|
|
5027
|
+
collaborative: z.number(),
|
|
5028
|
+
private: z.number(),
|
|
5012
5029
|
images: z.array(z.object({
|
|
5013
5030
|
blob_id: z.string(),
|
|
5014
5031
|
is_primary: z.number(),
|
|
@@ -5026,6 +5043,7 @@ export const PlaylistsQueryResultSchema = z.object({
|
|
|
5026
5043
|
deleted_by: z.string().nullish(),
|
|
5027
5044
|
created_by: z.string().nullish(),
|
|
5028
5045
|
updated_by: z.string().nullish(),
|
|
5046
|
+
created_by_username: z.string().nullish(),
|
|
5029
5047
|
song_count: z.number()
|
|
5030
5048
|
}),
|
|
5031
5049
|
song_count: z.number(),
|
|
@@ -5270,7 +5288,9 @@ export const QueryParamsSchema = z.object({
|
|
|
5270
5288
|
min_rating: z.number().nullish(),
|
|
5271
5289
|
mb_lookup_status: z.array(z.string()).nullish(),
|
|
5272
5290
|
pending_review: z.boolean().nullish(),
|
|
5273
|
-
|
|
5291
|
+
own_or_collaborative_only: z.boolean().nullish(),
|
|
5292
|
+
caller_is_admin: z.boolean().nullish(),
|
|
5293
|
+
caller_user_id: z.string().nullish()
|
|
5274
5294
|
});
|
|
5275
5295
|
export type QueryParams = z.infer<typeof QueryParamsSchema>;
|
|
5276
5296
|
|
|
@@ -5320,7 +5340,9 @@ export const QueryVideosRequestSchema = z.object({
|
|
|
5320
5340
|
min_rating: z.number().nullish(),
|
|
5321
5341
|
mb_lookup_status: z.array(z.string()).nullish(),
|
|
5322
5342
|
pending_review: z.boolean().nullish(),
|
|
5323
|
-
|
|
5343
|
+
own_or_collaborative_only: z.boolean().nullish(),
|
|
5344
|
+
caller_is_admin: z.boolean().nullish(),
|
|
5345
|
+
caller_user_id: z.string().nullish()
|
|
5324
5346
|
}),
|
|
5325
5347
|
series_id: z.string().nullish(),
|
|
5326
5348
|
season_id: z.string().nullish(),
|
|
@@ -5887,6 +5909,17 @@ export const ReplaceAlbumsTagsRequestSchema = z.object({
|
|
|
5887
5909
|
});
|
|
5888
5910
|
export type ReplaceAlbumsTagsRequest = z.infer<typeof ReplaceAlbumsTagsRequestSchema>;
|
|
5889
5911
|
|
|
5912
|
+
export const ReprocessVideoRequestSchema = z.object({
|
|
5913
|
+
id: z.string()
|
|
5914
|
+
});
|
|
5915
|
+
export type ReprocessVideoRequest = z.infer<typeof ReprocessVideoRequestSchema>;
|
|
5916
|
+
|
|
5917
|
+
export const ReprocessVideoResultSchema = z.object({
|
|
5918
|
+
video_id: z.string(),
|
|
5919
|
+
job_id: z.string().nullish()
|
|
5920
|
+
});
|
|
5921
|
+
export type ReprocessVideoResult = z.infer<typeof ReprocessVideoResultSchema>;
|
|
5922
|
+
|
|
5890
5923
|
export const RequeryEnrichmentRequestSchema = z.object({
|
|
5891
5924
|
album_id: z.string(),
|
|
5892
5925
|
source: z.union([z.literal('Mb'), z.literal('Lastfm'), z.literal('Audiodb')]),
|
|
@@ -7407,6 +7440,8 @@ export const UpdatePlaylistRequestSchema = z.object({
|
|
|
7407
7440
|
title: z.string().nullish(),
|
|
7408
7441
|
description: z.string().nullish(),
|
|
7409
7442
|
is_public: z.boolean().nullish(),
|
|
7443
|
+
collaborative: z.boolean().nullish(),
|
|
7444
|
+
private: z.boolean().nullish(),
|
|
7410
7445
|
entity_urls: z.array(z.object({
|
|
7411
7446
|
id: z.string().nullish(),
|
|
7412
7447
|
name: z.string().nullish(),
|
package/src/domains/video.ts
CHANGED
|
@@ -167,6 +167,18 @@ export function createVideoMethods(call: CallFn) {
|
|
|
167
167
|
);
|
|
168
168
|
},
|
|
169
169
|
|
|
170
|
+
reprocessVideo: (params: s.ReprocessVideoRequest) => {
|
|
171
|
+
return call(
|
|
172
|
+
"video",
|
|
173
|
+
"reprocess_video",
|
|
174
|
+
routes.video.reprocess_video.resp,
|
|
175
|
+
routes.video.reprocess_video.req,
|
|
176
|
+
routes.video.reprocess_video.method,
|
|
177
|
+
routes.video.reprocess_video.path,
|
|
178
|
+
params,
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
|
|
170
182
|
// playback progress
|
|
171
183
|
upsertPlaybackProgress: (params: s.UpsertPlaybackProgressRequest) => {
|
|
172
184
|
return call(
|
package/src/permissions.ts
CHANGED
|
@@ -120,13 +120,17 @@ export function canUpdatePlaylist(
|
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* check if user can add songs to a playlist.
|
|
123
|
-
* playlists use OwnerOr(Admin)
|
|
123
|
+
* playlists use OwnerOr(Admin) - collaborative playlists additionally
|
|
124
|
+
* allow any authenticated user, mirroring the backend's
|
|
125
|
+
* `require_owner_or_collaborative_or_scope`.
|
|
124
126
|
*/
|
|
125
127
|
export function canAddSongsToPlaylist(
|
|
126
128
|
userId: string,
|
|
127
129
|
playlistOwnerId: string | null,
|
|
128
130
|
userRole: UserRoleName,
|
|
131
|
+
isCollaborative = false,
|
|
129
132
|
): boolean {
|
|
133
|
+
if (isCollaborative) return true;
|
|
130
134
|
const auth = routes.music.add_songs_to_playlist.auth;
|
|
131
135
|
if (auth.type === "owner_or") {
|
|
132
136
|
return canAccessOwnerOr(userId, playlistOwnerId, userRole, auth.role);
|
|
@@ -136,13 +140,16 @@ export function canAddSongsToPlaylist(
|
|
|
136
140
|
|
|
137
141
|
/**
|
|
138
142
|
* check if user can remove songs from a playlist.
|
|
139
|
-
* playlists use OwnerOr(Admin)
|
|
143
|
+
* playlists use OwnerOr(Admin) - collaborative playlists additionally
|
|
144
|
+
* allow any authenticated user.
|
|
140
145
|
*/
|
|
141
146
|
export function canRemoveSongsFromPlaylist(
|
|
142
147
|
userId: string,
|
|
143
148
|
playlistOwnerId: string | null,
|
|
144
149
|
userRole: UserRoleName,
|
|
150
|
+
isCollaborative = false,
|
|
145
151
|
): boolean {
|
|
152
|
+
if (isCollaborative) return true;
|
|
146
153
|
const auth = routes.music.remove_songs_from_playlist.auth;
|
|
147
154
|
if (auth.type === "owner_or") {
|
|
148
155
|
return canAccessOwnerOr(userId, playlistOwnerId, userRole, auth.role);
|
|
@@ -402,13 +409,16 @@ export function canAccessMusicBrainz(userRole: UserRoleName): boolean {
|
|
|
402
409
|
|
|
403
410
|
/**
|
|
404
411
|
* check if user can reorder songs in a playlist.
|
|
405
|
-
* playlists use OwnerOr(Admin)
|
|
412
|
+
* playlists use OwnerOr(Admin) - collaborative playlists additionally
|
|
413
|
+
* allow any authenticated user.
|
|
406
414
|
*/
|
|
407
415
|
export function canReorderPlaylistSongs(
|
|
408
416
|
userId: string,
|
|
409
417
|
playlistOwnerId: string | null,
|
|
410
418
|
userRole: UserRoleName,
|
|
419
|
+
isCollaborative = false,
|
|
411
420
|
): boolean {
|
|
421
|
+
if (isCollaborative) return true;
|
|
412
422
|
const auth = routes.music.reorder_playlist_songs.auth;
|
|
413
423
|
if (auth.type === "owner_or") {
|
|
414
424
|
return canAccessOwnerOr(userId, playlistOwnerId, userRole, auth.role);
|