@erxes/core-contract 0.1.0-v2.1 → 0.1.0-v2.2
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/activities.d.ts +1387 -139
- package/dist/activities.js +90 -30
- package/dist/audit.d.ts +1081 -33
- package/dist/audit.js +28 -14
- package/dist/auth.d.ts +2834 -26
- package/dist/auth.js +47 -18
- package/dist/automationRuns.d.ts +7 -9
- package/dist/automationRuns.js +12 -13
- package/dist/automations.d.ts +2443 -61
- package/dist/automations.js +41 -21
- package/dist/client.d.ts +30704 -0
- package/dist/client.js +62 -0
- package/dist/common.d.ts +0 -13
- package/dist/common.js +1 -13
- package/dist/companies.d.ts +1120 -10
- package/dist/companies.js +27 -12
- package/dist/contract/routes.json.js +17 -1
- package/dist/customerAuth.d.ts +1456 -17
- package/dist/customerAuth.js +33 -16
- package/dist/customers.d.ts +1232 -11
- package/dist/customers.js +28 -13
- package/dist/{automationDefinition.d.ts → db/src/automationDefinition.d.ts} +2 -2
- package/dist/{automationDefinition.js → db/src/automationDefinition.js} +2 -2
- package/dist/db/src/enums.js +1 -3
- package/dist/db/src/schema/automations.d.ts +1 -0
- package/dist/db/src/schema/automations.js +3 -3
- package/dist/db/src/schema/index.d.ts +3 -0
- package/dist/db/src/schema/index.js +3 -2
- package/dist/db/src/schema/leads.js +2 -2
- package/dist/db/src/schema/notes.js +92 -0
- package/dist/db/src/schema/payments.js +2 -2
- package/dist/db/src/schema/platform.js +0 -5
- package/dist/db/src/schema/plugins.js +7 -2
- package/dist/db/src/schema/transfer.js +2 -2
- package/dist/errors.d.ts +516 -0
- package/dist/errors.js +218 -0
- package/dist/events.d.ts +570 -121
- package/dist/events.js +41 -24
- package/dist/fields.d.ts +1456 -16
- package/dist/fields.js +27 -19
- package/dist/files.d.ts +761 -62
- package/dist/files.js +32 -21
- package/dist/index.d.ts +25187 -618
- package/dist/index.js +8 -7
- package/dist/leads.d.ts +1105 -21
- package/dist/leads.js +31 -13
- package/dist/notifications.d.ts +689 -48
- package/dist/notifications.js +38 -18
- package/dist/organizations.d.ts +260 -2
- package/dist/organizations.js +21 -2
- package/dist/payments.d.ts +1766 -62
- package/dist/payments.js +48 -26
- package/dist/platform.d.ts +12 -21
- package/dist/platform.js +7 -17
- package/dist/plugins.d.ts +802 -71
- package/dist/plugins.js +48 -27
- package/dist/products.d.ts +1380 -17
- package/dist/products.js +32 -16
- package/dist/roles.d.ts +560 -5
- package/dist/roles.js +20 -6
- package/dist/saas.d.ts +164 -2
- package/dist/saas.js +9 -2
- package/dist/tags.d.ts +340 -4
- package/dist/tags.js +14 -6
- package/dist/transfer.d.ts +1299 -12
- package/dist/transfer.js +32 -13
- package/dist/trash.d.ts +278 -21
- package/dist/trash.js +23 -16
- package/dist/users.d.ts +1206 -18
- package/dist/users.js +35 -13
- package/dist/values.d.ts +0 -9
- package/dist/values.js +2 -7
- package/dist/views.d.ts +396 -5
- package/dist/views.js +10 -7
- package/dist/webhooks.d.ts +765 -9
- package/dist/webhooks.js +18 -10
- package/package.json +6 -2
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Every error the API answers with, by code: its status and the shape of its
|
|
4
|
+
* `data`. A procedure declares the codes it can answer with (`COMMON_ERRORS`
|
|
5
|
+
* plus its module's), so clients get them typed: `isDefinedError(error) &&
|
|
6
|
+
* error.code === 'TAKEN'` narrows `error.data`. The API throws them with
|
|
7
|
+
* `fail()` (apps/api/src/http/errors.ts).
|
|
8
|
+
*/
|
|
9
|
+
export declare const ERRORS: {
|
|
10
|
+
UNAUTHORIZED: {
|
|
11
|
+
status: number;
|
|
12
|
+
};
|
|
13
|
+
NOT_ALLOWED: {
|
|
14
|
+
status: number;
|
|
15
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
permission: z.ZodString;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
};
|
|
19
|
+
PLUGIN_ONLY: {
|
|
20
|
+
status: number;
|
|
21
|
+
};
|
|
22
|
+
MEMBERS_ONLY: {
|
|
23
|
+
status: number;
|
|
24
|
+
};
|
|
25
|
+
ORG_REQUIRED: {
|
|
26
|
+
status: number;
|
|
27
|
+
};
|
|
28
|
+
SCOPE_REQUIRED: {
|
|
29
|
+
status: number;
|
|
30
|
+
};
|
|
31
|
+
SERVICE_TOKEN_REQUIRED: {
|
|
32
|
+
status: number;
|
|
33
|
+
};
|
|
34
|
+
CROSS_SITE: {
|
|
35
|
+
status: number;
|
|
36
|
+
};
|
|
37
|
+
INVALID_SIGNATURE: {
|
|
38
|
+
status: number;
|
|
39
|
+
};
|
|
40
|
+
OWNER_ONLY: {
|
|
41
|
+
status: number;
|
|
42
|
+
};
|
|
43
|
+
OWN_ROLE: {
|
|
44
|
+
status: number;
|
|
45
|
+
};
|
|
46
|
+
OWN_ACCOUNT: {
|
|
47
|
+
status: number;
|
|
48
|
+
};
|
|
49
|
+
ORGANIZATION_DISABLED: {
|
|
50
|
+
status: number;
|
|
51
|
+
data: z.ZodObject<{
|
|
52
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
};
|
|
55
|
+
NOT_IN_PLAN: {
|
|
56
|
+
status: number;
|
|
57
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
};
|
|
61
|
+
READ_ONLY: {
|
|
62
|
+
status: number;
|
|
63
|
+
};
|
|
64
|
+
TOO_MANY_REQUESTS: {
|
|
65
|
+
status: number;
|
|
66
|
+
};
|
|
67
|
+
TOO_MANY_STREAMS: {
|
|
68
|
+
status: number;
|
|
69
|
+
};
|
|
70
|
+
INVALID_INPUT: {
|
|
71
|
+
status: number;
|
|
72
|
+
data: z.ZodObject<{
|
|
73
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
74
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
75
|
+
message: z.ZodString;
|
|
76
|
+
}, z.core.$strip>>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
};
|
|
79
|
+
INVALID_JSON: {
|
|
80
|
+
status: number;
|
|
81
|
+
};
|
|
82
|
+
NOT_FOUND: {
|
|
83
|
+
status: number;
|
|
84
|
+
};
|
|
85
|
+
TAKEN: {
|
|
86
|
+
status: number;
|
|
87
|
+
data: z.ZodObject<{
|
|
88
|
+
field: z.ZodString;
|
|
89
|
+
id: z.ZodOptional<z.ZodString>;
|
|
90
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
};
|
|
93
|
+
INVALID_CURSOR: {
|
|
94
|
+
status: number;
|
|
95
|
+
};
|
|
96
|
+
INVALID_REFERENCE: {
|
|
97
|
+
status: number;
|
|
98
|
+
data: z.ZodObject<{
|
|
99
|
+
field: z.ZodString;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
};
|
|
102
|
+
INVALID_TYPE: {
|
|
103
|
+
status: number;
|
|
104
|
+
};
|
|
105
|
+
INVALID_ACTOR: {
|
|
106
|
+
status: number;
|
|
107
|
+
};
|
|
108
|
+
INVALID_OWNER: {
|
|
109
|
+
status: number;
|
|
110
|
+
};
|
|
111
|
+
INVALID_FILTER: {
|
|
112
|
+
status: number;
|
|
113
|
+
};
|
|
114
|
+
FILTER_TOO_SLOW: {
|
|
115
|
+
status: number;
|
|
116
|
+
};
|
|
117
|
+
LIMIT_EXCEEDED: {
|
|
118
|
+
status: number;
|
|
119
|
+
};
|
|
120
|
+
MASS_DELETE_STOPPED: {
|
|
121
|
+
status: number;
|
|
122
|
+
};
|
|
123
|
+
INVALID_URL: {
|
|
124
|
+
status: number;
|
|
125
|
+
};
|
|
126
|
+
INVALID_FILE: {
|
|
127
|
+
status: number;
|
|
128
|
+
};
|
|
129
|
+
INVALID_CREDENTIALS: {
|
|
130
|
+
status: number;
|
|
131
|
+
};
|
|
132
|
+
CHALLENGE_EXPIRED: {
|
|
133
|
+
status: number;
|
|
134
|
+
};
|
|
135
|
+
WRONG_CODE: {
|
|
136
|
+
status: number;
|
|
137
|
+
};
|
|
138
|
+
WRONG_PASSWORD: {
|
|
139
|
+
status: number;
|
|
140
|
+
};
|
|
141
|
+
SAME_PASSWORD: {
|
|
142
|
+
status: number;
|
|
143
|
+
};
|
|
144
|
+
TOO_MANY_ATTEMPTS: {
|
|
145
|
+
status: number;
|
|
146
|
+
};
|
|
147
|
+
ORGANIZATION_REQUIRED: {
|
|
148
|
+
status: number;
|
|
149
|
+
};
|
|
150
|
+
ALREADY_ENABLED: {
|
|
151
|
+
status: number;
|
|
152
|
+
};
|
|
153
|
+
NOT_ENABLED: {
|
|
154
|
+
status: number;
|
|
155
|
+
};
|
|
156
|
+
NOT_SET_UP: {
|
|
157
|
+
status: number;
|
|
158
|
+
};
|
|
159
|
+
INVALID_LINK: {
|
|
160
|
+
status: number;
|
|
161
|
+
};
|
|
162
|
+
NOT_INVITED: {
|
|
163
|
+
status: number;
|
|
164
|
+
};
|
|
165
|
+
SETUP_DISABLED: {
|
|
166
|
+
status: number;
|
|
167
|
+
};
|
|
168
|
+
SETUP_DONE: {
|
|
169
|
+
status: number;
|
|
170
|
+
};
|
|
171
|
+
LAST_OWNER: {
|
|
172
|
+
status: number;
|
|
173
|
+
};
|
|
174
|
+
INVALID_CODE: {
|
|
175
|
+
status: number;
|
|
176
|
+
};
|
|
177
|
+
INVALID_TOKEN: {
|
|
178
|
+
status: number;
|
|
179
|
+
};
|
|
180
|
+
TOO_MANY_CODES: {
|
|
181
|
+
status: number;
|
|
182
|
+
};
|
|
183
|
+
ORIGIN_NOT_ALLOWED: {
|
|
184
|
+
status: number;
|
|
185
|
+
};
|
|
186
|
+
UNKNOWN_APP: {
|
|
187
|
+
status: number;
|
|
188
|
+
};
|
|
189
|
+
LAST_LOGIN: {
|
|
190
|
+
status: number;
|
|
191
|
+
};
|
|
192
|
+
NOT_AUTHOR: {
|
|
193
|
+
status: number;
|
|
194
|
+
};
|
|
195
|
+
NO_TIMELINE: {
|
|
196
|
+
status: number;
|
|
197
|
+
};
|
|
198
|
+
TOO_MANY_REACTIONS: {
|
|
199
|
+
status: number;
|
|
200
|
+
};
|
|
201
|
+
INVALID_RECIPIENT: {
|
|
202
|
+
status: number;
|
|
203
|
+
};
|
|
204
|
+
ALWAYS_ON: {
|
|
205
|
+
status: number;
|
|
206
|
+
};
|
|
207
|
+
SUBJECT_REQUIRED: {
|
|
208
|
+
status: number;
|
|
209
|
+
};
|
|
210
|
+
NOTHING_TO_RETRY: {
|
|
211
|
+
status: number;
|
|
212
|
+
};
|
|
213
|
+
INVALID_AUTOMATION: {
|
|
214
|
+
status: number;
|
|
215
|
+
data: z.ZodObject<{
|
|
216
|
+
problems: z.ZodArray<z.ZodString>;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
};
|
|
219
|
+
INVALID_STEP_INPUT: {
|
|
220
|
+
status: number;
|
|
221
|
+
};
|
|
222
|
+
NO_SUBJECT: {
|
|
223
|
+
status: number;
|
|
224
|
+
};
|
|
225
|
+
NO_MEMBERS: {
|
|
226
|
+
status: number;
|
|
227
|
+
};
|
|
228
|
+
NOT_ACTIVE: {
|
|
229
|
+
status: number;
|
|
230
|
+
};
|
|
231
|
+
NOT_FAILED: {
|
|
232
|
+
status: number;
|
|
233
|
+
};
|
|
234
|
+
NOT_RUNNING: {
|
|
235
|
+
status: number;
|
|
236
|
+
};
|
|
237
|
+
NOT_A_LEAD: {
|
|
238
|
+
status: number;
|
|
239
|
+
};
|
|
240
|
+
INVALID_LEAD_STAGE: {
|
|
241
|
+
status: number;
|
|
242
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
243
|
+
stageId: z.ZodString;
|
|
244
|
+
}, z.core.$strip>>;
|
|
245
|
+
};
|
|
246
|
+
LAST_OPEN_STAGE: {
|
|
247
|
+
status: number;
|
|
248
|
+
};
|
|
249
|
+
LEAD_STAGE_IN_USE: {
|
|
250
|
+
status: number;
|
|
251
|
+
data: z.ZodObject<{
|
|
252
|
+
count: z.ZodInt;
|
|
253
|
+
}, z.core.$strip>;
|
|
254
|
+
};
|
|
255
|
+
INVALID_TAG: {
|
|
256
|
+
status: number;
|
|
257
|
+
};
|
|
258
|
+
TAG_LIMIT: {
|
|
259
|
+
status: number;
|
|
260
|
+
};
|
|
261
|
+
INVALID_FIELD: {
|
|
262
|
+
status: number;
|
|
263
|
+
data: z.ZodObject<{
|
|
264
|
+
fieldId: z.ZodString;
|
|
265
|
+
}, z.core.$strip>;
|
|
266
|
+
};
|
|
267
|
+
INVALID_FIELD_VALUE: {
|
|
268
|
+
status: number;
|
|
269
|
+
data: z.ZodObject<{
|
|
270
|
+
fieldId: z.ZodString;
|
|
271
|
+
}, z.core.$strip>;
|
|
272
|
+
};
|
|
273
|
+
INVALID_FIELD_GROUP: {
|
|
274
|
+
status: number;
|
|
275
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
276
|
+
groupId: z.ZodString;
|
|
277
|
+
}, z.core.$strip>>;
|
|
278
|
+
};
|
|
279
|
+
FIELD_IN_USE: {
|
|
280
|
+
status: number;
|
|
281
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
282
|
+
fieldId: z.ZodString;
|
|
283
|
+
}, z.core.$strip>>;
|
|
284
|
+
};
|
|
285
|
+
INVALID_CATEGORY: {
|
|
286
|
+
status: number;
|
|
287
|
+
};
|
|
288
|
+
CATEGORY_HAS_CHILDREN: {
|
|
289
|
+
status: number;
|
|
290
|
+
};
|
|
291
|
+
INVALID_PRODUCT: {
|
|
292
|
+
status: number;
|
|
293
|
+
};
|
|
294
|
+
PLUGIN_NOT_INSTALLED: {
|
|
295
|
+
status: number;
|
|
296
|
+
};
|
|
297
|
+
FILE_TOO_LARGE: {
|
|
298
|
+
status: number;
|
|
299
|
+
data: z.ZodObject<{
|
|
300
|
+
maxSizeMb: z.ZodNumber;
|
|
301
|
+
}, z.core.$strip>;
|
|
302
|
+
};
|
|
303
|
+
FILE_TYPE_NOT_ALLOWED: {
|
|
304
|
+
status: number;
|
|
305
|
+
data: z.ZodObject<{
|
|
306
|
+
allowedTypes: z.ZodArray<z.ZodString>;
|
|
307
|
+
}, z.core.$strip>;
|
|
308
|
+
};
|
|
309
|
+
UPLOAD_INCOMPLETE: {
|
|
310
|
+
status: number;
|
|
311
|
+
};
|
|
312
|
+
UPLOAD_CHANGED: {
|
|
313
|
+
status: number;
|
|
314
|
+
};
|
|
315
|
+
CONTENT_TYPE_MISMATCH: {
|
|
316
|
+
status: number;
|
|
317
|
+
};
|
|
318
|
+
SIZE_MISMATCH: {
|
|
319
|
+
status: number;
|
|
320
|
+
};
|
|
321
|
+
ALREADY_UPLOADED: {
|
|
322
|
+
status: number;
|
|
323
|
+
};
|
|
324
|
+
CURRENCY_NOT_SUPPORTED: {
|
|
325
|
+
status: number;
|
|
326
|
+
data: z.ZodObject<{
|
|
327
|
+
currency: z.ZodString;
|
|
328
|
+
}, z.core.$strip>;
|
|
329
|
+
};
|
|
330
|
+
DEFAULT_NOT_ALLOWED: {
|
|
331
|
+
status: number;
|
|
332
|
+
};
|
|
333
|
+
GATEWAY_NOT_ALLOWED: {
|
|
334
|
+
status: number;
|
|
335
|
+
};
|
|
336
|
+
GATEWAY_REFUSED: {
|
|
337
|
+
status: number;
|
|
338
|
+
};
|
|
339
|
+
GATEWAY_IN_USE: {
|
|
340
|
+
status: number;
|
|
341
|
+
};
|
|
342
|
+
KIND_CHANGED: {
|
|
343
|
+
status: number;
|
|
344
|
+
};
|
|
345
|
+
NO_GATEWAY: {
|
|
346
|
+
status: number;
|
|
347
|
+
};
|
|
348
|
+
NOT_PENDING: {
|
|
349
|
+
status: number;
|
|
350
|
+
};
|
|
351
|
+
NOT_TEST: {
|
|
352
|
+
status: number;
|
|
353
|
+
};
|
|
354
|
+
LINES_MISMATCH: {
|
|
355
|
+
status: number;
|
|
356
|
+
};
|
|
357
|
+
NOT_REFUNDABLE: {
|
|
358
|
+
status: number;
|
|
359
|
+
};
|
|
360
|
+
PARTIAL_NOT_SUPPORTED: {
|
|
361
|
+
status: number;
|
|
362
|
+
};
|
|
363
|
+
OWNER_REQUIRED: {
|
|
364
|
+
status: number;
|
|
365
|
+
};
|
|
366
|
+
TOKEN_USED: {
|
|
367
|
+
status: number;
|
|
368
|
+
};
|
|
369
|
+
NOT_A_MEMBER: {
|
|
370
|
+
status: number;
|
|
371
|
+
};
|
|
372
|
+
INVALID_CLIENT: {
|
|
373
|
+
status: number;
|
|
374
|
+
};
|
|
375
|
+
NOT_INSTALLED: {
|
|
376
|
+
status: number;
|
|
377
|
+
};
|
|
378
|
+
NAMESPACE_REQUIRED: {
|
|
379
|
+
status: number;
|
|
380
|
+
};
|
|
381
|
+
PLUGIN_NOT_FOUND: {
|
|
382
|
+
status: number;
|
|
383
|
+
};
|
|
384
|
+
INVALID_SUBDOMAIN: {
|
|
385
|
+
status: number;
|
|
386
|
+
};
|
|
387
|
+
UNKNOWN_PERMISSION: {
|
|
388
|
+
status: number;
|
|
389
|
+
data: z.ZodObject<{
|
|
390
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
391
|
+
}, z.core.$strip>;
|
|
392
|
+
};
|
|
393
|
+
OWNER_ONLY_PERMISSION: {
|
|
394
|
+
status: number;
|
|
395
|
+
data: z.ZodObject<{
|
|
396
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
397
|
+
}, z.core.$strip>;
|
|
398
|
+
};
|
|
399
|
+
BEYOND_OWN_PERMISSIONS: {
|
|
400
|
+
status: number;
|
|
401
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
402
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
403
|
+
}, z.core.$strip>>;
|
|
404
|
+
};
|
|
405
|
+
ROLE_NOT_FOUND: {
|
|
406
|
+
status: number;
|
|
407
|
+
};
|
|
408
|
+
FIXED_ROLE: {
|
|
409
|
+
status: number;
|
|
410
|
+
};
|
|
411
|
+
BUILTIN_ROLE: {
|
|
412
|
+
status: number;
|
|
413
|
+
};
|
|
414
|
+
ROLE_IN_USE: {
|
|
415
|
+
status: number;
|
|
416
|
+
};
|
|
417
|
+
UNSUPPORTED_FILE: {
|
|
418
|
+
status: number;
|
|
419
|
+
};
|
|
420
|
+
INVALID_COLUMNS: {
|
|
421
|
+
status: number;
|
|
422
|
+
};
|
|
423
|
+
INVALID_MAPPING: {
|
|
424
|
+
status: number;
|
|
425
|
+
};
|
|
426
|
+
INVALID_OPTIONS: {
|
|
427
|
+
status: number;
|
|
428
|
+
};
|
|
429
|
+
IMPORT_LOCKED: {
|
|
430
|
+
status: number;
|
|
431
|
+
};
|
|
432
|
+
NOT_UNDOABLE: {
|
|
433
|
+
status: number;
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
export type ErrorCode = keyof typeof ERRORS;
|
|
437
|
+
/** What any procedure can answer with: access, standing, input, a missing record, a unique or reference conflict, a list filter. */
|
|
438
|
+
export declare const COMMON_ERRORS: {
|
|
439
|
+
UNAUTHORIZED: {
|
|
440
|
+
status: number;
|
|
441
|
+
};
|
|
442
|
+
NOT_ALLOWED: {
|
|
443
|
+
status: number;
|
|
444
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
445
|
+
permission: z.ZodString;
|
|
446
|
+
}, z.core.$strip>>;
|
|
447
|
+
};
|
|
448
|
+
PLUGIN_ONLY: {
|
|
449
|
+
status: number;
|
|
450
|
+
};
|
|
451
|
+
MEMBERS_ONLY: {
|
|
452
|
+
status: number;
|
|
453
|
+
};
|
|
454
|
+
ORG_REQUIRED: {
|
|
455
|
+
status: number;
|
|
456
|
+
};
|
|
457
|
+
SCOPE_REQUIRED: {
|
|
458
|
+
status: number;
|
|
459
|
+
};
|
|
460
|
+
SERVICE_TOKEN_REQUIRED: {
|
|
461
|
+
status: number;
|
|
462
|
+
};
|
|
463
|
+
ORGANIZATION_DISABLED: {
|
|
464
|
+
status: number;
|
|
465
|
+
data: z.ZodObject<{
|
|
466
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
467
|
+
}, z.core.$strip>;
|
|
468
|
+
};
|
|
469
|
+
NOT_IN_PLAN: {
|
|
470
|
+
status: number;
|
|
471
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
472
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
473
|
+
}, z.core.$strip>>;
|
|
474
|
+
};
|
|
475
|
+
READ_ONLY: {
|
|
476
|
+
status: number;
|
|
477
|
+
};
|
|
478
|
+
TOO_MANY_REQUESTS: {
|
|
479
|
+
status: number;
|
|
480
|
+
};
|
|
481
|
+
INVALID_INPUT: {
|
|
482
|
+
status: number;
|
|
483
|
+
data: z.ZodObject<{
|
|
484
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
485
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
486
|
+
message: z.ZodString;
|
|
487
|
+
}, z.core.$strip>>;
|
|
488
|
+
}, z.core.$strip>;
|
|
489
|
+
};
|
|
490
|
+
NOT_FOUND: {
|
|
491
|
+
status: number;
|
|
492
|
+
};
|
|
493
|
+
TAKEN: {
|
|
494
|
+
status: number;
|
|
495
|
+
data: z.ZodObject<{
|
|
496
|
+
field: z.ZodString;
|
|
497
|
+
id: z.ZodOptional<z.ZodString>;
|
|
498
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
499
|
+
}, z.core.$strip>;
|
|
500
|
+
};
|
|
501
|
+
INVALID_CURSOR: {
|
|
502
|
+
status: number;
|
|
503
|
+
};
|
|
504
|
+
INVALID_REFERENCE: {
|
|
505
|
+
status: number;
|
|
506
|
+
data: z.ZodObject<{
|
|
507
|
+
field: z.ZodString;
|
|
508
|
+
}, z.core.$strip>;
|
|
509
|
+
};
|
|
510
|
+
INVALID_FILTER: {
|
|
511
|
+
status: number;
|
|
512
|
+
};
|
|
513
|
+
FILTER_TOO_SLOW: {
|
|
514
|
+
status: number;
|
|
515
|
+
};
|
|
516
|
+
};
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { InvalidInput } from "./common.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
const Permissions = z.object({ permissions: z.array(z.string()) });
|
|
5
|
+
/**
|
|
6
|
+
* Every error the API answers with, by code: its status and the shape of its
|
|
7
|
+
* `data`. A procedure declares the codes it can answer with (`COMMON_ERRORS`
|
|
8
|
+
* plus its module's), so clients get them typed: `isDefinedError(error) &&
|
|
9
|
+
* error.code === 'TAKEN'` narrows `error.data`. The API throws them with
|
|
10
|
+
* `fail()` (apps/api/src/http/errors.ts).
|
|
11
|
+
*/
|
|
12
|
+
const ERRORS = {
|
|
13
|
+
UNAUTHORIZED: { status: 401 },
|
|
14
|
+
NOT_ALLOWED: {
|
|
15
|
+
status: 403,
|
|
16
|
+
data: z.object({ permission: z.string() }).optional()
|
|
17
|
+
},
|
|
18
|
+
PLUGIN_ONLY: { status: 403 },
|
|
19
|
+
MEMBERS_ONLY: { status: 403 },
|
|
20
|
+
ORG_REQUIRED: { status: 403 },
|
|
21
|
+
SCOPE_REQUIRED: { status: 403 },
|
|
22
|
+
SERVICE_TOKEN_REQUIRED: { status: 403 },
|
|
23
|
+
CROSS_SITE: { status: 403 },
|
|
24
|
+
INVALID_SIGNATURE: { status: 403 },
|
|
25
|
+
OWNER_ONLY: { status: 403 },
|
|
26
|
+
OWN_ROLE: { status: 403 },
|
|
27
|
+
OWN_ACCOUNT: { status: 403 },
|
|
28
|
+
ORGANIZATION_DISABLED: {
|
|
29
|
+
status: 403,
|
|
30
|
+
data: z.object({ manageUrl: z.string().nullable() })
|
|
31
|
+
},
|
|
32
|
+
NOT_IN_PLAN: {
|
|
33
|
+
status: 402,
|
|
34
|
+
data: z.object({ manageUrl: z.string().nullable() }).optional()
|
|
35
|
+
},
|
|
36
|
+
READ_ONLY: { status: 402 },
|
|
37
|
+
TOO_MANY_REQUESTS: { status: 429 },
|
|
38
|
+
TOO_MANY_STREAMS: { status: 429 },
|
|
39
|
+
INVALID_INPUT: {
|
|
40
|
+
status: 400,
|
|
41
|
+
data: InvalidInput
|
|
42
|
+
},
|
|
43
|
+
INVALID_JSON: { status: 400 },
|
|
44
|
+
NOT_FOUND: { status: 404 },
|
|
45
|
+
TAKEN: {
|
|
46
|
+
status: 409,
|
|
47
|
+
data: z.object({
|
|
48
|
+
field: z.string(),
|
|
49
|
+
id: z.string().optional(),
|
|
50
|
+
values: z.array(z.string()).optional()
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
INVALID_CURSOR: { status: 400 },
|
|
54
|
+
INVALID_REFERENCE: {
|
|
55
|
+
status: 400,
|
|
56
|
+
data: z.object({ field: z.string() })
|
|
57
|
+
},
|
|
58
|
+
INVALID_TYPE: { status: 400 },
|
|
59
|
+
INVALID_ACTOR: { status: 400 },
|
|
60
|
+
INVALID_OWNER: { status: 400 },
|
|
61
|
+
INVALID_FILTER: { status: 400 },
|
|
62
|
+
FILTER_TOO_SLOW: { status: 400 },
|
|
63
|
+
LIMIT_EXCEEDED: { status: 400 },
|
|
64
|
+
MASS_DELETE_STOPPED: { status: 429 },
|
|
65
|
+
INVALID_URL: { status: 400 },
|
|
66
|
+
INVALID_FILE: { status: 400 },
|
|
67
|
+
INVALID_CREDENTIALS: { status: 401 },
|
|
68
|
+
CHALLENGE_EXPIRED: { status: 401 },
|
|
69
|
+
WRONG_CODE: { status: 400 },
|
|
70
|
+
WRONG_PASSWORD: { status: 400 },
|
|
71
|
+
SAME_PASSWORD: { status: 400 },
|
|
72
|
+
TOO_MANY_ATTEMPTS: { status: 429 },
|
|
73
|
+
ORGANIZATION_REQUIRED: { status: 400 },
|
|
74
|
+
ALREADY_ENABLED: { status: 409 },
|
|
75
|
+
NOT_ENABLED: { status: 409 },
|
|
76
|
+
NOT_SET_UP: { status: 409 },
|
|
77
|
+
INVALID_LINK: { status: 400 },
|
|
78
|
+
NOT_INVITED: { status: 409 },
|
|
79
|
+
SETUP_DISABLED: { status: 403 },
|
|
80
|
+
SETUP_DONE: { status: 409 },
|
|
81
|
+
LAST_OWNER: { status: 409 },
|
|
82
|
+
INVALID_CODE: { status: 400 },
|
|
83
|
+
INVALID_TOKEN: { status: 401 },
|
|
84
|
+
TOO_MANY_CODES: { status: 429 },
|
|
85
|
+
ORIGIN_NOT_ALLOWED: { status: 403 },
|
|
86
|
+
UNKNOWN_APP: { status: 400 },
|
|
87
|
+
LAST_LOGIN: { status: 409 },
|
|
88
|
+
NOT_AUTHOR: { status: 403 },
|
|
89
|
+
NO_TIMELINE: { status: 404 },
|
|
90
|
+
TOO_MANY_REACTIONS: { status: 400 },
|
|
91
|
+
INVALID_RECIPIENT: { status: 400 },
|
|
92
|
+
ALWAYS_ON: { status: 400 },
|
|
93
|
+
SUBJECT_REQUIRED: { status: 400 },
|
|
94
|
+
NOTHING_TO_RETRY: { status: 400 },
|
|
95
|
+
INVALID_AUTOMATION: {
|
|
96
|
+
status: 400,
|
|
97
|
+
data: z.object({ problems: z.array(z.string()) })
|
|
98
|
+
},
|
|
99
|
+
INVALID_STEP_INPUT: { status: 400 },
|
|
100
|
+
NO_SUBJECT: { status: 400 },
|
|
101
|
+
NO_MEMBERS: { status: 400 },
|
|
102
|
+
NOT_ACTIVE: { status: 409 },
|
|
103
|
+
NOT_FAILED: { status: 409 },
|
|
104
|
+
NOT_RUNNING: { status: 409 },
|
|
105
|
+
NOT_A_LEAD: { status: 400 },
|
|
106
|
+
INVALID_LEAD_STAGE: {
|
|
107
|
+
status: 400,
|
|
108
|
+
data: z.object({ stageId: z.string() }).optional()
|
|
109
|
+
},
|
|
110
|
+
LAST_OPEN_STAGE: { status: 409 },
|
|
111
|
+
LEAD_STAGE_IN_USE: {
|
|
112
|
+
status: 409,
|
|
113
|
+
data: z.object({ count: z.int() })
|
|
114
|
+
},
|
|
115
|
+
INVALID_TAG: { status: 400 },
|
|
116
|
+
TAG_LIMIT: { status: 409 },
|
|
117
|
+
INVALID_FIELD: {
|
|
118
|
+
status: 400,
|
|
119
|
+
data: z.object({ fieldId: z.string() })
|
|
120
|
+
},
|
|
121
|
+
INVALID_FIELD_VALUE: {
|
|
122
|
+
status: 400,
|
|
123
|
+
data: z.object({ fieldId: z.string() })
|
|
124
|
+
},
|
|
125
|
+
INVALID_FIELD_GROUP: {
|
|
126
|
+
status: 400,
|
|
127
|
+
data: z.object({ groupId: z.string() }).optional()
|
|
128
|
+
},
|
|
129
|
+
FIELD_IN_USE: {
|
|
130
|
+
status: 409,
|
|
131
|
+
data: z.object({ fieldId: z.string() }).optional()
|
|
132
|
+
},
|
|
133
|
+
INVALID_CATEGORY: { status: 400 },
|
|
134
|
+
CATEGORY_HAS_CHILDREN: { status: 409 },
|
|
135
|
+
INVALID_PRODUCT: { status: 400 },
|
|
136
|
+
PLUGIN_NOT_INSTALLED: { status: 400 },
|
|
137
|
+
FILE_TOO_LARGE: {
|
|
138
|
+
status: 400,
|
|
139
|
+
data: z.object({ maxSizeMb: z.number() })
|
|
140
|
+
},
|
|
141
|
+
FILE_TYPE_NOT_ALLOWED: {
|
|
142
|
+
status: 400,
|
|
143
|
+
data: z.object({ allowedTypes: z.array(z.string()) })
|
|
144
|
+
},
|
|
145
|
+
UPLOAD_INCOMPLETE: { status: 409 },
|
|
146
|
+
UPLOAD_CHANGED: { status: 409 },
|
|
147
|
+
CONTENT_TYPE_MISMATCH: { status: 400 },
|
|
148
|
+
SIZE_MISMATCH: { status: 400 },
|
|
149
|
+
ALREADY_UPLOADED: { status: 409 },
|
|
150
|
+
CURRENCY_NOT_SUPPORTED: {
|
|
151
|
+
status: 400,
|
|
152
|
+
data: z.object({ currency: z.string() })
|
|
153
|
+
},
|
|
154
|
+
DEFAULT_NOT_ALLOWED: { status: 400 },
|
|
155
|
+
GATEWAY_NOT_ALLOWED: { status: 403 },
|
|
156
|
+
GATEWAY_REFUSED: { status: 400 },
|
|
157
|
+
GATEWAY_IN_USE: { status: 409 },
|
|
158
|
+
KIND_CHANGED: { status: 400 },
|
|
159
|
+
NO_GATEWAY: { status: 400 },
|
|
160
|
+
NOT_PENDING: { status: 409 },
|
|
161
|
+
NOT_TEST: { status: 400 },
|
|
162
|
+
LINES_MISMATCH: { status: 400 },
|
|
163
|
+
NOT_REFUNDABLE: { status: 409 },
|
|
164
|
+
PARTIAL_NOT_SUPPORTED: { status: 409 },
|
|
165
|
+
OWNER_REQUIRED: { status: 400 },
|
|
166
|
+
TOKEN_USED: { status: 400 },
|
|
167
|
+
NOT_A_MEMBER: { status: 403 },
|
|
168
|
+
INVALID_CLIENT: { status: 401 },
|
|
169
|
+
NOT_INSTALLED: { status: 403 },
|
|
170
|
+
NAMESPACE_REQUIRED: { status: 400 },
|
|
171
|
+
PLUGIN_NOT_FOUND: { status: 404 },
|
|
172
|
+
INVALID_SUBDOMAIN: { status: 400 },
|
|
173
|
+
UNKNOWN_PERMISSION: {
|
|
174
|
+
status: 400,
|
|
175
|
+
data: Permissions
|
|
176
|
+
},
|
|
177
|
+
OWNER_ONLY_PERMISSION: {
|
|
178
|
+
status: 400,
|
|
179
|
+
data: Permissions
|
|
180
|
+
},
|
|
181
|
+
BEYOND_OWN_PERMISSIONS: {
|
|
182
|
+
status: 403,
|
|
183
|
+
data: Permissions.optional()
|
|
184
|
+
},
|
|
185
|
+
ROLE_NOT_FOUND: { status: 404 },
|
|
186
|
+
FIXED_ROLE: { status: 403 },
|
|
187
|
+
BUILTIN_ROLE: { status: 403 },
|
|
188
|
+
ROLE_IN_USE: { status: 409 },
|
|
189
|
+
UNSUPPORTED_FILE: { status: 400 },
|
|
190
|
+
INVALID_COLUMNS: { status: 400 },
|
|
191
|
+
INVALID_MAPPING: { status: 400 },
|
|
192
|
+
INVALID_OPTIONS: { status: 400 },
|
|
193
|
+
IMPORT_LOCKED: { status: 409 },
|
|
194
|
+
NOT_UNDOABLE: { status: 409 }
|
|
195
|
+
};
|
|
196
|
+
const { UNAUTHORIZED, NOT_ALLOWED, PLUGIN_ONLY, MEMBERS_ONLY, ORG_REQUIRED, SCOPE_REQUIRED, SERVICE_TOKEN_REQUIRED, ORGANIZATION_DISABLED, NOT_IN_PLAN, READ_ONLY, TOO_MANY_REQUESTS, INVALID_INPUT, NOT_FOUND, TAKEN, INVALID_CURSOR, INVALID_REFERENCE, INVALID_FILTER, FILTER_TOO_SLOW } = ERRORS;
|
|
197
|
+
/** What any procedure can answer with: access, standing, input, a missing record, a unique or reference conflict, a list filter. */
|
|
198
|
+
const COMMON_ERRORS = {
|
|
199
|
+
UNAUTHORIZED,
|
|
200
|
+
NOT_ALLOWED,
|
|
201
|
+
PLUGIN_ONLY,
|
|
202
|
+
MEMBERS_ONLY,
|
|
203
|
+
ORG_REQUIRED,
|
|
204
|
+
SCOPE_REQUIRED,
|
|
205
|
+
SERVICE_TOKEN_REQUIRED,
|
|
206
|
+
ORGANIZATION_DISABLED,
|
|
207
|
+
NOT_IN_PLAN,
|
|
208
|
+
READ_ONLY,
|
|
209
|
+
TOO_MANY_REQUESTS,
|
|
210
|
+
INVALID_INPUT,
|
|
211
|
+
NOT_FOUND,
|
|
212
|
+
TAKEN,
|
|
213
|
+
INVALID_CURSOR,
|
|
214
|
+
INVALID_REFERENCE,
|
|
215
|
+
INVALID_FILTER,
|
|
216
|
+
FILTER_TOO_SLOW
|
|
217
|
+
};
|
|
218
|
+
export { COMMON_ERRORS, ERRORS };
|