docta-package 1.2.131 → 1.2.133

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 @@ 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 =
@@ -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.133",
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",