@adgytec/adgytec-web-utils 0.0.1 → 0.0.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/dist/chunks/applicationError +26 -0
- package/dist/chunks/decode +50 -0
- package/dist/chunks/formParse +11 -0
- package/dist/chunks/schema +322 -0
- package/dist/chunks/upload +371 -0
- package/dist/constants/httpRequestCredentials.d.ts +1 -0
- package/dist/constants/httpRequestHeaders.d.ts +14 -0
- package/dist/constants/http_methods.d.ts +7 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.js +29 -0
- package/dist/errorCodes/auth.d.ts +14 -0
- package/dist/errorCodes/common.d.ts +5 -0
- package/dist/errorCodes/form.d.ts +28 -0
- package/dist/errorCodes/iam.d.ts +6 -0
- package/dist/errorCodes/index.d.ts +8 -0
- package/dist/errorCodes/index.js +84 -0
- package/dist/errorCodes/media.d.ts +12 -0
- package/dist/errorCodes/pagination.d.ts +3 -0
- package/dist/errorCodes/reqBody.d.ts +6 -0
- package/dist/errorCodes/server.d.ts +7 -0
- package/dist/errorSchema/auth.d.ts +37 -0
- package/dist/errorSchema/common.d.ts +10 -0
- package/dist/errorSchema/form.d.ts +14 -0
- package/dist/errorSchema/formField.d.ts +117 -0
- package/dist/errorSchema/formFieldInvalid.d.ts +79 -0
- package/dist/errorSchema/formParse.d.ts +4 -0
- package/dist/errorSchema/iam.d.ts +21 -0
- package/dist/errorSchema/index.d.ts +12 -0
- package/dist/errorSchema/index.js +69 -0
- package/dist/errorSchema/media.d.ts +41 -0
- package/dist/errorSchema/pagination.d.ts +4 -0
- package/dist/errorSchema/reqBody.d.ts +35 -0
- package/dist/errorSchema/schema.d.ts +138 -0
- package/dist/errorSchema/server.d.ts +29 -0
- package/dist/errors/applicationError.d.ts +9 -0
- package/dist/errors/index.d.ts +1 -2
- package/dist/errors/index.js +5 -0
- package/dist/errors/types.d.ts +0 -19
- package/dist/index.d.ts +4 -0
- package/dist/index.js +97 -2726
- package/dist/media/index.d.ts +5 -0
- package/dist/media/index.js +12 -0
- package/dist/media/mediaInfo.d.ts +3 -0
- package/dist/media/multipartUtil.d.ts +18 -0
- package/dist/media/singlepartUtil.d.ts +10 -0
- package/dist/media/toUploadPayload.d.ts +3 -0
- package/dist/media/types/apiResponse.d.ts +17 -0
- package/dist/media/types/index.d.ts +6 -0
- package/dist/media/types/lifecycle.d.ts +10 -0
- package/dist/media/types/mediaInfo.d.ts +8 -0
- package/dist/media/types/toUploadPayload.d.ts +4 -0
- package/dist/media/types/upload.d.ts +42 -0
- package/dist/media/types/uploadDetails.d.ts +8 -0
- package/dist/media/upload.d.ts +3 -0
- package/dist/media/uploadDetails.d.ts +3 -0
- package/dist/media/uploadUtil.d.ts +6 -0
- package/dist/response/errorResponse.d.ts +1 -0
- package/dist/response/index.js +4 -0
- package/dist/response/successReponse.d.ts +2 -0
- package/dist/test.d.ts +1 -0
- package/package.json +53 -45
- package/dist/errors/apiError.d.ts +0 -8
- package/dist/errors/parse.d.ts +0 -2
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import r from "zod";
|
|
2
|
+
import { v7 as u } from "uuid";
|
|
3
|
+
import { B as n, A as l } from "./applicationError";
|
|
4
|
+
import { Queue as m } from "@datastructures-js/queue";
|
|
5
|
+
import { d as y } from "./decode";
|
|
6
|
+
import { httpMethods as c, httpReqHeaders as d, httpRequestCredentials as f } from "../constants/index.js";
|
|
7
|
+
import { mediaCodes as p } from "../errorCodes/index.js";
|
|
8
|
+
const w = r.object({
|
|
9
|
+
presignPut: r.url(),
|
|
10
|
+
partNumber: r.int().positive().lte(1e4),
|
|
11
|
+
partSize: r.int().positive().gt(0)
|
|
12
|
+
}), g = r.object({
|
|
13
|
+
mediaID: r.uuidv7(),
|
|
14
|
+
uploadType: r.literal("multipart"),
|
|
15
|
+
multipartPresignPart: r.array(w).nonempty(),
|
|
16
|
+
multipartSuccessCallback: r.url()
|
|
17
|
+
}), U = r.object({
|
|
18
|
+
mediaID: r.uuidv7(),
|
|
19
|
+
uploadType: r.literal("singlepart"),
|
|
20
|
+
presignPut: r.url(),
|
|
21
|
+
singlepartSuccessCallback: r.url()
|
|
22
|
+
}), I = r.discriminatedUnion("uploadType", [
|
|
23
|
+
g,
|
|
24
|
+
U
|
|
25
|
+
]), C = (a) => ({
|
|
26
|
+
id: u(),
|
|
27
|
+
name: a.name,
|
|
28
|
+
size: a.size,
|
|
29
|
+
file: a
|
|
30
|
+
}), k = (a) => a.map(C), P = (a) => ({
|
|
31
|
+
id: a.id,
|
|
32
|
+
size: a.size,
|
|
33
|
+
name: a.name
|
|
34
|
+
}), q = (a) => a.map(P), R = (a, t) => {
|
|
35
|
+
if (a.id !== t.mediaID)
|
|
36
|
+
throw new n("media item and response id mismatch");
|
|
37
|
+
return {
|
|
38
|
+
...t,
|
|
39
|
+
file: a.file,
|
|
40
|
+
size: a.size
|
|
41
|
+
};
|
|
42
|
+
}, $ = (a, t) => {
|
|
43
|
+
if (a.length !== t.length)
|
|
44
|
+
throw new n(
|
|
45
|
+
`items mismatch: mediaInfos=${a.length}, apiResponses=${t.length}`
|
|
46
|
+
);
|
|
47
|
+
const e = new Map(
|
|
48
|
+
t.map((i) => [i.mediaID, i])
|
|
49
|
+
);
|
|
50
|
+
return a.map((i) => {
|
|
51
|
+
const s = e.get(i.id);
|
|
52
|
+
if (!s)
|
|
53
|
+
throw new n(
|
|
54
|
+
`Could not find a matching API response for media info with id: ${i.id}`
|
|
55
|
+
);
|
|
56
|
+
return R(i, s);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
class S {
|
|
60
|
+
#s;
|
|
61
|
+
#t;
|
|
62
|
+
#a;
|
|
63
|
+
#i;
|
|
64
|
+
#e;
|
|
65
|
+
#n;
|
|
66
|
+
#o;
|
|
67
|
+
#r;
|
|
68
|
+
constructor(t, e, i, s) {
|
|
69
|
+
this.#s = t, this.#t = e, this.#a = [], this.#i = /* @__PURE__ */ new Set(), this.#e = s, this.#n = i, this.#o = !1, this.#r = !1;
|
|
70
|
+
}
|
|
71
|
+
get failed() {
|
|
72
|
+
return this.#o;
|
|
73
|
+
}
|
|
74
|
+
fail() {
|
|
75
|
+
this.#o = !0;
|
|
76
|
+
}
|
|
77
|
+
get id() {
|
|
78
|
+
return this.#s;
|
|
79
|
+
}
|
|
80
|
+
get completeURL() {
|
|
81
|
+
return this.#n;
|
|
82
|
+
}
|
|
83
|
+
get blob() {
|
|
84
|
+
return this.#t;
|
|
85
|
+
}
|
|
86
|
+
add(t) {
|
|
87
|
+
this.contains(t.partNumber) || (this.#a.push(t), this.#i.add(t.partNumber));
|
|
88
|
+
}
|
|
89
|
+
contains(t) {
|
|
90
|
+
return this.#i.has(t);
|
|
91
|
+
}
|
|
92
|
+
get list() {
|
|
93
|
+
return this.#a.slice().sort((t, e) => t.partNumber - e.partNumber);
|
|
94
|
+
}
|
|
95
|
+
get canComplete() {
|
|
96
|
+
return !this.failed && this.#i.size === this.#e;
|
|
97
|
+
}
|
|
98
|
+
tryStartComplete() {
|
|
99
|
+
return this.#r || !this.canComplete ? !1 : (this.#r = !0, !0);
|
|
100
|
+
}
|
|
101
|
+
resetComplete() {
|
|
102
|
+
this.#r = !1;
|
|
103
|
+
}
|
|
104
|
+
get totalPartsCount() {
|
|
105
|
+
return this.#e;
|
|
106
|
+
}
|
|
107
|
+
get uploadedPartsCount() {
|
|
108
|
+
return this.#i.size;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
class N {
|
|
112
|
+
#s;
|
|
113
|
+
#t;
|
|
114
|
+
#a;
|
|
115
|
+
#i;
|
|
116
|
+
#e;
|
|
117
|
+
constructor(t, e, i, s) {
|
|
118
|
+
this.#s = t, this.#t = e, this.#i = s, this.#a = i, this.#e = !1;
|
|
119
|
+
}
|
|
120
|
+
get canComplete() {
|
|
121
|
+
return this.#e;
|
|
122
|
+
}
|
|
123
|
+
allowComplete() {
|
|
124
|
+
this.#e = !0;
|
|
125
|
+
}
|
|
126
|
+
get id() {
|
|
127
|
+
return this.#s;
|
|
128
|
+
}
|
|
129
|
+
get blob() {
|
|
130
|
+
return this.#t;
|
|
131
|
+
}
|
|
132
|
+
get completeURL() {
|
|
133
|
+
return this.#i;
|
|
134
|
+
}
|
|
135
|
+
get uploadURL() {
|
|
136
|
+
return this.#a;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const L = {
|
|
140
|
+
concurrentUploads: 4,
|
|
141
|
+
retryLimit: 3
|
|
142
|
+
};
|
|
143
|
+
class z {
|
|
144
|
+
#s;
|
|
145
|
+
#t;
|
|
146
|
+
#a;
|
|
147
|
+
#i;
|
|
148
|
+
#e;
|
|
149
|
+
#n;
|
|
150
|
+
constructor(t, e, i = L, s) {
|
|
151
|
+
this.#s = t, this.#t = e, this.#a = i.concurrentUploads, this.#i = i.retryLimit, this.#e = new m(), this.#n = s;
|
|
152
|
+
}
|
|
153
|
+
#o(t) {
|
|
154
|
+
return t < this.#i;
|
|
155
|
+
}
|
|
156
|
+
#r(t) {
|
|
157
|
+
this.#e.enqueue(t);
|
|
158
|
+
}
|
|
159
|
+
async init() {
|
|
160
|
+
this.#t.init(this.#s);
|
|
161
|
+
const t = /* @__PURE__ */ new Set();
|
|
162
|
+
for await (const e of this.#m()) {
|
|
163
|
+
const i = e().finally(() => t.delete(i));
|
|
164
|
+
t.add(i), t.size >= this.#a && await Promise.race(t);
|
|
165
|
+
}
|
|
166
|
+
await Promise.all(t), await this.#f(), this.#t.completed();
|
|
167
|
+
}
|
|
168
|
+
async #l(t, e) {
|
|
169
|
+
return await fetch(t, {
|
|
170
|
+
method: c.put,
|
|
171
|
+
body: e
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async #d(t, e = 0) {
|
|
175
|
+
if (!t.canComplete)
|
|
176
|
+
try {
|
|
177
|
+
if (!(await this.#l(
|
|
178
|
+
t.uploadURL,
|
|
179
|
+
t.blob
|
|
180
|
+
)).ok)
|
|
181
|
+
throw new l(p.singlepartUploadFailed, {
|
|
182
|
+
mediaID: t.id
|
|
183
|
+
});
|
|
184
|
+
t.allowComplete(), await this.#h(t);
|
|
185
|
+
} catch (i) {
|
|
186
|
+
this.#o(e) ? (this.#t.uploadRetrying(t.id), this.#r({
|
|
187
|
+
type: "singlepart-upload",
|
|
188
|
+
retryCount: e + 1,
|
|
189
|
+
singlepartObj: t
|
|
190
|
+
})) : this.#t.failed(t.id, i);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async #p(t, e, i = 0) {
|
|
194
|
+
if (!(t.failed || t.contains(e.partNumber)))
|
|
195
|
+
try {
|
|
196
|
+
const s = await this.#l(
|
|
197
|
+
e.uploadURL,
|
|
198
|
+
t.blob.slice(e.startByte, e.endByte)
|
|
199
|
+
);
|
|
200
|
+
if (!s.ok)
|
|
201
|
+
throw new l(
|
|
202
|
+
p.multipartPartUploadFailed,
|
|
203
|
+
{
|
|
204
|
+
mediaID: t.id,
|
|
205
|
+
partNumber: e.partNumber
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
const o = s.headers.get("ETag");
|
|
209
|
+
if (!o)
|
|
210
|
+
throw new l(p.missingETagValue, {
|
|
211
|
+
mediaID: t.id,
|
|
212
|
+
partNumber: e.partNumber
|
|
213
|
+
});
|
|
214
|
+
if (t.add({
|
|
215
|
+
partNumber: e.partNumber,
|
|
216
|
+
etag: o
|
|
217
|
+
}), this.#t.multipartPartUploaded(
|
|
218
|
+
t.id,
|
|
219
|
+
t.uploadedPartsCount,
|
|
220
|
+
t.totalPartsCount
|
|
221
|
+
), !t.canComplete) return;
|
|
222
|
+
await this.#u(t);
|
|
223
|
+
} catch (s) {
|
|
224
|
+
this.#o(i) ? (this.#t.multipartPartUploadRetrying(
|
|
225
|
+
t.id,
|
|
226
|
+
e.partNumber
|
|
227
|
+
), this.#r({
|
|
228
|
+
type: "multipart-part-upload",
|
|
229
|
+
retryCount: i + 1,
|
|
230
|
+
multipartObj: t,
|
|
231
|
+
partInfo: e
|
|
232
|
+
})) : (t.fail(), this.#t.failed(t.id, s));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async #c(t, e) {
|
|
236
|
+
let i, s;
|
|
237
|
+
e && (i = JSON.stringify({
|
|
238
|
+
partsInfo: e
|
|
239
|
+
}), s = {
|
|
240
|
+
[d.contentType.key]: d.contentType.valueApplicationJSON
|
|
241
|
+
}), this.#n && (s = s || {}, s[d.userLocale.key] = this.#n);
|
|
242
|
+
const o = await fetch(t, {
|
|
243
|
+
method: c.post,
|
|
244
|
+
body: i,
|
|
245
|
+
headers: s,
|
|
246
|
+
credentials: f.include
|
|
247
|
+
});
|
|
248
|
+
await y(o);
|
|
249
|
+
}
|
|
250
|
+
async #h(t, e = 0) {
|
|
251
|
+
if (t.canComplete)
|
|
252
|
+
try {
|
|
253
|
+
await this.#c(t.completeURL), this.#t.itemUploaded(t.id);
|
|
254
|
+
} catch (i) {
|
|
255
|
+
this.#o(e) ? (this.#t.uploadRetrying(t.id), this.#r({
|
|
256
|
+
type: "singlepart-complete",
|
|
257
|
+
retryCount: e + 1,
|
|
258
|
+
singlepartObj: t
|
|
259
|
+
})) : this.#t.failed(t.id, i);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async #u(t, e = 0) {
|
|
263
|
+
if (t.tryStartComplete())
|
|
264
|
+
try {
|
|
265
|
+
await this.#c(
|
|
266
|
+
t.completeURL,
|
|
267
|
+
t.list
|
|
268
|
+
), this.#t.itemUploaded(t.id);
|
|
269
|
+
} catch (i) {
|
|
270
|
+
t.resetComplete(), this.#o(e) ? (this.#t.uploadRetrying(t.id), this.#r({
|
|
271
|
+
type: "multipart-complete",
|
|
272
|
+
retryCount: e + 1,
|
|
273
|
+
multipartObj: t
|
|
274
|
+
})) : (t.fail(), this.#t.failed(t.id, i));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
async *#m() {
|
|
278
|
+
for (const t of this.#s) {
|
|
279
|
+
if (t.uploadType === "singlepart") {
|
|
280
|
+
const o = new N(
|
|
281
|
+
t.mediaID,
|
|
282
|
+
t.file,
|
|
283
|
+
t.presignPut,
|
|
284
|
+
t.singlepartSuccessCallback
|
|
285
|
+
);
|
|
286
|
+
yield async () => {
|
|
287
|
+
await this.#d(o);
|
|
288
|
+
};
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
const e = new S(
|
|
292
|
+
t.mediaID,
|
|
293
|
+
t.file,
|
|
294
|
+
t.multipartSuccessCallback,
|
|
295
|
+
t.multipartPresignPart.length
|
|
296
|
+
);
|
|
297
|
+
let i = 0, s = 0;
|
|
298
|
+
for (const o of t.multipartPresignPart) {
|
|
299
|
+
s += o.partSize;
|
|
300
|
+
const h = {
|
|
301
|
+
partNumber: o.partNumber,
|
|
302
|
+
uploadURL: o.presignPut,
|
|
303
|
+
startByte: i,
|
|
304
|
+
endByte: s
|
|
305
|
+
};
|
|
306
|
+
yield async () => {
|
|
307
|
+
await this.#p(e, h);
|
|
308
|
+
}, i = s;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
#y(t) {
|
|
313
|
+
switch (t.type) {
|
|
314
|
+
case "singlepart-upload":
|
|
315
|
+
return this.#d(
|
|
316
|
+
t.singlepartObj,
|
|
317
|
+
t.retryCount
|
|
318
|
+
);
|
|
319
|
+
case "singlepart-complete":
|
|
320
|
+
return this.#h(
|
|
321
|
+
t.singlepartObj,
|
|
322
|
+
t.retryCount
|
|
323
|
+
);
|
|
324
|
+
case "multipart-part-upload":
|
|
325
|
+
return this.#p(
|
|
326
|
+
t.multipartObj,
|
|
327
|
+
t.partInfo,
|
|
328
|
+
t.retryCount
|
|
329
|
+
);
|
|
330
|
+
case "multipart-complete":
|
|
331
|
+
return this.#u(
|
|
332
|
+
t.multipartObj,
|
|
333
|
+
t.retryCount
|
|
334
|
+
);
|
|
335
|
+
default:
|
|
336
|
+
const e = t;
|
|
337
|
+
throw new n(
|
|
338
|
+
`Unhandled retry task type: ${e.type}`
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
async #f() {
|
|
343
|
+
const t = /* @__PURE__ */ new Set();
|
|
344
|
+
for (; !this.#e.isEmpty(); ) {
|
|
345
|
+
for (; !this.#e.isEmpty(); ) {
|
|
346
|
+
const e = this.#e.dequeue();
|
|
347
|
+
let i = this.#y(e).finally(
|
|
348
|
+
() => t.delete(i)
|
|
349
|
+
);
|
|
350
|
+
t.add(i), t.size >= this.#a && await Promise.race(t);
|
|
351
|
+
}
|
|
352
|
+
await Promise.all(t);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const x = async (a, t, e, i) => {
|
|
357
|
+
await D([a], t, e, i);
|
|
358
|
+
}, D = async (a, t, e, i) => {
|
|
359
|
+
await new z(a, t, e, i).init();
|
|
360
|
+
};
|
|
361
|
+
export {
|
|
362
|
+
I as U,
|
|
363
|
+
k as a,
|
|
364
|
+
R as b,
|
|
365
|
+
$ as c,
|
|
366
|
+
q as d,
|
|
367
|
+
D as e,
|
|
368
|
+
C as n,
|
|
369
|
+
P as t,
|
|
370
|
+
x as u
|
|
371
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const httpRequestCredentials: Record<string, RequestCredentials>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const httpReqHeaders: {
|
|
2
|
+
readonly contentType: {
|
|
3
|
+
readonly key: "Content-Type";
|
|
4
|
+
readonly valueApplicationJSON: "application/json";
|
|
5
|
+
};
|
|
6
|
+
readonly authorization: {
|
|
7
|
+
readonly key: "Authorization";
|
|
8
|
+
readonly schemeBearer: "Bearer";
|
|
9
|
+
readonly schemeBasic: "Basic";
|
|
10
|
+
};
|
|
11
|
+
readonly userLocale: {
|
|
12
|
+
readonly key: "x-user-locale";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
get: "GET",
|
|
3
|
+
post: "POST",
|
|
4
|
+
put: "PUT",
|
|
5
|
+
patch: "PATCH",
|
|
6
|
+
delete: "DELETE"
|
|
7
|
+
}, t = {
|
|
8
|
+
contentType: {
|
|
9
|
+
key: "Content-Type",
|
|
10
|
+
valueApplicationJSON: "application/json"
|
|
11
|
+
},
|
|
12
|
+
authorization: {
|
|
13
|
+
key: "Authorization",
|
|
14
|
+
schemeBearer: "Bearer",
|
|
15
|
+
schemeBasic: "Basic"
|
|
16
|
+
},
|
|
17
|
+
userLocale: {
|
|
18
|
+
key: "x-user-locale"
|
|
19
|
+
}
|
|
20
|
+
}, o = {
|
|
21
|
+
include: "include",
|
|
22
|
+
sameOrigin: "same-origin",
|
|
23
|
+
omit: "omit"
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
e as httpMethods,
|
|
27
|
+
t as httpReqHeaders,
|
|
28
|
+
o as httpRequestCredentials
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const authCodes: {
|
|
2
|
+
readonly invalidApiKey: "invalid-api-key";
|
|
3
|
+
readonly userNotFound: "user-not-found";
|
|
4
|
+
readonly jwtNotAcceptable: "jwt-not-acceptable";
|
|
5
|
+
readonly invalidSignedUrl: "invalid-signed-url";
|
|
6
|
+
readonly hashMismatch: "hash-mismatch";
|
|
7
|
+
readonly invalidAuthHeaderValue: "invalid-auth-header-value";
|
|
8
|
+
readonly unsupportedAuthScheme: "unsupported-auth-scheme";
|
|
9
|
+
readonly organizationStatusBad: "bad-org-status";
|
|
10
|
+
readonly userNotExistsInOrganizationManagement: "user-not-exists-in-organization-management";
|
|
11
|
+
readonly userNotExistInOrganization: "user-not-exists-in-organization";
|
|
12
|
+
readonly userDisabled: "user-disabled";
|
|
13
|
+
readonly tokenNotFound: "token-not-found";
|
|
14
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const formCodes: {
|
|
2
|
+
readonly formValidationFailed: "validation-failed";
|
|
3
|
+
};
|
|
4
|
+
export declare const formFieldTypes: {
|
|
5
|
+
readonly missing: "missing";
|
|
6
|
+
readonly overflow: "overflow";
|
|
7
|
+
readonly underflow: "underflow";
|
|
8
|
+
readonly length: "length";
|
|
9
|
+
readonly invalid: "invalid";
|
|
10
|
+
readonly unknown: "unknown";
|
|
11
|
+
};
|
|
12
|
+
export declare const formFieldInvalidTypeCauses: {
|
|
13
|
+
readonly invalidValue: "invalid-value";
|
|
14
|
+
readonly invalidEnumValue: "invalid-enum-value";
|
|
15
|
+
readonly requireHttps: "require-https";
|
|
16
|
+
readonly missingHost: "missing-host";
|
|
17
|
+
readonly containsPath: "contains-path";
|
|
18
|
+
readonly containsQuery: "contains-query";
|
|
19
|
+
readonly containsFragment: "contains-fragment";
|
|
20
|
+
readonly absoluteUrl: "absolute-url";
|
|
21
|
+
readonly nilID: "nil-id";
|
|
22
|
+
readonly invalidEmail: "invalid-email";
|
|
23
|
+
readonly missingMxRecords: "missing-mx-records";
|
|
24
|
+
readonly notDigit: "not-digit";
|
|
25
|
+
readonly notBase64UrlEncoded: "not-base64-url-encoded";
|
|
26
|
+
readonly invalidUrl: "invalid-url";
|
|
27
|
+
readonly nullValue: "null-value";
|
|
28
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
malformedResponseBody: "malformed-response-body",
|
|
3
|
+
malformedJsonFromServer: "malformed-json-from-server",
|
|
4
|
+
invalidResponseShape: "invalid-response-shape",
|
|
5
|
+
unknownServerError: "unknown-server-error",
|
|
6
|
+
internalServerError: "internal-server-error"
|
|
7
|
+
}, i = {
|
|
8
|
+
formValidationFailed: "validation-failed"
|
|
9
|
+
}, o = {
|
|
10
|
+
missing: "missing",
|
|
11
|
+
overflow: "overflow",
|
|
12
|
+
underflow: "underflow",
|
|
13
|
+
length: "length",
|
|
14
|
+
invalid: "invalid",
|
|
15
|
+
unknown: "unknown"
|
|
16
|
+
}, n = {
|
|
17
|
+
invalidValue: "invalid-value",
|
|
18
|
+
invalidEnumValue: "invalid-enum-value",
|
|
19
|
+
requireHttps: "require-https",
|
|
20
|
+
missingHost: "missing-host",
|
|
21
|
+
containsPath: "contains-path",
|
|
22
|
+
containsQuery: "contains-query",
|
|
23
|
+
containsFragment: "contains-fragment",
|
|
24
|
+
absoluteUrl: "absolute-url",
|
|
25
|
+
nilID: "nil-id",
|
|
26
|
+
invalidEmail: "invalid-email",
|
|
27
|
+
missingMxRecords: "missing-mx-records",
|
|
28
|
+
notDigit: "not-digit",
|
|
29
|
+
notBase64UrlEncoded: "not-base64-url-encoded",
|
|
30
|
+
invalidUrl: "invalid-url",
|
|
31
|
+
nullValue: "null-value"
|
|
32
|
+
}, a = {
|
|
33
|
+
invalidApiKey: "invalid-api-key",
|
|
34
|
+
userNotFound: "user-not-found",
|
|
35
|
+
jwtNotAcceptable: "jwt-not-acceptable",
|
|
36
|
+
invalidSignedUrl: "invalid-signed-url",
|
|
37
|
+
hashMismatch: "hash-mismatch",
|
|
38
|
+
invalidAuthHeaderValue: "invalid-auth-header-value",
|
|
39
|
+
unsupportedAuthScheme: "unsupported-auth-scheme",
|
|
40
|
+
organizationStatusBad: "bad-org-status",
|
|
41
|
+
userNotExistsInOrganizationManagement: "user-not-exists-in-organization-management",
|
|
42
|
+
userNotExistInOrganization: "user-not-exists-in-organization",
|
|
43
|
+
userDisabled: "user-disabled",
|
|
44
|
+
tokenNotFound: "token-not-found"
|
|
45
|
+
}, t = {
|
|
46
|
+
invalidRequestBody: "invalid-request-body",
|
|
47
|
+
unknownFieldInRequestBody: "unknown-field-in-request-body",
|
|
48
|
+
emptyRequestBody: "empty-request-body",
|
|
49
|
+
requestBodyTooLarge: "request-body-too-large"
|
|
50
|
+
}, s = {
|
|
51
|
+
invalidCursorValue: "invalid-cursor-value"
|
|
52
|
+
}, d = {
|
|
53
|
+
invalidId: "invalid-id",
|
|
54
|
+
routeNotFound: "route-not-found",
|
|
55
|
+
methodNotAllowed: "method-not-allowed"
|
|
56
|
+
}, l = {
|
|
57
|
+
invalidMultipartNumber: "invalid-multipart-upload-part-number",
|
|
58
|
+
mediaObjectNotFound: "object-not-found",
|
|
59
|
+
mediaTooLarge: "media-too-large",
|
|
60
|
+
mediaItemsLimitExceeded: "media-items-limit-exceeded",
|
|
61
|
+
uploadAlreadyCompleted: "upload-already-completed",
|
|
62
|
+
unsupportedObjectUploaded: "unsupported-object-uploaded",
|
|
63
|
+
completeMultipartUploadCalledTooSoon: "complete-multipart-upload-called-too-soon",
|
|
64
|
+
singlepartUploadFailed: "singlepart-upload-failed",
|
|
65
|
+
multipartPartUploadFailed: "multipart-part-upload-failed",
|
|
66
|
+
missingETagValue: "missing-etag-value"
|
|
67
|
+
}, r = {
|
|
68
|
+
selfPermissionMismatch: "self-permission-mismatch",
|
|
69
|
+
invalidActor: "invalid-actor",
|
|
70
|
+
permissionExplicitlyDenied: "permission-explicitly-denied",
|
|
71
|
+
missingPermission: "missing-permission"
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
a as authCodes,
|
|
75
|
+
d as commonCodes,
|
|
76
|
+
i as formCodes,
|
|
77
|
+
n as formFieldInvalidTypeCauses,
|
|
78
|
+
o as formFieldTypes,
|
|
79
|
+
r as iamCodes,
|
|
80
|
+
l as mediaCodes,
|
|
81
|
+
s as paginationCodes,
|
|
82
|
+
t as requestBodyCodes,
|
|
83
|
+
e as serverCodes
|
|
84
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const mediaCodes: {
|
|
2
|
+
readonly invalidMultipartNumber: "invalid-multipart-upload-part-number";
|
|
3
|
+
readonly mediaObjectNotFound: "object-not-found";
|
|
4
|
+
readonly mediaTooLarge: "media-too-large";
|
|
5
|
+
readonly mediaItemsLimitExceeded: "media-items-limit-exceeded";
|
|
6
|
+
readonly uploadAlreadyCompleted: "upload-already-completed";
|
|
7
|
+
readonly unsupportedObjectUploaded: "unsupported-object-uploaded";
|
|
8
|
+
readonly completeMultipartUploadCalledTooSoon: "complete-multipart-upload-called-too-soon";
|
|
9
|
+
readonly singlepartUploadFailed: "singlepart-upload-failed";
|
|
10
|
+
readonly multipartPartUploadFailed: "multipart-part-upload-failed";
|
|
11
|
+
readonly missingETagValue: "missing-etag-value";
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const requestBodyCodes: {
|
|
2
|
+
readonly invalidRequestBody: "invalid-request-body";
|
|
3
|
+
readonly unknownFieldInRequestBody: "unknown-field-in-request-body";
|
|
4
|
+
readonly emptyRequestBody: "empty-request-body";
|
|
5
|
+
readonly requestBodyTooLarge: "request-body-too-large";
|
|
6
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const serverCodes: {
|
|
2
|
+
readonly malformedResponseBody: "malformed-response-body";
|
|
3
|
+
readonly malformedJsonFromServer: "malformed-json-from-server";
|
|
4
|
+
readonly invalidResponseShape: "invalid-response-shape";
|
|
5
|
+
readonly unknownServerError: "unknown-server-error";
|
|
6
|
+
readonly internalServerError: "internal-server-error";
|
|
7
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { default as z } from 'zod';
|
|
2
|
+
export declare const invalidApiKeySchema: z.ZodObject<{
|
|
3
|
+
code: z.ZodLiteral<"invalid-api-key">;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export declare const userNotFoundSchema: z.ZodObject<{
|
|
6
|
+
code: z.ZodLiteral<"user-not-found">;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const jwtNotAcceptableSchema: z.ZodObject<{
|
|
9
|
+
code: z.ZodLiteral<"jwt-not-acceptable">;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const invalidSignedUrlSchema: z.ZodObject<{
|
|
12
|
+
code: z.ZodLiteral<"invalid-signed-url">;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const hashMismatchSchema: z.ZodObject<{
|
|
15
|
+
code: z.ZodLiteral<"hash-mismatch">;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const invalidAuthHeaderValueSchema: z.ZodObject<{
|
|
18
|
+
code: z.ZodLiteral<"invalid-auth-header-value">;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const unsupportedAuthSchemeSchema: z.ZodObject<{
|
|
21
|
+
code: z.ZodLiteral<"unsupported-auth-scheme">;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const organizationStatusBadSchema: z.ZodObject<{
|
|
24
|
+
code: z.ZodLiteral<"bad-org-status">;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export declare const userNotExistsInOrganizationManagementSchema: z.ZodObject<{
|
|
27
|
+
code: z.ZodLiteral<"user-not-exists-in-organization-management">;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export declare const userNotExistInOrganizationSchema: z.ZodObject<{
|
|
30
|
+
code: z.ZodLiteral<"user-not-exists-in-organization">;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export declare const userDisabledSchema: z.ZodObject<{
|
|
33
|
+
code: z.ZodLiteral<"user-disabled">;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const tokenNotFoundSchema: z.ZodObject<{
|
|
36
|
+
code: z.ZodLiteral<"token-not-found">;
|
|
37
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as z } from 'zod';
|
|
2
|
+
export declare const invalidIDSchema: z.ZodObject<{
|
|
3
|
+
code: z.ZodLiteral<"invalid-id">;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export declare const routeNotFoundSchema: z.ZodObject<{
|
|
6
|
+
code: z.ZodLiteral<"route-not-found">;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const methodNotAllowedSchema: z.ZodObject<{
|
|
9
|
+
code: z.ZodLiteral<"method-not-allowed">;
|
|
10
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as z } from 'zod';
|
|
2
|
+
import { FormFieldError } from './formField';
|
|
3
|
+
export type FieldNode = {
|
|
4
|
+
key: string;
|
|
5
|
+
errors: FormFieldError[];
|
|
6
|
+
} | {
|
|
7
|
+
key: string;
|
|
8
|
+
children: FieldNode[];
|
|
9
|
+
};
|
|
10
|
+
export declare const formValidationFailedSchema: z.ZodObject<{
|
|
11
|
+
code: z.ZodLiteral<"validation-failed">;
|
|
12
|
+
details: z.ZodArray<z.ZodType<FieldNode, unknown, z.core.$ZodTypeInternals<FieldNode, unknown>>>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type FormValidationFailed = z.infer<typeof formValidationFailedSchema>;
|