docta-package 1.2.131 → 1.2.134

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.
@@ -8,7 +8,7 @@ import { LanguageOutputDto } from "./language";
8
8
  import { FaqOutputDto } from "./faq";
9
9
  import { LocationOutputDto } from "./location";
10
10
  export declare class DoctorPublicOutputDto {
11
- id: string;
11
+ id: string | null;
12
12
  specialty: SpecialtyOutputDto;
13
13
  title: string;
14
14
  professionalEmail: string;
@@ -9,10 +9,11 @@ const position_1 = require("./position");
9
9
  const language_1 = require("./language");
10
10
  const faq_1 = require("./faq");
11
11
  const location_1 = require("./location");
12
+ const normalize_id_1 = require("../../utils/normalize.id");
12
13
  class DoctorPublicOutputDto {
13
14
  constructor(doctor) {
14
- var _a, _b, _c;
15
- this.id = (_b = ((_a = doctor.id) !== null && _a !== void 0 ? _a : doctor._id)) === null || _b === void 0 ? void 0 : _b.toString();
15
+ var _a;
16
+ this.id = (0, normalize_id_1.normalizeId)(doctor);
16
17
  this.title = doctor.title;
17
18
  this.professionalEmail = doctor.professionalEmail;
18
19
  this.dontBookMeBeforeInMins = doctor.dontBookMeBeforeInMins;
@@ -20,7 +21,7 @@ class DoctorPublicOutputDto {
20
21
  this.slug = doctor.slug;
21
22
  this.biography = doctor.biography || null;
22
23
  this.isActive = doctor.isActive;
23
- this.consultationFeePerHour = (_c = doctor.consultationFeePerHour) !== null && _c !== void 0 ? _c : null;
24
+ this.consultationFeePerHour = (_a = doctor.consultationFeePerHour) !== null && _a !== void 0 ? _a : null;
24
25
  this.isVerified = doctor.isVerified;
25
26
  this.isVisible = doctor.isVisible;
26
27
  this.photo = doctor.photo || null;
@@ -1,7 +1,7 @@
1
1
  import { IExpertiseDocument } from "../../models";
2
2
  import { UserOutputDto } from "./user";
3
3
  export declare class ExpertiseOutputDto {
4
- id: string;
4
+ id: string | null;
5
5
  en: {
6
6
  name: string;
7
7
  description: string | null;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExpertiseAdminOutputDto = exports.ExpertiseOutputDto = void 0;
4
4
  const user_1 = require("./user");
5
+ const normalize_id_1 = require("../../utils/normalize.id");
5
6
  // Base DTO for everyone
6
7
  class ExpertiseOutputDto {
7
8
  constructor(expertise) {
8
- var _a, _b;
9
- this.id = (_b = ((_a = expertise.id) !== null && _a !== void 0 ? _a : expertise._id)) === null || _b === void 0 ? void 0 : _b.toString();
9
+ this.id = (0, normalize_id_1.normalizeId)(expertise);
10
10
  this.en = {
11
11
  name: expertise.en.name,
12
12
  description: expertise.en.description || null,
@@ -2,7 +2,7 @@ import { Gender } from "../../enums";
2
2
  import { IPatientDocument } from "../../models";
3
3
  import { UserOutputDto, UserPublicOutputDto } from "./user";
4
4
  declare class OutputDto {
5
- id: string;
5
+ id: string | null;
6
6
  dob: number | null;
7
7
  phoneNumber: string | null;
8
8
  gender: Gender | null;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PatientAdminOutputDto = exports.PatientOutputDto = exports.PatientPublicOutputDto = void 0;
4
4
  const user_1 = require("./user");
5
+ const normalize_id_1 = require("../../utils/normalize.id");
5
6
  class OutputDto {
6
7
  constructor(patient) {
7
- var _a, _b;
8
- this.id = (_b = ((_a = patient.id) !== null && _a !== void 0 ? _a : patient._id)) === null || _b === void 0 ? void 0 : _b.toString();
8
+ this.id = (0, normalize_id_1.normalizeId)(patient);
9
9
  this.dob = patient.dob || null;
10
10
  this.phoneNumber = patient.phoneNumber || null;
11
11
  this.gender = patient.gender || null;
@@ -2,7 +2,7 @@ import { IPeriodDocument } from "../../models";
2
2
  import { UserOutputDto } from "./user";
3
3
  import { PeriodStatus } from "../../enums/period.status";
4
4
  export declare class PeriodOutputDto {
5
- id: string;
5
+ id: string | null;
6
6
  doctorId: string;
7
7
  startTime: number;
8
8
  endTime: number;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PeriodAdminOutputDto = exports.PeriodDoctorOutputDto = exports.PeriodOutputDto = void 0;
4
4
  const user_1 = require("./user");
5
+ const normalize_id_1 = require("../../utils/normalize.id");
5
6
  // Base DTO for everyone
6
7
  class PeriodOutputDto {
7
8
  constructor(period) {
8
- var _a, _b;
9
- this.id = (_b = ((_a = period.id) !== null && _a !== void 0 ? _a : period._id)) === null || _b === void 0 ? void 0 : _b.toString();
9
+ this.id = (0, normalize_id_1.normalizeId)(period);
10
10
  this.doctorId = String(period.doctor._id);
11
11
  this.startTime = period.startTime;
12
12
  this.endTime = period.endTime;
@@ -8,7 +8,7 @@ interface ISessionConfigOutput {
8
8
  disbursementPercentage: number;
9
9
  }
10
10
  export declare class SessionOutputDto {
11
- id: string;
11
+ id: string | null;
12
12
  period: PeriodOutputDto;
13
13
  status: string;
14
14
  doctorId: string | null;
@@ -7,8 +7,8 @@ const user_1 = require("./user");
7
7
  // Base DTO for everyone
8
8
  class SessionOutputDto {
9
9
  constructor(session) {
10
- var _a, _b;
11
- this.id = (_b = ((_a = session.id) !== null && _a !== void 0 ? _a : session._id)) === null || _b === void 0 ? void 0 : _b.toString();
10
+ this.id = (0, normalize_id_1.normalizeId)(session);
11
+ // (session.id ?? session._id)?.toString();
12
12
  this.period = new period_1.PeriodOutputDto(session.period);
13
13
  this.status = session.status;
14
14
  this.doctorId =
@@ -1,7 +1,7 @@
1
1
  import { ISpecialtyDocument } from "../../models";
2
2
  import { UserOutputDto } from "./user";
3
3
  export declare class SpecialtyOutputDto {
4
- id: string;
4
+ id: string | null;
5
5
  en: {
6
6
  name: string;
7
7
  description: string | null;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SpecialtyAdminOutputDto = exports.SpecialtyOutputDto = void 0;
4
4
  const user_1 = require("./user");
5
+ const normalize_id_1 = require("../../utils/normalize.id");
5
6
  // Base DTO for everyone
6
7
  class SpecialtyOutputDto {
7
8
  constructor(specialty) {
8
- var _a, _b;
9
- this.id = (_b = ((_a = specialty.id) !== null && _a !== void 0 ? _a : specialty._id)) === null || _b === void 0 ? void 0 : _b.toString();
9
+ this.id = (0, normalize_id_1.normalizeId)(specialty);
10
10
  this.en = {
11
11
  name: specialty.en.name,
12
12
  description: specialty.en.description || null,
@@ -1,6 +1,6 @@
1
1
  import { IUserDocument } from "../../models";
2
2
  export declare class UserPublicOutputDto {
3
- id: string;
3
+ id: string | null;
4
4
  name: string;
5
5
  email: string;
6
6
  role: string;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoggedInUserOutputDto = exports.UserAdminOutputDto = exports.UserOutputDto = exports.UserPublicOutputDto = void 0;
4
+ const normalize_id_1 = require("../../utils/normalize.id");
4
5
  class UserPublicOutputDto {
5
6
  constructor(user) {
6
- var _a, _b;
7
- this.id = (_b = ((_a = user.id) !== null && _a !== void 0 ? _a : user._id)) === null || _b === void 0 ? void 0 : _b.toString();
7
+ this.id = (0, normalize_id_1.normalizeId)(user);
8
8
  this.name = user.name;
9
9
  this.email = user.email;
10
10
  this.role = user.role;
@@ -8,17 +8,17 @@ const mongoose_1 = __importDefault(require("mongoose"));
8
8
  function normalizeId(value) {
9
9
  if (!value)
10
10
  return null;
11
- // populated doc {_id: ObjectId}
12
- if (typeof value === "object" && value._id) {
13
- return normalizeId(value._id);
14
- }
15
- // ObjectId
11
+ // 1️⃣ Raw ObjectId (aggregation, normal query)
16
12
  if (value instanceof mongoose_1.default.Types.ObjectId) {
17
13
  return value.toString();
18
14
  }
19
- // already a string
15
+ // 2️⃣ Already a string
20
16
  if (typeof value === "string") {
21
17
  return value;
22
18
  }
19
+ // 3️⃣ Populated document or plain object with _id
20
+ if (typeof value === "object" && value._id) {
21
+ return normalizeId(value._id);
22
+ }
23
23
  return null;
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docta-package",
3
- "version": "1.2.131",
3
+ "version": "1.2.134",
4
4
  "description": "This package will contail all the required files to run the docta micro-service app",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",