@purpleschool/gptbot 0.7.95-ai-proxy → 0.7.96-b2b

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,9 @@
1
+ export const B2B_CONTROLLER = 'private/b2b' as const;
2
+
3
+ export const B2B_ROUTES = {
4
+ GET_API_TOKEN: 'token',
5
+ REFRESH_API_TOKEN: 'token/refresh',
6
+ SEND_TEXT_REQUEST: 'completions',
7
+ SEND_IMAGE_REQUEST: 'image/generation',
8
+ FILE_UPLOAD: 'file/upload',
9
+ } as const;
@@ -53,3 +53,4 @@ export * from './cabinet';
53
53
  export * from './webmaster';
54
54
  export * from './music';
55
55
  export * from './webmaster-click';
56
+ export * from './b2b';
package/api/routes.ts CHANGED
@@ -794,4 +794,11 @@ export const REST_API = {
794
794
  CLOUD_PAYMENTS: {
795
795
  CALLBACK: `${ROOT}/${CONTROLLERS.CLOUD_PAYMENTS_CONTROLLER}/${CONTROLLERS.CLOUD_PAYMENTS_ROUTES.CALLBACK}`,
796
796
  },
797
+ B2B: {
798
+ GET_API_TOKEN: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.GET_API_TOKEN}`,
799
+ REFRESH_API_TOKEN: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.REFRESH_API_TOKEN}`,
800
+ SEND_TEXT_REQUEST: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_TEXT_REQUEST}`,
801
+ SEND_IMAGE_REQUEST: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_IMAGE_REQUEST}`,
802
+ FILE_UPLOAD: `${ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.FILE_UPLOAD}`,
803
+ },
797
804
  } as const;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.B2B_ROUTES = exports.B2B_CONTROLLER = void 0;
4
+ exports.B2B_CONTROLLER = 'private/b2b';
5
+ exports.B2B_ROUTES = {
6
+ GET_API_TOKEN: 'token',
7
+ REFRESH_API_TOKEN: 'token/refresh',
8
+ SEND_TEXT_REQUEST: 'completions',
9
+ SEND_IMAGE_REQUEST: 'image/generation',
10
+ FILE_UPLOAD: 'file/upload',
11
+ };
@@ -69,3 +69,4 @@ __exportStar(require("./cabinet"), exports);
69
69
  __exportStar(require("./webmaster"), exports);
70
70
  __exportStar(require("./music"), exports);
71
71
  __exportStar(require("./webmaster-click"), exports);
72
+ __exportStar(require("./b2b"), exports);
@@ -623,4 +623,11 @@ exports.REST_API = {
623
623
  CLOUD_PAYMENTS: {
624
624
  CALLBACK: `${exports.ROOT}/${CONTROLLERS.CLOUD_PAYMENTS_CONTROLLER}/${CONTROLLERS.CLOUD_PAYMENTS_ROUTES.CALLBACK}`,
625
625
  },
626
+ B2B: {
627
+ GET_API_TOKEN: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.GET_API_TOKEN}`,
628
+ REFRESH_API_TOKEN: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.REFRESH_API_TOKEN}`,
629
+ SEND_TEXT_REQUEST: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_TEXT_REQUEST}`,
630
+ SEND_IMAGE_REQUEST: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.SEND_IMAGE_REQUEST}`,
631
+ FILE_UPLOAD: `${exports.ROOT}/${CONTROLLERS.B2B_CONTROLLER}/${CONTROLLERS.B2B_ROUTES.FILE_UPLOAD}`,
632
+ },
626
633
  };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetApiKeyCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var GetApiKeyCommand;
