@purpleschool/gptbot 0.12.60 → 0.12.62
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/api/controllers/http/webmaster.ts +1 -0
- package/api/routes.ts +2 -0
- package/build/api/controllers/http/webmaster.js +1 -0
- package/build/api/routes.js +1 -0
- package/build/commands/team-account/find-team-accounts-by-name.command.js +2 -0
- package/build/commands/webmaster/update-webmaster.command.js +21 -2
- package/build/models/webmaster.schema.js +1 -0
- package/commands/team-account/find-team-accounts-by-name.command.ts +2 -0
- package/commands/webmaster/update-webmaster.command.ts +28 -1
- package/helpers/image-generation/calculate-gpt-image-2-price-with-margin.helper.ts +2 -8
- package/models/webmaster.schema.ts +1 -0
- package/package.json +1 -1
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
|
},
|
package/build/api/routes.js
CHANGED
|
@@ -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: {
|
|
@@ -8,6 +8,8 @@ var FindTeamAccountsByNameCommand;
|
|
|
8
8
|
(function (FindTeamAccountsByNameCommand) {
|
|
9
9
|
FindTeamAccountsByNameCommand.RequestSchema = zod_1.z.object({
|
|
10
10
|
name: zod_1.z.string().trim().min(1).optional(),
|
|
11
|
+
creatorEmail: zod_1.z.string().trim().min(1).optional(),
|
|
12
|
+
hasPaidSubscription: zod_1.z.boolean().optional(),
|
|
11
13
|
limit: zod_1.z.coerce.number().int().min(1).max(100).default(20).optional(),
|
|
12
14
|
offset: zod_1.z.coerce.number().int().min(0).default(0).optional(),
|
|
13
15
|
sortBy: zod_1.z
|
|
@@ -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.
|
|
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
|
});
|
|
@@ -5,6 +5,8 @@ import { SORT_ORDER, TEAM_ACCOUNT_ADMIN_SORT_BY } from '../../constants';
|
|
|
5
5
|
export namespace FindTeamAccountsByNameCommand {
|
|
6
6
|
export const RequestSchema = z.object({
|
|
7
7
|
name: z.string().trim().min(1).optional(),
|
|
8
|
+
creatorEmail: z.string().trim().min(1).optional(),
|
|
9
|
+
hasPaidSubscription: z.boolean().optional(),
|
|
8
10
|
limit: z.coerce.number().int().min(1).max(100).default(20).optional(),
|
|
9
11
|
offset: z.coerce.number().int().min(0).default(0).optional(),
|
|
10
12
|
sortBy: z
|
|
@@ -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.
|
|
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(),
|