@friggframework/core 2.0.0--canary.548.c8ae0ca.0 → 2.0.0--canary.545.dba001a.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.
Files changed (235) hide show
  1. package/CHANGELOG.md +66 -67
  2. package/CLAUDE.md +148 -124
  3. package/README.md +165 -130
  4. package/admin-scripts/index.js +52 -0
  5. package/admin-scripts/repositories/admin-api-key-repository-documentdb.js +21 -0
  6. package/admin-scripts/repositories/admin-api-key-repository-factory.js +51 -0
  7. package/admin-scripts/repositories/admin-api-key-repository-interface.js +121 -0
  8. package/admin-scripts/repositories/admin-api-key-repository-mongo.js +155 -0
  9. package/admin-scripts/repositories/admin-api-key-repository-postgres.js +189 -0
  10. package/admin-scripts/repositories/admin-process-repository-documentdb.js +21 -0
  11. package/admin-scripts/repositories/admin-process-repository-factory.js +49 -0
  12. package/admin-scripts/repositories/admin-process-repository-interface.js +150 -0
  13. package/admin-scripts/repositories/admin-process-repository-mongo.js +213 -0
  14. package/admin-scripts/repositories/admin-process-repository-postgres.js +251 -0
  15. package/admin-scripts/repositories/script-execution-repository-documentdb.js +21 -0
  16. package/admin-scripts/repositories/script-execution-repository-factory.js +51 -0
  17. package/admin-scripts/repositories/script-execution-repository-interface.js +193 -0
  18. package/admin-scripts/repositories/script-execution-repository-mongo.js +278 -0
  19. package/admin-scripts/repositories/script-execution-repository-postgres.js +320 -0
  20. package/admin-scripts/repositories/script-schedule-repository-documentdb.js +21 -0
  21. package/admin-scripts/repositories/script-schedule-repository-factory.js +49 -0
  22. package/admin-scripts/repositories/script-schedule-repository-interface.js +108 -0
  23. package/admin-scripts/repositories/script-schedule-repository-mongo.js +179 -0
  24. package/admin-scripts/repositories/script-schedule-repository-postgres.js +210 -0
  25. package/application/commands/admin-script-commands.js +348 -0
  26. package/application/commands/integration-commands.js +12 -6
  27. package/application/index.js +5 -3
  28. package/assertions/get.js +17 -7
  29. package/associations/association.js +59 -57
  30. package/core/CLAUDE.md +222 -156
  31. package/core/Worker.js +33 -12
  32. package/credential/credential-router.js +262 -0
  33. package/credential/repositories/credential-repository-documentdb.js +71 -1
  34. package/credential/repositories/credential-repository-factory.js +4 -6
  35. package/credential/repositories/credential-repository-interface.js +8 -2
  36. package/credential/repositories/credential-repository-mongo.js +45 -4
  37. package/credential/repositories/credential-repository-postgres.js +44 -3
  38. package/credential/repositories/credential-repository.js +3 -1
  39. package/credential/use-cases/delete-credential-for-user.js +50 -0
  40. package/credential/use-cases/get-credential-for-user.js +21 -3
  41. package/credential/use-cases/list-credentials-for-user.js +31 -0
  42. package/credential/use-cases/reauthorize-credential.js +103 -0
  43. package/credential/use-cases/update-authentication-status.js +5 -2
  44. package/database/MONGODB_TRANSACTION_FIX.md +72 -52
  45. package/database/config.js +13 -59
  46. package/database/documentdb-encryption-service.js +29 -13
  47. package/database/documentdb-utils.js +21 -12
  48. package/database/encryption/README.md +53 -36
  49. package/database/encryption/encryption-schema-registry.js +29 -23
  50. package/database/encryption/field-encryption-service.js +15 -4
  51. package/database/encryption/logger.js +3 -2
  52. package/database/encryption/prisma-encryption-extension.js +5 -8
  53. package/database/prisma.js +22 -14
  54. package/database/repositories/health-check-repository-factory.js +7 -5
  55. package/database/repositories/health-check-repository-interface.js +15 -5
  56. package/database/repositories/health-check-repository-postgres.js +1 -1
  57. package/database/use-cases/check-database-health-use-case.js +3 -2
  58. package/database/use-cases/check-database-state-use-case.js +8 -7
  59. package/database/use-cases/get-database-state-via-worker-use-case.js +15 -12
  60. package/database/use-cases/get-migration-status-use-case.js +4 -2
  61. package/database/use-cases/run-database-migration-use-case.js +41 -9
  62. package/database/use-cases/test-encryption-use-case.js +4 -5
  63. package/database/use-cases/trigger-database-migration-use-case.js +9 -8
  64. package/database/utils/mongodb-collection-utils.js +11 -3
  65. package/database/utils/mongodb-schema-init.js +10 -4
  66. package/database/utils/prisma-runner.js +144 -74
  67. package/database/utils/prisma-schema-parser.js +2 -2
  68. package/docs/PROCESS_MANAGEMENT_QUEUE_SPEC.md +135 -80
  69. package/encrypt/Cryptor.js +54 -49
  70. package/encrypt/aes-encryption-key-provider.js +82 -0
  71. package/encrypt/encryption-key-provider-interface.js +50 -0
  72. package/errors/fetch-error.js +1 -1
  73. package/generated/prisma-mongodb/edge.js +59 -4
  74. package/generated/prisma-mongodb/index-browser.js +49 -1
  75. package/generated/prisma-mongodb/index.d.ts +4023 -61
  76. package/generated/prisma-mongodb/index.js +59 -4
  77. package/generated/prisma-mongodb/package.json +1 -1
  78. package/generated/prisma-mongodb/schema.prisma +87 -0
  79. package/generated/prisma-mongodb/wasm.js +59 -4
  80. package/generated/prisma-postgresql/edge.js +58 -4
  81. package/generated/prisma-postgresql/index-browser.js +48 -1
  82. package/generated/prisma-postgresql/index.d.ts +4738 -54
  83. package/generated/prisma-postgresql/index.js +58 -4
  84. package/generated/prisma-postgresql/package.json +1 -1
  85. package/generated/prisma-postgresql/schema.prisma +85 -0
  86. package/generated/prisma-postgresql/wasm.js +58 -4
  87. package/handlers/WEBHOOKS.md +104 -81
  88. package/handlers/app-definition-loader.js +53 -10
  89. package/handlers/app-handler-helpers.js +14 -3
  90. package/handlers/backend-utils.js +0 -1
  91. package/handlers/database-migration-handler.js +64 -45
  92. package/handlers/middleware/admin-auth.js +53 -0
  93. package/handlers/routers/HEALTHCHECK.md +170 -135
  94. package/handlers/routers/admin.js +450 -0
  95. package/handlers/routers/auth.js +23 -2
  96. package/handlers/routers/db-migration.handler.js +2 -3
  97. package/handlers/routers/db-migration.js +102 -66
  98. package/handlers/routers/docs.js +180 -0
  99. package/handlers/routers/health.js +39 -249
  100. package/handlers/routers/integration-defined-routers.js +4 -4
  101. package/handlers/routers/integration-webhook-routers.js +17 -7
  102. package/handlers/routers/middleware/loadUser.js +39 -0
  103. package/handlers/routers/middleware/requireAdmin.js +43 -0
  104. package/handlers/routers/middleware/requireLoggedInUser.js +19 -0
  105. package/handlers/routers/websocket.js +9 -3
  106. package/handlers/use-cases/check-integrations-health-use-case.js +13 -6
  107. package/handlers/workers/db-migration.js +74 -35
  108. package/index.js +50 -16
  109. package/infrastructure/scheduler/index.js +15 -11
  110. package/infrastructure/scheduler/netlify-scheduler-adapter.js +185 -0
  111. package/infrastructure/scheduler/scheduler-service-factory.js +38 -31
  112. package/integrations/WEBHOOK-QUICKSTART.md +21 -14
  113. package/integrations/index.js +4 -0
  114. package/integrations/integration-base.js +9 -6
  115. package/integrations/integration-router.js +1828 -157
  116. package/integrations/options.js +47 -20
  117. package/integrations/repositories/integration-mapping-repository-factory.js +4 -8
  118. package/integrations/repositories/integration-repository-documentdb.js +53 -24
  119. package/integrations/repositories/integration-repository-factory.js +6 -6
  120. package/integrations/repositories/integration-repository-interface.js +27 -9
  121. package/integrations/repositories/integration-repository-postgres.js +3 -3
  122. package/integrations/repositories/process-repository-factory.js +4 -7
  123. package/integrations/repositories/process-repository-interface.js +9 -5
  124. package/integrations/repositories/process-repository-mongo.js +7 -3
  125. package/integrations/repositories/process-repository-postgres.js +2 -2
  126. package/integrations/tests/doubles/config-capturing-integration.js +9 -8
  127. package/integrations/tests/doubles/dummy-integration-class.js +81 -8
  128. package/integrations/tests/doubles/test-integration-repository.js +51 -11
  129. package/integrations/use-cases/create-integration.js +36 -32
  130. package/integrations/use-cases/create-process.js +20 -9
  131. package/integrations/use-cases/delete-integration-for-user.js +5 -4
  132. package/integrations/use-cases/execute-proxy-request.js +564 -0
  133. package/integrations/use-cases/get-integration-for-user.js +25 -10
  134. package/integrations/use-cases/get-integration-instance-by-definition.js +13 -7
  135. package/integrations/use-cases/get-integrations-for-user.js +4 -1
  136. package/integrations/use-cases/get-possible-integrations.js +1 -1
  137. package/integrations/use-cases/get-process.js +5 -6
  138. package/integrations/use-cases/index.js +3 -1
  139. package/integrations/use-cases/load-integration-context.js +1 -5
  140. package/integrations/use-cases/update-process-state.js +10 -8
  141. package/integrations/utils/map-integration-dto.js +9 -3
  142. package/jest-setup.js +1 -1
  143. package/jest-teardown.js +1 -1
  144. package/lambda/TimeoutCatcher.js +32 -30
  145. package/lambda/index.js +1 -1
  146. package/logs/index.js +3 -3
  147. package/modules/domain/entities/AuthorizationSession.js +131 -0
  148. package/modules/domain/entities/index.js +10 -0
  149. package/modules/module.js +4 -9
  150. package/modules/repositories/authorization-session-repository-factory.js +53 -0
  151. package/modules/repositories/authorization-session-repository-interface.js +75 -0
  152. package/modules/repositories/authorization-session-repository-mongo.js +169 -0
  153. package/modules/repositories/authorization-session-repository-postgres.js +170 -0
  154. package/modules/repositories/module-repository-documentdb.js +89 -41
  155. package/modules/repositories/module-repository-factory.js +4 -6
  156. package/modules/repositories/module-repository-interface.js +13 -0
  157. package/modules/repositories/module-repository-mongo.js +40 -5
  158. package/modules/repositories/module-repository-postgres.js +42 -5
  159. package/modules/repositories/module-repository.js +28 -0
  160. package/modules/requester/api-key.js +0 -2
  161. package/modules/requester/basic.js +0 -1
  162. package/modules/requester/oauth-2.js +3 -14
  163. package/modules/test/mock-api/definition.js +15 -10
  164. package/modules/test/mock-api/mocks/hubspot.js +36 -36
  165. package/modules/tests/doubles/test-module-factory.js +10 -4
  166. package/modules/tests/doubles/test-module-repository.js +1 -1
  167. package/modules/use-cases/delete-module-entity.js +23 -0
  168. package/modules/use-cases/get-authorization-requirements.js +110 -0
  169. package/modules/use-cases/get-entities-for-user.js +1 -1
  170. package/modules/use-cases/get-entity-options-by-id.js +8 -6
  171. package/modules/use-cases/get-module-entity-by-id.js +16 -0
  172. package/modules/use-cases/get-module.js +12 -9
  173. package/modules/use-cases/process-authorization-callback.js +12 -6
  174. package/modules/use-cases/process-authorization-step.js +160 -0
  175. package/modules/use-cases/refresh-entity-options.js +8 -6
  176. package/modules/use-cases/start-authorization-session.js +86 -0
  177. package/modules/use-cases/test-module-auth.js +8 -6
  178. package/modules/use-cases/update-module-entity.js +27 -0
  179. package/modules/utils/map-module-dto.js +2 -2
  180. package/openapi/openapi-spec-generator.js +370 -0
  181. package/openapi/openapi-v1.yaml +1360 -0
  182. package/openapi/openapi-v2.yaml +1535 -0
  183. package/package.json +7 -9
  184. package/prisma-mongodb/schema.prisma +87 -0
  185. package/prisma-postgresql/migrations/20260222000000_add_admin_process_and_script_schedule/migration.sql +55 -0
  186. package/prisma-postgresql/schema.prisma +85 -0
  187. package/providers/index.js +13 -0
  188. package/providers/resolve-provider.js +93 -0
  189. package/queues/index.js +19 -0
  190. package/queues/providers/index.js +7 -0
  191. package/queues/providers/netlify-background-provider.js +76 -0
  192. package/queues/providers/qstash-queue-provider.js +122 -0
  193. package/queues/queue-client-interface.js +55 -0
  194. package/queues/queue-provider-factory.js +93 -0
  195. package/queues/queue-provider.js +46 -0
  196. package/queues/queuer-util.js +33 -25
  197. package/syncs/repositories/sync-repository-documentdb.js +39 -19
  198. package/syncs/repositories/sync-repository-factory.js +4 -4
  199. package/syncs/repositories/sync-repository-interface.js +6 -2
  200. package/syncs/repositories/sync-repository-postgres.js +19 -13
  201. package/syncs/sync.js +104 -100
  202. package/token/repositories/token-repository-factory.js +4 -6
  203. package/types/assertions/index.d.ts +72 -72
  204. package/types/core/index.d.ts +98 -53
  205. package/types/errors/index.d.ts +61 -54
  206. package/types/eslint-config/index.d.ts +40 -40
  207. package/types/lambda/index.d.ts +26 -26
  208. package/types/logs/index.d.ts +4 -4
  209. package/types/prettier-config/index.d.ts +5 -5
  210. package/types/test-environment/index.d.ts +14 -14
  211. package/types/tsconfig.json +95 -93
  212. package/user/repositories/user-repository-factory.js +4 -4
  213. package/user/tests/doubles/test-user-repository.js +5 -2
  214. package/user/use-cases/authenticate-user.js +2 -4
  215. package/user/use-cases/authenticate-with-shared-secret.js +1 -1
  216. package/user/use-cases/create-individual-user.js +8 -7
  217. package/user/use-cases/create-organization-user.js +1 -1
  218. package/user/use-cases/create-token-for-user-id.js +1 -1
  219. package/user/use-cases/delete-user.js +47 -0
  220. package/user/use-cases/get-user-from-adopter-jwt.js +0 -2
  221. package/user/use-cases/get-user-from-bearer-token.js +7 -3
  222. package/user/use-cases/get-user-from-x-frigg-headers.js +14 -11
  223. package/user/use-cases/login-user.js +8 -8
  224. package/user/user.js +18 -4
  225. package/utils/backend-path.js +2 -2
  226. package/utils/index.js +4 -1
  227. package/websocket/repositories/websocket-connection-repository-documentdb.js +46 -21
  228. package/websocket/repositories/websocket-connection-repository-factory.js +4 -8
  229. package/websocket/repositories/websocket-connection-repository-mongo.js +26 -16
  230. package/websocket/repositories/websocket-connection-repository-postgres.js +26 -15
  231. package/websocket/repositories/websocket-connection-repository.js +26 -20
  232. package/websocket/websocket-message-sender-interface.js +38 -0
  233. package/database/adapters/lambda-invoker.js +0 -97
  234. package/database/repositories/migration-status-repository-s3.js +0 -137
  235. package/infrastructure/scheduler/eventbridge-scheduler-adapter.js +0 -184
