@purpleschool/gptbot 0.7.58 → 0.7.59

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,5 +1,6 @@
1
- export const CABINET_CONTROLLER = 'cabinet' as const;
1
+ export const CABINET_CONTROLLER = 'private/cabinet' as const;
2
2
 
3
3
  export const CABINET_ROUTES = {
4
- GET_USER_STATISTICS: 'statistics',
4
+ GET_USER_STATISTICS_OVERVIEW: 'statistics/overview',
5
+ GET_USER_STATISTICS_BY_MONTH: 'statistics/by-month',
5
6
  } as const;
package/api/routes.ts CHANGED
@@ -302,6 +302,7 @@ export const REST_API = {
302
302
  COLLECT: `${ROOT}/${CONTROLLERS.DAILY_STREAK_PRIVATE_CONTROLLER}/${CONTROLLERS.DAILY_STREAK_ROUTES.COLLECT}`,
303
303
  },
304
304
  CABINET: {
305
- GET_USER_STATISTICS: `${ROOT}/${CONTROLLERS.CABINET_CONTROLLER}/${CONTROLLERS.CABINET_ROUTES.GET_USER_STATISTICS}`,
305
+ GET_USER_STATISTICS_OVERVIEW: `${ROOT}/${CONTROLLERS.CABINET_CONTROLLER}/${CONTROLLERS.CABINET_ROUTES.GET_USER_STATISTICS_OVERVIEW}`,
306
+ GET_USER_STATISTICS_BY_MONTH: `${ROOT}/${CONTROLLERS.CABINET_CONTROLLER}/${CONTROLLERS.CABINET_ROUTES.GET_USER_STATISTICS_BY_MONTH}`,
306
307
  },
307
308
  } as const;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CABINET_ROUTES = exports.CABINET_CONTROLLER = void 0;
4
- exports.CABINET_CONTROLLER = 'cabinet';
4
+ exports.CABINET_CONTROLLER = 'private/cabinet';
5
5
  exports.CABINET_ROUTES = {
6
- GET_USER_STATISTICS: 'statistics',
6
+ GET_USER_STATISTICS_OVERVIEW: 'statistics/overview',
7
+ GET_USER_STATISTICS_BY_MONTH: 'statistics/by-month',
7
8
  };
@@ -271,6 +271,7 @@ exports.REST_API = {
271
271
  COLLECT: `${exports.ROOT}/${CONTROLLERS.DAILY_STREAK_PRIVATE_CONTROLLER}/${CONTROLLERS.DAILY_STREAK_ROUTES.COLLECT}`,
272
272
  },
273
273
  CABINET: {
274
- GET_USER_STATISTICS: `${exports.ROOT}/${CONTROLLERS.CABINET_CONTROLLER}/${CONTROLLERS.CABINET_ROUTES.GET_USER_STATISTICS}`,
274
+ GET_USER_STATISTICS_OVERVIEW: `${exports.ROOT}/${CONTROLLERS.CABINET_CONTROLLER}/${CONTROLLERS.CABINET_ROUTES.GET_USER_STATISTICS_OVERVIEW}`,
275
+ GET_USER_STATISTICS_BY_MONTH: `${exports.ROOT}/${CONTROLLERS.CABINET_CONTROLLER}/${CONTROLLERS.CABINET_ROUTES.GET_USER_STATISTICS_BY_MONTH}`,
275
276
  },
276
277
  };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUserStatisticsByMonthCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var GetUserStatisticsByMonthCommand;
