@sovrasdk/contracts 0.1.0
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/LICENSE +661 -0
- package/README.md +15 -0
- package/dist/entities.d.ts +380 -0
- package/dist/entities.d.ts.map +1 -0
- package/dist/entities.js +119 -0
- package/dist/entities.js.map +1 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +74 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const cidSchema: z.ZodString;
|
|
3
|
+
export declare const contentVisibilitySchema: z.ZodEnum<["public", "private"]>;
|
|
4
|
+
export type ContentVisibility = z.infer<typeof contentVisibilitySchema>;
|
|
5
|
+
export declare const encMetaSchema: z.ZodObject<{
|
|
6
|
+
algo: z.ZodLiteral<"AES-256-GCM">;
|
|
7
|
+
iv: z.ZodString;
|
|
8
|
+
wrappedKey: z.ZodString;
|
|
9
|
+
chunkSize: z.ZodNumber;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
algo: "AES-256-GCM";
|
|
12
|
+
iv: string;
|
|
13
|
+
wrappedKey: string;
|
|
14
|
+
chunkSize: number;
|
|
15
|
+
}, {
|
|
16
|
+
algo: "AES-256-GCM";
|
|
17
|
+
iv: string;
|
|
18
|
+
wrappedKey: string;
|
|
19
|
+
chunkSize: number;
|
|
20
|
+
}>;
|
|
21
|
+
export type EncMeta = z.infer<typeof encMetaSchema>;
|
|
22
|
+
export declare const fileObjectSchema: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
parentPath: z.ZodString;
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
cid: z.ZodString;
|
|
27
|
+
size: z.ZodNumber;
|
|
28
|
+
mime: z.ZodString;
|
|
29
|
+
visibility: z.ZodEnum<["public", "private"]>;
|
|
30
|
+
encMeta: z.ZodNullable<z.ZodObject<{
|
|
31
|
+
algo: z.ZodLiteral<"AES-256-GCM">;
|
|
32
|
+
iv: z.ZodString;
|
|
33
|
+
wrappedKey: z.ZodString;
|
|
34
|
+
chunkSize: z.ZodNumber;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
algo: "AES-256-GCM";
|
|
37
|
+
iv: string;
|
|
38
|
+
wrappedKey: string;
|
|
39
|
+
chunkSize: number;
|
|
40
|
+
}, {
|
|
41
|
+
algo: "AES-256-GCM";
|
|
42
|
+
iv: string;
|
|
43
|
+
wrappedKey: string;
|
|
44
|
+
chunkSize: number;
|
|
45
|
+
}>>;
|
|
46
|
+
thumbCid: z.ZodNullable<z.ZodString>;
|
|
47
|
+
createdAt: z.ZodNumber;
|
|
48
|
+
updatedAt: z.ZodNumber;
|
|
49
|
+
trashedAt: z.ZodNullable<z.ZodNumber>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
id: string;
|
|
52
|
+
parentPath: string;
|
|
53
|
+
name: string;
|
|
54
|
+
cid: string;
|
|
55
|
+
size: number;
|
|
56
|
+
mime: string;
|
|
57
|
+
visibility: "public" | "private";
|
|
58
|
+
encMeta: {
|
|
59
|
+
algo: "AES-256-GCM";
|
|
60
|
+
iv: string;
|
|
61
|
+
wrappedKey: string;
|
|
62
|
+
chunkSize: number;
|
|
63
|
+
} | null;
|
|
64
|
+
thumbCid: string | null;
|
|
65
|
+
createdAt: number;
|
|
66
|
+
updatedAt: number;
|
|
67
|
+
trashedAt: number | null;
|
|
68
|
+
}, {
|
|
69
|
+
id: string;
|
|
70
|
+
parentPath: string;
|
|
71
|
+
name: string;
|
|
72
|
+
cid: string;
|
|
73
|
+
size: number;
|
|
74
|
+
mime: string;
|
|
75
|
+
visibility: "public" | "private";
|
|
76
|
+
encMeta: {
|
|
77
|
+
algo: "AES-256-GCM";
|
|
78
|
+
iv: string;
|
|
79
|
+
wrappedKey: string;
|
|
80
|
+
chunkSize: number;
|
|
81
|
+
} | null;
|
|
82
|
+
thumbCid: string | null;
|
|
83
|
+
createdAt: number;
|
|
84
|
+
updatedAt: number;
|
|
85
|
+
trashedAt: number | null;
|
|
86
|
+
}>;
|
|
87
|
+
export type FileObject = z.infer<typeof fileObjectSchema>;
|
|
88
|
+
export declare const folderSchema: z.ZodObject<{
|
|
89
|
+
id: z.ZodString;
|
|
90
|
+
path: z.ZodString;
|
|
91
|
+
name: z.ZodString;
|
|
92
|
+
createdAt: z.ZodNumber;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
path: string;
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
createdAt: number;
|
|
98
|
+
}, {
|
|
99
|
+
path: string;
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
createdAt: number;
|
|
103
|
+
}>;
|
|
104
|
+
export type Folder = z.infer<typeof folderSchema>;
|
|
105
|
+
export declare const albumSchema: z.ZodObject<{
|
|
106
|
+
id: z.ZodString;
|
|
107
|
+
name: z.ZodString;
|
|
108
|
+
createdAt: z.ZodNumber;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
id: string;
|
|
111
|
+
name: string;
|
|
112
|
+
createdAt: number;
|
|
113
|
+
}, {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
createdAt: number;
|
|
117
|
+
}>;
|
|
118
|
+
export type Album = z.infer<typeof albumSchema>;
|
|
119
|
+
export declare const shareModeSchema: z.ZodEnum<["public", "restricted"]>;
|
|
120
|
+
export declare const shareLinkSchema: z.ZodObject<{
|
|
121
|
+
token: z.ZodString;
|
|
122
|
+
targetType: z.ZodEnum<["file", "album"]>;
|
|
123
|
+
targetId: z.ZodString;
|
|
124
|
+
mode: z.ZodEnum<["public", "restricted"]>;
|
|
125
|
+
allowedIdentities: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
126
|
+
expiresAt: z.ZodNullable<z.ZodNumber>;
|
|
127
|
+
revoked: z.ZodBoolean;
|
|
128
|
+
createdAt: z.ZodNumber;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
createdAt: number;
|
|
131
|
+
token: string;
|
|
132
|
+
targetType: "file" | "album";
|
|
133
|
+
targetId: string;
|
|
134
|
+
mode: "public" | "restricted";
|
|
135
|
+
allowedIdentities: string[];
|
|
136
|
+
expiresAt: number | null;
|
|
137
|
+
revoked: boolean;
|
|
138
|
+
}, {
|
|
139
|
+
createdAt: number;
|
|
140
|
+
token: string;
|
|
141
|
+
targetType: "file" | "album";
|
|
142
|
+
targetId: string;
|
|
143
|
+
mode: "public" | "restricted";
|
|
144
|
+
expiresAt: number | null;
|
|
145
|
+
revoked: boolean;
|
|
146
|
+
allowedIdentities?: string[] | undefined;
|
|
147
|
+
}>;
|
|
148
|
+
export type ShareLink = z.infer<typeof shareLinkSchema>;
|
|
149
|
+
export declare const permissionSchema: z.ZodEnum<["storage:read", "storage:write", "proxy:manage", "net:outbound:dns", "net:outbound:ssh", "net:outbound:http"]>;
|
|
150
|
+
export type Permission = z.infer<typeof permissionSchema>;
|
|
151
|
+
export declare const extensionStatusSchema: z.ZodEnum<["installed", "enabled", "disabled"]>;
|
|
152
|
+
export declare const extensionManifestSchema: z.ZodObject<{
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
name: z.ZodString;
|
|
155
|
+
version: z.ZodString;
|
|
156
|
+
engineVersion: z.ZodString;
|
|
157
|
+
description: z.ZodDefault<z.ZodString>;
|
|
158
|
+
author: z.ZodDefault<z.ZodString>;
|
|
159
|
+
permissions: z.ZodArray<z.ZodEnum<["storage:read", "storage:write", "proxy:manage", "net:outbound:dns", "net:outbound:ssh", "net:outbound:http"]>, "many">;
|
|
160
|
+
contributes: z.ZodOptional<z.ZodObject<{
|
|
161
|
+
apiNamespace: z.ZodString;
|
|
162
|
+
nav: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
163
|
+
id: z.ZodString;
|
|
164
|
+
title: z.ZodString;
|
|
165
|
+
icon: z.ZodDefault<z.ZodString>;
|
|
166
|
+
panel: z.ZodString;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
id: string;
|
|
169
|
+
title: string;
|
|
170
|
+
icon: string;
|
|
171
|
+
panel: string;
|
|
172
|
+
}, {
|
|
173
|
+
id: string;
|
|
174
|
+
title: string;
|
|
175
|
+
panel: string;
|
|
176
|
+
icon?: string | undefined;
|
|
177
|
+
}>, "many">>;
|
|
178
|
+
uiPanels: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
179
|
+
id: z.ZodString;
|
|
180
|
+
title: z.ZodString;
|
|
181
|
+
entry: z.ZodString;
|
|
182
|
+
}, "strip", z.ZodTypeAny, {
|
|
183
|
+
id: string;
|
|
184
|
+
title: string;
|
|
185
|
+
entry: string;
|
|
186
|
+
}, {
|
|
187
|
+
id: string;
|
|
188
|
+
title: string;
|
|
189
|
+
entry: string;
|
|
190
|
+
}>, "many">>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
apiNamespace: string;
|
|
193
|
+
nav: {
|
|
194
|
+
id: string;
|
|
195
|
+
title: string;
|
|
196
|
+
icon: string;
|
|
197
|
+
panel: string;
|
|
198
|
+
}[];
|
|
199
|
+
uiPanels: {
|
|
200
|
+
id: string;
|
|
201
|
+
title: string;
|
|
202
|
+
entry: string;
|
|
203
|
+
}[];
|
|
204
|
+
}, {
|
|
205
|
+
apiNamespace: string;
|
|
206
|
+
nav?: {
|
|
207
|
+
id: string;
|
|
208
|
+
title: string;
|
|
209
|
+
panel: string;
|
|
210
|
+
icon?: string | undefined;
|
|
211
|
+
}[] | undefined;
|
|
212
|
+
uiPanels?: {
|
|
213
|
+
id: string;
|
|
214
|
+
title: string;
|
|
215
|
+
entry: string;
|
|
216
|
+
}[] | undefined;
|
|
217
|
+
}>>;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
id: string;
|
|
220
|
+
name: string;
|
|
221
|
+
version: string;
|
|
222
|
+
engineVersion: string;
|
|
223
|
+
description: string;
|
|
224
|
+
author: string;
|
|
225
|
+
permissions: ("storage:read" | "storage:write" | "proxy:manage" | "net:outbound:dns" | "net:outbound:ssh" | "net:outbound:http")[];
|
|
226
|
+
contributes?: {
|
|
227
|
+
apiNamespace: string;
|
|
228
|
+
nav: {
|
|
229
|
+
id: string;
|
|
230
|
+
title: string;
|
|
231
|
+
icon: string;
|
|
232
|
+
panel: string;
|
|
233
|
+
}[];
|
|
234
|
+
uiPanels: {
|
|
235
|
+
id: string;
|
|
236
|
+
title: string;
|
|
237
|
+
entry: string;
|
|
238
|
+
}[];
|
|
239
|
+
} | undefined;
|
|
240
|
+
}, {
|
|
241
|
+
id: string;
|
|
242
|
+
name: string;
|
|
243
|
+
version: string;
|
|
244
|
+
engineVersion: string;
|
|
245
|
+
permissions: ("storage:read" | "storage:write" | "proxy:manage" | "net:outbound:dns" | "net:outbound:ssh" | "net:outbound:http")[];
|
|
246
|
+
description?: string | undefined;
|
|
247
|
+
author?: string | undefined;
|
|
248
|
+
contributes?: {
|
|
249
|
+
apiNamespace: string;
|
|
250
|
+
nav?: {
|
|
251
|
+
id: string;
|
|
252
|
+
title: string;
|
|
253
|
+
panel: string;
|
|
254
|
+
icon?: string | undefined;
|
|
255
|
+
}[] | undefined;
|
|
256
|
+
uiPanels?: {
|
|
257
|
+
id: string;
|
|
258
|
+
title: string;
|
|
259
|
+
entry: string;
|
|
260
|
+
}[] | undefined;
|
|
261
|
+
} | undefined;
|
|
262
|
+
}>;
|
|
263
|
+
export type ExtensionManifest = z.infer<typeof extensionManifestSchema>;
|
|
264
|
+
export declare const extensionNavSchema: z.ZodObject<{
|
|
265
|
+
id: z.ZodString;
|
|
266
|
+
title: z.ZodString;
|
|
267
|
+
icon: z.ZodString;
|
|
268
|
+
panel: z.ZodString;
|
|
269
|
+
}, "strip", z.ZodTypeAny, {
|
|
270
|
+
id: string;
|
|
271
|
+
title: string;
|
|
272
|
+
icon: string;
|
|
273
|
+
panel: string;
|
|
274
|
+
}, {
|
|
275
|
+
id: string;
|
|
276
|
+
title: string;
|
|
277
|
+
icon: string;
|
|
278
|
+
panel: string;
|
|
279
|
+
}>;
|
|
280
|
+
export type ExtensionNav = z.infer<typeof extensionNavSchema>;
|
|
281
|
+
export declare const extensionRecordSchema: z.ZodObject<{
|
|
282
|
+
id: z.ZodString;
|
|
283
|
+
name: z.ZodString;
|
|
284
|
+
version: z.ZodString;
|
|
285
|
+
description: z.ZodString;
|
|
286
|
+
author: z.ZodString;
|
|
287
|
+
status: z.ZodEnum<["installed", "enabled", "disabled"]>;
|
|
288
|
+
permissions: z.ZodArray<z.ZodEnum<["storage:read", "storage:write", "proxy:manage", "net:outbound:dns", "net:outbound:ssh", "net:outbound:http"]>, "many">;
|
|
289
|
+
nav: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
290
|
+
id: z.ZodString;
|
|
291
|
+
title: z.ZodString;
|
|
292
|
+
icon: z.ZodString;
|
|
293
|
+
panel: z.ZodString;
|
|
294
|
+
}, "strip", z.ZodTypeAny, {
|
|
295
|
+
id: string;
|
|
296
|
+
title: string;
|
|
297
|
+
icon: string;
|
|
298
|
+
panel: string;
|
|
299
|
+
}, {
|
|
300
|
+
id: string;
|
|
301
|
+
title: string;
|
|
302
|
+
icon: string;
|
|
303
|
+
panel: string;
|
|
304
|
+
}>, "many">>;
|
|
305
|
+
installedAt: z.ZodNumber;
|
|
306
|
+
}, "strip", z.ZodTypeAny, {
|
|
307
|
+
status: "installed" | "enabled" | "disabled";
|
|
308
|
+
id: string;
|
|
309
|
+
name: string;
|
|
310
|
+
version: string;
|
|
311
|
+
description: string;
|
|
312
|
+
author: string;
|
|
313
|
+
permissions: ("storage:read" | "storage:write" | "proxy:manage" | "net:outbound:dns" | "net:outbound:ssh" | "net:outbound:http")[];
|
|
314
|
+
nav: {
|
|
315
|
+
id: string;
|
|
316
|
+
title: string;
|
|
317
|
+
icon: string;
|
|
318
|
+
panel: string;
|
|
319
|
+
}[];
|
|
320
|
+
installedAt: number;
|
|
321
|
+
}, {
|
|
322
|
+
status: "installed" | "enabled" | "disabled";
|
|
323
|
+
id: string;
|
|
324
|
+
name: string;
|
|
325
|
+
version: string;
|
|
326
|
+
description: string;
|
|
327
|
+
author: string;
|
|
328
|
+
permissions: ("storage:read" | "storage:write" | "proxy:manage" | "net:outbound:dns" | "net:outbound:ssh" | "net:outbound:http")[];
|
|
329
|
+
installedAt: number;
|
|
330
|
+
nav?: {
|
|
331
|
+
id: string;
|
|
332
|
+
title: string;
|
|
333
|
+
icon: string;
|
|
334
|
+
panel: string;
|
|
335
|
+
}[] | undefined;
|
|
336
|
+
}>;
|
|
337
|
+
export type ExtensionRecord = z.infer<typeof extensionRecordSchema>;
|
|
338
|
+
export declare const siteSchema: z.ZodObject<{
|
|
339
|
+
id: z.ZodString;
|
|
340
|
+
name: z.ZodString;
|
|
341
|
+
activeManifestId: z.ZodNullable<z.ZodString>;
|
|
342
|
+
createdAt: z.ZodNumber;
|
|
343
|
+
}, "strip", z.ZodTypeAny, {
|
|
344
|
+
id: string;
|
|
345
|
+
name: string;
|
|
346
|
+
createdAt: number;
|
|
347
|
+
activeManifestId: string | null;
|
|
348
|
+
}, {
|
|
349
|
+
id: string;
|
|
350
|
+
name: string;
|
|
351
|
+
createdAt: number;
|
|
352
|
+
activeManifestId: string | null;
|
|
353
|
+
}>;
|
|
354
|
+
export type Site = z.infer<typeof siteSchema>;
|
|
355
|
+
export declare const domainStatusSchema: z.ZodEnum<["pending", "active"]>;
|
|
356
|
+
export declare const tlsStrategySchema: z.ZodEnum<["http-01", "dns-01", "cloudflare-origin"]>;
|
|
357
|
+
export type TlsStrategy = z.infer<typeof tlsStrategySchema>;
|
|
358
|
+
export declare const domainSchema: z.ZodObject<{
|
|
359
|
+
name: z.ZodString;
|
|
360
|
+
siteId: z.ZodString;
|
|
361
|
+
status: z.ZodEnum<["pending", "active"]>;
|
|
362
|
+
tlsStrategy: z.ZodEnum<["http-01", "dns-01", "cloudflare-origin"]>;
|
|
363
|
+
verifiedAt: z.ZodNullable<z.ZodNumber>;
|
|
364
|
+
}, "strip", z.ZodTypeAny, {
|
|
365
|
+
status: "pending" | "active";
|
|
366
|
+
name: string;
|
|
367
|
+
siteId: string;
|
|
368
|
+
tlsStrategy: "http-01" | "dns-01" | "cloudflare-origin";
|
|
369
|
+
verifiedAt: number | null;
|
|
370
|
+
}, {
|
|
371
|
+
status: "pending" | "active";
|
|
372
|
+
name: string;
|
|
373
|
+
siteId: string;
|
|
374
|
+
tlsStrategy: "http-01" | "dns-01" | "cloudflare-origin";
|
|
375
|
+
verifiedAt: number | null;
|
|
376
|
+
}>;
|
|
377
|
+
export type Domain = z.infer<typeof domainSchema>;
|
|
378
|
+
export declare const authModeSchema: z.ZodEnum<["password", "keypair"]>;
|
|
379
|
+
export type AuthMode = z.infer<typeof authModeSchema>;
|
|
380
|
+
//# sourceMappingURL=entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS,aAEoD,CAAC;AAE3E,eAAO,MAAM,uBAAuB,kCAAgC,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAKxB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;EAKrB,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,kBAAkB,kCAAgC,CAAC;AAChE,eAAO,MAAM,iBAAiB,uDAAqD,CAAC;AACpF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;EAMvB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc,oCAAkC,CAAC;AAC9D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
package/dist/entities.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const cidSchema = z
|
|
3
|
+
.string()
|
|
4
|
+
.regex(/^b3-[0-9a-f]{64}$/, 'CID must be of the form b3-<64 hex chars>');
|
|
5
|
+
export const contentVisibilitySchema = z.enum(['public', 'private']);
|
|
6
|
+
export const encMetaSchema = z.object({
|
|
7
|
+
algo: z.literal('AES-256-GCM'),
|
|
8
|
+
iv: z.string().min(1),
|
|
9
|
+
wrappedKey: z.string().min(1),
|
|
10
|
+
chunkSize: z.number().int().positive(),
|
|
11
|
+
});
|
|
12
|
+
export const fileObjectSchema = z.object({
|
|
13
|
+
id: z.string().uuid(),
|
|
14
|
+
parentPath: z.string().startsWith('/'),
|
|
15
|
+
name: z.string().min(1),
|
|
16
|
+
cid: cidSchema,
|
|
17
|
+
size: z.number().int().nonnegative(),
|
|
18
|
+
mime: z.string().min(1),
|
|
19
|
+
visibility: contentVisibilitySchema,
|
|
20
|
+
encMeta: encMetaSchema.nullable(),
|
|
21
|
+
thumbCid: cidSchema.nullable(),
|
|
22
|
+
createdAt: z.number().int().nonnegative(),
|
|
23
|
+
updatedAt: z.number().int().nonnegative(),
|
|
24
|
+
trashedAt: z.number().int().nonnegative().nullable(),
|
|
25
|
+
});
|
|
26
|
+
export const folderSchema = z.object({
|
|
27
|
+
id: z.string().uuid(),
|
|
28
|
+
path: z.string().startsWith('/'),
|
|
29
|
+
name: z.string().min(1),
|
|
30
|
+
createdAt: z.number().int().nonnegative(),
|
|
31
|
+
});
|
|
32
|
+
export const albumSchema = z.object({
|
|
33
|
+
id: z.string().uuid(),
|
|
34
|
+
name: z.string().min(1),
|
|
35
|
+
createdAt: z.number().int().nonnegative(),
|
|
36
|
+
});
|
|
37
|
+
export const shareModeSchema = z.enum(['public', 'restricted']);
|
|
38
|
+
export const shareLinkSchema = z.object({
|
|
39
|
+
token: z.string().min(16),
|
|
40
|
+
targetType: z.enum(['file', 'album']),
|
|
41
|
+
targetId: z.string().uuid(),
|
|
42
|
+
mode: shareModeSchema,
|
|
43
|
+
allowedIdentities: z.array(z.string()).default([]),
|
|
44
|
+
expiresAt: z.number().int().nonnegative().nullable(),
|
|
45
|
+
revoked: z.boolean(),
|
|
46
|
+
createdAt: z.number().int().nonnegative(),
|
|
47
|
+
});
|
|
48
|
+
export const permissionSchema = z.enum([
|
|
49
|
+
'storage:read',
|
|
50
|
+
'storage:write',
|
|
51
|
+
'proxy:manage',
|
|
52
|
+
'net:outbound:dns',
|
|
53
|
+
'net:outbound:ssh',
|
|
54
|
+
'net:outbound:http',
|
|
55
|
+
]);
|
|
56
|
+
export const extensionStatusSchema = z.enum(['installed', 'enabled', 'disabled']);
|
|
57
|
+
export const extensionManifestSchema = z.object({
|
|
58
|
+
id: z.string().regex(/^[a-z][a-z0-9-]*$/, 'Extension id must be kebab-case'),
|
|
59
|
+
name: z.string().min(1),
|
|
60
|
+
version: z.string().regex(/^\d+\.\d+\.\d+/, 'version must be semver'),
|
|
61
|
+
engineVersion: z.string().min(1),
|
|
62
|
+
description: z.string().default(''),
|
|
63
|
+
author: z.string().default(''),
|
|
64
|
+
permissions: z.array(permissionSchema),
|
|
65
|
+
contributes: z
|
|
66
|
+
.object({
|
|
67
|
+
apiNamespace: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
68
|
+
nav: z
|
|
69
|
+
.array(z.object({
|
|
70
|
+
id: z.string().min(1),
|
|
71
|
+
title: z.string().min(1),
|
|
72
|
+
icon: z.string().default('square'),
|
|
73
|
+
panel: z.string().min(1),
|
|
74
|
+
}))
|
|
75
|
+
.default([]),
|
|
76
|
+
uiPanels: z
|
|
77
|
+
.array(z.object({
|
|
78
|
+
id: z.string().min(1),
|
|
79
|
+
title: z.string().min(1),
|
|
80
|
+
entry: z.string().min(1),
|
|
81
|
+
}))
|
|
82
|
+
.default([]),
|
|
83
|
+
})
|
|
84
|
+
.optional(),
|
|
85
|
+
});
|
|
86
|
+
export const extensionNavSchema = z.object({
|
|
87
|
+
id: z.string(),
|
|
88
|
+
title: z.string(),
|
|
89
|
+
icon: z.string(),
|
|
90
|
+
panel: z.string(),
|
|
91
|
+
});
|
|
92
|
+
export const extensionRecordSchema = z.object({
|
|
93
|
+
id: z.string(),
|
|
94
|
+
name: z.string(),
|
|
95
|
+
version: z.string(),
|
|
96
|
+
description: z.string(),
|
|
97
|
+
author: z.string(),
|
|
98
|
+
status: extensionStatusSchema,
|
|
99
|
+
permissions: z.array(permissionSchema),
|
|
100
|
+
nav: z.array(extensionNavSchema).default([]),
|
|
101
|
+
installedAt: z.number().int().nonnegative(),
|
|
102
|
+
});
|
|
103
|
+
export const siteSchema = z.object({
|
|
104
|
+
id: z.string().uuid(),
|
|
105
|
+
name: z.string().min(1),
|
|
106
|
+
activeManifestId: z.string().uuid().nullable(),
|
|
107
|
+
createdAt: z.number().int().nonnegative(),
|
|
108
|
+
});
|
|
109
|
+
export const domainStatusSchema = z.enum(['pending', 'active']);
|
|
110
|
+
export const tlsStrategySchema = z.enum(['http-01', 'dns-01', 'cloudflare-origin']);
|
|
111
|
+
export const domainSchema = z.object({
|
|
112
|
+
name: z.string().regex(/^([a-z0-9-]+\.)+[a-z]{2,}$/i, 'must be a valid hostname'),
|
|
113
|
+
siteId: z.string().uuid(),
|
|
114
|
+
status: domainStatusSchema,
|
|
115
|
+
tlsStrategy: tlsStrategySchema,
|
|
116
|
+
verifiedAt: z.number().int().nonnegative().nullable(),
|
|
117
|
+
});
|
|
118
|
+
export const authModeSchema = z.enum(['password', 'keypair']);
|
|
119
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,MAAM,EAAE;KACR,KAAK,CAAC,mBAAmB,EAAE,2CAA2C,CAAC,CAAC;AAE3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAGrE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAC9B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACrB,UAAU,EAAE,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AAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;CAC1C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAGpF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,6BAA6B,EAAE,0BAA0B,CAAC;IACjF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACzB,MAAM,EAAE,kBAAkB;IAC1B,WAAW,EAAE,iBAAiB;IAC9B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ERROR_CODES: readonly ["unauthorized", "auth_locked", "quota_exceeded", "upload_incomplete", "content_corrupted", "not_found", "invalid_extension_manifest", "permission_denied", "extension_failure", "share_revoked", "share_expired", "domain_conflict", "cloudflare_unauthorized", "vps_auth_failed", "backup_version_unsupported", "rate_limited", "validation_error", "internal_error"];
|
|
3
|
+
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
4
|
+
export declare const errorCodeSchema: z.ZodEnum<["unauthorized", "auth_locked", "quota_exceeded", "upload_incomplete", "content_corrupted", "not_found", "invalid_extension_manifest", "permission_denied", "extension_failure", "share_revoked", "share_expired", "domain_conflict", "cloudflare_unauthorized", "vps_auth_failed", "backup_version_unsupported", "rate_limited", "validation_error", "internal_error"]>;
|
|
5
|
+
export declare const sovraErrorSchema: z.ZodObject<{
|
|
6
|
+
code: z.ZodEnum<["unauthorized", "auth_locked", "quota_exceeded", "upload_incomplete", "content_corrupted", "not_found", "invalid_extension_manifest", "permission_denied", "extension_failure", "share_revoked", "share_expired", "domain_conflict", "cloudflare_unauthorized", "vps_auth_failed", "backup_version_unsupported", "rate_limited", "validation_error", "internal_error"]>;
|
|
7
|
+
message: z.ZodString;
|
|
8
|
+
ts: z.ZodNumber;
|
|
9
|
+
detail: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
code: "unauthorized" | "auth_locked" | "quota_exceeded" | "upload_incomplete" | "content_corrupted" | "not_found" | "invalid_extension_manifest" | "permission_denied" | "extension_failure" | "share_revoked" | "share_expired" | "domain_conflict" | "cloudflare_unauthorized" | "vps_auth_failed" | "backup_version_unsupported" | "rate_limited" | "validation_error" | "internal_error";
|
|
12
|
+
message: string;
|
|
13
|
+
ts: number;
|
|
14
|
+
detail?: Record<string, unknown> | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
code: "unauthorized" | "auth_locked" | "quota_exceeded" | "upload_incomplete" | "content_corrupted" | "not_found" | "invalid_extension_manifest" | "permission_denied" | "extension_failure" | "share_revoked" | "share_expired" | "domain_conflict" | "cloudflare_unauthorized" | "vps_auth_failed" | "backup_version_unsupported" | "rate_limited" | "validation_error" | "internal_error";
|
|
17
|
+
message: string;
|
|
18
|
+
ts: number;
|
|
19
|
+
detail?: Record<string, unknown> | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export type SovraErrorShape = z.infer<typeof sovraErrorSchema>;
|
|
22
|
+
export declare class SovraError extends Error {
|
|
23
|
+
readonly code: ErrorCode;
|
|
24
|
+
readonly ts: number;
|
|
25
|
+
readonly detail?: Record<string, unknown>;
|
|
26
|
+
constructor(code: ErrorCode, message: string, options?: {
|
|
27
|
+
detail?: Record<string, unknown>;
|
|
28
|
+
ts?: number;
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
});
|
|
31
|
+
get retryable(): boolean;
|
|
32
|
+
toJSON(): SovraErrorShape;
|
|
33
|
+
static is(value: unknown): value is SovraError;
|
|
34
|
+
static fromJSON(value: unknown): SovraError;
|
|
35
|
+
}
|
|
36
|
+
export declare function makeError(code: ErrorCode, message: string, detail?: Record<string, unknown>): SovraError;
|
|
37
|
+
export declare function isRetryableCode(code: ErrorCode): boolean;
|
|
38
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,WAAW,kXAmBd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAOrD,eAAO,MAAM,eAAe,oXAAsB,CAAC;AAEnD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/D,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGxC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IAU9E,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,MAAM,IAAI,eAAe;IASzB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU;IAI9C,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU;CAO5C;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,UAAU,CAEZ;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAExD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ERROR_CODES = [
|
|
3
|
+
'unauthorized',
|
|
4
|
+
'auth_locked',
|
|
5
|
+
'quota_exceeded',
|
|
6
|
+
'upload_incomplete',
|
|
7
|
+
'content_corrupted',
|
|
8
|
+
'not_found',
|
|
9
|
+
'invalid_extension_manifest',
|
|
10
|
+
'permission_denied',
|
|
11
|
+
'extension_failure',
|
|
12
|
+
'share_revoked',
|
|
13
|
+
'share_expired',
|
|
14
|
+
'domain_conflict',
|
|
15
|
+
'cloudflare_unauthorized',
|
|
16
|
+
'vps_auth_failed',
|
|
17
|
+
'backup_version_unsupported',
|
|
18
|
+
'rate_limited',
|
|
19
|
+
'validation_error',
|
|
20
|
+
'internal_error',
|
|
21
|
+
];
|
|
22
|
+
const RETRYABLE_CODES = new Set([
|
|
23
|
+
'internal_error',
|
|
24
|
+
'rate_limited',
|
|
25
|
+
]);
|
|
26
|
+
export const errorCodeSchema = z.enum(ERROR_CODES);
|
|
27
|
+
export const sovraErrorSchema = z.object({
|
|
28
|
+
code: errorCodeSchema,
|
|
29
|
+
message: z.string().min(1),
|
|
30
|
+
ts: z.number().int().nonnegative(),
|
|
31
|
+
detail: z.record(z.unknown()).optional(),
|
|
32
|
+
});
|
|
33
|
+
export class SovraError extends Error {
|
|
34
|
+
code;
|
|
35
|
+
ts;
|
|
36
|
+
detail;
|
|
37
|
+
constructor(code, message, options) {
|
|
38
|
+
super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);
|
|
39
|
+
this.name = 'SovraError';
|
|
40
|
+
this.code = code;
|
|
41
|
+
this.ts = options?.ts ?? Date.now();
|
|
42
|
+
if (options?.detail)
|
|
43
|
+
this.detail = options.detail;
|
|
44
|
+
Object.setPrototypeOf(this, SovraError.prototype);
|
|
45
|
+
}
|
|
46
|
+
get retryable() {
|
|
47
|
+
return RETRYABLE_CODES.has(this.code);
|
|
48
|
+
}
|
|
49
|
+
toJSON() {
|
|
50
|
+
return {
|
|
51
|
+
code: this.code,
|
|
52
|
+
message: this.message,
|
|
53
|
+
ts: this.ts,
|
|
54
|
+
...(this.detail ? { detail: this.detail } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
static is(value) {
|
|
58
|
+
return value instanceof SovraError;
|
|
59
|
+
}
|
|
60
|
+
static fromJSON(value) {
|
|
61
|
+
const parsed = sovraErrorSchema.parse(value);
|
|
62
|
+
return new SovraError(parsed.code, parsed.message, {
|
|
63
|
+
ts: parsed.ts,
|
|
64
|
+
detail: parsed.detail,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function makeError(code, message, detail) {
|
|
69
|
+
return new SovraError(code, message, detail ? { detail } : undefined);
|
|
70
|
+
}
|
|
71
|
+
export function isRetryableCode(code) {
|
|
72
|
+
return RETRYABLE_CODES.has(code);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAA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CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|