@polinetwork/backend 0.15.5 → 0.15.7

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.cjs CHANGED
@@ -22,6 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AUTH_PATH: () => AUTH_PATH,
24
24
  TRPC_PATH: () => TRPC_PATH,
25
+ USER_ROLE: () => USER_ROLE,
25
26
  WS_PATH: () => WS_PATH
26
27
  });
27
28
  module.exports = __toCommonJS(index_exports);
@@ -30,10 +31,19 @@ module.exports = __toCommonJS(index_exports);
30
31
  var TRPC_PATH = "/api/trpc";
31
32
  var AUTH_PATH = "/api/auth";
32
33
  var WS_PATH = "/ws";
34
+ var USER_ROLE = {
35
+ ADMIN: "admin",
36
+ HR: "hr",
37
+ PRESIDENT: "president",
38
+ DIRETTIVO: "direttivo",
39
+ CREATOR: "creator",
40
+ OWNER: "owner"
41
+ };
33
42
  // Annotate the CommonJS export names for ESM import in node:
34
43
  0 && (module.exports = {
35
44
  AUTH_PATH,
36
45
  TRPC_PATH,
46
+ USER_ROLE,
37
47
  WS_PATH
38
48
  });
39
49
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/constants.ts"],"sourcesContent":["export { AUTH_PATH, TRPC_PATH, WS_PATH } from \"./constants\"\nexport type { AppRouter } from \"./routers\"\n\nimport type { telegramPlugin } from \"./auth/plugins/telegram\"\nexport type TelegramPlugin = typeof telegramPlugin\n\nexport type { TelegramSocket } from \"./websocket/telegram\"\n","export const TRPC_PATH = \"/api/trpc\"\nexport const AUTH_PATH = \"/api/auth\"\nexport const WS_PATH = \"/ws\"\n\nexport const TRUSTED_ORIGINS = [\n \"http://localhost:3001\",\n \"http://localhost:3002\",\n \"http://localhost:3003\",\n \"http://localhost:5173\",\n \"http://localhost:5174\",\n \"http://localhost:5175\",\n]\n\nexport const MESSAGES_RETENTION_DAYS = 7\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/constants.ts"],"sourcesContent":["export { AUTH_PATH, TRPC_PATH, USER_ROLE, WS_PATH } from \"./constants\"\nexport type { AppRouter } from \"./routers\"\n\nimport type { telegramPlugin } from \"./auth/plugins/telegram\"\nexport type TelegramPlugin = typeof telegramPlugin\n\nexport type { TelegramSocket } from \"./websocket/telegram\"\n","export const TRPC_PATH = \"/api/trpc\"\nexport const AUTH_PATH = \"/api/auth\"\nexport const WS_PATH = \"/ws\"\n\nexport const TRUSTED_ORIGINS = [\n \"http://localhost:3001\",\n \"http://localhost:3002\",\n \"http://localhost:3003\",\n \"http://localhost:5173\",\n \"http://localhost:5174\",\n \"http://localhost:5175\",\n]\n\nexport const MESSAGES_RETENTION_DAYS = 7\n\nexport const USER_ROLE = {\n ADMIN: \"admin\",\n HR: \"hr\",\n PRESIDENT: \"president\",\n DIRETTIVO: \"direttivo\",\n CREATOR: \"creator\",\n OWNER: \"owner\",\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,UAAU;AAahB,IAAM,YAAY;AAAA,EACvB,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AACT;","names":[]}
package/dist/index.d.cts CHANGED
@@ -6,6 +6,14 @@ import { Socket } from 'socket.io-client';
6
6
  declare const TRPC_PATH = "/api/trpc";
7
7
  declare const AUTH_PATH = "/api/auth";
8
8
  declare const WS_PATH = "/ws";
9
+ declare const USER_ROLE: {
10
+ readonly ADMIN: "admin";
11
+ readonly HR: "hr";
12
+ readonly PRESIDENT: "president";
13
+ readonly DIRETTIVO: "direttivo";
14
+ readonly CREATOR: "creator";
15
+ readonly OWNER: "owner";
16
+ };
9
17
 
