@marcoappio/marco-config 2.0.426 → 2.0.428

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 (97) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/types/AuthData.d.ts +4 -0
  5. package/dist/types/AuthData.d.ts.map +1 -0
  6. package/dist/types/AuthData.js +1 -0
  7. package/dist/types/Zero.d.ts +18 -0
  8. package/dist/types/Zero.d.ts.map +1 -1
  9. package/dist/types/Zero.js +5 -1
  10. package/dist/types/index.d.ts +1 -0
  11. package/dist/types/index.d.ts.map +1 -1
  12. package/dist/types/index.js +1 -0
  13. package/dist/zero/index.d.ts +176 -257
  14. package/dist/zero/index.d.ts.map +1 -1
  15. package/dist/zero/index.js +0 -7
  16. package/dist/zero/{mutators → mutatorSchemas}/account.d.ts +4 -33
  17. package/dist/zero/mutatorSchemas/account.d.ts.map +1 -0
  18. package/dist/zero/{mutators → mutatorSchemas}/account.js +4 -7
  19. package/dist/zero/{mutators → mutatorSchemas}/draft.d.ts +1 -1
  20. package/dist/zero/{mutators → mutatorSchemas}/draft.d.ts.map +1 -1
  21. package/dist/zero/{mutators → mutatorSchemas}/draft.js +1 -1
  22. package/dist/zero/mutatorSchemas/index.d.ts +5 -0
  23. package/dist/zero/mutatorSchemas/index.d.ts.map +1 -0
  24. package/dist/zero/mutatorSchemas/index.js +4 -0
  25. package/dist/zero/{mutators → mutatorSchemas}/thread.d.ts +13 -26
  26. package/dist/zero/mutatorSchemas/thread.d.ts.map +1 -0
  27. package/dist/zero/{mutators → mutatorSchemas}/thread.js +13 -24
  28. package/dist/zero/{mutators → mutatorSchemas}/user.d.ts +1 -7
  29. package/dist/zero/mutatorSchemas/user.d.ts.map +1 -0
  30. package/dist/zero/{mutators → mutatorSchemas}/user.js +1 -7
  31. package/dist/zero/mutators/accountMutators/accountMutators.d.ts +8 -0
  32. package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +1 -0
  33. package/dist/zero/mutators/accountMutators/accountMutators.js +112 -0
  34. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts +2 -0
  35. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts.map +1 -0
  36. package/dist/zero/mutators/accountMutators/accountMutators.test.js +390 -0
  37. package/dist/zero/mutators/accountMutators/index.d.ts +2 -0
  38. package/dist/zero/mutators/accountMutators/index.d.ts.map +1 -0
  39. package/dist/zero/mutators/accountMutators/index.js +1 -0
  40. package/dist/zero/mutators/draftMutators/draftMutators.d.ts +8 -0
  41. package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +1 -0
  42. package/dist/zero/mutators/draftMutators/draftMutators.js +162 -0
  43. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts +2 -0
  44. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts.map +1 -0
  45. package/dist/zero/mutators/draftMutators/draftMutators.test.js +390 -0
  46. package/dist/zero/mutators/draftMutators/index.d.ts +2 -0
  47. package/dist/zero/mutators/draftMutators/index.d.ts.map +1 -0
  48. package/dist/zero/mutators/draftMutators/index.js +1 -0
  49. package/dist/zero/mutators/index.d.ts +6566 -0
  50. package/dist/zero/mutators/index.d.ts.map +1 -0
  51. package/dist/zero/mutators/index.js +17 -0
  52. package/dist/zero/mutators/mutators.d.ts +29 -0
  53. package/dist/zero/mutators/mutators.d.ts.map +1 -0
  54. package/dist/zero/{mutators.js → mutators/mutators.js} +10 -15
  55. package/dist/zero/mutators/threadMutators/index.d.ts +2 -0
  56. package/dist/zero/mutators/threadMutators/index.d.ts.map +1 -0
  57. package/dist/zero/mutators/threadMutators/index.js +1 -0
  58. package/dist/zero/mutators/threadMutators/threadMutators.d.ts +8 -0
  59. package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +1 -0
  60. package/dist/zero/mutators/threadMutators/threadMutators.js +238 -0
  61. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts +2 -0
  62. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts.map +1 -0
  63. package/dist/zero/mutators/threadMutators/threadMutators.test.js +465 -0
  64. package/dist/zero/mutators/userMutators/index.d.ts +2 -0
  65. package/dist/zero/mutators/userMutators/index.d.ts.map +1 -0
  66. package/dist/zero/mutators/userMutators/index.js +1 -0
  67. package/dist/zero/mutators/userMutators/userMutators.d.ts +8 -0
  68. package/dist/zero/mutators/userMutators/userMutators.d.ts.map +1 -0
  69. package/dist/zero/mutators/userMutators/userMutators.js +37 -0
  70. package/dist/zero/mutators/userMutators/userMutators.test.d.ts +2 -0
  71. package/dist/zero/mutators/userMutators/userMutators.test.d.ts.map +1 -0
  72. package/dist/zero/mutators/userMutators/userMutators.test.js +123 -0
  73. package/dist/zero/queries/getAccounts.d.ts +29 -40
  74. package/dist/zero/queries/getAccounts.d.ts.map +1 -1
  75. package/dist/zero/queries/getContacts.d.ts +29 -40
  76. package/dist/zero/queries/getContacts.d.ts.map +1 -1
  77. package/dist/zero/queries/getDrafts.d.ts +29 -40
  78. package/dist/zero/queries/getDrafts.d.ts.map +1 -1
  79. package/dist/zero/queries/getThreads.d.ts +29 -47
  80. package/dist/zero/queries/getThreads.d.ts.map +1 -1
  81. package/dist/zero/queries/getThreads.js +1 -1
  82. package/dist/zero/queries/getUser.d.ts +29 -40
  83. package/dist/zero/queries/getUser.d.ts.map +1 -1
  84. package/dist/zero/queries/index.d.ts +29 -40
  85. package/dist/zero/queries/index.d.ts.map +1 -1
  86. package/dist/zero/schema.d.ts +29 -40
  87. package/dist/zero/schema.d.ts.map +1 -1
  88. package/dist/zero/schema.js +0 -9
  89. package/package.json +1 -1
  90. package/dist/zero/mutators/account.d.ts.map +0 -1
  91. package/dist/zero/mutators/thread.d.ts.map +0 -1
  92. package/dist/zero/mutators/user.d.ts.map +0 -1
  93. package/dist/zero/mutators.d.ts +0 -412
  94. package/dist/zero/mutators.d.ts.map +0 -1
  95. package/dist/zero/mutators.test.d.ts +0 -2
  96. package/dist/zero/mutators.test.d.ts.map +0 -1
  97. package/dist/zero/mutators.test.js +0 -33
