@marcoappio/marco-config 2.0.493 → 2.0.494

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/types/Zero.d.ts +8 -0
  2. package/dist/types/Zero.d.ts.map +1 -1
  3. package/dist/zero/crud.d.ts +1024 -0
  4. package/dist/zero/crud.d.ts.map +1 -0
  5. package/dist/zero/crud.js +3 -0
  6. package/dist/zero/index.d.ts +98 -38
  7. package/dist/zero/index.d.ts.map +1 -1
  8. package/dist/zero/mutators/accountMutators/accountMutators.d.ts +27 -9
  9. package/dist/zero/mutators/accountMutators/accountMutators.d.ts.map +1 -1
  10. package/dist/zero/mutators/accountMutators/accountMutators.js +30 -29
  11. package/dist/zero/mutators/draftMutators/draftMutators.d.ts +27 -9
  12. package/dist/zero/mutators/draftMutators/draftMutators.d.ts.map +1 -1
  13. package/dist/zero/mutators/draftMutators/draftMutators.js +28 -27
  14. package/dist/zero/mutators/index.d.ts +0 -1
  15. package/dist/zero/mutators/index.d.ts.map +1 -1
  16. package/dist/zero/mutators/index.js +0 -1
  17. package/dist/zero/mutators/mutators.d.ts +90 -31
  18. package/dist/zero/mutators/mutators.d.ts.map +1 -1
  19. package/dist/zero/mutators/mutators.js +0 -1
  20. package/dist/zero/mutators/threadMutators/threadMutators.d.ts +29 -12
  21. package/dist/zero/mutators/threadMutators/threadMutators.d.ts.map +1 -1
  22. package/dist/zero/mutators/threadMutators/threadMutators.js +41 -40
  23. package/dist/zero/mutators/userMutators/userMutators.d.ts +9 -3
  24. package/dist/zero/mutators/userMutators/userMutators.d.ts.map +1 -1
  25. package/dist/zero/mutators/userMutators/userMutators.js +8 -7
  26. package/dist/zero/queries/getAccounts.d.ts +1 -1
  27. package/dist/zero/queries/getContacts.d.ts +1 -1
  28. package/dist/zero/queries/getDrafts.d.ts +1 -1
  29. package/dist/zero/queries/getThread.d.ts +1 -1
  30. package/dist/zero/queries/getThreadList.d.ts +1 -1
  31. package/dist/zero/queries/getThreads.d.ts +1 -1
  32. package/dist/zero/queries/getUser.d.ts +1 -1
  33. package/dist/zero/queries/index.d.ts +1 -1
  34. package/dist/zero/schema.d.ts +1 -1
  35. package/dist/zero/schema.d.ts.map +1 -1
  36. package/dist/zero/schema.js +0 -1
  37. package/package.json +2 -2
  38. package/dist/zero/mutators/defineMutator.d.ts +0 -16
  39. package/dist/zero/mutators/defineMutator.d.ts.map +0 -1
  40. package/dist/zero/mutators/defineMutator.js +0 -7
@@ -1,6 +1,7 @@
1
+ import { defineMutator } from '@rocicorp/zero';
1
2
  import * as v from 'valibot';
2
3
  import { marcoSchemas } from '../../../schemas';
