connectfy-shared 0.0.88 → 0.0.90

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.cjs CHANGED
@@ -9849,6 +9849,7 @@ var CLS_KEYS = /* @__PURE__ */ ((CLS_KEYS2) => {
9849
9849
  CLS_KEYS2["LANG"] = "lang";
9850
9850
  CLS_KEYS2["ACCOUNT"] = "account";
9851
9851
  CLS_KEYS2["SETTINGS"] = "settings";
9852
+ CLS_KEYS2["DEVICE_ID"] = "deviceId";
9852
9853
  return CLS_KEYS2;
9853
9854
  })(CLS_KEYS || {});
9854
9855
  var FIELD_TYPE = /* @__PURE__ */ ((FIELD_TYPE2) => {
@@ -11359,14 +11360,19 @@ var BaseRepository = class {
11359
11360
  // CREATE AND CREATE MANY FUNCTIONS
11360
11361
  // ================================================
11361
11362
  async create(data, opts) {
11363
+ const virtuals = opts?.lean ?? true;
11362
11364
  const newData = new this.model(data);
11363
11365
  let saved = await newData.save();
11364
11366
  if (opts?.populate) {
11365
11367
  saved = await saved.populate(opts.populate);
11366
11368
  }
11367
- return saved.toObject({ versionKey: false });
11369
+ return saved.toObject({
11370
+ versionKey: false,
11371
+ virtuals
11372
+ });
11368
11373
  }
11369
11374
  async createMany(data, opts) {
11375
+ const virtuals = opts?.lean ?? true;
11370
11376
  const inserted = await this.model.insertMany(data, {
11371
11377
  lean: true,
11372
11378
  ordered: false
@@ -11375,9 +11381,14 @@ var BaseRepository = class {
11375
11381
  const ids = inserted.map((doc) => doc._id);
11376
11382
  const populated = await this.model.find({ _id: { $in: ids } }).populate(
11377
11383
  opts.populate
11378
- ).lean().exec();
11384
+ ).lean({ virtuals }).exec();
11379
11385
  return populated;
11380
11386
  }
11387
+ if (virtuals) {
11388
+ return inserted.map(
11389
+ (doc) => doc.toObject({ versionKey: false, virtuals })
11390
+ );
11391
+ }
11381
11392
  return inserted;
11382
11393
  }
11383
11394
  // ================================================
@@ -11389,7 +11400,7 @@ var BaseRepository = class {
11389
11400
  new: opts?.new ?? true,
11390
11401
  runValidators: opts?.runValidators ?? true,
11391
11402
  populate: opts?.populate ?? [],
11392
- lean: opts?.lean ?? false
11403
+ lean: opts?.lean ?? true ? { virtuals: true } : false
11393
11404
  };
11394
11405
  const updatedData = await this.model.findOneAndUpdate(
11395
11406
  query,
@@ -11438,24 +11449,27 @@ var BaseRepository = class {
11438
11449
  // ================================================
11439
11450
  // FINE ONE AND FIND MANY FUNCTIONS
11440
11451
  // ================================================
11441
- async findOne(params = {}) {
11452
+ async findOne(params = {}, opts) {
11442
11453
  const {
11443
11454
  query = {},
11444
11455
  fields = "",
11445
11456
  sort = { createdAt: -1 },
11446
11457
  populate = []
11447
11458
  } = params;
11448
- return await this.model.findOne(query).select(fields).sort(sort).populate(populate).lean().exec();
11459
+ const virtuals = opts?.lean ?? true;
11460
+ return await this.model.findOne(query).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11449
11461
  }
11450
- async findOneById(_id, params = {}) {
11462
+ async findOneById(_id, params = {}, opts) {
11451
11463
  const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
11452
- return await this.model.findOne({ _id }).select(fields).sort(sort).populate(populate).lean().exec();
11464
+ const virtuals = opts?.lean ?? true;
11465
+ return await this.model.findOne({ _id }).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11453
11466
  }
11454
- async findOneByUserId(userId, params = {}) {
11467
+ async findOneByUserId(userId, params = {}, opts) {
11455
11468
  const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
11456
- return await this.model.findOne({ userId }).select(fields).sort(sort).populate(populate).lean().exec();
11469
+ const virtuals = opts?.lean ?? true;
11470
+ return await this.model.findOne({ userId }).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11457
11471
  }
11458
- async findMany(params = {}) {
11472
+ async findMany(params = {}, opts) {
11459
11473
  const {
11460
11474
  query = {},
11461
11475
  fields = "",
@@ -11464,16 +11478,18 @@ var BaseRepository = class {
11464
11478
  skip = 0,
11465
11479
  limit = 10
11466
11480
  } = params;
11467
- return await this.model.find(query).select(fields).skip(skip).limit(limit).sort(sort).populate(populate).lean().exec();
11481
+ const virtuals = opts?.lean ?? true;
11482
+ return await this.model.find(query).select(fields).skip(skip).limit(limit).sort(sort).populate(populate).lean({ virtuals }).exec();
11468
11483
  }
11469
- async findAll(params = {}) {
11484
+ async findAll(params = {}, opts) {
11470
11485
  const {
11471
11486
  query = {},
11472
11487
  fields = "",
11473
11488
  sort = { createdAt: -1 },
11474
11489
  populate = []
11475
11490
  } = params;
11476
- return await this.model.find(query).select(fields).sort(sort).populate(populate).lean().exec();
11491
+ const virtuals = opts?.lean ?? true;
11492
+ return await this.model.find(query).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11477
11493
  }
11478
11494
  // ================================================
11479
11495
  // EXIST AND COUNT FUNCTIONS
package/dist/index.d.cts CHANGED
@@ -237,7 +237,8 @@ declare enum CLS_KEYS {
237
237
  USER = "user",
238
238
  LANG = "lang",
239
239
  ACCOUNT = "account",
240
- SETTINGS = "settings"
240
+ SETTINGS = "settings",
241
+ DEVICE_ID = "deviceId"
241
242
  }
242
243
  declare enum FIELD_TYPE {
243
244
  STRING = "string",
@@ -744,11 +745,11 @@ declare abstract class BaseRepository<TDocument extends Document, TInterface ext
744
745
  remove(data: BaseRemoveDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
745
746
  removeOne(query: Record<string, any>, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
746
747
  removeMany(data: BaseRemoveAllDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface[]>;
747
- findOne(params?: BaseFindDto): Promise<TInterface | null>;
748
- findOneById(_id: string, params?: BaseFindDto): Promise<TInterface | null>;
749
- findOneByUserId(userId: string, params?: BaseFindDto): Promise<TInterface | null>;
750
- findMany(params?: BaseFindDto): Promise<TInterface[]>;
751
- findAll(params?: BaseFindDto): Promise<TInterface[]>;
748
+ findOne(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
749
+ findOneById(_id: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
750
+ findOneByUserId(userId: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
751
+ findMany(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
752
+ findAll(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
752
753
  existsByField(query: Record<string, any>): Promise<boolean>;
753
754
  count(query: Record<string, any>): Promise<number>;
754
755
  }
package/dist/index.d.ts CHANGED
@@ -237,7 +237,8 @@ declare enum CLS_KEYS {
237
237
  USER = "user",
238
238
  LANG = "lang",
239
239
  ACCOUNT = "account",
240
- SETTINGS = "settings"
240
+ SETTINGS = "settings",
241
+ DEVICE_ID = "deviceId"
241
242
  }
242
243
  declare enum FIELD_TYPE {
243
244
  STRING = "string",
@@ -744,11 +745,11 @@ declare abstract class BaseRepository<TDocument extends Document, TInterface ext
744
745
  remove(data: BaseRemoveDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
745
746
  removeOne(query: Record<string, any>, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface>;
746
747
  removeMany(data: BaseRemoveAllDto, opts?: IBaseRepositoryRemoveOptions): Promise<TInterface[]>;
747
- findOne(params?: BaseFindDto): Promise<TInterface | null>;
748
- findOneById(_id: string, params?: BaseFindDto): Promise<TInterface | null>;
749
- findOneByUserId(userId: string, params?: BaseFindDto): Promise<TInterface | null>;
750
- findMany(params?: BaseFindDto): Promise<TInterface[]>;
751
- findAll(params?: BaseFindDto): Promise<TInterface[]>;
748
+ findOne(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
749
+ findOneById(_id: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
750
+ findOneByUserId(userId: string, params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface | null>;
751
+ findMany(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
752
+ findAll(params?: BaseFindDto, opts?: IBaseRepositoryOptions): Promise<TInterface[]>;
752
753
  existsByField(query: Record<string, any>): Promise<boolean>;
753
754
  count(query: Record<string, any>): Promise<number>;
754
755
  }
package/dist/index.mjs CHANGED
@@ -9764,6 +9764,7 @@ var CLS_KEYS = /* @__PURE__ */ ((CLS_KEYS2) => {
9764
9764
  CLS_KEYS2["LANG"] = "lang";
9765
9765
  CLS_KEYS2["ACCOUNT"] = "account";
9766
9766
  CLS_KEYS2["SETTINGS"] = "settings";
9767
+ CLS_KEYS2["DEVICE_ID"] = "deviceId";
9767
9768
  return CLS_KEYS2;
9768
9769
  })(CLS_KEYS || {});
9769
9770
  var FIELD_TYPE = /* @__PURE__ */ ((FIELD_TYPE2) => {
@@ -11316,14 +11317,19 @@ var BaseRepository = class {
11316
11317
  // CREATE AND CREATE MANY FUNCTIONS
11317
11318
  // ================================================
11318
11319
  async create(data, opts) {
11320
+ const virtuals = opts?.lean ?? true;
11319
11321
  const newData = new this.model(data);
11320
11322
  let saved = await newData.save();
11321
11323
  if (opts?.populate) {
11322
11324
  saved = await saved.populate(opts.populate);
11323
11325
  }
11324
- return saved.toObject({ versionKey: false });
11326
+ return saved.toObject({
11327
+ versionKey: false,
11328
+ virtuals
11329
+ });
11325
11330
  }
11326
11331
  async createMany(data, opts) {
11332
+ const virtuals = opts?.lean ?? true;
11327
11333
  const inserted = await this.model.insertMany(data, {
11328
11334
  lean: true,
11329
11335
  ordered: false
@@ -11332,9 +11338,14 @@ var BaseRepository = class {
11332
11338
  const ids = inserted.map((doc) => doc._id);
11333
11339
  const populated = await this.model.find({ _id: { $in: ids } }).populate(
11334
11340
  opts.populate
11335
- ).lean().exec();
11341
+ ).lean({ virtuals }).exec();
11336
11342
  return populated;
11337
11343
  }
11344
+ if (virtuals) {
11345
+ return inserted.map(
11346
+ (doc) => doc.toObject({ versionKey: false, virtuals })
11347
+ );
11348
+ }
11338
11349
  return inserted;
11339
11350
  }
11340
11351
  // ================================================
@@ -11346,7 +11357,7 @@ var BaseRepository = class {
11346
11357
  new: opts?.new ?? true,
11347
11358
  runValidators: opts?.runValidators ?? true,
11348
11359
  populate: opts?.populate ?? [],
11349
- lean: opts?.lean ?? false
11360
+ lean: opts?.lean ?? true ? { virtuals: true } : false
11350
11361
  };
11351
11362
  const updatedData = await this.model.findOneAndUpdate(
11352
11363
  query,
@@ -11395,24 +11406,27 @@ var BaseRepository = class {
11395
11406
  // ================================================
11396
11407
  // FINE ONE AND FIND MANY FUNCTIONS
11397
11408
  // ================================================
11398
- async findOne(params = {}) {
11409
+ async findOne(params = {}, opts) {
11399
11410
  const {
11400
11411
  query = {},
11401
11412
  fields = "",
11402
11413
  sort = { createdAt: -1 },
11403
11414
  populate = []
11404
11415
  } = params;
11405
- return await this.model.findOne(query).select(fields).sort(sort).populate(populate).lean().exec();
11416
+ const virtuals = opts?.lean ?? true;
11417
+ return await this.model.findOne(query).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11406
11418
  }
11407
- async findOneById(_id, params = {}) {
11419
+ async findOneById(_id, params = {}, opts) {
11408
11420
  const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
11409
- return await this.model.findOne({ _id }).select(fields).sort(sort).populate(populate).lean().exec();
11421
+ const virtuals = opts?.lean ?? true;
11422
+ return await this.model.findOne({ _id }).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11410
11423
  }
11411
- async findOneByUserId(userId, params = {}) {
11424
+ async findOneByUserId(userId, params = {}, opts) {
11412
11425
  const { fields = "", sort = { createdAt: -1 }, populate = [] } = params;
11413
- return await this.model.findOne({ userId }).select(fields).sort(sort).populate(populate).lean().exec();
11426
+ const virtuals = opts?.lean ?? true;
11427
+ return await this.model.findOne({ userId }).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11414
11428
  }
11415
- async findMany(params = {}) {
11429
+ async findMany(params = {}, opts) {
11416
11430
  const {
11417
11431
  query = {},
11418
11432
  fields = "",
@@ -11421,16 +11435,18 @@ var BaseRepository = class {
11421
11435
  skip = 0,
11422
11436
  limit = 10
11423
11437
  } = params;
11424
- return await this.model.find(query).select(fields).skip(skip).limit(limit).sort(sort).populate(populate).lean().exec();
11438
+ const virtuals = opts?.lean ?? true;
11439
+ return await this.model.find(query).select(fields).skip(skip).limit(limit).sort(sort).populate(populate).lean({ virtuals }).exec();
11425
11440
  }
11426
- async findAll(params = {}) {
11441
+ async findAll(params = {}, opts) {
11427
11442
  const {
11428
11443
  query = {},
11429
11444
  fields = "",
11430
11445
  sort = { createdAt: -1 },
11431
11446
  populate = []
11432
11447
  } = params;
11433
- return await this.model.find(query).select(fields).sort(sort).populate(populate).lean().exec();
11448
+ const virtuals = opts?.lean ?? true;
11449
+ return await this.model.find(query).select(fields).sort(sort).populate(populate).lean({ virtuals }).exec();
11434
11450
  }
11435
11451
  // ================================================
11436
11452
  // EXIST AND COUNT FUNCTIONS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectfy-shared",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {