@marcoappio/marco-config 2.0.484 → 2.0.485

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getThreads.d.ts","sourceRoot":"","sources":["../../../src/zero/queries/getThreads.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAOlE,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;QACvB,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,CAAA;CACF,CAAA;AAoBD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDtB,CAAA"}
@@ -0,0 +1,59 @@
1
+ import { syncedQueryWithContext } from '@rocicorp/zero';
2
+ import * as v from 'valibot';
3
+ import { threadsUtils } from '../../utils/threads';
4
+ import { z } from '../../zero/queries';
5
+ const MAX_LIMIT = 1000;
6
+ const DEFAULT_LIMIT = 50;
7
+ const parseArgs = (args) => {
8
+ const schema = v.object({
9
+ labelIds: v.pipe(v.array(v.string()), v.minLength(1)),
10
+ limit: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(MAX_LIMIT)), DEFAULT_LIMIT),
11
+ search: v.optional(v.string()),
12
+ where: v.optional(v.object({
13
+ flagged: v.optional(v.boolean()),
14
+ id: v.optional(v.string()),
15
+ messageIds: v.optional(v.array(v.string())),
16
+ participants: v.optional(v.array(v.string())),
17
+ seen: v.optional(v.boolean()),
18
+ })),
19
+ });
20
+ return [v.parse(schema, args[0])];
21
+ };
22
+ export const getThreads = syncedQueryWithContext('getThreads', parseArgs, ({ userId }, { labelIds, search, limit, where }) => {
23
+ const query = z.threadByLabel
24
+ .where('labelId', 'IN', labelIds)
25
+ .orderBy('latestMessageDate', 'desc')
26
+ .limit(limit)
27
+ .related('thread', t => {
28
+ let threadQuery = t
29
+ .where('userId', userId)
30
+ .related('messages', x => x.related('recipients').related('attachments').orderBy('envelopeDate', 'asc'));
31
+ if (where?.id) {
32
+ threadQuery = threadQuery.where('id', where.id);
33
+ }
34
+ if (typeof where?.flagged === 'boolean') {
35
+ threadQuery = threadQuery.where('flagged', where.flagged);
36
+ }
37
+ if (typeof where?.seen === 'boolean') {
38
+ threadQuery = threadQuery.where('seen', where.seen);
39
+ }
40
+ if (where?.messageIds && where.messageIds.length > 0) {
41
+ for (const messageId of where.messageIds) {
42
+ threadQuery = threadQuery.whereExists('messages', x => x.where('id', messageId));
43
+ }
44
+ }
45
+ if (where?.participants && where.participants.length > 0) {
46
+ for (const participant of where.participants) {
47
+ threadQuery = threadQuery.whereExists('messages', x => x.whereExists('recipients', y => y.where('emailAddress', participant)));
48
+ }
49
+ }
50
+ if (search) {
51
+ const tokens = threadsUtils.processSearchTerm(search);
52
+ if (tokens.length > 0) {
53
+ threadQuery = threadQuery.where(({ and, cmp }) => and(...tokens.map(x => cmp('words', 'ILIKE', `%${x}%`))));
54
+ }
55
+ }
56
+ return threadQuery;
57
+ });
58
+ return query;
59
+ });
@@ -1019,5 +1019,6 @@ export { getContacts } from './getContacts';
1019
1019
  export { getDrafts } from './getDrafts';
1020
1020
  export { getThread } from './getThread';
1021
1021
  export { getThreadList } from './getThreadList';
1022
+ export { getThreads } from './getThreads';
1022
1023
  export { getUser } from './getUser';
1023
1024
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/zero/queries/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAwB,CAAA;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
@@ -6,4 +6,5 @@ export { getContacts } from './getContacts';
6
6
  export { getDrafts } from './getDrafts';
7
7
  export { getThread } from './getThread';
8
8
  export { getThreadList } from './getThreadList';
9
+ export { getThreads } from './getThreads';
9
10
  export { getUser } from './getUser';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marcoappio/marco-config",
3
- "version": "2.0.484",
3
+ "version": "2.0.485",
4
4
  "author": "team@marcoapp.io",
5
5
  "main": "dist/index.js",
6
6
  "repository": "git@github.com:marcoappio/marco-config.git",