@purpleschool/gptbot 0.10.3 → 0.10.5

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.
Files changed (31) hide show
  1. package/build/commands/payment/get-payment-history.command.js +4 -0
  2. package/build/commands/team-account/create-team-account.command.js +1 -0
  3. package/build/commands/team-account/find-team-accounts-by-name.command.js +1 -1
  4. package/build/commands/team-account/get-my-team-account.command.js +1 -1
  5. package/build/commands/team-account/update-team-account.command.js +5 -1
  6. package/build/constants/subscription/index.js +1 -0
  7. package/build/constants/subscription/team-baseline-subscription.constant.js +4 -0
  8. package/build/constants/team-account/enums/index.js +1 -0
  9. package/build/constants/team-account/enums/team-subscription-feature-key.enum.js +10 -0
  10. package/build/models/index.js +1 -0
  11. package/build/models/subscription.schema.js +2 -0
  12. package/build/models/team-account/index.js +1 -0
  13. package/build/models/team-account/team-account-with-balance.schema.js +13 -0
  14. package/build/models/team-account/team-account.schema.js +26 -1
  15. package/build/models/team-subscription-feature.schema.js +13 -0
  16. package/commands/payment/get-payment-history.command.ts +7 -0
  17. package/commands/team-account/create-team-account.command.ts +1 -0
  18. package/commands/team-account/find-team-accounts-by-name.command.ts +2 -2
  19. package/commands/team-account/get-my-team-account.command.ts +2 -2
  20. package/commands/team-account/update-team-account.command.ts +5 -1
  21. package/constants/subscription/index.ts +1 -0
  22. package/constants/subscription/team-baseline-subscription.constant.ts +1 -0
  23. package/constants/team-account/enums/index.ts +1 -0
  24. package/constants/team-account/enums/team-subscription-feature-key.enum.ts +6 -0
  25. package/models/index.ts +1 -0
  26. package/models/subscription.schema.ts +2 -0
  27. package/models/team-account/index.ts +1 -0
  28. package/models/team-account/team-account-with-balance.schema.ts +11 -0
  29. package/models/team-account/team-account.schema.ts +26 -0
  30. package/models/team-subscription-feature.schema.ts +13 -0
  31. package/package.json +1 -1
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetPaymentHistoryCommand = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const payment_history_item_schema_1 = require("../../models/payment-history-item.schema");
6
+ const constants_1 = require("../../constants");
6
7
  var GetPaymentHistoryCommand;
7
8
  (function (GetPaymentHistoryCommand) {
9
+ GetPaymentHistoryCommand.RequestQuerySchema = zod_1.z.object({
10
+ billingScope: zod_1.z.nativeEnum(constants_1.BILLING_SCOPE).default(constants_1.BILLING_SCOPE.USER),
11
+ });
8
12
  GetPaymentHistoryCommand.ResponseSchema = zod_1.z.object({
9
13
  data: zod_1.z.array(payment_history_item_schema_1.PaymentHistoryItemSchema),
10
14
  });
@@ -9,6 +9,7 @@ var CreateTeamAccountCommand;
9
9
  name: zod_1.z.string().trim().min(1).max(255),
10
10
  email: zod_1.z.string().email().optional(),
11
11
  logoUUID: zod_1.z.string().uuid().optional(),
12
+ tin: zod_1.z.string().regex(/^\d{10}$|^\d{12}$/, 'ИНН должен быть длинной в 10 или 12 цифр').optional(),
12
13
  });
13
14
  CreateTeamAccountCommand.ResponseSchema = zod_1.z.object({
14
15
  data: models_1.TeamAccountSchema,
@@ -11,7 +11,7 @@ var FindTeamAccountsByNameCommand;
11
11
  offset: zod_1.z.coerce.number().int().min(0).default(0).optional(),
12
12
  });
13
13
  FindTeamAccountsByNameCommand.ResponseSchema = zod_1.z.object({
14
- data: zod_1.z.array(models_1.TeamAccountSchema),
14
+ data: zod_1.z.array(models_1.TeamAccountWithBalanceSchema),
15
15
  page: zod_1.z.number(),
16
16
  totalPages: zod_1.z.number(),
17
17
  });
