@adgytec/adgytec-web-utils 0.0.2 → 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 +42 -31
- package/dist/chunks/formParse +11 -0
- package/dist/chunks/schema +322 -0
- package/dist/chunks/upload +97 -95
- package/dist/constants/httpRequestCredentials.d.ts +1 -0
- package/dist/constants/httpRequestHeaders.d.ts +14 -6
- package/dist/constants/http_methods.d.ts +7 -0
- package/dist/constants/index.d.ts +2 -2
- package/dist/constants/index.js +27 -15
- 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 +3 -6
- package/dist/errors/types.d.ts +0 -19
- package/dist/index.d.ts +2 -0
- package/dist/index.js +97 -33
- package/dist/media/types/lifecycle.d.ts +1 -2
- package/dist/response/errorResponse.d.ts +1 -0
- package/dist/response/successReponse.d.ts +2 -0
- package/dist/test.d.ts +1 -0
- package/package.json +2 -1
- package/dist/chunks/apiError +0 -24
- package/dist/chunks/parse +0 -88
- package/dist/constants/http.d.ts +0 -5
- package/dist/constants/httpRequest.d.ts +0 -3
- package/dist/errors/apiError.d.ts +0 -8
- package/dist/errors/parse.d.ts +0 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { g as t } from "./schema";
|
|
2
|
+
class a extends Error {
|
|
3
|
+
}
|
|
4
|
+
class i extends a {
|
|
5
|
+
#s;
|
|
6
|
+
#r;
|
|
7
|
+
constructor(r, e = {}) {
|
|
8
|
+
super("application-error"), this.#s = r, this.#r = {
|
|
9
|
+
...e,
|
|
10
|
+
code: r
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
get details() {
|
|
14
|
+
return this.#r;
|
|
15
|
+
}
|
|
16
|
+
get code() {
|
|
17
|
+
return this.#s;
|
|
18
|
+
}
|
|
19
|
+
parse() {
|
|
20
|
+
return t.parse(this.#r);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
i as A,
|
|
25
|
+
a as B
|
|
26
|
+
};
|
package/dist/chunks/decode
CHANGED
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
message: "Expected response body but received empty response"
|
|
10
|
-
});
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
throw new r(e, {
|
|
14
|
-
message: "Empty error response from server"
|
|
1
|
+
import a from "zod";
|
|
2
|
+
import { A as s } from "./applicationError";
|
|
3
|
+
import { serverCodes as t } from "../errorCodes/index.js";
|
|
4
|
+
function c(e, o) {
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new s(t.invalidResponseShape, {
|
|
7
|
+
message: "Expected response body but received empty response",
|
|
8
|
+
payload: e
|
|
15
9
|
});
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const r = o.safeParse(e);
|
|
11
|
+
if (r.success) return r.data;
|
|
12
|
+
throw new s(t.invalidResponseShape, {
|
|
13
|
+
message: r.error.message,
|
|
14
|
+
payload: e
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const i = a.object({
|
|
18
|
+
code: a.string()
|
|
19
|
+
}).loose();
|
|
20
|
+
function p(e, o) {
|
|
21
|
+
const r = i.safeParse(o);
|
|
22
|
+
throw r.success ? new s(r.data.code, r.data) : e >= 500 ? new s(t.internalServerError) : new s(t.unknownServerError, {
|
|
23
|
+
payload: o
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function u(e, o) {
|
|
27
|
+
if (!o && e.ok)
|
|
28
|
+
return null;
|
|
29
|
+
let r;
|
|
18
30
|
try {
|
|
19
|
-
|
|
31
|
+
r = await e.text();
|
|
20
32
|
} catch {
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
throw new s(t.malformedResponseBody, {
|
|
34
|
+
response: e
|
|
35
|
+
});
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new
|
|
30
|
-
|
|
37
|
+
let n;
|
|
38
|
+
if (r.length > 0)
|
|
39
|
+
try {
|
|
40
|
+
n = JSON.parse(r);
|
|
41
|
+
} catch {
|
|
42
|
+
throw new s(t.malformedJsonFromServer, {
|
|
43
|
+
response: e
|
|
31
44
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const a = f(t);
|
|
35
|
-
throw new r(e, a);
|
|
45
|
+
}
|
|
46
|
+
return e.ok ? c(n, o) : p(e.status, n);
|
|
36
47
|
}
|
|
37
48
|
export {
|
|
38
|
-
|
|
49
|
+
u as d
|
|
39
50
|
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import e from "zod";
|
|
2
|
+
import { serverCodes as c, formFieldInvalidTypeCauses as a, formFieldTypes as r, formCodes as b, authCodes as o, requestBodyCodes as n, paginationCodes as h, commonCodes as d, mediaCodes as t, iamCodes as l } from "../errorCodes/index.js";
|
|
3
|
+
const S = e.object({
|
|
4
|
+
code: e.literal(c.malformedResponseBody),
|
|
5
|
+
response: e.instanceof(Response)
|
|
6
|
+
}), p = e.object({
|
|
7
|
+
code: e.literal(c.malformedJsonFromServer),
|
|
8
|
+
response: e.instanceof(Response)
|
|
9
|
+
}), j = e.object({
|
|
10
|
+
code: e.literal(c.invalidResponseShape),
|
|
11
|
+
message: e.string(),
|
|
12
|
+
payload: e.unknown()
|
|
13
|
+
}).transform(({ code: s, message: i, payload: u }) => ({
|
|
14
|
+
code: s,
|
|
15
|
+
debugMessage: i,
|
|
16
|
+
payload: u
|
|
17
|
+
})), g = e.object({
|
|
18
|
+
code: e.literal(c.unknownServerError),
|
|
19
|
+
payload: e.unknown()
|
|
20
|
+
}), v = e.object({
|
|
21
|
+
code: e.literal(c.internalServerError)
|
|
22
|
+
}), y = e.object({
|
|
23
|
+
cause: e.literal(a.invalidValue)
|
|
24
|
+
}), E = e.object({
|
|
25
|
+
cause: e.literal(a.invalidEnumValue),
|
|
26
|
+
possibleValues: e.array(e.string())
|
|
27
|
+
}), f = e.object({
|
|
28
|
+
cause: e.literal(a.requireHttps)
|
|
29
|
+
}), F = e.object({
|
|
30
|
+
cause: e.literal(a.missingHost)
|
|
31
|
+
}), U = e.object({
|
|
32
|
+
cause: e.literal(a.containsPath)
|
|
33
|
+
}), N = e.object({
|
|
34
|
+
cause: e.literal(a.containsQuery)
|
|
35
|
+
}), I = e.object({
|
|
36
|
+
cause: e.literal(a.containsFragment)
|
|
37
|
+
}), M = e.object({
|
|
38
|
+
cause: e.literal(a.absoluteUrl)
|
|
39
|
+
}), w = e.object({
|
|
40
|
+
cause: e.literal(a.nilID)
|
|
41
|
+
}), A = e.object({
|
|
42
|
+
cause: e.literal(a.invalidEmail)
|
|
43
|
+
}), V = e.object({
|
|
44
|
+
cause: e.literal(a.missingMxRecords)
|
|
45
|
+
}), x = e.object({
|
|
46
|
+
cause: e.literal(a.notDigit)
|
|
47
|
+
}), B = e.object({
|
|
48
|
+
cause: e.literal(a.notBase64UrlEncoded)
|
|
49
|
+
}), C = e.object({
|
|
50
|
+
cause: e.literal(a.invalidUrl)
|
|
51
|
+
}), D = e.object({
|
|
52
|
+
cause: e.literal(a.nullValue)
|
|
53
|
+
}), R = e.discriminatedUnion(
|
|
54
|
+
"cause",
|
|
55
|
+
[
|
|
56
|
+
y,
|
|
57
|
+
E,
|
|
58
|
+
f,
|
|
59
|
+
F,
|
|
60
|
+
U,
|
|
61
|
+
N,
|
|
62
|
+
I,
|
|
63
|
+
M,
|
|
64
|
+
w,
|
|
65
|
+
A,
|
|
66
|
+
V,
|
|
67
|
+
x,
|
|
68
|
+
B,
|
|
69
|
+
C,
|
|
70
|
+
D
|
|
71
|
+
]
|
|
72
|
+
), k = e.object({
|
|
73
|
+
type: e.literal(r.unknown)
|
|
74
|
+
}), q = e.object({
|
|
75
|
+
type: e.literal(r.missing)
|
|
76
|
+
}), z = e.object({
|
|
77
|
+
type: e.literal(r.overflow),
|
|
78
|
+
details: e.object({
|
|
79
|
+
max: e.union([e.coerce.date(), e.number()])
|
|
80
|
+
})
|
|
81
|
+
}), O = e.object({
|
|
82
|
+
type: e.literal(r.underflow),
|
|
83
|
+
details: e.object({
|
|
84
|
+
min: e.union([e.coerce.date(), e.number()])
|
|
85
|
+
})
|
|
86
|
+
}), P = e.object({
|
|
87
|
+
type: e.literal(r.length),
|
|
88
|
+
details: e.object({
|
|
89
|
+
min: e.number(),
|
|
90
|
+
max: e.number()
|
|
91
|
+
})
|
|
92
|
+
}), T = e.object({
|
|
93
|
+
type: e.literal(r.invalid),
|
|
94
|
+
details: R
|
|
95
|
+
}), L = e.discriminatedUnion("type", [
|
|
96
|
+
k,
|
|
97
|
+
q,
|
|
98
|
+
z,
|
|
99
|
+
O,
|
|
100
|
+
P,
|
|
101
|
+
T
|
|
102
|
+
]), m = e.lazy(
|
|
103
|
+
() => e.union([
|
|
104
|
+
e.object({
|
|
105
|
+
key: e.string(),
|
|
106
|
+
errors: e.array(L)
|
|
107
|
+
}),
|
|
108
|
+
e.object({
|
|
109
|
+
key: e.string(),
|
|
110
|
+
children: e.array(m)
|
|
111
|
+
})
|
|
112
|
+
])
|
|
113
|
+
), H = e.object({
|
|
114
|
+
code: e.literal(b.formValidationFailed),
|
|
115
|
+
details: e.array(m)
|
|
116
|
+
}), J = e.object({
|
|
117
|
+
code: e.literal(o.invalidApiKey)
|
|
118
|
+
}), K = e.object({
|
|
119
|
+
code: e.literal(o.userNotFound)
|
|
120
|
+
}), Q = e.object({
|
|
121
|
+
code: e.literal(o.jwtNotAcceptable)
|
|
122
|
+
}), G = e.object({
|
|
123
|
+
code: e.literal(o.invalidSignedUrl)
|
|
124
|
+
}), W = e.object({
|
|
125
|
+
code: e.literal(o.hashMismatch)
|
|
126
|
+
}), X = e.object({
|
|
127
|
+
code: e.literal(o.invalidAuthHeaderValue)
|
|
128
|
+
}), Y = e.object({
|
|
129
|
+
code: e.literal(o.unsupportedAuthScheme)
|
|
130
|
+
}), Z = e.object({
|
|
131
|
+
code: e.literal(o.organizationStatusBad)
|
|
132
|
+
}), _ = e.object({
|
|
133
|
+
code: e.literal(o.userNotExistsInOrganizationManagement)
|
|
134
|
+
}), $ = e.object({
|
|
135
|
+
code: e.literal(o.userNotExistInOrganization)
|
|
136
|
+
}), ee = e.object({
|
|
137
|
+
code: e.literal(o.userDisabled)
|
|
138
|
+
}), ae = e.object({
|
|
139
|
+
code: e.literal(o.tokenNotFound)
|
|
140
|
+
}), oe = e.object({
|
|
141
|
+
code: e.literal(n.invalidRequestBody),
|
|
142
|
+
message: e.string()
|
|
143
|
+
}).transform(({ code: s, message: i }) => ({
|
|
144
|
+
code: s,
|
|
145
|
+
debugMessage: i
|
|
146
|
+
})), te = e.object({
|
|
147
|
+
code: e.literal(n.unknownFieldInRequestBody),
|
|
148
|
+
message: e.string()
|
|
149
|
+
}).transform(({ code: s, message: i }) => ({
|
|
150
|
+
code: s,
|
|
151
|
+
debugMessage: i
|
|
152
|
+
})), se = e.object({
|
|
153
|
+
code: e.literal(n.requestBodyTooLarge),
|
|
154
|
+
limit: e.int()
|
|
155
|
+
}), ie = e.object({
|
|
156
|
+
code: e.literal(n.emptyRequestBody),
|
|
157
|
+
message: e.string()
|
|
158
|
+
}).transform(({ code: s, message: i }) => ({
|
|
159
|
+
code: s,
|
|
160
|
+
debugMessage: i
|
|
161
|
+
})), re = e.object({
|
|
162
|
+
code: e.literal(h.invalidCursorValue)
|
|
163
|
+
}), ce = e.object({
|
|
164
|
+
code: e.literal(d.invalidId)
|
|
165
|
+
}), ne = e.object({
|
|
166
|
+
code: e.literal(d.routeNotFound)
|
|
167
|
+
}), le = e.object({
|
|
168
|
+
code: e.literal(d.methodNotAllowed)
|
|
169
|
+
}), de = e.object({
|
|
170
|
+
code: e.literal(t.invalidMultipartNumber)
|
|
171
|
+
}), me = e.object({
|
|
172
|
+
code: e.literal(t.mediaObjectNotFound)
|
|
173
|
+
}), ue = e.object({
|
|
174
|
+
code: e.literal(t.mediaTooLarge),
|
|
175
|
+
mediaID: e.uuidv7(),
|
|
176
|
+
currentSize: e.int(),
|
|
177
|
+
maxSupportedSize: e.int()
|
|
178
|
+
}), be = e.object({
|
|
179
|
+
code: e.literal(t.mediaItemsLimitExceeded),
|
|
180
|
+
currentLength: e.int(),
|
|
181
|
+
maxItemsSupported: e.int()
|
|
182
|
+
}), he = e.object({
|
|
183
|
+
code: e.literal(t.uploadAlreadyCompleted)
|
|
184
|
+
}), Se = e.object({
|
|
185
|
+
code: e.literal(t.unsupportedObjectUploaded)
|
|
186
|
+
}), pe = e.object({
|
|
187
|
+
code: e.literal(t.completeMultipartUploadCalledTooSoon)
|
|
188
|
+
}), je = e.object({
|
|
189
|
+
code: e.literal(t.singlepartUploadFailed),
|
|
190
|
+
mediaID: e.uuidv7()
|
|
191
|
+
}), ge = e.object({
|
|
192
|
+
code: e.literal(t.multipartPartUploadFailed),
|
|
193
|
+
mediaID: e.uuidv7(),
|
|
194
|
+
partNumber: e.int()
|
|
195
|
+
}), ve = e.object({
|
|
196
|
+
code: e.literal(t.missingETagValue),
|
|
197
|
+
mediaID: e.uuidv7(),
|
|
198
|
+
partNumber: e.int()
|
|
199
|
+
}), ye = e.object({
|
|
200
|
+
code: e.literal(l.selfPermissionMismatch),
|
|
201
|
+
permission: e.string(),
|
|
202
|
+
key: e.string(),
|
|
203
|
+
required: e.string(),
|
|
204
|
+
got: e.string()
|
|
205
|
+
}), Ee = e.object({
|
|
206
|
+
code: e.literal(l.invalidActor),
|
|
207
|
+
supportedActors: e.array(e.string()),
|
|
208
|
+
currentActor: e.string()
|
|
209
|
+
}), fe = e.object({
|
|
210
|
+
code: e.literal(l.permissionExplicitlyDenied),
|
|
211
|
+
deniedPermission: e.string()
|
|
212
|
+
}), Fe = e.object({
|
|
213
|
+
code: e.literal(l.missingPermission),
|
|
214
|
+
missingPermission: e.string()
|
|
215
|
+
}), Ie = e.discriminatedUnion("code", [
|
|
216
|
+
J,
|
|
217
|
+
K,
|
|
218
|
+
Q,
|
|
219
|
+
G,
|
|
220
|
+
W,
|
|
221
|
+
X,
|
|
222
|
+
Z,
|
|
223
|
+
_,
|
|
224
|
+
$,
|
|
225
|
+
ee,
|
|
226
|
+
ae,
|
|
227
|
+
Y,
|
|
228
|
+
ce,
|
|
229
|
+
ne,
|
|
230
|
+
le,
|
|
231
|
+
H,
|
|
232
|
+
ye,
|
|
233
|
+
Ee,
|
|
234
|
+
fe,
|
|
235
|
+
Fe,
|
|
236
|
+
de,
|
|
237
|
+
me,
|
|
238
|
+
ue,
|
|
239
|
+
be,
|
|
240
|
+
he,
|
|
241
|
+
Se,
|
|
242
|
+
pe,
|
|
243
|
+
je,
|
|
244
|
+
ge,
|
|
245
|
+
ve,
|
|
246
|
+
re,
|
|
247
|
+
oe,
|
|
248
|
+
te,
|
|
249
|
+
se,
|
|
250
|
+
ie,
|
|
251
|
+
S,
|
|
252
|
+
p,
|
|
253
|
+
j,
|
|
254
|
+
g,
|
|
255
|
+
v
|
|
256
|
+
]);
|
|
257
|
+
export {
|
|
258
|
+
je as $,
|
|
259
|
+
oe as A,
|
|
260
|
+
j as B,
|
|
261
|
+
G as C,
|
|
262
|
+
C as D,
|
|
263
|
+
y as E,
|
|
264
|
+
Q as F,
|
|
265
|
+
p as G,
|
|
266
|
+
S as H,
|
|
267
|
+
be as I,
|
|
268
|
+
me as J,
|
|
269
|
+
ue as K,
|
|
270
|
+
le as L,
|
|
271
|
+
ve as M,
|
|
272
|
+
F as N,
|
|
273
|
+
V as O,
|
|
274
|
+
Fe as P,
|
|
275
|
+
ge as Q,
|
|
276
|
+
w as R,
|
|
277
|
+
B as S,
|
|
278
|
+
x as T,
|
|
279
|
+
D as U,
|
|
280
|
+
Z as V,
|
|
281
|
+
fe as W,
|
|
282
|
+
se as X,
|
|
283
|
+
f as Y,
|
|
284
|
+
ne as Z,
|
|
285
|
+
ye as _,
|
|
286
|
+
M as a,
|
|
287
|
+
ae as a0,
|
|
288
|
+
te as a1,
|
|
289
|
+
g as a2,
|
|
290
|
+
Y as a3,
|
|
291
|
+
Se as a4,
|
|
292
|
+
he as a5,
|
|
293
|
+
ee as a6,
|
|
294
|
+
$ as a7,
|
|
295
|
+
_ as a8,
|
|
296
|
+
K as a9,
|
|
297
|
+
I as b,
|
|
298
|
+
pe as c,
|
|
299
|
+
U as d,
|
|
300
|
+
N as e,
|
|
301
|
+
ie as f,
|
|
302
|
+
Ie as g,
|
|
303
|
+
T as h,
|
|
304
|
+
P as i,
|
|
305
|
+
q as j,
|
|
306
|
+
z as k,
|
|
307
|
+
O as l,
|
|
308
|
+
k as m,
|
|
309
|
+
L as n,
|
|
310
|
+
R as o,
|
|
311
|
+
H as p,
|
|
312
|
+
W as q,
|
|
313
|
+
v as r,
|
|
314
|
+
Ee as s,
|
|
315
|
+
J as t,
|
|
316
|
+
X as u,
|
|
317
|
+
re as v,
|
|
318
|
+
A as w,
|
|
319
|
+
E as x,
|
|
320
|
+
ce as y,
|
|
321
|
+
de as z
|
|
322
|
+
};
|