@erxes/core-contract 0.1.0-v2.0 → 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 +1394 -139
- package/dist/activities.js +96 -40
- package/dist/audit.d.ts +1092 -48
- package/dist/audit.js +37 -23
- package/dist/auth.d.ts +2867 -61
- package/dist/auth.js +55 -25
- package/dist/automationRuns.d.ts +12 -13
- package/dist/automationRuns.js +15 -30
- package/dist/automations.d.ts +2474 -93
- package/dist/automations.js +56 -44
- package/dist/client.d.ts +30704 -0
- package/dist/client.js +62 -0
- package/dist/common.d.ts +28 -16
- package/dist/common.js +30 -22
- package/dist/companies.d.ts +1154 -44
- package/dist/companies.js +33 -17
- package/dist/contract/routes.json.js +1810 -0
- package/dist/customerAuth.d.ts +1661 -0
- package/dist/customerAuth.js +197 -0
- package/dist/customers.d.ts +1283 -65
- package/dist/customers.js +35 -25
- package/dist/{automationDefinition.d.ts → db/src/automationDefinition.d.ts} +4 -3
- package/dist/{automationDefinition.js → db/src/automationDefinition.js} +10 -32
- package/dist/db/src/enums.d.ts +8 -0
- package/dist/db/src/enums.js +334 -0
- package/dist/db/src/schema/auditStreams.js +6 -14
- package/dist/db/src/schema/authTokens.js +4 -6
- package/dist/db/src/schema/automations.d.ts +1 -0
- package/dist/db/src/schema/automations.js +15 -31
- package/dist/db/src/schema/common.d.ts +2 -6
- package/dist/db/src/schema/common.js +1 -24
- package/dist/db/src/schema/companies.js +6 -5
- package/dist/db/src/schema/customerAuth.js +101 -0
- package/dist/db/src/schema/customers.js +6 -6
- package/dist/db/src/schema/events.js +12 -60
- package/dist/db/src/schema/fieldValues.js +2 -2
- package/dist/db/src/schema/fields.js +10 -28
- package/dist/db/src/schema/index.d.ts +3 -0
- package/dist/db/src/schema/index.js +22 -20
- package/dist/db/src/schema/leadStages.js +5 -10
- package/dist/db/src/schema/leads.js +6 -11
- package/dist/db/src/schema/notes.js +92 -0
- package/dist/db/src/schema/oauth.js +3 -3
- package/dist/db/src/schema/payments.js +13 -23
- package/dist/db/src/schema/platform.js +11 -31
- package/dist/db/src/schema/plugins.js +10 -5
- package/dist/db/src/schema/products.js +7 -8
- package/dist/db/src/schema/rateLimits.js +7 -0
- package/dist/db/src/schema/saas.js +3 -9
- package/dist/db/src/schema/tags.js +6 -5
- package/dist/db/src/schema/transfer.js +13 -33
- package/dist/db/src/schema/trash.js +6 -7
- package/dist/db/src/schema/users.js +6 -10
- package/dist/db/src/schema/views.js +5 -13
- package/dist/db/src/schema/webhooks.js +7 -14
- package/dist/db/src/table.js +16 -2
- package/dist/errors.d.ts +516 -0
- package/dist/errors.js +218 -0
- package/dist/events.d.ts +585 -140
- package/dist/events.js +57 -42
- package/dist/fields.d.ts +1478 -66
- package/dist/fields.js +33 -47
- package/dist/files.d.ts +766 -62
- package/dist/files.js +34 -22
- package/dist/index.d.ts +25707 -902
- package/dist/index.js +22 -20
- package/dist/leads.d.ts +1108 -22
- package/dist/leads.js +39 -20
- package/dist/notifications.d.ts +691 -94
- package/dist/notifications.js +45 -91
- package/dist/organizations.d.ts +263 -5
- package/dist/organizations.js +21 -2
- package/dist/payments.d.ts +1794 -120
- package/dist/payments.js +58 -60
- package/dist/platform.d.ts +12 -20
- package/dist/platform.js +8 -21
- package/dist/plugins.d.ts +808 -71
- package/dist/plugins.js +66 -35
- package/dist/products.d.ts +1411 -53
- package/dist/products.js +40 -23
- package/dist/roles.d.ts +560 -8
- package/dist/roles.js +25 -11
- package/dist/routes.d.ts +8 -0
- package/dist/routes.js +13 -0
- package/dist/saas.d.ts +164 -8
- package/dist/saas.js +14 -29
- package/dist/tags.d.ts +344 -8
- package/dist/tags.js +16 -8
- package/dist/transfer.d.ts +1361 -36
- package/dist/transfer.js +47 -49
- package/dist/trash.d.ts +299 -23
- package/dist/trash.js +27 -20
- package/dist/users.d.ts +1233 -59
- package/dist/users.js +48 -39
- package/dist/values.d.ts +150 -0
- package/dist/values.js +139 -0
- package/dist/views.d.ts +404 -13
- package/dist/views.js +18 -28
- package/dist/webhooks.d.ts +791 -29
- package/dist/webhooks.js +36 -21
- package/package.json +9 -2
- package/dist/db/src/schema/jobs.js +0 -44
package/dist/files.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import { FILE_STORAGES } from "./db/src/enums.js";
|
|
1
2
|
import { files } from "./db/src/schema/platform.js";
|
|
2
3
|
import "./db/src/schema/index.js";
|
|
4
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
3
5
|
import { Id, IdList, isoDate } from "./common.js";
|
|
4
|
-
import { ActorRef } from "./platform.js";
|
|
5
6
|
import { oc } from "@orpc/contract";
|
|
6
|
-
import { createSelectSchema } from "drizzle-zod";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
+
import { createSelectSchema } from "drizzle-zod";
|
|
8
9
|
// src/files.ts
|
|
9
10
|
const FileInfo = createSelectSchema(files, {
|
|
10
11
|
id: Id,
|
|
11
12
|
size: () => z.int(),
|
|
12
|
-
/** Files being deleted are never listed. */
|
|
13
|
-
status: z.enum(["pending", "ready"]),
|
|
14
13
|
createdAt: isoDate
|
|
15
14
|
}).pick({
|
|
16
15
|
id: true,
|
|
@@ -18,19 +17,21 @@ const FileInfo = createSelectSchema(files, {
|
|
|
18
17
|
contentType: true,
|
|
19
18
|
/** Bytes. */
|
|
20
19
|
size: true,
|
|
20
|
+
/** `pending` until `complete`; files being deleted are never returned. */
|
|
21
21
|
status: true,
|
|
22
22
|
/** `core` or the plugin that uploaded it. */
|
|
23
23
|
source: true,
|
|
24
|
+
/** Who uploaded it: a team member (`actorId` = user id), a plugin (its name) or `system`. */
|
|
25
|
+
actorType: true,
|
|
26
|
+
actorId: true,
|
|
24
27
|
createdAt: true
|
|
25
|
-
}).extend({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
url: z.string()
|
|
33
|
-
});
|
|
28
|
+
}).extend({
|
|
29
|
+
/**
|
|
30
|
+
* Stable address for signed-in members (`/core/v1/files/<id>/download`):
|
|
31
|
+
* it checks the session, then redirects to a short-lived storage link.
|
|
32
|
+
* Use it for `<img src>` and links. The query selects it with the row.
|
|
33
|
+
*/
|
|
34
|
+
url: z.string() });
|
|
34
35
|
/** Where and how to send the bytes: one HTTP request, then `complete`. */
|
|
35
36
|
const UploadTarget = z.object({
|
|
36
37
|
method: z.literal("PUT"),
|
|
@@ -48,11 +49,22 @@ const FileSettings = z.object({
|
|
|
48
49
|
/** The deployment's limit; `maxSizeMb` can't go above it. */
|
|
49
50
|
limitMb: z.int(),
|
|
50
51
|
/** Where files are stored. */
|
|
51
|
-
storage: z.enum(
|
|
52
|
+
storage: z.enum(FILE_STORAGES)
|
|
52
53
|
});
|
|
53
54
|
const AllowedType = z.string().trim().toLowerCase().max(100).regex(/^(\.[a-z0-9]{1,15}|[a-z0-9][a-z0-9.+-]*\/(\*|[a-z0-9][a-z0-9.+-]*))$/, ".ext, type/subtype or type/*");
|
|
55
|
+
const { FILE_TOO_LARGE, FILE_TYPE_NOT_ALLOWED, LIMIT_EXCEEDED, MASS_DELETE_STOPPED, UPLOAD_CHANGED, UPLOAD_INCOMPLETE } = ERRORS;
|
|
56
|
+
/** What these procedures answer with besides the common errors. */
|
|
57
|
+
const base = oc.errors({
|
|
58
|
+
...COMMON_ERRORS,
|
|
59
|
+
FILE_TOO_LARGE,
|
|
60
|
+
FILE_TYPE_NOT_ALLOWED,
|
|
61
|
+
LIMIT_EXCEEDED,
|
|
62
|
+
MASS_DELETE_STOPPED,
|
|
63
|
+
UPLOAD_CHANGED,
|
|
64
|
+
UPLOAD_INCOMPLETE
|
|
65
|
+
});
|
|
54
66
|
const filesContract = {
|
|
55
|
-
createUpload:
|
|
67
|
+
createUpload: base.route({
|
|
56
68
|
method: "POST",
|
|
57
69
|
path: "/files",
|
|
58
70
|
successStatus: 201,
|
|
@@ -66,32 +78,32 @@ const filesContract = {
|
|
|
66
78
|
file: FileInfo,
|
|
67
79
|
upload: UploadTarget
|
|
68
80
|
})),
|
|
69
|
-
complete:
|
|
81
|
+
complete: base.route({
|
|
70
82
|
method: "POST",
|
|
71
83
|
path: "/files/{id}/complete",
|
|
72
84
|
summary: "Finish an upload once the bytes are sent: core checks the stored object. 409 UPLOAD_INCOMPLETE if it is missing or the size differs"
|
|
73
85
|
}).input(z.object({ id: Id })).output(FileInfo),
|
|
74
|
-
get:
|
|
86
|
+
get: base.route({
|
|
75
87
|
method: "GET",
|
|
76
88
|
path: "/files/{id}",
|
|
77
89
|
summary: "A file, with a short-lived `downloadUrl`"
|
|
78
90
|
}).input(z.object({ id: Id })).output(FileInfo.extend({ downloadUrl: z.string().nullable() })),
|
|
79
|
-
list:
|
|
91
|
+
list: base.route({
|
|
80
92
|
method: "GET",
|
|
81
93
|
path: "/files",
|
|
82
94
|
summary: "Files by id (ready ones only), e.g. a record’s attachments"
|
|
83
|
-
}).input(z.object({ ids: IdList })).output(z.object({ data: z.array(FileInfo) })),
|
|
84
|
-
remove:
|
|
95
|
+
}).input(z.object({ ids: IdList })).output(z.object({ data: z.array(FileInfo).max(100) })),
|
|
96
|
+
remove: base.route({
|
|
85
97
|
method: "DELETE",
|
|
86
98
|
path: "/files/{id}",
|
|
87
99
|
summary: "Delete a file and its stored bytes (the uploader, or owners and admins)"
|
|
88
100
|
}).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
|
|
89
|
-
settings:
|
|
101
|
+
settings: base.route({
|
|
90
102
|
method: "GET",
|
|
91
103
|
path: "/settings/files",
|
|
92
104
|
summary: "What the organisation accepts as uploads"
|
|
93
105
|
}).output(FileSettings),
|
|
94
|
-
updateSettings:
|
|
106
|
+
updateSettings: base.route({
|
|
95
107
|
method: "PUT",
|
|
96
108
|
path: "/settings/files",
|
|
97
109
|
summary: "Change upload limits (owners and admins)"
|