@marcoappio/marco-config 2.0.491 → 2.0.492
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 +1 -1
- package/dist/zero/mutators/accountMutators/accountMutators.d.ts +1 -5
- package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +1 -1
- package/dist/zero/mutators/accountMutators/accountMutators.js +1 -10
- package/dist/zero/mutators/accountMutators/accountMutators.test.js +4 -22
- package/dist/zero/mutators/draftMutators/draftMutators.d.ts +1 -5
- package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +1 -1
- package/dist/zero/mutators/draftMutators/draftMutators.js +5 -16
- package/dist/zero/mutators/mutators.d.ts +3 -14
- package/dist/zero/mutators/mutators.d.ts.map +1 -1
- package/dist/zero/mutators/mutators.js +5 -5
- package/dist/zero/mutators/threadMutators/threadMutators.d.ts +1 -5
- package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +1 -1
- package/dist/zero/mutators/threadMutators/threadMutators.js +2 -11
- package/dist/zero/mutators/userMutators/userMutators.d.ts +1 -5
- package/dist/zero/mutators/userMutators/userMutators.d.ts.map +1 -1
- package/dist/zero/mutators/userMutators/userMutators.js +1 -4
- package/package.json +1 -1
package/dist/zero/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const marcoZero: {
|
|
2
|
-
readonly createMutators: (authData?: import("./mutators/mutators").AuthData
|
|
2
|
+
readonly createMutators: (authData?: import("./mutators/mutators").AuthData) => import("./mutators").MarcoZeroMutators;
|
|
3
3
|
readonly mutatorSchemas: {
|
|
4
4
|
readonly account: {
|
|
5
5
|
readonly createAccount: {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type * as v from 'valibot';
|
|
2
1
|
import { type AuthData, type HandlerMap } from '../../../types';
|
|
3
2
|
import type { ZeroMutatorSchemas } from '../../../zero/mutatorSchemas';
|
|
4
|
-
export
|
|
5
|
-
[K in keyof ZeroMutatorSchemas['account']]?: (args: v.InferOutput<ZeroMutatorSchemas['account'][K]['delta']>) => Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const createAccountMutators: (authData: AuthData | undefined, callbacks?: AccountMutatorCallbacks) => HandlerMap<ZeroMutatorSchemas["account"]>;
|
|
3
|
+
export declare const createAccountMutators: (authData: AuthData | undefined) => HandlerMap<ZeroMutatorSchemas["account"]>;
|
|
8
4
|
//# sourceMappingURL=accountMutators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/accountMutators/accountMutators.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"accountMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/accountMutators/accountMutators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAiB,MAAM,qBAAqB,CAAA;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAE3E,eAAO,MAAM,qBAAqB,aAAc,QAAQ,GAAG,SAAS,KAAG,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,CA2G7G,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MutationError } from '../../../types';
|
|
2
|
-
export const createAccountMutators = (authData
|
|
2
|
+
export const createAccountMutators = (authData) => ({
|
|
3
3
|
createAccount: async (tx, args) => {
|
|
4
4
|
if (!authData) {
|
|
5
5
|
throw new Error(MutationError.AUTHENTICATION_REQUIRED);
|
|
@@ -21,7 +21,6 @@ export const createAccountMutators = (authData, callbacks) => ({
|
|
|
21
21
|
isPrimary: true,
|
|
22
22
|
name: null,
|
|
23
23
|
});
|
|
24
|
-
callbacks?.createAccount?.(args);
|
|
25
24
|
},
|
|
26
25
|
createAlias: async (tx, args) => {
|
|
27
26
|
await tx.mutate.accountAlias.insert({
|
|
@@ -31,13 +30,11 @@ export const createAccountMutators = (authData, callbacks) => ({
|
|
|
31
30
|
isPrimary: false,
|
|
32
31
|
name: args.alias.name ?? null,
|
|
33
32
|
});
|
|
34
|
-
callbacks?.createAlias?.(args);
|
|
35
33
|
},
|
|
36
34
|
deleteAccount: async (tx, args) => {
|
|
37
35
|
await tx.mutate.account.delete({
|
|
38
36
|
id: args.id,
|
|
39
37
|
});
|
|
40
|
-
callbacks?.deleteAccount?.(args);
|
|
41
38
|
},
|
|
42
39
|
deleteAlias: async (tx, args) => {
|
|
43
40
|
const alias = await tx.query.accountAlias.where('id', args.aliasId).one().run();
|
|
@@ -64,14 +61,12 @@ export const createAccountMutators = (authData, callbacks) => ({
|
|
|
64
61
|
});
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
|
-
callbacks?.deleteAlias?.(args);
|
|
68
64
|
},
|
|
69
65
|
setAliasName: async (tx, args) => {
|
|
70
66
|
await tx.mutate.accountAlias.update({
|
|
71
67
|
id: args.aliasId,
|
|
72
68
|
name: args.displayName,
|
|
73
69
|
});
|
|
74
|
-
callbacks?.setAliasName?.(args);
|
|
75
70
|
},
|
|
76
71
|
setAliasPrimary: async (tx, args) => {
|
|
77
72
|
const aliases = await tx.query.accountAlias.where('accountId', args.accountId).run();
|
|
@@ -85,21 +80,18 @@ export const createAccountMutators = (authData, callbacks) => ({
|
|
|
85
80
|
id: args.accountId,
|
|
86
81
|
primaryAliasId: args.aliasId,
|
|
87
82
|
});
|
|
88
|
-
callbacks?.setAliasPrimary?.(args);
|
|
89
83
|
},
|
|
90
84
|
setConnectionConfigImapRaw: async (tx, args) => {
|
|
91
85
|
await tx.mutate.account.update({
|
|
92
86
|
id: args.id,
|
|
93
87
|
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
94
88
|
});
|
|
95
|
-
callbacks?.setConnectionConfigImapRaw?.(args);
|
|
96
89
|
},
|
|
97
90
|
setConnectionConfigOauth: async (tx, args) => {
|
|
98
91
|
await tx.mutate.account.update({
|
|
99
92
|
id: args.id,
|
|
100
93
|
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
101
94
|
});
|
|
102
|
-
callbacks?.setConnectionConfigOauth?.(args);
|
|
103
95
|
},
|
|
104
96
|
setSettings: async (tx, args) => {
|
|
105
97
|
await tx.mutate.account.update({
|
|
@@ -107,6 +99,5 @@ export const createAccountMutators = (authData, callbacks) => ({
|
|
|
107
99
|
displayName: args.displayName ? args.displayName : undefined,
|
|
108
100
|
id: args.id,
|
|
109
101
|
});
|
|
110
|
-
callbacks?.setSettings?.(args);
|
|
111
102
|
},
|
|
112
103
|
});
|
|
@@ -2,15 +2,10 @@ import { describe, expect, it, mock } from 'bun:test';
|
|
|
2
2
|
import { createMutators, ZeroMutatorValidationError } from '../mutators';
|
|
3
3
|
describe('accountMutators', () => {
|
|
4
4
|
describe('createAccount', () => {
|
|
5
|
-
it('creates an account
|
|
5
|
+
it('creates an account', async () => {
|
|
6
6
|
const accountInsert = mock(async () => { });
|
|
7
7
|
const accountAliasInsert = mock(async () => { });
|
|
8
|
-
const
|
|
9
|
-
const mutators = createMutators({ sub: 'test-user-id' }, {
|
|
10
|
-
account: {
|
|
11
|
-
createAccount: createAccountCallback,
|
|
12
|
-
},
|
|
13
|
-
});
|
|
8
|
+
const mutators = createMutators({ sub: 'test-user-id' });
|
|
14
9
|
const payload = {
|
|
15
10
|
aliasId: 'test-alias-id-1',
|
|
16
11
|
color: '#ff0000',
|
|
@@ -50,7 +45,6 @@ describe('accountMutators', () => {
|
|
|
50
45
|
isPrimary: true,
|
|
51
46
|
name: null,
|
|
52
47
|
});
|
|
53
|
-
expect(createAccountCallback).toHaveBeenCalledWith(payload);
|
|
54
48
|
expect(accountInsert.mock.invocationCallOrder[0]).toBeLessThan(accountAliasInsert.mock.invocationCallOrder[0]);
|
|
55
49
|
});
|
|
56
50
|
it('throws ZeroMutatorValidationError on invalid payloads', async () => {
|
|
@@ -69,12 +63,7 @@ describe('accountMutators', () => {
|
|
|
69
63
|
describe('createAlias', () => {
|
|
70
64
|
it('creates an alias', async () => {
|
|
71
65
|
const accountAliasInsert = mock(async () => { });
|
|
72
|
-
const
|
|
73
|
-
const mutators = createMutators({ sub: 'test-user-id' }, {
|
|
74
|
-
account: {
|
|
75
|
-
createAlias: createAliasCallback,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
66
|
+
const mutators = createMutators({ sub: 'test-user-id' });
|
|
78
67
|
const transaction = {
|
|
79
68
|
mutate: {
|
|
80
69
|
accountAlias: {
|
|
@@ -100,18 +89,12 @@ describe('accountMutators', () => {
|
|
|
100
89
|
isPrimary: false,
|
|
101
90
|
name: 'Work Email',
|
|
102
91
|
});
|
|
103
|
-
expect(createAliasCallback).toHaveBeenCalled();
|
|
104
92
|
});
|
|
105
93
|
});
|
|
106
94
|
describe('deleteAccount', () => {
|
|
107
95
|
it('deletes an account', async () => {
|
|
108
96
|
const accountDelete = mock(async () => { });
|
|
109
|
-
const
|
|
110
|
-
const mutators = createMutators({ sub: 'test-user-id' }, {
|
|
111
|
-
account: {
|
|
112
|
-
deleteAccount: deleteAccountCallback,
|
|
113
|
-
},
|
|
114
|
-
});
|
|
97
|
+
const mutators = createMutators({ sub: 'test-user-id' });
|
|
115
98
|
const transaction = {
|
|
116
99
|
mutate: {
|
|
117
100
|
account: {
|
|
@@ -128,7 +111,6 @@ describe('accountMutators', () => {
|
|
|
128
111
|
expect(accountDelete).toHaveBeenCalledWith({
|
|
129
112
|
id: 'test-account-id-1',
|
|
130
113
|
});
|
|
131
|
-
expect(deleteAccountCallback).toHaveBeenCalled();
|
|
132
114
|
});
|
|
133
115
|
});
|
|
134
116
|
describe('deleteAlias', () => {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type * as v from 'valibot';
|
|
2
1
|
import { type AuthData, type HandlerMap } from '../../../types';
|
|
3
2
|
import type { ZeroMutatorSchemas } from '../../../zero/mutatorSchemas';
|
|
4
|
-
export
|
|
5
|
-
[K in keyof ZeroMutatorSchemas['draft']]?: (args: v.InferOutput<ZeroMutatorSchemas['draft'][K]['delta']>) => Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const createDraftMutators: (authData: AuthData | undefined, callbacks?: DraftMutatorCallbacks) => HandlerMap<ZeroMutatorSchemas["draft"]>;
|
|
3
|
+
export declare const createDraftMutators: (authData: AuthData | undefined) => HandlerMap<ZeroMutatorSchemas["draft"]>;
|
|
8
4
|
//# sourceMappingURL=draftMutators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draftMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/draftMutators.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"draftMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/draftMutators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAiB,MAAM,qBAAqB,CAAA;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAE3E,eAAO,MAAM,mBAAmB,aAAc,QAAQ,GAAG,SAAS,KAAG,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAwJzG,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MutationError } from '../../../types';
|
|
2
2
|
import { stringPatch } from '../../../utils';
|
|
3
|
-
export const createDraftMutators = (authData
|
|
3
|
+
export const createDraftMutators = (authData) => ({
|
|
4
4
|
cancelSend: async (tx, args) => {
|
|
5
5
|
const draft = await tx.query.draft.where('id', args.id).one().run();
|
|
6
6
|
if (!draft) {
|
|
@@ -15,7 +15,6 @@ export const createDraftMutators = (authData, callbacks) => ({
|
|
|
15
15
|
status: 'DRAFT',
|
|
16
16
|
updatedAt: args.updatedAt,
|
|
17
17
|
});
|
|
18
|
-
callbacks?.cancelSend?.(args);
|
|
19
18
|
},
|
|
20
19
|
createAttachment: async (tx, args) => {
|
|
21
20
|
await tx.mutate.draftAttachment.insert({
|
|
@@ -30,7 +29,6 @@ export const createDraftMutators = (authData, callbacks) => ({
|
|
|
30
29
|
id: args.id,
|
|
31
30
|
updatedAt: args.updatedAt,
|
|
32
31
|
});
|
|
33
|
-
callbacks?.createAttachment?.(args);
|
|
34
32
|
},
|
|
35
33
|
createDraft: async (tx, args) => {
|
|
36
34
|
if (!authData) {
|
|
@@ -67,7 +65,6 @@ export const createDraftMutators = (authData, callbacks) => ({
|
|
|
67
65
|
totalSize: attachment.totalSize,
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
|
-
callbacks?.createDraft?.(args);
|
|
71
68
|
},
|
|
72
69
|
deleteAttachment: async (tx, args) => {
|
|
73
70
|
await tx.mutate.draftAttachment.delete({
|
|
@@ -77,13 +74,11 @@ export const createDraftMutators = (authData, callbacks) => ({
|
|
|
77
74
|
id: args.id,
|
|
78
75
|
updatedAt: args.updatedAt,
|
|
79
76
|
});
|
|
80
|
-
callbacks?.deleteAttachment?.(args);
|
|
81
77
|
},
|
|
82
78
|
deleteDraft: async (tx, args) => {
|
|
83
79
|
await tx.mutate.draft.delete({
|
|
84
80
|
id: args.id,
|
|
85
81
|
});
|
|
86
|
-
callbacks?.deleteDraft?.(args);
|
|
87
82
|
},
|
|
88
83
|
scheduleSend: async (tx, args) => {
|
|
89
84
|
if (args.kind === 'IMMEDIATE') {
|
|
@@ -102,24 +97,20 @@ export const createDraftMutators = (authData, callbacks) => ({
|
|
|
102
97
|
updatedAt: args.updatedAt,
|
|
103
98
|
});
|
|
104
99
|
}
|
|
105
|
-
callbacks?.scheduleSend?.(args);
|
|
106
100
|
},
|
|
107
101
|
setContent: async (tx, args) => {
|
|
108
102
|
const draft = await tx.query.draft.where('id', args.id).one().run();
|
|
109
103
|
if (!draft) {
|
|
110
104
|
throw new Error(MutationError.ENTITY_NOT_FOUND);
|
|
111
105
|
}
|
|
112
|
-
const currentContent = typeof draft.body?.content === 'string' ? draft.body.content : '';
|
|
113
|
-
const updatedBody = {
|
|
114
|
-
...draft.body,
|
|
115
|
-
content: stringPatch.apply(currentContent, args.patch),
|
|
116
|
-
};
|
|
117
106
|
await tx.mutate.draft.update({
|
|
118
|
-
body:
|
|
107
|
+
body: {
|
|
108
|
+
...draft.body,
|
|
109
|
+
content: stringPatch.apply(typeof draft.body?.content === 'string' ? draft.body.content : '', args.patch),
|
|
110
|
+
},
|
|
119
111
|
id: args.id,
|
|
120
112
|
updatedAt: args.updatedAt,
|
|
121
113
|
});
|
|
122
|
-
callbacks?.setContent?.(args);
|
|
123
114
|
},
|
|
124
115
|
setEnvelope: async (tx, args) => {
|
|
125
116
|
const draft = await tx.query.draft.where('id', args.id).one().run();
|
|
@@ -137,7 +128,6 @@ export const createDraftMutators = (authData, callbacks) => ({
|
|
|
137
128
|
subject: args.envelope.subject,
|
|
138
129
|
updatedAt: args.updatedAt,
|
|
139
130
|
});
|
|
140
|
-
callbacks?.setEnvelope?.(args);
|
|
141
131
|
},
|
|
142
132
|
setFrom: async (tx, args) => {
|
|
143
133
|
await tx.mutate.draft.update({
|
|
@@ -148,6 +138,5 @@ export const createDraftMutators = (authData, callbacks) => ({
|
|
|
148
138
|
id: args.id,
|
|
149
139
|
updatedAt: args.updatedAt,
|
|
150
140
|
});
|
|
151
|
-
callbacks?.setFrom?.(args);
|
|
152
141
|
},
|
|
153
142
|
});
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import type { MutatorMap } from '../../types';
|
|
3
3
|
import { type ZeroMutatorSchemas } from '../../zero/mutatorSchemas';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { type ThreadMutatorCallbacks } from './threadMutators';
|
|
7
|
-
import { type UserMutatorCallbacks } from './userMutators';
|
|
8
|
-
export type MutatorCallbacks = {
|
|
9
|
-
account?: AccountMutatorCallbacks;
|
|
10
|
-
draft?: DraftMutatorCallbacks;
|
|
11
|
-
thread?: ThreadMutatorCallbacks;
|
|
12
|
-
user?: UserMutatorCallbacks;
|
|
4
|
+
export type AuthData = {
|
|
5
|
+
sub: string;
|
|
13
6
|
};
|
|
14
7
|
export declare class ZeroMutatorValidationError extends Error {
|
|
15
8
|
readonly issues: ReturnType<typeof v.flatten>;
|
|
@@ -21,9 +14,5 @@ export type MarcoZeroMutators = {
|
|
|
21
14
|
thread: MutatorMap<ZeroMutatorSchemas['thread']>;
|
|
22
15
|
user: MutatorMap<ZeroMutatorSchemas['user']>;
|
|
23
16
|
};
|
|
24
|
-
export declare const createMutators: (authData?: AuthData
|
|
25
|
-
export type { AccountMutatorCallbacks, DraftMutatorCallbacks, ThreadMutatorCallbacks, UserMutatorCallbacks };
|
|
26
|
-
export type AuthData = {
|
|
27
|
-
sub: string;
|
|
28
|
-
};
|
|
17
|
+
export declare const createMutators: (authData?: AuthData) => MarcoZeroMutators;
|
|
29
18
|
//# sourceMappingURL=mutators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutators.d.ts","sourceRoot":"","sources":["../../../src/zero/mutators/mutators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAkD,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"mutators.d.ts","sourceRoot":"","sources":["../../../src/zero/mutators/mutators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAkD,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,mCAAmC,CAAA;AAQ/F,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AA8BD,qBAAa,0BAA2B,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;gBAApC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;CAG1D;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAA;IAClD,KAAK,EAAE,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9C,MAAM,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAA;IAChD,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,cAAc,cAAe,QAAQ,KAAG,iBAKnD,CAAA"}
|
|
@@ -31,9 +31,9 @@ export class ZeroMutatorValidationError extends Error {
|
|
|
31
31
|
this.issues = issues;
|
|
32
32
|
}
|
|
33
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
|
|
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)),
|
|
39
39
|
});
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { Transaction } from '@rocicorp/zero';
|
|
2
|
-
import type * as v from 'valibot';
|
|
3
2
|
import type { LabelSpecialUse } from '../../../types';
|
|
4
3
|
import { type AuthData, type HandlerMap } from '../../../types';
|
|
5
4
|
import type { ZeroMutatorSchemas } from '../../../zero/mutatorSchemas';
|
|
6
5
|
import type { MarcoZeroSchema } from '../../../zero/schema';
|
|
7
|
-
export type ThreadMutatorCallbacks = {
|
|
8
|
-
[K in keyof ZeroMutatorSchemas['thread']]?: (args: v.InferOutput<ZeroMutatorSchemas['thread'][K]['delta']>) => Promise<void>;
|
|
9
|
-
};
|
|
10
6
|
export declare const setSystemLabel: (tx: Transaction<MarcoZeroSchema>, threadId: string, targetSpecialUse: LabelSpecialUse) => Promise<void>;
|
|
11
|
-
export declare const createThreadMutators: (_authData: AuthData | undefined
|
|
7
|
+
export declare const createThreadMutators: (_authData: AuthData | undefined) => HandlerMap<ZeroMutatorSchemas["thread"]>;
|
|
12
8
|
//# 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;AAEjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAiB,MAAM,qBAAqB,CAAA;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE,eAAO,MAAM,cAAc,OACrB,WAAW,CAAC,eAAe,CAAC,YACtB,MAAM,oBACE,eAAe,KAChC,OAAO,CAAC,IAAI,CAyFd,CAAA;AAED,eAAO,MAAM,oBAAoB,cAAe,QAAQ,GAAG,SAAS,KAAG,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CA0O5G,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MutationError } from '../../../types';
|
|
2
2
|
import { threadsUtils } from '../../../utils/threads';
|
|
3
|
-
const buildLabelIdList = (
|
|
3
|
+
const buildLabelIdList = (x) => (x.length === 0 ? '' : ` ${[...new Set(x)].join(' ')} `);
|
|
4
4
|
export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
|
|
5
5
|
const thread = await tx.query.thread.where('id', threadId).one().run();
|
|
6
6
|
if (!thread) {
|
|
@@ -70,7 +70,7 @@ export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
|
|
|
70
70
|
labelIdList: buildLabelIdList([targetLabel.id]),
|
|
71
71
|
});
|
|
72
72
|
};
|
|
73
|
-
export const createThreadMutators = (_authData
|
|
73
|
+
export const createThreadMutators = (_authData) => ({
|
|
74
74
|
addLabel: async (tx, args) => {
|
|
75
75
|
for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
|
|
76
76
|
const label = await tx.query.accountLabel.where('accountId', accountId).where('path', args.labelPath).one().run();
|
|
@@ -124,7 +124,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
callbacks?.addLabel?.(args);
|
|
128
127
|
},
|
|
129
128
|
delete: async (tx, args) => {
|
|
130
129
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
@@ -147,7 +146,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
|
-
callbacks?.delete?.(args);
|
|
151
149
|
},
|
|
152
150
|
removeLabel: async (tx, args) => {
|
|
153
151
|
for (const [accountId, { threadIds }] of Object.entries(args.accounts)) {
|
|
@@ -193,7 +191,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
193
191
|
]);
|
|
194
192
|
}
|
|
195
193
|
}
|
|
196
|
-
callbacks?.removeLabel?.(args);
|
|
197
194
|
},
|
|
198
195
|
setArchive: async (tx, args) => {
|
|
199
196
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
@@ -201,7 +198,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
201
198
|
await setSystemLabel(tx, threadId, 'ARCHIVE');
|
|
202
199
|
}
|
|
203
200
|
}
|
|
204
|
-
callbacks?.setArchive?.(args);
|
|
205
201
|
},
|
|
206
202
|
setFlagged: async (tx, args) => {
|
|
207
203
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
@@ -210,7 +206,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
210
206
|
id: threadId,
|
|
211
207
|
})));
|
|
212
208
|
}
|
|
213
|
-
callbacks?.setFlagged?.(args);
|
|
214
209
|
},
|
|
215
210
|
setInbox: async (tx, args) => {
|
|
216
211
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
@@ -218,7 +213,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
218
213
|
await setSystemLabel(tx, threadId, 'INBOX');
|
|
219
214
|
}
|
|
220
215
|
}
|
|
221
|
-
callbacks?.setInbox?.(args);
|
|
222
216
|
},
|
|
223
217
|
setSeen: async (tx, args) => {
|
|
224
218
|
const allThreadIds = Object.values(args.accounts).flatMap(x => x.threadIds);
|
|
@@ -245,7 +239,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
245
239
|
id: threadId,
|
|
246
240
|
seen: args.seen,
|
|
247
241
|
})));
|
|
248
|
-
callbacks?.setSeen?.(args);
|
|
249
242
|
},
|
|
250
243
|
setSpam: async (tx, args) => {
|
|
251
244
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
@@ -253,7 +246,6 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
253
246
|
await setSystemLabel(tx, threadId, 'SPAM');
|
|
254
247
|
}
|
|
255
248
|
}
|
|
256
|
-
callbacks?.setSpam?.(args);
|
|
257
249
|
},
|
|
258
250
|
setTrash: async (tx, args) => {
|
|
259
251
|
for (const [, { threadIds }] of Object.entries(args.accounts)) {
|
|
@@ -261,6 +253,5 @@ export const createThreadMutators = (_authData, callbacks) => ({
|
|
|
261
253
|
await setSystemLabel(tx, threadId, 'TRASH');
|
|
262
254
|
}
|
|
263
255
|
}
|
|
264
|
-
callbacks?.setTrash?.(args);
|
|
265
256
|
},
|
|
266
257
|
});
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type * as v from 'valibot';
|
|
2
1
|
import type { AuthData, HandlerMap } from '../../../types';
|
|
3
2
|
import type { ZeroMutatorSchemas } from '../../../zero/mutatorSchemas';
|
|
4
|
-
export
|
|
5
|
-
[K in keyof ZeroMutatorSchemas['user']]?: (args: v.InferOutput<ZeroMutatorSchemas['user'][K]['delta']>) => Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const createUserMutators: (_authData: AuthData | undefined, callbacks?: UserMutatorCallbacks) => HandlerMap<ZeroMutatorSchemas["user"]>;
|
|
3
|
+
export declare const createUserMutators: (_authData: AuthData | undefined) => HandlerMap<ZeroMutatorSchemas["user"]>;
|
|
8
4
|
//# sourceMappingURL=userMutators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/userMutators/userMutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"userMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/userMutators/userMutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAE3E,eAAO,MAAM,kBAAkB,cAAe,QAAQ,GAAG,SAAS,KAAG,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CA4BxG,CAAA"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
export const createUserMutators = (_authData
|
|
1
|
+
export const createUserMutators = (_authData) => ({
|
|
2
2
|
deleteSettingsPushNotificationToken: async (tx, args) => {
|
|
3
3
|
await tx.mutate.userPushNotificationToken.delete({
|
|
4
4
|
id: args.id,
|
|
5
5
|
});
|
|
6
|
-
callbacks?.deleteSettingsPushNotificationToken?.(args);
|
|
7
6
|
},
|
|
8
7
|
setSettingsName: async (tx, args) => {
|
|
9
8
|
await tx.mutate.user.update({
|
|
10
9
|
id: args.id,
|
|
11
10
|
name: args.name,
|
|
12
11
|
});
|
|
13
|
-
callbacks?.setSettingsName?.(args);
|
|
14
12
|
},
|
|
15
13
|
setSettingsPushNotificationToken: async (tx, args) => {
|
|
16
14
|
const existing = await tx.query.userPushNotificationToken
|
|
@@ -25,7 +23,6 @@ export const createUserMutators = (_authData, callbacks) => ({
|
|
|
25
23
|
token: args.pushNotificationToken.token,
|
|
26
24
|
userId: args.id,
|
|
27
25
|
});
|
|
28
|
-
callbacks?.setSettingsPushNotificationToken?.(args);
|
|
29
26
|
}
|
|
30
27
|
},
|
|
31
28
|
});
|