@marcoappio/marco-config 2.0.466 → 2.0.467

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":"getThreadList.d.ts","sourceRoot":"","sources":["../../../src/zero/queries/getThreadList.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAMlE,KAAK,iBAAiB,GAAG;IACvB,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,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;QACnB,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,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDzB,CAAA"}
@@ -0,0 +1,59 @@
1
+ import { syncedQueryWithContext } from '@rocicorp/zero';
2
+ import * as v from 'valibot';
3
+ import { z } from '../../zero/queries';
4
+ const MAX_LIMIT = 1000;
5
+ const DEFAULT_LIMIT = 50;
6
+ const parseArgs = (args) => {
7
+ const schema = v.object({
8
+ limit: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(MAX_LIMIT)), DEFAULT_LIMIT),
9
+ search: v.optional(v.string()),
10
+ where: v.optional(v.object({
11
+ flagged: v.optional(v.boolean()),
12
+ id: v.optional(v.string()),
13
+ labelIds: v.optional(v.array(v.string())),
14
+ messageIds: v.optional(v.array(v.string())),
15
+ participants: v.optional(v.array(v.string())),
16
+ seen: v.optional(v.boolean()),
17
+ })),
18
+ });
19
+ return [v.parse(schema, args[0])];
20
+ };
21
+ export const getThreadList = syncedQueryWithContext('getThreadList', parseArgs, ({ userId }, { search, limit, where }) => {
22
+ let query = z.thread
23
+ .where('userId', userId)
24
+ .related('messages', x => x.related('attachments').orderBy('envelopeDate', 'asc'))
25
+ .related('labels')
26
+ .orderBy('latestMessageDate', 'desc');
27
+ if (where?.id) {
28
+ query = query.where('id', where.id);
29
+ }
30
+ if (typeof where?.flagged === 'boolean') {
31
+ query = query.where('flagged', where.flagged);
32
+ }
33
+ if (typeof where?.seen === 'boolean') {
34
+ query = query.where('seen', where.seen);
35
+ }
36
+ if (where?.labelIds && where.labelIds.length > 0) {
37
+ for (const labelId of where.labelIds) {
38
+ query = query.whereExists('labels', x => x.where('id', labelId));
39
+ }
40
+ }
41
+ if (where?.messageIds && where.messageIds.length > 0) {
42
+ for (const messageId of where.messageIds) {
43
+ query = query.whereExists('messages', x => x.where('id', messageId));
44
+ }
45
+ }
46
+ if (where?.participants && where.participants.length > 0) {
47
+ for (const participant of where.participants) {
48
+ query = query.whereExists('messages', x => x.whereExists('recipients', y => y.where('emailAddress', participant)));
49
+ }
50
+ }
51
+ if (search) {
52
+ const sanitizedTerm = search.trim().toLowerCase();
53
+ const tokens = sanitizedTerm.split(/\s+/).filter(Boolean);
54
+ if (tokens.length > 0) {
55
+ query = query.where(({ and, cmp }) => and(...tokens.map(x => cmp('words', 'ILIKE', `%${x}%`))));
56
+ }
57
+ }
58
+ return query.limit(limit);
59
+ });
@@ -917,6 +917,7 @@ export declare const z: import("@rocicorp/zero").SchemaQuery<{
917
917
  export { getAccounts } from './getAccounts';
918
918
  export { getContacts } from './getContacts';
919
919
  export { getDrafts } from './getDrafts';
920
+ export { getThreadList } from './getThreadList';
920
921
  export { getThreads } from './getThreads';
921
922
  export { getUser } from './getUser';
922
923
  //# 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,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,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"}
@@ -4,5 +4,6 @@ export const z = createBuilder(schema);
4
4
  export { getAccounts } from './getAccounts';
5
5
  export { getContacts } from './getContacts';
6
6
  export { getDrafts } from './getDrafts';
7
+ export { getThreadList } from './getThreadList';
7
8
  export { getThreads } from './getThreads';
8
9
  export { getUser } from './getUser';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marcoappio/marco-config",
3
- "version": "2.0.466",
3
+ "version": "2.0.467",
4
4
  "author": "team@marcoapp.io",
5
5
  "main": "dist/index.js",
6
6
  "repository": "git@github.com:marcoappio/marco-config.git",