@culturefy/shared 1.0.32 → 1.0.33

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.
@@ -1,118 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserService = void 0;
4
- const tslib_1 = require("tslib");
5
- const mongoose_1 = require("mongoose");
6
- const user_model_1 = require("../models/user.model");
7
4
  const shared_1 = require("@culturefy/shared");
8
5
  class UserService extends shared_1.Initializers {
6
+ // private readonly schema = UserModel.schema;
9
7
  constructor(context, dbUrl) {
10
8
  super(context, dbUrl);
11
- this.schema = user_model_1.UserModel.schema;
12
- }
13
- getModel() {
14
- const connection = this.getConnection();
15
- if (!connection) {
16
- throw new Error('Database connection not established');
17
- }
18
- return connection.model(user_model_1.UserModel.modelName, this.schema);
19
- }
20
- getUserById(userId) {
21
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
22
- try {
23
- let model = this.getModel();
24
- this.context.log("UserId:", JSON.stringify(userId));
25
- // Handle both string and SchemaObjectId inputs
26
- let objectId;
27
- if (typeof userId === 'string') {
28
- objectId = new mongoose_1.Types.ObjectId(userId);
29
- }
30
- else {
31
- // If it's already a SchemaObjectId, extract the string value
32
- const userIdString = userId.path || userId.toString();
33
- objectId = new mongoose_1.Types.ObjectId(userIdString);
34
- }
35
- this.context.log("ObjectId:", JSON.stringify(objectId));
36
- const user = yield model.findById(objectId);
37
- this.context.log("User:", JSON.stringify(user));
38
- return user;
39
- }
40
- catch (error) {
41
- this.context.error("Error in getUserById", error);
42
- throw error;
43
- }
44
- });
45
- }
46
- getUserByBusinessId(businessId, email) {
47
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
48
- try {
49
- let model = this.getModel();
50
- this.context.log("BusinessId:", JSON.stringify(businessId));
51
- this.context.log("Email:", JSON.stringify(email));
52
- if (!businessId)
53
- return null;
54
- if (!email)
55
- return null;
56
- businessId = businessId.toLowerCase();
57
- businessId = businessId.trim();
58
- email = email.toLowerCase();
59
- email = email.trim();
60
- // Handle both string and SchemaObjectId inputs
61
- let objectId;
62
- if (typeof businessId === 'string') {
63
- objectId = new mongoose_1.Types.ObjectId(businessId);
64
- }
65
- else {
66
- // If it's already a SchemaObjectId, extract the string value
67
- const businessIdString = businessId.path || businessId.toString();
68
- objectId = new mongoose_1.Types.ObjectId(businessIdString);
69
- }
70
- this.context.log("ObjectId:", JSON.stringify(objectId));
71
- const user = yield model.findOne({ businessId: objectId, email: email });
72
- this.context.log("User:", JSON.stringify(user));
73
- return user;
74
- }
75
- catch (error) {
76
- this.context.error("Error in getUserByBusinessId", error);
77
- throw error;
78
- }
79
- });
80
- }
81
- getUserByEmail(email) {
82
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
83
- try {
84
- let model = this.getModel();
85
- this.context.log("Email:", JSON.stringify(email));
86
- email = email.toLowerCase();
87
- email = email.trim();
88
- const user = yield model.findOne({ email: email });
89
- this.context.log("User:", JSON.stringify(user));
90
- return user;
91
- }
92
- catch (error) {
93
- this.context.error("Error in getUserByEmail", error);
94
- throw error;
95
- }
96
- });
97
9
  }
98
10
  }
99
11
  exports.UserService = UserService;
100
- tslib_1.__decorate([
101
- shared_1.WithDb,
102
- tslib_1.__metadata("design:type", Function),
103
- tslib_1.__metadata("design:paramtypes", [String]),
104
- tslib_1.__metadata("design:returntype", Promise)
105
- ], UserService.prototype, "getUserById", null);
106
- tslib_1.__decorate([
107
- shared_1.WithDb,
108
- tslib_1.__metadata("design:type", Function),
109
- tslib_1.__metadata("design:paramtypes", [String, String]),
110
- tslib_1.__metadata("design:returntype", Promise)
111
- ], UserService.prototype, "getUserByBusinessId", null);
112
- tslib_1.__decorate([
113
- shared_1.WithDb,
114
- tslib_1.__metadata("design:type", Function),
115
- tslib_1.__metadata("design:paramtypes", [String]),
116
- tslib_1.__metadata("design:returntype", Promise)
117
- ], UserService.prototype, "getUserByEmail", null);
118
12
  //# sourceMappingURL=user.service.js.map
@@ -1 +1 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B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;gBACrD,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;KAAA;CACJ;AA7FD,kCA6FC;AA7ES;IADL,eAAM;;;;8CAwBN;AAGK;IADL,eAAM;;;;sDAkCN;AAGK;IADL,eAAM;;;;iDAeN"}
1
+ {"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../../src/service/user.service.ts"],"names":[],"mappings":";;;AAKA,8CAAyD;AAEzD,MAAa,WAAY,SAAQ,qBAAY;IAEzC,8CAA8C;IAC9C,YAAY,OAA0B,EAAE,KAAY;QAChD,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;CAwFJ;AA7FD,kCA6FC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@culturefy/shared",
3
3
  "description": "Shared utilities for culturefy serverless services",
4
- "version": "1.0.32",
4
+ "version": "1.0.33",
5
5
  "main": "build/cjs/index.js",
6
6
  "module": "build/esm/index.js",
7
7
  "types": "build/src/index.d.ts",
@@ -350,7 +350,8 @@ async function validateUserByRealm(
350
350
  let user = null;
351
351
  context.log("Getting user by realm:", realm);
352
352
  try {
353
- user = await userService.getUserByBusinessId(realm, email);
353
+ // user = await userService.getUserByBusinessId(realm, email);
354
+ user = '';
354
355
  } catch (err: any) {
355
356
  context.error(`Failed to get user by realm:`, err);
356
357
  return { success: false, message: "User not found.." };
@@ -389,7 +390,8 @@ async function validateUserByEmail(
389
390
  let user = null;
390
391
  context.log("Getting user by email:", email);
391
392
  try {
392
- user = await userService.getUserByEmail(email);
393
+ // user = await userService.getUserByEmail(email);
394
+ user = '';
393
395
  } catch (err: any) {
394
396
  context.error(`Failed to get user by email:`, err);
395
397
  return { success: false, message: "User not found.." };