@@ -6,6 +6,6 @@ const models_1 = require("../../models");
6
6
  var GetMyTeamAccountCommand;
7
7
  (function (GetMyTeamAccountCommand) {
8
8
  GetMyTeamAccountCommand.ResponseSchema = zod_1.z.object({
9
- data: models_1.TeamAccountSchema.nullable(),
9
+ data: models_1.TeamAccountCabinetSchema.nullable(),
10
10
  });
11
11
  })(GetMyTeamAccountCommand || (exports.GetMyTeamAccountCommand = GetMyTeamAccountCommand = {}));
@@ -10,8 +10,12 @@ var UpdateTeamAccountCommand;
10
10
  name: zod_1.z.string().trim().min(1).max(255).optional(),
11
11
  email: zod_1.z.string().email().optional(),
12
12
  logoUUID: zod_1.z.string().uuid().optional(),
13
+ tin: zod_1.z.string().regex(/^\d{10}$|^\d{12}$/, 'ИНН должен быть длинной в 10 или 12 цифр').optional(),
13
14
  })
14
- .refine((data) => data.name !== undefined || data.email !== undefined || data.logoUUID !== undefined, { message: 'At least one field must be provided' });
15
+ .refine((data) => data.name !== undefined ||
16
+ data.email !== undefined ||
17
+ data.logoUUID !== undefined ||
18
+ data.tin !== undefined, { message: 'At least one field must be provided' });
15
19
  UpdateTeamAccountCommand.ResponseSchema = zod_1.z.object({
16
20
  data: models_1.TeamAccountSchema,
17
21
  });
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./enums"), exports);
18
+ __exportStar(require("./team-baseline-subscription.constant"), exports);
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEAM_BASELINE_SUBSCRIPTION_ID = void 0;
4
+ exports.TEAM_BASELINE_SUBSCRIPTION_ID = '3b5f3d3e-2c60-4a76-a3d8-9c91f7f2c0b1';
@@ -18,3 +18,4 @@ __exportStar(require("./team-account-invite-status.enum"), exports);
18
18
  __exportStar(require("./team-account-member-role.enum"), exports);
19
19
  __exportStar(require("./team-account-member-status.enum"), exports);
20
20
  __exportStar(require("./team-account-operation-type.enum"), exports);
21
+ __exportStar(require("./team-subscription-feature-key.enum"), exports);
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEAM_SUBSCRIPTION_FEATURE_KEY = void 0;
4
+ var TEAM_SUBSCRIPTION_FEATURE_KEY;
5
+ (function (TEAM_SUBSCRIPTION_FEATURE_KEY) {
6
+ TEAM_SUBSCRIPTION_FEATURE_KEY["TOKENS"] = "tokens";
7
+ TEAM_SUBSCRIPTION_FEATURE_KEY["MAX_TEAM_MEMBERS"] = "max_team_members";
8
+ TEAM_SUBSCRIPTION_FEATURE_KEY["CARRYOVER_PERCENT"] = "carryover_percent";
9
+ TEAM_SUBSCRIPTION_FEATURE_KEY["ALL_MODELS_ACCESS"] = "all_models_access";
10
+ })(TEAM_SUBSCRIPTION_FEATURE_KEY || (exports.TEAM_SUBSCRIPTION_FEATURE_KEY = TEAM_SUBSCRIPTION_FEATURE_KEY = {}));
@@ -45,6 +45,7 @@ __exportStar(require("./question.schema"), exports);
45
45
  __exportStar(require("./referral-bonus.schema"), exports);
46
46
  __exportStar(require("./section.schema"), exports);
47
47
  __exportStar(require("./subscription-feature.schema"), exports);
48
+ __exportStar(require("./team-subscription-feature.schema"), exports);
48
49
  __exportStar(require("./subscription-upgrade-schema"), exports);
49
50
  __exportStar(require("./subscription.schema"), exports);
50
51
  __exportStar(require("./telegram-user-data.schema"), exports);
@@ -4,6 +4,7 @@ exports.SubscriptionWithFeaturesSchema = exports.SubscriptionWithSubTypesSchema
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../constants");
6
6
  const subscription_feature_schema_1 = require("./subscription-feature.schema");
