@marcoappio/marco-config 2.0.503 → 2.0.505

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 (108) hide show
  1. package/dist/types/AuthData.d.ts +4 -0
  2. package/dist/types/AuthData.d.ts.map +1 -0
  3. package/dist/types/AuthData.js +1 -0
  4. package/dist/types/IMAPSourceLocation.d.ts +7 -0
  5. package/dist/types/IMAPSourceLocation.d.ts.map +1 -0
  6. package/dist/types/IMAPSourceLocation.js +1 -0
  7. package/dist/types/Zero.d.ts +14 -8
  8. package/dist/types/Zero.d.ts.map +1 -1
  9. package/dist/types/index.d.ts +2 -0
  10. package/dist/types/index.d.ts.map +1 -1
  11. package/dist/types/index.js +2 -0
  12. package/dist/zero/index.d.ts +7745 -3109
  13. package/dist/zero/index.d.ts.map +1 -1
  14. package/dist/zero/index.js +14 -5
  15. package/dist/zero/mutatorSchemas/account.d.ts +80 -0
  16. package/dist/zero/mutatorSchemas/account.d.ts.map +1 -0
  17. package/dist/zero/mutatorSchemas/account.js +66 -0
  18. package/dist/zero/mutatorSchemas/draft.d.ts +150 -0
  19. package/dist/zero/mutatorSchemas/draft.d.ts.map +1 -0
  20. package/dist/zero/mutatorSchemas/draft.js +104 -0
  21. package/dist/zero/mutatorSchemas/index.d.ts +323 -0
  22. package/dist/zero/mutatorSchemas/index.d.ts.map +1 -0
  23. package/dist/zero/mutatorSchemas/index.js +10 -0
  24. package/dist/zero/mutatorSchemas/thread.d.ts +71 -0
  25. package/dist/zero/mutatorSchemas/thread.d.ts.map +1 -0
  26. package/dist/zero/mutatorSchemas/thread.js +47 -0
  27. package/dist/zero/mutatorSchemas/user.d.ts +26 -0
  28. package/dist/zero/mutatorSchemas/user.d.ts.map +1 -0
  29. package/dist/zero/mutatorSchemas/user.js +27 -0
  30. package/dist/zero/mutators/accountMutators/accountMutators.d.ts +3 -188
  31. package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +1 -1
  32. package/dist/zero/mutators/accountMutators/accountMutators.js +82 -117
  33. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts +2 -0
  34. package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts.map +1 -0
  35. package/dist/zero/mutators/accountMutators/accountMutators.test.js +372 -0
  36. package/dist/zero/mutators/accountMutators/index.d.ts +1 -1
  37. package/dist/zero/mutators/accountMutators/index.d.ts.map +1 -1
  38. package/dist/zero/mutators/accountMutators/index.js +1 -1
  39. package/dist/zero/mutators/draftMutators/draftMutators.d.ts +3 -305
  40. package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +1 -1
  41. package/dist/zero/mutators/draftMutators/draftMutators.js +83 -156
  42. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts +2 -0
  43. package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts.map +1 -0
  44. package/dist/zero/mutators/draftMutators/draftMutators.test.js +416 -0
  45. package/dist/zero/mutators/draftMutators/index.d.ts +1 -1
  46. package/dist/zero/mutators/draftMutators/index.d.ts.map +1 -1
  47. package/dist/zero/mutators/draftMutators/index.js +1 -1
  48. package/dist/zero/mutators/index.d.ts +1 -251
  49. package/dist/zero/mutators/index.d.ts.map +1 -1
  50. package/dist/zero/mutators/index.js +1 -11
  51. package/dist/zero/mutators/mutators.d.ts +17 -1519
  52. package/dist/zero/mutators/mutators.d.ts.map +1 -1
  53. package/dist/zero/mutators/mutators.js +38 -11
  54. package/dist/zero/mutators/threadMutators/index.d.ts +1 -1
  55. package/dist/zero/mutators/threadMutators/index.d.ts.map +1 -1
  56. package/dist/zero/mutators/threadMutators/index.js +1 -1
  57. package/dist/zero/mutators/threadMutators/threadMutators.d.ts +6 -199
  58. package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +1 -1
  59. package/dist/zero/mutators/threadMutators/threadMutators.js +87 -118
  60. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts +2 -0
  61. package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts.map +1 -0
  62. package/dist/zero/mutators/threadMutators/threadMutators.test.js +755 -0
  63. package/dist/zero/mutators/userMutators/index.d.ts +1 -1
  64. package/dist/zero/mutators/userMutators/index.d.ts.map +1 -1
  65. package/dist/zero/mutators/userMutators/index.js +1 -1
  66. package/dist/zero/mutators/userMutators/userMutators.d.ts +3 -56
  67. package/dist/zero/mutators/userMutators/userMutators.d.ts.map +1 -1
  68. package/dist/zero/mutators/userMutators/userMutators.js +26 -39
  69. package/dist/zero/mutators/userMutators/userMutators.test.d.ts +2 -0
  70. package/dist/zero/mutators/userMutators/userMutators.test.d.ts.map +1 -0
  71. package/dist/zero/mutators/userMutators/userMutators.test.js +84 -0
  72. package/dist/zero/queries/getAccounts.d.ts +1025 -4
  73. package/dist/zero/queries/getAccounts.d.ts.map +1 -1
  74. package/dist/zero/queries/getAccounts.js +3 -3
  75. package/dist/zero/queries/getContacts.d.ts +1033 -18
  76. package/dist/zero/queries/getContacts.d.ts.map +1 -1
  77. package/dist/zero/queries/getContacts.js +15 -11
  78. package/dist/zero/queries/getDrafts.d.ts +1031 -11
  79. package/dist/zero/queries/getDrafts.d.ts.map +1 -1
  80. package/dist/zero/queries/getDrafts.js +11 -7
  81. package/dist/zero/queries/getThread.d.ts +1028 -7
  82. package/dist/zero/queries/getThread.d.ts.map +1 -1
  83. package/dist/zero/queries/getThread.js +9 -5
  84. package/dist/zero/queries/getThreadList.d.ts +1035 -23
  85. package/dist/zero/queries/getThreadList.d.ts.map +1 -1
  86. package/dist/zero/queries/getThreadList.js +18 -14
  87. package/dist/zero/queries/getThreads.d.ts +1035 -23
  88. package/dist/zero/queries/getThreads.d.ts.map +1 -1
  89. package/dist/zero/queries/getThreads.js +18 -14
  90. package/dist/zero/queries/getUser.d.ts +1025 -4
  91. package/dist/zero/queries/getUser.d.ts.map +1 -1
  92. package/dist/zero/queries/getUser.js +3 -3
  93. package/dist/zero/queries/index.d.ts +141 -460
  94. package/dist/zero/queries/index.d.ts.map +1 -1
  95. package/dist/zero/queries/index.js +10 -18
  96. package/dist/zero/schema.d.ts +133 -133
  97. package/dist/zero/schema.d.ts.map +1 -1
  98. package/dist/zero/schema.js +1 -0
  99. package/package.json +2 -2
  100. package/dist/zero/crud.d.ts +0 -1024
  101. package/dist/zero/crud.d.ts.map +0 -1
  102. package/dist/zero/crud.js +0 -3
  103. package/dist/zero/mutators/typedMutator.d.ts +0 -2056
  104. package/dist/zero/mutators/typedMutator.d.ts.map +0 -1
  105. package/dist/zero/mutators/typedMutator.js +0 -2
  106. package/dist/zero/queries/z.d.ts +0 -1024
  107. package/dist/zero/queries/z.d.ts.map +0 -1
  108. package/dist/zero/queries/z.js +0 -3
