@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/files.js CHANGED
@@ -1,17 +1,15 @@
1
- import { FILE_STATUSES, FILE_STORAGES } from "./db/src/enums.js";
1
+ import { FILE_STORAGES } from "./db/src/enums.js";
2
2
  import { files } from "./db/src/schema/platform.js";
3
3
  import "./db/src/schema/index.js";
4
+ import { COMMON_ERRORS, ERRORS } from "./errors.js";
4
5
  import { Id, IdList, isoDate } from "./common.js";
5
- import { ActorRef } from "./platform.js";
6
6
  import { oc } from "@orpc/contract";
7
- import { createSelectSchema } from "drizzle-zod";
8
7
  import { z } from "zod";
8
+ import { createSelectSchema } from "drizzle-zod";
9
9
  // src/files.ts
10
10
  const FileInfo = createSelectSchema(files, {
11
11
  id: Id,
12
12
  size: () => z.int(),
13
- /** Files being deleted are never listed. */
14
- status: z.enum(FILE_STATUSES).exclude(["deleting"]),
15
13
  createdAt: isoDate
16
14
  }).pick({
17
15
  id: true,
@@ -19,19 +17,21 @@ const FileInfo = createSelectSchema(files, {
19
17
  contentType: true,
20
18
  /** Bytes. */
21
19
  size: true,
20
+ /** `pending` until `complete`; files being deleted are never returned. */
22
21
  status: true,
23
22
  /** `core` or the plugin that uploaded it. */
24
23
  source: true,
24
+ /** Who uploaded it: a team member (`actorId` = user id), a plugin (its name) or `system`. */
25
+ actorType: true,
26
+ actorId: true,
25
27
  createdAt: true
26
- }).extend({
27
- uploadedBy: ActorRef,
28
- /**
29
- * Stable address for signed-in members (`/core/v1/files/<id>/download`):
30
- * it checks the session, then redirects to a short-lived storage link.
31
- * Use it for `<img src>` and links.
32
- */
33
- url: z.string()
34
- });
28
+ }).extend({
29
+ /**
30
+ * Stable address for signed-in members (`/core/v1/files/<id>/download`):
31
+ * it checks the session, then redirects to a short-lived storage link.
32
+ * Use it for `<img src>` and links. The query selects it with the row.
33
+ */
34
+ url: z.string() });
35
35
  /** Where and how to send the bytes: one HTTP request, then `complete`. */
36
36
  const UploadTarget = z.object({
37
37
  method: z.literal("PUT"),
@@ -52,8 +52,19 @@ const FileSettings = z.object({
52
52
  storage: z.enum(FILE_STORAGES)
53
53
  });
54
54
  const AllowedType = z.string().trim().toLowerCase().max(100).regex(/^(\.[a-z0-9]{1,15}|[a-z0-9][a-z0-9.+-]*\/(\*|[a-z0-9][a-z0-9.+-]*))$/, ".ext, type/subtype or type/*");
55
+ const { FILE_TOO_LARGE, FILE_TYPE_NOT_ALLOWED, LIMIT_EXCEEDED, MASS_DELETE_STOPPED, UPLOAD_CHANGED, UPLOAD_INCOMPLETE } = ERRORS;
56
+ /** What these procedures answer with besides the common errors. */
57
+ const base = oc.errors({
58
+ ...COMMON_ERRORS,
59
+ FILE_TOO_LARGE,
60
+ FILE_TYPE_NOT_ALLOWED,
61
+ LIMIT_EXCEEDED,
62
+ MASS_DELETE_STOPPED,
63
+ UPLOAD_CHANGED,
64
+ UPLOAD_INCOMPLETE
65
+ });
55
66
  const filesContract = {
56
- createUpload: oc.route({
67
+ createUpload: base.route({
57
68
  method: "POST",
58
69
  path: "/files",
59
70
  successStatus: 201,
@@ -67,32 +78,32 @@ const filesContract = {
67
78
  file: FileInfo,
68
79
  upload: UploadTarget
69
80
  })),
70
- complete: oc.route({
81
+ complete: base.route({
71
82
  method: "POST",
72
83
  path: "/files/{id}/complete",
73
84
  summary: "Finish an upload once the bytes are sent: core checks the stored object. 409 UPLOAD_INCOMPLETE if it is missing or the size differs"
74
85
  }).input(z.object({ id: Id })).output(FileInfo),
75
- get: oc.route({
86
+ get: base.route({
76
87
  method: "GET",
77
88
  path: "/files/{id}",
78
89
  summary: "A file, with a short-lived `downloadUrl`"
79
90
  }).input(z.object({ id: Id })).output(FileInfo.extend({ downloadUrl: z.string().nullable() })),
80
- list: oc.route({
91
+ list: base.route({
81
92
  method: "GET",
82
93
  path: "/files",
83
94
  summary: "Files by id (ready ones only), e.g. a record’s attachments"
84
95
  }).input(z.object({ ids: IdList })).output(z.object({ data: z.array(FileInfo).max(100) })),
85
- remove: oc.route({
96
+ remove: base.route({
86
97
  method: "DELETE",
87
98
  path: "/files/{id}",
88
99
  summary: "Delete a file and its stored bytes (the uploader, or owners and admins)"
89
100
  }).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
90
- settings: oc.route({
101
+ settings: base.route({
91
102
  method: "GET",
92
103
  path: "/settings/files",
93
104
  summary: "What the organisation accepts as uploads"
94
105
  }).output(FileSettings),
95
- updateSettings: oc.route({
106
+ updateSettings: base.route({
96
107
  method: "PUT",
97
108
  path: "/settings/files",
98
109
  summary: "Change upload limits (owners and admins)"