@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/companies.js CHANGED
@@ -2,12 +2,13 @@ import { CUSTOMER_STATES } from "./db/src/enums.js";
2
2
  import { customers } from "./db/src/schema/customers.js";
3
3
  import { companies } from "./db/src/schema/companies.js";
4
4
  import "./db/src/schema/index.js";
5
+ import { COMMON_ERRORS, ERRORS } from "./errors.js";
5
6
  import { CursorQuery, CustomFields, CustomFieldsPatch, DESCRIPTION_MAX, EmailAddress, Id, IdList, ImageAddress, PhoneNumber, cursorPageOf, isoDate } from "./common.js";
6
7
  import { ContactLink, ContactLinkInput } from "./customers.js";
7
8
  import { LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, lifecycleInput, lifecycleRow } from "./leads.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/companies.ts
12
13
  /** An organisation the organisation works with; shared by every plugin. */
13
14
  const Company = createSelectSchema(companies, {
@@ -100,8 +101,22 @@ const TagChange = z.object({
100
101
  add: z.array(Id).max(50).default([]),
101
102
  remove: z.array(Id).max(50).default([])
102
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
+ });
103
118
  const companiesContract = {
104
- list: oc.route({
119
+ list: base.route({
105
120
  method: "GET",
106
121
  path: "/companies",
107
122
  summary: "Companies of the organisation, newest first"
@@ -118,42 +133,42 @@ const companiesContract = {
118
133
  /** An advanced filter: JSON of a condition group (`RecordFilter`), as views save it. */
119
134
  filter: z.string().max(2e4).optional()
120
135
  })).output(cursorPageOf(Company)),
121
- get: oc.route({
136
+ get: base.route({
122
137
  method: "GET",
123
138
  path: "/companies/{id}",
124
139
  summary: "A company; ids merged into another company resolve to it"
125
140
  }).input(ID).output(Company),
126
- create: oc.route({
141
+ create: base.route({
127
142
  method: "POST",
128
143
  path: "/companies",
129
144
  successStatus: 201,
130
- summary: "Create a company. 409 COMPANY_EXISTS (data: { id }) when the name is taken"
145
+ summary: "Create a company. 409 TAKEN when the name is taken"
131
146
  }).input(CompanyFields.extend({ primaryName: z.string().trim().min(1).max(200) })).output(Company),
132
- update: oc.route({
147
+ update: base.route({
133
148
  method: "PATCH",
134
149
  path: "/companies/{id}"
135
150
  }).input(CompanyFields.extend({ id: Id }).refine(changes, "nothing to update")).output(Company),
136
- remove: oc.route({
151
+ remove: base.route({
137
152
  method: "POST",
138
153
  path: "/companies/remove",
139
154
  summary: "Delete companies (owners and admins)"
140
155
  }).input(Ids).output(z.object({ removed: z.int() })),
141
- merge: oc.route({
156
+ merge: base.route({
142
157
  method: "POST",
143
158
  path: "/companies/merge",
144
159
  summary: "Merge companies into `keepId` (owners and admins), as for customers"
145
160
  }).input(MergeInput).output(Company),
146
- tag: oc.route({
161
+ tag: base.route({
147
162
  method: "POST",
148
163
  path: "/companies/tag",
149
164
  summary: "Add and remove tags on many companies"
150
165
  }).input(TagChange).output(z.object({ updated: z.int() })),
151
- people: oc.route({
166
+ people: base.route({
152
167
  method: "GET",
153
168
  path: "/companies/{id}/people",
154
169
  summary: "The company's first 500 people: main contact first, then current, then former"
155
170
  }).input(ID).output(z.object({ data: z.array(PersonRef).max(500) })),
156
- linkPerson: oc.route({
171
+ linkPerson: base.route({
157
172
  method: "PUT",
158
173
  path: "/companies/{id}/people/{customerId}",
159
174
  summary: "Link a person (or change the link), as from the person"
@@ -161,7 +176,7 @@ const companiesContract = {
161
176
  id: Id,
162
177
  customerId: Id
163
178
  })).output(z.object({ ok: z.literal(true) })),
164
- unlinkPerson: oc.route({
179
+ unlinkPerson: base.route({
165
180
  method: "DELETE",
166
181
  path: "/companies/{id}/people/{customerId}"
167
182
  }).input(z.object({
@@ -33,7 +33,7 @@ var routes_default = {
33
33
  "path": "/activities/types"
34
34
  }
35
35
  } },
36
- "updateNote": { "~orpc": {
36
+ "editNote": { "~orpc": {
37
37
  "errorMap": {},
38
38
  "meta": {},
39
39
  "route": {
@@ -41,6 +41,22 @@ var routes_default = {
41
41
  "path": "/activities/notes/{id}"
42
42
  }
43
43
  } },
44
+ "pinNote": { "~orpc": {
45
+ "errorMap": {},
46
+ "meta": {},
47
+ "route": {
48
+ "method": "PUT",
49
+ "path": "/activities/notes/{id}/pinned"
50
+ }
51
+ } },
52
+ "noteVersions": { "~orpc": {
53
+ "errorMap": {},
54
+ "meta": {},
55
+ "route": {
56
+ "method": "GET",
57
+ "path": "/activities/notes/{id}/versions"
58
+ }
59
+ } },
44
60
  "removeNote": { "~orpc": {
45
61
  "errorMap": {},
46
62
  "meta": {},