@@ -1,45 +1,14 @@
1
- import * as v from 'valibot';
2
- import { marcoSchemas } from '../../../schemas';
3
1
  import { MutationError } from '../../../types';
4
2
  import { threadsUtils } from '../../../utils/threads';
5
- import { zeroCRUD } from '../../../zero/crud';
6
- import { defineMutator } from '../../../zero/mutators/typedMutator';
7
3
  const buildLabelIdList = (x) => (x.length === 0 ? '' : ` ${[...new Set(x)].join(' ')} `);
8
- const accountsSchema = v.record(marcoSchemas.string.required(), v.object({
9
- threadIds: v.array(marcoSchemas.string.required()),
10
- }));
11
- const baseThreadSchema = v.object({
12
- accounts: accountsSchema,
13
- });
14
- const threadChangeLabelSchema = v.object({
15
- accounts: accountsSchema,
16
- labelPath: marcoSchemas.string.required(),
17
- });
18
- export const threadMutatorSchemas = {
19
- addLabel: threadChangeLabelSchema,
20
- delete: baseThreadSchema,
21
- removeLabel: threadChangeLabelSchema,
22
- setArchive: baseThreadSchema,
23
- setFlagged: v.object({
24
- accounts: accountsSchema,
25
- flagged: v.nonOptional(v.boolean()),
26
- }),
27
- setInbox: baseThreadSchema,
28
- setSeen: v.object({
29
- accounts: accountsSchema,
30
- seen: v.boolean(),
31
- }),
32
- setSpam: baseThreadSchema,
33
- setTrash: baseThreadSchema,
34
- };
35
4
  export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