7
+ const team_subscription_feature_schema_1 = require("./team-subscription-feature.schema");
7
8
  exports.SubscriptionSchema = zod_1.z.object({
8
9
  uuid: zod_1.z.string().uuid(),
9
10
  mainSubscriptionId: zod_1.z.nullable(zod_1.z.string().uuid()),
@@ -29,6 +30,7 @@ exports.SubscriptionSchema = zod_1.z.object({
29
30
  }),
30
31
  action: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_ACTION).optional().nullable(),
31
32
  features: zod_1.z.array(subscription_feature_schema_1.SubscriptionFeatureSchema),
33
+ teamFeatures: zod_1.z.array(team_subscription_feature_schema_1.TeamSubscriptionFeatureSchema).default([]),
32
34
  maxInputLength: zod_1.z.number(),
33
35
  maxInputTokens: zod_1.z.number(),
34
36
  carryoverPercent: zod_1.z.number(),
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./team-account.schema"), exports);
18
+ __exportStar(require("./team-account-with-balance.schema"), exports);
18
19
  __exportStar(require("./team-account-member.schema"), exports);
19
20
  __exportStar(require("./team-account-member-list-item.schema"), exports);
20
21
  __exportStar(require("./team-account-invite.schema"), exports);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TeamAccountWithBalanceSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const team_account_schema_1 = require("./team-account.schema");
6
+ exports.TeamAccountWithBalanceSchema = team_account_schema_1.TeamAccountSchema.extend({
7
+ balance: zod_1.z.object({
8
+ totalTokenBalance: zod_1.z.number(),
9
+ subscriptionBalance: zod_1.z.number(),
10
+ productBalance: zod_1.z.number(),
11
+ carriedOverBalance: zod_1.z.number(),
12
+ }),
13
+ });
@@ -1,14 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TeamAccountSchema = void 0;
3
+ exports.TeamAccountCabinetSchema = exports.TeamAccountSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const constants_1 = require("../../constants");
5
6
  exports.TeamAccountSchema = zod_1.z.object({
6
7
  uuid: zod_1.z.string().uuid(),
7
8
  ownerUserId: zod_1.z.string().uuid(),
8
9
  name: zod_1.z.string(),
9
10
  email: zod_1.z.string().email(),
10
11
  logoUrl: zod_1.z.string().nullable(),
12
+ tin: zod_1.z.string().nullable(),
11
13
  isActive: zod_1.z.boolean(),
12
14
  createdAt: zod_1.z.date(),
13
15
  updatedAt: zod_1.z.date(),
14
16
  });
17
+ exports.TeamAccountCabinetSchema = zod_1.z.object({
18
+ account: zod_1.z.object({
19
+ uuid: zod_1.z.string().uuid(),
20
+ name: zod_1.z.string(),
21
+ email: zod_1.z.string().email().optional(),
22
+ logoUrl: zod_1.z.string().nullable(),
23
+ }),
24
+ membership: zod_1.z.object({
25
+ role: zod_1.z.nativeEnum(constants_1.TEAM_ACCOUNT_MEMBER_ROLE),
26
+ }),
27
+ balance: zod_1.z.object({
28
+ remaining: zod_1.z.number().int(),
29
+ limit: zod_1.z.number().int().nullable(),
30
+ }),
31
+ subscription: zod_1.z.object({
32
+ planName: zod_1.z.string().nullable(),
33
+ activeUntil: zod_1.z.date().nullable(),
34
+ isActive: zod_1.z.boolean(),
35
+ }),
36
+ products: zod_1.z.array(zod_1.z.object({
37
+ planName: zod_1.z.string().nullable(),
38
+ })),
39
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TeamSubscriptionFeatureSchema = void 0;
4
+ const constants_1 = require("../constants");
5
+ const zod_1 = require("zod");
6
+ const icon_variants_schema_1 = require("./icon-variants.schema");
7
+ exports.TeamSubscriptionFeatureSchema = zod_1.z.object({
8
+ key: zod_1.z.nativeEnum(constants_1.TEAM_SUBSCRIPTION_FEATURE_KEY),
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()]),
11
+ icon: icon_variants_schema_1.IconVariantsSchema,
12
+ order: zod_1.z.number().int().nonnegative().default(0),
13
+ });
@@ -1,7 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  import { PaymentHistoryItemSchema } from '../../models/payment-history-item.schema';
3
+ import { BILLING_SCOPE } from '../../constants';
3
4
 
4
5
  export namespace GetPaymentHistoryCommand {
6
+ export const RequestQuerySchema = z.object({
7
+ billingScope: z.nativeEnum(BILLING_SCOPE).default(BILLING_SCOPE.USER),
8
+ });
9
+
10
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
11
+
5
12
  export const ResponseSchema = z.object({
6
13
  data: z.array(PaymentHistoryItemSchema),
7
14
  });
@@ -6,6 +6,7 @@ export namespace CreateTeamAccountCommand {
6
6
  name: z.string().trim().min(1).max(255),
7
7
  email: z.string().email().optional(),
8
8
  logoUUID: z.string().uuid().optional(),
9
+ tin: z.string().regex(/^\d{10}$|^\d{12}$/, 'ИНН должен быть длинной в 10 или 12 цифр').optional(),
9
10
  });
10
11
 
11
12
  export type Request = z.infer<typeof RequestSchema>;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { TeamAccountSchema } from '../../models';
2
+ import { TeamAccountWithBalanceSchema } from '../../models';
3
3
 
4
4
  export namespace FindTeamAccountsByNameCommand {
5
5
  export const RequestSchema = z.object({
@@ -11,7 +11,7 @@ export namespace FindTeamAccountsByNameCommand {
11
11
  export type Request = z.infer<typeof RequestSchema>;
12
12
 
13
13
  export const ResponseSchema = z.object({
14
- data: z.array(TeamAccountSchema),
14
+ data: z.array(TeamAccountWithBalanceSchema),
15
15
  page: z.number(),
16
16
  totalPages: z.number(),
17
17
  });
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { TeamAccountSchema } from '../../models';
2
+ import { TeamAccountCabinetSchema } from '../../models';
3
3
 
4
4
  export namespace GetMyTeamAccountCommand {
5
5
  export const ResponseSchema = z.object({
6
- data: TeamAccountSchema.nullable(),
6
+ data: TeamAccountCabinetSchema.nullable(),
7
7
  });
8
8
 
9
9
  export type Response = z.infer<typeof ResponseSchema>;
@@ -7,10 +7,14 @@ export namespace UpdateTeamAccountCommand {
7
7
  name: z.string().trim().min(1).max(255).optional(),
8
8
  email: z.string().email().optional(),
9
9
  logoUUID: z.string().uuid().optional(),
10
+ tin: z.string().regex(/^\d{10}$|^\d{12}$/, 'ИНН должен быть длинной в 10 или 12 цифр').optional(),
10
11
  })
11
12
  .refine(
12
13
  (data) =>
13
- data.name !== undefined || data.email !== undefined || data.logoUUID !== undefined,
14
+ data.name !== undefined ||
15
+ data.email !== undefined ||
16
+ data.logoUUID !== undefined ||
17
+ data.tin !== undefined,
14
18
  { message: 'At least one field must be provided' },
15
19
  );
16
20
 
@@ -1 +1,2 @@
1
1
  export * from './enums';
2
+ export * from './team-baseline-subscription.constant';
@@ -0,0 +1 @@
1
+ export const TEAM_BASELINE_SUBSCRIPTION_ID = '3b5f3d3e-2c60-4a76-a3d8-9c91f7f2c0b1';
@@ -2,3 +2,4 @@ export * from './team-account-invite-status.enum';
2
2
  export * from './team-account-member-role.enum';
3
3
  export * from './team-account-member-status.enum';
4
4
  export * from './team-account-operation-type.enum';
5
+ export * from './team-subscription-feature-key.enum';
@@ -0,0 +1,6 @@
1
+ export enum TEAM_SUBSCRIPTION_FEATURE_KEY {
2
+ TOKENS = 'tokens',
3
+ MAX_TEAM_MEMBERS = 'max_team_members',
4
+ CARRYOVER_PERCENT = 'carryover_percent',
5
+ ALL_MODELS_ACCESS = 'all_models_access',
6
+ }
package/models/index.ts CHANGED
@@ -29,6 +29,7 @@ export * from './question.schema';
29
29
  export * from './referral-bonus.schema';
30
30
  export * from './section.schema';
31
31
  export * from './subscription-feature.schema';
32
+ export * from './team-subscription-feature.schema';
32
33
  export * from './subscription-upgrade-schema';
33
34
  export * from './subscription.schema';
34
35
  export * from './telegram-user-data.schema';
@@ -6,6 +6,7 @@ import {
6
6
  SUBSCRIPTION_TYPE,
7
7
  } from '../constants';
8
8
  import { SubscriptionFeatureSchema } from './subscription-feature.schema';
9
+ import { TeamSubscriptionFeatureSchema } from './team-subscription-feature.schema';
9
10
 
10
11
  export const SubscriptionSchema = z.object({
11
12
  uuid: z.string().uuid(),
@@ -32,6 +33,7 @@ export const SubscriptionSchema = z.object({
32
33
  }),
33
34
  action: z.nativeEnum(SUBSCRIPTION_ACTION).optional().nullable(),
34
35
  features: z.array(SubscriptionFeatureSchema),
36
+ teamFeatures: z.array(TeamSubscriptionFeatureSchema).default([]),
35
37
  maxInputLength: z.number(),
36
38
  maxInputTokens: z.number(),
37
39
  carryoverPercent: z.number(),
@@ -1,4 +1,5 @@
1
1
  export * from './team-account.schema';
2
+ export * from './team-account-with-balance.schema';
2
3
  export * from './team-account-member.schema';
3
4
  export * from './team-account-member-list-item.schema';
4
5
  export * from './team-account-invite.schema';
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { TeamAccountSchema } from './team-account.schema';
3
+
4
+ export const TeamAccountWithBalanceSchema = TeamAccountSchema.extend({
5
+ balance: z.object({
6
+ totalTokenBalance: z.number(),
7
+ subscriptionBalance: z.number(),
8
+ productBalance: z.number(),
9
+ carriedOverBalance: z.number(),
10
+ }),
11
+ });
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { TEAM_ACCOUNT_MEMBER_ROLE } from '../../constants';
2
3
 
3
4
  export const TeamAccountSchema = z.object({
4
5
  uuid: z.string().uuid(),
@@ -6,7 +7,32 @@ export const TeamAccountSchema = z.object({
6
7
  name: z.string(),
7
8
  email: z.string().email(),
8
9
  logoUrl: z.string().nullable(),
10
+ tin: z.string().nullable(),
9
11
  isActive: z.boolean(),
10
12
  createdAt: z.date(),
11
13
  updatedAt: z.date(),
12
14
  });
15
+
16
+ export const TeamAccountCabinetSchema = z.object({
17
+ account: z.object({
18
+ uuid: z.string().uuid(),
19
+ name: z.string(),
20
+ email: z.string().email().optional(),
21
+ logoUrl: z.string().nullable(),
22
+ }),
23
+ membership: z.object({
24
+ role: z.nativeEnum(TEAM_ACCOUNT_MEMBER_ROLE),
25
+ }),
26
+ balance: z.object({
27
+ remaining: z.number().int(),
28
+ limit: z.number().int().nullable(),
29
+ }),
30
+ subscription: z.object({
31
+ planName: z.string().nullable(),
32
+ activeUntil: z.date().nullable(),
33
+ isActive: z.boolean(),
34
+ }),
35
+ products: z.array(z.object({
36
+ planName: z.string().nullable(),
37
+ })),
38
+ });
@@ -0,0 +1,13 @@
1
+ import { TEAM_SUBSCRIPTION_FEATURE_KEY } from '../constants';
2
+ import { z } from 'zod';
3
+ import { IconVariantsSchema } from './icon-variants.schema';
4
+
5
+ export const TeamSubscriptionFeatureSchema = z.object({
6
+ key: z.nativeEnum(TEAM_SUBSCRIPTION_FEATURE_KEY),
7
+ title: z.string().min(1),
8
+ value: z.union([z.boolean(), z.number(), z.string()]),
9
+ icon: IconVariantsSchema,
10
+ order: z.number().int().nonnegative().default(0),
11
+ });
12
+
13
+ export type TeamSubscriptionFeature = z.infer<typeof TeamSubscriptionFeatureSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",