6
+ (function (GetApiKeyCommand) {
7
+ GetApiKeyCommand.ResponseSchema = zod_1.z.object({
8
+ data: zod_1.z.object({
9
+ apiKey: zod_1.z.string(),
10
+ }),
11
+ });
12
+ })(GetApiKeyCommand || (exports.GetApiKeyCommand = GetApiKeyCommand = {}));
@@ -0,0 +1,20 @@
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("./get-api-key.command"), exports);
18
+ __exportStar(require("./refresh-api-key.command"), exports);
19
+ __exportStar(require("./send-text-request.command"), exports);
20
+ __exportStar(require("./send-image-request.command"), exports);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RefreshApiKeyCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ var RefreshApiKeyCommand;
6
+ (function (RefreshApiKeyCommand) {
7
+ RefreshApiKeyCommand.ResponseSchema = zod_1.z.object({
8
+ data: zod_1.z.object({
9
+ apiKey: zod_1.z.string(),
10
+ }),
11
+ });
12
+ })(RefreshApiKeyCommand || (exports.RefreshApiKeyCommand = RefreshApiKeyCommand = {}));
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SendImageRequestCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../../constants");
6
+ var SendImageRequestCommand;
7
+ (function (SendImageRequestCommand) {
8
+ SendImageRequestCommand.RequestSchema = zod_1.z.object({
9
+ model: zod_1.z.string(),
10
+ prompt: zod_1.z.string(),
11
+ params: zod_1.z.array(zod_1.z.object({
12
+ type: zod_1.z.nativeEnum(constants_1.AI_MODEL_CONFIG_PARAM),
13
+ option: zod_1.z.string().uuid(),
14
+ })),
15
+ refinePrompt: zod_1.z.boolean().default(false),
16
+ features: zod_1.z.array(zod_1.z.nativeEnum(constants_1.AI_MODEL_FEATURE)).optional().default([]),
17
+ files: zod_1.z.array(zod_1.z.string().uuid()).optional().default([]),
18
+ });
19
+ SendImageRequestCommand.ResponseSchema = zod_1.z.object({
20
+ data: zod_1.z.object({
21
+ urls: zod_1.z.array(zod_1.z.string()),
22
+ }),
23
+ });
24
+ })(SendImageRequestCommand || (exports.SendImageRequestCommand = SendImageRequestCommand = {}));
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SendTextRequestCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../../constants");
6
+ var SendTextRequestCommand;
7
+ (function (SendTextRequestCommand) {
8
+ SendTextRequestCommand.BodySchema = zod_1.z.object({
9
+ model: zod_1.z.string(),
10
+ prompt: zod_1.z.string(),
11
+ files: zod_1.z.array(zod_1.z.string().uuid()),
12
+ features: zod_1.z.array(zod_1.z.nativeEnum(constants_1.AI_MODEL_FEATURE)),
13
+ });
14
+ SendTextRequestCommand.HeadersSchema = zod_1.z.object({
15
+ 'x-rugpt-key': zod_1.z.string(),
16
+ });
17
+ SendTextRequestCommand.ResponseSchema = zod_1.z.object({
18
+ data: zod_1.z.object({
19
+ text: zod_1.z.string(),
20
+ }),
21
+ });
22
+ })(SendTextRequestCommand || (exports.SendTextRequestCommand = SendTextRequestCommand = {}));
@@ -55,3 +55,4 @@ __exportStar(require("./daily-streak"), exports);
55
55
  __exportStar(require("./cabinet"), exports);
56
56
  __exportStar(require("./webmaster"), exports);
57
57
  __exportStar(require("./webmaster-click"), exports);
58
+ __exportStar(require("./b2b"), exports);
@@ -2346,4 +2346,29 @@ exports.ERRORS = {
2346
2346
  message: 'Ошибка при получении сводки записей о переходе по ссылке вебмастера',
2347
2347
  httpCode: 409,
2348
2348
  },
2349
+ FAILED_TO_GENERATE_API_KEY: {
2350
+ code: 'A480',
2351
+ message: 'Не удалось сгенерировать ключ API',
2352
+ httpCode: 500,
2353
+ },
2354
+ FAILED_TO_REFRESH_API_KEY: {
2355
+ code: 'A481',
2356
+ message: 'Не удалось обновить ключ API',
2357
+ httpCode: 500,
2358
+ },
2359
+ API_KEY_NOT_FOUND: {
2360
+ code: 'A482',
2361
+ message: 'Ключ API не найден',
2362
+ httpCode: 404,
2363
+ },
2364
+ API_KEY_IS_INACTIVE: {
2365
+ code: 'A483',
2366
+ message: 'Ключ API не активен',
2367
+ httpCode: 403,
2368
+ },
2369
+ API_KEY_ALREADY_EXISTS: {
2370
+ code: 'A484',
2371
+ message: 'Ключ API уже существует, если потеряли ключ воспользуйтесь GET token/refresh',
2372
+ httpCode: 409,
2373
+ },
2349
2374
  };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ApiKeySchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.ApiKeySchema = zod_1.default.object({
9
+ uuid: zod_1.default.string().uuid(),
10
+ userId: zod_1.default.string().uuid(),
11
+ key: zod_1.default.string(),
12
+ isActive: zod_1.default.boolean(),
13
+ createdAt: zod_1.default.date(),
14
+ updatedAt: zod_1.default.date(),
15
+ });
@@ -70,3 +70,4 @@ __exportStar(require("./webmaster.schema"), exports);
70
70
  __exportStar(require("./webmaster-balance.schema"), exports);
71
71
  __exportStar(require("./user-referrals.schema"), exports);
72
72
  __exportStar(require("./webmaster-click.schema"), exports);