36
- const thread = await tx.run(tx.query.thread.where('id', threadId).one());
5
+ const thread = await tx.query.thread.where('id', threadId).one().run();
37
6
  if (!thread) {
38
7
  throw new Error(MutationError.ENTITY_NOT_FOUND);
39
8
  }
40
9
  const [targetLabel, messages] = await Promise.all([
41
- tx.run(tx.query.accountLabel.where('accountId', thread.accountId).where('specialUse', targetSpecialUse).one()),
42
- tx.run(tx.query.threadMessage.where('threadId', threadId)),
10
+ tx.query.accountLabel.where('accountId', thread.accountId).where('specialUse', targetSpecialUse).one().run(),
11
+ tx.query.threadMessage.where('threadId', threadId).run(),
43
12
  ]);
44
13
  if (!targetLabel) {
45
14
  throw new Error(MutationError.ENTITY_NOT_FOUND);
@@ -51,28 +20,28 @@ export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
51
20
  const threadLabelDeletes = [];
52
21
  for (const message of messages) {
53
22
  for (const labelId of labelIdsToRemove) {
54
- threadLabelDeletes.push(tx.mutate(zeroCRUD.threadLabel.delete({
23
+ threadLabelDeletes.push(tx.mutate.threadLabel.delete({
55
24
  accountId: thread.accountId,
56
25
  labelId,
57
26
  threadMessageId: message.id,
58
- })));
27
+ }));
59
28
  }
60
29
  }
61
30
  await Promise.all([
62
31
  ...threadLabelDeletes,
63
- ...[...labelIdsToRemove].map(labelId => tx.mutate(zeroCRUD.threadByLabel.delete({ labelId, threadId }))),
32
+ ...[...labelIdsToRemove].map(labelId => tx.mutate.threadByLabel.delete({ labelId, threadId })),
64
33
  ]);
65
34
  if (thread.seen === false && labelIdsToRemove.size > 0) {
66
- const labelsToUpdate = await tx.run(tx.query.accountLabel.where('id', 'IN', [...labelIdsToRemove]));
67
- await Promise.all(labelsToUpdate.map(label => tx.mutate(zeroCRUD.accountLabel.update({
35
+ const labelsToUpdate = await tx.query.accountLabel.where('id', 'IN', [...labelIdsToRemove]).run();
36
+ await Promise.all(labelsToUpdate.map(label => tx.mutate.accountLabel.update({
68
37
  id: label.id,
69
38
  unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
70
- }))));
39
+ })));
71
40
  }
72
41
  if (!hasTarget) {
73
42
  const baseTimestamp = Date.now();
74
43
  await Promise.all([
75
- ...messages.map((message, i) => tx.mutate(zeroCRUD.threadLabel.insert({
44
+ ...messages.map((message, i) => tx.mutate.threadLabel.insert({
76
45
  accountId: thread.accountId,
77
46
  labelId: targetLabel.id,
78
47
  lastSyncedAt: 0,
@@ -80,38 +49,38 @@ export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
80
49
  threadMessageId: message.id,
81
50
  uid: -(baseTimestamp + i),
82
51
  uidValidity: targetLabel.uidValidity ?? 0,
83
- }))),
84
- tx.mutate(zeroCRUD.threadByLabel.insert({
52
+ })),
53
+ tx.mutate.threadByLabel.insert({
85
54
  labelId: targetLabel.id,
86
55
  latestMessageDate: thread.latestMessageDate,
87
56
  threadId,
88
- })),
57
+ }),
89
58
  ...(thread.seen === false
90
59
  ? [
91
- tx.mutate(zeroCRUD.accountLabel.update({
60
+ tx.mutate.accountLabel.update({
92
61
  id: targetLabel.id,
93
62
  unreadCount: (targetLabel.unreadCount ?? 0) + 1,
94
- })),
63
+ }),
95
64
  ]
96
65
  : []),
97
66
  ]);
98
67
  }
99
- await tx.mutate(zeroCRUD.thread.update({
68
+ await tx.mutate.thread.update({
100
69
  id: threadId,
101
70
  labelIdList: buildLabelIdList([targetLabel.id]),
102
- }));
71
+ });
103
72
  };
