@polinetwork/backend 0.9.2 → 0.11.0

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
@@ -21,16 +21,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AUTH_PATH: () => AUTH_PATH,
24
- TRPC_PATH: () => TRPC_PATH
24
+ TRPC_PATH: () => TRPC_PATH,
25
+ WS_PATH: () => WS_PATH
25
26
  });
26
27
  module.exports = __toCommonJS(index_exports);
27
28
 
28
29
  // src/constants.ts
29
30
  var TRPC_PATH = "/api/trpc";
30
31
  var AUTH_PATH = "/api/auth";
32
+ var WS_PATH = "/ws";
31
33
  // Annotate the CommonJS export names for ESM import in node:
32
34
  0 && (module.exports = {
33
35
  AUTH_PATH,
34
- TRPC_PATH
36
+ TRPC_PATH,
37
+ WS_PATH
35
38
  });
36
39
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/constants.ts"],"sourcesContent":["export { TRPC_PATH, AUTH_PATH } from \"./constants\"\nexport { type AppRouter } from \"./routers\"\nimport type { telegramPlugin } from \"./auth/plugins/telegram\"\n\nexport type TelegramPlugin = typeof telegramPlugin\n","export const TRPC_PATH = \"/api/trpc\";\nexport const AUTH_PATH = \"/api/auth\";\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;;;ACAO,IAAM,YAAY;AAClB,IAAM,YAAY;","names":[]}
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":[]}
package/dist/index.d.cts CHANGED
@@ -1,9 +1,11 @@
1
1
  import * as _trpc_server from '@trpc/server';
2
2
  import * as better_auth from 'better-auth';
3
3
  import { z } from 'zod';
4
+ import { Socket } from 'socket.io-client';
4
5
 
5
6
  declare const TRPC_PATH = "/api/trpc";
6
7
  declare const AUTH_PATH = "/api/auth";
8
+ declare const WS_PATH = "/ws";
7
9
 
