@marcoappio/marco-config 2.0.482 → 2.0.484

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.
@@ -1 +0,0 @@
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"}
@@ -1,59 +0,0 @@
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
- });