@marcoappio/marco-config 2.0.508 → 2.0.509
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types/Zero.d.ts +0 -17
- package/dist/types/Zero.d.ts.map +1 -1
- package/dist/zero/index.d.ts +2903 -8808
- package/dist/zero/index.d.ts.map +1 -1
- package/dist/zero/index.js +6 -17
- package/dist/zero/{queries/getThreadList.d.ts → mutators.d.ts} +572 -169
- package/dist/zero/{queries/getThreads.d.ts.map → mutators.d.ts.map} +1 -1
- package/dist/zero/mutators.js +659 -0
- package/dist/zero/mutators.test.d.ts +2 -0
- package/dist/zero/mutators.test.d.ts.map +1 -0
- package/dist/zero/mutators.test.js +603 -0
- package/dist/zero/{queries/getThreads.d.ts → queries.d.ts} +481 -196
- package/dist/zero/{queries/getThread.d.ts.map → queries.d.ts.map} +1 -1
- package/dist/zero/queries.js +168 -0
- package/dist/zero/schema.d.ts +138 -133
- package/dist/zero/schema.d.ts.map +1 -1
- package/dist/zero/schema.js +1 -1
- package/package.json +3 -3
- 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.d.ts +0 -4
- package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +0 -1
- package/dist/zero/mutators/accountMutators/accountMutators.js +0 -103
- 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/accountMutators/index.d.ts +0 -2
- package/dist/zero/mutators/accountMutators/index.d.ts.map +0 -1
- package/dist/zero/mutators/accountMutators/index.js +0 -1
- package/dist/zero/mutators/draftMutators/draftMutators.d.ts +0 -4
- package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +0 -1
- package/dist/zero/mutators/draftMutators/draftMutators.js +0 -142
- 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/draftMutators/index.d.ts +0 -2
- package/dist/zero/mutators/draftMutators/index.d.ts.map +0 -1
- package/dist/zero/mutators/draftMutators/index.js +0 -1
- package/dist/zero/mutators/index.d.ts +0 -3
- package/dist/zero/mutators/index.d.ts.map +0 -1
- package/dist/zero/mutators/index.js +0 -1
- package/dist/zero/mutators/mutators.d.ts +0 -18
- package/dist/zero/mutators/mutators.d.ts.map +0 -1
- package/dist/zero/mutators/mutators.js +0 -39
- package/dist/zero/mutators/threadMutators/index.d.ts +0 -2
- package/dist/zero/mutators/threadMutators/index.d.ts.map +0 -1
- package/dist/zero/mutators/threadMutators/index.js +0 -1
- package/dist/zero/mutators/threadMutators/threadMutators.d.ts +0 -8
- package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +0 -1
- package/dist/zero/mutators/threadMutators/threadMutators.js +0 -257
- 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/index.d.ts +0 -2
- package/dist/zero/mutators/userMutators/index.d.ts.map +0 -1
- package/dist/zero/mutators/userMutators/index.js +0 -1
- package/dist/zero/mutators/userMutators/userMutators.d.ts +0 -4
- package/dist/zero/mutators/userMutators/userMutators.d.ts.map +0 -1
- package/dist/zero/mutators/userMutators/userMutators.js +0 -28
- 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
- package/dist/zero/queries/getAccounts.d.ts +0 -1060
- package/dist/zero/queries/getAccounts.d.ts.map +0 -1
- package/dist/zero/queries/getAccounts.js +0 -3
- package/dist/zero/queries/getContacts.d.ts +0 -1040
- package/dist/zero/queries/getContacts.d.ts.map +0 -1
- package/dist/zero/queries/getContacts.js +0 -37
- package/dist/zero/queries/getDrafts.d.ts +0 -1061
- package/dist/zero/queries/getDrafts.d.ts.map +0 -1
- package/dist/zero/queries/getDrafts.js +0 -24
- package/dist/zero/queries/getThread.d.ts +0 -1072
- package/dist/zero/queries/getThread.js +0 -14
- package/dist/zero/queries/getThreadByMessageId.d.ts +0 -1056
- package/dist/zero/queries/getThreadByMessageId.d.ts.map +0 -1
- package/dist/zero/queries/getThreadByMessageId.js +0 -13
- package/dist/zero/queries/getThreadList.d.ts.map +0 -1
- package/dist/zero/queries/getThreadList.js +0 -57
- package/dist/zero/queries/getThreads.js +0 -59
- package/dist/zero/queries/getUser.d.ts +0 -1074
- package/dist/zero/queries/getUser.d.ts.map +0 -1
- package/dist/zero/queries/getUser.js +0 -7
- package/dist/zero/queries/index.d.ts +0 -1032
- package/dist/zero/queries/index.d.ts.map +0 -1
- package/dist/zero/queries/index.js +0 -11
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { MutationError } from '../../../types';
|
|
2
|
-
export const createAccountMutators = (authData) => ({
|
|
3
|
-
createAccount: async (tx, args) => {
|
|
4
|
-
if (!authData) {
|
|
5
|
-
throw new Error(MutationError.AUTHENTICATION_REQUIRED);
|
|
6
|
-
}
|
|
7
|
-
await tx.mutate.account.insert({
|
|
8
|
-
color: args.color,
|
|
9
|
-
displayName: null,
|
|
10
|
-
id: args.id,
|
|
11
|
-
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
12
|
-
mailProcessedCount: 0,
|
|
13
|
-
mailTotalCount: 0,
|
|
14
|
-
primaryAliasId: args.aliasId,
|
|
15
|
-
userId: authData.sub,
|
|
16
|
-
});
|
|
17
|
-
await tx.mutate.accountAlias.insert({
|
|
18
|
-
accountId: args.id,
|
|
19
|
-
emailAddress: args.emailAddress,
|
|
20
|
-
id: args.aliasId,
|
|
21
|
-
isPrimary: true,
|
|
22
|
-
name: null,
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
createAlias: async (tx, args) => {
|
|
26
|
-
await tx.mutate.accountAlias.insert({
|
|
27
|
-
accountId: args.accountId,
|
|
28
|
-
emailAddress: args.alias.emailAddress,
|
|
29
|
-
id: args.alias.id,
|
|
30
|
-
isPrimary: false,
|
|
31
|
-
name: args.alias.name ?? null,
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
deleteAccount: async (tx, args) => {
|
|
35
|
-
await tx.mutate.account.delete({
|
|
36
|
-
id: args.id,
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
deleteAlias: async (tx, args) => {
|
|
40
|
-
const alias = await tx.query.accountAlias.where('id', args.aliasId).one().run();
|
|
41
|
-
await tx.mutate.accountAlias.delete({
|
|
42
|
-
id: args.aliasId,
|
|
43
|
-
});
|
|
44
|
-
if (alias?.isPrimary) {
|
|
45
|
-
const remainingAliases = await tx.query.accountAlias.where('accountId', args.accountId).run();
|
|
46
|
-
if (remainingAliases.length > 0) {
|
|
47
|
-
const newPrimaryAlias = remainingAliases[0];
|
|
48
|
-
await tx.mutate.accountAlias.update({
|
|
49
|
-
id: newPrimaryAlias.id,
|
|
50
|
-
isPrimary: true,
|
|
51
|
-
});
|
|
52
|
-
await tx.mutate.account.update({
|
|
53
|
-
id: args.accountId,
|
|
54
|
-
primaryAliasId: newPrimaryAlias.id,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
await tx.mutate.account.update({
|
|
59
|
-
id: args.accountId,
|
|
60
|
-
primaryAliasId: null,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
setAliasName: async (tx, args) => {
|
|
66
|
-
await tx.mutate.accountAlias.update({
|
|
67
|
-
id: args.aliasId,
|
|
68
|
-
name: args.displayName,
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
setAliasPrimary: async (tx, args) => {
|
|
72
|
-
const aliases = await tx.query.accountAlias.where('accountId', args.accountId).run();
|
|
73
|
-
for (const alias of aliases) {
|
|
74
|
-
await tx.mutate.accountAlias.update({
|
|
75
|
-
id: alias.id,
|
|
76
|
-
isPrimary: alias.id === args.aliasId,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
await tx.mutate.account.update({
|
|
80
|
-
id: args.accountId,
|
|
81
|
-
primaryAliasId: args.aliasId,
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
setConnectionConfigImapRaw: async (tx, args) => {
|
|
85
|
-
await tx.mutate.account.update({
|
|
86
|
-
id: args.id,
|
|
87
|
-
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
setConnectionConfigOauth: async (tx, args) => {
|
|
91
|
-
await tx.mutate.account.update({
|
|
92
|
-
id: args.id,
|
|
93
|
-
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
setSettings: async (tx, args) => {
|
|
97
|
-
await tx.mutate.account.update({
|
|
98
|
-
color: args.color ? args.color : undefined,
|
|
99
|
-
displayName: args.displayName ? args.displayName : undefined,
|
|
100
|
-
id: args.id,
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accountMutators.test.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/accountMutators/accountMutators.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, mock } from 'bun:test';
|
|
2
|
-
import { createMutators, ZeroMutatorValidationError } from '../mutators';
|
|
3
|
-
describe('accountMutators', () => {
|
|
4
|
-
describe('createAccount', () => {
|
|
5
|
-
it('creates an account', async () => {
|
|
6
|
-
const accountInsert = mock(async () => { });
|
|
7
|
-
const accountAliasInsert = mock(async () => { });
|
|
8
|
-
const mutators = createMutators({ sub: 'test-user-id' });
|
|
9
|
-
const payload = {
|
|
10
|
-
aliasId: 'test-alias-id-1',
|
|
11
|
-
color: '#ff0000',
|
|
12
|
-
emailAddress: 'user@example.com',
|
|
13
|
-
id: 'test-account-id-1',
|
|
14
|
-
};
|
|
15
|
-
const transaction = {
|
|
16
|
-
mutate: {
|
|
17
|
-
account: {
|
|
18
|
-
delete: mock(async () => { }),
|
|
19
|
-
insert: accountInsert,
|
|
20
|
-
update: mock(async () => { }),
|
|
21
|
-
},
|
|
22
|
-
accountAlias: {
|
|
23
|
-
delete: mock(async () => { }),
|
|
24
|
-
insert: accountAliasInsert,
|
|
25
|
-
update: mock(async () => { }),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
query: {},
|
|
29
|
-
};
|
|
30
|
-
await mutators.account.createAccount(transaction, payload);
|
|
31
|
-
expect(accountInsert).toHaveBeenCalledWith({
|
|
32
|
-
color: payload.color,
|
|
33
|
-
displayName: null,
|
|
34
|
-
id: payload.id,
|
|
35
|
-
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
36
|
-
mailProcessedCount: 0,
|
|
37
|
-
mailTotalCount: 0,
|
|
38
|
-
primaryAliasId: payload.aliasId,
|
|
39
|
-
userId: 'test-user-id',
|
|
40
|
-
});
|
|
41
|
-
expect(accountAliasInsert).toHaveBeenCalledWith({
|
|
42
|
-
accountId: payload.id,
|
|
43
|
-
emailAddress: payload.emailAddress,
|
|
44
|
-
id: payload.aliasId,
|
|
45
|
-
isPrimary: true,
|
|
46
|
-
name: null,
|
|
47
|
-
});
|
|
48
|
-
expect(accountInsert.mock.invocationCallOrder[0]).toBeLessThan(accountAliasInsert.mock.invocationCallOrder[0]);
|
|
49
|
-
});
|
|
50
|
-
it('throws ZeroMutatorValidationError on invalid payloads', async () => {
|
|
51
|
-
const mutators = createMutators({ sub: 'test-user-id' });
|
|
52
|
-
await expect(mutators.account.createAccount({
|
|
53
|
-
mutate: {},
|
|
54
|
-
query: {},
|
|
55
|
-
}, {
|
|
56
|
-
aliasId: 'test-alias-id-1',
|
|
57
|
-
color: 'blue',
|
|
58
|
-
emailAddress: 'invalid-email',
|
|
59
|
-
id: 'test-account-id-1',
|
|
60
|
-
})).rejects.toBeInstanceOf(ZeroMutatorValidationError);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
describe('createAlias', () => {
|
|
64
|
-
it('creates an alias', async () => {
|
|
65
|
-
const accountAliasInsert = mock(async () => { });
|
|
66
|
-
const mutators = createMutators({ sub: 'test-user-id' });
|
|
67
|
-
const transaction = {
|
|
68
|
-
mutate: {
|
|
69
|
-
accountAlias: {
|
|
70
|
-
delete: mock(async () => { }),
|
|
71
|
-
insert: accountAliasInsert,
|
|
72
|
-
update: mock(async () => { }),
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
query: {},
|
|
76
|
-
};
|
|
77
|
-
await mutators.account.createAlias(transaction, {
|
|
78
|
-
accountId: 'test-account-id-1',
|
|
79
|
-
alias: {
|
|
80
|
-
emailAddress: 'alias@example.com',
|
|
81
|
-
id: 'test-alias-id-2',
|
|
82
|
-
name: 'Work Email',
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
expect(accountAliasInsert).toHaveBeenCalledWith({
|
|
86
|
-
accountId: 'test-account-id-1',
|
|
87
|
-
emailAddress: 'alias@example.com',
|
|
88
|
-
id: 'test-alias-id-2',
|
|
89
|
-
isPrimary: false,
|
|
90
|
-
name: 'Work Email',
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe('deleteAccount', () => {
|
|
95
|
-
it('deletes an account', async () => {
|
|
96
|
-
const accountDelete = mock(async () => { });
|
|
97
|
-
const mutators = createMutators({ sub: 'test-user-id' });
|
|
98
|
-
const transaction = {
|
|
99
|
-
mutate: {
|
|
100
|
-
account: {
|
|
101
|
-
delete: accountDelete,
|
|
102
|
-
insert: mock(async () => { }),
|
|
103
|
-
update: mock(async () => { }),
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
query: {},
|
|
107
|
-
};
|
|
108
|
-
await mutators.account.deleteAccount(transaction, {
|
|
109
|
-
id: 'test-account-id-1',
|
|
110
|
-
});
|
|
111
|
-
expect(accountDelete).toHaveBeenCalledWith({
|
|
112
|
-
id: 'test-account-id-1',
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe('deleteAlias', () => {
|
|
117
|
-
it('deletes a non-primary alias', async () => {
|
|
118
|
-
const aliasRecord = {
|
|
119
|
-
id: 'test-alias-id-2',
|
|
120
|
-
isPrimary: false,
|
|
121
|
-
};
|
|
122
|
-
const run = mock(async () => aliasRecord);
|
|
123
|
-
const one = mock(() => ({ run }));
|
|
124
|
-
const where = mock(() => ({ one }));
|
|
125
|
-
const accountAliasDelete = mock(async () => { });
|
|
126
|
-
const transaction = {
|
|
127
|
-
mutate: {
|
|
128
|
-
accountAlias: {
|
|
129
|
-
delete: accountAliasDelete,
|
|
130
|
-
insert: mock(async () => { }),
|
|
131
|
-
update: mock(async () => { }),
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
query: {
|
|
135
|
-
accountAlias: {
|
|
136
|
-
where,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
const mutators = createMutators();
|
|
141
|
-
await mutators.account.deleteAlias(transaction, {
|
|
142
|
-
accountId: 'test-account-id-1',
|
|
143
|
-
aliasId: 'test-alias-id-2',
|
|
144
|
-
});
|
|
145
|
-
expect(accountAliasDelete).toHaveBeenCalledWith({
|
|
146
|
-
id: 'test-alias-id-2',
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
it('deletes a primary alias and assigns new primary', async () => {
|
|
150
|
-
const aliasRecord = {
|
|
151
|
-
id: 'test-alias-id-1',
|
|
152
|
-
isPrimary: true,
|
|
153
|
-
};
|
|
154
|
-
const remainingAliases = [
|
|
155
|
-
{
|
|
156
|
-
id: 'test-alias-id-2',
|
|
157
|
-
isPrimary: false,
|
|
158
|
-
},
|
|
159
|
-
];
|
|
160
|
-
const runOne = mock(async () => aliasRecord);
|
|
161
|
-
const one = mock(() => ({ run: runOne }));
|
|
162
|
-
const runList = mock(async () => remainingAliases);
|
|
163
|
-
const where = mock((field) => {
|
|
164
|
-
if (field === 'accountId') {
|
|
165
|
-
return { run: runList };
|
|
166
|
-
}
|
|
167
|
-
return { one };
|
|
168
|
-
});
|
|
169
|
-
const accountAliasDelete = mock(async () => { });
|
|
170
|
-
const accountAliasUpdate = mock(async () => { });
|
|
171
|
-
const accountUpdate = mock(async () => { });
|
|
172
|
-
const transaction = {
|
|
173
|
-
mutate: {
|
|
174
|
-
account: {
|
|
175
|
-
delete: mock(async () => { }),
|
|
176
|
-
insert: mock(async () => { }),
|
|
177
|
-
update: accountUpdate,
|
|
178
|
-
},
|
|
179
|
-
accountAlias: {
|
|
180
|
-
delete: accountAliasDelete,
|
|
181
|
-
insert: mock(async () => { }),
|
|
182
|
-
update: accountAliasUpdate,
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
query: {
|
|
186
|
-
accountAlias: {
|
|
187
|
-
where,
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
const mutators = createMutators();
|
|
192
|
-
await mutators.account.deleteAlias(transaction, {
|
|
193
|
-
accountId: 'test-account-id-1',
|
|
194
|
-
aliasId: 'test-alias-id-1',
|
|
195
|
-
});
|
|
196
|
-
expect(accountAliasDelete).toHaveBeenCalledWith({
|
|
197
|
-
id: 'test-alias-id-1',
|
|
198
|
-
});
|
|
199
|
-
expect(accountAliasUpdate).toHaveBeenCalledWith({
|
|
200
|
-
id: 'test-alias-id-2',
|
|
201
|
-
isPrimary: true,
|
|
202
|
-
});
|
|
203
|
-
expect(accountUpdate).toHaveBeenCalledWith({
|
|
204
|
-
id: 'test-account-id-1',
|
|
205
|
-
primaryAliasId: 'test-alias-id-2',
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
describe('setAliasName', () => {
|
|
210
|
-
it('sets alias name', async () => {
|
|
211
|
-
const accountAliasUpdate = mock(async () => { });
|
|
212
|
-
const transaction = {
|
|
213
|
-
mutate: {
|
|
214
|
-
accountAlias: {
|
|
215
|
-
delete: mock(async () => { }),
|
|
216
|
-
insert: mock(async () => { }),
|
|
217
|
-
update: accountAliasUpdate,
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
query: {},
|
|
221
|
-
};
|
|
222
|
-
const mutators = createMutators();
|
|
223
|
-
await mutators.account.setAliasName(transaction, {
|
|
224
|
-
accountId: 'test-account-id-1',
|
|
225
|
-
aliasId: 'test-alias-id-1',
|
|
226
|
-
displayName: 'New Name',
|
|
227
|
-
});
|
|
228
|
-
expect(accountAliasUpdate).toHaveBeenCalledWith({
|
|
229
|
-
id: 'test-alias-id-1',
|
|
230
|
-
name: 'New Name',
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
describe('setAliasPrimary', () => {
|
|
235
|
-
it('sets alias as primary', async () => {
|
|
236
|
-
const aliases = [
|
|
237
|
-
{ id: 'test-alias-id-1', isPrimary: true },
|
|
238
|
-
{ id: 'test-alias-id-2', isPrimary: false },
|
|
239
|
-
];
|
|
240
|
-
const run = mock(async () => aliases);
|
|
241
|
-
const where = mock(() => ({ run }));
|
|
242
|
-
const accountAliasUpdate = mock(async () => { });
|
|
243
|
-
const accountUpdate = mock(async () => { });
|
|
244
|
-
const transaction = {
|
|
245
|
-
mutate: {
|
|
246
|
-
account: {
|
|
247
|
-
delete: mock(async () => { }),
|
|
248
|
-
insert: mock(async () => { }),
|
|
249
|
-
update: accountUpdate,
|
|
250
|
-
},
|
|
251
|
-
accountAlias: {
|
|
252
|
-
delete: mock(async () => { }),
|
|
253
|
-
insert: mock(async () => { }),
|
|
254
|
-
update: accountAliasUpdate,
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
query: {
|
|
258
|
-
accountAlias: {
|
|
259
|
-
where,
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
};
|
|
263
|
-
const mutators = createMutators();
|
|
264
|
-
await mutators.account.setAliasPrimary(transaction, {
|
|
265
|
-
accountId: 'test-account-id-1',
|
|
266
|
-
aliasId: 'test-alias-id-2',
|
|
267
|
-
});
|
|
268
|
-
expect(accountAliasUpdate).toHaveBeenCalledTimes(2);
|
|
269
|
-
expect(accountAliasUpdate).toHaveBeenCalledWith({
|
|
270
|
-
id: 'test-alias-id-1',
|
|
271
|
-
isPrimary: false,
|
|
272
|
-
});
|
|
273
|
-
expect(accountAliasUpdate).toHaveBeenCalledWith({
|
|
274
|
-
id: 'test-alias-id-2',
|
|
275
|
-
isPrimary: true,
|
|
276
|
-
});
|
|
277
|
-
expect(accountUpdate).toHaveBeenCalledWith({
|
|
278
|
-
id: 'test-account-id-1',
|
|
279
|
-
primaryAliasId: 'test-alias-id-2',
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
describe('setConnectionConfigImapRaw', () => {
|
|
284
|
-
it('sets connection config for IMAP raw', async () => {
|
|
285
|
-
const accountUpdate = mock(async () => { });
|
|
286
|
-
const transaction = {
|
|
287
|
-
mutate: {
|
|
288
|
-
account: {
|
|
289
|
-
delete: mock(async () => { }),
|
|
290
|
-
insert: mock(async () => { }),
|
|
291
|
-
update: accountUpdate,
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
query: {},
|
|
295
|
-
};
|
|
296
|
-
const mutators = createMutators();
|
|
297
|
-
await mutators.account.setConnectionConfigImapRaw(transaction, {
|
|
298
|
-
connectionConfig: {
|
|
299
|
-
imapHost: 'imap.example.com',
|
|
300
|
-
imapPassword: 'test-password',
|
|
301
|
-
imapPort: 993,
|
|
302
|
-
imapSocketType: 'SSL',
|
|
303
|
-
imapUser: 'user@example.com',
|
|
304
|
-
smtpHost: 'smtp.example.com',
|
|
305
|
-
smtpPassword: 'test-password',
|
|
306
|
-
smtpPort: 465,
|
|
307
|
-
smtpSocketType: 'SSL',
|
|
308
|
-
smtpUser: 'user@example.com',
|
|
309
|
-
},
|
|
310
|
-
id: 'test-account-id-1',
|
|
311
|
-
});
|
|
312
|
-
expect(accountUpdate).toHaveBeenCalledWith({
|
|
313
|
-
id: 'test-account-id-1',
|
|
314
|
-
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
describe('setConnectionConfigOauth', () => {
|
|
319
|
-
it('sets connection config for OAuth', async () => {
|
|
320
|
-
const accountUpdate = mock(async () => { });
|
|
321
|
-
const transaction = {
|
|
322
|
-
mutate: {
|
|
323
|
-
account: {
|
|
324
|
-
delete: mock(async () => { }),
|
|
325
|
-
insert: mock(async () => { }),
|
|
326
|
-
update: accountUpdate,
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
query: {},
|
|
330
|
-
};
|
|
331
|
-
const mutators = createMutators();
|
|
332
|
-
await mutators.account.setConnectionConfigOauth(transaction, {
|
|
333
|
-
connectionConfig: {
|
|
334
|
-
code: 'test-auth-code',
|
|
335
|
-
provider: 'GOOGLE',
|
|
336
|
-
user: 'user@example.com',
|
|
337
|
-
},
|
|
338
|
-
id: 'test-account-id-1',
|
|
339
|
-
});
|
|
340
|
-
expect(accountUpdate).toHaveBeenCalledWith({
|
|
341
|
-
id: 'test-account-id-1',
|
|
342
|
-
imapConnectionStatus: 'AWAITING_CONNECTION',
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
describe('setSettings', () => {
|
|
347
|
-
it('sets account settings', async () => {
|
|
348
|
-
const accountUpdate = mock(async () => { });
|
|
349
|
-
const transaction = {
|
|
350
|
-
mutate: {
|
|
351
|
-
account: {
|
|
352
|
-
delete: mock(async () => { }),
|
|
353
|
-
insert: mock(async () => { }),
|
|
354
|
-
update: accountUpdate,
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
query: {},
|
|
358
|
-
};
|
|
359
|
-
const mutators = createMutators();
|
|
360
|
-
await mutators.account.setSettings(transaction, {
|
|
361
|
-
color: '#00ff00',
|
|
362
|
-
displayName: 'Work Account',
|
|
363
|
-
id: 'test-account-id-1',
|
|
364
|
-
});
|
|
365
|
-
expect(accountUpdate).toHaveBeenCalledWith({
|
|
366
|
-
color: '#00ff00',
|
|
367
|
-
displayName: 'Work Account',
|
|
368
|
-
id: 'test-account-id-1',
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/accountMutators/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './accountMutators';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type AuthData, type HandlerMap } from '../../../types';
|
|
2
|
-
import type { ZeroMutatorSchemas } from '../../../zero/mutatorSchemas';
|
|
3
|
-
export declare const createDraftMutators: (authData: AuthData | undefined) => HandlerMap<ZeroMutatorSchemas["draft"]>;
|
|
4
|
-
//# sourceMappingURL=draftMutators.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,142 +0,0 @@
|
|
|
1
|
-
import { MutationError } from '../../../types';
|
|
2
|
-
import { stringPatch } from '../../../utils';
|
|
3
|
-
export const createDraftMutators = (authData) => ({
|
|
4
|
-
cancelSend: async (tx, args) => {
|
|
5
|
-
const draft = await tx.query.draft.where('id', args.id).one().run();
|
|
6
|
-
if (!draft) {
|
|
7
|
-
throw new Error(MutationError.ENTITY_NOT_FOUND);
|
|
8
|
-
}
|
|
9
|
-
if (draft.status === 'SEND_CONFIRMED') {
|
|
10
|
-
throw new Error(MutationError.ALREADY_APPLIED);
|
|
11
|
-
}
|
|
12
|
-
await tx.mutate.draft.update({
|
|
13
|
-
id: args.id,
|
|
14
|
-
scheduledFor: null,
|
|
15
|
-
status: 'DRAFT',
|
|
16
|
-
updatedAt: args.updatedAt,
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
createAttachment: async (tx, args) => {
|
|
20
|
-
await tx.mutate.draftAttachment.insert({
|
|
21
|
-
draftId: args.id,
|
|
22
|
-
fileName: args.attachment.fileName,
|
|
23
|
-
id: args.attachment.id,
|
|
24
|
-
mimeType: args.attachment.mimeType,
|
|
25
|
-
status: args.attachment.status,
|
|
26
|
-
totalSize: args.attachment.totalSize,
|
|
27
|
-
});
|
|
28
|
-
await tx.mutate.draft.update({
|
|
29
|
-
id: args.id,
|
|
30
|
-
updatedAt: args.updatedAt,
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
createDraft: async (tx, args) => {
|
|
34
|
-
if (!authData) {
|
|
35
|
-
throw new Error(MutationError.AUTHENTICATION_REQUIRED);
|
|
36
|
-
}
|
|
37
|
-
await tx.mutate.draft.insert({
|
|
38
|
-
accountId: args.accountId,
|
|
39
|
-
body: {
|
|
40
|
-
bcc: args.body.bcc,
|
|
41
|
-
cc: args.body.cc,
|
|
42
|
-
content: args.body.content,
|
|
43
|
-
to: args.body.to,
|
|
44
|
-
},
|
|
45
|
-
error: args.error,
|
|
46
|
-
fromAliasId: null,
|
|
47
|
-
fromEmail: args.from,
|
|
48
|
-
fromName: args.fromName,
|
|
49
|
-
id: args.id,
|
|
50
|
-
referencedMessageId: args.referencedMessageId,
|
|
51
|
-
scheduledFor: args.scheduledFor,
|
|
52
|
-
status: args.status,
|
|
53
|
-
subject: args.body.subject,
|
|
54
|
-
type: args.type,
|
|
55
|
-
updatedAt: args.updatedAt,
|
|
56
|
-
userId: authData.sub,
|
|
57
|
-
});
|
|
58
|
-
for (const attachment of args.attachments) {
|
|
59
|
-
await tx.mutate.draftAttachment.insert({
|
|
60
|
-
draftId: args.id,
|
|
61
|
-
fileName: attachment.fileName,
|
|
62
|
-
id: attachment.id,
|
|
63
|
-
mimeType: attachment.mimeType,
|
|
64
|
-
status: attachment.status,
|
|
65
|
-
totalSize: attachment.totalSize,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
deleteAttachment: async (tx, args) => {
|
|
70
|
-
await tx.mutate.draftAttachment.delete({
|
|
71
|
-
id: args.attachmentId,
|
|
72
|
-
});
|
|
73
|
-
await tx.mutate.draft.update({
|
|
74
|
-
id: args.id,
|
|
75
|
-
updatedAt: args.updatedAt,
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
deleteDraft: async (tx, args) => {
|
|
79
|
-
await tx.mutate.draft.delete({
|
|
80
|
-
id: args.id,
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
scheduleSend: async (tx, args) => {
|
|
84
|
-
if (args.kind === 'IMMEDIATE') {
|
|
85
|
-
await tx.mutate.draft.update({
|
|
86
|
-
id: args.id,
|
|
87
|
-
scheduledFor: args.updatedAt + args.undoMs,
|
|
88
|
-
status: 'SEND_REQUESTED',
|
|
89
|
-
updatedAt: args.updatedAt,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
await tx.mutate.draft.update({
|
|
94
|
-
id: args.id,
|
|
95
|
-
scheduledFor: args.scheduledFor,
|
|
96
|
-
status: 'SEND_REQUESTED',
|
|
97
|
-
updatedAt: args.updatedAt,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
setContent: async (tx, args) => {
|
|
102
|
-
const draft = await tx.query.draft.where('id', args.id).one().run();
|
|
103
|
-
if (!draft) {
|
|
104
|
-
throw new Error(MutationError.ENTITY_NOT_FOUND);
|
|
105
|
-
}
|
|
106
|
-
await tx.mutate.draft.update({
|
|
107
|
-
body: {
|
|
108
|
-
...draft.body,
|
|
109
|
-
content: stringPatch.apply(typeof draft.body?.content === 'string' ? draft.body.content : '', args.patch),
|
|
110
|
-
},
|
|
111
|
-
id: args.id,
|
|
112
|
-
updatedAt: args.updatedAt,
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
setEnvelope: async (tx, args) => {
|
|
116
|
-
const draft = await tx.query.draft.where('id', args.id).one().run();
|
|
117
|
-
if (!draft) {
|
|
118
|
-
throw new Error(MutationError.ENTITY_NOT_FOUND);
|
|
119
|
-
}
|
|
120
|
-
await tx.mutate.draft.update({
|
|
121
|
-
body: {
|
|
122
|
-
bcc: args.envelope.bcc,
|
|
123
|
-
cc: args.envelope.cc,
|
|
124
|
-
content: draft.body.content,
|
|
125
|
-
to: args.envelope.to,
|
|
126
|
-
},
|
|
127
|
-
id: args.id,
|
|
128
|
-
subject: args.envelope.subject,
|
|
129
|
-
updatedAt: args.updatedAt,
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
setFrom: async (tx, args) => {
|
|
133
|
-
await tx.mutate.draft.update({
|
|
134
|
-
accountId: args.accountId,
|
|
135
|
-
fromAliasId: args.aliasId,
|
|
136
|
-
fromEmail: args.from,
|
|
137
|
-
fromName: args.fromName,
|
|
138
|
-
id: args.id,
|
|
139
|
-
updatedAt: args.updatedAt,
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"draftMutators.test.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/draftMutators.test.ts"],"names":[],"mappings":""}
|