@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
@@ -1,13 +1,14 @@
1
1
  import { AUTOMATION_FIELD_TYPES, CONTENT_TYPES } from "./db/src/enums.js";
2
2
  import { automations } from "./db/src/schema/automations.js";
3
3
  import "./db/src/schema/index.js";
4
+ import { COMMON_ERRORS, ERRORS } from "./errors.js";
4
5
  import { AutomationStatus } from "./values.js";
5
- import { AutomationDefinition } from "./automationDefinition.js";
6
+ import { AutomationDefinition } from "./db/src/automationDefinition.js";
6
7
  import { ActionInfo, AutomationRun, RunStatus, RunStep } from "./automationRuns.js";
7
8
  import { CursorQuery, Id, cursorPageOf, isoDate, listOf } from "./common.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/automations.ts
12
13
  const Automation = createSelectSchema(automations, {
13
14
  id: Id,
@@ -60,8 +61,27 @@ const Fields = createUpdateSchema(automations, {
60
61
  * actions from core and plugins, delays and branches — for its customer or
61
62
  * company. Every run and step is logged.
62
63
  */
64
+ const { CROSS_SITE, INVALID_AUTOMATION, INVALID_FILE, INVALID_LEAD_STAGE, INVALID_RECIPIENT, INVALID_STEP_INPUT, INVALID_URL, LIMIT_EXCEEDED, NOT_ACTIVE, NOT_AUTHOR, NOT_FAILED, NOT_RUNNING, NO_MEMBERS, NO_SUBJECT } = ERRORS;
65
+ /** What these procedures answer with besides the common errors. */
66
+ const base = oc.errors({
67
+ ...COMMON_ERRORS,
68
+ CROSS_SITE,
69
+ INVALID_AUTOMATION,
70
+ INVALID_FILE,
71
+ INVALID_LEAD_STAGE,
72
+ INVALID_RECIPIENT,
73
+ INVALID_STEP_INPUT,
74
+ INVALID_URL,
75
+ LIMIT_EXCEEDED,
76
+ NOT_ACTIVE,
77
+ NOT_AUTHOR,
78
+ NOT_FAILED,
79
+ NOT_RUNNING,
80
+ NO_MEMBERS,
81
+ NO_SUBJECT
82
+ });
63
83
  const automationsContract = {
64
- catalog: oc.route({
84
+ catalog: base.route({
65
85
  method: "GET",
66
86
  path: "/automations/catalog",
67
87
  summary: "Triggers (event types) and actions: core's and installed plugins'"
@@ -76,15 +96,15 @@ const automationsContract = {
76
96
  })),
77
97
  actions: z.array(ActionInfo)
78
98
  })),
79
- list: oc.route({
99
+ list: base.route({
80
100
  method: "GET",
81
101
  path: "/automations"
82
102
  }).input(z.object({ status: AutomationStatus.optional() })).output(listOf(Automation)),
83
- get: oc.route({
103
+ get: base.route({
84
104
  method: "GET",
85
105
  path: "/automations/{id}"
86
106
  }).input(z.object({ id: Id })).output(Automation),
87
- create: oc.route({
107
+ create: base.route({
88
108
  method: "POST",
89
109
  path: "/automations",
90
110
  successStatus: 201
@@ -92,21 +112,21 @@ const automationsContract = {
92
112
  name: true,
93
113
  definition: true
94
114
  })).output(Automation),
95
- update: oc.route({
115
+ update: base.route({
96
116
  method: "PATCH",
97
117
  path: "/automations/{id}",
98
118
  summary: "Change an automation; an active one publishes a new version (runs in progress keep theirs)"
99
119
  }).input(Fields.extend({ id: Id })).output(Automation),
100
- activate: oc.route({
120
+ activate: base.route({
101
121
  method: "POST",
102
122
  path: "/automations/{id}/activate",
103
123
  summary: "Check and turn on (as the member, whose permissions its actions use)"
104
124
  }).input(z.object({ id: Id })).output(Automation),
105
- pause: oc.route({
125
+ pause: base.route({
106
126
  method: "POST",
107
127
  path: "/automations/{id}/pause"
108
128
  }).input(z.object({ id: Id })).output(Automation),
109
- start: oc.route({
129
+ start: base.route({
110
130
  method: "POST",
111
131
  path: "/automations/{id}/start",
112
132
  summary: "Run a manual (or any) automation now: on the given records, or on its audience"
@@ -119,7 +139,7 @@ const automationsContract = {
119
139
  /** The audience is larger than one page: the rest starts in the background. */
120
140
  continuing: z.boolean()
121
141
  })),
122
- test: oc.route({
142
+ test: base.route({
123
143
  method: "POST",
124
144
  path: "/automations/{id}/test",
125
145
  summary: "Dry run of the working copy: what each step would do for a record (nothing is changed)"
@@ -138,7 +158,7 @@ const automationsContract = {
138
158
  goalMetAtStart: z.boolean(),
139
159
  trace: z.array(DryRunStep)
140
160
  })),
141
- stats: oc.route({
161
+ stats: base.route({
142
162
  method: "GET",
143
163
  path: "/automations/{id}/stats",
144
164
  summary: "How runs went, overall and step by step (last 30 days)"
@@ -159,7 +179,7 @@ const automationsContract = {
159
179
  })),
160
180
  skippedByLimit: z.int()
161
181
  })),
162
- versions: oc.route({
182
+ versions: base.route({
163
183
  method: "GET",
164
184
  path: "/automations/{id}/versions",
165
185
  summary: "The 100 latest published versions, newest first"
@@ -169,7 +189,7 @@ const automationsContract = {
169
189
  createdAt: isoDate(),
170
190
  definition: AutomationDefinition
171
191
  })).max(100) })),
172
- restoreVersion: oc.route({
192
+ restoreVersion: base.route({
173
193
  method: "POST",
174
194
  path: "/automations/{id}/versions/{version}/restore",
175
195
  summary: "Make an older version the working copy (and publish it if the automation is on)"
@@ -177,7 +197,7 @@ const automationsContract = {
177
197
  id: Id,
178
198
  version: z.coerce.number().int().min(1)
179
199
  })).output(Automation),
180
- templates: oc.route({
200
+ templates: base.route({
181
201
  method: "GET",
182
202
  path: "/automations/templates",
183
203
  summary: "Ready-made automations to start from"
@@ -187,35 +207,35 @@ const automationsContract = {
187
207
  description: z.string(),
188
208
  definition: AutomationDefinition
189
209
  }))),
190
- fields: oc.route({
210
+ fields: base.route({
191
211
  method: "GET",
192
212
  path: "/automations/fields",
193
213
  summary: "Paths conditions and placeholders can use, with their types (custom fields included)"
194
214
  }).input(z.object({ subject: z.enum(CONTENT_TYPES).optional() })).output(listOf(AutomationFieldPath)),
195
- remove: oc.route({
215
+ remove: base.route({
196
216
  method: "DELETE",
197
217
  path: "/automations/{id}"
198
218
  }).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
199
- runs: oc.route({
219
+ runs: base.route({
200
220
  method: "GET",
201
221
  path: "/automations/{id}/runs"
202
222
  }).input(CursorQuery.extend({
203
223
  id: Id,
204
224
  status: RunStatus.optional()
205
225
  })).output(cursorPageOf(AutomationRun)),
206
- run: oc.route({
226
+ run: base.route({
207
227
  method: "GET",
208
228
  path: "/automations/runs/{runId}"
209
229
  }).input(z.object({ runId: Id })).output(z.object({
210
230
  run: AutomationRun,
211
231
  steps: z.array(RunStep)
212
232
  })),
213
- retryRun: oc.route({
233
+ retryRun: base.route({
214
234
  method: "POST",
215
235
  path: "/automations/runs/{runId}/retry",
216
236
  summary: "Continue a failed run from the step that failed"
217
237
  }).input(z.object({ runId: Id })).output(AutomationRun),
218
- cancelRun: oc.route({
238
+ cancelRun: base.route({
219
239
  method: "POST",
220
240
  path: "/automations/runs/{runId}/cancel",
221
241
  summary: "Stop a running or waiting run"