6
+ (function (GetUserStatisticsByMonthCommand) {
7
+ GetUserStatisticsByMonthCommand.UserStatisticsByMonthResponseSchema = zod_1.z.object({
8
+ month: zod_1.z.string(),
9
+ total_texts: zod_1.z.number(),
10
+ total_audios: zod_1.z.number(),
11
+ total_images: zod_1.z.number(),
12
+ total_videos: zod_1.z.number(),
13
+ total_presentations: zod_1.z.number(),
14
+ total_paraphrases: zod_1.z.number(),
15
+ total_writers: zod_1.z.number(),
16
+ });
17
+ GetUserStatisticsByMonthCommand.ResponseSchema = zod_1.z.object({
18
+ data: zod_1.z.array(GetUserStatisticsByMonthCommand.UserStatisticsByMonthResponseSchema),
19
+ });
20
+ })(GetUserStatisticsByMonthCommand || (exports.GetUserStatisticsByMonthCommand = GetUserStatisticsByMonthCommand = {}));
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUserStatisticsOverviewCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../../constants");
6
+ var GetUserStatisticsOverviewCommand;
7
+ (function (GetUserStatisticsOverviewCommand) {
8
+ GetUserStatisticsOverviewCommand.RequestSchema = zod_1.z.object({
9
+ startDate: zod_1.z.string().refine((v) => !isNaN(Date.parse(v)), {
10
+ message: 'from must be a valid date string',
11
+ }),
12
+ endDate: zod_1.z.string().refine((v) => !isNaN(Date.parse(v)), {
13
+ message: 'to must be a valid date string',
14
+ }),
15
+ groupBy: zod_1.z.nativeEnum(constants_1.GROUP_BY).default(constants_1.GROUP_BY.DAY),
16
+ });
17
+ GetUserStatisticsOverviewCommand.UserStatisticsOverviewResponseSchema = zod_1.z.object({
18
+ startDate: zod_1.z.string(),
19
+ endDate: zod_1.z.string(),
20
+ total_tokens: zod_1.z.number(),
21
+ total_messages: zod_1.z.number(),
22
+ });
23
+ GetUserStatisticsOverviewCommand.ResponseSchema = zod_1.z.object({
24
+ data: zod_1.z.array(GetUserStatisticsOverviewCommand.UserStatisticsOverviewResponseSchema),
25
+ });
26
+ })(GetUserStatisticsOverviewCommand || (exports.GetUserStatisticsOverviewCommand = GetUserStatisticsOverviewCommand = {}));
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./get-user-statistics.command"), exports);
17
+ __exportStar(require("./get-user-statistics-overview.command"), exports);
18
+ __exportStar(require("./get-user-statistics-by-month.command"), exports);
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GROUP_BY = void 0;
4
+ var GROUP_BY;
5
+ (function (GROUP_BY) {
6
+ GROUP_BY["DAY"] = "day";
7
+ GROUP_BY["WEEK"] = "week";
8
+ GROUP_BY["MONTH"] = "month";
9
+ })(GROUP_BY || (exports.GROUP_BY = GROUP_BY = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./group-by.enum"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums"), exports);
@@ -51,3 +51,4 @@ __exportStar(require("./writer"), exports);
51
51
  __exportStar(require("./tool-image-editor"), exports);
52
52
  __exportStar(require("./feedback"), exports);
53
53
  __exportStar(require("./daily-streak"), exports);
54
+ __exportStar(require("./cabinet"), exports);
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace GetUserStatisticsByMonthCommand {
4
+ export const UserStatisticsByMonthResponseSchema = z.object({
5
+ month: z.string(),
6
+ total_texts: z.number(),
7
+ total_audios: z.number(),
8
+ total_images: z.number(),
9
+ total_videos: z.number(),
10
+ total_presentations: z.number(),
11
+ total_paraphrases: z.number(),
12
+ total_writers: z.number(),
13
+ });
14
+
15
+ export const ResponseSchema = z.object({
16
+ data: z.array(UserStatisticsByMonthResponseSchema),
17
+ });
18
+
19
+ export type Response = z.infer<typeof ResponseSchema>;
20
+ }
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
+ import { GROUP_BY } from '../../constants';
2
3
 