package/CLAUDE.md CHANGED
@@ -4,12 +4,12 @@ This file provides guidance to Claude Code when working with the Frigg Framework
4
4
 
5
5
  ## Critical Context (Read First)
6
6
 
7
- - **Package Purpose**: Core framework functionality for building enterprise serverless integrations
8
- - **Main Architecture**: Hexagonal/DDD architecture with clear separation of adapters, use cases, and repositories
9
- - **Key Technologies**: Node.js, Express, AWS Lambda, MongoDB/PostgreSQL (Prisma), AWS KMS encryption
10
- - **Core Value**: Provides building blocks for integration developers - they extend IntegrationBase and use framework services
11
- - **Security Model**: Field-level encryption, OAuth2 flows, signature validation, VPC deployment
12
- - **DO NOT**: Bypass architectural layers, skip encryption for sensitive data, expose internal errors to users
7
+ - **Package Purpose**: Core framework functionality for building enterprise serverless integrations
8
+ - **Main Architecture**: Hexagonal/DDD architecture with clear separation of adapters, use cases, and repositories
9
+ - **Key Technologies**: Node.js, Express, AWS Lambda, MongoDB/PostgreSQL (Prisma), AWS KMS encryption
10
+ - **Core Value**: Provides building blocks for integration developers - they extend IntegrationBase and use framework services
11
+ - **Security Model**: Field-level encryption, OAuth2 flows, signature validation, VPC deployment
12
+ - **DO NOT**: Bypass architectural layers, skip encryption for sensitive data, expose internal errors to users
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -26,14 +26,14 @@ This file provides guidance to Claude Code when working with the Frigg Framework
26
26
 
