@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/companies.js
CHANGED
|
@@ -2,12 +2,13 @@ import { CUSTOMER_STATES } from "./db/src/enums.js";
|
|
|
2
2
|
import { customers } from "./db/src/schema/customers.js";
|
|
3
3
|
import { companies } from "./db/src/schema/companies.js";
|
|
4
4
|
import "./db/src/schema/index.js";
|
|
5
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
5
6
|
import { CursorQuery, CustomFields, CustomFieldsPatch, DESCRIPTION_MAX, EmailAddress, Id, IdList, ImageAddress, PhoneNumber, cursorPageOf, isoDate } from "./common.js";
|
|
6
7
|
import { ContactLink, ContactLinkInput } from "./customers.js";
|
|
7
8
|
import { LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, lifecycleInput, lifecycleRow } from "./leads.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/companies.ts
|
|
12
13
|
/** An organisation the organisation works with; shared by every plugin. */
|
|
13
14
|
const Company = createSelectSchema(companies, {
|
|
@@ -100,8 +101,22 @@ const TagChange = z.object({
|
|
|
100
101
|
add: z.array(Id).max(50).default([]),
|
|
101
102
|
remove: z.array(Id).max(50).default([])
|
|
102
103
|
});
|
|
104
|
+
const { INVALID_ACTOR, INVALID_FIELD, INVALID_FIELD_VALUE, INVALID_OWNER, INVALID_TAG, INVALID_TYPE, MASS_DELETE_STOPPED, NOT_A_LEAD, TAG_LIMIT } = ERRORS;
|
|
105
|
+
/** What these procedures answer with besides the common errors. */
|
|
106
|
+
const base = oc.errors({
|
|
107
|
+
...COMMON_ERRORS,
|
|
108
|
+
INVALID_ACTOR,
|
|
109
|
+
INVALID_FIELD,
|
|
110
|
+
INVALID_FIELD_VALUE,
|
|
111
|
+
INVALID_OWNER,
|
|
112
|
+
INVALID_TAG,
|
|
113
|
+
INVALID_TYPE,
|
|
114
|
+
MASS_DELETE_STOPPED,
|
|
115
|
+
NOT_A_LEAD,
|
|
116
|
+
TAG_LIMIT
|
|
117
|
+
});
|
|
103
118
|
const companiesContract = {
|
|
104
|
-
list:
|
|
119
|
+
list: base.route({
|
|
105
120
|
method: "GET",
|
|
106
121
|
path: "/companies",
|
|
107
122
|
summary: "Companies of the organisation, newest first"
|
|
@@ -118,42 +133,42 @@ const companiesContract = {
|
|
|
118
133
|
/** An advanced filter: JSON of a condition group (`RecordFilter`), as views save it. */
|
|
119
134
|
filter: z.string().max(2e4).optional()
|
|
120
135
|
})).output(cursorPageOf(Company)),
|
|
121
|
-
get:
|
|
136
|
+
get: base.route({
|
|
122
137
|
method: "GET",
|
|
123
138
|
path: "/companies/{id}",
|
|
124
139
|
summary: "A company; ids merged into another company resolve to it"
|
|
125
140
|
}).input(ID).output(Company),
|
|
126
|
-
create:
|
|
141
|
+
create: base.route({
|
|
127
142
|
method: "POST",
|
|
128
143
|
path: "/companies",
|
|
129
144
|
successStatus: 201,
|
|
130
|
-
summary: "Create a company. 409
|
|
145
|
+
summary: "Create a company. 409 TAKEN when the name is taken"
|
|
131
146
|
}).input(CompanyFields.extend({ primaryName: z.string().trim().min(1).max(200) })).output(Company),
|
|
132
|
-
update:
|
|
147
|
+
update: base.route({
|
|
133
148
|
method: "PATCH",
|
|
134
149
|
path: "/companies/{id}"
|
|
135
150
|
}).input(CompanyFields.extend({ id: Id }).refine(changes, "nothing to update")).output(Company),
|
|
136
|
-
remove:
|
|
151
|
+
remove: base.route({
|
|
137
152
|
method: "POST",
|
|
138
153
|
path: "/companies/remove",
|
|
139
154
|
summary: "Delete companies (owners and admins)"
|
|
140
155
|
}).input(Ids).output(z.object({ removed: z.int() })),
|
|
141
|
-
merge:
|
|
156
|
+
merge: base.route({
|
|
142
157
|
method: "POST",
|
|
143
158
|
path: "/companies/merge",
|
|
144
159
|
summary: "Merge companies into `keepId` (owners and admins), as for customers"
|
|
145
160
|
}).input(MergeInput).output(Company),
|
|
146
|
-
tag:
|
|
161
|
+
tag: base.route({
|
|
147
162
|
method: "POST",
|
|
148
163
|
path: "/companies/tag",
|
|
149
164
|
summary: "Add and remove tags on many companies"
|
|
150
165
|
}).input(TagChange).output(z.object({ updated: z.int() })),
|
|
151
|
-
people:
|
|
166
|
+
people: base.route({
|
|
152
167
|
method: "GET",
|
|
153
168
|
path: "/companies/{id}/people",
|
|
154
169
|
summary: "The company's first 500 people: main contact first, then current, then former"
|
|
155
170
|
}).input(ID).output(z.object({ data: z.array(PersonRef).max(500) })),
|
|
156
|
-
linkPerson:
|
|
171
|
+
linkPerson: base.route({
|
|
157
172
|
method: "PUT",
|
|
158
173
|
path: "/companies/{id}/people/{customerId}",
|
|
159
174
|
summary: "Link a person (or change the link), as from the person"
|
|
@@ -161,7 +176,7 @@ const companiesContract = {
|
|
|
161
176
|
id: Id,
|
|
162
177
|
customerId: Id
|
|
163
178
|
})).output(z.object({ ok: z.literal(true) })),
|
|
164
|
-
unlinkPerson:
|
|
179
|
+
unlinkPerson: base.route({
|
|
165
180
|
method: "DELETE",
|
|
166
181
|
path: "/companies/{id}/people/{customerId}"
|
|
167
182
|
}).input(z.object({
|
|
@@ -33,7 +33,7 @@ var routes_default = {
|
|
|
33
33
|
"path": "/activities/types"
|
|
34
34
|
}
|
|
35
35
|
} },
|
|
36
|
-
"
|
|
36
|
+
"editNote": { "~orpc": {
|
|
37
37
|
"errorMap": {},
|
|
38
38
|
"meta": {},
|
|
39
39
|
"route": {
|
|
@@ -41,6 +41,22 @@ var routes_default = {
|
|
|
41
41
|
"path": "/activities/notes/{id}"
|
|
42
42
|
}
|
|
43
43
|
} },
|
|
44
|
+
"pinNote": { "~orpc": {
|
|
45
|
+
"errorMap": {},
|
|
46
|
+
"meta": {},
|
|
47
|
+
"route": {
|
|
48
|
+
"method": "PUT",
|
|
49
|
+
"path": "/activities/notes/{id}/pinned"
|
|
50
|
+
}
|
|
51
|
+
} },
|
|
52
|
+
"noteVersions": { "~orpc": {
|
|
53
|
+
"errorMap": {},
|
|
54
|
+
"meta": {},
|
|
55
|
+
"route": {
|
|
56
|
+
"method": "GET",
|
|
57
|
+
"path": "/activities/notes/{id}/versions"
|
|
58
|
+
}
|
|
59
|
+
} },
|
|
44
60
|
"removeNote": { "~orpc": {
|
|
45
61
|
"errorMap": {},
|
|
46
62
|
"meta": {},
|