3
- export namespace GetUserStatisticsCommand {
4
+ export namespace GetUserStatisticsOverviewCommand {
4
5
  export const RequestSchema = z.object({
5
6
  startDate: z.string().refine((v) => !isNaN(Date.parse(v)), {
6
7
  message: 'from must be a valid date string',
@@ -8,28 +9,20 @@ export namespace GetUserStatisticsCommand {
8
9
  endDate: z.string().refine((v) => !isNaN(Date.parse(v)), {
9
10
  message: 'to must be a valid date string',
10
11
  }),
11
- groupByDays: z
12
- .preprocess(
13
- (val) => (val === undefined ? 1 : Number(val)),
14
- z.number().int().positive().max(31),
15
- )
16
- .default(1),
12
+ groupBy: z.nativeEnum(GROUP_BY).default(GROUP_BY.DAY),
17
13
  });
18
14
 
19
15
  export type Request = z.infer<typeof RequestSchema>;
20
16
 
21
- export const UserStatisticsResponseSchema = z.object({
17
+ export const UserStatisticsOverviewResponseSchema = z.object({
22
18
  startDate: z.string(),
23
19
  endDate: z.string(),
24
20
  total_tokens: z.number(),
25
21
  total_messages: z.number(),
26
- total_images: z.number(),
27
- total_videos: z.number(),
28
- total_presentations: z.number(),
29
22
  });
30
23
 
31
24
  export const ResponseSchema = z.object({
32
- data: z.array(UserStatisticsResponseSchema),
25
+ data: z.array(UserStatisticsOverviewResponseSchema),
33
26
  });
34
27
 
35
28
  export type Response = z.infer<typeof ResponseSchema>;
@@ -1 +1,2 @@
1
- export * from './get-user-statistics.command';
1
+ export * from './get-user-statistics-overview.command';
2
+ export * from './get-user-statistics-by-month.command';
@@ -0,0 +1,5 @@
1
+ export enum GROUP_BY {
2
+ DAY = 'day',
3
+ WEEK = 'week',
4
+ MONTH = 'month',
5
+ }
@@ -0,0 +1 @@
1
+ export * from './group-by.enum';
@@ -0,0 +1 @@
1
+ export * from './enums';
@@ -35,3 +35,4 @@ export * from './writer';
35
35
  export * from './tool-image-editor';
36
36
  export * from './feedback';
37
37
  export * from './daily-streak';
38
+ export * from './cabinet';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.7.58",
3
+ "version": "0.7.59",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetUserStatisticsCommand = void 0;
4
- const zod_1 = require("zod");
5
- var GetUserStatisticsCommand;
6
- (function (GetUserStatisticsCommand) {
7
- GetUserStatisticsCommand.RequestSchema = zod_1.z.object({
8
- startDate: zod_1.z.string().refine((v) => !isNaN(Date.parse(v)), {
9
- message: 'from must be a valid date string',
10
- }),
11
- endDate: zod_1.z.string().refine((v) => !isNaN(Date.parse(v)), {
12
- message: 'to must be a valid date string',
13
- }),
14
- groupByDays: zod_1.z
15
- .preprocess((val) => (val === undefined ? 1 : Number(val)), zod_1.z.number().int().positive().max(31))
16
- .default(1),
17
- });
18
- GetUserStatisticsCommand.UserStatisticsResponseSchema = zod_1.z.object({
19
- startDate: zod_1.z.string(),
20
- endDate: zod_1.z.string(),
21
- total_tokens: zod_1.z.number(),
22
- total_messages: zod_1.z.number(),
23
- total_images: zod_1.z.number(),
24
- total_videos: zod_1.z.number(),
25
- total_presentations: zod_1.z.number(),
26
- });
27
- GetUserStatisticsCommand.ResponseSchema = zod_1.z.object({
28
- data: zod_1.z.array(GetUserStatisticsCommand.UserStatisticsResponseSchema),
29
- });
30
- })(GetUserStatisticsCommand || (exports.GetUserStatisticsCommand = GetUserStatisticsCommand = {}));