@polinetwork/backend 0.15.4 → 0.15.6

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
  /**
@@ -140,6 +140,18 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
140
140
  };
141
141
  transformer: true;
142
142
  }, _trpc_server.TRPCDecorateCreateRouterOptions<{
143
+ getAll: _trpc_server.TRPCQueryProcedure<{
144
+ input: void;
145
+ output: {
146
+ updatedAt: Date | null;
147
+ createdAt: Date;
148
+ telegramId: number;
149
+ title: string;
150
+ tag: string | null;
151
+ link: string | null;
152
+ }[];
153
+ meta: object;
154
+ }>;
143
155
  search: _trpc_server.TRPCQueryProcedure<{
144
156
  input: {
145
157
  query: string;
@@ -215,6 +227,21 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
215
227
  output: {
216
228
  userId: number;
217
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)[];
218
245
  };
219
246
  meta: object;
220
247
  }>;
@@ -243,7 +270,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
243
270
  addRole: _trpc_server.TRPCMutationProcedure<{
244
271
  input: {
245
272
  userId: number;
246
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
273
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
247
274
  adderId: number;
248
275
  };
249
276
  output: {
@@ -258,7 +285,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
258
285
  removeRole: _trpc_server.TRPCMutationProcedure<{
259
286
  input: {
260
287
  userId: number;
261
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
288
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
262
289
  removerId: number;
263
290
  };
264
291
  output: {
@@ -278,7 +305,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
278
305
  output: boolean;
279
306
  meta: object;
280
307
  }>;
281
- addGroup: _trpc_server.TRPCQueryProcedure<{
308
+ addGroup: _trpc_server.TRPCMutationProcedure<{
282
309
  input: {
283
310
  userId: number;
284
311
  adderId: number;
@@ -287,6 +314,17 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
287
314
  output: void;
288
315
  meta: object;
289
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
+ }>;
290
328
  canAddBot: _trpc_server.TRPCQueryProcedure<{
291
329
  input: {
292
330
  userId: number;
@@ -369,6 +407,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
369
407
  authorId: number;
370
408
  message: string;
371
409
  timestamp: Date;
410
+ group?: {
411
+ title: string;
412
+ inviteLink: string | null;
413
+ } | undefined;
372
414
  };
373
415
  error: null;
374
416
  } | {
@@ -385,6 +427,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
385
427
  authorId: number;
386
428
  message: string;
387
429
  timestamp: Date;
430
+ group?: {
431
+ title: string;
432
+ inviteLink: string | null;
433
+ } | undefined;
388
434
  }[];
389
435
  };
390
436
  output: {
@@ -392,6 +438,29 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
392
438
  };
393
439
  meta: object;
394
440
  }>;
441
+ getLastByUser: _trpc_server.TRPCQueryProcedure<{
442
+ input: {
443
+ userId: number;
444
+ };
445
+ output: {
446
+ messages: {
447
+ chatId: number;
448
+ messageId: number;
449
+ authorId: number;
450
+ message: string;
451
+ timestamp: Date;
452
+ group?: {
453
+ title: string;
454
+ inviteLink: string | null;
455
+ } | undefined;
456
+ }[];
457
+ error: null;
458
+ } | {
459
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
460
+ messages?: null | undefined;
461
+ };
462
+ meta: object;
463
+ }>;
395
464
  }>>;
396
465
  auditLog: _trpc_server.TRPCBuiltRouter<{
397
466
  ctx: {
@@ -484,6 +553,26 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
484
553
  };
485
554
  meta: object;
486
555
  }>;
556
+ getByUsername: _trpc_server.TRPCQueryProcedure<{
557
+ input: {
558
+ username: string;
559
+ };
560
+ output: {
561
+ user: {
562
+ id: number;
563
+ firstName: string;
564
+ isBot: boolean;
565
+ lastName?: string | undefined;
566
+ username?: string | undefined;
567
+ langCode?: string | undefined;
568
+ };
569
+ error: null;
570
+ } | {
571
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
572
+ user?: null | undefined;
573
+ };
574
+ meta: object;
575
+ }>;
487
576
  add: _trpc_server.TRPCMutationProcedure<{
488
577
  input: {
489
578
  users: {
@@ -742,4 +831,4 @@ type TelegramSocket = Socket<ToClient, ToServer>;
742
831
 
743
832
  type TelegramPlugin = typeof telegramPlugin;
744
833
 
745
- export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, WS_PATH };
834
+ 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
  /**
@@ -140,6 +140,18 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
140
140
  };
141
141
  transformer: true;
142
142
  }, _trpc_server.TRPCDecorateCreateRouterOptions<{
143
+ getAll: _trpc_server.TRPCQueryProcedure<{
144
+ input: void;
145
+ output: {
146
+ updatedAt: Date | null;
147
+ createdAt: Date;
148
+ telegramId: number;
149
+ title: string;
150
+ tag: string | null;
151
+ link: string | null;
152
+ }[];
153
+ meta: object;
154
+ }>;
143
155
  search: _trpc_server.TRPCQueryProcedure<{
144
156
  input: {
145
157
  query: string;
@@ -215,6 +227,21 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
215
227
  output: {
216
228
  userId: number;
217
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)[];
218
245
  };
219
246
  meta: object;
220
247
  }>;
@@ -243,7 +270,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
243
270
  addRole: _trpc_server.TRPCMutationProcedure<{
244
271
  input: {
245
272
  userId: number;
246
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
273
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
247
274
  adderId: number;
248
275
  };
249
276
  output: {
@@ -258,7 +285,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
258
285
  removeRole: _trpc_server.TRPCMutationProcedure<{
259
286
  input: {
260
287
  userId: number;
261
- role: "hr" | "admin" | "president" | "direttivo" | "creator" | "owner";
288
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
262
289
  removerId: number;
263
290
  };
264
291
  output: {
@@ -278,7 +305,7 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
278
305
  output: boolean;
279
306
  meta: object;
280
307
  }>;
281
- addGroup: _trpc_server.TRPCQueryProcedure<{
308
+ addGroup: _trpc_server.TRPCMutationProcedure<{
282
309
  input: {
283
310
  userId: number;
284
311
  adderId: number;
@@ -287,6 +314,17 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
287
314
  output: void;
288
315
  meta: object;
289
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
+ }>;
290
328
  canAddBot: _trpc_server.TRPCQueryProcedure<{
291
329
  input: {
292
330
  userId: number;
@@ -369,6 +407,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
369
407
  authorId: number;
370
408
  message: string;
371
409
  timestamp: Date;
410
+ group?: {
411
+ title: string;
412
+ inviteLink: string | null;
413
+ } | undefined;
372
414
  };
373
415
  error: null;
374
416
  } | {
@@ -385,6 +427,10 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
385
427
  authorId: number;
386
428
  message: string;
387
429
  timestamp: Date;
430
+ group?: {
431
+ title: string;
432
+ inviteLink: string | null;
433
+ } | undefined;
388
434
  }[];
389
435
  };
390
436
  output: {
@@ -392,6 +438,29 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
392
438
  };
393
439
  meta: object;
394
440
  }>;
441
+ getLastByUser: _trpc_server.TRPCQueryProcedure<{
442
+ input: {
443
+ userId: number;
444
+ };
445
+ output: {
446
+ messages: {
447
+ chatId: number;
448
+ messageId: number;
449
+ authorId: number;
450
+ message: string;
451
+ timestamp: Date;
452
+ group?: {
453
+ title: string;
454
+ inviteLink: string | null;
455
+ } | undefined;
456
+ }[];
457
+ error: null;
458
+ } | {
459
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
460
+ messages?: null | undefined;
461
+ };
462
+ meta: object;
463
+ }>;
395
464
  }>>;
396
465
  auditLog: _trpc_server.TRPCBuiltRouter<{
397
466
  ctx: {
@@ -484,6 +553,26 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
484
553
  };
485
554
  meta: object;
486
555
  }>;
556
+ getByUsername: _trpc_server.TRPCQueryProcedure<{
557
+ input: {
558
+ username: string;
559
+ };
560
+ output: {
561
+ user: {
562
+ id: number;
563
+ firstName: string;
564
+ isBot: boolean;
565
+ lastName?: string | undefined;
566
+ username?: string | undefined;
567
+ langCode?: string | undefined;
568
+ };
569
+ error: null;
570
+ } | {
571
+ error: "INTERNAL_SERVER_ERROR" | "NOT_FOUND" | "DECRYPT_ERROR";
572
+ user?: null | undefined;
573
+ };
574
+ meta: object;
575
+ }>;
487
576
  add: _trpc_server.TRPCMutationProcedure<{
488
577
  input: {
489
578
  users: {
@@ -742,4 +831,4 @@ type TelegramSocket = Socket<ToClient, ToServer>;
742
831
 
743
832
  type TelegramPlugin = typeof telegramPlugin;
744
833
 
745
- export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, WS_PATH };
834
+ 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.4",
3
+ "version": "0.15.6",
4
4
  "description": "Utils to interact with the backend.",
5
5
  "repository": {
6
6
  "type": "git",