@erxes/core-contract 0.1.0-v2.0 → 0.1.0-v2.1

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 (94) hide show
  1. package/dist/activities.d.ts +21 -14
  2. package/dist/activities.js +6 -10
  3. package/dist/audit.d.ts +13 -17
  4. package/dist/audit.js +9 -9
  5. package/dist/auth.d.ts +33 -35
  6. package/dist/auth.js +8 -7
  7. package/dist/automationDefinition.d.ts +4 -3
  8. package/dist/automationDefinition.js +9 -31
  9. package/dist/automationRuns.d.ts +6 -5
  10. package/dist/automationRuns.js +8 -22
  11. package/dist/automations.d.ts +35 -36
  12. package/dist/automations.js +15 -23
  13. package/dist/common.d.ts +29 -4
  14. package/dist/common.js +30 -10
  15. package/dist/companies.d.ts +34 -34
  16. package/dist/companies.js +6 -5
  17. package/dist/contract/routes.json.js +1794 -0
  18. package/dist/customerAuth.d.ts +222 -0
  19. package/dist/customerAuth.js +180 -0
  20. package/dist/customers.d.ts +51 -54
  21. package/dist/customers.js +7 -12
  22. package/dist/db/src/enums.d.ts +8 -0
  23. package/dist/db/src/enums.js +336 -0
  24. package/dist/db/src/schema/auditStreams.js +6 -14
  25. package/dist/db/src/schema/authTokens.js +4 -6
  26. package/dist/db/src/schema/automations.js +12 -28
  27. package/dist/db/src/schema/common.d.ts +2 -6
  28. package/dist/db/src/schema/common.js +1 -24
  29. package/dist/db/src/schema/companies.js +6 -5
  30. package/dist/db/src/schema/customerAuth.js +101 -0
  31. package/dist/db/src/schema/customers.js +6 -6
  32. package/dist/db/src/schema/events.js +12 -60
  33. package/dist/db/src/schema/fieldValues.js +2 -2
  34. package/dist/db/src/schema/fields.js +10 -28
  35. package/dist/db/src/schema/index.js +21 -20
  36. package/dist/db/src/schema/leadStages.js +5 -10
  37. package/dist/db/src/schema/leads.js +5 -10
  38. package/dist/db/src/schema/oauth.js +3 -3
  39. package/dist/db/src/schema/payments.js +12 -22
  40. package/dist/db/src/schema/platform.js +11 -26
  41. package/dist/db/src/schema/plugins.js +4 -4
  42. package/dist/db/src/schema/products.js +7 -8
  43. package/dist/db/src/schema/rateLimits.js +7 -0
  44. package/dist/db/src/schema/saas.js +3 -9
  45. package/dist/db/src/schema/tags.js +6 -5
  46. package/dist/db/src/schema/transfer.js +12 -32
  47. package/dist/db/src/schema/trash.js +6 -7
  48. package/dist/db/src/schema/users.js +6 -10
  49. package/dist/db/src/schema/views.js +5 -13
  50. package/dist/db/src/schema/webhooks.js +7 -14
  51. package/dist/db/src/table.js +16 -2
  52. package/dist/events.d.ts +19 -23
  53. package/dist/events.js +16 -18
  54. package/dist/fields.d.ts +22 -50
  55. package/dist/fields.js +6 -28
  56. package/dist/files.d.ts +10 -5
  57. package/dist/files.js +4 -3
  58. package/dist/index.d.ts +557 -321
  59. package/dist/index.js +17 -16
  60. package/dist/leads.d.ts +5 -3
  61. package/dist/leads.js +8 -7
  62. package/dist/notifications.d.ts +4 -48
  63. package/dist/notifications.js +7 -73
  64. package/dist/organizations.d.ts +3 -3
  65. package/dist/payments.d.ts +28 -58
  66. package/dist/payments.js +10 -34
  67. package/dist/platform.d.ts +1 -0
  68. package/dist/platform.js +2 -5
  69. package/dist/plugins.d.ts +10 -4
  70. package/dist/plugins.js +19 -9
  71. package/dist/products.d.ts +31 -36
  72. package/dist/products.js +8 -7
  73. package/dist/roles.d.ts +0 -3
  74. package/dist/roles.js +5 -5
  75. package/dist/routes.d.ts +8 -0
  76. package/dist/routes.js +13 -0
  77. package/dist/saas.d.ts +0 -6
  78. package/dist/saas.js +5 -27
  79. package/dist/tags.d.ts +4 -4
  80. package/dist/tags.js +3 -3
  81. package/dist/transfer.d.ts +62 -24
  82. package/dist/transfer.js +15 -36
  83. package/dist/trash.d.ts +23 -4
  84. package/dist/trash.js +5 -5
  85. package/dist/users.d.ts +27 -41
  86. package/dist/users.js +13 -26
  87. package/dist/values.d.ts +159 -0
  88. package/dist/values.js +144 -0
  89. package/dist/views.d.ts +8 -8
  90. package/dist/views.js +8 -21
  91. package/dist/webhooks.d.ts +26 -20
  92. package/dist/webhooks.js +18 -11
  93. package/package.json +4 -1
  94. package/dist/db/src/schema/jobs.js +0 -44
