@friggframework/core 2.0.0-next.59 → 2.0.0-next.60

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.
@@ -215,6 +215,27 @@ function createCredentialCommands() {
215
215
  return mapErrorToResponse(error);
216
216
  }
217
217
  },
218
+
219
+ /**
220
+ * Delete a credential by ID (alias for deleteCredential)
221
+ * @param {string} credentialId - Credential ID to delete
222
+ * @returns {Promise<Object>} Result object with success flag
223
+ */
224
+ async deleteCredentialById(credentialId) {
225
+ try {
226
+ if (!credentialId) {
227
+ const error = new Error('credentialId is required');
228
+ error.code = 'INVALID_CREDENTIAL_DATA';
229
+ throw error;
230
+ }
231
+
232
+ await credRepo.deleteCredentialById(credentialId);
233
+
234
+ return { success: true };
235
+ } catch (error) {
236
+ return mapErrorToResponse(error);
237
+ }
238
+ },
218
239
  };
219
240
  }
220
241
 
@@ -286,6 +286,27 @@ function createEntityCommands() {
286
286
  }
287
287
  },
288
288
 
289
+ /**
290
+ * Delete an entity by ID (alias for deleteEntity)
291
+ * @param {string} entityId - Entity ID to delete
292
+ * @returns {Promise<Object>} Result object with success flag
293
+ */
294
+ async deleteEntityById(entityId) {
295
+ try {
296
+ if (!entityId) {
297
+ const error = new Error('entityId is required');
298
+ error.code = 'INVALID_ENTITY_DATA';
299
+ throw error;
300
+ }
301
+
302
+ await moduleRepo.deleteEntity(entityId);
303
+
304
+ return { success: true };
305
+ } catch (error) {
306
+ return mapErrorToResponse(error);
307
+ }
308
+ },
309
+
289
310
  /**
290
311
  * Remove credential reference from an entity
291
312
  * @param {string} entityId - Entity ID to update
@@ -161,6 +161,37 @@ function createIntegrationCommands({ integrationClass }) {
161
161
  return mapErrorToResponse(error);
162
162
  }
163
163
  },
164
+
165
+ /**
166
+ * Delete an integration by ID
167
+ * @param {string} integrationId - Integration ID to delete
168
+ * @returns {Promise<Object>} Deletion result
169
+ */
170
+ async deleteIntegrationById(integrationId) {
171
+ try {
172
+ if (!integrationId) {
173
+ const error = new Error('integrationId is required');
174
+ error.code = 'INVALID_INTEGRATION_DATA';
175
+ throw error;
176
+ }
177
+
178
+ const deleted = await integrationRepository.deleteIntegrationById(integrationId);
179
+
180
+ if (!deleted) {
181
+ const error = new Error(`Integration ${integrationId} not found`);
182
+ error.code = 'INTEGRATION_NOT_FOUND';
183
+ return mapErrorToResponse(error);
184
+ }
185
+
186
+ return {
187
+ success: true,
188
+ integrationId,
189
+ message: 'Integration deleted successfully',
190
+ };
191
+ } catch (error) {
192
+ return mapErrorToResponse(error);
193
+ }
194
+ },
164
195
  };
165
196
  }
166
197
 
@@ -238,7 +238,14 @@ function createUserCommands() {
238
238
 
239
239
  /**
240
240
  * Delete a user by ID
241
- * Cascades to all related records (credentials, entities, integrations, etc.)
241
+ *
242
+ * IMPORTANT: This does NOT automatically cascade delete related records in MongoDB.
243
+ * Integration developers MUST manually delete related data first:
244
+ * 1. Delete integrations (via deleteIntegrationById)
245
+ * 2. Delete entities (via deleteEntityById)
246
+ * 3. Delete credentials (via deleteCredentialById)
247
+ * 4. Finally delete user (via deleteUserById)
248
+ *
242
249
  * @param {string} userId - User ID to delete
243
250
  * @returns {Promise<Object>} Deletion result
244
251
  */
@@ -261,7 +268,7 @@ function createUserCommands() {
261
268
  return {
262
269
  success: true,
263
270
  userId,
264
- message: 'User and all related data deleted successfully',
271
+ message: 'User deleted successfully',
265
272
  };
266
273
  } catch (error) {
267
274
  return mapErrorToResponse(error);
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-next.59",
4
+ "version": "2.0.0-next.60",
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-next.59",
42
- "@friggframework/prettier-config": "2.0.0-next.59",
43
- "@friggframework/test": "2.0.0-next.59",
41
+ "@friggframework/eslint-config": "2.0.0-next.60",
42
+ "@friggframework/prettier-config": "2.0.0-next.60",
43
+ "@friggframework/test": "2.0.0-next.60",
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": "53a970071272e2fd89c6454742c50de367647c85"
83
+ "gitHead": "8fc85a629bedc7b17a9415ef8952dddb1daee1b5"
84
84
  }
@@ -259,6 +259,15 @@ class UserRepositoryMongo extends UserRepositoryInterface {
259
259
 
260
260
  /**
261
261
  * Delete user by ID
262
+ *
263
+ * NOTE: This only deletes the user record itself.
264
+ * Prisma's onDelete: Cascade does NOT work reliably with MongoDB (no database-level referential integrity).
265
+ * Integration developers MUST manually cascade delete related records before calling this method:
266
+ * 1. Delete integrations (via deleteIntegrationById)
267
+ * 2. Delete entities (via deleteEntityById)
268
+ * 3. Delete credentials (via deleteCredentialById)
269
+ * 4. Finally delete user (via deleteUserById)
270
+ *
262
271
  * @param {string} userId - User ID to delete
263
272
  * @returns {Promise<boolean>} True if deleted successfully
264
273
  */