@purpleschool/gptbot 0.5.54 → 0.5.55

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.
@@ -5,9 +5,13 @@ const models_1 = require("../../models");
5
5
  const zod_1 = require("zod");
6
6
  var RegisterUserCommand;
7
7
  (function (RegisterUserCommand) {
8
- RegisterUserCommand.RequestSchema = zod_1.z.intersection(models_1.UserSchema.pick({ email: true, password: true }), zod_1.z.object({
9
- partnerId: zod_1.z.string().uuid().optional(),
10
- }));
8
+ RegisterUserCommand.RequestSchema = models_1.UserSchema.pick({ email: true, password: true })
9
+ .extend({
10
+ partnerId: zod_1.z.string().optional(),
11
+ })
12
+ .extend({
13
+ utm: models_1.UtmSchema.optional(),
14
+ });
11
15
  RegisterUserCommand.ResponseSchema = zod_1.z.object({
12
16
  data: zod_1.z.object({
13
17
  accessToken: zod_1.z.string(),
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthWithTelegramWebAppCommand = void 0;
4
4
  const zod_1 = require("zod");
5
+ const models_1 = require("../../models");
5
6
  var AuthWithTelegramWebAppCommand;
6
7
  (function (AuthWithTelegramWebAppCommand) {
7
8
  AuthWithTelegramWebAppCommand.RequestBodySchema = zod_1.z.object({
8
9
  initData: zod_1.z.string(),
9
10
  platform: zod_1.z.string().nullable(),
10
11
  partnerId: zod_1.z.string().optional(),
12
+ utm: models_1.UtmSchema.optional(),
11
13
  });
12
14
  AuthWithTelegramWebAppCommand.ResponseSchema = zod_1.z.object({
13
15
  data: zod_1.z.object({
@@ -960,4 +960,9 @@ exports.ERRORS = {
960
960
  message: 'Произошла ошибка при проверке ограничений на длину запроса для чата',
961
961
  httpCode: 500,
962
962
  },
963
+ UTM_SAVE_ERROR: {
964
+ code: 'A218',
965
+ message: 'Произошла ошибка при сохранении UTM',
966
+ httpCode: 500,
967
+ },
963
968
  };
@@ -46,3 +46,4 @@ __exportStar(require("./user-task.schema"), exports);
46
46
  __exportStar(require("./user-to-product.schema"), exports);
47
47
  __exportStar(require("./user-to-subscription.schema"), exports);
48
48
  __exportStar(require("./user.schema"), exports);
49
+ __exportStar(require("./utm.schema"), exports);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UtmSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.UtmSchema = zod_1.z
6
+ .object({
7
+ utmSource: zod_1.z.string().optional().nullable(),
8
+ utmMedium: zod_1.z.string().optional().nullable(),
9
+ utmCampaign: zod_1.z.string().optional().nullable(),
10
+ utmContent: zod_1.z.string().optional().nullable(),
11
+ utmTerm: zod_1.z.string().optional().nullable(),
12
+ })
13
+ .refine((data) => Object.values(data).some((value) => value != null && value !== ''), {
14
+ message: 'At least one UTM parameter must be provided',
15
+ });
@@ -1,13 +1,14 @@
1
- import { UserSchema } from '../../models';
1
+ import { UserSchema, UtmSchema } from '../../models';
2
2
  import { z } from 'zod';
3
3
 
4
4
  export namespace RegisterUserCommand {
5
- export const RequestSchema = z.intersection(
6
- UserSchema.pick({ email: true, password: true }),
7
- z.object({
8
- partnerId: z.string().uuid().optional(),
9
- }),
10
- );
5
+ export const RequestSchema = UserSchema.pick({ email: true, password: true })
6
+ .extend({
7
+ partnerId: z.string().optional(),
8
+ })
9
+ .extend({
10
+ utm: UtmSchema.optional(),
11
+ });
11
12
 
12
13
  export type Request = z.infer<typeof RequestSchema>;
13
14
 
@@ -1,10 +1,12 @@
1
1
  import { z } from 'zod';
2
+ import { UtmSchema } from '../../models';
2
3
 
3
4
  export namespace AuthWithTelegramWebAppCommand {
4
5
  export const RequestBodySchema = z.object({
5
6
  initData: z.string(),
6
7
  platform: z.string().nullable(),
7
8
  partnerId: z.string().optional(),
9
+ utm: UtmSchema.optional(),
8
10
  });
9
11
 
10
12
  export type Request = z.infer<typeof RequestBodySchema>;
@@ -963,4 +963,9 @@ export const ERRORS = {
963
963
  message: 'Произошла ошибка при проверке ограничений на длину запроса для чата',
964
964
  httpCode: 500,
965
965
  },
966
+ UTM_SAVE_ERROR: {
967
+ code: 'A218',
968
+ message: 'Произошла ошибка при сохранении UTM',
969
+ httpCode: 500,
970
+ },
966
971
  };
package/models/index.ts CHANGED
@@ -30,3 +30,4 @@ export * from './user-task.schema';
30
30
  export * from './user-to-product.schema';
31
31
  export * from './user-to-subscription.schema';
32
32
  export * from './user.schema';
33
+ export * from './utm.schema';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+
3
+ export const UtmSchema = z
4
+ .object({
5
+ utmSource: z.string().optional().nullable(),
6
+ utmMedium: z.string().optional().nullable(),
7
+ utmCampaign: z.string().optional().nullable(),
8
+ utmContent: z.string().optional().nullable(),
9
+ utmTerm: z.string().optional().nullable(),
10
+ })
11
+ .refine((data) => Object.values(data).some((value) => value != null && value !== ''), {
12
+ message: 'At least one UTM parameter must be provided',
13
+ });
14
+
15
+ export type Utm = z.infer<typeof UtmSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.5.54",
3
+ "version": "0.5.55",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",