3
- import { defineMutator } from '../../../zero/mutators/defineMutator';
4
+ import { zeroCRUD } from '../../../zero/crud';
4
5
  const accountAliasSchema = v.object({
5
6
  emailAddress: marcoSchemas.string.email(),
6
7
  id: marcoSchemas.string.required(),
@@ -13,7 +14,7 @@ export const accountMutators = {
13
14
  emailAddress: marcoSchemas.string.email(),
14
15
  id: marcoSchemas.string.required(),
15
16
  }), async ({ tx, ctx: { userId }, args }) => {
16
- await tx.mutate.account.insert({
17
+ await tx.mutate(zeroCRUD.account.insert({
17
18
  color: args.color,
18
19
  displayName: null,
19
20
  id: args.id,
@@ -22,60 +23,60 @@ export const accountMutators = {
22
23
  mailTotalCount: 0,
23
24
  primaryAliasId: args.aliasId,
24
25
  userId,
25
- });
26
- await tx.mutate.accountAlias.insert({
26
+ }));
27
+ await tx.mutate(zeroCRUD.accountAlias.insert({
27
28
  accountId: args.id,
28
29
  emailAddress: args.emailAddress,
29
30
  id: args.aliasId,
30
31
  isPrimary: true,
31
32
  name: null,
32
- });
33
+ }));
33
34
  }),
34
35
  createAlias: defineMutator(v.object({
35
36
  accountId: marcoSchemas.string.required(),
36
37
  alias: accountAliasSchema,
37
38
  }), async ({ tx, args }) => {
38
- await tx.mutate.accountAlias.insert({
39
+ await tx.mutate(zeroCRUD.accountAlias.insert({
39
40
  accountId: args.accountId,
40
41
  emailAddress: args.alias.emailAddress,
41
42
  id: args.alias.id,
42
43
  isPrimary: false,
43
44
  name: args.alias.name ?? null,
44
- });
45
+ }));
45
46
  }),
46
47
  deleteAccount: defineMutator(v.object({
47
48
  id: marcoSchemas.string.required(),
48
49
  }), async ({ tx, args }) => {
49
- await tx.mutate.account.delete({
50
+ await tx.mutate(zeroCRUD.account.delete({
50
51
  id: args.id,
51
- });
52
+ }));
52
53
  }),
53
54
  deleteAlias: defineMutator(v.object({
54
55
  accountId: marcoSchemas.string.required(),
55
56
  aliasId: marcoSchemas.string.required(),
56
57
  }), async ({ tx, args }) => {
57
58
  const alias = await tx.query.accountAlias.where('id', args.aliasId).one().run();
58
- await tx.mutate.accountAlias.delete({
59
+ await tx.mutate(zeroCRUD.accountAlias.delete({
59
60
  id: args.aliasId,
60
- });
61
+ }));
61
62
  if (alias?.isPrimary) {
62
63
  const remainingAliases = await tx.query.accountAlias.where('accountId', args.accountId).run();
63
64
  if (remainingAliases.length > 0) {
64
65
  const newPrimaryAlias = remainingAliases[0];
65
- await tx.mutate.accountAlias.update({
66
+ await tx.mutate(zeroCRUD.accountAlias.update({
66
67
  id: newPrimaryAlias.id,
67
68
  isPrimary: true,
68
- });
69
- await tx.mutate.account.update({
69
+ }));
70
+ await tx.mutate(zeroCRUD.account.update({
70
71
  id: args.accountId,
71
72
  primaryAliasId: newPrimaryAlias.id,
72
- });
73
+ }));
73
74
  }
74
75
  else {
75
- await tx.mutate.account.update({
76
+ await tx.mutate(zeroCRUD.account.update({
76
77
  id: args.accountId,
77
78
  primaryAliasId: null,
78
- });
79
+ }));
79
80
  }
80
81
  }
81
82
  }),
@@ -84,10 +85,10 @@ export const accountMutators = {
84
85
  aliasId: marcoSchemas.string.required(),
85
86
  displayName: marcoSchemas.string.nullable(),
86
87
  }), async ({ tx, args }) => {
87
- await tx.mutate.accountAlias.update({
88
+ await tx.mutate(zeroCRUD.accountAlias.update({
88
89
  id: args.aliasId,
89
90
  name: args.displayName,
90
- });
91
+ }));
91
92
  }),