8
10
  declare const AUDIT_TYPE: {
9
11
  readonly BAN: "ban";
@@ -14,6 +16,16 @@ declare const AUDIT_TYPE: {
14
16
  };
15
17
  type TAuditType = (typeof AUDIT_TYPE)[keyof typeof AUDIT_TYPE];
16
18
 
19
+ declare const USER_ROLE: {
20
+ readonly ADMIN: "admin";
21
+ readonly HR: "hr";
22
+ readonly PRESIDENT: "president";
23
+ readonly DIRETTIVO: "direttivo";
24
+ readonly CREATOR: "creator";
25
+ readonly OWNER: "owner";
26
+ };
27
+ type TUserRole = (typeof USER_ROLE)[keyof typeof USER_ROLE];
28
+
17
29
  /**
18
30
  * This is the primary router for your server.
19
31
  *
@@ -191,23 +203,55 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
191
203
  };
192
204
  transformer: true;
193
205
  }, _trpc_server.TRPCDecorateCreateRouterOptions<{
194
- getRole: _trpc_server.TRPCQueryProcedure<{
206
+ getRoles: _trpc_server.TRPCQueryProcedure<{
195
207
  input: {
196
208
  userId: number;
197
209
  };
198
210
  output: {
199
211
  userId: number;
200
- role: string;
212
+ roles: TUserRole[] | null;
213
+ };
214
+ meta: object;
215
+ }>;
216
+ getDirettivo: _trpc_server.TRPCQueryProcedure<{
217
+ input: void;
218
+ output: {
219
+ members: {
220
+ userId: number;
221
+ isPresident: boolean;
222
+ }[];
223
+ error: "INTERNAL_SERVER_ERROR" | "EMPTY" | "NOT_ENOUGH_MEMBERS" | "TOO_MANY_MEMBERS" | null;
201
224
  };
202
225
  meta: object;
203
226
  }>;
204
- setRole: _trpc_server.TRPCQueryProcedure<{
227
+ addRole: _trpc_server.TRPCMutationProcedure<{
205
228
  input: {
206
229
  userId: number;
207
- role: "admin" | "hr" | "direttivo" | "creator" | "owner";
230
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
208
231
  adderId: number;
209
232
  };
210
- output: void;
233
+ output: {
234
+ roles: TUserRole[];
235
+ error: null;
236
+ } | {
237
+ error: "INTERNAL_SERVER_ERROR" | "UNAUTHORIZED" | "UNAUTHORIZED_SELF_ASSIGN" | null;
238
+ roles?: null | undefined;
239
+ };
240
+ meta: object;
241
+ }>;
242
+ removeRole: _trpc_server.TRPCMutationProcedure<{
243
+ input: {
244
+ userId: number;
245
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
246
+ removerId: number;
247
+ };
248
+ output: {
249
+ roles: TUserRole[];
250
+ error: null;
251
+ } | {
252
+ error: "INTERNAL_SERVER_ERROR" | "UNAUTHORIZED" | "NOT_FOUND" | "UNAUTHORIZED_SELF_ASSIGN" | null;
253
+ roles?: null | undefined;
254
+ };
211
255
  meta: object;
212
256
  }>;
213
257
  checkGroup: _trpc_server.TRPCQueryProcedure<{
@@ -593,6 +637,16 @@ declare const telegramPlugin: () => {
593
637
  };
594
638
  };
595
639
 
640
+ interface ToClient {
641
+ ban: (data: {
642
+ chatId: number;
643
+ userId: number;
644
+ durationInSeconds?: number;
645
+ }, cb: (error: string | null) => void) => void;
646
+ }
647
+ type ToServer = {};
648
+ type TelegramSocket = Socket<ToClient, ToServer>;
649
+
596
650
  type TelegramPlugin = typeof telegramPlugin;
597
651
 
598
- export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin };
652
+ export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, WS_PATH };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import * as _trpc_server from '@trpc/server';
2
2
  import * as better_auth from 'better-auth';
3
3
  import { z } from 'zod';
4
+ import { Socket } from 'socket.io-client';
4
5
 
5
6
  declare const TRPC_PATH = "/api/trpc";
6
7
  declare const AUTH_PATH = "/api/auth";
8
+ declare const WS_PATH = "/ws";
7
9
 
8
10
  declare const AUDIT_TYPE: {
9
11
  readonly BAN: "ban";
@@ -14,6 +16,16 @@ declare const AUDIT_TYPE: {
14
16
  };
15
17
  type TAuditType = (typeof AUDIT_TYPE)[keyof typeof AUDIT_TYPE];
16
18
 
19
+ declare const USER_ROLE: {
20
+ readonly ADMIN: "admin";
21
+ readonly HR: "hr";
22
+ readonly PRESIDENT: "president";
23
+ readonly DIRETTIVO: "direttivo";
24
+ readonly CREATOR: "creator";
25
+ readonly OWNER: "owner";
26
+ };
27
+ type TUserRole = (typeof USER_ROLE)[keyof typeof USER_ROLE];
28
+
17
29
  /**
18
30
  * This is the primary router for your server.
19
31
  *
@@ -191,23 +203,55 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
191
203
  };
192
204
  transformer: true;
193
205
  }, _trpc_server.TRPCDecorateCreateRouterOptions<{
194
- getRole: _trpc_server.TRPCQueryProcedure<{
206
+ getRoles: _trpc_server.TRPCQueryProcedure<{
195
207
  input: {
196
208
  userId: number;
197
209
  };
198
210
  output: {
199
211
  userId: number;
200
- role: string;
212
+ roles: TUserRole[] | null;
213
+ };
214
+ meta: object;
215
+ }>;
216
+ getDirettivo: _trpc_server.TRPCQueryProcedure<{
217
+ input: void;
218
+ output: {
219
+ members: {
220
+ userId: number;
221
+ isPresident: boolean;
222
+ }[];
223
+ error: "INTERNAL_SERVER_ERROR" | "EMPTY" | "NOT_ENOUGH_MEMBERS" | "TOO_MANY_MEMBERS" | null;
201
224
  };
202
225
  meta: object;
203
226
  }>;
204
- setRole: _trpc_server.TRPCQueryProcedure<{
227
+ addRole: _trpc_server.TRPCMutationProcedure<{
205
228
  input: {
206
229
  userId: number;
207
- role: "admin" | "hr" | "direttivo" | "creator" | "owner";
230
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
208
231
  adderId: number;
209
232
  };
210
- output: void;
233
+ output: {
234
+ roles: TUserRole[];
235
+ error: null;
236
+ } | {
237
+ error: "INTERNAL_SERVER_ERROR" | "UNAUTHORIZED" | "UNAUTHORIZED_SELF_ASSIGN" | null;
238
+ roles?: null | undefined;
239
+ };
240
+ meta: object;
241
+ }>;
242
+ removeRole: _trpc_server.TRPCMutationProcedure<{
243
+ input: {
244
+ userId: number;
245
+ role: "admin" | "hr" | "president" | "direttivo" | "creator" | "owner";
246
+ removerId: number;
247
+ };
248
+ output: {
249
+ roles: TUserRole[];
250
+ error: null;
251
+ } | {
252
+ error: "INTERNAL_SERVER_ERROR" | "UNAUTHORIZED" | "NOT_FOUND" | "UNAUTHORIZED_SELF_ASSIGN" | null;
253
+ roles?: null | undefined;
254
+ };
211
255
  meta: object;
212
256
  }>;
213
257
  checkGroup: _trpc_server.TRPCQueryProcedure<{
@@ -593,6 +637,16 @@ declare const telegramPlugin: () => {
593
637
  };
594
638
  };
595
639
 
640
+ interface ToClient {
641
+ ban: (data: {
642
+ chatId: number;
643
+ userId: number;
644
+ durationInSeconds?: number;
645
+ }, cb: (error: string | null) => void) => void;
646
+ }
647
+ type ToServer = {};
648
+ type TelegramSocket = Socket<ToClient, ToServer>;
649
+
596
650
  type TelegramPlugin = typeof telegramPlugin;
597
651
 
598
- export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin };
652
+ export { AUTH_PATH, type AppRouter, TRPC_PATH, type TelegramPlugin, type TelegramSocket, WS_PATH };
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  // src/constants.ts
2
2
  var TRPC_PATH = "/api/trpc";
3
3
  var AUTH_PATH = "/api/auth";
4
+ var WS_PATH = "/ws";
4
5
  export {
5
6
  AUTH_PATH,
6
- TRPC_PATH
7
+ TRPC_PATH,
8
+ WS_PATH
7
9
  };
8
10
  //# 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\";\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;","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"],"mappings":";AAAO,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,UAAU;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polinetwork/backend",
3
- "version": "0.9.2",
3
+ "version": "0.11.0",
4
4
  "description": "Utils to interact with the backend.",
5
5
  "repository": {
6
6
  "type": "git",