73
+ __exportStar(require("./api-key.schema"), exports);
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace GetApiKeyCommand {
4
+ export const ResponseSchema = z.object({
5
+ data: z.object({
6
+ apiKey: z.string(),
7
+ }),
8
+ });
9
+
10
+ export type Response = z.infer<typeof ResponseSchema>;
11
+ }
@@ -0,0 +1,4 @@
1
+ export * from './get-api-key.command';
2
+ export * from './refresh-api-key.command';
3
+ export * from './send-text-request.command';
4
+ export * from './send-image-request.command';
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+
3
+ export namespace RefreshApiKeyCommand {
4
+ export const ResponseSchema = z.object({
5
+ data: z.object({
6
+ apiKey: z.string(),
7
+ }),
8
+ });
9
+
10
+ export type Response = z.infer<typeof ResponseSchema>;
11
+ }
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { AI_MODEL_CONFIG_PARAM, AI_MODEL_FEATURE } from '../../constants';
3
+
4
+ export namespace SendImageRequestCommand {
5
+ export const RequestSchema = z.object({
6
+ model: z.string(),
7
+ prompt: z.string(),
8
+ params: z.array(
9
+ z.object({
10
+ type: z.nativeEnum(AI_MODEL_CONFIG_PARAM),
11
+ option: z.string().uuid(),
12
+ }),
13
+ ),
14
+ refinePrompt: z.boolean().default(false),
15
+ features: z.array(z.nativeEnum(AI_MODEL_FEATURE)).optional().default([]),
16
+ files: z.array(z.string().uuid()).optional().default([]),
17
+ });
18
+
19
+ export type Request = z.infer<typeof RequestSchema>;
20
+
21
+ export const ResponseSchema = z.object({
22
+ data: z.object({
23
+ urls: z.array(z.string()),
24
+ }),
25
+ });
26
+
27
+ export type Response = z.infer<typeof ResponseSchema>;
28
+ }
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { AI_MODEL_FEATURE } from '../../constants';
3
+
4
+ export namespace SendTextRequestCommand {
5
+ export const BodySchema = z.object({
6
+ model: z.string(),
7
+ prompt: z.string(),
8
+ files: z.array(z.string().uuid()),
9
+ features: z.array(z.nativeEnum(AI_MODEL_FEATURE)),
10
+ });
11
+
12
+ export const HeadersSchema = z.object({
13
+ 'x-rugpt-key': z.string(),
14
+ });
15
+
16
+ export const ResponseSchema = z.object({
17
+ data: z.object({
18
+ text: z.string(),
19
+ }),
20
+ });
21
+
22
+ // ✅ Types
23
+ export type Body = z.infer<typeof BodySchema>;
24
+ export type Headers = z.infer<typeof HeadersSchema>;
25
+ export type Response = z.infer<typeof ResponseSchema>;
26
+ }
package/commands/index.ts CHANGED
@@ -39,3 +39,4 @@ export * from './daily-streak';
39
39
  export * from './cabinet';
40
40
  export * from './webmaster';
41
41
  export * from './webmaster-click';
42
+ export * from './b2b';
@@ -2354,4 +2354,29 @@ export const ERRORS = {
2354
2354
  message: 'Ошибка при получении сводки записей о переходе по ссылке вебмастера',
2355
2355
  httpCode: 409,
2356
2356
  },
2357
+ FAILED_TO_GENERATE_API_KEY: {
2358
+ code: 'A480',
2359
+ message: 'Не удалось сгенерировать ключ API',
2360
+ httpCode: 500,
2361
+ },
2362
+ FAILED_TO_REFRESH_API_KEY: {
2363
+ code: 'A481',
2364
+ message: 'Не удалось обновить ключ API',
2365
+ httpCode: 500,
2366
+ },
2367
+ API_KEY_NOT_FOUND: {
2368
+ code: 'A482',
2369
+ message: 'Ключ API не найден',
2370
+ httpCode: 404,
2371
+ },
2372
+ API_KEY_IS_INACTIVE: {
2373
+ code: 'A483',
2374
+ message: 'Ключ API не активен',
2375
+ httpCode: 403,
2376
+ },
2377
+ API_KEY_ALREADY_EXISTS: {
2378
+ code: 'A484',
2379
+ message: 'Ключ API уже существует, если потеряли ключ воспользуйтесь GET token/refresh',
2380
+ httpCode: 409,
2381
+ },
2357
2382
  };
@@ -0,0 +1,10 @@
1
+ import z from 'zod';
2
+
3
+ export const ApiKeySchema = z.object({
4
+ uuid: z.string().uuid(),
5
+ userId: z.string().uuid(),
6
+ key: z.string(),
7
+ isActive: z.boolean(),
8
+ createdAt: z.date(),
9
+ updatedAt: z.date(),
10
+ });
package/models/index.ts CHANGED
@@ -54,3 +54,4 @@ export * from './webmaster.schema';
54
54
  export * from './webmaster-balance.schema';
55
55
  export * from './user-referrals.schema';
56
56
  export * from './webmaster-click.schema';
57
+ export * from './api-key.schema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.7.95-ai-proxy",
3
+ "version": "0.7.96-b2b",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",