@marcoappio/marco-config 2.0.511 → 2.0.512
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.
- package/dist/zero/index.d.ts +402 -141
- package/dist/zero/index.d.ts.map +1 -1
- package/dist/zero/index.js +2 -0
- package/dist/zero/mutatorSchemas.d.ts +263 -0
- package/dist/zero/mutatorSchemas.d.ts.map +1 -0
- package/dist/zero/mutatorSchemas.js +176 -0
- package/dist/zero/mutators.d.ts +47 -47
- package/dist/zero/mutators.d.ts.map +1 -1
- package/dist/zero/mutators.js +33 -167
- package/dist/zero/queries.d.ts +47 -47
- package/dist/zero/queries.d.ts.map +1 -1
- package/dist/zero/queries.js +1 -1
- package/dist/zero/schema.d.ts +48 -57
- package/dist/zero/schema.d.ts.map +1 -1
- package/dist/zero/schema.js +1 -0
- package/package.json +1 -1
package/dist/zero/mutators.js
CHANGED
|
@@ -1,46 +1,11 @@
|
|
|
1
1
|
import { createBuilder, defineMutators, defineMutatorWithType } from '@rocicorp/zero';
|
|
2
|
-
import
|
|
3
|
-
import { marcoSchemas } from '../schemas';
|
|
4
|
-
import { DRAFT_ATTACHMENT_UPLOAD_STATUSES, DRAFT_STATUSES, DRAFT_TYPES, MutationError } from '../types';
|
|
2
|
+
import { MutationError } from '../types';
|
|
5
3
|
import { stringPatch } from '../utils';
|
|
6
4
|
import { threadsUtils } from '../utils/threads';
|
|
7
|
-
import {
|
|
5
|
+
import { mutatorSchemas } from '../zero/mutatorSchemas';
|
|
6
|
+
import { schema } from '../zero/schema';
|
|
8
7
|
const zql = createBuilder(schema);
|
|
9
8
|
const defineMutator = defineMutatorWithType();
|
|
10
|
-
const accountAliasSchema = v.object({
|
|
11
|
-
emailAddress: marcoSchemas.string.email(),
|
|
12
|
-
id: marcoSchemas.string.required(),
|
|
13
|
-
name: marcoSchemas.string.nullable(),
|
|
14
|
-
});
|
|
15
|
-
const accountsSchema = v.record(marcoSchemas.string.required(), v.object({
|
|
16
|
-
threadIds: v.array(marcoSchemas.string.required()),
|
|
17
|
-
}));
|
|
18
|
-
const baseThreadSchema = v.object({
|
|
19
|
-
accounts: accountsSchema,
|
|
20
|
-
});
|
|
21
|
-
const threadChangeLabelSchema = v.object({
|
|
22
|
-
accounts: accountsSchema,
|
|
23
|
-
labelPath: marcoSchemas.string.required(),
|
|
24
|
-
});
|
|
25
|
-
const draftBodySchema = v.object({
|
|
26
|
-
bcc: v.array(marcoSchemas.string.email()),
|
|
27
|
-
cc: v.array(marcoSchemas.string.email()),
|
|
28
|
-
content: v.pipe(v.string(), v.maxLength(384000)),
|
|
29
|
-
subject: marcoSchemas.string.nullable(),
|
|
30
|
-
to: v.array(marcoSchemas.string.email()),
|
|
31
|
-
});
|
|
32
|
-
const draftAttachmentSchema = v.object({
|
|
33
|
-
fileName: marcoSchemas.string.required(),
|
|
34
|
-
id: marcoSchemas.string.required(),
|
|
35
|
-
mimeType: marcoSchemas.string.required(),
|
|
36
|
-
status: v.picklist(DRAFT_ATTACHMENT_UPLOAD_STATUSES),
|
|
37
|
-
totalSize: marcoSchemas.number.positiveInteger(),
|
|
38
|
-
});
|
|
39
|
-
const userPushNotificationTokenSchema = v.object({
|
|
40
|
-
createdAt: marcoSchemas.number.positiveInteger(),
|
|
41
|
-
id: marcoSchemas.string.required(),
|
|
42
|
-
token: marcoSchemas.string.required(),
|
|
43
|
-
});
|
|
44
9
|
const buildLabelIdList = (x) => (x.length === 0 ? '' : ` ${[...new Set(x)].join(' ')} `);
|
|
45
10
|
const setSystemLabel = async (tx, builder, threadId, targetSpecialUse) => {
|
|
46
11
|
const thread = await tx.run(builder.thread.where('id', threadId).one());
|
|
@@ -113,12 +78,7 @@ const setSystemLabel = async (tx, builder, threadId, targetSpecialUse) => {
|
|
|
113
78
|
};
|
|
114
79
|
export const mutators = defineMutators({
|
|
115
80
|
account: {
|
|
116
|
-
createAccount: defineMutator(
|
|
117
|
-
aliasId: marcoSchemas.string.required(),
|
|
118
|
-
color: marcoSchemas.string.required(),
|
|
119
|
-
emailAddress: marcoSchemas.string.email(),
|
|
120
|
-
id: marcoSchemas.string.required(),
|
|
121
|
-
}), async ({ tx, ctx, args }) => {
|
|
81
|
+
createAccount: defineMutator(mutatorSchemas.account.createAccount, async ({ tx, ctx, args }) => {
|
|
122
82
|
await tx.mutate.account.insert({
|
|
123
83
|
color: args.color,
|
|
124
84
|
displayName: null,
|
|
@@ -137,10 +97,7 @@ export const mutators = defineMutators({
|
|
|
137
97
|
name: null,
|
|
138
98
|
});
|
|
139
99
|
}),
|
|
140
|
-
createAlias: defineMutator(
|
|
141
|
-
accountId: marcoSchemas.string.required(),
|
|
142
|
-
alias: accountAliasSchema,
|
|
143
|
-
}), async ({ tx, args }) => {
|
|
100
|
+
createAlias: defineMutator(mutatorSchemas.account.createAlias, async ({ tx, args }) => {
|
|
144
101
|
await tx.mutate.accountAlias.insert({
|
|
145
102
|
accountId: args.accountId,
|
|
146
103
|
emailAddress: args.alias.emailAddress,
|
|
@@ -149,17 +106,12 @@ export const mutators = defineMutators({
|
|
|
149
106
|
name: args.alias.name ?? null,
|
|
150
107
|
});
|
|
151
108
|
}),
|
|
152
|
-
deleteAccount: defineMutator(
|
|
153
|
-
id: marcoSchemas.string.required(),
|
|
154
|
-
}), async ({ tx, args }) => {
|
|
109
|
+
deleteAccount: defineMutator(mutatorSchemas.account.deleteAccount, async ({ tx, args }) => {
|
|
155
110
|
await tx.mutate.account.delete({
|
|
156
111
|
id: args.id,
|
|
157
112
|
});
|
|
158
113
|
}),
|
|
159
|
-
deleteAlias: defineMutator(
|
|
160
|
-
accountId: marcoSchemas.string.required(),
|
|
161
|
-
aliasId: marcoSchemas.string.required(),
|
|
162
|
-
}), async ({ tx, args }) => {
|
|
114
|
+
deleteAlias: defineMutator(mutatorSchemas.account.deleteAlias, async ({ tx, args }) => {
|
|
163
115
|
const alias = await tx.run(zql.accountAlias.where('id', args.aliasId).one());
|
|
164
116
|
await tx.mutate.accountAlias.delete({
|
|
165
117
|
id: args.aliasId,
|
|
@@ -185,20 +137,13 @@ export const mutators = defineMutators({
|
|
|
185
137
|
}
|
|
186
138
|
}
|
|
187
139
|
}),
|
|
188
|
-
setAliasName: defineMutator(
|
|
189
|
-
accountId: marcoSchemas.string.required(),
|
|
190
|
-
aliasId: marcoSchemas.string.required(),
|
|
191
|
-
displayName: marcoSchemas.string.nullable(),
|
|
192
|
-
}), async ({ tx, args }) => {
|
|
140
|
+
setAliasName: defineMutator(mutatorSchemas.account.setAliasName, async ({ tx, args }) => {
|
|
193
141
|
await tx.mutate.accountAlias.update({
|
|
194
142
|
id: args.aliasId,
|
|
195
143
|
name: args.displayName,
|
|
196
144
|
});
|
|
197
145
|
}),
|
|
198
|
-
setAliasPrimary: defineMutator(
|
|
199
|
-
accountId: marcoSchemas.string.required(),
|
|
200
|
-
aliasId: marcoSchemas.string.required(),
|
|
201
|
-
}), async ({ tx, args }) => {
|
|
146
|
+
setAliasPrimary: defineMutator(mutatorSchemas.account.setAliasPrimary, async ({ tx, args }) => {
|
|
202
147
|
const aliases = await tx.run(zql.accountAlias.where('accountId', args.accountId));
|
|
203
148
|
for (const alias of aliases) {
|
|
204
149
|
await tx.mutate.accountAlias.update({
|
|
@@ -211,29 +156,19 @@ export const mutators = defineMutators({
|
|
|
211
156
|
primaryAliasId: args.aliasId,
|
|
212
157
|
});
|
|
213
158
|
}),
|
|
214
|
-
setConnectionConfigImapRaw: defineMutator(
|
|
215
|
-
connectionConfig: marcoSchemas.emailAccount.connectionConfigImapRaw(),
|
|
216
|
-
id: marcoSchemas.string.required(),
|
|
217
|
-
}), async ({ tx, args }) => {
|
|
159
|
+
setConnectionConfigImapRaw: defineMutator(mutatorSchemas.account.setConnectionConfigImapRaw, async ({ tx, args }) => {
|
|
218
160
|
await tx.mutate.account.update({
|
|
219
161
|
id: args.id,
|
|
220
162
|
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
221
163
|
});
|
|
222
164
|
}),
|
|
223
|
-
setConnectionConfigOauth: defineMutator(
|
|
224
|
-
connectionConfig: marcoSchemas.emailAccount.connectionConfigOauth(),
|
|
225
|
-
id: marcoSchemas.string.required(),
|
|
226
|
-
}), async ({ tx, args }) => {
|
|
165
|
+
setConnectionConfigOauth: defineMutator(mutatorSchemas.account.setConnectionConfigOauth, async ({ tx, args }) => {
|
|
227
166
|
await tx.mutate.account.update({
|
|
228
167
|
id: args.id,
|
|
229
168
|
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
230
169
|
});
|
|
231
170
|
}),
|
|
232
|
-
setSettings: defineMutator(
|
|
233
|
-
color: v.optional(marcoSchemas.string.nullable()),
|
|
234
|
-
displayName: v.optional(marcoSchemas.string.nullable()),
|
|
235
|
-
id: marcoSchemas.string.required(),
|
|
236
|
-
}), async ({ tx, args }) => {
|
|
171
|
+
setSettings: defineMutator(mutatorSchemas.account.setSettings, async ({ tx, args }) => {
|
|
237
172
|
await tx.mutate.account.update({
|
|
238
173
|
color: args.color ? args.color : undefined,
|
|
239
174
|
displayName: args.displayName ? args.displayName : undefined,
|
|
@@ -242,10 +177,7 @@ export const mutators = defineMutators({
|
|
|
242
177
|
}),
|
|
243
178
|
},
|
|
244
179
|
draft: {
|
|
245
|
-
cancelSend: defineMutator(
|
|
246
|
-
id: marcoSchemas.string.required(),
|
|
247
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
248
|
-
}), async ({ tx, args }) => {
|
|
180
|
+
cancelSend: defineMutator(mutatorSchemas.draft.cancelSend, async ({ tx, args }) => {
|
|
249
181
|
const draft = await tx.run(zql.draft.where('id', args.id).one());
|
|
250
182
|
if (!draft) {
|
|
251
183
|
throw new Error(MutationError.ENTITY_NOT_FOUND);
|
|
@@ -260,11 +192,7 @@ export const mutators = defineMutators({
|
|
|
260
192
|
updatedAt: args.updatedAt,
|
|
261
193
|
});
|
|
262
194
|
}),
|
|
263
|
-
createAttachment: defineMutator(
|
|
264
|
-
attachment: draftAttachmentSchema,
|
|
265
|
-
id: marcoSchemas.string.required(),
|
|
266
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
267
|
-
}), async ({ tx, args }) => {
|
|
195
|
+
createAttachment: defineMutator(mutatorSchemas.draft.createAttachment, async ({ tx, args }) => {
|
|
268
196
|
await tx.mutate.draftAttachment.insert({
|
|
269
197
|
draftId: args.id,
|
|
270
198
|
fileName: args.attachment.fileName,
|
|
@@ -278,20 +206,7 @@ export const mutators = defineMutators({
|
|
|
278
206
|
updatedAt: args.updatedAt,
|
|
279
207
|
});
|
|
280
208
|
}),
|
|
281
|
-
createDraft: defineMutator(
|
|
282
|
-
accountId: marcoSchemas.string.required(),
|
|
283
|
-
attachments: v.array(draftAttachmentSchema),
|
|
284
|
-
body: draftBodySchema,
|
|
285
|
-
error: marcoSchemas.string.nullable(),
|
|
286
|
-
from: marcoSchemas.string.email(),
|
|
287
|
-
fromName: marcoSchemas.string.nullable(),
|
|
288
|
-
id: marcoSchemas.string.required(),
|
|
289
|
-
referencedMessageId: marcoSchemas.string.nullable(),
|
|
290
|
-
scheduledFor: v.nullable(marcoSchemas.number.positiveInteger()),
|
|
291
|
-
status: v.picklist(DRAFT_STATUSES),
|
|
292
|
-
type: v.picklist(DRAFT_TYPES),
|
|
293
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
294
|
-
}), async ({ tx, ctx, args }) => {
|
|
209
|
+
createDraft: defineMutator(mutatorSchemas.draft.createDraft, async ({ tx, ctx, args }) => {
|
|
295
210
|
await tx.mutate.draft.insert({
|
|
296
211
|
accountId: args.accountId,
|
|
297
212
|
body: {
|
|
@@ -324,11 +239,7 @@ export const mutators = defineMutators({
|
|
|
324
239
|
});
|
|
325
240
|
}
|
|
326
241
|
}),
|
|
327
|
-
deleteAttachment: defineMutator(
|
|
328
|
-
attachmentId: marcoSchemas.string.required(),
|
|
329
|
-
id: marcoSchemas.string.required(),
|
|
330
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
331
|
-
}), async ({ tx, args }) => {
|
|
242
|
+
deleteAttachment: defineMutator(mutatorSchemas.draft.deleteAttachment, async ({ tx, args }) => {
|
|
332
243
|
await tx.mutate.draftAttachment.delete({
|
|
333
244
|
id: args.attachmentId,
|
|
334
245
|
});
|
|
@@ -337,27 +248,12 @@ export const mutators = defineMutators({
|
|
|
337
248
|
updatedAt: args.updatedAt,
|
|
338
249
|
});
|
|
339
250
|
}),
|
|
340
|
-
deleteDraft: defineMutator(
|
|
341
|
-
id: marcoSchemas.string.required(),
|
|
342
|
-
}), async ({ tx, args }) => {
|
|
251
|
+
deleteDraft: defineMutator(mutatorSchemas.draft.deleteDraft, async ({ tx, args }) => {
|
|
343
252
|
await tx.mutate.draft.delete({
|
|
344
253
|
id: args.id,
|
|
345
254
|
});
|
|
346
255
|
}),
|
|
347
|
-
scheduleSend: defineMutator(
|
|
348
|
-
v.object({
|
|
349
|
-
id: marcoSchemas.string.required(),
|
|
350
|
-
kind: v.literal('IMMEDIATE'),
|
|
351
|
-
undoMs: marcoSchemas.number.positiveInteger(),
|
|
352
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
353
|
-
}),
|
|
354
|
-
v.object({
|
|
355
|
-
id: marcoSchemas.string.required(),
|
|
356
|
-
kind: v.literal('SCHEDULED'),
|
|
357
|
-
scheduledFor: marcoSchemas.number.positiveInteger(),
|
|
358
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
359
|
-
}),
|
|
360
|
-
]), async ({ tx, args }) => {
|
|
256
|
+
scheduleSend: defineMutator(mutatorSchemas.draft.scheduleSend, async ({ tx, args }) => {
|
|
361
257
|
if (args.kind === 'IMMEDIATE') {
|
|
362
258
|
await tx.mutate.draft.update({
|
|
363
259
|
id: args.id,
|
|
@@ -375,11 +271,7 @@ export const mutators = defineMutators({
|
|
|
375
271
|
});
|
|
376
272
|
}
|
|
377
273
|
}),
|
|
378
|
-
setContent: defineMutator(
|
|
379
|
-
id: marcoSchemas.string.required(),
|
|
380
|
-
patch: marcoSchemas.drafts.contentPatch.patch(),
|
|
381
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
382
|
-
}), async ({ tx, args }) => {
|
|
274
|
+
setContent: defineMutator(mutatorSchemas.draft.setContent, async ({ tx, args }) => {
|
|
383
275
|
const draft = await tx.run(zql.draft.where('id', args.id).one());
|
|
384
276
|
if (!draft) {
|
|
385
277
|
throw new Error(MutationError.ENTITY_NOT_FOUND);
|
|
@@ -393,11 +285,7 @@ export const mutators = defineMutators({
|
|
|
393
285
|
updatedAt: args.updatedAt,
|
|
394
286
|
});
|
|
395
287
|
}),
|
|
396
|
-
setEnvelope: defineMutator(
|
|
397
|
-
envelope: v.omit(draftBodySchema, ['content']),
|
|
398
|
-
id: marcoSchemas.string.required(),
|
|
399
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
400
|
-
}), async ({ tx, args }) => {
|
|
288
|
+
setEnvelope: defineMutator(mutatorSchemas.draft.setEnvelope, async ({ tx, args }) => {
|
|
401
289
|
const draft = await tx.run(zql.draft.where('id', args.id).one());
|
|
402
290
|
if (!draft) {
|
|
403
291
|
throw new Error(MutationError.ENTITY_NOT_FOUND);
|
|
@@ -414,14 +302,7 @@ export const mutators = defineMutators({
|
|
|
414
302
|
updatedAt: args.updatedAt,
|
|
415
303
|
});
|
|
416
304
|
}),
|
|
417
|
-
setFrom: defineMutator(
|
|
418
|
-
accountId: marcoSchemas.string.required(),
|
|
419
|
-
aliasId: marcoSchemas.string.required(),
|
|
420
|
-
from: marcoSchemas.string.email(),
|
|
421
|
-
fromName: marcoSchemas.string.nullable(),
|
|
422
|
-
id: marcoSchemas.string.required(),
|
|
423
|
-
updatedAt: marcoSchemas.number.positiveInteger(),
|
|
424
|
-
}), async ({ tx, args }) => {
|
|
305
|
+
setFrom: defineMutator(mutatorSchemas.draft.setFrom, async ({ tx, args }) => {
|
|
425
306
|
await tx.mutate.draft.update({
|
|
426
307
|
accountId: args.accountId,
|
|
427
308
|
fromAliasId: args.aliasId,
|
|
@@ -433,7 +314,7 @@ export const mutators = defineMutators({
|
|
|
433
314
|
}),
|
|
434
315
|
},
|
|
435
316
|
thread: {
|
|
436
|
-
addLabel: defineMutator(
|
|
317
|
+
addLabel: defineMutator(mutatorSchemas.thread.addLabel, async ({ tx, args }) => {
|
|
437
318
|
for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
|
|
438
319
|
const label = await tx.run(zql.accountLabel.where('accountId', accountId).where('path', args.labelPath).one());
|
|
439
320
|
if (!label) {
|
|
@@ -487,7 +368,7 @@ export const mutators = defineMutators({
|
|
|
487
368
|
}
|
|
488
369
|
}
|
|
489
370
|
}),
|
|
490
|
-
delete: defineMutator(
|
|
371
|
+
delete: defineMutator(mutatorSchemas.thread.delete, async ({ tx, args }) => {
|
|
491
372
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
492
373
|
for (const threadId of threadIds) {
|
|
493
374
|
const thread = await tx.run(zql.thread.where('id', threadId).one());
|
|
@@ -509,7 +390,7 @@ export const mutators = defineMutators({
|
|
|
509
390
|
}
|
|
510
391
|
}
|
|
511
392
|
}),
|
|
512
|
-
removeLabel: defineMutator(
|
|
393
|
+
removeLabel: defineMutator(mutatorSchemas.thread.removeLabel, async ({ tx, args }) => {
|
|
513
394
|
for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
|
|
514
395
|
const label = await tx.run(zql.accountLabel.where('accountId', accountId).where('path', args.labelPath).one());
|
|
515
396
|
if (!label) {
|
|
@@ -554,17 +435,14 @@ export const mutators = defineMutators({
|
|
|
554
435
|
}
|
|
555
436
|
}
|
|
556
437
|
}),
|
|
557
|
-
setArchive: defineMutator(
|
|
438
|
+
setArchive: defineMutator(mutatorSchemas.thread.setArchive, async ({ tx, args }) => {
|
|
558
439
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
559
440
|
for (const threadId of threadIds) {
|
|
560
441
|
await setSystemLabel(tx, zql, threadId, 'ARCHIVE');
|
|
561
442
|
}
|
|
562
443
|
}
|
|
563
444
|
}),
|
|
564
|
-
setFlagged: defineMutator(
|
|
565
|
-
accounts: accountsSchema,
|
|
566
|
-
flagged: v.nonOptional(v.boolean()),
|
|
567
|
-
}), async ({ tx, args }) => {
|
|
445
|
+
setFlagged: defineMutator(mutatorSchemas.thread.setFlagged, async ({ tx, args }) => {
|
|
568
446
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
569
447
|
await Promise.all(threadIds.map(threadId => tx.mutate.thread.update({
|
|
570
448
|
flagged: args.flagged,
|
|
@@ -572,17 +450,14 @@ export const mutators = defineMutators({
|
|
|
572
450
|
})));
|
|
573
451
|
}
|
|
574
452
|
}),
|
|
575
|
-
setInbox: defineMutator(
|
|
453
|
+
setInbox: defineMutator(mutatorSchemas.thread.setInbox, async ({ tx, args }) => {
|
|
576
454
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
577
455
|
for (const threadId of threadIds) {
|
|
578
456
|
await setSystemLabel(tx, zql, threadId, 'INBOX');
|
|
579
457
|
}
|
|
580
458
|
}
|
|
581
459
|
}),
|
|
582
|
-
setSeen: defineMutator(
|
|
583
|
-
accounts: accountsSchema,
|
|
584
|
-
seen: v.boolean(),
|
|
585
|
-
}), async ({ tx, args }) => {
|
|
460
|
+
setSeen: defineMutator(mutatorSchemas.thread.setSeen, async ({ tx, args }) => {
|
|
586
461
|
const allThreadIds = Object.values(args.accounts).flatMap(x => x.threadIds);
|
|
587
462
|
const threads = await tx.run(zql.thread.where('id', 'IN', allThreadIds));
|
|
588
463
|
const labelCounts = new Map();
|
|
@@ -608,14 +483,14 @@ export const mutators = defineMutators({
|
|
|
608
483
|
seen: args.seen,
|
|
609
484
|
})));
|
|
610
485
|
}),
|
|
611
|
-
setSpam: defineMutator(
|
|
486
|
+
setSpam: defineMutator(mutatorSchemas.thread.setSpam, async ({ tx, args }) => {
|
|
612
487
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
613
488
|
for (const threadId of threadIds) {
|
|
614
489
|
await setSystemLabel(tx, zql, threadId, 'SPAM');
|
|
615
490
|
}
|
|
616
491
|
}
|
|
617
492
|
}),
|
|
618
|
-
setTrash: defineMutator(
|
|
493
|
+
setTrash: defineMutator(mutatorSchemas.thread.setTrash, async ({ tx, args }) => {
|
|
619
494
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
620
495
|
for (const threadId of threadIds) {
|
|
621
496
|
await setSystemLabel(tx, zql, threadId, 'TRASH');
|
|
@@ -624,27 +499,18 @@ export const mutators = defineMutators({
|
|
|
624
499
|
}),
|
|
625
500
|
},
|
|
626
501
|
user: {
|
|
627
|
-
deleteSettingsPushNotificationToken: defineMutator(
|
|
628
|
-
id: marcoSchemas.string.required(),
|
|
629
|
-
token: marcoSchemas.string.required(),
|
|
630
|
-
}), async ({ tx, args }) => {
|
|
502
|
+
deleteSettingsPushNotificationToken: defineMutator(mutatorSchemas.user.deleteSettingsPushNotificationToken, async ({ tx, args }) => {
|
|
631
503
|
await tx.mutate.userPushNotificationToken.delete({
|
|
632
504
|
id: args.id,
|
|
633
505
|
});
|
|
634
506
|
}),
|
|
635
|
-
setSettingsName: defineMutator(
|
|
636
|
-
id: marcoSchemas.string.required(),
|
|
637
|
-
name: marcoSchemas.string.nullable(),
|
|
638
|
-
}), async ({ tx, args }) => {
|
|
507
|
+
setSettingsName: defineMutator(mutatorSchemas.user.setSettingsName, async ({ tx, args }) => {
|
|
639
508
|
await tx.mutate.user.update({
|
|
640
509
|
id: args.id,
|
|
641
510
|
name: args.name,
|
|
642
511
|
});
|
|
643
512
|
}),
|
|
644
|
-
setSettingsPushNotificationToken: defineMutator(
|
|
645
|
-
id: marcoSchemas.string.required(),
|
|
646
|
-
pushNotificationToken: userPushNotificationTokenSchema,
|
|
647
|
-
}), async ({ tx, args }) => {
|
|
513
|
+
setSettingsPushNotificationToken: defineMutator(mutatorSchemas.user.setSettingsPushNotificationToken, async ({ tx, args }) => {
|
|
648
514
|
const existing = await tx.run(zql.userPushNotificationToken.where('userId', args.id).where('token', args.pushNotificationToken.token).one());
|
|
649
515
|
if (!existing) {
|
|
650
516
|
await tx.mutate.userPushNotificationToken.insert({
|