ovi-kit 1.12.4 → 1.13.0

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/dist/index.d.ts CHANGED
@@ -35,10 +35,12 @@ export { CustomDate } from './shared/decorators/custom-date';
35
35
  export { IsCardType } from './shared/decorators/luhn';
36
36
  export { RedisService } from './shared/modules/redis/redis.service';
37
37
  export { CustomHttpService } from './shared/modules/http/http.service';
38
+ export { ChottuLinkService } from './shared/modules/chottu-link/chottu-link.service';
38
39
  export { RedisModule } from './shared/modules/redis/redis.module';
39
40
  export { CustomHttpModule } from './shared/modules/http/http.module';
40
41
  export { SharedModule } from './shared.module';
41
42
  export { BullMqModule } from './shared/modules/bull-mq/bull-mq.module';
43
+ export { ChottuLinkModule } from './shared/modules/chottu-link/chottu-link.module';
42
44
  export type { MethodInfo } from './shared/types/method-info';
43
45
  export type { MetaData } from './shared/types/meta-data';
44
46
  export type { GeneralConfig } from './shared/types/config';
@@ -64,7 +66,10 @@ export type { TranslationType } from './shared/types/translation';
64
66
  export type { AiModelType } from './shared/types/ai-model.type';
65
67
  export type { UserMinimalData } from './shared/types/user-minimal-data';
66
68
  export type { ClinicRegionalType } from './shared/types/clinic-regional-type';
69
+ export type { ChottuLinkConfig, ChottuLinkPayload, ChottuLinkCreateResponse, } from './shared/modules/chottu-link/chottu-link.types';
70
+ export { CHOTTULINK_CONFIG } from './shared/modules/chottu-link/chottu-link.types';
67
71
  export { WEEKDAYS } from './shared/arrays/weekdays';
68
72
  export { CustomRpcException } from './shared/exceptions/custom-rpc.exception';
73
+ export { ChottuLinkUnavailableError } from './shared/modules/chottu-link/chottu-link.types';
69
74
  export { RpcErrorCode } from './shared/enums/exception-codes';
70
75
  export { INTERNAL_SERVER_ERROR } from './shared/constants/internal-error-message.const';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.INTERNAL_SERVER_ERROR = exports.RpcErrorCode = exports.CustomRpcException = exports.WEEKDAYS = exports.BullMqModule = exports.SharedModule = exports.CustomHttpModule = exports.RedisModule = exports.CustomHttpService = exports.RedisService = exports.IsCardType = exports.CustomDate = exports.API_META_KEY = exports.ApiMeta = exports.BaseEntity = exports.getWeekdayName = exports.getTitle = exports.createRandomPassword = exports.getFiveMinutesLater = exports.uuid = exports.PasswordVo = exports.OtpResponseDto = exports.ConfirmResponseDto = exports.SessionSecretResponseDto = exports.UserMinimalDataResponseDto = exports.GetByIdsDto = exports.CheckUserDto = exports.LoginDto = exports.BaseDto = exports.BaseResponseDto = exports.GetByIdDto = exports.GetByNameDto = exports.MetaDataDto = exports.PaginationResponseDto = exports.PaginationDto = exports.DeleteUserDto = exports.ForgotPasswordDto = exports.UserConfirmDto = exports.RevokeSessionDto = exports.ResetPasswordDto = exports.ResendOtpDto = exports.RecoveryPasswordDto = exports.LanguageDto = exports.MetaDto = void 0;
