@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/customerAuth.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { customers } from "./db/src/schema/customers.js";
|
|
2
2
|
import { customerLogins, customerSessions } from "./db/src/schema/customerAuth.js";
|
|
3
3
|
import "./db/src/schema/index.js";
|
|
4
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
4
5
|
import { EmailAddress, Id, ImageAddress, PhoneNumber, isoDate, listOf } from "./common.js";
|
|
5
6
|
import { PluginName } from "./plugins.js";
|
|
6
7
|
import { oc } from "@orpc/contract";
|
|
7
|
-
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
9
10
|
// src/customerAuth.ts
|
|
10
11
|
/** An email address or phone, with more fields. */
|
|
11
12
|
const addressWith = (fields) => z.discriminatedUnion("kind", [z.object({
|
|
@@ -91,8 +92,24 @@ const CustomerTokens = z.object({
|
|
|
91
92
|
* Customers sign in to a plugin's app with a one-time code (decision 42): the
|
|
92
93
|
* app's own form calls these. Public; browsers only from the app's origins.
|
|
93
94
|
*/
|
|
95
|
+
const { INVALID_CODE, INVALID_CREDENTIALS, INVALID_TOKEN, LAST_LOGIN, NOTHING_TO_RETRY, ORGANIZATION_REQUIRED, ORIGIN_NOT_ALLOWED, SUBJECT_REQUIRED, TOO_MANY_ATTEMPTS, TOO_MANY_CODES, UNKNOWN_APP } = ERRORS;
|
|
96
|
+
/** What these procedures answer with besides the common errors. */
|
|
97
|
+
const base = oc.errors({
|
|
98
|
+
...COMMON_ERRORS,
|
|
99
|
+
INVALID_CODE,
|
|
100
|
+
INVALID_CREDENTIALS,
|
|
101
|
+
INVALID_TOKEN,
|
|
102
|
+
LAST_LOGIN,
|
|
103
|
+
NOTHING_TO_RETRY,
|
|
104
|
+
ORGANIZATION_REQUIRED,
|
|
105
|
+
ORIGIN_NOT_ALLOWED,
|
|
106
|
+
SUBJECT_REQUIRED,
|
|
107
|
+
TOO_MANY_ATTEMPTS,
|
|
108
|
+
TOO_MANY_CODES,
|
|
109
|
+
UNKNOWN_APP
|
|
110
|
+
});
|
|
94
111
|
const customerAuthContract = {
|
|
95
|
-
sendCode:
|
|
112
|
+
sendCode: base.route({
|
|
96
113
|
method: "POST",
|
|
97
114
|
path: "/customer-auth/code",
|
|
98
115
|
successStatus: 202,
|
|
@@ -101,7 +118,7 @@ const customerAuthContract = {
|
|
|
101
118
|
clientId,
|
|
102
119
|
organization
|
|
103
120
|
})).output(CodeSent),
|
|
104
|
-
signIn:
|
|
121
|
+
signIn: base.route({
|
|
105
122
|
method: "POST",
|
|
106
123
|
path: "/customer-auth/sign-in",
|
|
107
124
|
summary: "Sign in (or up) with the code and get the app's tokens. 400 INVALID_CODE (wrong, used, expired or 5 tries), 400 UNKNOWN_APP, 403 ORIGIN_NOT_ALLOWED"
|
|
@@ -113,7 +130,7 @@ const customerAuthContract = {
|
|
|
113
130
|
customer: CustomerProfile,
|
|
114
131
|
created: z.boolean()
|
|
115
132
|
})),
|
|
116
|
-
refresh:
|
|
133
|
+
refresh: base.route({
|
|
117
134
|
method: "POST",
|
|
118
135
|
path: "/customer-auth/refresh",
|
|
119
136
|
summary: "New tokens for a refresh token; the old one stops working, and using it again ends the session. 401 INVALID_TOKEN, 403 ORIGIN_NOT_ALLOWED"
|
|
@@ -121,7 +138,7 @@ const customerAuthContract = {
|
|
|
121
138
|
clientId,
|
|
122
139
|
refreshToken: RefreshToken
|
|
123
140
|
})).output(CustomerTokens),
|
|
124
|
-
signOut:
|
|
141
|
+
signOut: base.route({
|
|
125
142
|
method: "POST",
|
|
126
143
|
path: "/customer-auth/sign-out",
|
|
127
144
|
summary: "End the refresh token's session; the answer is ok either way"
|
|
@@ -129,49 +146,49 @@ const customerAuthContract = {
|
|
|
129
146
|
};
|
|
130
147
|
/** The signed-in customer (`Authorization: Bearer` with a customer access token). */
|
|
131
148
|
const customerAccountContract = {
|
|
132
|
-
me:
|
|
149
|
+
me: base.route({
|
|
133
150
|
method: "GET",
|
|
134
151
|
path: "/customer/me",
|
|
135
152
|
summary: "The signed-in customer's profile"
|
|
136
153
|
}).output(CustomerProfile),
|
|
137
|
-
update:
|
|
154
|
+
update: base.route({
|
|
138
155
|
method: "PATCH",
|
|
139
156
|
path: "/customer/me",
|
|
140
157
|
summary: "Change name, picture or birth date"
|
|
141
158
|
}).input(CustomerProfileFields).output(CustomerProfile),
|
|
142
|
-
logins:
|
|
159
|
+
logins: base.route({
|
|
143
160
|
method: "GET",
|
|
144
161
|
path: "/customer/me/logins",
|
|
145
162
|
summary: "Addresses I sign in with"
|
|
146
163
|
}).output(listOf(CustomerLogin)),
|
|
147
|
-
addLogin:
|
|
164
|
+
addLogin: base.route({
|
|
148
165
|
method: "POST",
|
|
149
166
|
path: "/customer/me/logins",
|
|
150
167
|
successStatus: 202,
|
|
151
|
-
summary: "Send a code to a new address to sign in with. 409
|
|
168
|
+
summary: "Send a code to a new address to sign in with. 409 TAKEN when it is already a login, 429 TOO_MANY_CODES"
|
|
152
169
|
}).input(addressWith({})).output(CodeSent),
|
|
153
|
-
confirmLogin:
|
|
170
|
+
confirmLogin: base.route({
|
|
154
171
|
method: "POST",
|
|
155
172
|
path: "/customer/me/logins/confirm",
|
|
156
173
|
successStatus: 201,
|
|
157
|
-
summary: "Add the address with its code. 400 INVALID_CODE, 409
|
|
174
|
+
summary: "Add the address with its code. 400 INVALID_CODE, 409 TAKEN"
|
|
158
175
|
}).input(addressWith({ code: Code })).output(CustomerLogin),
|
|
159
|
-
removeLogin:
|
|
176
|
+
removeLogin: base.route({
|
|
160
177
|
method: "DELETE",
|
|
161
178
|
path: "/customer/me/logins/{id}",
|
|
162
179
|
summary: "Stop signing in with an address. 409 LAST_LOGIN"
|
|
163
180
|
}).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
|
|
164
|
-
sessions:
|
|
181
|
+
sessions: base.route({
|
|
165
182
|
method: "GET",
|
|
166
183
|
path: "/customer/me/sessions",
|
|
167
184
|
summary: "Where I am signed in"
|
|
168
185
|
}).output(listOf(CustomerSession)),
|
|
169
|
-
revokeSession:
|
|
186
|
+
revokeSession: base.route({
|
|
170
187
|
method: "DELETE",
|
|
171
188
|
path: "/customer/me/sessions/{id}",
|
|
172
189
|
summary: "Sign out one app"
|
|
173
190
|
}).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
|
|
174
|
-
signOutEverywhere:
|
|
191
|
+
signOutEverywhere: base.route({
|
|
175
192
|
method: "POST",
|
|
176
193
|
path: "/customer/me/sign-out-everywhere",
|
|
177
194
|
summary: "Sign out of every app (access tokens end within 15 minutes)"
|