27
27
  `@friggframework/core` is the foundational package of the Frigg Framework, providing:
28
28
 
29
- - **IntegrationBase**: Base class all integrations extend
30
- - **Database Layer**: Multi-database support (MongoDB, DocumentDB, PostgreSQL) with Prisma ORM
31
- - **Encryption**: Transparent field-level encryption with AWS KMS or AES
32
- - **User Management**: Individual and organizational user support
33
- - **Module System**: API module loading and credential management
34
- - **Lambda Runtime**: Handler factory, worker base class, timeout management
35
- - **Error Handling**: Standardized error types with proper HTTP status codes
36
- - **Event System**: Integration lifecycle events and user actions
29
+ - **IntegrationBase**: Base class all integrations extend
30
+ - **Database Layer**: Multi-database support (MongoDB, DocumentDB, PostgreSQL) with Prisma ORM
31
+ - **Encryption**: Transparent field-level encryption with AWS KMS or AES
32
+ - **User Management**: Individual and organizational user support
33
+ - **Module System**: API module loading and credential management
34
+ - **Lambda Runtime**: Handler factory, worker base class, timeout management
35
+ - **Error Handling**: Standardized error types with proper HTTP status codes
36
+ - **Event System**: Integration lifecycle events and user actions
37
37
 
38
38
  ## Architecture Principles
