@marcoappio/marco-config 2.0.508 → 2.0.510

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 (105) hide show
  1. package/dist/constants/index.d.ts +1 -0
  2. package/dist/constants/index.d.ts.map +1 -1
  3. package/dist/constants/zero.d.ts +1 -0
  4. package/dist/constants/zero.d.ts.map +1 -1
  5. package/dist/constants/zero.js +1 -0
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/types/Zero.d.ts +0 -17
  9. package/dist/types/Zero.d.ts.map +1 -1
  10. package/dist/zero/index.d.ts +2903 -8808
  11. package/dist/zero/index.d.ts.map +1 -1
  12. package/dist/zero/index.js +6 -17
  13. package/dist/zero/{queries/getThreadList.d.ts → mutators.d.ts} +572 -169
  14. package/dist/zero/{queries/getThreads.d.ts.map → mutators.d.ts.map} +1 -1
  15. package/dist/zero/mutators.js +659 -0
  16. package/dist/zero/mutators.test.d.ts +2 -0
  17. package/dist/zero/mutators.test.d.ts.map +1 -0
  18. package/dist/zero/mutators.test.js +603 -0
  19. package/dist/zero/{queries/getThreads.d.ts → queries.d.ts} +481 -196
  20. package/dist/zero/{queries/getThread.d.ts.map → queries.d.ts.map} +1 -1
  21. package/dist/zero/queries.js +168 -0
  22. package/dist/zero/schema.d.ts +138 -133
  23. package/dist/zero/schema.d.ts.map +1 -1
  24. package/dist/zero/schema.js +1 -1
  25. package/package.json +3 -3
  26. package/dist/zero/mutatorSchemas/account.d.ts +0 -80
  27. package/dist/zero/mutatorSchemas/account.d.ts.map +0 -1
  28. package/dist/zero/mutatorSchemas/account.js +0 -66
  29. package/dist/zero/mutatorSchemas/draft.d.ts +0 -150
  30. package/dist/zero/mutatorSchemas/draft.d.ts.map +0 -1
  31. package/dist/zero/mutatorSchemas/draft.js +0 -104
  32. package/dist/zero/mutatorSchemas/index.d.ts +0 -323
  33. package/dist/zero/mutatorSchemas/index.d.ts.map +0 -1
  34. package/dist/zero/mutatorSchemas/index.js +0 -10
  35. package/dist/zero/mutatorSchemas/thread.d.ts +0 -71
  36. package/dist/zero/mutatorSchemas/thread.d.ts.map +0 -1
  37. package/dist/zero/mutatorSchemas/thread.js +0 -47
  38. package/dist/zero/mutatorSchemas/user.d.ts +0 -26
  39. package/dist/zero/mutatorSchemas/user.d.ts.map +0 -1
  40. package/dist/zero/mutatorSchemas/user.js +0 -27
  41. package/dist/zero/mutators/accountMutators/accountMutators.d.ts +0 -4
  42. package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +0 -1
  43. package/dist/zero/mutators/accountMutators/accountMutators.js +0 -103
  44. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts +0 -2
  45. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts.map +0 -1
  46. package/dist/zero/mutators/accountMutators/accountMutators.test.js +0 -372
  47. package/dist/zero/mutators/accountMutators/index.d.ts +0 -2
  48. package/dist/zero/mutators/accountMutators/index.d.ts.map +0 -1
  49. package/dist/zero/mutators/accountMutators/index.js +0 -1
  50. package/dist/zero/mutators/draftMutators/draftMutators.d.ts +0 -4
  51. package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +0 -1
  52. package/dist/zero/mutators/draftMutators/draftMutators.js +0 -142
  53. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts +0 -2
  54. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts.map +0 -1
  55. package/dist/zero/mutators/draftMutators/draftMutators.test.js +0 -416
  56. package/dist/zero/mutators/draftMutators/index.d.ts +0 -2
  57. package/dist/zero/mutators/draftMutators/index.d.ts.map +0 -1
  58. package/dist/zero/mutators/draftMutators/index.js +0 -1
  59. package/dist/zero/mutators/index.d.ts +0 -3
  60. package/dist/zero/mutators/index.d.ts.map +0 -1
  61. package/dist/zero/mutators/index.js +0 -1
  62. package/dist/zero/mutators/mutators.d.ts +0 -18
  63. package/dist/zero/mutators/mutators.d.ts.map +0 -1
  64. package/dist/zero/mutators/mutators.js +0 -39
  65. package/dist/zero/mutators/threadMutators/index.d.ts +0 -2
  66. package/dist/zero/mutators/threadMutators/index.d.ts.map +0 -1
  67. package/dist/zero/mutators/threadMutators/index.js +0 -1
  68. package/dist/zero/mutators/threadMutators/threadMutators.d.ts +0 -8
  69. package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +0 -1
  70. package/dist/zero/mutators/threadMutators/threadMutators.js +0 -257
  71. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts +0 -2
  72. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts.map +0 -1
  73. package/dist/zero/mutators/threadMutators/threadMutators.test.js +0 -755
  74. package/dist/zero/mutators/userMutators/index.d.ts +0 -2
  75. package/dist/zero/mutators/userMutators/index.d.ts.map +0 -1
  76. package/dist/zero/mutators/userMutators/index.js +0 -1
  77. package/dist/zero/mutators/userMutators/userMutators.d.ts +0 -4
  78. package/dist/zero/mutators/userMutators/userMutators.d.ts.map +0 -1
  79. package/dist/zero/mutators/userMutators/userMutators.js +0 -28
  80. package/dist/zero/mutators/userMutators/userMutators.test.d.ts +0 -2
  81. package/dist/zero/mutators/userMutators/userMutators.test.d.ts.map +0 -1
  82. package/dist/zero/mutators/userMutators/userMutators.test.js +0 -84
  83. package/dist/zero/queries/getAccounts.d.ts +0 -1060
  84. package/dist/zero/queries/getAccounts.d.ts.map +0 -1
  85. package/dist/zero/queries/getAccounts.js +0 -3
  86. package/dist/zero/queries/getContacts.d.ts +0 -1040
  87. package/dist/zero/queries/getContacts.d.ts.map +0 -1
  88. package/dist/zero/queries/getContacts.js +0 -37
  89. package/dist/zero/queries/getDrafts.d.ts +0 -1061
  90. package/dist/zero/queries/getDrafts.d.ts.map +0 -1
  91. package/dist/zero/queries/getDrafts.js +0 -24
  92. package/dist/zero/queries/getThread.d.ts +0 -1072
  93. package/dist/zero/queries/getThread.js +0 -14
  94. package/dist/zero/queries/getThreadByMessageId.d.ts +0 -1056
  95. package/dist/zero/queries/getThreadByMessageId.d.ts.map +0 -1
  96. package/dist/zero/queries/getThreadByMessageId.js +0 -13
  97. package/dist/zero/queries/getThreadList.d.ts.map +0 -1
  98. package/dist/zero/queries/getThreadList.js +0 -57
  99. package/dist/zero/queries/getThreads.js +0 -59
  100. package/dist/zero/queries/getUser.d.ts +0 -1074
  101. package/dist/zero/queries/getUser.d.ts.map +0 -1
  102. package/dist/zero/queries/getUser.js +0 -7
  103. package/dist/zero/queries/index.d.ts +0 -1032
  104. package/dist/zero/queries/index.d.ts.map +0 -1
  105. package/dist/zero/queries/index.js +0 -11
