@marcoappio/marco-config 2.0.492 → 2.0.493
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/types/Zero.d.ts +0 -14
- package/dist/types/Zero.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/zero/index.d.ts +1553 -1439
- package/dist/zero/index.d.ts.map +1 -1
- package/dist/zero/index.js +2 -4
- package/dist/zero/mutators/accountMutators/accountMutators.d.ts +109 -3
- package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +1 -1
- package/dist/zero/mutators/accountMutators/accountMutators.js +59 -25
- package/dist/zero/mutators/defineMutator.d.ts +16 -0
- package/dist/zero/mutators/defineMutator.d.ts.map +1 -0
- package/dist/zero/mutators/defineMutator.js +7 -0
- package/dist/zero/mutators/draftMutators/draftMutators.d.ts +167 -3
- package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +1 -1
- package/dist/zero/mutators/draftMutators/draftMutators.js +97 -25
- package/dist/zero/mutators/index.d.ts +2 -1
- package/dist/zero/mutators/index.d.ts.map +1 -1
- package/dist/zero/mutators/index.js +2 -1
- package/dist/zero/mutators/mutators.d.ts +438 -17
- package/dist/zero/mutators/mutators.d.ts.map +1 -1
- package/dist/zero/mutators/mutators.js +11 -38
- package/dist/zero/mutators/threadMutators/threadMutators.d.ts +127 -3
- package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +1 -1
- package/dist/zero/mutators/threadMutators/threadMutators.js +39 -20
- package/dist/zero/mutators/userMutators/userMutators.d.ts +31 -3
- package/dist/zero/mutators/userMutators/userMutators.d.ts.map +1 -1
- package/dist/zero/mutators/userMutators/userMutators.js +25 -8
- package/dist/zero/queries/getAccounts.d.ts +134 -134
- package/dist/zero/queries/getContacts.d.ts +134 -134
- package/dist/zero/queries/getDrafts.d.ts +134 -134
- package/dist/zero/queries/getThread.d.ts +134 -134
- package/dist/zero/queries/getThreadList.d.ts +134 -134
- package/dist/zero/queries/getThreads.d.ts +134 -134
- package/dist/zero/queries/getUser.d.ts +134 -134
- package/dist/zero/queries/index.d.ts +132 -132
- package/dist/zero/schema.d.ts +132 -132
- package/dist/zero/schema.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/types/AuthData.d.ts +0 -4
- package/dist/types/AuthData.d.ts.map +0 -1
- package/dist/types/AuthData.js +0 -1
- package/dist/zero/mutatorSchemas/account.d.ts +0 -80
- package/dist/zero/mutatorSchemas/account.d.ts.map +0 -1
- package/dist/zero/mutatorSchemas/account.js +0 -66
- package/dist/zero/mutatorSchemas/draft.d.ts +0 -150
- package/dist/zero/mutatorSchemas/draft.d.ts.map +0 -1
- package/dist/zero/mutatorSchemas/draft.js +0 -104
- package/dist/zero/mutatorSchemas/index.d.ts +0 -323
- package/dist/zero/mutatorSchemas/index.d.ts.map +0 -1
- package/dist/zero/mutatorSchemas/index.js +0 -10
- package/dist/zero/mutatorSchemas/thread.d.ts +0 -71
- package/dist/zero/mutatorSchemas/thread.d.ts.map +0 -1
- package/dist/zero/mutatorSchemas/thread.js +0 -47
- package/dist/zero/mutatorSchemas/user.d.ts +0 -26
- package/dist/zero/mutatorSchemas/user.d.ts.map +0 -1
- package/dist/zero/mutatorSchemas/user.js +0 -27
- package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts +0 -2
- package/dist/zero/mutators/accountMutators/accountMutators.test.d.ts.map +0 -1
- package/dist/zero/mutators/accountMutators/accountMutators.test.js +0 -372
- package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts +0 -2
- package/dist/zero/mutators/draftMutators/draftMutators.test.d.ts.map +0 -1
- package/dist/zero/mutators/draftMutators/draftMutators.test.js +0 -416
- package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts +0 -2
- package/dist/zero/mutators/threadMutators/threadMutators.test.d.ts.map +0 -1
- package/dist/zero/mutators/threadMutators/threadMutators.test.js +0 -755
- package/dist/zero/mutators/userMutators/userMutators.test.d.ts +0 -2
- package/dist/zero/mutators/userMutators/userMutators.test.d.ts.map +0 -1
- package/dist/zero/mutators/userMutators/userMutators.test.js +0 -84
|
@@ -1,39 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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)),
|
|
1
|
+
import { defineMutators } from '@rocicorp/zero';
|
|
2
|
+
import { accountMutators } from './accountMutators';
|
|
3
|
+
import { draftMutators } from './draftMutators';
|
|
4
|
+
import { threadMutators } from './threadMutators';
|
|
5
|
+
import { userMutators } from './userMutators';
|
|
6
|
+
export { defineMutator } from './defineMutator';
|
|
7
|
+
export const mutators = defineMutators({
|
|
8
|
+
account: accountMutators,
|
|
9
|
+
draft: draftMutators,
|
|
10
|
+
thread: threadMutators,
|
|
11
|
+
user: userMutators,
|
|
39
12
|
});
|
|
@@ -1,8 +1,132 @@
|
|
|
1
1
|
import type { Transaction } from '@rocicorp/zero';
|
|
2
2
|
import type { LabelSpecialUse } from '../../../types';
|
|
3
|
-
import { type AuthData, type HandlerMap } from '../../../types';
|
|
4
|
-
import type { ZeroMutatorSchemas } from '../../../zero/mutatorSchemas';
|
|
5
3
|
import type { MarcoZeroSchema } from '../../../zero/schema';
|
|
6
4
|
export declare const setSystemLabel: (tx: Transaction<MarcoZeroSchema>, threadId: string, targetSpecialUse: LabelSpecialUse) => Promise<void>;
|
|
7
|
-
export declare const
|
|
5
|
+
export declare const threadMutators: {
|
|
6
|
+
addLabel: import("@rocicorp/zero").MutatorDefinition<{
|
|
7
|
+
accounts: {
|
|
8
|
+
[x: string]: {
|
|
9
|
+
threadIds: string[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
labelPath: string;
|
|
13
|
+
}, {
|
|
14
|
+
accounts: {
|
|
15
|
+
[x: string]: {
|
|
16
|
+
threadIds: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
labelPath: string;
|
|
20
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
21
|
+
delete: import("@rocicorp/zero").MutatorDefinition<{
|
|
22
|
+
accounts: {
|
|
23
|
+
[x: string]: {
|
|
24
|
+
threadIds: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}, {
|
|
28
|
+
accounts: {
|
|
29
|
+
[x: string]: {
|
|
30
|
+
threadIds: string[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
34
|
+
removeLabel: import("@rocicorp/zero").MutatorDefinition<{
|
|
35
|
+
accounts: {
|
|
36
|
+
[x: string]: {
|
|
37
|
+
threadIds: string[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
labelPath: string;
|
|
41
|
+
}, {
|
|
42
|
+
accounts: {
|
|
43
|
+
[x: string]: {
|
|
44
|
+
threadIds: string[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
labelPath: string;
|
|
48
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
49
|
+
setArchive: import("@rocicorp/zero").MutatorDefinition<{
|
|
50
|
+
accounts: {
|
|
51
|
+
[x: string]: {
|
|
52
|
+
threadIds: string[];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}, {
|
|
56
|
+
accounts: {
|
|
57
|
+
[x: string]: {
|
|
58
|
+
threadIds: string[];
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
62
|
+
setFlagged: import("@rocicorp/zero").MutatorDefinition<{
|
|
63
|
+
accounts: {
|
|
64
|
+
[x: string]: {
|
|
65
|
+
threadIds: string[];
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
flagged: boolean;
|
|
69
|
+
}, {
|
|
70
|
+
accounts: {
|
|
71
|
+
[x: string]: {
|
|
72
|
+
threadIds: string[];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
flagged: boolean;
|
|
76
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
77
|
+
setInbox: import("@rocicorp/zero").MutatorDefinition<{
|
|
78
|
+
accounts: {
|
|
79
|
+
[x: string]: {
|
|
80
|
+
threadIds: string[];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
}, {
|
|
84
|
+
accounts: {
|
|
85
|
+
[x: string]: {
|
|
86
|
+
threadIds: string[];
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
90
|
+
setSeen: import("@rocicorp/zero").MutatorDefinition<{
|
|
91
|
+
accounts: {
|
|
92
|
+
[x: string]: {
|
|
93
|
+
threadIds: string[];
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
seen: boolean;
|
|
97
|
+
}, {
|
|
98
|
+
accounts: {
|
|
99
|
+
[x: string]: {
|
|
100
|
+
threadIds: string[];
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
seen: boolean;
|
|
104
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
105
|
+
setSpam: import("@rocicorp/zero").MutatorDefinition<{
|
|
106
|
+
accounts: {
|
|
107
|
+
[x: string]: {
|
|
108
|
+
threadIds: string[];
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
}, {
|
|
112
|
+
accounts: {
|
|
113
|
+
[x: string]: {
|
|
114
|
+
threadIds: string[];
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
118
|
+
setTrash: import("@rocicorp/zero").MutatorDefinition<{
|
|
119
|
+
accounts: {
|
|
120
|
+
[x: string]: {
|
|
121
|
+
threadIds: string[];
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
}, {
|
|
125
|
+
accounts: {
|
|
126
|
+
[x: string]: {
|
|
127
|
+
threadIds: string[];
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
131
|
+
};
|
|
8
132
|
//# sourceMappingURL=threadMutators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAIjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAI1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAoBhE,eAAO,MAAM,cAAc,OACrB,WAAW,CAAC,eAAe,CAAC,YACtB,MAAM,oBACE,eAAe,KAChC,OAAO,CAAC,IAAI,CAyFd,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsP1B,CAAA"}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { marcoSchemas } from '../../../schemas';
|
|
1
3
|
import { MutationError } from '../../../types';
|
|
2
4
|
import { threadsUtils } from '../../../utils/threads';
|
|
5
|
+
import { defineMutator } from '../../../zero/mutators/defineMutator';
|
|
3
6
|
const buildLabelIdList = (x) => (x.length === 0 ? '' : ` ${[...new Set(x)].join(' ')} `);
|
|
7
|
+
const accountsSchema = v.record(marcoSchemas.string.required(), v.object({
|
|
8
|
+
threadIds: v.array(marcoSchemas.string.required()),
|
|
9
|
+
}));
|
|
10
|
+
const baseThreadSchema = v.object({
|
|
11
|
+
accounts: accountsSchema,
|
|
12
|
+
});
|
|
13
|
+
const threadChangeLabelSchema = v.object({
|
|
14
|
+
accounts: accountsSchema,
|
|
15
|
+
labelPath: marcoSchemas.string.required(),
|
|
16
|
+
});
|
|
4
17
|
export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
|
|
5
18
|
const thread = await tx.query.thread.where('id', threadId).one().run();
|
|
6
19
|
if (!thread) {
|
|
@@ -70,8 +83,8 @@ export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
|
|
|
70
83
|
labelIdList: buildLabelIdList([targetLabel.id]),
|
|
71
84
|
});
|
|
72
85
|
};
|
|
73
|
-
export const
|
|
74
|
-
addLabel: async (tx, args) => {
|
|
86
|
+
export const threadMutators = {
|
|
87
|
+
addLabel: defineMutator(threadChangeLabelSchema, async ({ tx, args }) => {
|
|
75
88
|
for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
|
|
76
89
|
const label = await tx.query.accountLabel.where('accountId', accountId).where('path', args.labelPath).one().run();
|
|
77
90
|
if (!label) {
|
|
@@ -124,8 +137,8 @@ export const createThreadMutators = (_authData) => ({
|
|
|
124
137
|
});
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
|
-
},
|
|
128
|
-
delete: async (tx, args) => {
|
|
140
|
+
}),
|
|
141
|
+
delete: defineMutator(baseThreadSchema, async ({ tx, args }) => {
|
|
129
142
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
130
143
|
for (const threadId of threadIds) {
|
|
131
144
|
const thread = await tx.query.thread.where('id', threadId).one().run();
|
|
@@ -146,8 +159,8 @@ export const createThreadMutators = (_authData) => ({
|
|
|
146
159
|
}
|
|
147
160
|
}
|
|
148
161
|
}
|
|
149
|
-
},
|
|
150
|
-
removeLabel: async (tx, args) => {
|
|
162
|
+
}),
|
|
163
|
+
removeLabel: defineMutator(threadChangeLabelSchema, async ({ tx, args }) => {
|
|
151
164
|
for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
|
|
152
165
|
const label = await tx.query.accountLabel.where('accountId', accountId).where('path', args.labelPath).one().run();
|
|
153
166
|
if (!label) {
|
|
@@ -191,30 +204,36 @@ export const createThreadMutators = (_authData) => ({
|
|
|
191
204
|
]);
|
|
192
205
|
}
|
|
193
206
|
}
|
|
194
|
-
},
|
|
195
|
-
setArchive: async (tx, args) => {
|
|
207
|
+
}),
|
|
208
|
+
setArchive: defineMutator(baseThreadSchema, async ({ tx, args }) => {
|
|
196
209
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
197
210
|
for (const threadId of threadIds) {
|
|
198
211
|
await setSystemLabel(tx, threadId, 'ARCHIVE');
|
|
199
212
|
}
|
|
200
213
|
}
|
|
201
|
-
},
|
|
202
|
-
setFlagged:
|
|
214
|
+
}),
|
|
215
|
+
setFlagged: defineMutator(v.object({
|
|
216
|
+
accounts: accountsSchema,
|
|
217
|
+
flagged: v.nonOptional(v.boolean()),
|
|
218
|
+
}), async ({ tx, args }) => {
|
|
203
219
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
204
220
|
await Promise.all(threadIds.map(threadId => tx.mutate.thread.update({
|
|
205
221
|
flagged: args.flagged,
|
|
206
222
|
id: threadId,
|
|
207
223
|
})));
|
|
208
224
|
}
|
|
209
|
-
},
|
|
210
|
-
setInbox: async (tx, args) => {
|
|
225
|
+
}),
|
|
226
|
+
setInbox: defineMutator(baseThreadSchema, async ({ tx, args }) => {
|
|
211
227
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
212
228
|
for (const threadId of threadIds) {
|
|
213
229
|
await setSystemLabel(tx, threadId, 'INBOX');
|
|
214
230
|
}
|
|
215
231
|
}
|
|
216
|
-
},
|
|
217
|
-
setSeen:
|
|
232
|
+
}),
|
|
233
|
+
setSeen: defineMutator(v.object({
|
|
234
|
+
accounts: accountsSchema,
|
|
235
|
+
seen: v.boolean(),
|
|
236
|
+
}), async ({ tx, args }) => {
|
|
218
237
|
const allThreadIds = Object.values(args.accounts).flatMap(x => x.threadIds);
|
|
219
238
|
const threads = await tx.query.thread.where('id', 'IN', allThreadIds).run();
|
|
220
239
|
const labelCounts = new Map();
|
|
@@ -239,19 +258,19 @@ export const createThreadMutators = (_authData) => ({
|
|
|
239
258
|
id: threadId,
|
|
240
259
|
seen: args.seen,
|
|
241
260
|
})));
|
|
242
|
-
},
|
|
243
|
-
setSpam: async (tx, args) => {
|
|
261
|
+
}),
|
|
262
|
+
setSpam: defineMutator(baseThreadSchema, async ({ tx, args }) => {
|
|
244
263
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
245
264
|
for (const threadId of threadIds) {
|
|
246
265
|
await setSystemLabel(tx, threadId, 'SPAM');
|
|
247
266
|
}
|
|
248
267
|
}
|
|
249
|
-
},
|
|
250
|
-
setTrash: async (tx, args) => {
|
|
268
|
+
}),
|
|
269
|
+
setTrash: defineMutator(baseThreadSchema, async ({ tx, args }) => {
|
|
251
270
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
252
271
|
for (const threadId of threadIds) {
|
|
253
272
|
await setSystemLabel(tx, threadId, 'TRASH');
|
|
254
273
|
}
|
|
255
274
|
}
|
|
256
|
-
},
|
|
257
|
-
}
|
|
275
|
+
}),
|
|
276
|
+
};
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
export declare const userMutators: {
|
|
2
|
+
deleteSettingsPushNotificationToken: import("@rocicorp/zero").MutatorDefinition<{
|
|
3
|
+
id: string;
|
|
4
|
+
token: string;
|
|
5
|
+
}, {
|
|
6
|
+
id: string;
|
|
7
|
+
token: string;
|
|
8
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
9
|
+
setSettingsName: import("@rocicorp/zero").MutatorDefinition<{
|
|
10
|
+
id: string;
|
|
11
|
+
name: string | null;
|
|
12
|
+
}, {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string | null;
|
|
15
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
16
|
+
setSettingsPushNotificationToken: import("@rocicorp/zero").MutatorDefinition<{
|
|
17
|
+
id: string;
|
|
18
|
+
pushNotificationToken: {
|
|
19
|
+
createdAt: number;
|
|
20
|
+
id: string;
|
|
21
|
+
token: string;
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
id: string;
|
|
25
|
+
pushNotificationToken: {
|
|
26
|
+
createdAt: number;
|
|
27
|
+
id: string;
|
|
28
|
+
token: string;
|
|
29
|
+
};
|
|
30
|
+
}, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
|
|
31
|
+
};
|
|
4
32
|
//# sourceMappingURL=userMutators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/userMutators/userMutators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"userMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/userMutators/userMutators.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CxB,CAAA"}
|
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { marcoSchemas } from '../../../schemas';
|
|
3
|
+
import { defineMutator } from '../../../zero/mutators/defineMutator';
|
|
4
|
+
const userPushNotificationTokenSchema = v.object({
|
|
5
|
+
createdAt: marcoSchemas.number.positiveInteger(),
|
|
6
|
+
id: marcoSchemas.string.required(),
|
|
7
|
+
token: marcoSchemas.string.required(),
|
|
8
|
+
});
|
|
9
|
+
export const userMutators = {
|
|
10
|
+
deleteSettingsPushNotificationToken: defineMutator(v.object({
|
|
11
|
+
id: marcoSchemas.string.required(),
|
|
12
|
+
token: marcoSchemas.string.required(),
|
|
13
|
+
}), async ({ tx, args }) => {
|
|
3
14
|
await tx.mutate.userPushNotificationToken.delete({
|
|
4
15
|
id: args.id,
|
|
5
16
|
});
|
|
6
|
-
},
|
|
7
|
-
setSettingsName:
|
|
17
|
+
}),
|
|
18
|
+
setSettingsName: defineMutator(v.object({
|
|
19
|
+
id: marcoSchemas.string.required(),
|
|
20
|
+
name: marcoSchemas.string.nullable(),
|
|
21
|
+
}), async ({ tx, args }) => {
|
|
8
22
|
await tx.mutate.user.update({
|
|
9
23
|
id: args.id,
|
|
10
24
|
name: args.name,
|
|
11
25
|
});
|
|
12
|
-
},
|
|
13
|
-
setSettingsPushNotificationToken:
|
|
26
|
+
}),
|
|
27
|
+
setSettingsPushNotificationToken: defineMutator(v.object({
|
|
28
|
+
id: marcoSchemas.string.required(),
|
|
29
|
+
pushNotificationToken: userPushNotificationTokenSchema,
|
|
30
|
+
}), async ({ tx, args }) => {
|
|
14
31
|
const existing = await tx.query.userPushNotificationToken
|
|
15
32
|
.where('userId', args.id)
|
|
16
33
|
.where('token', args.pushNotificationToken.token)
|
|
@@ -24,5 +41,5 @@ export const createUserMutators = (_authData) => ({
|
|
|
24
41
|
userId: args.id,
|
|
25
42
|
});
|
|
26
43
|
}
|
|
27
|
-
},
|
|
28
|
-
}
|
|
44
|
+
}),
|
|
45
|
+
};
|