10
18
  type ParsedUser = {
11
19
  id: string;
@@ -29,14 +37,6 @@ declare const AUDIT_TYPE: {
29
37
  };
30
38
  type TAuditType = (typeof AUDIT_TYPE)[keyof typeof AUDIT_TYPE];
31
39
 
32
- declare const USER_ROLE: {
33
- readonly ADMIN: "admin";
34
- readonly HR: "hr";
35
- readonly PRESIDENT: "president";
36
- readonly DIRETTIVO: "direttivo";
37
- readonly CREATOR: "creator";
38
- readonly OWNER: "owner";
39
- };
40
40
  type TUserRole = (typeof USER_ROLE)[keyof typeof USER_ROLE];
41
41
 
42
42
  /**
@@ -179,7 +179,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
179
179
  title: string;
180
180
  tag: string | null;
181
181
  link: string | null;
182
- }[];
182
+ } | null;
183
183
  meta: object;
184
184
  }>;
185
185
  create: _trpc_server.TRPCMutationProcedure<{
@@ -227,6 +227,21 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
227
227
  output: {
228
228
  userId: number;
229
229
  roles: TUserRole[] | null;
230
+ groupAdmin: ({
231
+ addedBy: {
232
+ id: number;
233
+ firstName: string;
234
+ isBot: boolean;
235
+ lastName?: string | undefined;
236
+ username?: string | undefined;
237
+ langCode?: string | undefined;
238
+ };
239
+ group: {
240
+ title: string;
241
+ id: number;
242
+ inviteLink: string | null;
243
+ };
244
+ } | null)[];
230
245
  };
231
246
  meta: object;
232
247
  }>;
@@ -255,7 +270,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
255
270
  addRole: _trpc_server.TRPCMutationProcedure<{
256
271
  input: {
257
272
  userId: number;
258
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
273
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
259
274
  adderId: number;
260
275
  };
261
276
  output: {
@@ -270,7 +285,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
270
285
  removeRole: _trpc_server.TRPCMutationProcedure<{
271
286
  input: {
272
287
  userId: number;
273
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
288
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
274
289
  removerId: number;
275
290
  };
276
291
  output: {
@@ -290,7 +305,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
290
305
  output: boolean;
291
306
  meta: object;
292
307
  }>;
293
- addGroup: _trpc_server.TRPCQueryProcedure<{
308
+ addGroup: _trpc_server.TRPCMutationProcedure<{
294
309
  input: {
295
310
  userId: number;
296
311
  adderId: number;
@@ -299,6 +314,17 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
299
314
  output: void;
300
315
  meta: object;
301
316
  }>;
317
+ removeGroup: _trpc_server.TRPCMutationProcedure<{
318
+ input: {
319
+ userId: number;
320
+ groupId: number;
321
+ removerId: number;
322
+ };
323
+ output: {
324
+ error: "INTERNAL_SERVER_ERROR" | "UNAUTHORIZED" | "NOT_FOUND" | "UNAUTHORIZED_SELF_ASSIGN" | null;
325
+ };
326
+ meta: object;
327
+ }>;
302
328
  canAddBot: _trpc_server.TRPCQueryProcedure<{
303
329
  input: {
304
330
  userId: number;
@@ -381,6 +407,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
381
407
  authorId: number;
382
408
  message: string;
383
409
  timestamp: Date;
410
+ group?: {
411
+ title: string;
412
+ inviteLink: string | null;
413
+ } | undefined;
384
414
  };
385
415
  error: null;
386
416
  } | {
@@ -397,6 +427,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
397
427
  authorId: number;
398
428
  message: string;
399
429
  timestamp: Date;
430
+ group?: {
431
+ title: string;
432
+ inviteLink: string | null;
433
+ } | undefined;
400
434
  }[];
401
435
  };
402
436
  output: {
@@ -404,6 +438,30 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
404
438
  };
405
439
  meta: object;
406
440
  }>;
441
+ getLastByUser: _trpc_server.TRPCQueryProcedure<{
442
+ input: {
443
+ userId: number;
444
+ limit?: number | undefined;
445
+ };
446
+ output: {
447
+ messages: {
448
+ chatId: number;
449
+ messageId: number;
450
+ authorId: number;
451
+ message: string;
452
+ timestamp: Date;
453
+ group?: {
454
+ title: string;
455
+ inviteLink: string | null;
456
+ } | undefined;
457
+ }[];
458
+ error: null;
459
+ } | {
460
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
461
+ messages?: null | undefined;
462
+ };
463
+ meta: object;
464
+ }>;
407
465
  }>>;
408
466
  auditLog: _trpc_server.TRPCBuiltRouter<{
409
467
  ctx: {
@@ -496,6 +554,26 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
496
554
  };
497
555
  meta: object;
498
556
  }>;
557
+ getByUsername: _trpc_server.TRPCQueryProcedure<{
558
+ input: {
559
+ username: string;
560
+ };
561
+ output: {
562
+ user: {
563
+ id: number;
564
+ firstName: string;
565
+ isBot: boolean;
566
+ lastName?: string | undefined;
567
+ username?: string | undefined;
568
+ langCode?: string | undefined;
569
+ };
570
+ error: null;
571
+ } | {
572
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
573
+ user?: null | undefined;
574
+ };
575
+ meta: object;
576
+ }>;
499
577
  add: _trpc_server.TRPCMutationProcedure<{
500
578
  input: {
501
579
  users: {
@@ -754,4 +832,4 @@ type TelegramSocket = Socket<ToClient, ToServer>;
754
832
 
755
833
  type TelegramPlugin = typeof telegramPlugin;
756
834
 
757
- export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, WS_PATH };
835
+ export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, USER_ROLE, WS_PATH };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,14 @@ import { Socket } from 'socket.io-client';
6
6
  declare const TRPC_PATH = "/api/trpc";
7
7
  declare const AUTH_PATH = "/api/auth";
8
8
  declare const WS_PATH = "/ws";
9
+ declare const USER_ROLE: {
10
+ readonly ADMIN: "admin";
11
+ readonly HR: "hr";
12
+ readonly PRESIDENT: "president";
13
+ readonly DIRETTIVO: "direttivo";
14
+ readonly CREATOR: "creator";
15
+ readonly OWNER: "owner";
16
+ };
9
17
 
10
18
  type ParsedUser = {
11
19
  id: string;
@@ -29,14 +37,6 @@ declare const AUDIT_TYPE: {
29
37
  };
30
38
  type TAuditType = (typeof AUDIT_TYPE)[keyof typeof AUDIT_TYPE];
31
39
 
32
- declare const USER_ROLE: {
33
- readonly ADMIN: "admin";
34
- readonly HR: "hr";
35
- readonly PRESIDENT: "president";
36
- readonly DIRETTIVO: "direttivo";
37
- readonly CREATOR: "creator";
38
- readonly OWNER: "owner";
39
- };
40
40
  type TUserRole = (typeof USER_ROLE)[keyof typeof USER_ROLE];
41
41
 
42
42
  /**
@@ -179,7 +179,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
179
179
  title: string;
180
180
  tag: string | null;
181
181
  link: string | null;
182
- }[];
182
+ } | null;
183
183
  meta: object;
184
184
  }>;
185
185
  create: _trpc_server.TRPCMutationProcedure<{
@@ -227,6 +227,21 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
227
227
  output: {
228
228
  userId: number;
229
229
  roles: TUserRole[] | null;
230
+ groupAdmin: ({
231
+ addedBy: {
232
+ id: number;
233
+ firstName: string;
234
+ isBot: boolean;
235
+ lastName?: string | undefined;
236
+ username?: string | undefined;
237
+ langCode?: string | undefined;
238
+ };
239
+ group: {
240
+ title: string;
241
+ id: number;
242
+ inviteLink: string | null;
243
+ };
244
+ } | null)[];
230
245
  };
231
246
  meta: object;
232
247
  }>;
@@ -255,7 +270,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
255
270
  addRole: _trpc_server.TRPCMutationProcedure<{
256
271
  input: {
257
272
  userId: number;
258
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
273
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
259
274
  adderId: number;
260
275
  };
261
276
  output: {
@@ -270,7 +285,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
270
285
  removeRole: _trpc_server.TRPCMutationProcedure<{
271
286
  input: {
272
287
  userId: number;
273
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
288
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
274
289
  removerId: number;
275
290
  };
276
291
  output: {
@@ -290,7 +305,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
290
305
  output: boolean;
291
306
  meta: object;
292
307
  }>;
293
- addGroup: _trpc_server.TRPCQueryProcedure<{
308
+ addGroup: _trpc_server.TRPCMutationProcedure<{
294
309
  input: {
295
310
  userId: number;
296
311
  adderId: number;
@@ -299,6 +314,17 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
299
314
  output: void;
300
315
  meta: object;
301
316
  }>;
317
+ removeGroup: _trpc_server.TRPCMutationProcedure<{
318
+ input: {
319
+ userId: number;
320
+ groupId: number;
321
+ removerId: number;
322
+ };
323
+ output: {
324
+ error: "INTERNAL_SERVER_ERROR" | "UNAUTHORIZED" | "NOT_FOUND" | "UNAUTHORIZED_SELF_ASSIGN" | null;
325
+ };
326
+ meta: object;
327
+ }>;
302
328
  canAddBot: _trpc_server.TRPCQueryProcedure<{
303
329
  input: {
304
330
  userId: number;
@@ -381,6 +407,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
381
407
  authorId: number;
382
408
  message: string;
383
409
  timestamp: Date;
410
+ group?: {
411
+ title: string;
412
+ inviteLink: string | null;
413
+ } | undefined;
384
414
  };
385
415
  error: null;
386
416
  } | {
@@ -397,6 +427,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
397
427
  authorId: number;
398
428
  message: string;
399
429
  timestamp: Date;
430
+ group?: {
431
+ title: string;
432
+ inviteLink: string | null;
433
+ } | undefined;
400
434
  }[];
401
435
  };
402
436
  output: {
@@ -404,6 +438,30 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
404
438
  };
405
439
  meta: object;
406
440
  }>;
441
+ getLastByUser: _trpc_server.TRPCQueryProcedure<{
442
+ input: {
443
+ userId: number;
444
+ limit?: number | undefined;
445
+ };
446
+ output: {
447
+ messages: {
448
+ chatId: number;
449
+ messageId: number;
450
+ authorId: number;
451
+ message: string;
452
+ timestamp: Date;
453
+ group?: {
454
+ title: string;
455
+ inviteLink: string | null;
456
+ } | undefined;
457
+ }[];
458
+ error: null;
459
+ } | {
460
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
461
+ messages?: null | undefined;
462
+ };
463
+ meta: object;
464
+ }>;
407
465
  }>>;
408
466
  auditLog: _trpc_server.TRPCBuiltRouter<{
409
467
  ctx: {
@@ -496,6 +554,26 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
496
554
  };
497
555
  meta: object;
498
556
  }>;
557
+ getByUsername: _trpc_server.TRPCQueryProcedure<{
558
+ input: {
559
+ username: string;
560
+ };
561
+ output: {
562
+ user: {
563
+ id: number;
564
+ firstName: string;
565
+ isBot: boolean;
566
+ lastName?: string | undefined;
567
+ username?: string | undefined;
568
+ langCode?: string | undefined;
569
+ };
570
+ error: null;
571
+ } | {
572
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
573
+ user?: null | undefined;
574
+ };
575
+ meta: object;
576
+ }>;
499
577
  add: _trpc_server.TRPCMutationProcedure<{
500
578
  input: {
501
579
  users: {
@@ -754,4 +832,4 @@ type TelegramSocket = Socket<ToClient, ToServer>;
754
832
 
755
833
  type TelegramPlugin = typeof telegramPlugin;
756
834
 
757
- export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, WS_PATH };
835
+ export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, USER_ROLE, WS_PATH };
package/dist/index.js CHANGED
@@ -2,9 +2,18 @@
2
2
  var TRPC_PATH = "/api/trpc";
3
3
  var AUTH_PATH = "/api/auth";
4
4
  var WS_PATH = "/ws";
5
+ var USER_ROLE = {
6
+ ADMIN: "admin",
7
+ HR: "hr",
8
+ PRESIDENT: "president",
9
+ DIRETTIVO: "direttivo",
10
+ CREATOR: "creator",
11
+ OWNER: "owner"
12
+ };
5
13
  export {
6
14
  AUTH_PATH,
7
15
  TRPC_PATH,
16
+ USER_ROLE,
8
17
  WS_PATH
9
18
  };
10
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants.ts"],"sourcesContent":["export const TRPC_PATH = \"/api/trpc\"\nexport const AUTH_PATH = \"/api/auth\"\nexport const WS_PATH = \"/ws\"\n\nexport const TRUSTED_ORIGINS = [\n \"http://localhost:3001\",\n \"http://localhost:3002\",\n \"http://localhost:3003\",\n \"http://localhost:5173\",\n \"http://localhost:5174\",\n \"http://localhost:5175\",\n]\n\nexport const MESSAGES_RETENTION_DAYS = 7\n"],"mappings":";AAAO,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../../src/constants.ts"],"sourcesContent":["export const TRPC_PATH = \"/api/trpc\"\nexport const AUTH_PATH = \"/api/auth\"\nexport const WS_PATH = \"/ws\"\n\nexport const TRUSTED_ORIGINS = [\n \"http://localhost:3001\",\n \"http://localhost:3002\",\n \"http://localhost:3003\",\n \"http://localhost:5173\",\n \"http://localhost:5174\",\n \"http://localhost:5175\",\n]\n\nexport const MESSAGES_RETENTION_DAYS = 7\n\nexport const USER_ROLE = {\n ADMIN: \"admin\",\n HR: \"hr\",\n PRESIDENT: \"president\",\n DIRETTIVO: \"direttivo\",\n CREATOR: \"creator\",\n OWNER: \"owner\",\n} as const\n"],"mappings":";AAAO,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,UAAU;AAahB,IAAM,YAAY;AAAA,EACvB,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,SAAS;AAAA,EACT,OAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polinetwork/backend",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "description": "Utils to interact with the backend.",
5
5
  "repository": {
6
6
  "type": "git",