@purpleschool/gptbot 0.7.25 → 0.7.27
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/daily-streak.ts +6 -0
- package/api/controllers/http/index.ts +1 -0
- package/api/routes.ts +4 -0
- package/build/api/controllers/http/daily-streak.js +8 -0
- package/build/api/controllers/http/index.js +1 -0
- package/build/api/routes.js +4 -0
- package/build/commands/daily-streak/collect-daily-reward.command.js +11 -0
- package/build/commands/daily-streak/get-daily-streak.command.js +11 -0
- package/build/commands/daily-streak/index.js +18 -0
- package/build/commands/index.js +1 -0
- package/build/commands/tools/video/video.command.js +1 -6
- package/build/constants/daily-streak/enums/daily-streak-status.enum.js +9 -0
- package/build/constants/daily-streak/enums/day-in-daily-streak-reward-type.enum.js +8 -0
- package/build/constants/daily-streak/enums/index.js +18 -0
- package/build/constants/daily-streak/index.js +17 -0
- package/build/constants/errors/errors.js +35 -0
- package/build/constants/index.js +1 -0
- package/build/constants/promocode/enums/promocode-promotion.enum.js +1 -0
- package/build/constants/tool-video/enums/index.js +1 -0
- package/build/constants/tool-video/enums/video-pricing-rule-type.enum.js +7 -0
- package/build/helpers/video/calculate-video-price.helper.js +25 -5
- package/build/models/daily-streak.js +29 -0
- package/build/models/index.js +1 -0
- package/build/models/tools/video/video-model.schema.js +17 -1
- package/commands/daily-streak/collect-daily-reward.command.ts +12 -0
- package/commands/daily-streak/get-daily-streak.command.ts +12 -0
- package/commands/daily-streak/index.ts +2 -0
- package/commands/index.ts +1 -0
- package/commands/tools/video/video.command.ts +2 -7
- package/constants/daily-streak/enums/daily-streak-status.enum.ts +5 -0
- package/constants/daily-streak/enums/day-in-daily-streak-reward-type.enum.ts +4 -0
- package/constants/daily-streak/enums/index.ts +2 -0
- package/constants/daily-streak/index.ts +1 -0
- package/constants/errors/errors.ts +35 -0
- package/constants/index.ts +1 -0
- package/constants/promocode/enums/promocode-promotion.enum.ts +1 -0
- package/constants/tool-video/enums/index.ts +1 -0
- package/constants/tool-video/enums/video-pricing-rule-type.enum.ts +3 -0
- package/helpers/video/calculate-video-price.helper.ts +48 -4
- package/models/daily-streak.ts +27 -0
- package/models/index.ts +1 -0
- package/models/tools/video/video-model.schema.ts +24 -0
- package/package.json +1 -1
package/api/routes.ts
CHANGED
|
@@ -284,4 +284,8 @@ export const REST_API = {
|
|
|
284
284
|
FEEDBACK_PUBLIC: {
|
|
285
285
|
CHECK_IF_USER_READY_FOR_FEEDBACK: `${ROOT}/${CONTROLLERS.FEEDBACK_CONTROLLER_PUBLIC}/${CONTROLLERS.FEEDBACK_ROUTES.CHECK_IF_USER_READY_FOR_FEEDBACK}`,
|
|
286
286
|
},
|
|
287
|
+
DAILY_STREAK_PRIVATE: {
|
|
288
|
+
GET: `${ROOT}/${CONTROLLERS.DAILY_STREAK_PRIVATE_CONTROLLER}/${CONTROLLERS.DAILY_STREAK_ROUTES.GET}`,
|
|
289
|
+
COLLECT: `${ROOT}/${CONTROLLERS.DAILY_STREAK_PRIVATE_CONTROLLER}/${CONTROLLERS.DAILY_STREAK_ROUTES.COLLECT}`,
|
|
290
|
+
},
|
|
287
291
|
} as const;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DAILY_STREAK_ROUTES = exports.DAILY_STREAK_PRIVATE_CONTROLLER = void 0;
|
|
4
|
+
exports.DAILY_STREAK_PRIVATE_CONTROLLER = 'private/daily-streak';
|
|
5
|
+
exports.DAILY_STREAK_ROUTES = {
|
|
6
|
+
GET: '',
|
|
7
|
+
COLLECT: 'collect',
|
|
8
|
+
};
|
package/build/api/routes.js
CHANGED
|
@@ -256,4 +256,8 @@ exports.REST_API = {
|
|
|
256
256
|
FEEDBACK_PUBLIC: {
|
|
257
257
|
CHECK_IF_USER_READY_FOR_FEEDBACK: `${exports.ROOT}/${CONTROLLERS.FEEDBACK_CONTROLLER_PUBLIC}/${CONTROLLERS.FEEDBACK_ROUTES.CHECK_IF_USER_READY_FOR_FEEDBACK}`,
|
|
258
258
|
},
|
|
259
|
+
DAILY_STREAK_PRIVATE: {
|
|
260
|
+
GET: `${exports.ROOT}/${CONTROLLERS.DAILY_STREAK_PRIVATE_CONTROLLER}/${CONTROLLERS.DAILY_STREAK_ROUTES.GET}`,
|
|
261
|
+
COLLECT: `${exports.ROOT}/${CONTROLLERS.DAILY_STREAK_PRIVATE_CONTROLLER}/${CONTROLLERS.DAILY_STREAK_ROUTES.COLLECT}`,
|
|
262
|
+
},
|
|
259
263
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectDailyRewardCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var CollectDailyRewardCommand;
|
|
7
|
+
(function (CollectDailyRewardCommand) {
|
|
8
|
+
CollectDailyRewardCommand.ResponseSchema = zod_1.z.object({
|
|
9
|
+
data: models_1.DailyStreakWithPromocodeSchema,
|
|
10
|
+
});
|
|
11
|
+
})(CollectDailyRewardCommand || (exports.CollectDailyRewardCommand = CollectDailyRewardCommand = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetDailyStreakCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var GetDailyStreakCommand;
|
|
7
|
+
(function (GetDailyStreakCommand) {
|
|
8
|
+
GetDailyStreakCommand.ResponseSchema = zod_1.z.object({
|
|
9
|
+
data: models_1.DailyStreakWithPromocodeSchema,
|
|
10
|
+
});
|
|
11
|
+
})(GetDailyStreakCommand || (exports.GetDailyStreakCommand = GetDailyStreakCommand = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./collect-daily-reward.command"), exports);
|
|
18
|
+
__exportStar(require("./get-daily-streak.command"), exports);
|
package/build/commands/index.js
CHANGED
|
@@ -8,12 +8,7 @@ var VideoCommand;
|
|
|
8
8
|
VideoCommand.RequestSchema = zod_1.z.object({
|
|
9
9
|
modelId: zod_1.z.string().uuid(),
|
|
10
10
|
prompt: zod_1.z.string(),
|
|
11
|
-
params:
|
|
12
|
-
imageUrls: zod_1.z.array(zod_1.z.string()).optional(),
|
|
13
|
-
duration: zod_1.z.number(),
|
|
14
|
-
aspectRatio: zod_1.z.string().optional(),
|
|
15
|
-
quality: zod_1.z.string().optional(),
|
|
16
|
-
}),
|
|
11
|
+
params: models_1.VideoGenerationRequestParamsSchema,
|
|
17
12
|
});
|
|
18
13
|
VideoCommand.ResponseSchema = zod_1.z.object({
|
|
19
14
|
data: models_1.ToolJobSchema,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DAILY_STREAK_STATUS = void 0;
|
|
4
|
+
var DAILY_STREAK_STATUS;
|
|
5
|
+
(function (DAILY_STREAK_STATUS) {
|
|
6
|
+
DAILY_STREAK_STATUS["COLLECTED"] = "COLLECTED";
|
|
7
|
+
DAILY_STREAK_STATUS["NOT_READY"] = "NOT_READY";
|
|
8
|
+
DAILY_STREAK_STATUS["READY"] = "READY";
|
|
9
|
+
})(DAILY_STREAK_STATUS || (exports.DAILY_STREAK_STATUS = DAILY_STREAK_STATUS = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DAY_IN_DAILY_STREAK_AWARD_TYPE = void 0;
|
|
4
|
+
var DAY_IN_DAILY_STREAK_AWARD_TYPE;
|
|
5
|
+
(function (DAY_IN_DAILY_STREAK_AWARD_TYPE) {
|
|
6
|
+
DAY_IN_DAILY_STREAK_AWARD_TYPE["COIN_TRANSACTION"] = "COIN_TRANSACTION";
|
|
7
|
+
DAY_IN_DAILY_STREAK_AWARD_TYPE["PROMOCODE"] = "PROMOCODE";
|
|
8
|
+
})(DAY_IN_DAILY_STREAK_AWARD_TYPE || (exports.DAY_IN_DAILY_STREAK_AWARD_TYPE = DAY_IN_DAILY_STREAK_AWARD_TYPE = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./daily-streak-status.enum"), exports);
|
|
18
|
+
__exportStar(require("./day-in-daily-streak-reward-type.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);
|
|
@@ -1662,4 +1662,39 @@ exports.ERRORS = {
|
|
|
1662
1662
|
message: 'Произошла ошибка при подсчёте количества сообщений для юзера',
|
|
1663
1663
|
httpCode: 500,
|
|
1664
1664
|
},
|
|
1665
|
+
DAILY_REWARD_COLLECT_ERROR: {
|
|
1666
|
+
code: 'A353',
|
|
1667
|
+
message: 'Ошибка при получении ежедневной награды',
|
|
1668
|
+
httpCode: 500,
|
|
1669
|
+
},
|
|
1670
|
+
DAILY_STREAK_CREATE_ERROR: {
|
|
1671
|
+
code: 'A354',
|
|
1672
|
+
message: 'Ошибка при создании ежедневного стрика',
|
|
1673
|
+
httpCode: 500,
|
|
1674
|
+
},
|
|
1675
|
+
DAILY_STREAK_FIND_ERROR: {
|
|
1676
|
+
code: 'A355',
|
|
1677
|
+
message: 'Ошибка при поиске ежедневного стрика',
|
|
1678
|
+
httpCode: 500,
|
|
1679
|
+
},
|
|
1680
|
+
DAILY_STREAK_PROMOCODE_ALREADY_EXISTS_ERROR: {
|
|
1681
|
+
code: 'A356',
|
|
1682
|
+
message: 'Промокод для ежедневного стрика уже существует',
|
|
1683
|
+
httpCode: 409,
|
|
1684
|
+
},
|
|
1685
|
+
DAILY_REWARD_NOT_READY_ERROR: {
|
|
1686
|
+
code: 'A357',
|
|
1687
|
+
message: 'Запрашиваемая награда ещё недоступна для получения',
|
|
1688
|
+
httpCode: 429,
|
|
1689
|
+
},
|
|
1690
|
+
DAILY_REWARD_ALREADY_COLLECTED_ERROR: {
|
|
1691
|
+
code: 'A358',
|
|
1692
|
+
message: 'Запрашиваемая награда уже получена',
|
|
1693
|
+
httpCode: 429,
|
|
1694
|
+
},
|
|
1695
|
+
DAILY_STREAK_UPDATE_ERROR: {
|
|
1696
|
+
code: 'A359',
|
|
1697
|
+
message: 'Ошибка при обновлении ежедневного стрика',
|
|
1698
|
+
httpCode: 500,
|
|
1699
|
+
},
|
|
1665
1700
|
};
|
package/build/constants/index.js
CHANGED
|
@@ -5,4 +5,5 @@ var PROMOCODE_PROMOTION;
|
|
|
5
5
|
(function (PROMOCODE_PROMOTION) {
|
|
6
6
|
PROMOCODE_PROMOTION["BONUS"] = "bonus";
|
|
7
7
|
PROMOCODE_PROMOTION["CHAT_UPSELL"] = "chat_upsell";
|
|
8
|
+
PROMOCODE_PROMOTION["DAILY_STREAK"] = "daily_streak";
|
|
8
9
|
})(PROMOCODE_PROMOTION || (exports.PROMOCODE_PROMOTION = PROMOCODE_PROMOTION = {}));
|
|
@@ -22,3 +22,4 @@ __exportStar(require("./veo-aspect-ratio.enum"), exports);
|
|
|
22
22
|
__exportStar(require("./veo-person-allow.enum"), exports);
|
|
23
23
|
__exportStar(require("./veo-job-params-type.enum"), exports);
|
|
24
24
|
__exportStar(require("./video-resolution.enum"), exports);
|
|
25
|
+
__exportStar(require("./video-pricing-rule-type.enum"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VIDEO_PRICING_RULE_TYPE = void 0;
|
|
4
|
+
var VIDEO_PRICING_RULE_TYPE;
|
|
5
|
+
(function (VIDEO_PRICING_RULE_TYPE) {
|
|
6
|
+
VIDEO_PRICING_RULE_TYPE["FLAT"] = "flat";
|
|
7
|
+
})(VIDEO_PRICING_RULE_TYPE || (exports.VIDEO_PRICING_RULE_TYPE = VIDEO_PRICING_RULE_TYPE = {}));
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
return
|
|
3
|
+
exports.calculateVideoGenerationPrice = calculateVideoGenerationPrice;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
function matchesCondition(condition, params) {
|
|
6
|
+
const keys = Object.keys(condition);
|
|
7
|
+
return keys.every((key) => {
|
|
8
|
+
const expected = condition[key];
|
|
9
|
+
if (expected === undefined || expected === null || expected === '') {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
const value = params[key];
|
|
13
|
+
if (value === undefined || value === null) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return value === expected;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function calculateVideoGenerationPrice({ pricePerSecond, params, rules, }) {
|
|
20
|
+
const base = pricePerSecond * params.duration;
|
|
21
|
+
const flatMarkup = rules.reduce((sum, r) => {
|
|
22
|
+
if (r.type !== constants_1.VIDEO_PRICING_RULE_TYPE.FLAT) {
|
|
23
|
+
return sum;
|
|
24
|
+
}
|
|
25
|
+
return matchesCondition(r.condition, params) ? sum + r.value : sum;
|
|
26
|
+
}, 0);
|
|
27
|
+
return Math.ceil(base + flatMarkup);
|
|
8
28
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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.DailyStreakWithPromocodeSchema = exports.DailyStreakSchema = exports.DayInDailyStreakSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const promocode_schema_1 = require("./promocode.schema");
|
|
10
|
+
exports.DayInDailyStreakSchema = zod_1.default.object({
|
|
11
|
+
dayNumber: zod_1.default.number().int().nonnegative(),
|
|
12
|
+
status: zod_1.default.nativeEnum(constants_1.DAILY_STREAK_STATUS),
|
|
13
|
+
award: zod_1.default.number().int().nonnegative().nullable(), // null on PROMOCODE days
|
|
14
|
+
isCurrentDay: zod_1.default.boolean(),
|
|
15
|
+
awardType: zod_1.default.nativeEnum(constants_1.DAY_IN_DAILY_STREAK_AWARD_TYPE),
|
|
16
|
+
});
|
|
17
|
+
exports.DailyStreakSchema = zod_1.default.object({
|
|
18
|
+
uuid: zod_1.default.string().uuid(),
|
|
19
|
+
userId: zod_1.default.string().uuid(),
|
|
20
|
+
promocodeId: zod_1.default.string().uuid().nullable(),
|
|
21
|
+
lastDailyCollectionAt: zod_1.default.date().nullable(),
|
|
22
|
+
currentDayStreak: zod_1.default.number().int().min(0),
|
|
23
|
+
createdAt: zod_1.default.date(),
|
|
24
|
+
updatedAt: zod_1.default.date(),
|
|
25
|
+
days: zod_1.default.array(exports.DayInDailyStreakSchema).default([]),
|
|
26
|
+
});
|
|
27
|
+
exports.DailyStreakWithPromocodeSchema = exports.DailyStreakSchema.extend({
|
|
28
|
+
promocode: promocode_schema_1.PromocodeSchema.nullable(),
|
|
29
|
+
}).omit({ promocodeId: true });
|
package/build/models/index.js
CHANGED
|
@@ -64,3 +64,4 @@ __exportStar(require("./prompt.schema"), exports);
|
|
|
64
64
|
__exportStar(require("./folder.schema"), exports);
|
|
65
65
|
__exportStar(require("./filters.schema"), exports);
|
|
66
66
|
__exportStar(require("./users-filter-notification.schema"), exports);
|
|
67
|
+
__exportStar(require("./daily-streak"), exports);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VideoModelSchema = exports.VideoModelParamsSchema = void 0;
|
|
3
|
+
exports.VideoModelSchema = exports.VideoModelPricingRulesSchema = exports.VideoModelPricingRuleConditionSchema = exports.VideoGenerationRequestParamsSchema = exports.VideoModelParamsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const icon_variants_schema_1 = require("../../icon-variants.schema");
|
|
6
6
|
const unlocked_by_subscription_schema_1 = require("../../unlocked-by-subscription.schema");
|
|
7
|
+
const constants_1 = require("../../../constants");
|
|
7
8
|
exports.VideoModelParamsSchema = zod_1.z.object({
|
|
8
9
|
imageAttachment: zod_1.z.object({
|
|
9
10
|
supported: zod_1.z.boolean(),
|
|
@@ -19,6 +20,20 @@ exports.VideoModelParamsSchema = zod_1.z.object({
|
|
|
19
20
|
.optional(),
|
|
20
21
|
quality: zod_1.z.string().optional(),
|
|
21
22
|
});
|
|
23
|
+
exports.VideoGenerationRequestParamsSchema = zod_1.z.object({
|
|
24
|
+
imageUrls: zod_1.z.string().array().optional(),
|
|
25
|
+
duration: zod_1.z.number(),
|
|
26
|
+
aspectRatio: zod_1.z.string().optional(),
|
|
27
|
+
quality: zod_1.z.string().optional(),
|
|
28
|
+
});
|
|
29
|
+
exports.VideoModelPricingRuleConditionSchema = zod_1.z.object({
|
|
30
|
+
aspectRatio: zod_1.z.string(),
|
|
31
|
+
});
|
|
32
|
+
exports.VideoModelPricingRulesSchema = zod_1.z.array(zod_1.z.object({
|
|
33
|
+
type: zod_1.z.nativeEnum(constants_1.VIDEO_PRICING_RULE_TYPE),
|
|
34
|
+
condition: exports.VideoModelPricingRuleConditionSchema,
|
|
35
|
+
value: zod_1.z.number(),
|
|
36
|
+
}));
|
|
22
37
|
exports.VideoModelSchema = zod_1.z.object({
|
|
23
38
|
uuid: zod_1.z.string(),
|
|
24
39
|
title: zod_1.z.string(),
|
|
@@ -29,6 +44,7 @@ exports.VideoModelSchema = zod_1.z.object({
|
|
|
29
44
|
maxInputLength: zod_1.z.number(),
|
|
30
45
|
maxNegativeInputLength: zod_1.z.number(),
|
|
31
46
|
params: exports.VideoModelParamsSchema,
|
|
47
|
+
pricingRules: exports.VideoModelPricingRulesSchema,
|
|
32
48
|
unlockedBy: unlocked_by_subscription_schema_1.UnlockedBySchema.nullable(),
|
|
33
49
|
canUse: zod_1.z.boolean(),
|
|
34
50
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DailyStreakWithPromocodeSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace CollectDailyRewardCommand {
|
|
5
|
+
export type Request = void;
|
|
6
|
+
|
|
7
|
+
export const ResponseSchema = z.object({
|
|
8
|
+
data: DailyStreakWithPromocodeSchema,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DailyStreakWithPromocodeSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace GetDailyStreakCommand {
|
|
5
|
+
export type Request = void;
|
|
6
|
+
|
|
7
|
+
export const ResponseSchema = z.object({
|
|
8
|
+
data: DailyStreakWithPromocodeSchema,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
12
|
+
}
|
package/commands/index.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolJobSchema } from '../../../models';
|
|
2
|
+
import { ToolJobSchema, VideoGenerationRequestParamsSchema } from '../../../models';
|
|
3
3
|
export namespace VideoCommand {
|
|
4
4
|
export const RequestSchema = z.object({
|
|
5
5
|
modelId: z.string().uuid(),
|
|
6
6
|
prompt: z.string(),
|
|
7
|
-
params:
|
|
8
|
-
imageUrls: z.array(z.string()).optional(),
|
|
9
|
-
duration: z.number(),
|
|
10
|
-
aspectRatio: z.string().optional(),
|
|
11
|
-
quality: z.string().optional(),
|
|
12
|
-
}),
|
|
7
|
+
params: VideoGenerationRequestParamsSchema,
|
|
13
8
|
});
|
|
14
9
|
|
|
15
10
|
export type Request = z.infer<typeof RequestSchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './enums';
|
|
@@ -1669,4 +1669,39 @@ export const ERRORS = {
|
|
|
1669
1669
|
message: 'Произошла ошибка при подсчёте количества сообщений для юзера',
|
|
1670
1670
|
httpCode: 500,
|
|
1671
1671
|
},
|
|
1672
|
+
DAILY_REWARD_COLLECT_ERROR: {
|
|
1673
|
+
code: 'A353',
|
|
1674
|
+
message: 'Ошибка при получении ежедневной награды',
|
|
1675
|
+
httpCode: 500,
|
|
1676
|
+
},
|
|
1677
|
+
DAILY_STREAK_CREATE_ERROR: {
|
|
1678
|
+
code: 'A354',
|
|
1679
|
+
message: 'Ошибка при создании ежедневного стрика',
|
|
1680
|
+
httpCode: 500,
|
|
1681
|
+
},
|
|
1682
|
+
DAILY_STREAK_FIND_ERROR: {
|
|
1683
|
+
code: 'A355',
|
|
1684
|
+
message: 'Ошибка при поиске ежедневного стрика',
|
|
1685
|
+
httpCode: 500,
|
|
1686
|
+
},
|
|
1687
|
+
DAILY_STREAK_PROMOCODE_ALREADY_EXISTS_ERROR: {
|
|
1688
|
+
code: 'A356',
|
|
1689
|
+
message: 'Промокод для ежедневного стрика уже существует',
|
|
1690
|
+
httpCode: 409,
|
|
1691
|
+
},
|
|
1692
|
+
DAILY_REWARD_NOT_READY_ERROR: {
|
|
1693
|
+
code: 'A357',
|
|
1694
|
+
message: 'Запрашиваемая награда ещё недоступна для получения',
|
|
1695
|
+
httpCode: 429,
|
|
1696
|
+
},
|
|
1697
|
+
DAILY_REWARD_ALREADY_COLLECTED_ERROR: {
|
|
1698
|
+
code: 'A358',
|
|
1699
|
+
message: 'Запрашиваемая награда уже получена',
|
|
1700
|
+
httpCode: 429,
|
|
1701
|
+
},
|
|
1702
|
+
DAILY_STREAK_UPDATE_ERROR: {
|
|
1703
|
+
code: 'A359',
|
|
1704
|
+
message: 'Ошибка при обновлении ежедневного стрика',
|
|
1705
|
+
httpCode: 500,
|
|
1706
|
+
},
|
|
1672
1707
|
};
|
package/constants/index.ts
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VIDEO_PRICING_RULE_TYPE } from '../../constants';
|
|
2
|
+
import {
|
|
3
|
+
VideoGenerationRequestParams,
|
|
4
|
+
VideoModelPricingRuleCondition,
|
|
5
|
+
VideoModelPricingRules,
|
|
6
|
+
} from '../../models';
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
function matchesCondition(
|
|
9
|
+
condition: VideoModelPricingRuleCondition,
|
|
10
|
+
params: VideoGenerationRequestParams,
|
|
11
|
+
): boolean {
|
|
12
|
+
const keys = Object.keys(condition) as (keyof VideoModelPricingRuleCondition)[];
|
|
13
|
+
|
|
14
|
+
return keys.every((key) => {
|
|
15
|
+
const expected = condition[key];
|
|
16
|
+
|
|
17
|
+
if (expected === undefined || expected === null || expected === '') {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const value = params[key];
|
|
22
|
+
if (value === undefined || value === null) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return value === expected;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function calculateVideoGenerationPrice({
|
|
31
|
+
pricePerSecond,
|
|
32
|
+
params,
|
|
33
|
+
rules,
|
|
34
|
+
}: {
|
|
35
|
+
pricePerSecond: number;
|
|
36
|
+
params: VideoGenerationRequestParams;
|
|
37
|
+
rules: VideoModelPricingRules;
|
|
38
|
+
}) {
|
|
39
|
+
const base = pricePerSecond * params.duration;
|
|
40
|
+
|
|
41
|
+
const flatMarkup = rules.reduce((sum, r) => {
|
|
42
|
+
if (r.type !== VIDEO_PRICING_RULE_TYPE.FLAT) {
|
|
43
|
+
return sum;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return matchesCondition(r.condition, params) ? sum + r.value : sum;
|
|
47
|
+
}, 0);
|
|
48
|
+
|
|
49
|
+
return Math.ceil(base + flatMarkup);
|
|
6
50
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { DAILY_STREAK_STATUS, DAY_IN_DAILY_STREAK_AWARD_TYPE } from '../constants';
|
|
3
|
+
import { PromocodeSchema } from './promocode.schema';
|
|
4
|
+
|
|
5
|
+
export const DayInDailyStreakSchema = z.object({
|
|
6
|
+
dayNumber: z.number().int().nonnegative(),
|
|
7
|
+
status: z.nativeEnum(DAILY_STREAK_STATUS),
|
|
8
|
+
award: z.number().int().nonnegative().nullable(), // null on PROMOCODE days
|
|
9
|
+
isCurrentDay: z.boolean(),
|
|
10
|
+
awardType: z.nativeEnum(DAY_IN_DAILY_STREAK_AWARD_TYPE),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const DailyStreakSchema = z.object({
|
|
14
|
+
uuid: z.string().uuid(),
|
|
15
|
+
userId: z.string().uuid(),
|
|
16
|
+
promocodeId: z.string().uuid().nullable(),
|
|
17
|
+
lastDailyCollectionAt: z.date().nullable(),
|
|
18
|
+
currentDayStreak: z.number().int().min(0),
|
|
19
|
+
createdAt: z.date(),
|
|
20
|
+
updatedAt: z.date(),
|
|
21
|
+
|
|
22
|
+
days: z.array(DayInDailyStreakSchema).default([]),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const DailyStreakWithPromocodeSchema = DailyStreakSchema.extend({
|
|
26
|
+
promocode: PromocodeSchema.nullable(),
|
|
27
|
+
}).omit({ promocodeId: true });
|
package/models/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { IconVariantsSchema } from '../../icon-variants.schema';
|
|
3
3
|
import { UnlockedBySchema } from '../../unlocked-by-subscription.schema';
|
|
4
|
+
import { VIDEO_PRICING_RULE_TYPE } from '../../../constants';
|
|
4
5
|
|
|
5
6
|
export const VideoModelParamsSchema = z.object({
|
|
6
7
|
imageAttachment: z.object({
|
|
@@ -18,6 +19,28 @@ export const VideoModelParamsSchema = z.object({
|
|
|
18
19
|
quality: z.string().optional(),
|
|
19
20
|
});
|
|
20
21
|
|
|
22
|
+
export const VideoGenerationRequestParamsSchema = z.object({
|
|
23
|
+
imageUrls: z.string().array().optional(),
|
|
24
|
+
duration: z.number(),
|
|
25
|
+
aspectRatio: z.string().optional(),
|
|
26
|
+
quality: z.string().optional(),
|
|
27
|
+
});
|
|
28
|
+
export type VideoGenerationRequestParams = z.infer<typeof VideoGenerationRequestParamsSchema>;
|
|
29
|
+
|
|
30
|
+
export const VideoModelPricingRuleConditionSchema = z.object({
|
|
31
|
+
aspectRatio: z.string(),
|
|
32
|
+
});
|
|
33
|
+
export type VideoModelPricingRuleCondition = z.infer<typeof VideoModelPricingRuleConditionSchema>;
|
|
34
|
+
|
|
35
|
+
export const VideoModelPricingRulesSchema = z.array(
|
|
36
|
+
z.object({
|
|
37
|
+
type: z.nativeEnum(VIDEO_PRICING_RULE_TYPE),
|
|
38
|
+
condition: VideoModelPricingRuleConditionSchema,
|
|
39
|
+
value: z.number(),
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
export type VideoModelPricingRules = z.infer<typeof VideoModelPricingRulesSchema>;
|
|
43
|
+
|
|
21
44
|
export const VideoModelSchema = z.object({
|
|
22
45
|
uuid: z.string(),
|
|
23
46
|
title: z.string(),
|
|
@@ -28,6 +51,7 @@ export const VideoModelSchema = z.object({
|
|
|
28
51
|
maxInputLength: z.number(),
|
|
29
52
|
maxNegativeInputLength: z.number(),
|
|
30
53
|
params: VideoModelParamsSchema,
|
|
54
|
+
pricingRules: VideoModelPricingRulesSchema,
|
|
31
55
|
unlockedBy: UnlockedBySchema.nullable(),
|
|
32
56
|
canUse: z.boolean(),
|
|
33
57
|
});
|