@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/companies.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { CUSTOMER_STATES } from "./db/src/enums.js";
|
|
1
2
|
import { customers } from "./db/src/schema/customers.js";
|
|
2
3
|
import { companies } from "./db/src/schema/companies.js";
|
|
3
4
|
import "./db/src/schema/index.js";
|
|
4
|
-
import {
|
|
5
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
6
|
+
import { CursorQuery, CustomFields, CustomFieldsPatch, DESCRIPTION_MAX, EmailAddress, Id, IdList, ImageAddress, PhoneNumber, cursorPageOf, isoDate } from "./common.js";
|
|
5
7
|
import { ContactLink, ContactLinkInput } from "./customers.js";
|
|
6
8
|
import { LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, lifecycleInput, lifecycleRow } from "./leads.js";
|
|
7
9
|
import { oc } from "@orpc/contract";
|
|
8
|
-
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
9
10
|
import { z } from "zod";
|
|
11
|
+
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
10
12
|
// src/companies.ts
|
|
11
13
|
/** An organisation the organisation works with; shared by every plugin. */
|
|
12
14
|
const Company = createSelectSchema(companies, {
|
|
@@ -64,7 +66,7 @@ const CompanyFields = createUpdateSchema(companies, {
|
|
|
64
66
|
size: () => z.int().min(0).max(1e7),
|
|
65
67
|
businessType: (value) => value.trim().max(200),
|
|
66
68
|
code: (code) => code.trim().max(100),
|
|
67
|
-
description: (value) => value.trim().max(
|
|
69
|
+
description: (value) => value.trim().max(DESCRIPTION_MAX),
|
|
68
70
|
ownerId: () => Id,
|
|
69
71
|
...lifecycleInput
|
|
70
72
|
}).pick({
|
|
@@ -99,14 +101,28 @@ const TagChange = z.object({
|
|
|
99
101
|
add: z.array(Id).max(50).default([]),
|
|
100
102
|
remove: z.array(Id).max(50).default([])
|
|
101
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
|
+
});
|
|
102
118
|
const companiesContract = {
|
|
103
|
-
list:
|
|
119
|
+
list: base.route({
|
|
104
120
|
method: "GET",
|
|
105
121
|
path: "/companies",
|
|
106
122
|
summary: "Companies of the organisation, newest first"
|
|
107
123
|
}).input(CursorQuery.extend({
|
|
108
124
|
search: z.string().trim().max(100).optional(),
|
|
109
|
-
state: z.enum(
|
|
125
|
+
state: z.enum(CUSTOMER_STATES).optional(),
|
|
110
126
|
/** Leads in this stage. */
|
|
111
127
|
leadStageId: Id.optional(),
|
|
112
128
|
ownerId: Id.optional(),
|
|
@@ -117,42 +133,42 @@ const companiesContract = {
|
|
|
117
133
|
/** An advanced filter: JSON of a condition group (`RecordFilter`), as views save it. */
|
|
118
134
|
filter: z.string().max(2e4).optional()
|
|
119
135
|
})).output(cursorPageOf(Company)),
|
|
120
|
-
get:
|
|
136
|
+
get: base.route({
|
|
121
137
|
method: "GET",
|
|
122
138
|
path: "/companies/{id}",
|
|
123
139
|
summary: "A company; ids merged into another company resolve to it"
|
|
124
140
|
}).input(ID).output(Company),
|
|
125
|
-
create:
|
|
141
|
+
create: base.route({
|
|
126
142
|
method: "POST",
|
|
127
143
|
path: "/companies",
|
|
128
144
|
successStatus: 201,
|
|
129
|
-
summary: "Create a company. 409
|
|
145
|
+
summary: "Create a company. 409 TAKEN when the name is taken"
|
|
130
146
|
}).input(CompanyFields.extend({ primaryName: z.string().trim().min(1).max(200) })).output(Company),
|
|
131
|
-
update:
|
|
147
|
+
update: base.route({
|
|
132
148
|
method: "PATCH",
|
|
133
149
|
path: "/companies/{id}"
|
|
134
150
|
}).input(CompanyFields.extend({ id: Id }).refine(changes, "nothing to update")).output(Company),
|
|
135
|
-
remove:
|
|
151
|
+
remove: base.route({
|
|
136
152
|
method: "POST",
|
|
137
153
|
path: "/companies/remove",
|
|
138
154
|
summary: "Delete companies (owners and admins)"
|
|
139
155
|
}).input(Ids).output(z.object({ removed: z.int() })),
|
|
140
|
-
merge:
|
|
156
|
+
merge: base.route({
|
|
141
157
|
method: "POST",
|
|
142
158
|
path: "/companies/merge",
|
|
143
159
|
summary: "Merge companies into `keepId` (owners and admins), as for customers"
|
|
144
160
|
}).input(MergeInput).output(Company),
|
|
145
|
-
tag:
|
|
161
|
+
tag: base.route({
|
|
146
162
|
method: "POST",
|
|
147
163
|
path: "/companies/tag",
|
|
148
164
|
summary: "Add and remove tags on many companies"
|
|
149
165
|
}).input(TagChange).output(z.object({ updated: z.int() })),
|
|
150
|
-
people:
|
|
166
|
+
people: base.route({
|
|
151
167
|
method: "GET",
|
|
152
168
|
path: "/companies/{id}/people",
|
|
153
|
-
summary: "The company's people: main contact first, then current, then former"
|
|
154
|
-
}).input(ID).output(z.object({ data: z.array(PersonRef) })),
|
|
155
|
-
linkPerson:
|
|
169
|
+
summary: "The company's first 500 people: main contact first, then current, then former"
|
|
170
|
+
}).input(ID).output(z.object({ data: z.array(PersonRef).max(500) })),
|
|
171
|
+
linkPerson: base.route({
|
|
156
172
|
method: "PUT",
|
|
157
173
|
path: "/companies/{id}/people/{customerId}",
|
|
158
174
|
summary: "Link a person (or change the link), as from the person"
|
|
@@ -160,7 +176,7 @@ const companiesContract = {
|
|
|
160
176
|
id: Id,
|
|
161
177
|
customerId: Id
|
|
162
178
|
})).output(z.object({ ok: z.literal(true) })),
|
|
163
|
-
unlinkPerson:
|
|
179
|
+
unlinkPerson: base.route({
|
|
164
180
|
method: "DELETE",
|
|
165
181
|
path: "/companies/{id}/people/{customerId}"
|
|
166
182
|
}).input(z.object({
|