@@ -0,0 +1,390 @@
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 draftUpdate = mock(async () => { });
81
+ const transaction = {
82
+ mutate: {
83
+ draft: {
84
+ delete: mock(async () => { }),
85
+ insert: mock(async () => { }),
86
+ update: draftUpdate,
87
+ },
88
+ },
89
+ query: {},
90
+ };
91
+ const mutators = createMutators();
92
+ await mutators.draft.cancelSend(transaction, {
93
+ id: 'test-draft-id-1',
94
+ updatedAt: 5_000,
95
+ });
96
+ expect(draftUpdate).toHaveBeenCalledWith({
97
+ id: 'test-draft-id-1',
98
+ scheduledFor: null,
99
+ status: 'DRAFT',
100
+ updatedAt: 5_000,
101
+ });
102
+ });
103
+ });
104
+ describe('createAttachment', () => {
105
+ it('creates draft attachment', async () => {
106
+ const draftAttachmentInsert = mock(async () => { });
107
+ const draftUpdate = mock(async () => { });
108
+ const transaction = {
109
+ mutate: {
110
+ draft: {
111
+ delete: mock(async () => { }),
112
+ insert: mock(async () => { }),
113
+ update: draftUpdate,
114
+ },
115
+ draftAttachment: {
116
+ delete: mock(async () => { }),
117
+ insert: draftAttachmentInsert,
118
+ update: mock(async () => { }),
119
+ },
120
+ },
121
+ query: {},
122
+ };
123
+ const mutators = createMutators();
124
+ await mutators.draft.createAttachment(transaction, {
125
+ attachment: {
126
+ failed: false,
127
+ fileName: 'test-document.pdf',
128
+ id: 'test-attachment-id-1',
129
+ mimeType: 'application/pdf',
130
+ totalChunks: 5,
131
+ totalSize: 1024000,
132
+ uploadedChunks: 0,
133
+ },
134
+ id: 'test-draft-id-1',
135
+ updatedAt: 3_000,
136
+ });
137
+ expect(draftAttachmentInsert).toHaveBeenCalledWith({
138
+ draftId: 'test-draft-id-1',
139
+ failed: false,
140
+ fileName: 'test-document.pdf',
141
+ id: 'test-attachment-id-1',
142
+ mimeType: 'application/pdf',
143
+ totalChunks: 5,
144
+ totalSize: 1024000,
145
+ uploadedChunks: 0,
146
+ });
147
+ expect(draftUpdate).toHaveBeenCalledWith({
148
+ id: 'test-draft-id-1',
149
+ updatedAt: 3_000,
150
+ });
151
+ });
152
+ });
153
+ describe('createDraft', () => {
154
+ it('creates a draft', async () => {
155
+ const draftInsert = mock(async () => { });
156
+ const transaction = {
157
+ mutate: {
158
+ draft: {
159
+ delete: mock(async () => { }),
160
+ insert: draftInsert,
161
+ update: mock(async () => { }),
162
+ },
163
+ draftAttachment: {
164
+ delete: mock(async () => { }),
165
+ insert: mock(async () => { }),
166
+ update: mock(async () => { }),
167
+ },
168
+ },
169
+ query: {},
170
+ };
171
+ const mutators = createMutators({ sub: 'test-user-id' });
172
+ await mutators.draft.createDraft(transaction, {
173
+ attachments: [],
174
+ body: {
175
+ bcc: [],
176
+ cc: [],
177
+ content: 'Draft content',
178
+ subject: 'Test Subject',
179
+ to: ['recipient@example.com'],
180
+ },
181
+ emailAccountId: 'test-account-id-1',
182
+ error: null,
183
+ from: 'sender@example.com',
184
+ fromName: 'Test Sender',
185
+ id: 'test-draft-id-2',
186
+ referencedMessageId: null,
187
+ scheduledFor: null,
188
+ status: 'DRAFT',
189
+ type: 'NEW',
190
+ updatedAt: 1_000,
191
+ });
192
+ expect(draftInsert).toHaveBeenCalledWith({
193
+ accountId: 'test-account-id-1',
194
+ body: {
195
+ bcc: [],
196
+ cc: [],
197
+ content: 'Draft content',
198
+ to: ['recipient@example.com'],
199
+ },
200
+ error: null,
201
+ fromAliasId: null,
202
+ fromEmail: 'sender@example.com',
203
+ fromName: 'Test Sender',
204
+ id: 'test-draft-id-2',
205
+ referencedMessageId: null,
206
+ scheduledFor: null,
207
+ status: 'DRAFT',
208
+ subject: 'Test Subject',
209
+ type: 'NEW',
210
+ updatedAt: 1_000,
211
+ userId: 'test-user-id',
212
+ });
213
+ });
214
+ });
215
+ describe('deleteAttachment', () => {
216
+ it('deletes draft attachment', async () => {
217
+ const draftAttachmentDelete = mock(async () => { });
218
+ const draftUpdate = mock(async () => { });
219
+ const transaction = {
220
+ mutate: {
221
+ draft: {
222
+ delete: mock(async () => { }),
223
+ insert: mock(async () => { }),
224
+ update: draftUpdate,
225
+ },
226
+ draftAttachment: {
227
+ delete: draftAttachmentDelete,
228
+ insert: mock(async () => { }),
229
+ update: mock(async () => { }),
230
+ },
231
+ },
232
+ query: {},
233
+ };
234
+ const mutators = createMutators();
235
+ await mutators.draft.deleteAttachment(transaction, {
236
+ attachmentId: 'test-attachment-id-1',
237
+ id: 'test-draft-id-1',
238
+ updatedAt: 4_000,
239
+ });
240
+ expect(draftAttachmentDelete).toHaveBeenCalledWith({
241
+ id: 'test-attachment-id-1',
242
+ });
243
+ expect(draftUpdate).toHaveBeenCalledWith({
244
+ id: 'test-draft-id-1',
245
+ updatedAt: 4_000,
246
+ });
247
+ });
248
+ });
249
+ describe('deleteDraft', () => {
250
+ it('deletes a draft', async () => {
251
+ const draftDelete = mock(async () => { });
252
+ const transaction = {
253
+ mutate: {
254
+ draft: {
255
+ delete: draftDelete,
256
+ insert: mock(async () => { }),
257
+ update: mock(async () => { }),
258
+ },
259
+ },
260
+ query: {},
261
+ };
262
+ const mutators = createMutators();
263
+ await mutators.draft.deleteDraft(transaction, {
264
+ id: 'test-draft-id-1',
265
+ });
266
+ expect(draftDelete).toHaveBeenCalledWith({
267
+ id: 'test-draft-id-1',
268
+ });
269
+ });
270
+ });
271
+ describe('setEnvelope', () => {
272
+ it('sets draft envelope', async () => {
273
+ const draftRecord = {
274
+ body: {
275
+ content: 'Existing content',
276
+ },
277
+ id: 'test-draft-id-1',
278
+ };
279
+ const run = mock(async () => draftRecord);
280
+ const one = mock(() => ({ run }));
281
+ const where = mock(() => ({ one }));
282
+ const draftUpdate = mock(async () => { });
283
+ const transaction = {
284
+ mutate: {
285
+ draft: {
286
+ delete: mock(async () => { }),
287
+ insert: mock(async () => { }),
288
+ update: draftUpdate,
289
+ },
290
+ },
291
+ query: {
292
+ draft: {
293
+ where,
294
+ },
295
+ },
296
+ };
297
+ const mutators = createMutators();
298
+ await mutators.draft.setEnvelope(transaction, {
299
+ envelope: {
300
+ bcc: ['bcc@example.com'],
301
+ cc: ['cc@example.com'],
302
+ subject: 'Updated Subject',
303
+ to: ['to@example.com'],
304
+ },
305
+ id: 'test-draft-id-1',
306
+ updatedAt: 6_000,
307
+ });
308
+ expect(draftUpdate).toHaveBeenCalledWith({
309
+ body: {
310
+ bcc: ['bcc@example.com'],
311
+ cc: ['cc@example.com'],
312
+ content: 'Existing content',
313
+ to: ['to@example.com'],
314
+ },
315
+ id: 'test-draft-id-1',
316
+ subject: 'Updated Subject',
317
+ updatedAt: 6_000,
318
+ });
319
+ });
320
+ });
321
+ describe('setFrom', () => {
322
+ it('sets draft from address', async () => {
323
+ const draftUpdate = mock(async () => { });
324
+ const transaction = {
325
+ mutate: {
326
+ draft: {
327
+ delete: mock(async () => { }),
328
+ insert: mock(async () => { }),
329
+ update: draftUpdate,
330
+ },
331
+ },
332
+ query: {},
333
+ };
334
+ const mutators = createMutators();
335
+ await mutators.draft.setFrom(transaction, {
336
+ aliasId: 'test-alias-id-1',
337
+ emailAccountId: 'test-account-id-1',
338
+ from: 'sender@example.com',
339
+ fromName: 'Updated Sender',
340
+ id: 'test-draft-id-1',
341
+ updatedAt: 7_000,
342
+ });
343
+ expect(draftUpdate).toHaveBeenCalledWith({
344
+ accountId: 'test-account-id-1',
345
+ fromAliasId: 'test-alias-id-1',
346
+ fromEmail: 'sender@example.com',
347
+ fromName: 'Updated Sender',
348
+ id: 'test-draft-id-1',
349
+ updatedAt: 7_000,
350
+ });
351
+ });
352
+ });
353
+ describe('uploadAttachmentChunk', () => {
354
+ it('uploads attachment chunk', async () => {
355
+ const attachmentRecord = {
356
+ id: 'test-attachment-id-1',
357
+ uploadedChunks: 2,
358
+ };
359
+ const run = mock(async () => attachmentRecord);
360
+ const one = mock(() => ({ run }));
361
+ const where = mock(() => ({ one }));
362
+ const draftAttachmentUpdate = mock(async () => { });
363
+ const transaction = {
364
+ mutate: {
365
+ draftAttachment: {
366
+ delete: mock(async () => { }),
367
+ insert: mock(async () => { }),
368
+ update: draftAttachmentUpdate,
369
+ },
370
+ },
371
+ query: {
372
+ draftAttachment: {
373
+ where,
374
+ },
375
+ },
376
+ };
377
+ const mutators = createMutators();
378
+ await mutators.draft.uploadAttachmentChunk(transaction, {
379
+ attachmentId: 'test-attachment-id-1',
380
+ chunk: 'dGVzdC1jaHVuaw==',
381
+ chunkIndex: 3,
382
+ id: 'test-draft-id-1',
383
+ });
384
+ expect(draftAttachmentUpdate).toHaveBeenCalledWith({
385
+ id: 'test-attachment-id-1',
386
+ uploadedChunks: 4,
387
+ });
388
+ });
389
+ });
390
+ });
@@ -0,0 +1,2 @@
1
+ export * from './draftMutators';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ export * from './draftMutators';