92
93
  setAliasPrimary: defineMutator(v.object({
93
94
  accountId: marcoSchemas.string.required(),
@@ -95,43 +96,43 @@ export const accountMutators = {
95
96
  }), async ({ tx, args }) => {
96
97
  const aliases = await tx.query.accountAlias.where('accountId', args.accountId).run();
97
98
  for (const alias of aliases) {
98
- await tx.mutate.accountAlias.update({
99
+ await tx.mutate(zeroCRUD.accountAlias.update({
99
100
  id: alias.id,
100
101
  isPrimary: alias.id === args.aliasId,
101
- });
102
+ }));
102
103
  }
103
- await tx.mutate.account.update({
104
+ await tx.mutate(zeroCRUD.account.update({
104
105
  id: args.accountId,
105
106
  primaryAliasId: args.aliasId,
106
- });
107
+ }));
107
108
  }),
108
109
  setConnectionConfigImapRaw: defineMutator(v.object({
109
110
  connectionConfig: marcoSchemas.emailAccount.connectionConfigImapRaw(),
110
111
  id: marcoSchemas.string.required(),
111
112
  }), async ({ tx, args }) => {
112
- await tx.mutate.account.update({
113
+ await tx.mutate(zeroCRUD.account.update({
113
114
  id: args.id,
114
115
  imapConnectionStatus: 'AWAITING_CONNECTION',
115
- });
116
+ }));
116
117
  }),
117
118
  setConnectionConfigOauth: defineMutator(v.object({
118
119
  connectionConfig: marcoSchemas.emailAccount.connectionConfigOauth(),
119
120
  id: marcoSchemas.string.required(),
120
121
  }), async ({ tx, args }) => {
121
- await tx.mutate.account.update({
122
+ await tx.mutate(zeroCRUD.account.update({
122
123
  id: args.id,
123
124
  imapConnectionStatus: 'AWAITING_CONNECTION',
124
- });
125
+ }));
125
126
  }),
126
127
  setSettings: defineMutator(v.object({
127
128
  color: v.optional(marcoSchemas.string.nullable()),
128
129
  displayName: v.optional(marcoSchemas.string.nullable()),
129
130
  id: marcoSchemas.string.required(),
130
131
  }), async ({ tx, args }) => {
131
- await tx.mutate.account.update({
132
+ await tx.mutate(zeroCRUD.account.update({
132
133
  color: args.color ? args.color : undefined,
133
134
  displayName: args.displayName ? args.displayName : undefined,
134
135
  id: args.id,
135
- });
136
+ }));
136
137
  }),
137
138
  };
