@purpleschool/gptbot 0.12.60 → 0.12.61

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.
@@ -7,4 +7,5 @@ export const WEBMASTER_ROUTES = {
7
7
  CREATE_WITHDRAWAL_REQUEST: 'withdraw',
8
8
  CONFIRM_WITHDRAWAL: (uuid: string) => `withdraw/${uuid}`,
9
9
  UPDATE: (uuid: string) => `${uuid}`,
10
+ ADMIN_UPDATE: (uuid: string) => `admin/${uuid}`,
10
11
  } as const;
package/api/routes.ts CHANGED
@@ -415,6 +415,8 @@ export const REST_API = {
415
415
  CREATE_WITHDRAWAL_REQUEST: `${ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.CREATE_WITHDRAWAL_REQUEST}`,
416
416
  UPDATE: (uuid: string) =>
417
417
  `${ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.UPDATE(uuid)}`,
418
+ ADMIN_UPDATE: (uuid: string) =>
419
+ `${ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.ADMIN_UPDATE(uuid)}`,
418
420
  CONFIRM_WITHDRAWAL: (uuid: string) =>
419
421
  `${ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.CONFIRM_WITHDRAWAL(uuid)}`,
420
422
  },
@@ -9,4 +9,5 @@ exports.WEBMASTER_ROUTES = {
9
9
  CREATE_WITHDRAWAL_REQUEST: 'withdraw',
10
10
  CONFIRM_WITHDRAWAL: (uuid) => `withdraw/${uuid}`,
11
11
  UPDATE: (uuid) => `${uuid}`,
12
+ ADMIN_UPDATE: (uuid) => `admin/${uuid}`,
12
13
  };
@@ -361,6 +361,7 @@ exports.REST_API = {
361
361
  CREATE: `${exports.ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.CREATE}`,
362
362
  CREATE_WITHDRAWAL_REQUEST: `${exports.ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.CREATE_WITHDRAWAL_REQUEST}`,
363
363
  UPDATE: (uuid) => `${exports.ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.UPDATE(uuid)}`,
364
+ ADMIN_UPDATE: (uuid) => `${exports.ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.ADMIN_UPDATE(uuid)}`,
364
365
  CONFIRM_WITHDRAWAL: (uuid) => `${exports.ROOT}/${CONTROLLERS.WEBMASTER_CONTROLLER_PRIVATE}/${CONTROLLERS.WEBMASTER_ROUTES.CONFIRM_WITHDRAWAL(uuid)}`,
365
366
  },
