@marcoappio/marco-config 2.0.492 → 2.0.494

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 (71) hide show
  1. package/dist/types/Zero.d.ts +8 -14
  2. package/dist/types/Zero.d.ts.map +1 -1
  3. package/dist/types/index.d.ts +0 -1
  4. package/dist/types/index.d.ts.map +1 -1
  5. package/dist/types/index.js +0 -1
  6. package/dist/zero/crud.d.ts +1024 -0
  7. package/dist/zero/crud.d.ts.map +1 -0
  8. package/dist/zero/crud.js +3 -0
  9. package/dist/zero/index.d.ts +1621 -1447
  10. package/dist/zero/index.d.ts.map +1 -1
  11. package/dist/zero/index.js +2 -4
  12. package/dist/zero/mutators/accountMutators/accountMutators.d.ts +127 -3
  13. package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +1 -1
  14. package/dist/zero/mutators/accountMutators/accountMutators.js +88 -53
  15. package/dist/zero/mutators/draftMutators/draftMutators.d.ts +185 -3
  16. package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +1 -1
  17. package/dist/zero/mutators/draftMutators/draftMutators.js +124 -51
  18. package/dist/zero/mutators/index.d.ts +1 -1
  19. package/dist/zero/mutators/index.d.ts.map +1 -1
  20. package/dist/zero/mutators/index.js +1 -1
  21. package/dist/zero/mutators/mutators.d.ts +497 -17
  22. package/dist/zero/mutators/mutators.d.ts.map +1 -1
  23. package/dist/zero/mutators/mutators.js +10 -38
  24. package/dist/zero/mutators/threadMutators/threadMutators.d.ts +147 -6
  25. package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +1 -1
  26. package/dist/zero/mutators/threadMutators/threadMutators.js +79 -59
  27. package/dist/zero/mutators/userMutators/userMutators.d.ts +37 -3
  28. package/dist/zero/mutators/userMutators/userMutators.d.ts.map +1 -1
  29. package/dist/zero/mutators/userMutators/userMutators.js +32 -14
  30. package/dist/zero/queries/getAccounts.d.ts +135 -135
  31. package/dist/zero/queries/getContacts.d.ts +135 -135
  32. package/dist/zero/queries/getDrafts.d.ts +135 -135
  33. package/dist/zero/queries/getThread.d.ts +135 -135
  34. package/dist/zero/queries/getThreadList.d.ts +135 -135
  35. package/dist/zero/queries/getThreads.d.ts +135 -135
  36. package/dist/zero/queries/getUser.d.ts +135 -135
  37. package/dist/zero/queries/index.d.ts +133 -133
  38. package/dist/zero/schema.d.ts +133 -133
  39. package/dist/zero/schema.d.ts.map +1 -1
  40. package/dist/zero/schema.js +0 -1
  41. package/package.json +2 -2
  42. package/dist/types/AuthData.d.ts +0 -4
  43. package/dist/types/AuthData.d.ts.map +0 -1
  44. package/dist/types/AuthData.js +0 -1
  45. package/dist/zero/mutatorSchemas/account.d.ts +0 -80
  46. package/dist/zero/mutatorSchemas/account.d.ts.map +0 -1
  47. package/dist/zero/mutatorSchemas/account.js +0 -66
  48. package/dist/zero/mutatorSchemas/draft.d.ts +0 -150
  49. package/dist/zero/mutatorSchemas/draft.d.ts.map +0 -1
  50. package/dist/zero/mutatorSchemas/draft.js +0 -104
  51. package/dist/zero/mutatorSchemas/index.d.ts +0 -323
  52. package/dist/zero/mutatorSchemas/index.d.ts.map +0 -1
  53. package/dist/zero/mutatorSchemas/index.js +0 -10
  54. package/dist/zero/mutatorSchemas/thread.d.ts +0 -71
  55. package/dist/zero/mutatorSchemas/thread.d.ts.map +0 -1
  56. package/dist/zero/mutatorSchemas/thread.js +0 -47
  57. package/dist/zero/mutatorSchemas/user.d.ts +0 -26
  58. package/dist/zero/mutatorSchemas/user.d.ts.map +0 -1
  59. package/dist/zero/mutatorSchemas/user.js +0 -27
  60. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts +0 -2
  61. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts.map +0 -1
  62. package/dist/zero/mutators/accountMutators/accountMutators.test.js +0 -372
  63. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts +0 -2
  64. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts.map +0 -1
  65. package/dist/zero/mutators/draftMutators/draftMutators.test.js +0 -416
  66. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts +0 -2
  67. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts.map +0 -1
  68. package/dist/zero/mutators/threadMutators/threadMutators.test.js +0 -755
  69. package/dist/zero/mutators/userMutators/userMutators.test.d.ts +0 -2
  70. package/dist/zero/mutators/userMutators/userMutators.test.d.ts.map +0 -1
  71. package/dist/zero/mutators/userMutators/userMutators.test.js +0 -84