@@ -5,7 +5,9 @@ export declare const draftMutators: {
5
5
  }, {
6
6
  id: string;
7
7
  updatedAt: number;
8
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
8
+ }, {
9
+ readonly userId: string;
10
+ }, unknown>;
9
11
  createAttachment: import("@rocicorp/zero").MutatorDefinition<{
10
12
  attachment: {
11
13
  fileName: string;
@@ -26,7 +28,9 @@ export declare const draftMutators: {
26
28
  };
27
29
  id: string;
28
30
  updatedAt: number;
29
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
31
+ }, {
32
+ readonly userId: string;
33
+ }, unknown>;
30
34
  createDraft: import("@rocicorp/zero").MutatorDefinition<{
31
35
  accountId: string;
32
36
  attachments: {
@@ -77,7 +81,9 @@ export declare const draftMutators: {
77
81
  status: "DRAFT" | "SEND_REQUESTED" | "SEND_CONFIRMED" | "SEND_FAILED";
78
82
  type: "NEW" | "REPLY" | "FORWARD";
79
83
  updatedAt: number;
80
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
84
+ }, {
85
+ readonly userId: string;
86
+ }, unknown>;
81
87
  deleteAttachment: import("@rocicorp/zero").MutatorDefinition<{
82
88
  attachmentId: string;
83
89
  id: string;
@@ -86,12 +92,16 @@ export declare const draftMutators: {
86
92
  attachmentId: string;
87
93
  id: string;
88
94
  updatedAt: number;
89
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
95
+ }, {
96
+ readonly userId: string;
97
+ }, unknown>;
90
98
  deleteDraft: import("@rocicorp/zero").MutatorDefinition<{
91
99
  id: string;
92
100
  }, {
93
101
  id: string;
94
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
102
+ }, {
103
+ readonly userId: string;
104
+ }, unknown>;
95
105
  scheduleSend: import("@rocicorp/zero").MutatorDefinition<{
96
106
  id: string;
97
107
  kind: "IMMEDIATE";
@@ -112,7 +122,9 @@ export declare const draftMutators: {
112
122
  kind: "SCHEDULED";
113
123
  scheduledFor: number;
114
124
  updatedAt: number;
115
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
125
+ }, {
126
+ readonly userId: string;
127
+ }, unknown>;
116
128
  setContent: import("@rocicorp/zero").MutatorDefinition<{
117
129
  id: string;
118
130
  patch: {
@@ -129,7 +141,9 @@ export declare const draftMutators: {
129
141
  value: string;
130
142
  }[];
131
143
  updatedAt: number;
132
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
144
+ }, {
145
+ readonly userId: string;
146
+ }, unknown>;
133
147
  setEnvelope: import("@rocicorp/zero").MutatorDefinition<{
134
148
  envelope: {
135
149
  bcc: string[];
@@ -148,7 +162,9 @@ export declare const draftMutators: {
148
162
  };
149
163
  id: string;
150
164
  updatedAt: number;
151
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
165
+ }, {
166
+ readonly userId: string;
167
+ }, unknown>;
152
168
  setFrom: import("@rocicorp/zero").MutatorDefinition<{
153
169
  accountId: string;
154
170
  aliasId: string;
@@ -163,6 +179,8 @@ export declare const draftMutators: {
163
179
  fromName: string | null;
164
180
  id: string;
165
181
  updatedAt: number;
166
- }, import("../../../zero/mutators/defineMutator").MarcoZeroContext>;
182
+ }, {
183
+ readonly userId: string;
184
+ }, unknown>;
167
185
  };
168
186
  //# sourceMappingURL=draftMutators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"draftMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/draftMutators.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqMzB,CAAA"}
1
+ {"version":3,"file":"draftMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/draftMutators/draftMutators.ts"],"names":[],"mappings":"AAyDA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgOzB,CAAA"}
@@ -1,8 +1,9 @@
1
+ import { defineMutator } from '@rocicorp/zero';
1
2
  import * as v from 'valibot';
2
3
  import { marcoSchemas } from '../../../schemas';
3
4
  import { DRAFT_ATTACHMENT_UPLOAD_STATUSES, DRAFT_STATUSES, DRAFT_TYPES, MutationError } from '../../../types';
4
5
  import { stringPatch } from '../../../utils';
5
- import { defineMutator } from '../../../zero/mutators/defineMutator';
6
+ import { zeroCRUD } from '../../../zero/crud';
6
7
  const draftStatusSchema = v.picklist(DRAFT_STATUSES);
7
8
  const draftTypeSchema = v.picklist(DRAFT_TYPES);
8
9
  const draftBodySchema = v.object({
@@ -59,33 +60,33 @@ export const draftMutators = {
59
60
  if (draft.status === 'SEND_CONFIRMED') {
60
61
  throw new Error(MutationError.ALREADY_APPLIED);
61
62
  }
62
- await tx.mutate.draft.update({
63
+ await tx.mutate(zeroCRUD.draft.update({
63
64
  id: args.id,
64
65
  scheduledFor: null,
65
66
  status: 'DRAFT',
66
67
  updatedAt: args.updatedAt,
67
- });
68
+ }));
68
69
  }),
69
70
  createAttachment: defineMutator(v.object({
70
71
  attachment: draftAttachmentSchema,
71
72
  id: marcoSchemas.string.required(),
72
73
  updatedAt: marcoSchemas.number.positiveInteger(),
73
74
  }), async ({ tx, args }) => {
74
- await tx.mutate.draftAttachment.insert({
75
+ await tx.mutate(zeroCRUD.draftAttachment.insert({
75
76
  draftId: args.id,
76
77
  fileName: args.attachment.fileName,
77
78
  id: args.attachment.id,
78
79
  mimeType: args.attachment.mimeType,
79
80
  status: args.attachment.status,
80
81
  totalSize: args.attachment.totalSize,
81
- });
82
- await tx.mutate.draft.update({
82
+ }));
83
+ await tx.mutate(zeroCRUD.draft.update({
83
84
  id: args.id,
84
85
  updatedAt: args.updatedAt,
85
- });
86
+ }));
86
87
  }),
87
88
  createDraft: defineMutator(draftModelSchema, async ({ tx, ctx: { userId }, args }) => {
88
- await tx.mutate.draft.insert({
89
+ await tx.mutate(zeroCRUD.draft.insert({
89
90
  accountId: args.accountId,
90
91
  body: {
91
92
  bcc: args.body.bcc,
@@ -105,16 +106,16 @@ export const draftMutators = {
105
106
  type: args.type,
106
107
  updatedAt: args.updatedAt,
107
108
  userId,
108
- });
109
+ }));
109
110
  for (const attachment of args.attachments) {
110
- await tx.mutate.draftAttachment.insert({
111
+ await tx.mutate(zeroCRUD.draftAttachment.insert({
111
112
  draftId: args.id,
112
113
  fileName: attachment.fileName,
113
114
  id: attachment.id,
114
115
  mimeType: attachment.mimeType,
115
116
  status: attachment.status,
116
117
  totalSize: attachment.totalSize,
117
- });
118
+ }));
118
119
  }
119
120
  }),
120
121
  deleteAttachment: defineMutator(v.object({
@@ -122,37 +123,37 @@ export const draftMutators = {
122
123
  id: marcoSchemas.string.required(),
123
124
  updatedAt: marcoSchemas.number.positiveInteger(),
124
125
  }), async ({ tx, args }) => {
125
- await tx.mutate.draftAttachment.delete({
126
+ await tx.mutate(zeroCRUD.draftAttachment.delete({
126
127
  id: args.attachmentId,
127
- });
128
- await tx.mutate.draft.update({
128
+ }));
129
+ await tx.mutate(zeroCRUD.draft.update({
129
130
  id: args.id,
130
131
  updatedAt: args.updatedAt,
131
- });
132
+ }));
132
133
  }),
133
134
  deleteDraft: defineMutator(v.object({
134
135
  id: marcoSchemas.string.required(),
135
136
  }), async ({ tx, args }) => {
136
- await tx.mutate.draft.delete({
137
+ await tx.mutate(zeroCRUD.draft.delete({
137
138
  id: args.id,
138
- });
139
+ }));
139
140
  }),
140
141
  scheduleSend: defineMutator(draftScheduleSchema, async ({ tx, args }) => {
141
142
  if (args.kind === 'IMMEDIATE') {
142
- await tx.mutate.draft.update({
143
+ await tx.mutate(zeroCRUD.draft.update({
143
144
  id: args.id,
144
145
  scheduledFor: args.updatedAt + args.undoMs,
145
146
  status: 'SEND_REQUESTED',
146
147
  updatedAt: args.updatedAt,
147
- });
148
+ }));
148
149
  }
149
150
  else {
150
- await tx.mutate.draft.update({
151
+ await tx.mutate(zeroCRUD.draft.update({
151
152
  id: args.id,
152
153
  scheduledFor: args.scheduledFor,
153
154
  status: 'SEND_REQUESTED',
154
155
  updatedAt: args.updatedAt,
155
- });
156
+ }));
156
157
  }
157
158
  }),
158
159
  setContent: defineMutator(v.object({
@@ -164,14 +165,14 @@ export const draftMutators = {
164
165
  if (!draft) {
165
166
  throw new Error(MutationError.ENTITY_NOT_FOUND);
166
167
  }
167
- await tx.mutate.draft.update({
168
+ await tx.mutate(zeroCRUD.draft.update({
168
169
  body: {
169
170
  ...draft.body,
170
171
  content: stringPatch.apply(typeof draft.body?.content === 'string' ? draft.body.content : '', args.patch),
171
172
  },
172
173
  id: args.id,
173
174
  updatedAt: args.updatedAt,
174
- });
175
+ }));
175
176
  }),
176
177
  setEnvelope: defineMutator(v.object({
177
178
  envelope: v.omit(draftBodySchema, ['content']),
@@ -182,7 +183,7 @@ export const draftMutators = {
182
183
  if (!draft) {
183
184
  throw new Error(MutationError.ENTITY_NOT_FOUND);
184
185
  }
185
- await tx.mutate.draft.update({
186
+ await tx.mutate(zeroCRUD.draft.update({
186
187
  body: {
187
188
  bcc: args.envelope.bcc,
188
189
  cc: args.envelope.cc,
@@ -192,7 +193,7 @@ export const draftMutators = {
192
193
  id: args.id,
193
194
  subject: args.envelope.subject,
194
195
  updatedAt: args.updatedAt,
195
- });
196
+ }));
196
197
  }),
197
198
  setFrom: defineMutator(v.object({
198
199
  accountId: marcoSchemas.string.required(),
@@ -202,13 +203,13 @@ export const draftMutators = {
202
203
  id: marcoSchemas.string.required(),
203
204
  updatedAt: marcoSchemas.number.positiveInteger(),
204
205
  }), async ({ tx, args }) => {
205
- await tx.mutate.draft.update({
206
+ await tx.mutate(zeroCRUD.draft.update({
206
207
  accountId: args.accountId,
207
208
  fromAliasId: args.aliasId,
208
209
  fromEmail: args.from,
209
210
  fromName: args.fromName,
210
211
  id: args.id,
211
212
  updatedAt: args.updatedAt,
212
- });
213
+ }));
213
214
  }),
214
215
  };
@@ -1,4 +1,3 @@
1
- export { defineMutator, type MarcoZeroContext } from './defineMutator';
2
1
  export type { MarcoZeroMutators } from './mutators';
3
2
  export { mutators } from './mutators';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zero/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zero/mutators/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
@@ -1,2 +1 @@
1
- export { defineMutator } from './defineMutator';
2
1
  export { mutators } from './mutators';