39
39
 
@@ -196,22 +196,25 @@ packages/core/
196
196
  **Purpose**: Foundation for building integrations between external systems.
197
197
 
198
198
  **Key Files**:
199
- - `integration-base.js` - Base class all integrations extend
200
- - `integration.js` - Integration domain aggregate using Proxy pattern
201
- - `options.js` - Integration configuration and options
199
+
200
+ - `integration-base.js` - Base class all integrations extend
201
+ - `integration.js` - Integration domain aggregate using Proxy pattern
202
+ - `options.js` - Integration configuration and options
202
203
 
203
204
  **Use Cases**:
204
- - `create-integration.js` - Create new integration instance
205
- - `update-integration.js` - Update integration configuration
206
- - `delete-integration-for-user.js` - Remove integration
207
- - `get-integration-instance.js` - Load integration with modules
208
- - `load-integration-context.js` - Full integration context loading
205
+
206
+ - `create-integration.js` - Create new integration instance
207
+ - `update-integration.js` - Update integration configuration
208
+ - `delete-integration-for-user.js` - Remove integration
209
+ - `get-integration-instance.js` - Load integration with modules
210
+ - `load-integration-context.js` - Full integration context loading
209
211
 
210
212
  **Repositories**:
211
- - `integration-repository-factory.js` - Creates database-specific repositories
212
- - `integration-repository-mongo.js` - MongoDB implementation
213
- - `integration-repository-postgres.js` - PostgreSQL implementation
214
- - `integration-mapping-repository-*.js` - Mapping data persistence
213
+
214
+ - `integration-repository-factory.js` - Creates database-specific repositories
215
+ - `integration-repository-mongo.js` - MongoDB implementation
216
+ - `integration-repository-postgres.js` - PostgreSQL implementation
217
+ - `integration-mapping-repository-*.js` - Mapping data persistence
215
218
 