@@ -1,18 +1,498 @@
1
- import * as v from 'valibot';
2
- import type { MutatorMap } from '../../types';
3
- import { type ZeroMutatorSchemas } from '../../zero/mutatorSchemas';
4
- export type AuthData = {
5
- sub: string;
6
- };
7
- export declare class ZeroMutatorValidationError extends Error {
8
- readonly issues: ReturnType<typeof v.flatten>;
9
- constructor(issues: ReturnType<typeof v.flatten>);
10
- }
11
- export type MarcoZeroMutators = {
12
- account: MutatorMap<ZeroMutatorSchemas['account']>;
13
- draft: MutatorMap<ZeroMutatorSchemas['draft']>;
14
- thread: MutatorMap<ZeroMutatorSchemas['thread']>;
15
- user: MutatorMap<ZeroMutatorSchemas['user']>;
16
- };
17
- export declare const createMutators: (authData?: AuthData) => MarcoZeroMutators;
1
+ export declare const mutators: import("@rocicorp/zero").MutatorRegistry<{
2
+ readonly account: {
3
+ createAccount: import("@rocicorp/zero").MutatorDefinition<{
4
+ aliasId: string;
5
+ color: string;
6
+ emailAddress: string;
7
+ id: string;
8
+ }, {
9
+ aliasId: string;
10
+ color: string;
11
+ emailAddress: string;
12
+ id: string;
13
+ }, {
14
+ readonly userId: string;
15
+ }, unknown>;
16
+ createAlias: import("@rocicorp/zero").MutatorDefinition<{
17
+ accountId: string;
18
+ alias: {
19
+ emailAddress: string;
20
+ id: string;
21
+ name: string | null;
22
+ };
23
+ }, {
24
+ accountId: string;
25
+ alias: {
26
+ emailAddress: string;
27
+ id: string;
28
+ name: string | null;
29
+ };
30
+ }, {
31
+ readonly userId: string;
32
+ }, unknown>;
33
+ deleteAccount: import("@rocicorp/zero").MutatorDefinition<{
34
+ id: string;
35
+ }, {
36
+ id: string;
37
+ }, {
38
+ readonly userId: string;
39
+ }, unknown>;
40
+ deleteAlias: import("@rocicorp/zero").MutatorDefinition<{
41
+ accountId: string;
42
+ aliasId: string;
43
+ }, {
44
+ accountId: string;
45
+ aliasId: string;
46
+ }, {
47
+ readonly userId: string;
48
+ }, unknown>;
49
+ setAliasName: import("@rocicorp/zero").MutatorDefinition<{
50
+ accountId: string;
51
+ aliasId: string;
52
+ displayName: string | null;
53
+ }, {
54
+ accountId: string;
55
+ aliasId: string;
56
+ displayName: string | null;
57
+ }, {
58
+ readonly userId: string;
59
+ }, unknown>;
60
+ setAliasPrimary: import("@rocicorp/zero").MutatorDefinition<{
61
+ accountId: string;
62
+ aliasId: string;
63
+ }, {
64
+ accountId: string;
65
+ aliasId: string;
66
+ }, {
67
+ readonly userId: string;
68
+ }, unknown>;
69
+ setConnectionConfigImapRaw: import("@rocicorp/zero").MutatorDefinition<{
70
+ connectionConfig: {
71
+ imapHost: string;
72
+ imapPassword: string;
73
+ imapPort: number;
74
+ imapSocketType: "STARTTLS" | "SSL";
75
+ imapUser: string;
76
+ smtpHost: string;
77
+ smtpPassword: string;
78
+ smtpPort: number;
79
+ smtpSocketType: "STARTTLS" | "SSL";
80
+ smtpUser: string;
81
+ };
82
+ id: string;
83
+ }, {
84
+ connectionConfig: {
85
+ imapHost: string;
86
+ imapPassword: string;
87
+ imapPort: number;
88
+ imapSocketType: "STARTTLS" | "SSL";
89
+ imapUser: string;
90
+ smtpHost: string;
91
+ smtpPassword: string;
92
+ smtpPort: number;
93
+ smtpSocketType: "STARTTLS" | "SSL";
94
+ smtpUser: string;
95
+ };
96
+ id: string;
97
+ }, {
98
+ readonly userId: string;
99
+ }, unknown>;
100
+ setConnectionConfigOauth: import("@rocicorp/zero").MutatorDefinition<{
101
+ connectionConfig: {
102
+ code: string;
103
+ provider: "GOOGLE" | "OUTLOOK";
104
+ user: string;
105
+ };
106
+ id: string;
107
+ }, {
108
+ connectionConfig: {
109
+ code: string;
110
+ provider: "GOOGLE" | "OUTLOOK";
111
+ user: string;
112
+ };
113
+ id: string;
114
+ }, {
115
+ readonly userId: string;
116
+ }, unknown>;
117
+ setSettings: import("@rocicorp/zero").MutatorDefinition<{
118
+ color?: string | null | undefined;
119
+ displayName?: string | null | undefined;
120
+ id: string;
121
+ }, {
122
+ color?: string | null | undefined;
123
+ displayName?: string | null | undefined;
124
+ id: string;
125
+ }, {
126
+ readonly userId: string;
127
+ }, unknown>;
128
+ };
129
+ readonly draft: {
130
+ cancelSend: import("@rocicorp/zero").MutatorDefinition<{
131
+ id: string;
132
+ updatedAt: number;
133
+ }, {
134
+ id: string;
135
+ updatedAt: number;
136
+ }, {
137
+ readonly userId: string;
138
+ }, unknown>;
139
+ createAttachment: import("@rocicorp/zero").MutatorDefinition<{
140
+ attachment: {
141
+ fileName: string;
142
+ id: string;
143
+ mimeType: string;
144
+ status: "PENDING" | "COMPLETE" | "FAILED";
145
+ totalSize: number;
146
+ };
147
+ id: string;
148
+ updatedAt: number;
149
+ }, {
150
+ attachment: {
151
+ fileName: string;
152
+ id: string;
153
+ mimeType: string;
154
+ status: "PENDING" | "COMPLETE" | "FAILED";
155
+ totalSize: number;
156
+ };
157
+ id: string;
158
+ updatedAt: number;
159
+ }, {
160
+ readonly userId: string;
161
+ }, unknown>;
162
+ createDraft: import("@rocicorp/zero").MutatorDefinition<{
163
+ accountId: string;
164
+ attachments: {
165
+ fileName: string;
166
+ id: string;
167
+ mimeType: string;
168
+ status: "PENDING" | "COMPLETE" | "FAILED";
169
+ totalSize: number;
170
+ }[];
171
+ body: {
172
+ bcc: string[];
173
+ cc: string[];
174
+ content: string;
175
+ subject: string | null;
176
+ to: string[];
177
+ };
178
+ error: string | null;
179
+ from: string;
180
+ fromName: string | null;
181
+ id: string;
182
+ referencedMessageId: string | null;
183
+ scheduledFor: number | null;
184
+ status: "DRAFT" | "SEND_REQUESTED" | "SEND_CONFIRMED" | "SEND_FAILED";
185
+ type: "NEW" | "REPLY" | "FORWARD";
186
+ updatedAt: number;
187
+ }, {
188
+ accountId: string;
189
+ attachments: {
190
+ fileName: string;
191
+ id: string;
192
+ mimeType: string;
193
+ status: "PENDING" | "COMPLETE" | "FAILED";
194
+ totalSize: number;
195
+ }[];
196
+ body: {
197
+ bcc: string[];
198
+ cc: string[];
199
+ content: string;
200
+ subject: string | null;
201
+ to: string[];
202
+ };
203
+ error: string | null;
204
+ from: string;
205
+ fromName: string | null;
206
+ id: string;
207
+ referencedMessageId: string | null;
208
+ scheduledFor: number | null;
209
+ status: "DRAFT" | "SEND_REQUESTED" | "SEND_CONFIRMED" | "SEND_FAILED";
210
+ type: "NEW" | "REPLY" | "FORWARD";
211
+ updatedAt: number;
212
+ }, {
213
+ readonly userId: string;
214
+ }, unknown>;
215
+ deleteAttachment: import("@rocicorp/zero").MutatorDefinition<{
216
+ attachmentId: string;
217
+ id: string;
218
+ updatedAt: number;
219
+ }, {
220
+ attachmentId: string;
221
+ id: string;
222
+ updatedAt: number;
223
+ }, {
224
+ readonly userId: string;
225
+ }, unknown>;
226
+ deleteDraft: import("@rocicorp/zero").MutatorDefinition<{
227
+ id: string;
228
+ }, {
229
+ id: string;
230
+ }, {
231
+ readonly userId: string;
232
+ }, unknown>;
233
+ scheduleSend: import("@rocicorp/zero").MutatorDefinition<{
234
+ id: string;
235
+ kind: "IMMEDIATE";
236
+ undoMs: number;
237
+ updatedAt: number;
238
+ } | {
239
+ id: string;
240
+ kind: "SCHEDULED";
241
+ scheduledFor: number;
242
+ updatedAt: number;
243
+ }, {
244
+ id: string;
245
+ kind: "IMMEDIATE";
246
+ undoMs: number;
247
+ updatedAt: number;
248
+ } | {
249
+ id: string;
250
+ kind: "SCHEDULED";
251
+ scheduledFor: number;
252
+ updatedAt: number;
253
+ }, {
254
+ readonly userId: string;
255
+ }, unknown>;
256
+ setContent: import("@rocicorp/zero").MutatorDefinition<{
257
+ id: string;
258
+ patch: {
259
+ index: number;
260
+ type: "INSERTION" | "DELETION";
261
+ value: string;
262
+ }[];
263
+ updatedAt: number;
264
+ }, {
265
+ id: string;
266
+ patch: {
267
+ index: number;
268
+ type: "INSERTION" | "DELETION";
269
+ value: string;
270
+ }[];
271
+ updatedAt: number;
272
+ }, {
273
+ readonly userId: string;
274
+ }, unknown>;
275
+ setEnvelope: import("@rocicorp/zero").MutatorDefinition<{
276
+ envelope: {
277
+ bcc: string[];
278
+ cc: string[];
279
+ to: string[];
280
+ subject: string | null;
281
+ };
282
+ id: string;
283
+ updatedAt: number;
284
+ }, {
285
+ envelope: {
286
+ bcc: string[];
287
+ cc: string[];
288
+ to: string[];
289
+ subject: string | null;
290
+ };
291
+ id: string;
292
+ updatedAt: number;
293
+ }, {
294
+ readonly userId: string;
295
+ }, unknown>;
296
+ setFrom: import("@rocicorp/zero").MutatorDefinition<{
297
+ accountId: string;
298
+ aliasId: string;
299
+ from: string;
300
+ fromName: string | null;
301
+ id: string;
302
+ updatedAt: number;
303
+ }, {
304
+ accountId: string;
305
+ aliasId: string;
306
+ from: string;
307
+ fromName: string | null;
308
+ id: string;
309
+ updatedAt: number;
310
+ }, {
311
+ readonly userId: string;
312
+ }, unknown>;
313
+ };
314
+ readonly thread: {
315
+ addLabel: import("@rocicorp/zero").MutatorDefinition<{
316
+ accounts: {
317
+ [x: string]: {
318
+ threadIds: string[];
319
+ };
320
+ };
321
+ labelPath: string;
322
+ }, {
323
+ accounts: {
324
+ [x: string]: {
325
+ threadIds: string[];
326
+ };
327
+ };
328
+ labelPath: string;
329
+ }, {
330
+ readonly userId: string;
331
+ }, unknown>;
332
+ delete: import("@rocicorp/zero").MutatorDefinition<{
333
+ accounts: {
334
+ [x: string]: {
335
+ threadIds: string[];
336
+ };
337
+ };
338
+ }, {
339
+ accounts: {
340
+ [x: string]: {
341
+ threadIds: string[];
342
+ };
343
+ };
344
+ }, {
345
+ readonly userId: string;
346
+ }, unknown>;
347
+ removeLabel: import("@rocicorp/zero").MutatorDefinition<{
348
+ accounts: {
349
+ [x: string]: {
350
+ threadIds: string[];
351
+ };
352
+ };
353
+ labelPath: string;
354
+ }, {
355
+ accounts: {
356
+ [x: string]: {
357
+ threadIds: string[];
358
+ };
359
+ };
360
+ labelPath: string;
361
+ }, {
362
+ readonly userId: string;
363
+ }, unknown>;
364
+ setArchive: import("@rocicorp/zero").MutatorDefinition<{
365
+ accounts: {
366
+ [x: string]: {
367
+ threadIds: string[];
368
+ };
369
+ };
370
+ }, {
371
+ accounts: {
372
+ [x: string]: {
373
+ threadIds: string[];
374
+ };
375
+ };
376
+ }, {
377
+ readonly userId: string;
378
+ }, unknown>;
379
+ setFlagged: import("@rocicorp/zero").MutatorDefinition<{
380
+ accounts: {
381
+ [x: string]: {
382
+ threadIds: string[];
383
+ };
384
+ };
385
+ flagged: boolean;
386
+ }, {
387
+ accounts: {
388
+ [x: string]: {
389
+ threadIds: string[];
390
+ };
391
+ };
392
+ flagged: boolean;
393
+ }, {
394
+ readonly userId: string;
395
+ }, unknown>;
396
+ setInbox: import("@rocicorp/zero").MutatorDefinition<{
397
+ accounts: {
398
+ [x: string]: {
399
+ threadIds: string[];
400
+ };
401
+ };
402
+ }, {
403
+ accounts: {
404
+ [x: string]: {
405
+ threadIds: string[];
406
+ };
407
+ };
408
+ }, {
409
+ readonly userId: string;
410
+ }, unknown>;
411
+ setSeen: import("@rocicorp/zero").MutatorDefinition<{
412
+ accounts: {
413
+ [x: string]: {
414
+ threadIds: string[];
415
+ };
416
+ };
417
+ seen: boolean;
418
+ }, {
419
+ accounts: {
420
+ [x: string]: {
421
+ threadIds: string[];
422
+ };
423
+ };
424
+ seen: boolean;
425
+ }, {
426
+ readonly userId: string;
427
+ }, unknown>;
428
+ setSpam: import("@rocicorp/zero").MutatorDefinition<{
429
+ accounts: {
430
+ [x: string]: {
431
+ threadIds: string[];
432
+ };
433
+ };
434
+ }, {
435
+ accounts: {
436
+ [x: string]: {
437
+ threadIds: string[];
438
+ };
439
+ };
440
+ }, {
441
+ readonly userId: string;
442
+ }, unknown>;
443
+ setTrash: import("@rocicorp/zero").MutatorDefinition<{
444
+ accounts: {
445
+ [x: string]: {
446
+ threadIds: string[];
447
+ };
448
+ };
449
+ }, {
450
+ accounts: {
451
+ [x: string]: {
452
+ threadIds: string[];
453
+ };
454
+ };
455
+ }, {
456
+ readonly userId: string;
457
+ }, unknown>;
458
+ };
459
+ readonly user: {
460
+ deleteSettingsPushNotificationToken: import("@rocicorp/zero").MutatorDefinition<{
461
+ id: string;
462
+ token: string;
463
+ }, {
464
+ id: string;
465
+ token: string;
466
+ }, {
467
+ readonly userId: string;
468
+ }, unknown>;
469
+ setSettingsName: import("@rocicorp/zero").MutatorDefinition<{
470
+ id: string;
471
+ name: string | null;
472
+ }, {
473
+ id: string;
474
+ name: string | null;
475
+ }, {
476
+ readonly userId: string;
477
+ }, unknown>;
478
+ setSettingsPushNotificationToken: import("@rocicorp/zero").MutatorDefinition<{
479
+ id: string;
480
+ pushNotificationToken: {
481
+ createdAt: number;
482
+ id: string;
483
+ token: string;
484
+ };
485
+ }, {
486
+ id: string;
487
+ pushNotificationToken: {
488
+ createdAt: number;
489
+ id: string;
490
+ token: string;
491
+ };
492
+ }, {
493
+ readonly userId: string;
494
+ }, unknown>;
495
+ };
496
+ }, import("@rocicorp/zero").Schema>;
497
+ export type MarcoZeroMutators = typeof mutators;
18
498
  //# sourceMappingURL=mutators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutators.d.ts","sourceRoot":"","sources":["../../../src/zero/mutators/mutators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAkD,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,mCAAmC,CAAA;AAQ/F,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AA8BD,qBAAa,0BAA2B,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;gBAApC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;CAG1D;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAA;IAClD,KAAK,EAAE,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9C,MAAM,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAA;IAChD,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,cAAc,cAAe,QAAQ,KAAG,iBAKnD,CAAA"}