104
- export const threadMutators = {
105
- addLabel: defineMutator(threadMutatorSchemas.addLabel, async ({ tx, args: { accounts, labelPath } }) => {
106
- for (const [accountId, { threadIds }] of Object.entries(accounts)) {
107
- const label = await tx.run(tx.query.accountLabel.where('accountId', accountId).where('path', labelPath).one());
73
+ export const createThreadMutators = (_authData) => ({
74
+ addLabel: async (tx, args) => {
75
+ for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
76
+ const label = await tx.query.accountLabel.where('accountId', accountId).where('path', args.labelPath).one().run();
108
77
  if (!label) {
109
78
  throw new Error(MutationError.ENTITY_NOT_FOUND);
110
79
  }
111
80
  for (const threadId of threadIds) {
112
81
  const [thread, messages] = await Promise.all([
113
- tx.run(tx.query.thread.where('id', threadId).one()),
114
- tx.run(tx.query.threadMessage.where('threadId', threadId)),
82
+ tx.query.thread.where('id', threadId).one().run(),
83
+ tx.query.threadMessage.where('threadId', threadId).run(),
115
84
  ]);
116
85
  if (!thread) {
117
86
  throw new Error(MutationError.ENTITY_NOT_FOUND);
@@ -119,26 +88,26 @@ export const threadMutators = {
119
88
  const currentLabelIds = new Set(threadsUtils.parseLabelIdList(thread.labelIdList));
120
89
  if (!currentLabelIds.has(label.id)) {
121
90
  await Promise.all([
122
- tx.mutate(zeroCRUD.threadByLabel.insert({
91
+ tx.mutate.threadByLabel.insert({
123
92
  labelId: label.id,
124
93
  latestMessageDate: thread.latestMessageDate,
125
94
  threadId,
126
- })),
95
+ }),
127
96
  ...(thread.seen === false
128
97
  ? [
129
- tx.mutate(zeroCRUD.accountLabel.update({
98
+ tx.mutate.accountLabel.update({
130
99
  id: label.id,
131
100
  unreadCount: (label.unreadCount ?? 0) + 1,
132
- })),
101
+ }),
133
102
  ]
134
103
  : []),
135
104
  ]);
136
105
  }
137
- const existingChecks = await Promise.all(messages.map(x => tx.run(tx.query.threadLabel.where('threadMessageId', x.id).where('labelId', label.id).one())));
106
+ const existingChecks = await Promise.all(messages.map(x => tx.query.threadLabel.where('threadMessageId', x.id).where('labelId', label.id).one().run()));
138
107
  const messagesToInsert = messages.filter((_, i) => !existingChecks[i]);
139
108
  const baseTimestamp = Date.now();
140
109
  if (messagesToInsert.length > 0) {
141
- await Promise.all(messagesToInsert.map((x, i) => tx.mutate(zeroCRUD.threadLabel.insert({
110
+ await Promise.all(messagesToInsert.map((x, i) => tx.mutate.threadLabel.insert({
142
111
  accountId,
143
112
  labelId: label.id,
144
113
  lastSyncedAt: 0,
@@ -146,48 +115,48 @@ export const threadMutators = {
146
115
  threadMessageId: x.id,
147
116
  uid: -(baseTimestamp + i),
148
117
  uidValidity: label.uidValidity ?? 0,
149
- }))));
118
+ })));
150
119
  }
151
120
  currentLabelIds.add(label.id);
152
- await tx.mutate(zeroCRUD.thread.update({
121
+ await tx.mutate.thread.update({
153
122
  id: threadId,
154
123
  labelIdList: buildLabelIdList([...currentLabelIds]),
155
- }));
124
+ });
156
125
  }
157
126
  }
158
- }),
159
- delete: defineMutator(threadMutatorSchemas.delete, async ({ tx, args: { accounts } }) => {
160
- for (const [, { threadIds }] of Object.entries(accounts)) {
127
+ },
128
+ delete: async (tx, args) => {
129
+ for (const [, { threadIds }] of Object.entries(args.accounts)) {
161
130
  for (const threadId of threadIds) {
162
- const thread = await tx.run(tx.query.thread.where('id', threadId).one());
131
+ const thread = await tx.query.thread.where('id', threadId).one().run();
163
132
  if (thread) {
164
133
  if (thread.seen === false) {
165
134
  const labelIds = threadsUtils.parseLabelIdList(thread.labelIdList);
166
135
  if (labelIds.length > 0) {
167
- const labels = await tx.run(tx.query.accountLabel.where('id', 'IN', labelIds));
168
- await Promise.all(labels.map(x => tx.mutate(zeroCRUD.accountLabel.update({
136
+ const labels = await tx.query.accountLabel.where('id', 'IN', labelIds).run();
137
+ await Promise.all(labels.map(x => tx.mutate.accountLabel.update({
169
138
  id: x.id,
170
139
  unreadCount: Math.max(0, (x.unreadCount ?? 0) - 1),
171
- }))));
140
+ })));
172
141
  }
173
142
  }
174
- await tx.mutate(zeroCRUD.thread.delete({
143
+ await tx.mutate.thread.delete({
175
144
  id: threadId,
176
- }));
145
+ });
177
146
  }
178
147
  }
179
148
  }
180
- }),
181
- removeLabel: defineMutator(threadMutatorSchemas.removeLabel, async ({ tx, args: { accounts, labelPath } }) => {
182
- for (const [accountId, { threadIds }] of Object.entries(accounts)) {
183
- const label = await tx.run(tx.query.accountLabel.where('accountId', accountId).where('path', labelPath).one());
149
+ },
150
+ removeLabel: async (tx, args) => {
151
+ for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
152
+ const label = await tx.query.accountLabel.where('accountId', accountId).where('path', args.labelPath).one().run();
184
153
  if (!label) {
185
154
  throw new Error(MutationError.ENTITY_NOT_FOUND);
186
155
  }
187
156
  for (const threadId of threadIds) {
188
157
  const [thread, messages] = await Promise.all([
189
- tx.run(tx.query.thread.where('id', threadId).one()),
190
- tx.run(tx.query.threadMessage.where('threadId', threadId)),
158
+ tx.query.thread.where('id', threadId).one().run(),
159
+ tx.query.threadMessage.where('threadId', threadId).run(),
191
160
  ]);
192
161
  if (!thread) {
193
162
  throw new Error(MutationError.ENTITY_NOT_FOUND);
@@ -198,91 +167,91 @@ export const threadMutators = {
198
167
  }
199
168
  currentLabelIds.delete(label.id);
200
169
  await Promise.all([
201
- ...messages.map(x => tx.mutate(zeroCRUD.threadLabel.delete({
170
+ ...messages.map(x => tx.mutate.threadLabel.delete({
202
171
  accountId,
203
172
  labelId: label.id,
204
173
  threadMessageId: x.id,
205
- }))),
206
- tx.mutate(zeroCRUD.threadByLabel.delete({
174
+ })),
175
+ tx.mutate.threadByLabel.delete({
207
176
  labelId: label.id,
208
177
  threadId,
209
- })),
178
+ }),
210
179
  ...(thread.seen === false
211
180
  ? [
212
- tx.mutate(zeroCRUD.accountLabel.update({
181
+ tx.mutate.accountLabel.update({
213
182
  id: label.id,
214
183
  unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
215
- })),
184
+ }),
216
185
  ]
217
186
  : []),
218
- tx.mutate(zeroCRUD.thread.update({
187
+ tx.mutate.thread.update({
219
188
  id: threadId,
220
189
  labelIdList: buildLabelIdList([...currentLabelIds]),
221
- })),
190
+ }),
222
191
  ]);
223
192
  }
224
193
  }
225
- }),
226
- setArchive: defineMutator(threadMutatorSchemas.setArchive, async ({ tx, args: { accounts } }) => {
227
- for (const [, { threadIds }] of Object.entries(accounts)) {
194
+ },
195
+ setArchive: async (tx, args) => {
196
+ for (const [, { threadIds }] of Object.entries(args.accounts)) {
228
197
  for (const threadId of threadIds) {
229
198
  await setSystemLabel(tx, threadId, 'ARCHIVE');
230
199
  }
231
200
  }
232
- }),
233
- setFlagged: defineMutator(threadMutatorSchemas.setFlagged, async ({ tx, args: { accounts, flagged } }) => {
234
- for (const [, { threadIds }] of Object.entries(accounts)) {
235
- await Promise.all(threadIds.map(threadId => tx.mutate(zeroCRUD.thread.update({
236
- flagged,
201
+ },
202
+ setFlagged: async (tx, args) => {
203
+ for (const [, { threadIds }] of Object.entries(args.accounts)) {
204
+ await Promise.all(threadIds.map(threadId => tx.mutate.thread.update({
205
+ flagged: args.flagged,
237
206
  id: threadId,
238
- }))));
207
+ })));
239
208
  }
240
- }),
241
- setInbox: defineMutator(threadMutatorSchemas.setInbox, async ({ tx, args: { accounts } }) => {
242
- for (const [, { threadIds }] of Object.entries(accounts)) {
209
+ },
210
+ setInbox: async (tx, args) => {
211
+ for (const [, { threadIds }] of Object.entries(args.accounts)) {
243
212
  for (const threadId of threadIds) {
244
213
  await setSystemLabel(tx, threadId, 'INBOX');
245
214
  }
246
215
  }
247
- }),
248
- setSeen: defineMutator(threadMutatorSchemas.setSeen, async ({ tx, args: { accounts, seen } }) => {
249
- const allThreadIds = Object.values(accounts).flatMap(x => x.threadIds);
250
- const threads = await tx.run(tx.query.thread.where('id', 'IN', allThreadIds));
216
+ },
217
+ setSeen: async (tx, args) => {
218
+ const allThreadIds = Object.values(args.accounts).flatMap(x => x.threadIds);
219
+ const threads = await tx.query.thread.where('id', 'IN', allThreadIds).run();
251
220
  const labelCounts = new Map();
252
221
  for (const thread of threads) {
253
- if (thread.seen !== seen) {
222
+ if (thread.seen !== args.seen) {
254
223
  for (const labelId of threadsUtils.parseLabelIdList(thread.labelIdList)) {
255
224
  labelCounts.set(labelId, (labelCounts.get(labelId) ?? 0) + 1);
256
225
  }
257
226
  }
258
227
  }
259
228
  if (labelCounts.size > 0) {
260
- const labels = await tx.run(tx.query.accountLabel.where('id', 'IN', [...labelCounts.keys()]));
261
- const delta = seen ? -1 : 1;
229
+ const labels = await tx.query.accountLabel.where('id', 'IN', [...labelCounts.keys()]).run();
230
+ const delta = args.seen ? -1 : 1;
262
231
  await Promise.all(labels
263
232
  .filter(x => labelCounts.has(x.id))
264
- .map(x => tx.mutate(zeroCRUD.accountLabel.update({
233
+ .map(x => tx.mutate.accountLabel.update({
265
234
  id: x.id,
266
235
  unreadCount: Math.max(0, (x.unreadCount ?? 0) + delta * (labelCounts.get(x.id) ?? 0)),
267
- }))));
236
+ })));
268
237
  }
269
- await Promise.all(allThreadIds.map(threadId => tx.mutate(zeroCRUD.thread.update({
238
+ await Promise.all(allThreadIds.map(threadId => tx.mutate.thread.update({
270
239
  id: threadId,
271
- seen,
272
- }))));
273
- }),
274
- setSpam: defineMutator(threadMutatorSchemas.setSpam, async ({ tx, args: { accounts } }) => {
275
- for (const [, { threadIds }] of Object.entries(accounts)) {
240
+ seen: args.seen,
241
+ })));
242
+ },
243
+ setSpam: async (tx, args) => {
244
+ for (const [, { threadIds }] of Object.entries(args.accounts)) {
276
245
  for (const threadId of threadIds) {
277
246
  await setSystemLabel(tx, threadId, 'SPAM');
278
247
  }
279
248
  }
280
- }),
281
- setTrash: defineMutator(threadMutatorSchemas.setTrash, async ({ tx, args: { accounts } }) => {
282
- for (const [, { threadIds }] of Object.entries(accounts)) {
249
+ },
250
+ setTrash: async (tx, args) => {
251
+ for (const [, { threadIds }] of Object.entries(args.accounts)) {
283
252
  for (const threadId of threadIds) {
284
253
  await setSystemLabel(tx, threadId, 'TRASH');
285
254
  }
286
255
  }
287
- }),
288
- };
256
+ },
257
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=threadMutators.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadMutators.test.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/threadMutators/threadMutators.test.ts"],"names":[],"mappings":""}