@@ -1,416 +0,0 @@
1
- import { describe, expect, it, mock } from 'bun:test';
2
- import { createMutators } from '../mutators';
3
- describe('draftMutators', () => {
4
- describe('scheduleSend', () => {
5
- it('marks immediate schedule send drafts as send requested', async () => {
6
- const draftUpdate = mock(async () => { });
7
- const transaction = {
8
- mutate: {
9
- draft: {
10
- delete: mock(async () => { }),
11
- insert: mock(async () => { }),
12
- update: draftUpdate,
13
- },
14
- },
15
- query: {},
16
- };
17
- const mutators = createMutators();
18
- await mutators.draft.scheduleSend(transaction, {
19
- id: 'test-draft-id-1',
20
- kind: 'IMMEDIATE',
21
- undoMs: 15_000,
22
- updatedAt: 1_000,
23
- });
24
- expect(draftUpdate).toHaveBeenCalledWith({
25
- id: 'test-draft-id-1',
26
- scheduledFor: 16_000,
27
- status: 'SEND_REQUESTED',
28
- updatedAt: 1_000,
29
- });
30
- });
31
- });
32
- describe('setContent', () => {
33
- it('applies string patches when updating draft content', async () => {
34
- const draftRecord = {
35
- body: { content: 'hello' },
36
- id: 'test-draft-id-1',
37
- };
38
- const run = mock(async () => draftRecord);
39
- const one = mock(() => ({ run }));
40
- const where = mock(() => ({ one }));
41
- const draftUpdate = mock(async () => { });
42
- const transaction = {
43
- mutate: {
44
- draft: {
45
- delete: mock(async () => { }),
46
- insert: mock(async () => { }),
47
- update: draftUpdate,
48
- },
49
- },
50
- query: {
51
- draft: {
52
- where,
53
- },
54
- },
55
- };
56
- const mutators = createMutators();
57
- await mutators.draft.setContent(transaction, {
58
- id: 'test-draft-id-1',
59
- patch: [
60
- {
61
- index: 5,
62
- type: 'INSERTION',
63
- value: '!',
64
- },
65
- ],
66
- updatedAt: 2_000,
67
- });
68
- expect(where).toHaveBeenCalledWith('id', 'test-draft-id-1');
69
- expect(draftUpdate).toHaveBeenCalledWith({
70
- body: {
71
- content: 'hello!',
72
- },
73
- id: 'test-draft-id-1',
74
- updatedAt: 2_000,
75
- });
76
- });
77
- });
78
- describe('cancelSend', () => {
79
- it('cancels draft send', async () => {
80
- const draftRecord = {
81
- id: 'test-draft-id-1',
82
- status: 'SEND_REQUESTED',
83
- };
84
- const run = mock(async () => draftRecord);
85
- const one = mock(() => ({ run }));
86
- const where = mock(() => ({ one }));
87
- const draftUpdate = mock(async () => { });
88
- const transaction = {
89
- mutate: {
90
- draft: {
91
- delete: mock(async () => { }),
92
- insert: mock(async () => { }),
93
- update: draftUpdate,
94
- },
95
- },
96
- query: {
97
- draft: {
98
- where,
99
- },
100
- },
101
- };
102
- const mutators = createMutators();
103
- await mutators.draft.cancelSend(transaction, {
104
- id: 'test-draft-id-1',
105
- updatedAt: 5_000,
106
- });
107
- expect(draftUpdate).toHaveBeenCalledWith({
108
- id: 'test-draft-id-1',
109
- scheduledFor: null,
110
- status: 'DRAFT',
111
- updatedAt: 5_000,
112
- });
113
- });
114
- it('throws error when draft is already sent', async () => {
115
- const draftRecord = {
116
- id: 'test-draft-id-1',
117
- status: 'SEND_CONFIRMED',
118
- };
119
- const run = mock(async () => draftRecord);
120
- const one = mock(() => ({ run }));
121
- const where = mock(() => ({ one }));
122
- const draftUpdate = mock(async () => { });
123
- const transaction = {
124
- mutate: {
125
- draft: {
126
- delete: mock(async () => { }),
127
- insert: mock(async () => { }),
128
- update: draftUpdate,
129
- },
130
- },
131
- query: {
132
- draft: {
133
- where,
134
- },
135
- },
136
- };
137
- const mutators = createMutators();
138
- await expect(mutators.draft.cancelSend(transaction, {
139
- id: 'test-draft-id-1',
140
- updatedAt: 5_000,
141
- })).rejects.toThrow('MutationError/ALREADY_APPLIED');
142
- expect(draftUpdate).not.toHaveBeenCalled();
143
- });
144
- it('throws error when draft not found', async () => {
145
- const run = mock(async () => null);
146
- const one = mock(() => ({ run }));
147
- const where = mock(() => ({ one }));
148
- const draftUpdate = mock(async () => { });
149
- const transaction = {
150
- mutate: {
151
- draft: {
152
- delete: mock(async () => { }),
153
- insert: mock(async () => { }),
154
- update: draftUpdate,
155
- },
156
- },
157
- query: {
158
- draft: {
159
- where,
160
- },
161
- },
162
- };
163
- const mutators = createMutators();
164
- await expect(mutators.draft.cancelSend(transaction, {
165
- id: 'test-draft-id-1',
166
- updatedAt: 5_000,
167
- })).rejects.toThrow('MutationError/ENTITY_NOT_FOUND');
168
- expect(draftUpdate).not.toHaveBeenCalled();
169
- });
170
- });
171
- describe('createAttachment', () => {
172
- it('creates draft attachment', async () => {
173
- const draftAttachmentInsert = mock(async () => { });
174
- const draftUpdate = mock(async () => { });
175
- const transaction = {
176
- mutate: {
177
- draft: {
178
- delete: mock(async () => { }),
179
- insert: mock(async () => { }),
180
- update: draftUpdate,
181
- },
182
- draftAttachment: {
183
- delete: mock(async () => { }),
184
- insert: draftAttachmentInsert,
185
- update: mock(async () => { }),
186
- },
187
- },
188
- query: {},
189
- };
190
- const mutators = createMutators();
191
- await mutators.draft.createAttachment(transaction, {
192
- attachment: {
193
- fileName: 'test-document.pdf',
194
- id: 'test-attachment-id-1',
195
- mimeType: 'application/pdf',
196
- status: 'PENDING',
197
- totalSize: 1024000,
198
- },
199
- id: 'test-draft-id-1',
200
- updatedAt: 3_000,
201
- });
202
- expect(draftAttachmentInsert).toHaveBeenCalledWith({
203
- draftId: 'test-draft-id-1',
204
- fileName: 'test-document.pdf',
205
- id: 'test-attachment-id-1',
206
- mimeType: 'application/pdf',
207
- status: 'PENDING',
208
- totalSize: 1024000,
209
- });
210
- expect(draftUpdate).toHaveBeenCalledWith({
211
- id: 'test-draft-id-1',
212
- updatedAt: 3_000,
213
- });
214
- });
215
- });
216
- describe('createDraft', () => {
217
- it('creates a draft', async () => {
218
- const draftInsert = mock(async () => { });
219
- const transaction = {
220
- mutate: {
221
- draft: {
222
- delete: mock(async () => { }),
223
- insert: draftInsert,
224
- update: mock(async () => { }),
225
- },
226
- draftAttachment: {
227
- delete: mock(async () => { }),
228
- insert: mock(async () => { }),
229
- update: mock(async () => { }),
230
- },
231
- },
232
- query: {},
233
- };
234
- const mutators = createMutators({ sub: 'test-user-id' });
235
- await mutators.draft.createDraft(transaction, {
236
- accountId: 'test-account-id-1',
237
- attachments: [],
238
- body: {
239
- bcc: [],
240
- cc: [],
241
- content: 'Draft content',
242
- subject: 'Test Subject',
243
- to: ['recipient@example.com'],
244
- },
245
- error: null,
246
- from: 'sender@example.com',
247
- fromName: 'Test Sender',
248
- id: 'test-draft-id-2',
249
- referencedMessageId: null,
250
- scheduledFor: null,
251
- status: 'DRAFT',
252
- type: 'NEW',
253
- updatedAt: 1_000,
254
- });
255
- expect(draftInsert).toHaveBeenCalledWith({
256
- accountId: 'test-account-id-1',
257
- body: {
258
- bcc: [],
259
- cc: [],
260
- content: 'Draft content',
261
- to: ['recipient@example.com'],
262
- },
263
- error: null,
264
- fromAliasId: null,
265
- fromEmail: 'sender@example.com',
266
- fromName: 'Test Sender',
267
- id: 'test-draft-id-2',
268
- referencedMessageId: null,
269
- scheduledFor: null,
270
- status: 'DRAFT',
271
- subject: 'Test Subject',
272
- type: 'NEW',
273
- updatedAt: 1_000,
274
- userId: 'test-user-id',
275
- });
276
- });
277
- });
278
- describe('deleteAttachment', () => {
279
- it('deletes draft attachment', async () => {
280
- const draftAttachmentDelete = mock(async () => { });
281
- const draftUpdate = mock(async () => { });
282
- const transaction = {
283
- mutate: {
284
- draft: {
285
- delete: mock(async () => { }),
286
- insert: mock(async () => { }),
287
- update: draftUpdate,
288
- },
289
- draftAttachment: {
290
- delete: draftAttachmentDelete,
291
- insert: mock(async () => { }),
292
- update: mock(async () => { }),
293
- },
294
- },
295
- query: {},
296
- };
297
- const mutators = createMutators();
298
- await mutators.draft.deleteAttachment(transaction, {
299
- attachmentId: 'test-attachment-id-1',
300
- id: 'test-draft-id-1',
301
- updatedAt: 4_000,
302
- });
303
- expect(draftAttachmentDelete).toHaveBeenCalledWith({
304
- id: 'test-attachment-id-1',
305
- });
306
- expect(draftUpdate).toHaveBeenCalledWith({
307
- id: 'test-draft-id-1',
308
- updatedAt: 4_000,
309
- });
310
- });
311
- });
312
- describe('deleteDraft', () => {
313
- it('deletes a draft', async () => {
314
- const draftDelete = mock(async () => { });
315
- const transaction = {
316
- mutate: {
317
- draft: {
318
- delete: draftDelete,
319
- insert: mock(async () => { }),
320
- update: mock(async () => { }),
321
- },
322
- },
323
- query: {},
324
- };
325
- const mutators = createMutators();
326
- await mutators.draft.deleteDraft(transaction, {
327
- id: 'test-draft-id-1',
328
- });
329
- expect(draftDelete).toHaveBeenCalledWith({
330
- id: 'test-draft-id-1',
331
- });
332
- });
333
- });
334
- describe('setEnvelope', () => {
335
- it('sets draft envelope', async () => {
336
- const draftRecord = {
337
- body: {
338
- content: 'Existing content',
339
- },
340
- id: 'test-draft-id-1',
341
- };
342
- const run = mock(async () => draftRecord);
343
- const one = mock(() => ({ run }));
344
- const where = mock(() => ({ one }));
345
- const draftUpdate = mock(async () => { });
346
- const transaction = {
347
- mutate: {
348
- draft: {
349
- delete: mock(async () => { }),
350
- insert: mock(async () => { }),
351
- update: draftUpdate,
352
- },
353
- },
354
- query: {
355
- draft: {
356
- where,
357
- },
358
- },
359
- };
360
- const mutators = createMutators();
361
- await mutators.draft.setEnvelope(transaction, {
362
- envelope: {
363
- bcc: ['bcc@example.com'],
364
- cc: ['cc@example.com'],
365
- subject: 'Updated Subject',
366
- to: ['to@example.com'],
367
- },
368
- id: 'test-draft-id-1',
369
- updatedAt: 6_000,
370
- });
371
- expect(draftUpdate).toHaveBeenCalledWith({
372
- body: {
373
- bcc: ['bcc@example.com'],
374
- cc: ['cc@example.com'],
375
- content: 'Existing content',
376
- to: ['to@example.com'],
377
- },
378
- id: 'test-draft-id-1',
379
- subject: 'Updated Subject',
380
- updatedAt: 6_000,
381
- });
382
- });
383
- });
384
- describe('setFrom', () => {
385
- it('sets draft from address', async () => {
386
- const draftUpdate = mock(async () => { });
387
- const transaction = {
388
- mutate: {
389
- draft: {
390
- delete: mock(async () => { }),
391
- insert: mock(async () => { }),
392
- update: draftUpdate,
393
- },
394
- },
395
- query: {},
396
- };
397
- const mutators = createMutators();
398
- await mutators.draft.setFrom(transaction, {
399
- accountId: 'test-account-id-1',
400
- aliasId: 'test-alias-id-1',
401
- from: 'sender@example.com',
402
- fromName: 'Updated Sender',
403
- id: 'test-draft-id-1',
404
- updatedAt: 7_000,
405
- });
406
- expect(draftUpdate).toHaveBeenCalledWith({
407
- accountId: 'test-account-id-1',
408
- fromAliasId: 'test-alias-id-1',
409
- fromEmail: 'sender@example.com',
410
- fromName: 'Updated Sender',
411
- id: 'test-draft-id-1',
412
- updatedAt: 7_000,
413
- });
414
- });
415
- });
416
- });
@@ -1,2 +0,0 @@
1
- export * from './draftMutators';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
@@ -1 +0,0 @@
1
- export * from './draftMutators';
@@ -1,3 +0,0 @@
1
- export type { MarcoZeroMutators } from './mutators';
2
- export { createMutators, ZeroMutatorValidationError } from './mutators';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zero/mutators/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- export { createMutators, ZeroMutatorValidationError } from './mutators';
@@ -1,18 +0,0 @@
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;
18
- //# sourceMappingURL=mutators.d.ts.map
@@ -1 +0,0 @@
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,39 +0,0 @@
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)),
39
- });
@@ -1,2 +0,0 @@
1
- export * from './threadMutators';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/threadMutators/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
@@ -1 +0,0 @@
1
- export * from './threadMutators';
@@ -1,8 +0,0 @@
1
- import type { Transaction } from '@rocicorp/zero';
2
- import type { LabelSpecialUse } from '../../../types';
3
- import { type AuthData, type HandlerMap } from '../../../types';
4
- import type { ZeroMutatorSchemas } from '../../../zero/mutatorSchemas';
5
- import type { MarcoZeroSchema } from '../../../zero/schema';
6
- export declare const setSystemLabel: (tx: Transaction<MarcoZeroSchema>, threadId: string, targetSpecialUse: LabelSpecialUse) => Promise<void>;
7
- export declare const createThreadMutators: (_authData: AuthData | undefined) => HandlerMap<ZeroMutatorSchemas["thread"]>;
8
- //# sourceMappingURL=threadMutators.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"threadMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/threadMutators/threadMutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAiB,MAAM,qBAAqB,CAAA;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE,eAAO,MAAM,cAAc,OACrB,WAAW,CAAC,eAAe,CAAC,YACtB,MAAM,oBACE,eAAe,KAChC,OAAO,CAAC,IAAI,CAyFd,CAAA;AAED,eAAO,MAAM,oBAAoB,cAAe,QAAQ,GAAG,SAAS,KAAG,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CA0O5G,CAAA"}