3
+ exports.INTERNAL_SERVER_ERROR = exports.RpcErrorCode = exports.ChottuLinkUnavailableError = exports.CustomRpcException = exports.WEEKDAYS = exports.CHOTTULINK_CONFIG = exports.ChottuLinkModule = exports.BullMqModule = exports.SharedModule = exports.CustomHttpModule = exports.RedisModule = exports.ChottuLinkService = exports.CustomHttpService = exports.RedisService = exports.IsCardType = exports.CustomDate = exports.API_META_KEY = exports.ApiMeta = exports.BaseEntity = exports.getWeekdayName = exports.getTitle = exports.createRandomPassword = exports.getFiveMinutesLater = exports.uuid = exports.PasswordVo = exports.OtpResponseDto = exports.ConfirmResponseDto = exports.SessionSecretResponseDto = exports.UserMinimalDataResponseDto = exports.GetByIdsDto = exports.CheckUserDto = exports.LoginDto = exports.BaseDto = exports.BaseResponseDto = exports.GetByIdDto = exports.GetByNameDto = exports.MetaDataDto = exports.PaginationResponseDto = exports.PaginationDto = exports.DeleteUserDto = exports.ForgotPasswordDto = exports.UserConfirmDto = exports.RevokeSessionDto = exports.ResetPasswordDto = exports.ResendOtpDto = exports.RecoveryPasswordDto = exports.LanguageDto = exports.MetaDto = void 0;
4
4
  var meta_data_dto_1 = require("./shared/dto/meta-data.dto");
5
5
  Object.defineProperty(exports, "MetaDto", { enumerable: true, get: function () { return meta_data_dto_1.MetaDto; } });
6
6
  var language_dto_1 = require("./shared/dto/language.dto");
@@ -73,6 +73,8 @@ var redis_service_1 = require("./shared/modules/redis/redis.service");
73
73
  Object.defineProperty(exports, "RedisService", { enumerable: true, get: function () { return redis_service_1.RedisService; } });
74
74
  var http_service_1 = require("./shared/modules/http/http.service");
75
75
  Object.defineProperty(exports, "CustomHttpService", { enumerable: true, get: function () { return http_service_1.CustomHttpService; } });
76
+ var chottu_link_service_1 = require("./shared/modules/chottu-link/chottu-link.service");
77
+ Object.defineProperty(exports, "ChottuLinkService", { enumerable: true, get: function () { return chottu_link_service_1.ChottuLinkService; } });
76
78
  var redis_module_1 = require("./shared/modules/redis/redis.module");
77
79
  Object.defineProperty(exports, "RedisModule", { enumerable: true, get: function () { return redis_module_1.RedisModule; } });
78
80
  var http_module_1 = require("./shared/modules/http/http.module");
@@ -81,10 +83,16 @@ var shared_module_1 = require("./shared.module");
81
83
  Object.defineProperty(exports, "SharedModule", { enumerable: true, get: function () { return shared_module_1.SharedModule; } });
82
84
  var bull_mq_module_1 = require("./shared/modules/bull-mq/bull-mq.module");
83
85
  Object.defineProperty(exports, "BullMqModule", { enumerable: true, get: function () { return bull_mq_module_1.BullMqModule; } });
86
+ var chottu_link_module_1 = require("./shared/modules/chottu-link/chottu-link.module");
87
+ Object.defineProperty(exports, "ChottuLinkModule", { enumerable: true, get: function () { return chottu_link_module_1.ChottuLinkModule; } });
88
+ var chottu_link_types_1 = require("./shared/modules/chottu-link/chottu-link.types");
89
+ Object.defineProperty(exports, "CHOTTULINK_CONFIG", { enumerable: true, get: function () { return chottu_link_types_1.CHOTTULINK_CONFIG; } });
84
90
  var weekdays_1 = require("./shared/arrays/weekdays");
85
91
  Object.defineProperty(exports, "WEEKDAYS", { enumerable: true, get: function () { return weekdays_1.WEEKDAYS; } });
86
92
  var custom_rpc_exception_1 = require("./shared/exceptions/custom-rpc.exception");
87
93
  Object.defineProperty(exports, "CustomRpcException", { enumerable: true, get: function () { return custom_rpc_exception_1.CustomRpcException; } });
