@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.
Files changed (77) hide show
  1. package/dist/activities.d.ts +1387 -139
  2. package/dist/activities.js +90 -30
  3. package/dist/audit.d.ts +1081 -33
  4. package/dist/audit.js +28 -14
  5. package/dist/auth.d.ts +2834 -26
  6. package/dist/auth.js +47 -18
  7. package/dist/automationRuns.d.ts +7 -9
  8. package/dist/automationRuns.js +12 -13
  9. package/dist/automations.d.ts +2443 -61
  10. package/dist/automations.js +41 -21
  11. package/dist/client.d.ts +30704 -0
  12. package/dist/client.js +62 -0
  13. package/dist/common.d.ts +0 -13
  14. package/dist/common.js +1 -13
  15. package/dist/companies.d.ts +1120 -10
  16. package/dist/companies.js +27 -12
  17. package/dist/contract/routes.json.js +17 -1
  18. package/dist/customerAuth.d.ts +1456 -17
  19. package/dist/customerAuth.js +33 -16
  20. package/dist/customers.d.ts +1232 -11
  21. package/dist/customers.js +28 -13
  22. package/dist/{automationDefinition.d.ts → db/src/automationDefinition.d.ts} +2 -2
  23. package/dist/{automationDefinition.js → db/src/automationDefinition.js} +2 -2
  24. package/dist/db/src/enums.js +1 -3
  25. package/dist/db/src/schema/automations.d.ts +1 -0
  26. package/dist/db/src/schema/automations.js +3 -3
  27. package/dist/db/src/schema/index.d.ts +3 -0
  28. package/dist/db/src/schema/index.js +3 -2
  29. package/dist/db/src/schema/leads.js +2 -2
  30. package/dist/db/src/schema/notes.js +92 -0
  31. package/dist/db/src/schema/payments.js +2 -2
  32. package/dist/db/src/schema/platform.js +0 -5
  33. package/dist/db/src/schema/plugins.js +7 -2
  34. package/dist/db/src/schema/transfer.js +2 -2
  35. package/dist/errors.d.ts +516 -0
  36. package/dist/errors.js +218 -0
  37. package/dist/events.d.ts +570 -121
  38. package/dist/events.js +41 -24
  39. package/dist/fields.d.ts +1456 -16
  40. package/dist/fields.js +27 -19
  41. package/dist/files.d.ts +761 -62
  42. package/dist/files.js +32 -21
  43. package/dist/index.d.ts +25187 -618
  44. package/dist/index.js +8 -7
  45. package/dist/leads.d.ts +1105 -21
  46. package/dist/leads.js +31 -13
  47. package/dist/notifications.d.ts +689 -48
  48. package/dist/notifications.js +38 -18
  49. package/dist/organizations.d.ts +260 -2
  50. package/dist/organizations.js +21 -2
  51. package/dist/payments.d.ts +1766 -62
  52. package/dist/payments.js +48 -26
  53. package/dist/platform.d.ts +12 -21
  54. package/dist/platform.js +7 -17
  55. package/dist/plugins.d.ts +802 -71
  56. package/dist/plugins.js +48 -27
  57. package/dist/products.d.ts +1380 -17
  58. package/dist/products.js +32 -16
  59. package/dist/roles.d.ts +560 -5
  60. package/dist/roles.js +20 -6
  61. package/dist/saas.d.ts +164 -2
  62. package/dist/saas.js +9 -2
  63. package/dist/tags.d.ts +340 -4
  64. package/dist/tags.js +14 -6
  65. package/dist/transfer.d.ts +1299 -12
  66. package/dist/transfer.js +32 -13
  67. package/dist/trash.d.ts +278 -21
  68. package/dist/trash.js +23 -16
  69. package/dist/users.d.ts +1206 -18
  70. package/dist/users.js +35 -13
  71. package/dist/values.d.ts +0 -9
  72. package/dist/values.js +2 -7
  73. package/dist/views.d.ts +396 -5
  74. package/dist/views.js +10 -7
  75. package/dist/webhooks.d.ts +765 -9
  76. package/dist/webhooks.js +18 -10
  77. 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: oc.route({
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: oc.route({
251
+ list: base.route({
244
252
  method: "GET",
245
253
  path: "/webhooks"
246
254
  }).output(listOf(Webhook)),
247
- create: oc.route({
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: oc.route({
267
+ update: base.route({
260
268
  method: "PATCH",
261
269
  path: "/webhooks/{id}"
262
270
  }).input(WebhookFields.extend({ id: Id })).output(Webhook),
263
- remove: oc.route({
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: oc.route({
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: oc.route({
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: oc.route({
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: oc.route({
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.1",
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",