@purpleschool/gptbot 0.12.46 → 0.12.48
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/team-account.ts +1 -0
- package/api/routes.ts +1 -0
- package/build/api/controllers/http/team-account.js +1 -0
- package/build/api/routes.js +1 -0
- package/build/commands/subscription/get-available-upgrades.command.js +4 -0
- package/build/commands/subscription/upgrade-subscription.command.js +1 -0
- package/build/commands/team-account/create-manual-team-subscription-upgrade.command.js +17 -0
- package/build/commands/team-account/create-team-account-invoice-payment.command.js +6 -2
- package/build/commands/team-account/index.js +1 -0
- package/build/commands/team-to-subscription/add-team-to-subscription.command.js +1 -0
- package/build/commands/team-to-subscription/update-team-to-subscription.command.js +1 -0
- package/build/models/invoice-for-payment.schema.js +20 -7
- package/build/models/team-account/team-account-with-balance.schema.js +2 -1
- package/build/models/team-account/team-to-subscription.schema.js +1 -0
- package/build/models/team-subscription-feature.schema.js +2 -1
- package/commands/subscription/get-available-upgrades.command.ts +7 -0
- package/commands/subscription/upgrade-subscription.command.ts +2 -1
- package/commands/team-account/create-manual-team-subscription-upgrade.command.ts +19 -0
- package/commands/team-account/create-team-account-invoice-payment.command.ts +7 -3
- package/commands/team-account/index.ts +1 -0
- package/commands/team-to-subscription/add-team-to-subscription.command.ts +1 -0
- package/commands/team-to-subscription/update-team-to-subscription.command.ts +1 -0
- package/models/invoice-for-payment.schema.ts +20 -7
- package/models/team-account/team-account-with-balance.schema.ts +2 -1
- package/models/team-account/team-to-subscription.schema.ts +1 -0
- package/models/team-subscription-feature.schema.ts +2 -1
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ export const TEAM_ACCOUNT_ROUTES = {
|
|
|
20
20
|
GET_STATISTICS_OVERVIEW: 'statistics/overview',
|
|
21
21
|
GET_STATISTICS_BY_MONTH: 'statistics/by-month',
|
|
22
22
|
CREATE_MANUAL_SUBSCRIPTION: 'manual/subscription',
|
|
23
|
+
CREATE_MANUAL_SUBSCRIPTION_UPGRADE: 'manual/subscription/upgrade',
|
|
23
24
|
CREATE_MANUAL_PRODUCT: 'manual/product',
|
|
24
25
|
CREATE_INVOICE_PAYMENT: 'invoice-payment',
|
|
25
26
|
ADMIN_FIND_BY_NAME: 'admin/find',
|
package/api/routes.ts
CHANGED
|
@@ -211,6 +211,7 @@ export const REST_API = {
|
|
|
211
211
|
CANCEL_TRIAL_SUBSCRIPTION: `${ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CANCEL_TRIAL_SUBSCRIPTION}`,
|
|
212
212
|
GET_BALANCE: `${ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.GET_BALANCE}`,
|
|
213
213
|
CREATE_MANUAL_SUBSCRIPTION: `${ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_MANUAL_SUBSCRIPTION}`,
|
|
214
|
+
CREATE_MANUAL_SUBSCRIPTION_UPGRADE: `${ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_MANUAL_SUBSCRIPTION_UPGRADE}`,
|
|
214
215
|
CREATE_MANUAL_PRODUCT: `${ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_MANUAL_PRODUCT}`,
|
|
215
216
|
CREATE_INVOICE_PAYMENT: `${ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_INVOICE_PAYMENT}`,
|
|
216
217
|
ADMIN_FIND_BY_NAME: `${ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.ADMIN_FIND_BY_NAME}`,
|
|
@@ -22,6 +22,7 @@ exports.TEAM_ACCOUNT_ROUTES = {
|
|
|
22
22
|
GET_STATISTICS_OVERVIEW: 'statistics/overview',
|
|
23
23
|
GET_STATISTICS_BY_MONTH: 'statistics/by-month',
|
|
24
24
|
CREATE_MANUAL_SUBSCRIPTION: 'manual/subscription',
|
|
25
|
+
CREATE_MANUAL_SUBSCRIPTION_UPGRADE: 'manual/subscription/upgrade',
|
|
25
26
|
CREATE_MANUAL_PRODUCT: 'manual/product',
|
|
26
27
|
CREATE_INVOICE_PAYMENT: 'invoice-payment',
|
|
27
28
|
ADMIN_FIND_BY_NAME: 'admin/find',
|
package/build/api/routes.js
CHANGED
|
@@ -207,6 +207,7 @@ exports.REST_API = {
|
|
|
207
207
|
CANCEL_TRIAL_SUBSCRIPTION: `${exports.ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CANCEL_TRIAL_SUBSCRIPTION}`,
|
|
208
208
|
GET_BALANCE: `${exports.ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.GET_BALANCE}`,
|
|
209
209
|
CREATE_MANUAL_SUBSCRIPTION: `${exports.ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_MANUAL_SUBSCRIPTION}`,
|
|
210
|
+
CREATE_MANUAL_SUBSCRIPTION_UPGRADE: `${exports.ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_MANUAL_SUBSCRIPTION_UPGRADE}`,
|
|
210
211
|
CREATE_MANUAL_PRODUCT: `${exports.ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_MANUAL_PRODUCT}`,
|
|
211
212
|
CREATE_INVOICE_PAYMENT: `${exports.ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.CREATE_INVOICE_PAYMENT}`,
|
|
212
213
|
ADMIN_FIND_BY_NAME: `${exports.ROOT}/${CONTROLLERS.TEAM_ACCOUNT_CONTROLLER}/${CONTROLLERS.TEAM_ACCOUNT_ROUTES.ADMIN_FIND_BY_NAME}`,
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetAvailableUpgradesCommand = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
5
6
|
const models_1 = require("../../models");
|
|
6
7
|
const subscription_upgrade_schema_1 = require("../../models/subscription-upgrade-schema");
|
|
7
8
|
const subscription_feature_schema_1 = require("../../models/subscription-feature.schema");
|
|
8
9
|
var GetAvailableUpgradesCommand;
|
|
9
10
|
(function (GetAvailableUpgradesCommand) {
|
|
10
11
|
GetAvailableUpgradesCommand.RequestSchema = models_1.SubscriptionSchema.pick({});
|
|
12
|
+
GetAvailableUpgradesCommand.RequestQuerySchema = zod_1.z.object({
|
|
13
|
+
billingScope: zod_1.z.nativeEnum(constants_1.BILLING_SCOPE).default(constants_1.BILLING_SCOPE.USER),
|
|
14
|
+
});
|
|
11
15
|
GetAvailableUpgradesCommand.ResponseSchema = zod_1.z.object({
|
|
12
16
|
features: zod_1.z.record(zod_1.z.string().uuid(), zod_1.z.array(subscription_feature_schema_1.SubscriptionFeatureSchema)),
|
|
13
17
|
subscriptions: zod_1.z.array(subscription_upgrade_schema_1.SubscriptionUpgradeSchema),
|
|
@@ -10,6 +10,7 @@ var UpgradeSubscriptionCommand;
|
|
|
10
10
|
upgradeSubscriptionId: zod_1.z.string().uuid(),
|
|
11
11
|
promocode: zod_1.z.string().optional(),
|
|
12
12
|
provider: zod_1.z.nativeEnum(constants_1.PAYMENT_PROVIDER).optional().default(constants_1.PAYMENT_PROVIDER.CLOUDPAYMENTS),
|
|
13
|
+
billingScope: zod_1.z.nativeEnum(constants_1.BILLING_SCOPE).default(constants_1.BILLING_SCOPE.USER),
|
|
13
14
|
});
|
|
14
15
|
UpgradeSubscriptionCommand.RequestParamSchema = models_1.UserToSubscriptionSchema.pick({
|
|
15
16
|
uuid: true,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateManualTeamSubscriptionUpgradeCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
var CreateManualTeamSubscriptionUpgradeCommand;
|
|
7
|
+
(function (CreateManualTeamSubscriptionUpgradeCommand) {
|
|
8
|
+
CreateManualTeamSubscriptionUpgradeCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
teamAccountId: zod_1.z.string().uuid(),
|
|
10
|
+
subscriptionId: zod_1.z.string().uuid(),
|
|
11
|
+
durationMonths: zod_1.z.number().int().min(1).max(36).optional(),
|
|
12
|
+
upgradeFromSubscriptionId: zod_1.z.string().uuid(),
|
|
13
|
+
});
|
|
14
|
+
CreateManualTeamSubscriptionUpgradeCommand.ResponseSchema = zod_1.z.object({
|
|
15
|
+
data: models_1.TeamToSubscriptionSchema,
|
|
16
|
+
});
|
|
17
|
+
})(CreateManualTeamSubscriptionUpgradeCommand || (exports.CreateManualTeamSubscriptionUpgradeCommand = CreateManualTeamSubscriptionUpgradeCommand = {}));
|
|
@@ -12,9 +12,13 @@ var CreateTeamAccountInvoicePaymentCommand;
|
|
|
12
12
|
amount: zod_1.z.number().positive(),
|
|
13
13
|
subscriptionUuid: zod_1.z.string().uuid().optional(),
|
|
14
14
|
productUuid: zod_1.z.string().uuid().optional(),
|
|
15
|
+
upgradeSubscriptionUuid: zod_1.z.string().uuid().optional(),
|
|
15
16
|
})
|
|
16
|
-
.refine(({ subscriptionUuid, productUuid }) => Number(Boolean(subscriptionUuid)) +
|
|
17
|
-
|
|
17
|
+
.refine(({ subscriptionUuid, productUuid, upgradeSubscriptionUuid }) => Number(Boolean(subscriptionUuid)) +
|
|
18
|
+
Number(Boolean(productUuid)) +
|
|
19
|
+
Number(Boolean(upgradeSubscriptionUuid)) ===
|
|
20
|
+
1, {
|
|
21
|
+
message: 'Нужно передать ровно один идентификатор: subscriptionUuid, productUuid или upgradeSubscriptionUuid',
|
|
18
22
|
});
|
|
19
23
|
CreateTeamAccountInvoicePaymentCommand.ResponseSchema = zod_1.z.object({
|
|
20
24
|
data: zod_1.z.object({
|
|
@@ -36,6 +36,7 @@ __exportStar(require("./get-team-account-statistics-overview.command"), exports)
|
|
|
36
36
|
__exportStar(require("./get-team-account-statistics-by-month.command"), exports);
|
|
37
37
|
__exportStar(require("./get-team-account-balance.command"), exports);
|
|
38
38
|
__exportStar(require("./create-manual-team-subscription.command"), exports);
|
|
39
|
+
__exportStar(require("./create-manual-team-subscription-upgrade.command"), exports);
|
|
39
40
|
__exportStar(require("./create-manual-team-product.command"), exports);
|
|
40
41
|
__exportStar(require("./find-team-accounts-by-name.command"), exports);
|
|
41
42
|
__exportStar(require("./find-team-account-by-uuid.command"), exports);
|
|
@@ -11,6 +11,7 @@ var AddTeamToSubscriptionCommand;
|
|
|
11
11
|
cloudPaymentsSubscriptionId: zod_1.z.string().optional(),
|
|
12
12
|
zenpaymentsInvoiceNumber: zod_1.z.string().optional(),
|
|
13
13
|
startDate: zod_1.z.coerce.date().optional(),
|
|
14
|
+
upgradedFromSubscriptionId: zod_1.z.string().uuid().nullable().optional(),
|
|
14
15
|
downgradedFromTeamSubscriptionId: zod_1.z.string().uuid().nullable().optional(),
|
|
15
16
|
orderId: zod_1.z.string().uuid(),
|
|
16
17
|
});
|
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvoiceForPaymentSchema = exports.InvoiceForPaymentPayloadSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.InvoiceForPaymentPayloadSchema = zod_1.z.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
exports.InvoiceForPaymentPayloadSchema = zod_1.z.discriminatedUnion('invoiceType', [
|
|
6
|
+
zod_1.z.object({
|
|
7
|
+
invoiceType: zod_1.z.literal('purchase'),
|
|
8
|
+
email: zod_1.z.string().email(),
|
|
9
|
+
name: zod_1.z.string(),
|
|
10
|
+
inn: zod_1.z.string(),
|
|
11
|
+
amount: zod_1.z.number(),
|
|
12
|
+
itemName: zod_1.z.string(),
|
|
13
|
+
}),
|
|
14
|
+
zod_1.z.object({
|
|
15
|
+
invoiceType: zod_1.z.literal('subscription_upgrade'),
|
|
16
|
+
email: zod_1.z.string().email(),
|
|
17
|
+
name: zod_1.z.string(),
|
|
18
|
+
inn: zod_1.z.string(),
|
|
19
|
+
amount: zod_1.z.number(),
|
|
20
|
+
fromSubscriptionName: zod_1.z.string(),
|
|
21
|
+
toSubscriptionName: zod_1.z.string(),
|
|
22
|
+
durationMonths: zod_1.z.number(),
|
|
23
|
+
}),
|
|
24
|
+
]);
|
|
12
25
|
exports.InvoiceForPaymentSchema = zod_1.z.object({
|
|
13
26
|
uuid: zod_1.z.string().uuid(),
|
|
14
27
|
userId: zod_1.z.string().uuid(),
|
|
@@ -21,5 +21,6 @@ exports.TeamAccountWithBalanceSchema = team_account_schema_1.TeamAccountSchema.e
|
|
|
21
21
|
}),
|
|
22
22
|
invoicesCount: zod_1.z.number(),
|
|
23
23
|
membersCount: zod_1.z.number(),
|
|
24
|
-
maxSeats: zod_1.z.number(),
|
|
24
|
+
maxSeats: zod_1.z.number().nullable(),
|
|
25
|
+
isUnlimitedSeats: zod_1.z.boolean(),
|
|
25
26
|
});
|
|
@@ -21,6 +21,7 @@ exports.TeamToSubscriptionSchema = zod_1.z.object({
|
|
|
21
21
|
type: zod_1.z.nativeEnum(constants_1.USER_TO_SUBSCRIPTION_TYPE),
|
|
22
22
|
intervalEndDate: zod_1.z.date().nullable(),
|
|
23
23
|
marks: zod_1.z.array(zod_1.z.nativeEnum(constants_1.USER_TO_SUBSCRIPTION_MARKS)),
|
|
24
|
+
upgradedFromSubscriptionId: zod_1.z.string().uuid().nullable(),
|
|
24
25
|
downgradedFromTeamSubscriptionId: zod_1.z.string().uuid().nullable(),
|
|
25
26
|
orderId: zod_1.z.string().uuid().nullable(),
|
|
26
27
|
createdAt: zod_1.z.date(),
|
|
@@ -7,7 +7,8 @@ const icon_variants_schema_1 = require("./icon-variants.schema");
|
|
|
7
7
|
exports.TeamSubscriptionFeatureSchema = zod_1.z.object({
|
|
8
8
|
key: zod_1.z.nativeEnum(constants_1.TEAM_SUBSCRIPTION_FEATURE_KEY),
|
|
9
9
|
title: zod_1.z.string().min(1),
|
|
10
|
-
value: zod_1.z.union([zod_1.z.boolean(), zod_1.z.number(), zod_1.z.string()]),
|
|
10
|
+
value: zod_1.z.union([zod_1.z.boolean(), zod_1.z.number(), zod_1.z.string(), zod_1.z.null()]),
|
|
11
|
+
isUnlimited: zod_1.z.boolean().default(false),
|
|
11
12
|
icon: icon_variants_schema_1.IconVariantsSchema,
|
|
12
13
|
order: zod_1.z.number().int().nonnegative().default(0),
|
|
13
14
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { BILLING_SCOPE } from '../../constants';
|
|
2
3
|
import { SubscriptionSchema } from '../../models';
|
|
3
4
|
import { SubscriptionUpgradeSchema } from '../../models/subscription-upgrade-schema';
|
|
4
5
|
import { SubscriptionFeatureSchema } from '../../models/subscription-feature.schema';
|
|
@@ -8,6 +9,12 @@ export namespace GetAvailableUpgradesCommand {
|
|
|
8
9
|
|
|
9
10
|
export type Request = z.infer<typeof RequestSchema>;
|
|
10
11
|
|
|
12
|
+
export const RequestQuerySchema = z.object({
|
|
13
|
+
billingScope: z.nativeEnum(BILLING_SCOPE).default(BILLING_SCOPE.USER),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
17
|
+
|
|
11
18
|
export const ResponseSchema = z.object({
|
|
12
19
|
features: z.record(z.string().uuid(), z.array(SubscriptionFeatureSchema)),
|
|
13
20
|
subscriptions: z.array(SubscriptionUpgradeSchema),
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { UserToSubscriptionSchema } from '../../models';
|
|
3
|
-
import { PAYMENT_PROVIDER } from '../../constants';
|
|
3
|
+
import { BILLING_SCOPE, PAYMENT_PROVIDER } from '../../constants';
|
|
4
4
|
|
|
5
5
|
export namespace UpgradeSubscriptionCommand {
|
|
6
6
|
export const RequestSchema = z.object({
|
|
7
7
|
upgradeSubscriptionId: z.string().uuid(),
|
|
8
8
|
promocode: z.string().optional(),
|
|
9
9
|
provider: z.nativeEnum(PAYMENT_PROVIDER).optional().default(PAYMENT_PROVIDER.CLOUDPAYMENTS),
|
|
10
|
+
billingScope: z.nativeEnum(BILLING_SCOPE).default(BILLING_SCOPE.USER),
|
|
10
11
|
});
|
|
11
12
|
|
|
12
13
|
export const RequestParamSchema = UserToSubscriptionSchema.pick({
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TeamToSubscriptionSchema } from '../../models';
|
|
3
|
+
|
|
4
|
+
export namespace CreateManualTeamSubscriptionUpgradeCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
teamAccountId: z.string().uuid(),
|
|
7
|
+
subscriptionId: z.string().uuid(),
|
|
8
|
+
durationMonths: z.number().int().min(1).max(36).optional(),
|
|
9
|
+
upgradeFromSubscriptionId: z.string().uuid(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
13
|
+
|
|
14
|
+
export const ResponseSchema = z.object({
|
|
15
|
+
data: TeamToSubscriptionSchema,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -9,13 +9,17 @@ export namespace CreateTeamAccountInvoicePaymentCommand {
|
|
|
9
9
|
amount: z.number().positive(),
|
|
10
10
|
subscriptionUuid: z.string().uuid().optional(),
|
|
11
11
|
productUuid: z.string().uuid().optional(),
|
|
12
|
+
upgradeSubscriptionUuid: z.string().uuid().optional(),
|
|
12
13
|
})
|
|
13
14
|
.refine(
|
|
14
|
-
({ subscriptionUuid, productUuid }) =>
|
|
15
|
-
Number(Boolean(subscriptionUuid)) +
|
|
15
|
+
({ subscriptionUuid, productUuid, upgradeSubscriptionUuid }) =>
|
|
16
|
+
Number(Boolean(subscriptionUuid)) +
|
|
17
|
+
Number(Boolean(productUuid)) +
|
|
18
|
+
Number(Boolean(upgradeSubscriptionUuid)) ===
|
|
19
|
+
1,
|
|
16
20
|
{
|
|
17
21
|
message:
|
|
18
|
-
'Нужно передать ровно один идентификатор: subscriptionUuid или
|
|
22
|
+
'Нужно передать ровно один идентификатор: subscriptionUuid, productUuid или upgradeSubscriptionUuid',
|
|
19
23
|
},
|
|
20
24
|
);
|
|
21
25
|
|
|
@@ -20,6 +20,7 @@ export * from './get-team-account-statistics-overview.command';
|
|
|
20
20
|
export * from './get-team-account-statistics-by-month.command';
|
|
21
21
|
export * from './get-team-account-balance.command';
|
|
22
22
|
export * from './create-manual-team-subscription.command';
|
|
23
|
+
export * from './create-manual-team-subscription-upgrade.command';
|
|
23
24
|
export * from './create-manual-team-product.command';
|
|
24
25
|
export * from './find-team-accounts-by-name.command';
|
|
25
26
|
export * from './find-team-account-by-uuid.command';
|
|
@@ -8,6 +8,7 @@ export namespace AddTeamToSubscriptionCommand {
|
|
|
8
8
|
cloudPaymentsSubscriptionId: z.string().optional(),
|
|
9
9
|
zenpaymentsInvoiceNumber: z.string().optional(),
|
|
10
10
|
startDate: z.coerce.date().optional(),
|
|
11
|
+
upgradedFromSubscriptionId: z.string().uuid().nullable().optional(),
|
|
11
12
|
downgradedFromTeamSubscriptionId: z.string().uuid().nullable().optional(),
|
|
12
13
|
orderId: z.string().uuid(),
|
|
13
14
|
});
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
export const InvoiceForPaymentPayloadSchema = z.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export const InvoiceForPaymentPayloadSchema = z.discriminatedUnion('invoiceType', [
|
|
4
|
+
z.object({
|
|
5
|
+
invoiceType: z.literal('purchase'),
|
|
6
|
+
email: z.string().email(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
inn: z.string(),
|
|
9
|
+
amount: z.number(),
|
|
10
|
+
itemName: z.string(),
|
|
11
|
+
}),
|
|
12
|
+
z.object({
|
|
13
|
+
invoiceType: z.literal('subscription_upgrade'),
|
|
14
|
+
email: z.string().email(),
|
|
15
|
+
name: z.string(),
|
|
16
|
+
inn: z.string(),
|
|
17
|
+
amount: z.number(),
|
|
18
|
+
fromSubscriptionName: z.string(),
|
|
19
|
+
toSubscriptionName: z.string(),
|
|
20
|
+
durationMonths: z.number(),
|
|
21
|
+
}),
|
|
22
|
+
]);
|
|
10
23
|
|
|
11
24
|
export const InvoiceForPaymentSchema = z.object({
|
|
12
25
|
uuid: z.string().uuid(),
|
|
@@ -23,6 +23,7 @@ export const TeamToSubscriptionSchema = z.object({
|
|
|
23
23
|
type: z.nativeEnum(USER_TO_SUBSCRIPTION_TYPE),
|
|
24
24
|
intervalEndDate: z.date().nullable(),
|
|
25
25
|
marks: z.array(z.nativeEnum(USER_TO_SUBSCRIPTION_MARKS)),
|
|
26
|
+
upgradedFromSubscriptionId: z.string().uuid().nullable(),
|
|
26
27
|
downgradedFromTeamSubscriptionId: z.string().uuid().nullable(),
|
|
27
28
|
orderId: z.string().uuid().nullable(),
|
|
28
29
|
createdAt: z.date(),
|
|
@@ -5,7 +5,8 @@ import { IconVariantsSchema } from './icon-variants.schema';
|
|
|
5
5
|
export const TeamSubscriptionFeatureSchema = z.object({
|
|
6
6
|
key: z.nativeEnum(TEAM_SUBSCRIPTION_FEATURE_KEY),
|
|
7
7
|
title: z.string().min(1),
|
|
8
|
-
value: z.union([z.boolean(), z.number(), z.string()]),
|
|
8
|
+
value: z.union([z.boolean(), z.number(), z.string(), z.null()]),
|
|
9
|
+
isUnlimited: z.boolean().default(false),
|
|
9
10
|
icon: IconVariantsSchema,
|
|
10
11
|
order: z.number().int().nonnegative().default(0),
|
|
11
12
|
});
|