1
+ {"version":3,"file":"mutators.d.ts","sourceRoot":"","sources":["../../../src/zero/mutators/mutators.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAKnB,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,QAAQ,CAAA"}
@@ -1,39 +1,11 @@
1
- import * as v from 'valibot';
2
- import { zeroMutatorSchemas } from '../../zero/mutatorSchemas';
3
- import { createAccountMutators } from './accountMutators';
4
- import { createDraftMutators } from './draftMutators';
5
- import { createThreadMutators } from './threadMutators';
6
- import { createUserMutators } from './userMutators';
7
- const validateArgs = (schema, input) => {
8
- const parsed = v.safeParse(schema, input);
9
- if (!parsed.success) {
10
- throw new ZeroMutatorValidationError(v.flatten(parsed.issues));
11
- }
12
- return parsed.output;
13
- };
14
- const createValidatingMutator = (schema, handler) => {
15
- return async (tx, input) => {
16
- const args = validateArgs(schema, input);
17
- await handler(tx, args);
18
- };
19
- };
20
- const buildMutatorMap = (defs, handlers) => {
21
- const entries = Object.entries(defs).map(([name, definition]) => [
22
- name,
23
- createValidatingMutator(definition.delta, handlers[name]),
24
- ]);
25
- return Object.fromEntries(entries);
26
- };
27
- export class ZeroMutatorValidationError extends Error {
28
- issues;
29
- constructor(issues) {
30
- super('Zero mutator payload failed validation');
31
- this.issues = issues;
32
- }
33
- }
34
- export const createMutators = (authData) => ({
35
- account: buildMutatorMap(zeroMutatorSchemas.account, createAccountMutators(authData)),
36
- draft: buildMutatorMap(zeroMutatorSchemas.draft, createDraftMutators(authData)),
37
- thread: buildMutatorMap(zeroMutatorSchemas.thread, createThreadMutators(authData)),
38
- user: buildMutatorMap(zeroMutatorSchemas.user, createUserMutators(authData)),
1
+ import { defineMutators } from '@rocicorp/zero';
2
+ import { accountMutators } from './accountMutators';
3
+ import { draftMutators } from './draftMutators';
4
+ import { threadMutators } from './threadMutators';
5
+ import { userMutators } from './userMutators';
6
+ export const mutators = defineMutators({
7
+ account: accountMutators,
8
+ draft: draftMutators,
9
+ thread: threadMutators,
10
+ user: userMutators,
39
11
  });