package/dist/events.d.ts CHANGED
@@ -53,8 +53,8 @@ export declare const CoreEvent: z.ZodObject<{
53
53
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
54
54
  summary: z.ZodNullable<z.ZodString>;
55
55
  link: z.ZodNullable<z.ZodString>;
56
- occurredAt: z.ZodISODateTime;
57
- createdAt: z.ZodISODateTime;
56
+ occurredAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
57
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
58
58
  subject: z.ZodNullable<z.ZodObject<{
59
59
  type: z.ZodEnum<{
60
60
  company: "company";
@@ -68,6 +68,7 @@ export declare const CoreEvent: z.ZodObject<{
68
68
  }, z.core.$strip>>;
69
69
  actor: z.ZodObject<{
70
70
  type: z.ZodEnum<{
71
+ customer: "customer";
71
72
  plugin: "plugin";
72
73
  system: "system";
73
74
  user: "user";
@@ -85,7 +86,7 @@ export declare const EventFailureStatus: z.ZodEnum<{
85
86
  dead: "dead";
86
87
  retrying: "retrying";
87
88
  }>;
88
- /** An event a consumer (timeline, notifications, …) could not handle. */
89
+ /** An event a consumer (timeline, notifications, …) could not handle: its job in the consumer's queue. */
89
90
  export declare const EventFailure: z.ZodObject<{
90
91
  consumer: z.ZodString;
91
92
  status: z.ZodEnum<{
@@ -94,9 +95,8 @@ export declare const EventFailure: z.ZodObject<{
94
95
  }>;
95
96
  attempts: z.ZodInt;
96
97
  lastError: z.ZodString;
97
- nextAttemptAt: z.ZodNullable<z.ZodISODateTime>;
98
- firstFailedAt: z.ZodISODateTime;
99
- updatedAt: z.ZodISODateTime;
98
+ failedAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
99
+ nextAttemptAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
100
100
  event: z.ZodObject<{
101
101
  id: z.ZodString;
102
102
  source: z.ZodString;
@@ -105,8 +105,8 @@ export declare const EventFailure: z.ZodObject<{
105
105
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
106
106
  summary: z.ZodNullable<z.ZodString>;
107
107
  link: z.ZodNullable<z.ZodString>;
108
- occurredAt: z.ZodISODateTime;
109
- createdAt: z.ZodISODateTime;
108
+ occurredAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
109
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
110
110
  subject: z.ZodNullable<z.ZodObject<{
111
111
  type: z.ZodEnum<{
112
112
  company: "company";
@@ -120,6 +120,7 @@ export declare const EventFailure: z.ZodObject<{
120
120
  }, z.core.$strip>>;
121
121
  actor: z.ZodObject<{
122
122
  type: z.ZodEnum<{
123
+ customer: "customer";
123
124
  plugin: "plugin";
124
125
  system: "system";
125
126
  user: "user";
@@ -132,10 +133,7 @@ export declare const EventFailure: z.ZodObject<{
132
133
  out: {};
133
134
  in: {};
134
135
  }>;
135
- }, {
136
- out: {};
137
- in: {};
138
- }>;
136
+ }, z.core.$strip>;
139
137
  export type EventFailure = z.infer<typeof EventFailure>;
140
138
  /**
141
139
  * The event stream (transactional outbox). Plugins on core's database publish
@@ -210,8 +208,8 @@ export declare const eventsContract: {
210
208
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
211
209
  summary: z.ZodNullable<z.ZodString>;
212
210
  link: z.ZodNullable<z.ZodString>;
213
- occurredAt: z.ZodISODateTime;
214
- createdAt: z.ZodISODateTime;
211
+ occurredAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
212
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
215
213
  subject: z.ZodNullable<z.ZodObject<{
216
214
  type: z.ZodEnum<{
217
215
  company: "company";
@@ -225,6 +223,7 @@ export declare const eventsContract: {
225
223
  }, z.core.$strip>>;
226
224
  actor: z.ZodObject<{
227
225
  type: z.ZodEnum<{
226
+ customer: "customer";
228
227
  plugin: "plugin";
229
228
  system: "system";
230
229
  user: "user";
@@ -260,9 +259,8 @@ export declare const eventsContract: {
260
259
  }>;
261
260
  attempts: z.ZodInt;
262
261
  lastError: z.ZodString;
263
- nextAttemptAt: z.ZodNullable<z.ZodISODateTime>;
264
- firstFailedAt: z.ZodISODateTime;
265
- updatedAt: z.ZodISODateTime;
262
+ failedAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
263
+ nextAttemptAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
266
264
  event: z.ZodObject<{
267
265
  id: z.ZodString;
268
266
  source: z.ZodString;
@@ -271,8 +269,8 @@ export declare const eventsContract: {
271
269
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
272
270
  summary: z.ZodNullable<z.ZodString>;
273
271
  link: z.ZodNullable<z.ZodString>;
274
- occurredAt: z.ZodISODateTime;
275
- createdAt: z.ZodISODateTime;
272
+ occurredAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
273
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
276
274
  subject: z.ZodNullable<z.ZodObject<{
277
275
  type: z.ZodEnum<{
278
276
  company: "company";
@@ -286,6 +284,7 @@ export declare const eventsContract: {
286
284
  }, z.core.$strip>>;
287
285
  actor: z.ZodObject<{
288
286
  type: z.ZodEnum<{
287
+ customer: "customer";
289
288
  plugin: "plugin";
290
289
  system: "system";
291
290
  user: "user";
@@ -298,10 +297,7 @@ export declare const eventsContract: {
298
297
  out: {};
299
298
  in: {};
300
299
  }>;
301
- }, {
302
- out: {};
303
- in: {};
304
- }>>;
300
+ }, z.core.$strip>>;
305
301
  counts: z.ZodObject<{
306
302
  retrying: z.ZodInt;
307
303
  dead: z.ZodInt;
package/dist/events.js CHANGED
@@ -1,4 +1,5 @@
1
- import { EVENT_FAILURE_STATUSES, eventFailures, events } from "./db/src/schema/events.js";
1
+ import { EVENT_FAILURE_STATUSES, NOTIFICATION_PRIORITIES } from "./db/src/enums.js";
2
+ import { events } from "./db/src/schema/events.js";
2
3
  import "./db/src/schema/index.js";
3
4
  import { CursorQuery, Id, cursorPageOf, isoDate } from "./common.js";
4
5
  import { ActivityTarget } from "./activities.js";
@@ -13,7 +14,7 @@ const EventNotify = z.object({
13
14
  title: z.string().trim().min(1).max(200),
14
15
  body: z.string().trim().max(2e3).optional(),
15
16
  link: AppLink.optional(),
16
- priority: z.enum(["normal", "high"]).optional()
17
+ priority: z.enum(NOTIFICATION_PRIORITIES).optional()
17
18
  });
18
19
  const EventInput = createUpdateSchema(events, {
19
20
  type: () => EventType,
@@ -69,21 +70,18 @@ const CoreEvent = createSelectSchema(events, {
69
70
  actor: ActorRef
70
71
  });
71
72
  const EventFailureStatus = z.enum(EVENT_FAILURE_STATUSES);
72
- /** An event a consumer (timeline, notifications, …) could not handle. */
73
- const EventFailure = createSelectSchema(eventFailures, {
74
- attempts: () => z.int(),
75
- nextAttemptAt: isoDate,
76
- firstFailedAt: isoDate,
77
- updatedAt: isoDate
78
- }).pick({
79
- consumer: true,
80
- status: true,
81
- attempts: true,
82
- lastError: true,
83
- nextAttemptAt: true,
84
- firstFailedAt: true,
85
- updatedAt: true
86
- }).extend({ event: CoreEvent });
73
+ /** An event a consumer (timeline, notifications, …) could not handle: its job in the consumer's queue. */
74
+ const EventFailure = z.object({
75
+ consumer: z.string(),
76
+ status: EventFailureStatus,
77
+ attempts: z.int(),
78
+ lastError: z.string(),
79
+ /** When the last attempt failed. */
80
+ failedAt: isoDate(),
81
+ /** When it is tried again; null once dead. */
82
+ nextAttemptAt: isoDate().nullable(),
83
+ event: CoreEvent
84
+ });
87
85
  const FailureRef = z.object({
88
86
  consumer: z.string().trim().min(1).max(100),
89
87
  eventId: Id
@@ -120,7 +118,7 @@ const eventsContract = {
120
118
  path: "/events/failures",
121
119
  summary: "Events that could not be handled: retrying with backoff, or dead after the last attempt (owners and admins)"
122
120
  }).input(z.object({ status: EventFailureStatus.optional() })).output(z.object({
123
- data: z.array(EventFailure),
121
+ data: z.array(EventFailure).max(200),
124
122
  counts: z.object({
125
123
  retrying: z.int(),
126
124
  dead: z.int()
package/dist/fields.d.ts CHANGED
@@ -1,32 +1,4 @@
1
1
  import { z } from "zod";
2
- export declare const FieldType: z.ZodEnum<{
3
- boolean: "boolean";
4
- check: "check";
5
- date: "date";
6
- list: "list";
7
- multiselect: "multiselect";
8
- number: "number";
9
- phone: "phone";
10
- radio: "radio";
11
- select: "select";
12
- text: "text";
13
- textarea: "textarea";
14
- }>;
15
- export type FieldType = z.infer<typeof FieldType>;
16
- /** Field types whose values are chosen from `options`. */
17
- export declare const OPTION_FIELD_TYPES: readonly FieldType[];
18
- /**
19
- * Types sharing a stored value: a field holding values may only change within
20
- * its family; an unused field may become any type.
21
- */
22
- export declare const FIELD_TYPE_FAMILIES: readonly (readonly FieldType[])[];
23
- /** Format a text field's values must have. */
24
- export declare const FieldValidation: z.ZodEnum<{
25
- date: "date";
26
- email: "email";
27
- number: "number";
28
- }>;
29
- export type FieldValidation = z.infer<typeof FieldValidation>;
30
2
  export declare const Field: z.ZodObject<{
31
3
  id: z.ZodString;
32
4
  contentType: z.ZodEnum<{
@@ -60,8 +32,8 @@ export declare const Field: z.ZodObject<{
60
32
  options: z.ZodArray<z.ZodString>;
61
33
  isVisible: z.ZodBoolean;
62
34
  order: z.ZodInt;
63
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
64
- createdAt: z.ZodISODateTime;
35
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
36
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
65
37
  }, {
66
38
  out: {};
67
39
  in: {};
@@ -79,8 +51,8 @@ export declare const FieldGroup: z.ZodObject<{
79
51
  code: z.ZodString;
80
52
  description: z.ZodNullable<z.ZodString>;
81
53
  order: z.ZodInt;
82
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
83
- createdAt: z.ZodISODateTime;
54
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
55
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
84
56
  }, {
85
57
  out: {};
86
58
  in: {};
@@ -139,8 +111,8 @@ export declare const fieldsContract: {
139
111
  options: z.ZodArray<z.ZodString>;
140
112
  isVisible: z.ZodBoolean;
141
113
  order: z.ZodInt;
142
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
143
- createdAt: z.ZodISODateTime;
114
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
115
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
144
116
  }, {
145
117
  out: {};
146
118
  in: {};
@@ -221,8 +193,8 @@ export declare const fieldsContract: {
221
193
  options: z.ZodArray<z.ZodString>;
222
194
  isVisible: z.ZodBoolean;
223
195
  order: z.ZodInt;
224
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
225
- createdAt: z.ZodISODateTime;
196
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
197
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
226
198
  }, {
227
199
  out: {};
228
200
  in: {};
@@ -291,8 +263,8 @@ export declare const fieldsContract: {
291
263
  options: z.ZodArray<z.ZodString>;
292
264
  isVisible: z.ZodBoolean;
293
265
  order: z.ZodInt;
294
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
295
- createdAt: z.ZodISODateTime;
266
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
267
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
296
268
  }, {
297
269
  out: {};
298
270
  in: {};
@@ -345,8 +317,8 @@ export declare const fieldsContract: {
345
317
  options: z.ZodArray<z.ZodString>;
346
318
  isVisible: z.ZodBoolean;
347
319
  order: z.ZodInt;
348
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
349
- createdAt: z.ZodISODateTime;
320
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
321
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
350
322
  }, {
351
323
  out: {};
352
324
  in: {};
@@ -385,8 +357,8 @@ export declare const fieldGroupsContract: {
385
357
  code: z.ZodString;
386
358
  description: z.ZodNullable<z.ZodString>;
387
359
  order: z.ZodInt;
388
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
389
- createdAt: z.ZodISODateTime;
360
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
361
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
390
362
  }, {
391
363
  out: {};
392
364
  in: {};
@@ -415,8 +387,8 @@ export declare const fieldGroupsContract: {
415
387
  code: z.ZodString;
416
388
  description: z.ZodNullable<z.ZodString>;
417
389
  order: z.ZodInt;
418
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
419
- createdAt: z.ZodISODateTime;
390
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
391
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
420
392
  }, {
421
393
  out: {};
422
394
  in: {};
@@ -441,8 +413,8 @@ export declare const fieldGroupsContract: {
441
413
  code: z.ZodString;
442
414
  description: z.ZodNullable<z.ZodString>;
443
415
  order: z.ZodInt;
444
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
445
- createdAt: z.ZodISODateTime;
416
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
417
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
446
418
  }, {
447
419
  out: {};
448
420
  in: {};
@@ -468,8 +440,8 @@ export declare const fieldGroupsContract: {
468
440
  code: z.ZodString;
469
441
  description: z.ZodNullable<z.ZodString>;
470
442
  order: z.ZodInt;
471
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
472
- createdAt: z.ZodISODateTime;
443
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
444
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
473
445
  }, {
474
446
  out: {};
475
447
  in: {};
@@ -487,8 +459,8 @@ export declare const fieldGroupsContract: {
487
459
  code: z.ZodString;
488
460
  description: z.ZodNullable<z.ZodString>;
489
461
  order: z.ZodInt;
490
- archivedAt: z.ZodNullable<z.ZodISODateTime>;
491
- createdAt: z.ZodISODateTime;
462
+ archivedAt: z.ZodNullable<z.ZodCodec<z.ZodDate, z.ZodISODateTime>>;
463
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
492
464
  }, {
493
465
  out: {};
494
466
  in: {};
package/dist/fields.js CHANGED
@@ -1,33 +1,11 @@
1
- import { FIELD_TYPES, FIELD_VALIDATIONS, fieldGroups, fields } from "./db/src/schema/fields.js";
1
+ import { fieldGroups, fields } from "./db/src/schema/fields.js";
2
2
  import "./db/src/schema/index.js";
3
- import { FieldContentType, Id, IdList, QueryBoolean, isoDate } from "./common.js";
3
+ import { OPTION_FIELD_TYPES } from "./values.js";
4
+ import { FieldContentType, Id, IdList, QueryBoolean, isoDate, listOf } from "./common.js";
4
5
  import { oc } from "@orpc/contract";
5
6
  import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
6
7
  import { z } from "zod";
7
8
  // src/fields.ts
8
- const FieldType = z.enum(FIELD_TYPES);
9
- /** Field types whose values are chosen from `options`. */
10
- const OPTION_FIELD_TYPES = [
11
- "select",
12
- "multiselect",
13
- "radio",
14
- "check"
15
- ];
16
- /**
17
- * Types sharing a stored value: a field holding values may only change within
18
- * its family; an unused field may become any type.
19
- */
20
- const FIELD_TYPE_FAMILIES = [
21
- ["select", "radio"],
22
- ["multiselect", "check"],
23
- [
24
- "text",
25
- "textarea",
26
- "phone"
27
- ]
28
- ];
29
- /** Format a text field's values must have. */
30
- const FieldValidation = z.enum(FIELD_VALIDATIONS);
31
9
  /** A custom field ("property") on customers or companies. */
32
10
  const int = () => z.int();
33
11
  const Field = createSelectSchema(fields, {
@@ -140,7 +118,7 @@ const fieldsContract = {
140
118
  contentType: FieldContentType,
141
119
  groupId: Id.optional(),
142
120
  archived: QueryBoolean.optional()
143
- })).output(z.object({ data: z.array(Field) })),
121
+ })).output(listOf(Field)),
144
122
  usage: oc.route({
145
123
  method: "GET",
146
124
  path: "/fields/usage",
@@ -201,7 +179,7 @@ const fieldGroupsContract = {
201
179
  }).input(z.object({
202
180
  contentType: FieldContentType,
203
181
  archived: QueryBoolean.optional()
204
- })).output(z.object({ data: z.array(FieldGroup) })),
182
+ })).output(listOf(FieldGroup)),
205
183
  create: oc.route({
206
184
  method: "POST",
207
185
  path: "/field-groups",
@@ -237,4 +215,4 @@ const fieldGroupsContract = {
237
215
  summary: "Delete a group and its fields when no record holds their values (owners and admins). 409 FIELD_IN_USE otherwise"
238
216
  }).input(z.object({ id: Id })).output(Ok)
239
217
  };
240
- export { FIELD_TYPE_FAMILIES, Field, FieldGroup, FieldType, FieldUsage, FieldValidation, OPTION_FIELD_TYPES, fieldGroupsContract, fieldsContract };
218
+ export { Field, FieldGroup, FieldUsage, fieldGroupsContract, fieldsContract };
package/dist/files.d.ts CHANGED
@@ -9,9 +9,10 @@ export declare const FileInfo: z.ZodObject<{
9
9
  ready: "ready";
10
10
  }>;
11
11
  source: z.ZodString;
12
- createdAt: z.ZodISODateTime;
12
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
13
13
  uploadedBy: z.ZodObject<{
14
14
  type: z.ZodEnum<{
15
+ customer: "customer";
15
16
  plugin: "plugin";
16
17
  system: "system";
17
18
  user: "user";
@@ -61,9 +62,10 @@ export declare const filesContract: {
61
62
  ready: "ready";
62
63
  }>;
63
64
  source: z.ZodString;
64
- createdAt: z.ZodISODateTime;
65
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
65
66
  uploadedBy: z.ZodObject<{
66
67
  type: z.ZodEnum<{
68
+ customer: "customer";
67
69
  plugin: "plugin";
68
70
  system: "system";
69
71
  user: "user";
@@ -96,9 +98,10 @@ export declare const filesContract: {
96
98
  ready: "ready";
97
99
  }>;
98
100
  source: z.ZodString;
99
- createdAt: z.ZodISODateTime;
101
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
100
102
  uploadedBy: z.ZodObject<{
101
103
  type: z.ZodEnum<{
104
+ customer: "customer";
102
105
  plugin: "plugin";
103
106
  system: "system";
104
107
  user: "user";
@@ -124,9 +127,10 @@ export declare const filesContract: {
124
127
  ready: "ready";
125
128
  }>;
126
129
  source: z.ZodString;
127
- createdAt: z.ZodISODateTime;
130
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
128
131
  uploadedBy: z.ZodObject<{
129
132
  type: z.ZodEnum<{
133
+ customer: "customer";
130
134
  plugin: "plugin";
131
135
  system: "system";
132
136
  user: "user";
@@ -154,9 +158,10 @@ export declare const filesContract: {
154
158
  ready: "ready";
155
159
  }>;
156
160
  source: z.ZodString;
157
- createdAt: z.ZodISODateTime;
161
+ createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
158
162
  uploadedBy: z.ZodObject<{
159
163
  type: z.ZodEnum<{
164
+ customer: "customer";
160
165
  plugin: "plugin";
161
166
  system: "system";
162
167
  user: "user";
package/dist/files.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { FILE_STATUSES, FILE_STORAGES } from "./db/src/enums.js";
1
2
  import { files } from "./db/src/schema/platform.js";
2
3
  import "./db/src/schema/index.js";
3
4
  import { Id, IdList, isoDate } from "./common.js";
@@ -10,7 +11,7 @@ const FileInfo = createSelectSchema(files, {
10
11
  id: Id,
11
12
  size: () => z.int(),
12
13
  /** Files being deleted are never listed. */
13
- status: z.enum(["pending", "ready"]),
14
+ status: z.enum(FILE_STATUSES).exclude(["deleting"]),
14
15
  createdAt: isoDate
15
16
  }).pick({
16
17
  id: true,
@@ -48,7 +49,7 @@ const FileSettings = z.object({
48
49
  /** The deployment's limit; `maxSizeMb` can't go above it. */
49
50
  limitMb: z.int(),
50
51
  /** Where files are stored. */
51
- storage: z.enum(["local", "s3"])
52
+ storage: z.enum(FILE_STORAGES)
52
53
  });
53
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/*");
54
55
  const filesContract = {
@@ -80,7 +81,7 @@ const filesContract = {
80
81
  method: "GET",
81
82
  path: "/files",
82
83
  summary: "Files by id (ready ones only), e.g. a record’s attachments"
83
- }).input(z.object({ ids: IdList })).output(z.object({ data: z.array(FileInfo) })),
84
+ }).input(z.object({ ids: IdList })).output(z.object({ data: z.array(FileInfo).max(100) })),
84
85
  remove: oc.route({
85
86
  method: "DELETE",
86
87
  path: "/files/{id}",