@erxes/core-contract 0.1.0-v2.1 → 0.1.0-v2.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/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/automations.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AUTOMATION_FIELD_TYPES, CONTENT_TYPES } from "./db/src/enums.js";
|
|
2
2
|
import { automations } from "./db/src/schema/automations.js";
|
|
3
3
|
import "./db/src/schema/index.js";
|
|
4
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
4
5
|
import { AutomationStatus } from "./values.js";
|
|
5
|
-
import { AutomationDefinition } from "./automationDefinition.js";
|
|
6
|
+
import { AutomationDefinition } from "./db/src/automationDefinition.js";
|
|
6
7
|
import { ActionInfo, AutomationRun, RunStatus, RunStep } from "./automationRuns.js";
|
|
7
8
|
import { CursorQuery, Id, cursorPageOf, isoDate, listOf } from "./common.js";
|
|
8
9
|
import { oc } from "@orpc/contract";
|
|
9
|
-
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
10
10
|
import { z } from "zod";
|
|
11
|
+
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
11
12
|
// src/automations.ts
|
|
12
13
|
const Automation = createSelectSchema(automations, {
|
|
13
14
|
id: Id,
|
|
@@ -60,8 +61,27 @@ const Fields = createUpdateSchema(automations, {
|
|
|
60
61
|
* actions from core and plugins, delays and branches — for its customer or
|
|
61
62
|
* company. Every run and step is logged.
|
|
62
63
|
*/
|
|
64
|
+
const { CROSS_SITE, INVALID_AUTOMATION, INVALID_FILE, INVALID_LEAD_STAGE, INVALID_RECIPIENT, INVALID_STEP_INPUT, INVALID_URL, LIMIT_EXCEEDED, NOT_ACTIVE, NOT_AUTHOR, NOT_FAILED, NOT_RUNNING, NO_MEMBERS, NO_SUBJECT } = ERRORS;
|
|
65
|
+
/** What these procedures answer with besides the common errors. */
|
|
66
|
+
const base = oc.errors({
|
|
67
|
+
...COMMON_ERRORS,
|
|
68
|
+
CROSS_SITE,
|
|
69
|
+
INVALID_AUTOMATION,
|
|
70
|
+
INVALID_FILE,
|
|
71
|
+
INVALID_LEAD_STAGE,
|
|
72
|
+
INVALID_RECIPIENT,
|
|
73
|
+
INVALID_STEP_INPUT,
|
|
74
|
+
INVALID_URL,
|
|
75
|
+
LIMIT_EXCEEDED,
|
|
76
|
+
NOT_ACTIVE,
|
|
77
|
+
NOT_AUTHOR,
|
|
78
|
+
NOT_FAILED,
|
|
79
|
+
NOT_RUNNING,
|
|
80
|
+
NO_MEMBERS,
|
|
81
|
+
NO_SUBJECT
|
|
82
|
+
});
|
|
63
83
|
const automationsContract = {
|
|
64
|
-
catalog:
|
|
84
|
+
catalog: base.route({
|
|
65
85
|
method: "GET",
|
|
66
86
|
path: "/automations/catalog",
|
|
67
87
|
summary: "Triggers (event types) and actions: core's and installed plugins'"
|
|
@@ -76,15 +96,15 @@ const automationsContract = {
|
|
|
76
96
|
})),
|
|
77
97
|
actions: z.array(ActionInfo)
|
|
78
98
|
})),
|
|
79
|
-
list:
|
|
99
|
+
list: base.route({
|
|
80
100
|
method: "GET",
|
|
81
101
|
path: "/automations"
|
|
82
102
|
}).input(z.object({ status: AutomationStatus.optional() })).output(listOf(Automation)),
|
|
83
|
-
get:
|
|
103
|
+
get: base.route({
|
|
84
104
|
method: "GET",
|
|
85
105
|
path: "/automations/{id}"
|
|
86
106
|
}).input(z.object({ id: Id })).output(Automation),
|
|
87
|
-
create:
|
|
107
|
+
create: base.route({
|
|
88
108
|
method: "POST",
|
|
89
109
|
path: "/automations",
|
|
90
110
|
successStatus: 201
|
|
@@ -92,21 +112,21 @@ const automationsContract = {
|
|
|
92
112
|
name: true,
|
|
93
113
|
definition: true
|
|
94
114
|
})).output(Automation),
|
|
95
|
-
update:
|
|
115
|
+
update: base.route({
|
|
96
116
|
method: "PATCH",
|
|
97
117
|
path: "/automations/{id}",
|
|
98
118
|
summary: "Change an automation; an active one publishes a new version (runs in progress keep theirs)"
|
|
99
119
|
}).input(Fields.extend({ id: Id })).output(Automation),
|
|
100
|
-
activate:
|
|
120
|
+
activate: base.route({
|
|
101
121
|
method: "POST",
|
|
102
122
|
path: "/automations/{id}/activate",
|
|
103
123
|
summary: "Check and turn on (as the member, whose permissions its actions use)"
|
|
104
124
|
}).input(z.object({ id: Id })).output(Automation),
|
|
105
|
-
pause:
|
|
125
|
+
pause: base.route({
|
|
106
126
|
method: "POST",
|
|
107
127
|
path: "/automations/{id}/pause"
|
|
108
128
|
}).input(z.object({ id: Id })).output(Automation),
|
|
109
|
-
start:
|
|
129
|
+
start: base.route({
|
|
110
130
|
method: "POST",
|
|
111
131
|
path: "/automations/{id}/start",
|
|
112
132
|
summary: "Run a manual (or any) automation now: on the given records, or on its audience"
|
|
@@ -119,7 +139,7 @@ const automationsContract = {
|
|
|
119
139
|
/** The audience is larger than one page: the rest starts in the background. */
|
|
120
140
|
continuing: z.boolean()
|
|
121
141
|
})),
|
|
122
|
-
test:
|
|
142
|
+
test: base.route({
|
|
123
143
|
method: "POST",
|
|
124
144
|
path: "/automations/{id}/test",
|
|
125
145
|
summary: "Dry run of the working copy: what each step would do for a record (nothing is changed)"
|
|
@@ -138,7 +158,7 @@ const automationsContract = {
|
|
|
138
158
|
goalMetAtStart: z.boolean(),
|
|
139
159
|
trace: z.array(DryRunStep)
|
|
140
160
|
})),
|
|
141
|
-
stats:
|
|
161
|
+
stats: base.route({
|
|
142
162
|
method: "GET",
|
|
143
163
|
path: "/automations/{id}/stats",
|
|
144
164
|
summary: "How runs went, overall and step by step (last 30 days)"
|
|
@@ -159,7 +179,7 @@ const automationsContract = {
|
|
|
159
179
|
})),
|
|
160
180
|
skippedByLimit: z.int()
|
|
161
181
|
})),
|
|
162
|
-
versions:
|
|
182
|
+
versions: base.route({
|
|
163
183
|
method: "GET",
|
|
164
184
|
path: "/automations/{id}/versions",
|
|
165
185
|
summary: "The 100 latest published versions, newest first"
|
|
@@ -169,7 +189,7 @@ const automationsContract = {
|
|
|
169
189
|
createdAt: isoDate(),
|
|
170
190
|
definition: AutomationDefinition
|
|
171
191
|
})).max(100) })),
|
|
172
|
-
restoreVersion:
|
|
192
|
+
restoreVersion: base.route({
|
|
173
193
|
method: "POST",
|
|
174
194
|
path: "/automations/{id}/versions/{version}/restore",
|
|
175
195
|
summary: "Make an older version the working copy (and publish it if the automation is on)"
|
|
@@ -177,7 +197,7 @@ const automationsContract = {
|
|
|
177
197
|
id: Id,
|
|
178
198
|
version: z.coerce.number().int().min(1)
|
|
179
199
|
})).output(Automation),
|
|
180
|
-
templates:
|
|
200
|
+
templates: base.route({
|
|
181
201
|
method: "GET",
|
|
182
202
|
path: "/automations/templates",
|
|
183
203
|
summary: "Ready-made automations to start from"
|
|
@@ -187,35 +207,35 @@ const automationsContract = {
|
|
|
187
207
|
description: z.string(),
|
|
188
208
|
definition: AutomationDefinition
|
|
189
209
|
}))),
|
|
190
|
-
fields:
|
|
210
|
+
fields: base.route({
|
|
191
211
|
method: "GET",
|
|
192
212
|
path: "/automations/fields",
|
|
193
213
|
summary: "Paths conditions and placeholders can use, with their types (custom fields included)"
|
|
194
214
|
}).input(z.object({ subject: z.enum(CONTENT_TYPES).optional() })).output(listOf(AutomationFieldPath)),
|
|
195
|
-
remove:
|
|
215
|
+
remove: base.route({
|
|
196
216
|
method: "DELETE",
|
|
197
217
|
path: "/automations/{id}"
|
|
198
218
|
}).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
|
|
199
|
-
runs:
|
|
219
|
+
runs: base.route({
|
|
200
220
|
method: "GET",
|
|
201
221
|
path: "/automations/{id}/runs"
|
|
202
222
|
}).input(CursorQuery.extend({
|
|
203
223
|
id: Id,
|
|
204
224
|
status: RunStatus.optional()
|
|
205
225
|
})).output(cursorPageOf(AutomationRun)),
|
|
206
|
-
run:
|
|
226
|
+
run: base.route({
|
|
207
227
|
method: "GET",
|
|
208
228
|
path: "/automations/runs/{runId}"
|
|
209
229
|
}).input(z.object({ runId: Id })).output(z.object({
|
|
210
230
|
run: AutomationRun,
|
|
211
231
|
steps: z.array(RunStep)
|
|
212
232
|
})),
|
|
213
|
-
retryRun:
|
|
233
|
+
retryRun: base.route({
|
|
214
234
|
method: "POST",
|
|
215
235
|
path: "/automations/runs/{runId}/retry",
|
|
216
236
|
summary: "Continue a failed run from the step that failed"
|
|
217
237
|
}).input(z.object({ runId: Id })).output(AutomationRun),
|
|
218
|
-
cancelRun:
|
|
238
|
+
cancelRun: base.route({
|
|
219
239
|
method: "POST",
|
|
220
240
|
path: "/automations/runs/{runId}/cancel",
|
|
221
241
|
summary: "Stop a running or waiting run"
|