216
219
  **Integration developers extend IntegrationBase**:
217
220
 
@@ -224,8 +227,8 @@ class MyIntegration extends IntegrationBase {
224
227
  version: '1.0.0',
225
228
  modules: {
226
229
  serviceA: 'service-a',
227
- serviceB: 'service-b'
228
- }
230
+ serviceB: 'service-b',
231
+ },
229
232
  };
230
233
 
231
234
  async onCreate({ integrationId }) {
@@ -240,52 +243,60 @@ class MyIntegration extends IntegrationBase {
240
243
  **Purpose**: Multi-database support with transparent encryption.
241
244
 
242
245
  **Key Components**:
243
- - `prisma.js` - Prisma client initialization with encryption extension
244
- - `mongo.js` - Mongoose connection management (legacy)
245
- - `models/` - Mongoose model definitions
246
+
247
+ - `prisma.js` - Prisma client initialization with encryption extension
248
+ - `mongo.js` - Mongoose connection management (legacy)
249
+ - `models/` - Mongoose model definitions
246
250
 
247
251
  **Encryption System** (`/database/encryption`):
248
- - **Transparent encryption**: Application code never sees encrypted data
249
- - **Database-agnostic**: Works with MongoDB and PostgreSQL
250
- - **AWS KMS or AES**: Production KMS, development AES
251
- - **Configurable**: Via environment variables and app definition
252
+
253
+ - **Transparent encryption**: Application code never sees encrypted data
254
+ - **Database-agnostic**: Works with MongoDB and PostgreSQL
255
+ - **AWS KMS or AES**: Production KMS, development AES
256
+ - **Configurable**: Via environment variables and app definition
252
257
 
253
258
  **See**: `database/encryption/README.md` for comprehensive documentation
254
259
 
255
260
  **Repositories**:
256
- - `health-check-repository.js` - Database health monitoring
257
- - `token-repository.js` - Authentication tokens
258
- - `websocket-connection-repository.js` - WebSocket connections
259
- - DocumentDB-enabled adapters mirror the MongoDB APIs but execute raw commands (`$runCommandRaw`, `$aggregateRaw`) for compatibility; encrypted models (e.g., credentials) still delegate reads to Prisma so the encryption extension can decrypt secrets transparently.
261
+
262
+ - `health-check-repository.js` - Database health monitoring
263
+ - `token-repository.js` - Authentication tokens
264
+ - `websocket-connection-repository.js` - WebSocket connections
265
+ - DocumentDB-enabled adapters mirror the MongoDB APIs but execute raw commands (`$runCommandRaw`, `$aggregateRaw`) for compatibility; encrypted models (e.g., credentials) still delegate reads to Prisma so the encryption extension can decrypt secrets transparently.
260
266
 
261
267
  **Use Cases**:
262
- - `check-database-health-use-case.js` - Database health checks
263
- - `test-encryption-use-case.js` - Encryption verification
268
+
269
+ - `check-database-health-use-case.js` - Database health checks
270
+ - `test-encryption-use-case.js` - Encryption verification
264
271
 
265
272
  ### 3. User Management (`/user`)
266
273
 
267
274
  **Purpose**: Individual and organizational user authentication.
268
275
 
269
276
  **User Types**:
270
- - **Individual Users**: Personal accounts with email/password
271
- - **Organization Users**: Business accounts with organization-level access
272
- - **Hybrid**: Support both simultaneously
277
+
278
+ - **Individual Users**: Personal accounts with email/password
279
+ - **Organization Users**: Business accounts with organization-level access
280
+ - **Hybrid**: Support both simultaneously
273
281
 
274
282
  **Authentication Methods**:
275
- - Password-based (bcrypt hashed)
276
- - Token-based (Bearer tokens)
277
- - App-based (external app user IDs)
283
+
284
+ - Password-based (bcrypt hashed)
285
+ - Token-based (Bearer tokens)
286
+ - App-based (external app user IDs)
278
287
 
279
288
  **Use Cases**:
280
- - `login-user.js` - User authentication
281
- - `create-individual-user.js` - Create personal account
282
- - `create-organization-user.js` - Create business account
283
- - `get-user-from-bearer-token.js` - Token authentication
289
+
290
+ - `login-user.js` - User authentication
291
+ - `create-individual-user.js` - Create personal account
292
+ - `create-organization-user.js` - Create business account
293
+ - `get-user-from-bearer-token.js` - Token authentication
284
294
 
285
295
  **Repositories**:
286
- - `user-repository-factory.js` - Creates database-specific repositories
287
- - `user-repository-mongo.js` - MongoDB implementation
288
- - `user-repository-postgres.js` - PostgreSQL implementation
296
+
297
+ - `user-repository-factory.js` - Creates database-specific repositories
298
+ - `user-repository-mongo.js` - MongoDB implementation
299
+ - `user-repository-postgres.js` - PostgreSQL implementation
289
300
 
290
301
  **Configuration** (in app definition):
291
302
 
@@ -305,21 +316,24 @@ class MyIntegration extends IntegrationBase {
305
316
  **Purpose**: API module loading, credential management, and HTTP clients.
306
317
 
307
318
  **Key Classes**:
308
- - `Credential` - API credentials domain entity
309
- - `Entity` - External service entity (account, workspace, etc.)
310
- - `Requester` - Base HTTP client class
311
- - `OAuth2Requester` - OAuth 2.0 flow implementation
312
- - `ApiKeyRequester` - API key authentication
313
- - `BasicAuthRequester` - Basic authentication
319
+
320
+ - `Credential` - API credentials domain entity
321
+ - `Entity` - External service entity (account, workspace, etc.)
322
+ - `Requester` - Base HTTP client class
323
+ - `OAuth2Requester` - OAuth 2.0 flow implementation
324
+ - `ApiKeyRequester` - API key authentication
325
+ - `BasicAuthRequester` - Basic authentication
314
326
 
315
327
  **Module Factory**:
316
- - `ModuleFactory` - Creates and configures API module instances
317
- - Handles credential injection
318
- - Manages module lifecycle
328
+
329
+ - `ModuleFactory` - Creates and configures API module instances
330
+ - Handles credential injection
331
+ - Manages module lifecycle
319
332
 
320
333
  **Repositories**:
321
- - `module-repository.js` - Module data access
322
- - `credential-repository.js` - Credential persistence (encrypted)
334
+
335
+ - `module-repository.js` - Module data access
336
+ - `credential-repository.js` - Credential persistence (encrypted)
323
337
 
324
338
  ### 5. Core Runtime System (`/core`)
325
339
 
@@ -328,10 +342,11 @@ class MyIntegration extends IntegrationBase {
328
342
  **See**: `core/CLAUDE.md` for comprehensive documentation
329
343
 
330
344
  **Key Components**:
331
- - `create-handler.js` - Lambda handler factory
332
- - `Worker.js` - SQS job processing base class
333
- - `Delegate.js` - Observer/delegation pattern
334
- - `load-installed-modules.js` - Dynamic module loading
345
+
346
+ - `create-handler.js` - Lambda handler factory
347
+ - `Worker.js` - SQS job processing base class
348
+ - `Delegate.js` - Observer/delegation pattern
349
+ - `load-installed-modules.js` - Dynamic module loading
335
350
 
336
351
  **Handler Pattern**:
337
352
 
@@ -340,12 +355,12 @@ const { createHandler } = require('@friggframework/core');
340
355
 
341
356
  const handler = createHandler({
342
357
  eventName: 'MyIntegration',
343
- isUserFacingResponse: true, // Sanitize errors
344
- shouldUseDatabase: true, // Connect to DB
358
+ isUserFacingResponse: true, // Sanitize errors
359
+ shouldUseDatabase: true, // Connect to DB
345
360
  method: async (event, context) => {
346
361
  // Your logic here
347
362
  return { statusCode: 200, body: 'Success' };
348
- }
363
+ },
349
364
  });
350
365
  ```
351
366
 
@@ -370,10 +385,11 @@ class MyWorker extends Worker {
370
385
  **Purpose**: Cryptor adapter for AWS KMS and AES encryption.
371
386
 
372
387
  **Key Class**: `Cryptor.js`
373
- - Envelope encryption pattern
374
- - AWS KMS integration
375
- - AES-256-GCM fallback
376
- - Key rotation support
388
+
389
+ - Envelope encryption pattern
390
+ - AWS KMS integration
391
+ - AES-256-GCM fallback
392
+ - Key rotation support
377
393
 
378
394
  **Usage**:
379
395
 
@@ -381,7 +397,7 @@ class MyWorker extends Worker {
381
397
  const { Cryptor } = require('@friggframework/core');
382
398
 
383
399
  const cryptor = new Cryptor({
384
- shouldUseAws: process.env.KMS_KEY_ARN ? true : false
400
+ shouldUseAws: process.env.KMS_KEY_ARN ? true : false,
385
401
  });
386
402
 
387
403
  const encrypted = await cryptor.encrypt('sensitive-data');
@@ -393,29 +409,33 @@ const decrypted = await cryptor.decrypt(encrypted);
393
409
  **Purpose**: HTTP/Lambda request handling and routing.
394
410
 
395
411
  **Key Routers**:
396
- - `integration-router.js` - Integration CRUD operations
397
- - `auth.js` - Authentication endpoints
398
- - `health.js` - Health check endpoints with encryption verification
412
+
413
+ - `integration-router.js` - Integration CRUD operations
414
+ - `auth.js` - Authentication endpoints
415
+ - `health.js` - Health check endpoints with encryption verification
399
416
 
400
417
  **Handler Types**:
401
- - **User-facing**: Sanitize errors, friendly responses
402
- - **Server-to-server**: Full error details for debugging
403
- - **Background workers**: SQS message processing
418
+
419
+ - **User-facing**: Sanitize errors, friendly responses
420
+ - **Server-to-server**: Full error details for debugging
421
+ - **Background workers**: SQS message processing
404
422
 
405
423
  **Event Dispatcher**:
406
- - `integration-event-dispatcher.js` - Routes events to integration handlers
407
- - Supports lifecycle events and user actions
424
+
425
+ - `integration-event-dispatcher.js` - Routes events to integration handlers
426
+ - Supports lifecycle events and user actions
408
427
 
409
428
  ### 8. Error Handling (`/errors`)
410
429
 
411
430
  **Purpose**: Standardized error types with proper HTTP semantics.
412
431
 
413
432
  **Error Types**:
414
- - `BaseError` - Base error class
415
- - `FetchError` - HTTP request failures
416
- - `HaltError` - Stop processing without retry
417
- - `RequiredPropertyError` - Missing required parameters
418
- - `ParameterTypeError` - Invalid parameter type
433
+
434
+ - `BaseError` - Base error class
435
+ - `FetchError` - HTTP request failures
436
+ - `HaltError` - Stop processing without retry
437
+ - `RequiredPropertyError` - Missing required parameters
438
+ - `ParameterTypeError` - Invalid parameter type
419
439
 
420
440
  **Usage**:
421
441
 
@@ -432,9 +452,10 @@ if (!userId) {
432
452
  **Purpose**: Structured logging with debug capabilities.
433
453
 
434
454
  **Functions**:
435
- - `debug(message, data)` - Debug logging
436
- - `initDebugLog(eventName, event)` - Initialize debug context
437
- - `flushDebugLog(error)` - Flush logs on error
455
+
456
+ - `debug(message, data)` - Debug logging
457
+ - `initDebugLog(eventName, event)` - Initialize debug context
458
+ - `flushDebugLog(error)` - Flush logs on error
438
459
 
439
460
  **Usage**:
440
461
 
@@ -452,8 +473,9 @@ flushDebugLog(); // On error
452
473
  **Purpose**: AWS Lambda-specific utilities.
453
474
 
454
475
  **Key Classes**:
455
- - `TimeoutCatcher` - Detect approaching Lambda timeout
456
- - Graceful shutdown handling
476
+
477
+ - `TimeoutCatcher` - Detect approaching Lambda timeout
478
+ - Graceful shutdown handling
457
479
 
458
480
  **Usage**:
459
481
 
@@ -511,10 +533,10 @@ const appDefinition = {
511
533
  encryption: {
512
534
  schema: {
513
535
  MyCustomModel: {
514
- fields: ['secretData', 'data.apiKey']
515
- }
516
- }
517
- }
536
+ fields: ['secretData', 'data.apiKey'],
537
+ },
538
+ },
539
+ },
518
540
  };
519
541
  ```
520
542
 
@@ -525,8 +547,8 @@ Edit `database/encryption/encryption-schema-registry.js`:
525
547
  ```javascript
526
548
  const ENCRYPTION_SCHEMA = {
527
549
  MyModel: {
528
- fields: ['sensitiveField']
529
- }
550
+ fields: ['sensitiveField'],
551
+ },
530
552
  };
531
553
  ```
532
554
 
@@ -571,7 +593,7 @@ describe('MyUseCase', () => {
571
593
  beforeEach(() => {
572
594
  mockRepository = {
573
595
  findById: jest.fn(),
574
- save: jest.fn()
596
+ save: jest.fn(),
575
597
  };
576
598
  useCase = new MyUseCase({ repository: mockRepository });
577
599
  });
@@ -638,35 +660,35 @@ Use test doubles from `@friggframework/test` package for consistent mocking.
638
660
 
639
661
  ### Required
640
662
 
641
- - `AWS_REGION` - AWS region for services
642
- - `DATABASE_URL` - Database connection string (auto-set)
643
- - `DB_TYPE` - Database type: 'mongodb' or 'postgresql'
663
+ - `AWS_REGION` - AWS region for services
664
+ - `DATABASE_URL` - Database connection string (auto-set)
665
+ - `DB_TYPE` - Database type: 'mongodb' or 'postgresql'
644
666
 
645
667
  ### Encryption
646
668
 
647
- - `KMS_KEY_ARN` - AWS KMS key ARN (production)
648
- - `AES_KEY_ID` - AES key ID (development)
649
- - `AES_KEY` - AES encryption key (development)
650
- - `STAGE` - Environment stage (dev, test, local bypass encryption)
669
+ - `KMS_KEY_ARN` - AWS KMS key ARN (production)
670
+ - `AES_KEY_ID` - AES key ID (development)
671
+ - `AES_KEY` - AES encryption key (development)
672
+ - `STAGE` - Environment stage (dev, test, local bypass encryption)
651
673
 
652
674
  ### Optional
653
675
 
654
- - `SECRET_ARN` - AWS Secrets Manager ARN for auto-injection
655
- - `DEBUG` - Debug logging pattern
656
- - `LOG_LEVEL` - Logging level (debug, info, warn, error)
676
+ - `SECRET_ARN` - AWS Secrets Manager ARN for auto-injection
677
+ - `DEBUG` - Debug logging pattern
678
+ - `LOG_LEVEL` - Logging level (debug, info, warn, error)
657
679
 
658
680
  ## Version Information
659
681
 
660
- - **Current Version**: 2.0.0-next.0 (pre-release)
661
- - **Node.js**: >=18 required
662
- - **Dependencies**: See package.json for full list
682
+ - **Current Version**: 2.0.0-next.0 (pre-release)
683
+ - **Node.js**: >=18 required
684
+ - **Dependencies**: See package.json for full list
663
685
 
664
686
  ## Support and Documentation
665
687
 
666
- - **Main Framework CLAUDE.md**: See root Frigg CLAUDE.md for framework-wide guidance
667
- - **Core Runtime**: See `core/CLAUDE.md` for Lambda/Worker patterns
668
- - **Encryption**: See `database/encryption/README.md` for encryption details
669
- - **Package README**: See `README.md` for API reference
688
+ - **Main Framework CLAUDE.md**: See root Frigg CLAUDE.md for framework-wide guidance
689
+ - **Core Runtime**: See `core/CLAUDE.md` for Lambda/Worker patterns
690
+ - **Encryption**: See `database/encryption/README.md` for encryption details
691
+ - **Package README**: See `README.md` for API reference
670
692
 
671
693
  ## Recent Important Changes
672
694
 
@@ -677,13 +699,15 @@ Use test doubles from `@friggframework/test` package for consistent mocking.
677
699
  **Problem**: The `FieldEncryptionService` was converting objects to the string `"[object Object]"` before encrypting, corrupting JSON fields like `IntegrationMapping.mapping`.
678
700
 
679
701
  **Solution**: Added `_serializeForEncryption()` and `_deserializeAfterDecryption()` methods:
680
- - Objects are now JSON.stringify'd before encryption
681
- - Decrypted strings are JSON.parse'd back to objects
682
- - Plain strings work as before
702
+
703
+ - Objects are now JSON.stringify'd before encryption
704
+ - Decrypted strings are JSON.parse'd back to objects
705
+ - Plain strings work as before
683
706
 
684
707
  **Files Changed**:
685
- - `database/encryption/field-encryption-service.js`
686
- - `database/encryption/field-encryption-service.test.js`
708
+
709
+ - `database/encryption/field-encryption-service.js`
710
+ - `database/encryption/field-encryption-service.test.js`
687
711
 
688
712
  **Test Coverage**: All 40 tests pass, including new object encryption test.
689
713