@marcoappio/marco-config 2.0.504 → 2.0.506

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 (120) hide show
  1. package/dist/schemas/auth.d.ts +1 -1
  2. package/dist/schemas/index.d.ts +2 -2
  3. package/dist/schemas/string.d.ts +1 -1
  4. package/dist/schemas/string.d.ts.map +1 -1
  5. package/dist/schemas/string.js +4 -1
  6. package/dist/sdk/endpoints/index.d.ts +4 -4
  7. package/dist/sdk/endpoints/public/auth/index.d.ts +4 -4
  8. package/dist/sdk/endpoints/public/auth/refreshAuth.d.ts +1 -1
  9. package/dist/sdk/endpoints/public/auth/sendAuthCode.d.ts +1 -1
  10. package/dist/sdk/endpoints/public/auth/verifyAuthCode.d.ts +2 -2
  11. package/dist/sdk/endpoints/public/index.d.ts +4 -4
  12. package/dist/sdk/index.d.ts +4 -4
  13. package/dist/types/AuthData.d.ts +4 -0
  14. package/dist/types/AuthData.d.ts.map +1 -0
  15. package/dist/types/AuthData.js +1 -0
  16. package/dist/types/IMAPSourceLocation.d.ts +7 -0
  17. package/dist/types/IMAPSourceLocation.d.ts.map +1 -0
  18. package/dist/types/IMAPSourceLocation.js +1 -0
  19. package/dist/types/Zero.d.ts +14 -8
  20. package/dist/types/Zero.d.ts.map +1 -1
  21. package/dist/types/index.d.ts +2 -0
  22. package/dist/types/index.d.ts.map +1 -1
  23. package/dist/types/index.js +2 -0
  24. package/dist/zero/index.d.ts +7749 -3113
  25. package/dist/zero/index.d.ts.map +1 -1
  26. package/dist/zero/index.js +14 -5
  27. package/dist/zero/mutatorSchemas/account.d.ts +80 -0
  28. package/dist/zero/mutatorSchemas/account.d.ts.map +1 -0
  29. package/dist/zero/mutatorSchemas/account.js +66 -0
  30. package/dist/zero/mutatorSchemas/draft.d.ts +150 -0
  31. package/dist/zero/mutatorSchemas/draft.d.ts.map +1 -0
  32. package/dist/zero/mutatorSchemas/draft.js +104 -0
  33. package/dist/zero/mutatorSchemas/index.d.ts +323 -0
  34. package/dist/zero/mutatorSchemas/index.d.ts.map +1 -0
  35. package/dist/zero/mutatorSchemas/index.js +10 -0
  36. package/dist/zero/mutatorSchemas/thread.d.ts +71 -0
  37. package/dist/zero/mutatorSchemas/thread.d.ts.map +1 -0
  38. package/dist/zero/mutatorSchemas/thread.js +47 -0
  39. package/dist/zero/mutatorSchemas/user.d.ts +26 -0
  40. package/dist/zero/mutatorSchemas/user.d.ts.map +1 -0
  41. package/dist/zero/mutatorSchemas/user.js +27 -0
  42. package/dist/zero/mutators/accountMutators/accountMutators.d.ts +3 -188
  43. package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +1 -1
  44. package/dist/zero/mutators/accountMutators/accountMutators.js +82 -118
  45. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts +2 -0
  46. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts.map +1 -0
  47. package/dist/zero/mutators/accountMutators/accountMutators.test.js +372 -0
  48. package/dist/zero/mutators/accountMutators/index.d.ts +1 -1
  49. package/dist/zero/mutators/accountMutators/index.d.ts.map +1 -1
  50. package/dist/zero/mutators/accountMutators/index.js +1 -1
  51. package/dist/zero/mutators/draftMutators/draftMutators.d.ts +3 -305
  52. package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +1 -1
  53. package/dist/zero/mutators/draftMutators/draftMutators.js +83 -157
  54. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts +2 -0
  55. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts.map +1 -0
  56. package/dist/zero/mutators/draftMutators/draftMutators.test.js +416 -0
  57. package/dist/zero/mutators/draftMutators/index.d.ts +1 -1
  58. package/dist/zero/mutators/draftMutators/index.d.ts.map +1 -1
  59. package/dist/zero/mutators/draftMutators/index.js +1 -1
  60. package/dist/zero/mutators/index.d.ts +1 -251
  61. package/dist/zero/mutators/index.d.ts.map +1 -1
  62. package/dist/zero/mutators/index.js +1 -11
  63. package/dist/zero/mutators/mutators.d.ts +17 -1519
  64. package/dist/zero/mutators/mutators.d.ts.map +1 -1
  65. package/dist/zero/mutators/mutators.js +38 -11
  66. package/dist/zero/mutators/threadMutators/index.d.ts +1 -1
  67. package/dist/zero/mutators/threadMutators/index.d.ts.map +1 -1
  68. package/dist/zero/mutators/threadMutators/index.js +1 -1
  69. package/dist/zero/mutators/threadMutators/threadMutators.d.ts +6 -199
  70. package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +1 -1
  71. package/dist/zero/mutators/threadMutators/threadMutators.js +87 -119
  72. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts +2 -0
  73. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts.map +1 -0
  74. package/dist/zero/mutators/threadMutators/threadMutators.test.js +755 -0
  75. package/dist/zero/mutators/userMutators/index.d.ts +1 -1
  76. package/dist/zero/mutators/userMutators/index.d.ts.map +1 -1
  77. package/dist/zero/mutators/userMutators/index.js +1 -1
  78. package/dist/zero/mutators/userMutators/userMutators.d.ts +3 -56
  79. package/dist/zero/mutators/userMutators/userMutators.d.ts.map +1 -1
  80. package/dist/zero/mutators/userMutators/userMutators.js +26 -40
  81. package/dist/zero/mutators/userMutators/userMutators.test.d.ts +2 -0
  82. package/dist/zero/mutators/userMutators/userMutators.test.d.ts.map +1 -0
  83. package/dist/zero/mutators/userMutators/userMutators.test.js +84 -0
  84. package/dist/zero/queries/getAccounts.d.ts +1025 -4
  85. package/dist/zero/queries/getAccounts.d.ts.map +1 -1
  86. package/dist/zero/queries/getAccounts.js +3 -6
  87. package/dist/zero/queries/getContacts.d.ts +1033 -18
  88. package/dist/zero/queries/getContacts.d.ts.map +1 -1
  89. package/dist/zero/queries/getContacts.js +15 -11
  90. package/dist/zero/queries/getDrafts.d.ts +1031 -11
  91. package/dist/zero/queries/getDrafts.d.ts.map +1 -1
  92. package/dist/zero/queries/getDrafts.js +11 -7
  93. package/dist/zero/queries/getThread.d.ts +1028 -7
  94. package/dist/zero/queries/getThread.d.ts.map +1 -1
  95. package/dist/zero/queries/getThread.js +9 -5
  96. package/dist/zero/queries/getThreadList.d.ts +1035 -23
  97. package/dist/zero/queries/getThreadList.d.ts.map +1 -1
  98. package/dist/zero/queries/getThreadList.js +18 -14
  99. package/dist/zero/queries/getThreads.d.ts +1035 -23
  100. package/dist/zero/queries/getThreads.d.ts.map +1 -1
  101. package/dist/zero/queries/getThreads.js +18 -14
  102. package/dist/zero/queries/getUser.d.ts +1025 -4
  103. package/dist/zero/queries/getUser.d.ts.map +1 -1
  104. package/dist/zero/queries/getUser.js +7 -10
  105. package/dist/zero/queries/index.d.ts +141 -460
  106. package/dist/zero/queries/index.d.ts.map +1 -1
  107. package/dist/zero/queries/index.js +10 -18
  108. package/dist/zero/schema.d.ts +133 -133
  109. package/dist/zero/schema.d.ts.map +1 -1
  110. package/dist/zero/schema.js +1 -0
  111. package/package.json +3 -2
  112. package/dist/zero/crud.d.ts +0 -1024
  113. package/dist/zero/crud.d.ts.map +0 -1
  114. package/dist/zero/crud.js +0 -3
  115. package/dist/zero/mutators/typedMutator.d.ts +0 -2056
  116. package/dist/zero/mutators/typedMutator.d.ts.map +0 -1
  117. package/dist/zero/mutators/typedMutator.js +0 -2
  118. package/dist/zero/queries/z.d.ts +0 -14439
  119. package/dist/zero/queries/z.d.ts.map +0 -1
  120. package/dist/zero/queries/z.js +0 -3
@@ -0,0 +1,416 @@
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 +1,2 @@
1
- export { draftMutatorSchemas, draftMutators } from './draftMutators';
1
+ export * from './draftMutators';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
@@ -1 +1 @@
1
- export { draftMutatorSchemas, draftMutators } from './draftMutators';
1
+ export * from './draftMutators';