@friggframework/core 2.0.0--canary.498.056db99.0 → 2.0.0--canary.498.02de8cb.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.498.056db99.0",
4
+ "version": "2.0.0--canary.498.02de8cb.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "@friggframework/eslint-config": "2.0.0--canary.498.056db99.0",
42
- "@friggframework/prettier-config": "2.0.0--canary.498.056db99.0",
43
- "@friggframework/test": "2.0.0--canary.498.056db99.0",
41
+ "@friggframework/eslint-config": "2.0.0--canary.498.02de8cb.0",
42
+ "@friggframework/prettier-config": "2.0.0--canary.498.02de8cb.0",
43
+ "@friggframework/test": "2.0.0--canary.498.02de8cb.0",
44
44
  "@prisma/client": "^6.17.0",
45
45
  "@types/lodash": "4.17.15",
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "056db998fdcb35d4834bad3f8a7313045cafdf64"
83
+ "gitHead": "02de8cb34e8c2576d999c970e43f464728a693c0"
84
84
  }
@@ -427,6 +427,26 @@ class UserRepositoryDocumentDB extends UserRepositoryInterface {
427
427
  const date = new Date(value);
428
428
  return isNaN(date.getTime()) ? undefined : date;
429
429
  }
430
+
431
+ /**
432
+ * Link an individual user to an organization user
433
+ * @param {string} individualUserId - Individual user ID (MongoDB ObjectId string)
434
+ * @param {string} organizationUserId - Organization user ID (MongoDB ObjectId string)
435
+ * @returns {Promise<Object>} Updated individual user object
436
+ */
437
+ async linkIndividualToOrganization(individualUserId, organizationUserId) {
438
+ const doc = await updateOne(
439
+ this.prisma,
440
+ 'User',
441
+ { _id: toObjectId(individualUserId), type: 'INDIVIDUAL' },
442
+ { $set: { organizationId: toObjectId(organizationUserId) } }
443
+ );
444
+ const decrypted = await this.encryptionService.decryptFields(
445
+ 'User',
446
+ doc
447
+ );
448
+ return this._mapUser(decrypted);
449
+ }
430
450
  }
431
451
 
432
452
  module.exports = { UserRepositoryDocumentDB };
@@ -193,6 +193,20 @@ class UserRepositoryInterface {
193
193
  async deleteUser(userId) {
194
194
  throw new Error('Method deleteUser must be implemented by subclass');
195
195
  }
196
+
197
+ /**
198
+ * Link an individual user to an organization user
199
+ *
200
+ * @param {string|number} individualUserId - Individual user ID
201
+ * @param {string|number} organizationUserId - Organization user ID
202
+ * @returns {Promise<Object>} Updated individual user object
203
+ * @abstract
204
+ */
205
+ async linkIndividualToOrganization(individualUserId, organizationUserId) {
206
+ throw new Error(
207
+ 'Method linkIndividualToOrganization must be implemented by subclass'
208
+ );
209
+ }
196
210
  }
197
211
 
198
212
  module.exports = { UserRepositoryInterface };
@@ -287,6 +287,24 @@ class UserRepositoryMongo extends UserRepositoryInterface {
287
287
  throw error;
288
288
  }
289
289
  }
290
+
291
+ /**
292
+ * Link an individual user to an organization user
293
+ * @param {string} individualUserId - Individual user ID (MongoDB ObjectId string)
294
+ * @param {string} organizationUserId - Organization user ID (MongoDB ObjectId string)
295
+ * @returns {Promise<Object>} Updated individual user object
296
+ */
297
+ async linkIndividualToOrganization(individualUserId, organizationUserId) {
298
+ return await this.prisma.user.update({
299
+ where: {
300
+ id: individualUserId,
301
+ type: 'INDIVIDUAL',
302
+ },
303
+ data: {
304
+ organizationId: organizationUserId,
305
+ },
306
+ });
307
+ }
290
308
  }
291
309
 
292
310
  module.exports = { UserRepositoryMongo };