94
+ var chottu_link_types_2 = require("./shared/modules/chottu-link/chottu-link.types");
95
+ Object.defineProperty(exports, "ChottuLinkUnavailableError", { enumerable: true, get: function () { return chottu_link_types_2.ChottuLinkUnavailableError; } });
88
96
  var exception_codes_1 = require("./shared/enums/exception-codes");
89
97
  Object.defineProperty(exports, "RpcErrorCode", { enumerable: true, get: function () { return exception_codes_1.RpcErrorCode; } });
90
98
  var internal_error_message_const_1 = require("./shared/constants/internal-error-message.const");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,4DAAqD;AAA5C,wGAAA,OAAO,OAAA;AAChB,0DAAwD;AAA/C,2GAAA,WAAW,OAAA;AACpB,4EAAyE;AAAhE,4HAAA,mBAAmB,OAAA;AAC5B,8DAA2D;AAAlD,8GAAA,YAAY,OAAA;AACrB,sEAAmE;AAA1D,sHAAA,gBAAgB,OAAA;AACzB,sEAAmE;AAA1D,sHAAA,gBAAgB,OAAA;AACzB,kEAA+D;AAAtD,kHAAA,cAAc,OAAA;AACvB,wEAAqE;AAA5D,wHAAA,iBAAiB,OAAA;AAC1B,gEAA6D;AAApD,gHAAA,aAAa,OAAA;AACtB,8DAA4D;AAAnD,+GAAA,aAAa,OAAA;AACtB,8DAAoE;AAA3D,uHAAA,qBAAqB,OAAA;AAC9B,4DAAyD;AAAhD,4GAAA,WAAW,OAAA;AACpB,gEAA4D;AAAnD,+GAAA,YAAY,OAAA;AACrB,4DAAwD;AAA/C,2GAAA,UAAU,OAAA;AACnB,oEAAiE;AAAxD,oHAAA,eAAe,OAAA;AACxB,kDAAgD;AAAvC,mGAAA,OAAO,OAAA;AAChB,oDAAkD;AAAzC,q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AA,UAAU,OAAA;AAGnB,6EAAiE;AAAxD,6GAAA,OAAO,OAAA;AAChB,6EAAsE;AAA7D,kHAAA,YAAY,OAAA;AAErB,+DAA6D;AAApD,yGAAA,UAAU,OAAA;AACnB,iDAAsD;AAA7C,kGAAA,UAAU,OAAA;AAGnB,sEAAoE;AAA3D,6GAAA,YAAY,OAAA;AACrB,mEAAuE;AAA9D,iHAAA,iBAAiB,OAAA;AAC1B,wFAAqF;AAA5E,wHAAA,iBAAiB,OAAA;AAG1B,oEAAkE;AAAzD,2GAAA,WAAW,OAAA;AACpB,iEAAqE;AAA5D,+GAAA,gBAAgB,OAAA;AACzB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,0EAAuE;AAA9D,8GAAA,YAAY,OAAA;AACrB,sFAAmF;AAA1E,sHAAA,gBAAgB,OAAA;AAiCzB,oFAAmF;AAA1E,sHAAA,iBAAiB,OAAA;AAG1B,qDAAoD;AAA3C,oGAAA,QAAQ,OAAA;AAGjB,iFAA8E;AAArE,0HAAA,kBAAkB,OAAA;AAC3B,oFAA4F;AAAnF,+HAAA,0BAA0B,OAAA;AAGnC,kEAA8D;AAArD,+GAAA,YAAY,OAAA;AAGrB,gGAAwF;AAA/E,qIAAA,qBAAqB,OAAA"}
@@ -0,0 +1,5 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { ChottuLinkConfig } from './chottu-link.types';
3
+ export declare class ChottuLinkModule {
4
+ static forRoot(config: ChottuLinkConfig): DynamicModule;
5
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var ChottuLinkModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ChottuLinkModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const chottu_link_service_1 = require("./chottu-link.service");
13
+ const chottu_link_types_1 = require("./chottu-link.types");
14
+ let ChottuLinkModule = ChottuLinkModule_1 = class ChottuLinkModule {
15
+ static forRoot(config) {
16
+ return {
17
+ module: ChottuLinkModule_1,
18
+ global: true,
19
+ providers: [
20
+ { provide: chottu_link_types_1.CHOTTULINK_CONFIG, useValue: config },
21
+ chottu_link_service_1.ChottuLinkService,
22
+ ],
23
+ exports: [chottu_link_service_1.ChottuLinkService],
24
+ };
25
+ }
26
+ };
27
+ exports.ChottuLinkModule = ChottuLinkModule;
28
+ exports.ChottuLinkModule = ChottuLinkModule = ChottuLinkModule_1 = __decorate([
29
+ (0, common_1.Module)({})
30
+ ], ChottuLinkModule);
31
+ //# sourceMappingURL=chottu-link.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chottu-link.module.js","sourceRoot":"","sources":["../../../../src/shared/modules/chottu-link/chottu-link.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,+DAA0D;AAC1D,2DAA0E;AAGnE,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,MAAwB;QACrC,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,qCAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE;gBAChD,uCAAiB;aAClB;YACD,OAAO,EAAE,CAAC,uCAAiB,CAAC;SAC7B,CAAC;IACJ,CAAC;CACF,CAAA;AAZY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAY5B"}
@@ -0,0 +1,11 @@
1
+ import type { ChottuLinkConfig, ChottuLinkCreateResponse, ChottuLinkPayload } from './chottu-link.types';
2
+ export declare class ChottuLinkService {
3
+ private readonly config;
4
+ private readonly logger;
5
+ private readonly http;
6
+ private readonly maxRetries;
7
+ constructor(config: ChottuLinkConfig);
8
+ create(payload: ChottuLinkPayload): Promise<ChottuLinkCreateResponse>;
9
+ private parse;
10
+ private sleep;
11
+ }
@@ -0,0 +1,122 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ var ChottuLinkService_1;
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.ChottuLinkService = void 0;
50
+ const common_1 = require("@nestjs/common");
51
+ const axios_1 = __importStar(require("axios"));
52
+ const chottu_link_types_1 = require("./chottu-link.types");
53
+ const DEFAULT_TIMEOUT_MS = 5_000;
54
+ const DEFAULT_MAX_RETRIES = 2;
55
+ const TOTAL_BUDGET_MS = 10_000;
56
+ const BACKOFF_MS = [300, 900];
57
+ let ChottuLinkService = ChottuLinkService_1 = class ChottuLinkService {
58
+ config;
59
+ logger = new common_1.Logger(ChottuLinkService_1.name);
60
+ http;
61
+ maxRetries;
62
+ constructor(config) {
63
+ this.config = config;
64
+ this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
65
+ this.http = axios_1.default.create({
66
+ baseURL: config.baseUrl,
67
+ timeout: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,
68
+ headers: {
69
+ 'API-KEY': config.apiKey,
70
+ 'Content-Type': 'application/json',
71
+ },
72
+ });
73
+ }
74
+ async create(payload) {
75
+ const startedAt = Date.now();
76
+ let lastError;
77
+ const body = { ...payload, domain: this.config.domain };
78
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
79
+ if (Date.now() - startedAt > TOTAL_BUDGET_MS) {
80
+ throw new chottu_link_types_1.ChottuLinkUnavailableError(lastError);
81
+ }
82
+ try {
83
+ const response = await this.http.post('/chotuCore/pa/v1/create-link', body);
84
+ return this.parse(response.data);
85
+ }
86
+ catch (err) {
87
+ lastError = err;
88
+ if (err instanceof axios_1.AxiosError && err.response) {
89
+ const status = err.response.status;
90
+ if (status >= 400 && status < 500) {
91
+ this.logger.error(`ChottuLink 4xx: ${status} for link_name=${payload.link_name}`);
92
+ throw err;
93
+ }
94
+ }
95
+ if (attempt < this.maxRetries) {
96
+ await this.sleep(BACKOFF_MS[attempt] ?? BACKOFF_MS[BACKOFF_MS.length - 1]);
97
+ continue;
98
+ }
99
+ }
100
+ }
101
+ throw new chottu_link_types_1.ChottuLinkUnavailableError(lastError);
102
+ }
103
+ parse(data) {
104
+ if (typeof data === 'object' &&
105
+ data !== null &&
106
+ 'short_url' in data &&
107
+ typeof data.short_url === 'string') {
108
+ return { short_url: data.short_url };
109
+ }
110
+ throw new chottu_link_types_1.ChottuLinkUnavailableError(new Error('Unparseable response'));
111
+ }
112
+ sleep(ms) {
113
+ return new Promise((resolve) => setTimeout(resolve, ms));
114
+ }
115
+ };
116
+ exports.ChottuLinkService = ChottuLinkService;
117
+ exports.ChottuLinkService = ChottuLinkService = ChottuLinkService_1 = __decorate([
118
+ (0, common_1.Injectable)(),
119
+ __param(0, (0, common_1.Inject)(chottu_link_types_1.CHOTTULINK_CONFIG)),
120
+ __metadata("design:paramtypes", [Object])
121
+ ], ChottuLinkService);
122
+ //# sourceMappingURL=chottu-link.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chottu-link.service.js","sourceRoot":"","sources":["../../../../src/shared/modules/chottu-link/chottu-link.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,+CAAyD;AACzD,2DAG6B;AAO7B,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAM9B,MAAM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;CACF,CAAA;AAhFY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,qCAAiB,CAAC,CAAA;;GANjB,iBAAiB,CAgF7B"}
@@ -0,0 +1,22 @@
1
+ export declare const CHOTTULINK_CONFIG: unique symbol;
2
+ export interface ChottuLinkConfig {
3
+ apiKey: string;
4
+ baseUrl: string;
5
+ domain: string;
6
+ timeoutMs?: number;
7
+ maxRetries?: number;
8
+ }
9
+ export interface ChottuLinkPayload {
10
+ destination_url: string;
11
+ ios_behavior: 1 | 2;
12
+ android_behavior: 1 | 2;
13
+ link_name: string;
14
+ social_title: string;
15
+ social_image_url?: string;
16
+ }
17
+ export interface ChottuLinkCreateResponse {
18
+ short_url: string;
19
+ }
20
+ export declare class ChottuLinkUnavailableError extends Error {
21
+ constructor(cause: unknown);
22
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChottuLinkUnavailableError = exports.CHOTTULINK_CONFIG = void 0;
4
+ exports.CHOTTULINK_CONFIG = Symbol('CHOTTULINK_CONFIG');
5
+ class ChottuLinkUnavailableError extends Error {
6
+ constructor(cause) {
7
+ super('ChottuLink unavailable after retries', { cause });
8
+ this.name = 'ChottuLinkUnavailableError';
9
+ }
10
+ }
11
+ exports.ChottuLinkUnavailableError = ChottuLinkUnavailableError;
12
+ //# sourceMappingURL=chottu-link.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chottu-link.types.js","sourceRoot":"","sources":["../../../../src/shared/modules/chottu-link/chottu-link.types.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AA0B7D,MAAa,0BAA2B,SAAQ,KAAK;IACnD,YAAY,KAAc;QACxB,KAAK,CAAC,sCAAsC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AALD,gEAKC"}
@@ -1 +1 @@
1
- export type DoctorState = 'confirmed' | 'confirmed_for_competition' | 'is_not_doctor' | 'not_confirmed' | 'blocked';
1
+ export type DoctorState = 'confirmed' | 'pending' | 'is_not_doctor' | 'not_confirmed' | 'blocked';