@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/webhooks.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CONTENT_TYPES, WEBHOOK_DELIVERY_STATUSES } from "./db/src/enums.js";
|
|
2
2
|
import { webhookDeliveries, webhooks } from "./db/src/schema/webhooks.js";
|
|
3
3
|
import "./db/src/schema/index.js";
|
|
4
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
4
5
|
import { CursorQuery, Id, cursorPageOf, 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/webhooks.ts
|
|
9
10
|
/**
|
|
10
11
|
* Events core publishes (plugins add theirs through their manifest). Webhooks
|
|
@@ -229,22 +230,29 @@ const WebhookFields = createUpdateSchema(webhooks, {
|
|
|
229
230
|
eventTypes: true,
|
|
230
231
|
status: true
|
|
231
232
|
});
|
|
233
|
+
const { INVALID_URL, LIMIT_EXCEEDED } = ERRORS;
|
|
234
|
+
/** What these procedures answer with besides the common errors. */
|
|
235
|
+
const base = oc.errors({
|
|
236
|
+
...COMMON_ERRORS,
|
|
237
|
+
INVALID_URL,
|
|
238
|
+
LIMIT_EXCEEDED
|
|
239
|
+
});
|
|
232
240
|
/**
|
|
233
241
|
* Webhooks: an organisation's endpoints get its events as signed POSTs
|
|
234
242
|
* (`Erxes-Signature: t=<unix>,v1=<hex HMAC-SHA256 of "<t>.<body>">`), retried
|
|
235
243
|
* with backoff for about a day; every attempt is in the delivery log.
|
|
236
244
|
*/
|
|
237
245
|
const webhooksContract = {
|
|
238
|
-
eventTypes:
|
|
246
|
+
eventTypes: base.route({
|
|
239
247
|
method: "GET",
|
|
240
248
|
path: "/events/types",
|
|
241
249
|
summary: "Event types to subscribe to or automate on: core's and installed plugins'"
|
|
242
250
|
}).output(listOf(EventTypeInfo)),
|
|
243
|
-
list:
|
|
251
|
+
list: base.route({
|
|
244
252
|
method: "GET",
|
|
245
253
|
path: "/webhooks"
|
|
246
254
|
}).output(listOf(Webhook)),
|
|
247
|
-
create:
|
|
255
|
+
create: base.route({
|
|
248
256
|
method: "POST",
|
|
249
257
|
path: "/webhooks",
|
|
250
258
|
successStatus: 201,
|
|
@@ -256,25 +264,25 @@ const webhooksContract = {
|
|
|
256
264
|
webhook: Webhook,
|
|
257
265
|
secret: z.string()
|
|
258
266
|
})),
|
|
259
|
-
update:
|
|
267
|
+
update: base.route({
|
|
260
268
|
method: "PATCH",
|
|
261
269
|
path: "/webhooks/{id}"
|
|
262
270
|
}).input(WebhookFields.extend({ id: Id })).output(Webhook),
|
|
263
|
-
remove:
|
|
271
|
+
remove: base.route({
|
|
264
272
|
method: "DELETE",
|
|
265
273
|
path: "/webhooks/{id}"
|
|
266
274
|
}).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
|
|
267
|
-
rotateSecret:
|
|
275
|
+
rotateSecret: base.route({
|
|
268
276
|
method: "POST",
|
|
269
277
|
path: "/webhooks/{id}/secret",
|
|
270
278
|
summary: "A new signing secret (returned once); the old one stops at once"
|
|
271
279
|
}).input(z.object({ id: Id })).output(z.object({ secret: z.string() })),
|
|
272
|
-
test:
|
|
280
|
+
test: base.route({
|
|
273
281
|
method: "POST",
|
|
274
282
|
path: "/webhooks/{id}/test",
|
|
275
283
|
summary: "Send a `core.webhook.test` event to the endpoint now"
|
|
276
284
|
}).input(z.object({ id: Id })).output(WebhookDelivery),
|
|
277
|
-
deliveries:
|
|
285
|
+
deliveries: base.route({
|
|
278
286
|
method: "GET",
|
|
279
287
|
path: "/webhooks/{id}/deliveries",
|
|
280
288
|
summary: "Recent deliveries, newest first"
|
|
@@ -282,7 +290,7 @@ const webhooksContract = {
|
|
|
282
290
|
id: Id,
|
|
283
291
|
status: z.enum(WEBHOOK_DELIVERY_STATUSES).optional()
|
|
284
292
|
})).output(cursorPageOf(WebhookDelivery)),
|
|
285
|
-
redeliver:
|
|
293
|
+
redeliver: base.route({
|
|
286
294
|
method: "POST",
|
|
287
295
|
path: "/webhooks/deliveries/{deliveryId}/redeliver",
|
|
288
296
|
summary: "Send a delivery again"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erxes/core-contract",
|
|
3
|
-
"version": "0.1.0-v2.
|
|
3
|
+
"version": "0.1.0-v2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "erxes core API contract (/core/v1) and event schemas, shared by core and plugins",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"./activities": "./dist/activities.js",
|
|
20
20
|
"./audit": "./dist/audit.js",
|
|
21
21
|
"./auth": "./dist/auth.js",
|
|
22
|
-
"./automationDefinition": "./dist/automationDefinition.js",
|
|
23
22
|
"./automationRuns": "./dist/automationRuns.js",
|
|
24
23
|
"./automations": "./dist/automations.js",
|
|
24
|
+
"./client": "./dist/client.js",
|
|
25
25
|
"./common": "./dist/common.js",
|
|
26
26
|
"./companies": "./dist/companies.js",
|
|
27
27
|
"./customerAuth": "./dist/customerAuth.js",
|
|
28
28
|
"./customers": "./dist/customers.js",
|
|
29
|
+
"./errors": "./dist/errors.js",
|
|
29
30
|
"./events": "./dist/events.js",
|
|
30
31
|
"./fields": "./dist/fields.js",
|
|
31
32
|
"./files": "./dist/files.js",
|
|
@@ -55,7 +56,10 @@
|
|
|
55
56
|
"tag": "v2-next"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
59
|
+
"@orpc/client": "1.16.2",
|
|
58
60
|
"@orpc/contract": "1.16.2",
|
|
61
|
+
"@orpc/openapi-client": "1.16.2",
|
|
62
|
+
"@orpc/tanstack-query": "1.16.2",
|
|
59
63
|
"country-to-currency": "^3.0.2",
|
|
60
64
|
"drizzle-orm": "0.45.4",
|
|
61
65
|
"drizzle-zod": "0.8.3",
|