@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/auth.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LANGUAGES } from "./db/src/enums.js";
|
|
2
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
2
3
|
import { isoDate } from "./common.js";
|
|
3
4
|
import { NewPassword } from "./values.js";
|
|
4
5
|
import { Organization, OrganizationRegion } from "./organizations.js";
|
|
@@ -12,13 +13,41 @@ const Session = z.object({
|
|
|
12
13
|
/** What the member may do (actions); owners have every one. */
|
|
13
14
|
permissions: z.array(z.string())
|
|
14
15
|
});
|
|
16
|
+
const { ALREADY_ENABLED, BEYOND_OWN_PERMISSIONS, BUILTIN_ROLE, CHALLENGE_EXPIRED, CROSS_SITE, FIXED_ROLE, INVALID_CREDENTIALS, INVALID_LINK, LIMIT_EXCEEDED, NOT_ENABLED, NOT_INVITED, NOT_SET_UP, ORGANIZATION_REQUIRED, OWNER_ONLY_PERMISSION, ROLE_IN_USE, ROLE_NOT_FOUND, SAME_PASSWORD, SETUP_DISABLED, SETUP_DONE, TOO_MANY_ATTEMPTS, UNKNOWN_PERMISSION, WRONG_CODE, WRONG_PASSWORD } = ERRORS;
|
|
17
|
+
/** What these procedures answer with besides the common errors. */
|
|
18
|
+
const base = oc.errors({
|
|
19
|
+
...COMMON_ERRORS,
|
|
20
|
+
ALREADY_ENABLED,
|
|
21
|
+
BEYOND_OWN_PERMISSIONS,
|
|
22
|
+
BUILTIN_ROLE,
|
|
23
|
+
CHALLENGE_EXPIRED,
|
|
24
|
+
CROSS_SITE,
|
|
25
|
+
FIXED_ROLE,
|
|
26
|
+
INVALID_CREDENTIALS,
|
|
27
|
+
INVALID_LINK,
|
|
28
|
+
LIMIT_EXCEEDED,
|
|
29
|
+
NOT_ENABLED,
|
|
30
|
+
NOT_INVITED,
|
|
31
|
+
NOT_SET_UP,
|
|
32
|
+
ORGANIZATION_REQUIRED,
|
|
33
|
+
OWNER_ONLY_PERMISSION,
|
|
34
|
+
ROLE_IN_USE,
|
|
35
|
+
ROLE_NOT_FOUND,
|
|
36
|
+
SAME_PASSWORD,
|
|
37
|
+
SETUP_DISABLED,
|
|
38
|
+
SETUP_DONE,
|
|
39
|
+
TOO_MANY_ATTEMPTS,
|
|
40
|
+
UNKNOWN_PERMISSION,
|
|
41
|
+
WRONG_CODE,
|
|
42
|
+
WRONG_PASSWORD
|
|
43
|
+
});
|
|
15
44
|
const authContract = {
|
|
16
|
-
setupStatus:
|
|
45
|
+
setupStatus: base.route({
|
|
17
46
|
method: "GET",
|
|
18
47
|
path: "/setup",
|
|
19
48
|
summary: "Whether this installation still needs its first organisation and owner"
|
|
20
49
|
}).output(z.object({ required: z.boolean() })),
|
|
21
|
-
setup:
|
|
50
|
+
setup: base.route({
|
|
22
51
|
method: "POST",
|
|
23
52
|
path: "/setup",
|
|
24
53
|
successStatus: 201,
|
|
@@ -32,7 +61,7 @@ const authContract = {
|
|
|
32
61
|
email: z.string().trim().check(z.email()).max(254),
|
|
33
62
|
password: NewPassword
|
|
34
63
|
})).output(Session),
|
|
35
|
-
signIn:
|
|
64
|
+
signIn: base.route({
|
|
36
65
|
method: "POST",
|
|
37
66
|
path: "/auth/sign-in",
|
|
38
67
|
summary: "Sign in with email and password; sets the session cookie"
|
|
@@ -45,7 +74,7 @@ const authContract = {
|
|
|
45
74
|
twoFactorRequired: z.literal(true),
|
|
46
75
|
challenge: z.string()
|
|
47
76
|
})])),
|
|
48
|
-
requestPasswordReset:
|
|
77
|
+
requestPasswordReset: base.route({
|
|
49
78
|
method: "POST",
|
|
50
79
|
path: "/auth/password-reset",
|
|
51
80
|
summary: "Email a password reset link. Always answers ok: it never tells whether an email has an account"
|
|
@@ -53,7 +82,7 @@ const authContract = {
|
|
|
53
82
|
email: z.string().trim().check(z.email()).max(254),
|
|
54
83
|
subdomain: z.string().trim().max(63).optional()
|
|
55
84
|
})).output(z.object({ ok: z.literal(true) })),
|
|
56
|
-
resetPassword:
|
|
85
|
+
resetPassword: base.route({
|
|
57
86
|
method: "POST",
|
|
58
87
|
path: "/auth/password-reset/confirm",
|
|
59
88
|
summary: "Set a new password with the emailed link's token; signs in"
|
|
@@ -61,7 +90,7 @@ const authContract = {
|
|
|
61
90
|
token: z.string().min(10).max(300),
|
|
62
91
|
password: NewPassword
|
|
63
92
|
})).output(Session),
|
|
64
|
-
invitation:
|
|
93
|
+
invitation: base.route({
|
|
65
94
|
method: "GET",
|
|
66
95
|
path: "/auth/invitation",
|
|
67
96
|
summary: "What an invitation link is for (organisation, email), to show before accepting"
|
|
@@ -70,7 +99,7 @@ const authContract = {
|
|
|
70
99
|
email: z.string(),
|
|
71
100
|
inviter: z.string().nullable()
|
|
72
101
|
})),
|
|
73
|
-
acceptInvitation:
|
|
102
|
+
acceptInvitation: base.route({
|
|
74
103
|
method: "POST",
|
|
75
104
|
path: "/auth/invitation/accept",
|
|
76
105
|
summary: "Accept an invitation: choose a password; signs in"
|
|
@@ -80,7 +109,7 @@ const authContract = {
|
|
|
80
109
|
firstName: z.string().trim().max(100).optional(),
|
|
81
110
|
lastName: z.string().trim().max(100).optional()
|
|
82
111
|
})).output(Session),
|
|
83
|
-
signInTwoFactor:
|
|
112
|
+
signInTwoFactor: base.route({
|
|
84
113
|
method: "POST",
|
|
85
114
|
path: "/auth/sign-in/2fa",
|
|
86
115
|
summary: "The sign-in's second step: an authenticator code, or a recovery code"
|
|
@@ -89,7 +118,7 @@ const authContract = {
|
|
|
89
118
|
code: z.string().trim().regex(/^\d{6}$/).optional(),
|
|
90
119
|
recoveryCode: z.string().trim().min(8).max(40).optional()
|
|
91
120
|
}).refine((value) => Boolean(value.code || value.recoveryCode), "a code or a recovery code")).output(Session),
|
|
92
|
-
twoFactorSetup:
|
|
121
|
+
twoFactorSetup: base.route({
|
|
93
122
|
method: "POST",
|
|
94
123
|
path: "/auth/2fa/setup",
|
|
95
124
|
summary: "Start turning on two-factor sign-in: a new secret for an authenticator app"
|
|
@@ -97,37 +126,37 @@ const authContract = {
|
|
|
97
126
|
secret: z.string(),
|
|
98
127
|
uri: z.string()
|
|
99
128
|
})),
|
|
100
|
-
twoFactorEnable:
|
|
129
|
+
twoFactorEnable: base.route({
|
|
101
130
|
method: "POST",
|
|
102
131
|
path: "/auth/2fa/enable",
|
|
103
132
|
summary: "Confirm with a code from the app; returns recovery codes (shown once)"
|
|
104
133
|
}).input(z.object({ code: z.string().trim().regex(/^\d{6}$/) })).output(z.object({ recoveryCodes: z.array(z.string()) })),
|
|
105
|
-
twoFactorDisable:
|
|
134
|
+
twoFactorDisable: base.route({
|
|
106
135
|
method: "POST",
|
|
107
136
|
path: "/auth/2fa/disable",
|
|
108
137
|
summary: "Turn two-factor sign-in off (needs the password)"
|
|
109
138
|
}).input(z.object({ password: z.string().min(1).max(200) })).output(z.object({ ok: z.literal(true) })),
|
|
110
|
-
twoFactorRecoveryCodes:
|
|
139
|
+
twoFactorRecoveryCodes: base.route({
|
|
111
140
|
method: "POST",
|
|
112
141
|
path: "/auth/2fa/recovery-codes",
|
|
113
142
|
summary: "New recovery codes (the old ones stop working; needs the password)"
|
|
114
143
|
}).input(z.object({ password: z.string().min(1).max(200) })).output(z.object({ recoveryCodes: z.array(z.string()) })),
|
|
115
|
-
signOutEverywhere:
|
|
144
|
+
signOutEverywhere: base.route({
|
|
116
145
|
method: "POST",
|
|
117
146
|
path: "/auth/sign-out-everywhere",
|
|
118
147
|
summary: "End every session of the signed-in member, on every device"
|
|
119
148
|
}).output(z.object({ ok: z.literal(true) })),
|
|
120
|
-
signOut:
|
|
149
|
+
signOut: base.route({
|
|
121
150
|
method: "POST",
|
|
122
151
|
path: "/auth/sign-out",
|
|
123
152
|
summary: "Sign out; clears the session cookie"
|
|
124
153
|
}).output(z.object({ ok: z.literal(true) })),
|
|
125
|
-
me:
|
|
154
|
+
me: base.route({
|
|
126
155
|
method: "GET",
|
|
127
156
|
path: "/auth/me",
|
|
128
157
|
summary: "The signed-in team member and their organisation"
|
|
129
158
|
}).output(Session),
|
|
130
|
-
onboarded:
|
|
159
|
+
onboarded: base.route({
|
|
131
160
|
method: "POST",
|
|
132
161
|
path: "/auth/onboarded",
|
|
133
162
|
summary: "The signed-in member finished the welcome steps (on every browser)"
|
|
@@ -137,7 +166,7 @@ const authContract = {
|
|
|
137
166
|
/** The language of the example data: the member's UI language. */
|
|
138
167
|
language: z.enum(LANGUAGES).optional()
|
|
139
168
|
}).optional()).output(Session),
|
|
140
|
-
changePassword:
|
|
169
|
+
changePassword: base.route({
|
|
141
170
|
method: "POST",
|
|
142
171
|
path: "/auth/password",
|
|
143
172
|
summary: "Change my own password. 400 WRONG_PASSWORD when the current one is wrong; SAME_PASSWORD when unchanged"
|
|
@@ -145,7 +174,7 @@ const authContract = {
|
|
|
145
174
|
currentPassword: z.string().min(1).max(200),
|
|
146
175
|
newPassword: NewPassword
|
|
147
176
|
})).output(z.object({ ok: z.literal(true) })),
|
|
148
|
-
signIns:
|
|
177
|
+
signIns: base.route({
|
|
149
178
|
method: "GET",
|
|
150
179
|
path: "/auth/sign-ins",
|
|
151
180
|
summary: "My 15 most recent sign-ins and failed attempts, newest first"
|
package/dist/automationRuns.d.ts
CHANGED
|
@@ -82,6 +82,11 @@ export declare const AutomationRun: z.ZodObject<{
|
|
|
82
82
|
version: z.ZodInt;
|
|
83
83
|
eventId: z.ZodString;
|
|
84
84
|
eventType: z.ZodString;
|
|
85
|
+
subjectType: z.ZodNullable<z.ZodEnum<{
|
|
86
|
+
company: "company";
|
|
87
|
+
customer: "customer";
|
|
88
|
+
}>>;
|
|
89
|
+
subjectId: z.ZodNullable<z.ZodString>;
|
|
85
90
|
status: z.ZodEnum<{
|
|
86
91
|
cancelled: "cancelled";
|
|
87
92
|
failed: "failed";
|
|
@@ -91,17 +96,10 @@ export declare const AutomationRun: z.ZodObject<{
|
|
|
91
96
|
}>;
|
|
92
97
|
error: z.ZodNullable<z.ZodString>;
|
|
93
98
|
waitingUntil: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
|
|
99
|
+
goalReachedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
|
|
94
100
|
startedAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
95
101
|
finishedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
|
|
96
|
-
|
|
97
|
-
type: z.ZodEnum<{
|
|
98
|
-
company: "company";
|
|
99
|
-
customer: "customer";
|
|
100
|
-
}>;
|
|
101
|
-
id: z.ZodString;
|
|
102
|
-
name: z.ZodNullable<z.ZodString>;
|
|
103
|
-
}, z.core.$strip>>;
|
|
104
|
-
goalReached: z.ZodBoolean;
|
|
102
|
+
subjectName: z.ZodNullable<z.ZodString>;
|
|
105
103
|
}, {
|
|
106
104
|
out: {};
|
|
107
105
|
in: {};
|
package/dist/automationRuns.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ACTION_FIELD_TYPES, AUTOMATION_SUBJECTS,
|
|
1
|
+
import { ACTION_FIELD_TYPES, AUTOMATION_SUBJECTS, RUN_STATUSES } from "./db/src/enums.js";
|
|
2
2
|
import { automationRunSteps, automationRuns } from "./db/src/schema/automations.js";
|
|
3
3
|
import "./db/src/schema/index.js";
|
|
4
4
|
import { Id, isoDate } from "./common.js";
|
|
5
|
-
import { createSelectSchema } from "drizzle-zod";
|
|
6
5
|
import { z } from "zod";
|
|
6
|
+
import { createSelectSchema } from "drizzle-zod";
|
|
7
7
|
// src/automationRuns.ts
|
|
8
8
|
/**
|
|
9
9
|
* One input of an action. Besides plain values: `custom_field` (one of the
|
|
@@ -41,28 +41,27 @@ const AutomationRun = createSelectSchema(automationRuns, {
|
|
|
41
41
|
version: int,
|
|
42
42
|
waitingUntil: isoDate,
|
|
43
43
|
startedAt: isoDate,
|
|
44
|
-
finishedAt: isoDate
|
|
44
|
+
finishedAt: isoDate,
|
|
45
|
+
goalReachedAt: isoDate
|
|
45
46
|
}).pick({
|
|
46
47
|
id: true,
|
|
47
48
|
automationId: true,
|
|
48
49
|
version: true,
|
|
49
50
|
eventId: true,
|
|
50
51
|
eventType: true,
|
|
52
|
+
/** The customer or company the run is about. */
|
|
53
|
+
subjectType: true,
|
|
54
|
+
subjectId: true,
|
|
51
55
|
status: true,
|
|
52
56
|
error: true,
|
|
53
57
|
waitingUntil: true,
|
|
54
58
|
startedAt: true,
|
|
55
|
-
finishedAt: true
|
|
56
|
-
}).extend({
|
|
57
|
-
subject: z.object({
|
|
58
|
-
type: z.enum(CONTENT_TYPES),
|
|
59
|
-
id: Id,
|
|
60
|
-
/** The customer's or company's name now; null once it is deleted. */
|
|
61
|
-
name: z.string().nullable()
|
|
62
|
-
}).nullable(),
|
|
59
|
+
finishedAt: true,
|
|
63
60
|
/** Left early because the automation's goal was met. */
|
|
64
|
-
|
|
65
|
-
})
|
|
61
|
+
goalReachedAt: true
|
|
62
|
+
}).extend({
|
|
63
|
+
/** The customer's or company's name now; null once it is deleted. */
|
|
64
|
+
subjectName: z.string().nullable() });
|
|
66
65
|
const RunStep = createSelectSchema(automationRunSteps, {
|
|
67
66
|
id: Id,
|
|
68
67
|
input: () => z.unknown(),
|