@unisource/sdk 0.2.0 → 0.3.1
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/README.md +55 -23
- package/dist/index.d.mts +623 -21
- package/dist/index.mjs +438 -38
- package/package.json +8 -4
- package/src/client.ts +474 -233
- package/src/fileRecords.ts +99 -87
- package/src/folders.ts +97 -84
- package/src/index.ts +198 -106
- package/src/mainStorage.ts +51 -0
- package/src/primitives.ts +30 -25
- package/src/releases.ts +132 -0
- package/src/services.ts +137 -69
- package/src/shareLinks.ts +93 -0
- package/src/uploads.ts +99 -90
- package/dist/index.d.ts +0 -478
- package/src/uploadDestination.ts +0 -4
package/src/index.ts
CHANGED
|
@@ -1,106 +1,198 @@
|
|
|
1
|
-
// ─── Primitives ───────────────────────────────────────────────────────────────
|
|
2
|
-
export {
|
|
3
|
-
nonEmptyString,
|
|
4
|
-
positiveInt,
|
|
5
|
-
unixTimestamp,
|
|
6
|
-
uploadDestinationSchema,
|
|
7
|
-
uploadStatusSchema,
|
|
8
|
-
apiErrorSchema,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
export
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
// ─── Primitives ───────────────────────────────────────────────────────────────
|
|
2
|
+
export {
|
|
3
|
+
nonEmptyString,
|
|
4
|
+
positiveInt,
|
|
5
|
+
unixTimestamp,
|
|
6
|
+
uploadDestinationSchema,
|
|
7
|
+
uploadStatusSchema,
|
|
8
|
+
apiErrorSchema,
|
|
9
|
+
FILES_DEFAULT_LIMIT,
|
|
10
|
+
FILES_MAX_LIMIT,
|
|
11
|
+
} from './primitives';
|
|
12
|
+
export type { UploadDestination, UploadStatus, ApiError } from './primitives';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// ─── Upload ───────────────────────────────────────────────────────────────────
|
|
16
|
+
export {
|
|
17
|
+
uploadR2InitRequestSchema,
|
|
18
|
+
uploadR2InitResponseSchema,
|
|
19
|
+
uploadAppwriteInitRequestSchema,
|
|
20
|
+
uploadAppwriteInitResponseSchema,
|
|
21
|
+
uploadLifecycleRequestSchema,
|
|
22
|
+
uploadCompleteResponseSchema,
|
|
23
|
+
uploadFailResponseSchema,
|
|
24
|
+
uploadRecordSchema,
|
|
25
|
+
uploadsListResponseSchema,
|
|
26
|
+
uploadRecordDetailResponseSchema,
|
|
27
|
+
} from './uploads';
|
|
28
|
+
export type {
|
|
29
|
+
UploadR2InitRequest,
|
|
30
|
+
UploadR2InitResponse,
|
|
31
|
+
UploadAppwriteInitRequest,
|
|
32
|
+
UploadAppwriteInitResponse,
|
|
33
|
+
UploadLifecycleRequest,
|
|
34
|
+
UploadCompleteResponse,
|
|
35
|
+
UploadFailResponse,
|
|
36
|
+
UploadRecord,
|
|
37
|
+
UploadsListResponse,
|
|
38
|
+
UploadRecordDetailResponse,
|
|
39
|
+
} from './uploads';
|
|
40
|
+
|
|
41
|
+
// ─── File Records ─────────────────────────────────────────────────────────────
|
|
42
|
+
export {
|
|
43
|
+
fileRecordSchema,
|
|
44
|
+
fileRecordsListQuerySchema,
|
|
45
|
+
fileRecordsListResponseSchema,
|
|
46
|
+
fileRecordDetailResponseSchema,
|
|
47
|
+
fileMoveRequestSchema,
|
|
48
|
+
fileDownloadUrlResponseSchema,
|
|
49
|
+
fileDeleteResponseSchema,
|
|
50
|
+
fileRestoreResponseSchema,
|
|
51
|
+
fileUpdateRequestSchema,
|
|
52
|
+
fileUpdateResponseSchema,
|
|
53
|
+
} from './fileRecords';
|
|
54
|
+
export type {
|
|
55
|
+
FileRecord,
|
|
56
|
+
FileRecordsListQuery,
|
|
57
|
+
FileRecordsListResponse,
|
|
58
|
+
FileRecordDetailResponse,
|
|
59
|
+
FileMoveRequest,
|
|
60
|
+
FileDownloadUrlResponse,
|
|
61
|
+
FileDeleteResponse,
|
|
62
|
+
FileRestoreResponse,
|
|
63
|
+
FileUpdateRequest,
|
|
64
|
+
FileUpdateResponse,
|
|
65
|
+
} from './fileRecords';
|
|
66
|
+
|
|
67
|
+
// ─── Folders ─────────────────────────────────────────────────────────────────
|
|
68
|
+
export {
|
|
69
|
+
folderSchema,
|
|
70
|
+
folderListQuerySchema,
|
|
71
|
+
folderListResponseSchema,
|
|
72
|
+
folderDetailResponseSchema,
|
|
73
|
+
folderCreateRequestSchema,
|
|
74
|
+
folderCreateResponseSchema,
|
|
75
|
+
folderUpdateRequestSchema,
|
|
76
|
+
folderUpdateResponseSchema,
|
|
77
|
+
folderDeleteResponseSchema,
|
|
78
|
+
folderRestoreResponseSchema,
|
|
79
|
+
} from './folders';
|
|
80
|
+
export type {
|
|
81
|
+
Folder,
|
|
82
|
+
FolderListQuery,
|
|
83
|
+
FolderListResponse,
|
|
84
|
+
FolderDetailResponse,
|
|
85
|
+
FolderCreateRequest,
|
|
86
|
+
FolderCreateResponse,
|
|
87
|
+
FolderUpdateRequest,
|
|
88
|
+
FolderUpdateResponse,
|
|
89
|
+
FolderDeleteResponse,
|
|
90
|
+
FolderRestoreResponse,
|
|
91
|
+
} from './folders';
|
|
92
|
+
|
|
93
|
+
// ─── Services & Audit ─────────────────────────────────────────────────────────
|
|
94
|
+
export {
|
|
95
|
+
serviceSchema,
|
|
96
|
+
serviceDetailResponseSchema,
|
|
97
|
+
adminServiceUpdateRequestSchema,
|
|
98
|
+
adminServiceUpdateResponseSchema,
|
|
99
|
+
serviceUsageResponseSchema,
|
|
100
|
+
auditEventActionSchema,
|
|
101
|
+
auditEventSchema,
|
|
102
|
+
auditLogListQuerySchema,
|
|
103
|
+
auditLogListResponseSchema,
|
|
104
|
+
adminUserSchema,
|
|
105
|
+
adminUserListResponseSchema,
|
|
106
|
+
adminUserUpdateRequestSchema,
|
|
107
|
+
adminUserUpdateResponseSchema,
|
|
108
|
+
adminUserPasswordResetRequestSchema,
|
|
109
|
+
adminUserPasswordResetResponseSchema,
|
|
110
|
+
} from './services';
|
|
111
|
+
export type {
|
|
112
|
+
Service,
|
|
113
|
+
ServiceDetailResponse,
|
|
114
|
+
AdminServiceUpdateRequest,
|
|
115
|
+
AdminServiceUpdateResponse,
|
|
116
|
+
ServiceUsageResponse,
|
|
117
|
+
AuditEventAction,
|
|
118
|
+
AuditEvent,
|
|
119
|
+
AuditLogListQuery,
|
|
120
|
+
AuditLogListResponse,
|
|
121
|
+
AdminUser,
|
|
122
|
+
AdminUserListResponse,
|
|
123
|
+
AdminUserUpdateRequest,
|
|
124
|
+
AdminUserUpdateResponse,
|
|
125
|
+
AdminUserPasswordResetRequest,
|
|
126
|
+
AdminUserPasswordResetResponse,
|
|
127
|
+
} from './services';
|
|
128
|
+
|
|
129
|
+
// ─── Main Storage ─────────────────────────────────────────────────────────────
|
|
130
|
+
export * from './mainStorage';
|
|
131
|
+
|
|
132
|
+
// ─── Releases ───────────────────────────────────────────────────────────────
|
|
133
|
+
export {
|
|
134
|
+
releaseDTOSchema,
|
|
135
|
+
releaseUploadInitRequestSchema,
|
|
136
|
+
releaseUploadInitResponseSchema,
|
|
137
|
+
releaseUploadCompleteRequestSchema,
|
|
138
|
+
releaseUploadCompleteResponseSchema,
|
|
139
|
+
releaseUploadFailResponseSchema,
|
|
140
|
+
releasesListQuerySchema,
|
|
141
|
+
releasesListResponseSchema,
|
|
142
|
+
releaseUpdateRequestSchema,
|
|
143
|
+
releaseDeleteResponseSchema,
|
|
144
|
+
releaseSyncManifestSchema,
|
|
145
|
+
releaseSyncRequestSchema,
|
|
146
|
+
releaseSyncResultSchema,
|
|
147
|
+
releaseSyncResponseSchema,
|
|
148
|
+
} from './releases';
|
|
149
|
+
export type {
|
|
150
|
+
ReleaseDTO,
|
|
151
|
+
ReleaseUploadInitRequest,
|
|
152
|
+
ReleaseUploadInitResponse,
|
|
153
|
+
ReleaseUploadCompleteRequest,
|
|
154
|
+
ReleaseUploadCompleteResponse,
|
|
155
|
+
ReleaseUploadFailResponse,
|
|
156
|
+
ReleasesListQuery,
|
|
157
|
+
ReleasesListResponse,
|
|
158
|
+
ReleaseUpdateRequest,
|
|
159
|
+
ReleaseDeleteResponse,
|
|
160
|
+
ReleaseSyncManifest,
|
|
161
|
+
ReleaseSyncRequest,
|
|
162
|
+
ReleaseSyncResult,
|
|
163
|
+
ReleaseSyncResponse,
|
|
164
|
+
} from './releases';
|
|
165
|
+
|
|
166
|
+
// ─── Share Links ─────────────────────────────────────────────────────────────
|
|
167
|
+
export {
|
|
168
|
+
shareLinkSchema,
|
|
169
|
+
shareLinkCreateRequestSchema,
|
|
170
|
+
shareLinkUpdateRequestSchema,
|
|
171
|
+
shareLinkListResponseSchema,
|
|
172
|
+
shareLinkCreateResponseSchema,
|
|
173
|
+
shareLinkUpdateResponseSchema,
|
|
174
|
+
shareLinkDeleteResponseSchema,
|
|
175
|
+
publicFileAccessResponseSchema,
|
|
176
|
+
publicFileLockedResponseSchema,
|
|
177
|
+
} from './shareLinks';
|
|
178
|
+
export type {
|
|
179
|
+
ShareLink,
|
|
180
|
+
ShareLinkCreateRequest,
|
|
181
|
+
ShareLinkUpdateRequest,
|
|
182
|
+
ShareLinkListResponse,
|
|
183
|
+
ShareLinkCreateResponse,
|
|
184
|
+
ShareLinkUpdateResponse,
|
|
185
|
+
ShareLinkDeleteResponse,
|
|
186
|
+
PublicFileAccessResponse,
|
|
187
|
+
PublicFileLockedResponse,
|
|
188
|
+
} from './shareLinks';
|
|
189
|
+
|
|
190
|
+
// ─── HTTP Client ─────────────────────────────────────────────────────────────
|
|
191
|
+
export {
|
|
192
|
+
UnisourceClient,
|
|
193
|
+
UnisourceError,
|
|
194
|
+
UnisourceNetworkError,
|
|
195
|
+
getPublicFileInfo,
|
|
196
|
+
unlockPublicFile,
|
|
197
|
+
} from './client';
|
|
198
|
+
export type { UnisourceClientConfig } from './client';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FILES_MAX_LIMIT, nonEmptyString } from './primitives';
|
|
3
|
+
import { fileRecordSchema } from './fileRecords';
|
|
4
|
+
|
|
5
|
+
// ─── List ──────────────────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
export const mainStorageListQuerySchema = z.object({
|
|
8
|
+
limit: z.number().int().min(1).max(FILES_MAX_LIMIT).optional(),
|
|
9
|
+
cursor: nonEmptyString.optional(),
|
|
10
|
+
});
|
|
11
|
+
export type MainStorageListQuery = z.infer<typeof mainStorageListQuerySchema>;
|
|
12
|
+
|
|
13
|
+
export const mainStorageFileSchema = fileRecordSchema;
|
|
14
|
+
export type MainStorageFile = z.infer<typeof mainStorageFileSchema>;
|
|
15
|
+
|
|
16
|
+
export const mainStorageListResponseSchema = z.object({
|
|
17
|
+
items: z.array(mainStorageFileSchema),
|
|
18
|
+
next_cursor: z.string().nullable(),
|
|
19
|
+
});
|
|
20
|
+
export type MainStorageListResponse = z.infer<typeof mainStorageListResponseSchema>;
|
|
21
|
+
|
|
22
|
+
export const mainStorageDetailResponseSchema = mainStorageFileSchema;
|
|
23
|
+
export type MainStorageDetailResponse = z.infer<typeof mainStorageDetailResponseSchema>;
|
|
24
|
+
|
|
25
|
+
// ─── Rename ────────────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
export const mainStorageRenameRequestSchema = z.object({
|
|
28
|
+
filename: nonEmptyString.max(255),
|
|
29
|
+
});
|
|
30
|
+
export type MainStorageRenameRequest = z.infer<typeof mainStorageRenameRequestSchema>;
|
|
31
|
+
|
|
32
|
+
export const mainStorageRenameResponseSchema = z.object({
|
|
33
|
+
file: mainStorageFileSchema,
|
|
34
|
+
});
|
|
35
|
+
export type MainStorageRenameResponse = z.infer<typeof mainStorageRenameResponseSchema>;
|
|
36
|
+
|
|
37
|
+
// ─── Delete ────────────────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
export const mainStorageDeleteResponseSchema = z.object({
|
|
40
|
+
success: z.boolean(),
|
|
41
|
+
file_id: nonEmptyString,
|
|
42
|
+
});
|
|
43
|
+
export type MainStorageDeleteResponse = z.infer<typeof mainStorageDeleteResponseSchema>;
|
|
44
|
+
|
|
45
|
+
// ─── Restore ───────────────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
export const mainStorageRestoreResponseSchema = z.object({
|
|
48
|
+
success: z.boolean(),
|
|
49
|
+
file_id: nonEmptyString,
|
|
50
|
+
});
|
|
51
|
+
export type MainStorageRestoreResponse = z.infer<typeof mainStorageRestoreResponseSchema>;
|
package/src/primitives.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// ─── Primitives ─────────────────────────────────────────────────────────────
|
|
4
|
-
|
|
5
|
-
export const nonEmptyString = z.string().trim().min(1);
|
|
6
|
-
export const positiveInt = z.number().int().positive();
|
|
7
|
-
export const unixTimestamp = z.number().int().nonnegative();
|
|
8
|
-
|
|
9
|
-
// ───
|
|
10
|
-
|
|
11
|
-
export const
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
// ─── Upload
|
|
15
|
-
|
|
16
|
-
export const
|
|
17
|
-
export type
|
|
18
|
-
|
|
19
|
-
// ───
|
|
20
|
-
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// ─── Primitives ─────────────────────────────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
export const nonEmptyString = z.string().trim().min(1);
|
|
6
|
+
export const positiveInt = z.number().int().positive();
|
|
7
|
+
export const unixTimestamp = z.number().int().nonnegative();
|
|
8
|
+
|
|
9
|
+
// ─── Pagination constants ─────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
export const FILES_DEFAULT_LIMIT = 25;
|
|
12
|
+
export const FILES_MAX_LIMIT = 100;
|
|
13
|
+
|
|
14
|
+
// ─── Upload Destination ──────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
export const uploadDestinationSchema = z.enum(['r2', 'appwrite']);
|
|
17
|
+
export type UploadDestination = z.infer<typeof uploadDestinationSchema>;
|
|
18
|
+
|
|
19
|
+
// ─── Upload Status ────────────────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
export const uploadStatusSchema = z.enum(['pending', 'completed', 'failed']);
|
|
22
|
+
export type UploadStatus = z.infer<typeof uploadStatusSchema>;
|
|
23
|
+
|
|
24
|
+
// ─── API Error ────────────────────────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
export const apiErrorSchema = z.object({
|
|
27
|
+
error: nonEmptyString,
|
|
28
|
+
message: nonEmptyString,
|
|
29
|
+
});
|
|
30
|
+
export type ApiError = z.infer<typeof apiErrorSchema>;
|
package/src/releases.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { nonEmptyString, positiveInt, uploadStatusSchema } from './primitives';
|
|
3
|
+
|
|
4
|
+
const releaseIdSchema = z.string().trim().min(1).max(128);
|
|
5
|
+
const releaseNameSchema = z.string().trim().min(1).max(256);
|
|
6
|
+
const releaseFilenameSchema = z.string().trim().min(1).max(255);
|
|
7
|
+
const releaseTagsSchema = z.array(z.string().trim().min(1).max(64)).max(32);
|
|
8
|
+
const releaseNotesSchema = z.string().trim().max(10_000).nullable().optional();
|
|
9
|
+
const releaseR2KeySchema = z.string().trim().min(1).max(1024);
|
|
10
|
+
|
|
11
|
+
// ─── Release DTO ─────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export const releaseDTOSchema = z.object({
|
|
14
|
+
id: nonEmptyString,
|
|
15
|
+
service_id: nonEmptyString,
|
|
16
|
+
name: nonEmptyString,
|
|
17
|
+
size: z.number().int().nonnegative(),
|
|
18
|
+
r2_key: nonEmptyString,
|
|
19
|
+
tags: z.array(nonEmptyString),
|
|
20
|
+
notes: z.string().nullable(),
|
|
21
|
+
force_update: z.boolean(),
|
|
22
|
+
uploaded_by: nonEmptyString,
|
|
23
|
+
upload_status: uploadStatusSchema,
|
|
24
|
+
created_at: nonEmptyString,
|
|
25
|
+
});
|
|
26
|
+
export type ReleaseDTO = z.infer<typeof releaseDTOSchema>;
|
|
27
|
+
|
|
28
|
+
// ─── Upload Lifecycle ───────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
export const releaseUploadInitRequestSchema = z.object({
|
|
31
|
+
name: releaseNameSchema,
|
|
32
|
+
filename: releaseFilenameSchema,
|
|
33
|
+
tags: releaseTagsSchema.optional().default([]),
|
|
34
|
+
notes: releaseNotesSchema,
|
|
35
|
+
force_update: z.boolean().optional().default(false),
|
|
36
|
+
});
|
|
37
|
+
export type ReleaseUploadInitRequest = z.input<typeof releaseUploadInitRequestSchema>;
|
|
38
|
+
|
|
39
|
+
export const releaseUploadInitResponseSchema = z.object({
|
|
40
|
+
release_id: nonEmptyString,
|
|
41
|
+
presigned_url: z.string().url(),
|
|
42
|
+
r2_key: nonEmptyString,
|
|
43
|
+
expires_at: positiveInt,
|
|
44
|
+
});
|
|
45
|
+
export type ReleaseUploadInitResponse = z.infer<typeof releaseUploadInitResponseSchema>;
|
|
46
|
+
|
|
47
|
+
export const releaseUploadCompleteRequestSchema = z.object({
|
|
48
|
+
release_id: releaseIdSchema,
|
|
49
|
+
size: z.number().int().nonnegative(),
|
|
50
|
+
});
|
|
51
|
+
export type ReleaseUploadCompleteRequest = z.infer<typeof releaseUploadCompleteRequestSchema>;
|
|
52
|
+
|
|
53
|
+
export const releaseUploadCompleteResponseSchema = z.object({
|
|
54
|
+
success: z.literal(true),
|
|
55
|
+
release_id: nonEmptyString,
|
|
56
|
+
status: z.literal('completed'),
|
|
57
|
+
});
|
|
58
|
+
export type ReleaseUploadCompleteResponse = z.infer<typeof releaseUploadCompleteResponseSchema>;
|
|
59
|
+
|
|
60
|
+
export const releaseUploadFailResponseSchema = z.object({
|
|
61
|
+
success: z.literal(true),
|
|
62
|
+
release_id: nonEmptyString,
|
|
63
|
+
status: z.literal('failed'),
|
|
64
|
+
});
|
|
65
|
+
export type ReleaseUploadFailResponse = z.infer<typeof releaseUploadFailResponseSchema>;
|
|
66
|
+
|
|
67
|
+
// ─── List ───────────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
export const releasesListQuerySchema = z.object({
|
|
70
|
+
limit: z.number().int().positive().max(100).optional(),
|
|
71
|
+
cursor: nonEmptyString.optional(),
|
|
72
|
+
});
|
|
73
|
+
export type ReleasesListQuery = z.infer<typeof releasesListQuerySchema>;
|
|
74
|
+
|
|
75
|
+
export const releasesListResponseSchema = z.object({
|
|
76
|
+
items: z.array(releaseDTOSchema),
|
|
77
|
+
next_cursor: z.string().nullable(),
|
|
78
|
+
});
|
|
79
|
+
export type ReleasesListResponse = z.infer<typeof releasesListResponseSchema>;
|
|
80
|
+
|
|
81
|
+
// ─── Update ─────────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
export const releaseUpdateRequestSchema = z
|
|
84
|
+
.object({
|
|
85
|
+
name: releaseNameSchema.optional(),
|
|
86
|
+
tags: releaseTagsSchema.optional(),
|
|
87
|
+
notes: releaseNotesSchema,
|
|
88
|
+
force_update: z.boolean().optional(),
|
|
89
|
+
})
|
|
90
|
+
.refine((body) => Object.values(body).some((value) => value !== undefined), {
|
|
91
|
+
message: 'At least one field must be provided',
|
|
92
|
+
});
|
|
93
|
+
export type ReleaseUpdateRequest = z.infer<typeof releaseUpdateRequestSchema>;
|
|
94
|
+
|
|
95
|
+
// ─── Delete ─────────────────────────────────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
export const releaseDeleteResponseSchema = z.object({
|
|
98
|
+
success: z.literal(true),
|
|
99
|
+
release_id: nonEmptyString,
|
|
100
|
+
});
|
|
101
|
+
export type ReleaseDeleteResponse = z.infer<typeof releaseDeleteResponseSchema>;
|
|
102
|
+
|
|
103
|
+
// ─── Sync ───────────────────────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
export const releaseSyncManifestSchema = z.object({
|
|
106
|
+
id: releaseIdSchema.optional(),
|
|
107
|
+
name: releaseNameSchema,
|
|
108
|
+
r2_key: releaseR2KeySchema,
|
|
109
|
+
size: z.number().int().nonnegative(),
|
|
110
|
+
tags: releaseTagsSchema.optional().default([]),
|
|
111
|
+
notes: releaseNotesSchema,
|
|
112
|
+
force_update: z.boolean().optional().default(false),
|
|
113
|
+
});
|
|
114
|
+
export type ReleaseSyncManifest = z.input<typeof releaseSyncManifestSchema>;
|
|
115
|
+
|
|
116
|
+
export const releaseSyncRequestSchema = z.object({
|
|
117
|
+
releases: z.array(releaseSyncManifestSchema).min(1).max(100),
|
|
118
|
+
});
|
|
119
|
+
export type ReleaseSyncRequest = z.input<typeof releaseSyncRequestSchema>;
|
|
120
|
+
|
|
121
|
+
export const releaseSyncResultSchema = z.object({
|
|
122
|
+
release_id: nonEmptyString,
|
|
123
|
+
success: z.boolean(),
|
|
124
|
+
status: uploadStatusSchema,
|
|
125
|
+
});
|
|
126
|
+
export type ReleaseSyncResult = z.infer<typeof releaseSyncResultSchema>;
|
|
127
|
+
|
|
128
|
+
export const releaseSyncResponseSchema = z.object({
|
|
129
|
+
synced: z.number().int().nonnegative(),
|
|
130
|
+
results: z.array(releaseSyncResultSchema),
|
|
131
|
+
});
|
|
132
|
+
export type ReleaseSyncResponse = z.infer<typeof releaseSyncResponseSchema>;
|