@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/fields.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { fieldGroups, fields } from "./db/src/schema/fields.js";
|
|
2
2
|
import "./db/src/schema/index.js";
|
|
3
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
3
4
|
import { OPTION_FIELD_TYPES } from "./values.js";
|
|
4
5
|
import { FieldContentType, Id, IdList, QueryBoolean, isoDate, listOf } from "./common.js";
|
|
5
6
|
import { oc } from "@orpc/contract";
|
|
6
|
-
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
+
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
8
9
|
// src/fields.ts
|
|
9
10
|
/** A custom field ("property") on customers or companies. */
|
|
10
11
|
const int = () => z.int();
|
|
@@ -109,8 +110,15 @@ const Orders = z.object({ orders: z.array(z.object({
|
|
|
109
110
|
const Ok = z.object({ ok: z.literal(true) });
|
|
110
111
|
const changes = (value) => Object.keys(value).some((key) => key !== "id");
|
|
111
112
|
const needsOptions = (value) => !value.type || !OPTION_FIELD_TYPES.includes(value.type) || (value.options?.length ?? 0) > 0;
|
|
113
|
+
const { FIELD_IN_USE, INVALID_FIELD_GROUP } = ERRORS;
|
|
114
|
+
/** What these procedures answer with besides the common errors. */
|
|
115
|
+
const base = oc.errors({
|
|
116
|
+
...COMMON_ERRORS,
|
|
117
|
+
FIELD_IN_USE,
|
|
118
|
+
INVALID_FIELD_GROUP
|
|
119
|
+
});
|
|
112
120
|
const fieldsContract = {
|
|
113
|
-
list:
|
|
121
|
+
list: base.route({
|
|
114
122
|
method: "GET",
|
|
115
123
|
path: "/fields",
|
|
116
124
|
summary: "Custom fields of a record type, in order. Archived ones (or those of an archived group) only with `archived=true`"
|
|
@@ -119,7 +127,7 @@ const fieldsContract = {
|
|
|
119
127
|
groupId: Id.optional(),
|
|
120
128
|
archived: QueryBoolean.optional()
|
|
121
129
|
})).output(listOf(Field)),
|
|
122
|
-
usage:
|
|
130
|
+
usage: base.route({
|
|
123
131
|
method: "GET",
|
|
124
132
|
path: "/fields/usage",
|
|
125
133
|
summary: "How many records hold values of the given fields (or of a group’s fields)"
|
|
@@ -127,11 +135,11 @@ const fieldsContract = {
|
|
|
127
135
|
ids: IdList.optional(),
|
|
128
136
|
groupId: Id.optional()
|
|
129
137
|
}).refine((value) => (value.ids?.length ?? 0) > 0 || !!value.groupId, "ids or groupId is required")).output(FieldUsage),
|
|
130
|
-
create:
|
|
138
|
+
create: base.route({
|
|
131
139
|
method: "POST",
|
|
132
140
|
path: "/fields",
|
|
133
141
|
successStatus: 201,
|
|
134
|
-
summary: "Add a custom field (owners and admins). 409
|
|
142
|
+
summary: "Add a custom field (owners and admins). 409 TAKEN for a taken label or code"
|
|
135
143
|
}).input(FieldFields.omit({ order: true }).required({
|
|
136
144
|
contentType: true,
|
|
137
145
|
label: true,
|
|
@@ -140,39 +148,39 @@ const fieldsContract = {
|
|
|
140
148
|
path: ["options"],
|
|
141
149
|
error: "select fields need options"
|
|
142
150
|
})).output(Field),
|
|
143
|
-
update:
|
|
151
|
+
update: base.route({
|
|
144
152
|
method: "PATCH",
|
|
145
153
|
path: "/fields/{id}",
|
|
146
154
|
summary: "Change a field. The type changes only within types sharing a stored value while records hold values (409 FIELD_IN_USE)"
|
|
147
155
|
}).input(FieldFields.omit({ contentType: true }).extend({ id: Id }).refine(changes, "nothing to update")).output(Field),
|
|
148
|
-
reorder:
|
|
156
|
+
reorder: base.route({
|
|
149
157
|
method: "POST",
|
|
150
158
|
path: "/fields/order",
|
|
151
159
|
summary: "Set the order of fields (owners and admins)"
|
|
152
160
|
}).input(Orders).output(Ok),
|
|
153
|
-
archive:
|
|
161
|
+
archive: base.route({
|
|
154
162
|
method: "POST",
|
|
155
163
|
path: "/fields/archive",
|
|
156
164
|
summary: "Archive fields: hidden everywhere, values kept (owners and admins)"
|
|
157
165
|
}).input(z.object({ ids: z.array(Id).min(1).max(100) })).output(Ok),
|
|
158
|
-
restore:
|
|
166
|
+
restore: base.route({
|
|
159
167
|
method: "POST",
|
|
160
168
|
path: "/fields/{id}/restore",
|
|
161
169
|
summary: "Restore an archived field (owners and admins)"
|
|
162
170
|
}).input(z.object({ id: Id })).output(Field),
|
|
163
|
-
removeUnused:
|
|
171
|
+
removeUnused: base.route({
|
|
164
172
|
method: "POST",
|
|
165
173
|
path: "/fields/remove",
|
|
166
174
|
summary: "Delete fields no record holds a value of (owners and admins). 409 FIELD_IN_USE otherwise"
|
|
167
175
|
}).input(z.object({ ids: z.array(Id).min(1).max(100) })).output(Ok),
|
|
168
|
-
remove:
|
|
176
|
+
remove: base.route({
|
|
169
177
|
method: "DELETE",
|
|
170
178
|
path: "/fields/{id}",
|
|
171
179
|
summary: "Delete a custom field and its values (owners and admins)"
|
|
172
180
|
}).input(z.object({ id: Id })).output(Ok)
|
|
173
181
|
};
|
|
174
182
|
const fieldGroupsContract = {
|
|
175
|
-
list:
|
|
183
|
+
list: base.route({
|
|
176
184
|
method: "GET",
|
|
177
185
|
path: "/field-groups",
|
|
178
186
|
summary: "Field groups of a record type, in order. Archived ones only with `archived=true`"
|
|
@@ -180,36 +188,36 @@ const fieldGroupsContract = {
|
|
|
180
188
|
contentType: FieldContentType,
|
|
181
189
|
archived: QueryBoolean.optional()
|
|
182
190
|
})).output(listOf(FieldGroup)),
|
|
183
|
-
create:
|
|
191
|
+
create: base.route({
|
|
184
192
|
method: "POST",
|
|
185
193
|
path: "/field-groups",
|
|
186
194
|
successStatus: 201,
|
|
187
|
-
summary: "Add a field group (owners and admins). The code defaults to the name; 409
|
|
195
|
+
summary: "Add a field group (owners and admins). The code defaults to the name; 409 TAKEN for a taken code"
|
|
188
196
|
}).input(GroupFields.omit({ order: true }).required({
|
|
189
197
|
contentType: true,
|
|
190
198
|
name: true
|
|
191
199
|
})).output(FieldGroup),
|
|
192
|
-
update:
|
|
200
|
+
update: base.route({
|
|
193
201
|
method: "PATCH",
|
|
194
202
|
path: "/field-groups/{id}",
|
|
195
203
|
summary: "Rename a field group (owners and admins)"
|
|
196
204
|
}).input(GroupFields.omit({ contentType: true }).extend({ id: Id }).refine(changes, "nothing to update")).output(FieldGroup),
|
|
197
|
-
reorder:
|
|
205
|
+
reorder: base.route({
|
|
198
206
|
method: "POST",
|
|
199
207
|
path: "/field-groups/order",
|
|
200
208
|
summary: "Set the order of field groups (owners and admins)"
|
|
201
209
|
}).input(Orders).output(Ok),
|
|
202
|
-
archive:
|
|
210
|
+
archive: base.route({
|
|
203
211
|
method: "POST",
|
|
204
212
|
path: "/field-groups/{id}/archive",
|
|
205
213
|
summary: "Archive a group: it and its fields are hidden, values kept (owners and admins)"
|
|
206
214
|
}).input(z.object({ id: Id })).output(FieldGroup),
|
|
207
|
-
restore:
|
|
215
|
+
restore: base.route({
|
|
208
216
|
method: "POST",
|
|
209
217
|
path: "/field-groups/{id}/restore",
|
|
210
218
|
summary: "Restore an archived group (owners and admins)"
|
|
211
219
|
}).input(z.object({ id: Id })).output(FieldGroup),
|
|
212
|
-
remove:
|
|
220
|
+
remove: base.route({
|
|
213
221
|
method: "DELETE",
|
|
214
222
|
path: "/field-groups/{id}",
|
|
215
223
|
summary: "Delete a group and its fields when no record holds their values (owners and admins). 409 FIELD_IN_USE otherwise"
|