366
367
  TOOL: {
@@ -1,13 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpdateWebmasterCommand = void 0;
3
+ exports.AdminUpdateWebmasterCommand = exports.UpdateWebmasterCommand = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const models_1 = require("../../models");
6
6
  var UpdateWebmasterCommand;
7
7
  (function (UpdateWebmasterCommand) {
8
8
  UpdateWebmasterCommand.RequestParamSchema = models_1.WebmasterSchema.pick({ uuid: true });
9
- UpdateWebmasterCommand.RequestSchema = models_1.WebmasterSchema.partial();
9
+ UpdateWebmasterCommand.RequestSchema = models_1.WebmasterSchema.pick({
10
+ organization: true,
11
+ organizationType: true,
12
+ tin: true,
13
+ alias: true,
14
+ }).partial();
10
15
  UpdateWebmasterCommand.ResponseSchema = zod_1.z.object({
11
16
  data: models_1.WebmasterSchema,
12
17
  });
13
18
  })(UpdateWebmasterCommand || (exports.UpdateWebmasterCommand = UpdateWebmasterCommand = {}));
19
+ var AdminUpdateWebmasterCommand;
20
+ (function (AdminUpdateWebmasterCommand) {
21
+ AdminUpdateWebmasterCommand.RequestParamSchema = models_1.WebmasterSchema.pick({ uuid: true });
22
+ AdminUpdateWebmasterCommand.RequestSchema = models_1.WebmasterSchema.pick({
23
+ organization: true,
24
+ organizationType: true,
25
+ tin: true,
26
+ alias: true,
27
+ isPremium: true,
28
+ }).partial();
29
+ AdminUpdateWebmasterCommand.ResponseSchema = zod_1.z.object({
30
+ data: models_1.WebmasterSchema,
31
+ });
32
+ })(AdminUpdateWebmasterCommand || (exports.AdminUpdateWebmasterCommand = AdminUpdateWebmasterCommand = {}));
@@ -13,6 +13,7 @@ exports.WebmasterSchema = zod_1.default.object({
13
13
  organizationType: zod_1.default.nativeEnum(webmaster_1.ORGANIZATION_TYPE),
14
14
  tin: zod_1.default.string().regex(/^\d{10}$|^\d{12}$/, 'ИНН должен быть длинной в 10 или 12 цифр'),
15
15
  alias: zod_1.default.string(),
16
+ isPremium: zod_1.default.boolean(),
16
17
  createdAt: zod_1.default.date(),
17
18
  updatedAt: zod_1.default.date(),
18
19
  });
@@ -6,7 +6,34 @@ export namespace UpdateWebmasterCommand {
6
6
 
7
7
  export type RequestParam = z.infer<typeof RequestParamSchema>;
8
8
 
9
- export const RequestSchema = WebmasterSchema.partial();
9
+ export const RequestSchema = WebmasterSchema.pick({
10
+ organization: true,
11
+ organizationType: true,
12
+ tin: true,
13
+ alias: true,
14
+ }).partial();
15
+
16
+ export type Request = z.infer<typeof RequestSchema>;
17
+
18
+ export const ResponseSchema = z.object({
19
+ data: WebmasterSchema,
20
+ });
21
+
22
+ export type Response = z.infer<typeof ResponseSchema>;
23
+ }
24
+
25
+ export namespace AdminUpdateWebmasterCommand {
26
+ export const RequestParamSchema = WebmasterSchema.pick({ uuid: true });
27
+
28
+ export type RequestParam = z.infer<typeof RequestParamSchema>;
29
+
30
+ export const RequestSchema = WebmasterSchema.pick({
31
+ organization: true,
32
+ organizationType: true,
33
+ tin: true,
34
+ alias: true,
35
+ isPremium: true,
36
+ }).partial();
10
37
 
11
38
  export type Request = z.infer<typeof RequestSchema>;
12
39
 
@@ -52,10 +52,7 @@ export function estimateGptImage2OutputCostUsdFromTokens(params: {
52
52
  return (outputTokens / 1_000_000) * outputPricePer1MUsd;
53
53
  }
54
54
 
55
- export function applyTargetMargin(params: {
56
- cost: number;
57
- targetMargin?: number;
58
- }): number {
55
+ export function applyTargetMargin(params: { cost: number; targetMargin?: number }): number {
59
56
  const { cost, targetMargin = DEFAULT_TARGET_MARGIN } = params;
60
57
  if (targetMargin < 0 || targetMargin >= 1) {
61
58
  throw new Error(`targetMargin must be in [0, 1), got ${targetMargin}`);
@@ -64,10 +61,7 @@ export function applyTargetMargin(params: {
64
61
  return cost / (1 - targetMargin);
65
62
  }
66
63
 
67
- export function convertUsdToStarsCeil(params: {
68
- usd: number;
69
- starPriceUsd?: number;
70
- }): number {
64
+ export function convertUsdToStarsCeil(params: { usd: number; starPriceUsd?: number }): number {
71
65
  const { usd, starPriceUsd = DEFAULT_STAR_PRICE_USD } = params;
72
66
  if (starPriceUsd <= 0) {
73
67
  throw new Error(`starPriceUsd must be > 0, got ${starPriceUsd}`);
@@ -8,6 +8,7 @@ export const WebmasterSchema = z.object({
8
8
  organizationType: z.nativeEnum(ORGANIZATION_TYPE),
9
9
  tin: z.string().regex(/^\d{10}$|^\d{12}$/, 'ИНН должен быть длинной в 10 или 12 цифр'),
10
10
  alias: z.string(),
11
+ isPremium: z.boolean(),
11
12
 
12
13
  createdAt: z.date(),
13
14
  updatedAt: z.date(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.12.60",
3
+ "version": "0.12.61",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",