@friggframework/core 2.0.0--canary.545.ccb5010.0 → 2.0.0--canary.549.b074651.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/CHANGELOG.md +67 -66
- package/CLAUDE.md +124 -148
- package/README.md +130 -165
- package/assertions/jest.config.ts +7 -0
- package/core/CLAUDE.md +156 -222
- package/database/MONGODB_TRANSACTION_FIX.md +52 -72
- package/database/encryption/README.md +36 -53
- package/database/jest.config.ts +7 -0
- package/database/models/WorkflowExecutionModel.ts +315 -0
- package/database/models/WorkflowModel.ts +129 -0
- package/docs/PROCESS_MANAGEMENT_QUEUE_SPEC.md +80 -135
- package/generated/prisma-mongodb/edge.js +5 -60
- package/generated/prisma-mongodb/index-browser.js +1 -49
- package/generated/prisma-mongodb/index.d.ts +57 -4019
- package/generated/prisma-mongodb/index.js +11 -66
- package/generated/prisma-mongodb/package.json +1 -1
- package/generated/prisma-mongodb/{libquery_engine-debian-openssl-3.0.x.so.node → query-engine-debian-openssl-3.0.x} +0 -0
- package/generated/prisma-mongodb/{libquery_engine-rhel-openssl-3.0.x.so.node → query-engine-rhel-openssl-3.0.x} +0 -0
- package/generated/prisma-mongodb/runtime/binary.d.ts +1 -0
- package/generated/prisma-mongodb/runtime/binary.js +289 -0
- package/generated/prisma-mongodb/schema.prisma +2 -89
- package/generated/prisma-mongodb/wasm.js +5 -60
- package/generated/prisma-postgresql/edge.js +5 -59
- package/generated/prisma-postgresql/index-browser.js +1 -48
- package/generated/prisma-postgresql/index.d.ts +44 -4732
- package/generated/prisma-postgresql/index.js +11 -65
- package/generated/prisma-postgresql/package.json +1 -1
- package/generated/prisma-postgresql/{libquery_engine-debian-openssl-3.0.x.so.node → query-engine-debian-openssl-3.0.x} +0 -0
- package/generated/prisma-postgresql/{libquery_engine-rhel-openssl-3.0.x.so.node → query-engine-rhel-openssl-3.0.x} +0 -0
- package/generated/prisma-postgresql/runtime/binary.d.ts +1 -0
- package/generated/prisma-postgresql/runtime/binary.js +289 -0
- package/generated/prisma-postgresql/schema.prisma +2 -87
- package/generated/prisma-postgresql/wasm.js +5 -59
- package/handlers/WEBHOOKS.md +81 -104
- package/handlers/routers/HEALTHCHECK.md +135 -170
- package/integrations/WEBHOOK-QUICKSTART.md +14 -21
- package/jest-global-setup-noop.ts +3 -0
- package/jest-global-teardown-noop.ts +3 -0
- package/jest-resolver.ts +36 -0
- package/jest-setup.ts +1 -0
- package/jest-teardown.ts +1 -0
- package/jest.config.ts +20 -0
- package/package.json +32 -8
- package/prisma-mongodb/schema.prisma +2 -89
- package/prisma-postgresql/schema.prisma +2 -87
- package/src/application/commands/command-utils.ts +17 -0
- package/src/application/commands/credential-commands.ts +214 -0
- package/src/application/commands/entity-commands.ts +253 -0
- package/src/application/commands/integration-commands.test.ts +158 -0
- package/src/application/commands/integration-commands.ts +205 -0
- package/{application/commands/scheduler-commands.js → src/application/commands/scheduler-commands.ts} +82 -104
- package/{application/commands/user-commands.js → src/application/commands/user-commands.ts} +73 -97
- package/src/application/index.ts +82 -0
- package/src/assertions/get.ts +196 -0
- package/src/assertions/index.ts +9 -0
- package/src/associations/association.ts +103 -0
- package/src/associations/index.ts +3 -0
- package/src/core/Delegate.ts +41 -0
- package/src/core/Worker.test.ts +158 -0
- package/src/core/Worker.ts +86 -0
- package/{core/create-handler.js → src/core/create-handler.ts} +42 -15
- package/src/core/index.ts +15 -0
- package/src/core/load-installed-modules.ts +31 -0
- package/{core/secrets-to-env.js → src/core/secrets-to-env.ts} +14 -14
- package/src/credential/index.ts +9 -0
- package/src/credential/repositories/credential-repository-documentdb.ts +185 -0
- package/src/credential/repositories/credential-repository-factory.ts +26 -0
- package/src/credential/repositories/credential-repository-interface.ts +62 -0
- package/src/credential/repositories/credential-repository-mongo.ts +163 -0
- package/src/credential/repositories/credential-repository-postgres.ts +169 -0
- package/src/credential/repositories/credential-repository.ts +162 -0
- package/src/credential/use-cases/get-credential-for-user.ts +27 -0
- package/src/credential/use-cases/update-authentication-status.ts +17 -0
- package/src/database/adapters/index.ts +1 -0
- package/src/database/adapters/lambda-invoker.test.ts +104 -0
- package/src/database/adapters/lambda-invoker.ts +61 -0
- package/src/database/config.ts +142 -0
- package/src/database/documentdb-encryption-service.ts +191 -0
- package/src/database/documentdb-utils.ts +160 -0
- package/src/database/encryption/encryption-schema-registry.test.ts +397 -0
- package/src/database/encryption/encryption-schema-registry.ts +243 -0
- package/src/database/encryption/field-encryption-service.test.ts +511 -0
- package/{database/encryption/field-encryption-service.js → src/database/encryption/field-encryption-service.ts} +46 -67
- package/src/database/encryption/index.ts +24 -0
- package/{database/encryption/logger.js → src/database/encryption/logger.ts} +19 -21
- package/src/database/encryption/mongo-decryption-fix-verification.test.ts +337 -0
- package/src/database/encryption/postgres-decryption-fix-verification.test.ts +335 -0
- package/src/database/encryption/postgres-relation-decryption.test.ts +205 -0
- package/src/database/encryption/prisma-encryption-extension.test.ts +433 -0
- package/{database/encryption/prisma-encryption-extension.js → src/database/encryption/prisma-encryption-extension.ts} +58 -77
- package/src/database/index.ts +126 -0
- package/src/database/prisma.test.ts +65 -0
- package/src/database/prisma.ts +166 -0
- package/{database/repositories/health-check-repository-documentdb.js → src/database/repositories/health-check-repository-documentdb.ts} +34 -45
- package/src/database/repositories/health-check-repository-factory.ts +38 -0
- package/src/database/repositories/health-check-repository-interface.ts +20 -0
- package/src/database/repositories/health-check-repository-mongodb.test.ts +178 -0
- package/src/database/repositories/health-check-repository-mongodb.ts +79 -0
- package/src/database/repositories/health-check-repository-postgres.test.ts +94 -0
- package/src/database/repositories/health-check-repository-postgres.ts +70 -0
- package/src/database/repositories/index.ts +10 -0
- package/src/database/repositories/migration-status-repository-s3.test.ts +150 -0
- package/src/database/repositories/migration-status-repository-s3.ts +127 -0
- package/src/database/use-cases/check-database-health-use-case.test.ts +131 -0
- package/src/database/use-cases/check-database-health-use-case.ts +30 -0
- package/src/database/use-cases/check-database-state-use-case.test.ts +131 -0
- package/src/database/use-cases/check-database-state-use-case.ts +66 -0
- package/src/database/use-cases/check-encryption-health-use-case.test.ts +183 -0
- package/{database/use-cases/check-encryption-health-use-case.js → src/database/use-cases/check-encryption-health-use-case.ts} +38 -15
- package/src/database/use-cases/get-database-state-via-worker-use-case.test.ts +126 -0
- package/src/database/use-cases/get-database-state-via-worker-use-case.ts +31 -0
- package/src/database/use-cases/get-migration-status-use-case.test.ts +160 -0
- package/src/database/use-cases/get-migration-status-use-case.ts +57 -0
- package/src/database/use-cases/index.ts +14 -0
- package/src/database/use-cases/run-database-migration-use-case.test.ts +350 -0
- package/src/database/use-cases/run-database-migration-use-case.ts +113 -0
- package/src/database/use-cases/test-encryption-use-case.ts +197 -0
- package/src/database/use-cases/trigger-database-migration-use-case.test.ts +256 -0
- package/src/database/use-cases/trigger-database-migration-use-case.ts +131 -0
- package/src/database/utils/index.ts +26 -0
- package/src/database/utils/mongodb-collection-utils.test.ts +133 -0
- package/src/database/utils/mongodb-collection-utils.ts +45 -0
- package/src/database/utils/mongodb-schema-init.test.ts +152 -0
- package/src/database/utils/mongodb-schema-init.ts +51 -0
- package/src/database/utils/prisma-runner.test.ts +513 -0
- package/src/database/utils/prisma-runner.ts +336 -0
- package/src/database/utils/prisma-schema-parser.test.ts +283 -0
- package/src/database/utils/prisma-schema-parser.ts +90 -0
- package/src/declarations.d.ts +141 -0
- package/src/encrypt/Cryptor.test.ts +137 -0
- package/src/encrypt/Cryptor.ts +92 -0
- package/{encrypt/aes.js → src/encrypt/aes.ts} +4 -9
- package/src/encrypt/index.ts +2 -0
- package/src/errors/base-error.test.ts +32 -0
- package/src/errors/base-error.ts +15 -0
- package/src/errors/client-safe-error.ts +12 -0
- package/src/errors/fetch-error.test.ts +105 -0
- package/{errors/fetch-error.js → src/errors/fetch-error.ts} +36 -17
- package/src/errors/halt-error.test.ts +11 -0
- package/src/errors/halt-error.ts +10 -0
- package/src/errors/index.ts +9 -0
- package/src/errors/validation-errors.test.ts +122 -0
- package/src/errors/validation-errors.ts +33 -0
- package/src/handlers/app-definition-loader.ts +52 -0
- package/src/handlers/app-handler-helpers.ts +62 -0
- package/src/handlers/auth-flow.integration.test.ts +149 -0
- package/{handlers/backend-utils.js → src/handlers/backend-utils.ts} +55 -52
- package/src/handlers/database-migration-handler.ts +172 -0
- package/src/handlers/index.ts +22 -0
- package/src/handlers/integration-event-dispatcher.test.ts +211 -0
- package/{handlers/integration-event-dispatcher.js → src/handlers/integration-event-dispatcher.ts} +33 -9
- package/src/handlers/routers/auth.ts +20 -0
- package/src/handlers/routers/db-migration.handler.ts +28 -0
- package/src/handlers/routers/db-migration.test.ts +69 -0
- package/src/handlers/routers/db-migration.ts +173 -0
- package/src/handlers/routers/health.test.ts +251 -0
- package/src/handlers/routers/health.ts +390 -0
- package/src/handlers/routers/index.ts +8 -0
- package/src/handlers/routers/integration-defined-routers.ts +50 -0
- package/src/handlers/routers/integration-webhook-routers.test.ts +116 -0
- package/src/handlers/routers/integration-webhook-routers.ts +72 -0
- package/src/handlers/routers/user.ts +63 -0
- package/{handlers/routers/websocket.js → src/handlers/routers/websocket.ts} +25 -28
- package/{handlers/use-cases/check-external-apis-health-use-case.js → src/handlers/use-cases/check-external-apis-health-use-case.ts} +31 -12
- package/src/handlers/use-cases/check-integrations-health-use-case.test.ts +124 -0
- package/src/handlers/use-cases/check-integrations-health-use-case.ts +69 -0
- package/src/handlers/use-cases/index.ts +9 -0
- package/src/handlers/webhook-flow.integration.test.ts +318 -0
- package/src/handlers/workers/db-migration.test.ts +168 -0
- package/src/handlers/workers/db-migration.ts +173 -0
- package/src/handlers/workers/index.ts +3 -0
- package/src/handlers/workers/integration-defined-workers.test.ts +254 -0
- package/src/handlers/workers/integration-defined-workers.ts +35 -0
- package/src/index.ts +400 -0
- package/src/infrastructure/index.ts +14 -0
- package/src/infrastructure/scheduler/eventbridge-scheduler-adapter.ts +148 -0
- package/src/infrastructure/scheduler/index.ts +19 -0
- package/{infrastructure/scheduler/mock-scheduler-adapter.js → src/infrastructure/scheduler/mock-scheduler-adapter.ts} +25 -59
- package/src/infrastructure/scheduler/scheduler-service-factory.ts +50 -0
- package/src/infrastructure/scheduler/scheduler-service-interface.ts +31 -0
- package/src/integrations/index.ts +79 -0
- package/src/integrations/integration-base.module-keys.test.ts +204 -0
- package/{integrations/integration-base.js → src/integrations/integration-base.ts} +161 -169
- package/src/integrations/integration-router.ts +645 -0
- package/src/integrations/options.ts +57 -0
- package/{integrations/repositories/integration-mapping-repository-documentdb.js → src/integrations/repositories/integration-mapping-repository-documentdb.ts} +54 -134
- package/src/integrations/repositories/integration-mapping-repository-factory.ts +27 -0
- package/src/integrations/repositories/integration-mapping-repository-interface.ts +56 -0
- package/src/integrations/repositories/integration-mapping-repository-mongo.ts +89 -0
- package/src/integrations/repositories/integration-mapping-repository-postgres.ts +129 -0
- package/src/integrations/repositories/integration-mapping-repository.ts +71 -0
- package/{integrations/repositories/integration-repository-documentdb.js → src/integrations/repositories/integration-repository-documentdb.ts} +51 -89
- package/src/integrations/repositories/integration-repository-factory.ts +27 -0
- package/src/integrations/repositories/integration-repository-interface.ts +52 -0
- package/src/integrations/repositories/integration-repository-mongo.ts +186 -0
- package/src/integrations/repositories/integration-repository-postgres.ts +227 -0
- package/{integrations/repositories/process-repository-documentdb.js → src/integrations/repositories/process-repository-documentdb.ts} +57 -124
- package/src/integrations/repositories/process-repository-factory.ts +27 -0
- package/src/integrations/repositories/process-repository-interface.ts +34 -0
- package/src/integrations/repositories/process-repository-mongo.ts +102 -0
- package/src/integrations/repositories/process-repository-postgres.ts +123 -0
- package/{integrations/tests/doubles/config-capturing-integration.js → src/integrations/tests/doubles/config-capturing-integration.ts} +21 -22
- package/src/integrations/tests/doubles/dummy-integration-class.ts +109 -0
- package/src/integrations/tests/doubles/test-integration-repository.ts +100 -0
- package/src/integrations/tests/integration-router-multi-auth.test.ts +531 -0
- package/src/integrations/tests/use-cases/create-integration.test.ts +131 -0
- package/src/integrations/tests/use-cases/delete-integration-for-user.test.ts +150 -0
- package/src/integrations/tests/use-cases/find-integration-context-by-external-entity-id.test.ts +92 -0
- package/src/integrations/tests/use-cases/get-integration-for-user.test.ts +150 -0
- package/src/integrations/tests/use-cases/get-integration-instance.test.ts +176 -0
- package/src/integrations/tests/use-cases/get-integrations-for-user.test.ts +176 -0
- package/src/integrations/tests/use-cases/get-possible-integrations.test.ts +188 -0
- package/src/integrations/tests/use-cases/update-integration-messages.test.ts +142 -0
- package/src/integrations/tests/use-cases/update-integration-status.test.ts +103 -0
- package/src/integrations/tests/use-cases/update-integration.test.ts +208 -0
- package/src/integrations/types.ts +195 -0
- package/src/integrations/use-cases/create-integration.ts +70 -0
- package/src/integrations/use-cases/create-process.test.ts +172 -0
- package/src/integrations/use-cases/create-process.ts +77 -0
- package/src/integrations/use-cases/delete-integration-for-user.ts +87 -0
- package/src/integrations/use-cases/find-integration-context-by-external-entity-id.ts +92 -0
- package/src/integrations/use-cases/get-integration-for-user.ts +74 -0
- package/src/integrations/use-cases/get-integration-instance-by-definition.ts +69 -0
- package/{integrations/use-cases/get-integration-instance.js → src/integrations/use-cases/get-integration-instance.ts} +20 -31
- package/src/integrations/use-cases/get-integrations-for-user.ts +75 -0
- package/src/integrations/use-cases/get-possible-integrations.ts +15 -0
- package/src/integrations/use-cases/get-process.test.ts +181 -0
- package/src/integrations/use-cases/get-process.ts +49 -0
- package/src/integrations/use-cases/index.ts +16 -0
- package/src/integrations/use-cases/load-integration-context-full.test.ts +316 -0
- package/src/integrations/use-cases/load-integration-context.test.ts +115 -0
- package/{integrations/use-cases/load-integration-context.js → src/integrations/use-cases/load-integration-context.ts} +34 -14
- package/src/integrations/use-cases/update-integration-messages.ts +26 -0
- package/src/integrations/use-cases/update-integration-status.ts +17 -0
- package/src/integrations/use-cases/update-integration.ts +76 -0
- package/src/integrations/use-cases/update-process-metrics.test.ts +278 -0
- package/src/integrations/use-cases/update-process-metrics.ts +128 -0
- package/src/integrations/use-cases/update-process-state.test.ts +249 -0
- package/src/integrations/use-cases/update-process-state.ts +73 -0
- package/src/integrations/utils/map-integration-dto.ts +55 -0
- package/src/lambda/TimeoutCatcher.test.ts +69 -0
- package/src/lambda/TimeoutCatcher.ts +57 -0
- package/src/lambda/index.ts +2 -0
- package/src/logs/index.ts +2 -0
- package/src/logs/logger.test.ts +76 -0
- package/{logs/logger.js → src/logs/logger.ts} +15 -10
- package/src/modules/ModuleConstants.ts +11 -0
- package/src/modules/index.ts +38 -0
- package/{modules/module-factory.js → src/modules/module-factory.ts} +16 -20
- package/src/modules/module-hydration.test.ts +203 -0
- package/src/modules/module.ts +283 -0
- package/src/modules/repositories/module-repository-documentdb.ts +303 -0
- package/src/modules/repositories/module-repository-factory.ts +29 -0
- package/src/modules/repositories/module-repository-interface.ts +73 -0
- package/src/modules/repositories/module-repository-mongo.ts +260 -0
- package/src/modules/repositories/module-repository-postgres.ts +293 -0
- package/src/modules/repositories/module-repository.ts +210 -0
- package/src/modules/requester/api-key.ts +58 -0
- package/src/modules/requester/basic.ts +49 -0
- package/src/modules/requester/oauth-2.test.ts +425 -0
- package/src/modules/requester/oauth-2.ts +298 -0
- package/src/modules/requester/requester.test.ts +28 -0
- package/src/modules/requester/requester.ts +212 -0
- package/{modules/test/mock-api/api.js → src/modules/test/mock-api/api.ts} +6 -8
- package/{modules/test/mock-api/definition.js → src/modules/test/mock-api/definition.ts} +15 -21
- package/src/modules/test/mock-api/mocks/hubspot.ts +41 -0
- package/src/modules/tests/doubles/test-module-factory.ts +11 -0
- package/{modules/tests/doubles/test-module-repository.js → src/modules/tests/doubles/test-module-repository.ts} +7 -7
- package/src/modules/tests/module-on-token-update.test.ts +125 -0
- package/src/modules/use-cases/get-entities-for-user.ts +36 -0
- package/src/modules/use-cases/get-entity-options-by-id.ts +64 -0
- package/src/modules/use-cases/get-entity-options-by-type.ts +25 -0
- package/src/modules/use-cases/get-module-instance-from-type.ts +23 -0
- package/src/modules/use-cases/get-module.ts +70 -0
- package/{modules/use-cases/process-authorization-callback.js → src/modules/use-cases/process-authorization-callback.ts} +50 -49
- package/src/modules/use-cases/refresh-entity-options.ts +65 -0
- package/src/modules/use-cases/test-module-auth.ts +64 -0
- package/src/modules/utils/map-module-dto.ts +23 -0
- package/src/queues/index.ts +1 -0
- package/src/queues/queuer-util.test.ts +131 -0
- package/src/queues/queuer-util.ts +59 -0
- package/src/syncs/index.ts +14 -0
- package/{syncs/manager.js → src/syncs/manager.ts} +140 -142
- package/{syncs/repositories/sync-repository-documentdb.js → src/syncs/repositories/sync-repository-documentdb.ts} +46 -67
- package/src/syncs/repositories/sync-repository-factory.ts +30 -0
- package/src/syncs/repositories/sync-repository-interface.ts +68 -0
- package/src/syncs/repositories/sync-repository-mongo.ts +149 -0
- package/src/syncs/repositories/sync-repository-postgres.ts +221 -0
- package/src/syncs/sync.ts +119 -0
- package/src/token/index.ts +7 -0
- package/src/token/repositories/token-repository-documentdb.ts +110 -0
- package/src/token/repositories/token-repository-factory.ts +26 -0
- package/src/token/repositories/token-repository-interface.ts +57 -0
- package/src/token/repositories/token-repository-mongo.ts +81 -0
- package/src/token/repositories/token-repository-postgres.ts +105 -0
- package/src/token/repositories/token-repository.ts +125 -0
- package/src/user/index.ts +17 -0
- package/src/user/repositories/user-repository-documentdb.ts +286 -0
- package/src/user/repositories/user-repository-factory.ts +26 -0
- package/src/user/repositories/user-repository-interface.ts +109 -0
- package/src/user/repositories/user-repository-mongo.ts +130 -0
- package/src/user/repositories/user-repository-postgres.ts +175 -0
- package/{user/tests/doubles/test-user-repository.js → src/user/tests/doubles/test-user-repository.ts} +16 -19
- package/src/user/tests/use-cases/create-individual-user.test.ts +24 -0
- package/src/user/tests/use-cases/create-organization-user.test.ts +28 -0
- package/src/user/tests/use-cases/create-token-for-user-id.test.ts +18 -0
- package/src/user/tests/use-cases/get-user-from-adopter-jwt.test.ts +113 -0
- package/src/user/tests/use-cases/get-user-from-bearer-token.test.ts +64 -0
- package/src/user/tests/use-cases/get-user-from-x-frigg-headers.test.ts +440 -0
- package/src/user/tests/use-cases/login-user.test.ts +220 -0
- package/src/user/use-cases/authenticate-user.ts +98 -0
- package/src/user/use-cases/authenticate-with-shared-secret.test.ts +127 -0
- package/src/user/use-cases/authenticate-with-shared-secret.ts +19 -0
- package/src/user/use-cases/create-individual-user.ts +59 -0
- package/src/user/use-cases/create-organization-user.ts +44 -0
- package/src/user/use-cases/create-token-for-user-id.ts +19 -0
- package/src/user/use-cases/get-user-from-adopter-jwt.ts +40 -0
- package/{user/use-cases/get-user-from-bearer-token.js → src/user/use-cases/get-user-from-bearer-token.ts} +23 -30
- package/src/user/use-cases/get-user-from-x-frigg-headers.ts +119 -0
- package/src/user/use-cases/login-user.ts +110 -0
- package/src/user/user.ts +125 -0
- package/{utils/backend-path.js → src/utils/backend-path.ts} +5 -8
- package/src/utils/index.ts +2 -0
- package/src/websocket/index.ts +7 -0
- package/src/websocket/repositories/websocket-connection-repository-documentdb.ts +93 -0
- package/src/websocket/repositories/websocket-connection-repository-factory.ts +26 -0
- package/src/websocket/repositories/websocket-connection-repository-interface.ts +47 -0
- package/src/websocket/repositories/websocket-connection-repository-mongo.ts +77 -0
- package/src/websocket/repositories/websocket-connection-repository-postgres.ts +94 -0
- package/src/websocket/repositories/websocket-connection-repository.test.ts +220 -0
- package/src/websocket/repositories/websocket-connection-repository.ts +101 -0
- package/tsconfig.json +17 -0
- package/tsconfig.test.json +10 -0
- package/workflows/frigg-workflow.ts +322 -0
- package/workflows/index.ts +205 -0
- package/workflows/steps/fan-out-step.ts +275 -0
- package/workflows/steps/function-step.ts +174 -0
- package/workflows/steps/index.ts +30 -0
- package/workflows/steps/workflow-step.ts +115 -0
- package/workflows/use-cases/create-workflow.ts +332 -0
- package/workflows/use-cases/execute-workflow-step.ts +465 -0
- package/workflows/use-cases/execute-workflow.ts +403 -0
- package/workflows/workflow-execution-repository.ts +415 -0
- package/workflows/workflow-execution.ts +209 -0
- package/workflows/workflow-queue-service.ts +379 -0
- package/workflows/workflow-repository.ts +295 -0
- package/workflows/workflow.ts +117 -0
- package/admin-scripts/index.js +0 -52
- package/admin-scripts/repositories/admin-api-key-repository-documentdb.js +0 -21
- package/admin-scripts/repositories/admin-api-key-repository-factory.js +0 -51
- package/admin-scripts/repositories/admin-api-key-repository-interface.js +0 -121
- package/admin-scripts/repositories/admin-api-key-repository-mongo.js +0 -155
- package/admin-scripts/repositories/admin-api-key-repository-postgres.js +0 -189
- package/admin-scripts/repositories/admin-process-repository-documentdb.js +0 -21
- package/admin-scripts/repositories/admin-process-repository-factory.js +0 -49
- package/admin-scripts/repositories/admin-process-repository-interface.js +0 -150
- package/admin-scripts/repositories/admin-process-repository-mongo.js +0 -213
- package/admin-scripts/repositories/admin-process-repository-postgres.js +0 -251
- package/admin-scripts/repositories/script-execution-repository-documentdb.js +0 -21
- package/admin-scripts/repositories/script-execution-repository-factory.js +0 -51
- package/admin-scripts/repositories/script-execution-repository-interface.js +0 -193
- package/admin-scripts/repositories/script-execution-repository-mongo.js +0 -278
- package/admin-scripts/repositories/script-execution-repository-postgres.js +0 -320
- package/admin-scripts/repositories/script-schedule-repository-documentdb.js +0 -21
- package/admin-scripts/repositories/script-schedule-repository-factory.js +0 -49
- package/admin-scripts/repositories/script-schedule-repository-interface.js +0 -108
- package/admin-scripts/repositories/script-schedule-repository-mongo.js +0 -179
- package/admin-scripts/repositories/script-schedule-repository-postgres.js +0 -210
- package/application/commands/admin-script-commands.js +0 -348
- package/application/commands/credential-commands.js +0 -245
- package/application/commands/entity-commands.js +0 -336
- package/application/commands/integration-commands.js +0 -216
- package/application/index.js +0 -75
- package/assertions/get.js +0 -149
- package/assertions/index.js +0 -16
- package/assertions/jest.config.js +0 -5
- package/associations/association.js +0 -80
- package/core/Delegate.js +0 -29
- package/core/Worker.js +0 -93
- package/core/index.js +0 -6
- package/core/load-installed-modules.js +0 -28
- package/credential/credential-router.js +0 -262
- package/credential/repositories/credential-repository-documentdb.js +0 -374
- package/credential/repositories/credential-repository-factory.js +0 -52
- package/credential/repositories/credential-repository-interface.js +0 -104
- package/credential/repositories/credential-repository-mongo.js +0 -310
- package/credential/repositories/credential-repository-postgres.js +0 -328
- package/credential/repositories/credential-repository.js +0 -302
- package/credential/use-cases/delete-credential-for-user.js +0 -50
- package/credential/use-cases/get-credential-for-user.js +0 -43
- package/credential/use-cases/list-credentials-for-user.js +0 -31
- package/credential/use-cases/reauthorize-credential.js +0 -103
- package/credential/use-cases/update-authentication-status.js +0 -18
- package/database/config.js +0 -108
- package/database/documentdb-encryption-service.js +0 -346
- package/database/documentdb-utils.js +0 -145
- package/database/encryption/encryption-schema-registry.js +0 -314
- package/database/index.js +0 -25
- package/database/jest.config.js +0 -5
- package/database/prisma.js +0 -193
- package/database/repositories/health-check-repository-factory.js +0 -50
- package/database/repositories/health-check-repository-interface.js +0 -92
- package/database/repositories/health-check-repository-mongodb.js +0 -89
- package/database/repositories/health-check-repository-postgres.js +0 -82
- package/database/use-cases/check-database-health-use-case.js +0 -30
- package/database/use-cases/check-database-state-use-case.js +0 -82
- package/database/use-cases/get-database-state-via-worker-use-case.js +0 -64
- package/database/use-cases/get-migration-status-use-case.js +0 -95
- package/database/use-cases/run-database-migration-use-case.js +0 -171
- package/database/use-cases/test-encryption-use-case.js +0 -252
- package/database/use-cases/trigger-database-migration-use-case.js +0 -158
- package/database/utils/mongodb-collection-utils.js +0 -102
- package/database/utils/mongodb-schema-init.js +0 -114
- package/database/utils/prisma-runner.js +0 -547
- package/database/utils/prisma-schema-parser.js +0 -182
- package/encrypt/Cryptor.js +0 -107
- package/encrypt/aes-encryption-key-provider.js +0 -82
- package/encrypt/encryption-key-provider-interface.js +0 -50
- package/encrypt/index.js +0 -3
- package/errors/base-error.js +0 -23
- package/errors/client-safe-error.js +0 -26
- package/errors/halt-error.js +0 -10
- package/errors/index.js +0 -17
- package/errors/validation-errors.js +0 -23
- package/extensions/bootstrap-runner.js +0 -43
- package/extensions/extension-loader.js +0 -167
- package/extensions/index.js +0 -37
- package/extensions/initialize-app.js +0 -123
- package/extensions/route-mounter.js +0 -59
- package/extensions/schema-composer.js +0 -188
- package/generated/prisma-mongodb/runtime/library.js +0 -146
- package/generated/prisma-postgresql/runtime/library.js +0 -146
- package/handlers/app-definition-loader.js +0 -81
- package/handlers/app-handler-helpers.js +0 -68
- package/handlers/database-migration-handler.js +0 -246
- package/handlers/middleware/admin-auth.js +0 -53
- package/handlers/routers/admin.js +0 -474
- package/handlers/routers/auth.js +0 -57
- package/handlers/routers/db-migration.handler.js +0 -28
- package/handlers/routers/db-migration.js +0 -362
- package/handlers/routers/docs.js +0 -180
- package/handlers/routers/health.js +0 -317
- package/handlers/routers/integration-defined-routers.js +0 -56
- package/handlers/routers/integration-webhook-routers.js +0 -88
- package/handlers/routers/middleware/loadUser.js +0 -39
- package/handlers/routers/middleware/requireAdmin.js +0 -43
- package/handlers/routers/middleware/requireLoggedInUser.js +0 -19
- package/handlers/routers/user.js +0 -79
- package/handlers/use-cases/check-integrations-health-use-case.js +0 -51
- package/handlers/workers/db-migration.js +0 -391
- package/handlers/workers/integration-defined-workers.js +0 -38
- package/index.js +0 -220
- package/infrastructure/scheduler/index.js +0 -37
- package/infrastructure/scheduler/netlify-scheduler-adapter.js +0 -185
- package/infrastructure/scheduler/scheduler-service-factory.js +0 -80
- package/infrastructure/scheduler/scheduler-service-interface.js +0 -47
- package/integrations/index.js +0 -25
- package/integrations/integration-router.js +0 -2354
- package/integrations/options.js +0 -80
- package/integrations/repositories/integration-mapping-repository-factory.js +0 -53
- package/integrations/repositories/integration-mapping-repository-interface.js +0 -106
- package/integrations/repositories/integration-mapping-repository-mongo.js +0 -161
- package/integrations/repositories/integration-mapping-repository-postgres.js +0 -227
- package/integrations/repositories/integration-mapping-repository.js +0 -156
- package/integrations/repositories/integration-repository-factory.js +0 -51
- package/integrations/repositories/integration-repository-interface.js +0 -145
- package/integrations/repositories/integration-repository-mongo.js +0 -303
- package/integrations/repositories/integration-repository-postgres.js +0 -352
- package/integrations/repositories/process-repository-factory.js +0 -50
- package/integrations/repositories/process-repository-interface.js +0 -94
- package/integrations/repositories/process-repository-mongo.js +0 -194
- package/integrations/repositories/process-repository-postgres.js +0 -217
- package/integrations/tests/doubles/dummy-integration-class.js +0 -178
- package/integrations/tests/doubles/test-integration-repository.js +0 -139
- package/integrations/use-cases/create-integration.js +0 -87
- package/integrations/use-cases/create-process.js +0 -139
- package/integrations/use-cases/delete-integration-for-user.js +0 -102
- package/integrations/use-cases/execute-proxy-request.js +0 -564
- package/integrations/use-cases/find-integration-context-by-external-entity-id.js +0 -72
- package/integrations/use-cases/get-integration-for-user.js +0 -93
- package/integrations/use-cases/get-integration-instance-by-definition.js +0 -73
- package/integrations/use-cases/get-integrations-for-user.js +0 -91
- package/integrations/use-cases/get-possible-integrations.js +0 -27
- package/integrations/use-cases/get-process.js +0 -86
- package/integrations/use-cases/index.js +0 -21
- package/integrations/use-cases/update-integration-messages.js +0 -44
- package/integrations/use-cases/update-integration-status.js +0 -32
- package/integrations/use-cases/update-integration.js +0 -92
- package/integrations/use-cases/update-process-metrics.js +0 -201
- package/integrations/use-cases/update-process-state.js +0 -121
- package/integrations/utils/map-integration-dto.js +0 -43
- package/jest-global-setup-noop.js +0 -3
- package/jest-global-teardown-noop.js +0 -3
- package/jest-setup.js +0 -2
- package/jest-teardown.js +0 -2
- package/jest.config.js +0 -21
- package/lambda/TimeoutCatcher.js +0 -45
- package/lambda/index.js +0 -3
- package/logs/index.js +0 -7
- package/modules/ModuleConstants.js +0 -10
- package/modules/domain/entities/AuthorizationSession.js +0 -131
- package/modules/domain/entities/index.js +0 -10
- package/modules/index.js +0 -15
- package/modules/module.js +0 -261
- package/modules/repositories/authorization-session-repository-factory.js +0 -53
- package/modules/repositories/authorization-session-repository-interface.js +0 -75
- package/modules/repositories/authorization-session-repository-mongo.js +0 -169
- package/modules/repositories/authorization-session-repository-postgres.js +0 -170
- package/modules/repositories/module-repository-documentdb.js +0 -383
- package/modules/repositories/module-repository-factory.js +0 -38
- package/modules/repositories/module-repository-interface.js +0 -142
- package/modules/repositories/module-repository-mongo.js +0 -443
- package/modules/repositories/module-repository-postgres.js +0 -490
- package/modules/repositories/module-repository.js +0 -373
- package/modules/requester/api-key.js +0 -50
- package/modules/requester/basic.js +0 -42
- package/modules/requester/oauth-2.js +0 -385
- package/modules/requester/requester.js +0 -167
- package/modules/test/mock-api/mocks/hubspot.js +0 -43
- package/modules/tests/doubles/test-module-factory.js +0 -22
- package/modules/use-cases/delete-module-entity.js +0 -23
- package/modules/use-cases/get-authorization-requirements.js +0 -110
- package/modules/use-cases/get-entities-for-user.js +0 -32
- package/modules/use-cases/get-entity-options-by-id.js +0 -73
- package/modules/use-cases/get-entity-options-by-type.js +0 -34
- package/modules/use-cases/get-module-entity-by-id.js +0 -16
- package/modules/use-cases/get-module-instance-from-type.js +0 -31
- package/modules/use-cases/get-module.js +0 -77
- package/modules/use-cases/process-authorization-step.js +0 -160
- package/modules/use-cases/refresh-entity-options.js +0 -74
- package/modules/use-cases/start-authorization-session.js +0 -86
- package/modules/use-cases/test-module-auth.js +0 -74
- package/modules/use-cases/update-module-entity.js +0 -27
- package/modules/utils/map-module-dto.js +0 -18
- package/openapi/openapi-spec-generator.js +0 -370
- package/openapi/openapi-v1.yaml +0 -1360
- package/openapi/openapi-v2.yaml +0 -1535
- package/prisma-postgresql/migrations/20260222000000_add_admin_process_and_script_schedule/migration.sql +0 -55
- package/providers/index.js +0 -13
- package/providers/resolve-provider.js +0 -93
- package/queues/index.js +0 -23
- package/queues/providers/index.js +0 -7
- package/queues/providers/netlify-background-provider.js +0 -76
- package/queues/providers/qstash-queue-provider.js +0 -122
- package/queues/queue-client-interface.js +0 -55
- package/queues/queue-provider-factory.js +0 -93
- package/queues/queue-provider.js +0 -46
- package/queues/queuer-util.js +0 -74
- package/syncs/repositories/sync-repository-factory.js +0 -43
- package/syncs/repositories/sync-repository-interface.js +0 -113
- package/syncs/repositories/sync-repository-mongo.js +0 -239
- package/syncs/repositories/sync-repository-postgres.js +0 -325
- package/syncs/sync.js +0 -117
- package/token/repositories/token-repository-documentdb.js +0 -137
- package/token/repositories/token-repository-factory.js +0 -38
- package/token/repositories/token-repository-interface.js +0 -131
- package/token/repositories/token-repository-mongo.js +0 -219
- package/token/repositories/token-repository-postgres.js +0 -264
- package/token/repositories/token-repository.js +0 -219
- package/types/assertions/index.d.ts +0 -83
- package/types/associations/index.d.ts +0 -57
- package/types/core/index.d.ts +0 -99
- package/types/database/index.d.ts +0 -11
- package/types/encrypt/index.d.ts +0 -7
- package/types/errors/index.d.ts +0 -73
- package/types/eslint-config/index.d.ts +0 -41
- package/types/index.d.ts +0 -14
- package/types/integrations/index.d.ts +0 -186
- package/types/lambda/index.d.ts +0 -31
- package/types/logs/index.d.ts +0 -5
- package/types/module-plugin/index.d.ts +0 -241
- package/types/prettier-config/index.d.ts +0 -6
- package/types/syncs/index.d.ts +0 -111
- package/types/test-environment/index.d.ts +0 -17
- package/types/tsconfig.json +0 -105
- package/user/repositories/user-repository-documentdb.js +0 -441
- package/user/repositories/user-repository-factory.js +0 -52
- package/user/repositories/user-repository-interface.js +0 -201
- package/user/repositories/user-repository-mongo.js +0 -308
- package/user/repositories/user-repository-postgres.js +0 -360
- package/user/use-cases/authenticate-user.js +0 -125
- package/user/use-cases/authenticate-with-shared-secret.js +0 -48
- package/user/use-cases/create-individual-user.js +0 -62
- package/user/use-cases/create-organization-user.js +0 -47
- package/user/use-cases/create-token-for-user-id.js +0 -30
- package/user/use-cases/delete-user.js +0 -47
- package/user/use-cases/get-user-from-adopter-jwt.js +0 -147
- package/user/use-cases/get-user-from-x-frigg-headers.js +0 -135
- package/user/use-cases/login-user.js +0 -122
- package/user/user.js +0 -139
- package/utils/index.js +0 -9
- package/websocket/repositories/websocket-connection-repository-documentdb.js +0 -144
- package/websocket/repositories/websocket-connection-repository-factory.js +0 -40
- package/websocket/repositories/websocket-connection-repository-interface.js +0 -106
- package/websocket/repositories/websocket-connection-repository-mongo.js +0 -166
- package/websocket/repositories/websocket-connection-repository-postgres.js +0 -207
- package/websocket/repositories/websocket-connection-repository.js +0 -167
- package/websocket/websocket-message-sender-interface.js +0 -38
package/README.md
CHANGED
|
@@ -4,16 +4,16 @@ The `@friggframework/core` package is the foundational layer of the Frigg Framew
|
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
7
|
+
- [Architecture Overview](#architecture-overview)
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Quick Start](#quick-start)
|
|
10
|
+
- [Core Components](#core-components)
|
|
11
|
+
- [Hexagonal Architecture](#hexagonal-architecture)
|
|
12
|
+
- [Usage Examples](#usage-examples)
|
|
13
|
+
- [Testing](#testing)
|
|
14
|
+
- [Development](#development)
|
|
15
|
+
- [API Reference](#api-reference)
|
|
16
|
+
- [Contributing](#contributing)
|
|
17
17
|
|
|
18
18
|
## Architecture Overview
|
|
19
19
|
|
|
@@ -67,13 +67,11 @@ yarn add @friggframework/core
|
|
|
67
67
|
`@friggframework/core` supports both MongoDB and PostgreSQL via Prisma ORM. **Prisma is an optional peer dependency** - you only need to install it if you're using database features that require migrations or schema generation.
|
|
68
68
|
|
|
69
69
|
**When you need Prisma:**
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
- Using the migration Lambda function (`dbMigrate`)
|
|
70
|
+
- Running database migrations (`prisma migrate`, `prisma db push`)
|
|
71
|
+
- Generating Prisma clients for your application
|
|
72
|
+
- Using the migration Lambda function (`dbMigrate`)
|
|
74
73
|
|
|
75
74
|
**Installation:**
|
|
76
|
-
|
|
77
75
|
```bash
|
|
78
76
|
# Install Prisma CLI and Client as dev dependencies
|
|
79
77
|
npm install --save-dev prisma @prisma/client
|
|
@@ -83,7 +81,6 @@ yarn add -D prisma @prisma/client
|
|
|
83
81
|
```
|
|
84
82
|
|
|
85
83
|
**Generate Prisma Clients:**
|
|
86
|
-
|
|
87
84
|
```bash
|
|
88
85
|
# From @friggframework/core directory
|
|
89
86
|
npm run prisma:generate:mongo # MongoDB only
|
|
@@ -95,9 +92,9 @@ npm run prisma:generate # Both databases
|
|
|
95
92
|
|
|
96
93
|
### Prerequisites
|
|
97
94
|
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
95
|
+
- Node.js 16+
|
|
96
|
+
- MongoDB 4.4+ (for data persistence)
|
|
97
|
+
- AWS credentials (for SQS, KMS, Lambda deployment)
|
|
101
98
|
|
|
102
99
|
### Environment Variables
|
|
103
100
|
|
|
@@ -123,13 +120,11 @@ LOG_LEVEL=info
|
|
|
123
120
|
The heart of the framework - manages integration lifecycle and business logic.
|
|
124
121
|
|
|
125
122
|
**Key Classes:**
|
|
126
|
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
- Use cases: `CreateIntegration`, `UpdateIntegration`, `DeleteIntegration`
|
|
123
|
+
- `IntegrationBase` - Base class for all integrations
|
|
124
|
+
- `Integration` - Domain aggregate using Proxy pattern
|
|
125
|
+
- Use cases: `CreateIntegration`, `UpdateIntegration`, `DeleteIntegration`
|
|
130
126
|
|
|
131
127
|
**Usage:**
|
|
132
|
-
|
|
133
128
|
```javascript
|
|
134
129
|
const { IntegrationBase } = require('@friggframework/core');
|
|
135
130
|
|
|
@@ -139,8 +134,8 @@ class SlackHubSpotSync extends IntegrationBase {
|
|
|
139
134
|
version: '2.1.0',
|
|
140
135
|
modules: {
|
|
141
136
|
slack: 'slack',
|
|
142
|
-
hubspot: 'hubspot'
|
|
143
|
-
}
|
|
137
|
+
hubspot: 'hubspot'
|
|
138
|
+
}
|
|
144
139
|
};
|
|
145
140
|
|
|
146
141
|
async onCreate({ integrationId }) {
|
|
@@ -157,32 +152,30 @@ class SlackHubSpotSync extends IntegrationBase {
|
|
|
157
152
|
MongoDB integration with Mongoose ODM.
|
|
158
153
|
|
|
159
154
|
**Key Components:**
|
|
160
|
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
- Schema definitions
|
|
155
|
+
- Connection management
|
|
156
|
+
- Pre-built models (User, Integration, Credential, etc.)
|
|
157
|
+
- Schema definitions
|
|
164
158
|
|
|
165
159
|
**Usage:**
|
|
166
|
-
|
|
167
160
|
```javascript
|
|
168
|
-
const {
|
|
169
|
-
connectToDatabase,
|
|
170
|
-
IntegrationModel,
|
|
171
|
-
UserModel
|
|
161
|
+
const {
|
|
162
|
+
connectToDatabase,
|
|
163
|
+
IntegrationModel,
|
|
164
|
+
UserModel
|
|
172
165
|
} = require('@friggframework/core');
|
|
173
166
|
|
|
174
167
|
await connectToDatabase();
|
|
175
168
|
|
|
176
169
|
// Query integrations
|
|
177
|
-
const userIntegrations = await IntegrationModel.find({
|
|
170
|
+
const userIntegrations = await IntegrationModel.find({
|
|
178
171
|
userId: 'user-123',
|
|
179
|
-
status: 'ENABLED'
|
|
172
|
+
status: 'ENABLED'
|
|
180
173
|
});
|
|
181
174
|
|
|
182
175
|
// Create user
|
|
183
176
|
const user = new UserModel({
|
|
184
177
|
email: 'user@example.com',
|
|
185
|
-
name: 'John Doe'
|
|
178
|
+
name: 'John Doe'
|
|
186
179
|
});
|
|
187
180
|
await user.save();
|
|
188
181
|
```
|
|
@@ -192,7 +185,6 @@ await user.save();
|
|
|
192
185
|
AES-256-GCM encryption for sensitive data.
|
|
193
186
|
|
|
194
187
|
**Usage:**
|
|
195
|
-
|
|
196
188
|
```javascript
|
|
197
189
|
const { Encrypt, Cryptor } = require('@friggframework/core');
|
|
198
190
|
|
|
@@ -202,12 +194,10 @@ const decrypted = Encrypt.decrypt(encrypted);
|
|
|
202
194
|
|
|
203
195
|
// Advanced encryption with custom key
|
|
204
196
|
const cryptor = new Cryptor(process.env.CUSTOM_KEY);
|
|
205
|
-
const secureData = cryptor.encrypt(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
})
|
|
210
|
-
);
|
|
197
|
+
const secureData = cryptor.encrypt(JSON.stringify({
|
|
198
|
+
accessToken: 'oauth-token',
|
|
199
|
+
refreshToken: 'refresh-token'
|
|
200
|
+
}));
|
|
211
201
|
```
|
|
212
202
|
|
|
213
203
|
### 5. Error Handling (`/errors`)
|
|
@@ -215,12 +205,11 @@ const secureData = cryptor.encrypt(
|
|
|
215
205
|
Standardized error types with proper HTTP status codes.
|
|
216
206
|
|
|
217
207
|
**Usage:**
|
|
218
|
-
|
|
219
208
|
```javascript
|
|
220
|
-
const {
|
|
221
|
-
BaseError,
|
|
222
|
-
RequiredPropertyError,
|
|
223
|
-
FetchError
|
|
209
|
+
const {
|
|
210
|
+
BaseError,
|
|
211
|
+
RequiredPropertyError,
|
|
212
|
+
FetchError
|
|
224
213
|
} = require('@friggframework/core');
|
|
225
214
|
|
|
226
215
|
// Custom business logic error
|
|
@@ -229,13 +218,13 @@ throw new RequiredPropertyError('userId is required');
|
|
|
229
218
|
// API communication error
|
|
230
219
|
throw new FetchError('Failed to fetch data from external API', {
|
|
231
220
|
statusCode: 404,
|
|
232
|
-
response: errorResponse
|
|
221
|
+
response: errorResponse
|
|
233
222
|
});
|
|
234
223
|
|
|
235
224
|
// Base error with custom properties
|
|
236
225
|
throw new BaseError('Integration failed', {
|
|
237
226
|
integrationId: 'int-123',
|
|
238
|
-
errorCode: 'SYNC_FAILED'
|
|
227
|
+
errorCode: 'SYNC_FAILED'
|
|
239
228
|
});
|
|
240
229
|
```
|
|
241
230
|
|
|
@@ -244,7 +233,6 @@ throw new BaseError('Integration failed', {
|
|
|
244
233
|
Structured logging with debug capabilities.
|
|
245
234
|
|
|
246
235
|
**Usage:**
|
|
247
|
-
|
|
248
236
|
```javascript
|
|
249
237
|
const { debug, initDebugLog, flushDebugLog } = require('@friggframework/core');
|
|
250
238
|
|
|
@@ -252,9 +240,9 @@ const { debug, initDebugLog, flushDebugLog } = require('@friggframework/core');
|
|
|
252
240
|
initDebugLog('integration:slack');
|
|
253
241
|
|
|
254
242
|
// Log debug information
|
|
255
|
-
debug('Processing webhook payload', {
|
|
243
|
+
debug('Processing webhook payload', {
|
|
256
244
|
eventType: 'contact.created',
|
|
257
|
-
payload: webhookData
|
|
245
|
+
payload: webhookData
|
|
258
246
|
});
|
|
259
247
|
|
|
260
248
|
// Flush logs (useful in serverless environments)
|
|
@@ -266,31 +254,27 @@ await flushDebugLog();
|
|
|
266
254
|
Comprehensive user authentication and authorization system supporting both individual and organizational users.
|
|
267
255
|
|
|
268
256
|
**Key Classes:**
|
|
269
|
-
|
|
270
|
-
-
|
|
271
|
-
-
|
|
272
|
-
- Use cases: `LoginUser`, `CreateIndividualUser`, `CreateOrganizationUser`, `GetUserFromBearerToken`
|
|
257
|
+
- `User` - Domain aggregate for user entities
|
|
258
|
+
- `UserRepository` - Data access for user operations
|
|
259
|
+
- Use cases: `LoginUser`, `CreateIndividualUser`, `CreateOrganizationUser`, `GetUserFromBearerToken`
|
|
273
260
|
|
|
274
261
|
**User Types:**
|
|
275
|
-
|
|
276
|
-
-
|
|
277
|
-
-
|
|
278
|
-
- **Hybrid Mode**: Support for both user types simultaneously
|
|
262
|
+
- **Individual Users**: Personal accounts with email/username authentication
|
|
263
|
+
- **Organization Users**: Business accounts with organization-level access
|
|
264
|
+
- **Hybrid Mode**: Support for both user types simultaneously
|
|
279
265
|
|
|
280
266
|
**Authentication Methods:**
|
|
281
|
-
|
|
282
|
-
-
|
|
283
|
-
-
|
|
284
|
-
- **App-based**: External app user ID authentication (passwordless)
|
|
267
|
+
- **Password-based**: Traditional username/password authentication
|
|
268
|
+
- **Token-based**: Bearer token authentication with session management
|
|
269
|
+
- **App-based**: External app user ID authentication (passwordless)
|
|
285
270
|
|
|
286
271
|
**Usage:**
|
|
287
|
-
|
|
288
272
|
```javascript
|
|
289
|
-
const {
|
|
290
|
-
LoginUser,
|
|
291
|
-
CreateIndividualUser,
|
|
273
|
+
const {
|
|
274
|
+
LoginUser,
|
|
275
|
+
CreateIndividualUser,
|
|
292
276
|
GetUserFromBearerToken,
|
|
293
|
-
UserRepository
|
|
277
|
+
UserRepository
|
|
294
278
|
} = require('@friggframework/core');
|
|
295
279
|
|
|
296
280
|
// Configure user behavior in app definition
|
|
@@ -298,7 +282,7 @@ const userConfig = {
|
|
|
298
282
|
usePassword: true,
|
|
299
283
|
primary: 'individual', // or 'organization'
|
|
300
284
|
individualUserRequired: true,
|
|
301
|
-
organizationUserRequired: false
|
|
285
|
+
organizationUserRequired: false
|
|
302
286
|
};
|
|
303
287
|
|
|
304
288
|
const userRepository = new UserRepository({ userConfig });
|
|
@@ -309,21 +293,18 @@ const user = await createUser.execute({
|
|
|
309
293
|
email: 'user@example.com',
|
|
310
294
|
username: 'john_doe',
|
|
311
295
|
password: 'secure_password',
|
|
312
|
-
appUserId: 'external_user_123'
|
|
296
|
+
appUserId: 'external_user_123' // Optional external reference
|
|
313
297
|
});
|
|
314
298
|
|
|
315
299
|
// Login user
|
|
316
300
|
const loginUser = new LoginUser({ userRepository, userConfig });
|
|
317
301
|
const authenticatedUser = await loginUser.execute({
|
|
318
302
|
username: 'john_doe',
|
|
319
|
-
password: 'secure_password'
|
|
303
|
+
password: 'secure_password'
|
|
320
304
|
});
|
|
321
305
|
|
|
322
306
|
// Token-based authentication
|
|
323
|
-
const getUserFromToken = new GetUserFromBearerToken({
|
|
324
|
-
userRepository,
|
|
325
|
-
userConfig,
|
|
326
|
-
});
|
|
307
|
+
const getUserFromToken = new GetUserFromBearerToken({ userRepository, userConfig });
|
|
327
308
|
const user = await getUserFromToken.execute('Bearer eyJhbGciOiJIUzI1NiIs...');
|
|
328
309
|
|
|
329
310
|
// Access user properties
|
|
@@ -338,13 +319,12 @@ console.log('Organization user:', user.getOrganizationUser());
|
|
|
338
319
|
AWS Lambda-specific utilities and helpers.
|
|
339
320
|
|
|
340
321
|
**Usage:**
|
|
341
|
-
|
|
342
322
|
```javascript
|
|
343
323
|
const { TimeoutCatcher } = require('@friggframework/core');
|
|
344
324
|
|
|
345
325
|
exports.handler = async (event, context) => {
|
|
346
326
|
const timeoutCatcher = new TimeoutCatcher(context);
|
|
347
|
-
|
|
327
|
+
|
|
348
328
|
try {
|
|
349
329
|
// Long-running integration process
|
|
350
330
|
const result = await processIntegrationSync(event);
|
|
@@ -373,11 +353,11 @@ User behavior is configured in the app definition, allowing you to customize aut
|
|
|
373
353
|
const appDefinition = {
|
|
374
354
|
integrations: [HubSpotIntegration],
|
|
375
355
|
user: {
|
|
376
|
-
usePassword: true,
|
|
377
|
-
primary: 'individual',
|
|
378
|
-
organizationUserRequired: true,
|
|
379
|
-
individualUserRequired: true,
|
|
380
|
-
}
|
|
356
|
+
usePassword: true, // Enable password authentication
|
|
357
|
+
primary: 'individual', // Primary user type: 'individual' or 'organization'
|
|
358
|
+
organizationUserRequired: true, // Require organization user
|
|
359
|
+
individualUserRequired: true, // Require individual user
|
|
360
|
+
}
|
|
381
361
|
};
|
|
382
362
|
```
|
|
383
363
|
|
|
@@ -392,20 +372,20 @@ const { User } = require('@friggframework/core');
|
|
|
392
372
|
const user = new User(individualUser, organizationUser, usePassword, primary);
|
|
393
373
|
|
|
394
374
|
// Access methods
|
|
395
|
-
user.getId()
|
|
396
|
-
user.getPrimaryUser()
|
|
397
|
-
user.getIndividualUser()
|
|
398
|
-
user.getOrganizationUser()
|
|
375
|
+
user.getId() // Get primary user ID
|
|
376
|
+
user.getPrimaryUser() // Get primary user based on config
|
|
377
|
+
user.getIndividualUser() // Get individual user
|
|
378
|
+
user.getOrganizationUser() // Get organization user
|
|
399
379
|
|
|
400
380
|
// Validation methods
|
|
401
|
-
user.isPasswordRequired()
|
|
402
|
-
user.isPasswordValid(password)
|
|
403
|
-
user.isIndividualUserRequired()
|
|
404
|
-
user.isOrganizationUserRequired()
|
|
381
|
+
user.isPasswordRequired() // Check if password is required
|
|
382
|
+
user.isPasswordValid(password) // Validate password
|
|
383
|
+
user.isIndividualUserRequired() // Check individual user requirement
|
|
384
|
+
user.isOrganizationUserRequired() // Check organization user requirement
|
|
405
385
|
|
|
406
386
|
// Configuration methods
|
|
407
|
-
user.setIndividualUser(individualUser)
|
|
408
|
-
user.setOrganizationUser(organizationUser)
|
|
387
|
+
user.setIndividualUser(individualUser)
|
|
388
|
+
user.setOrganizationUser(organizationUser)
|
|
409
389
|
```
|
|
410
390
|
|
|
411
391
|
### Database Models
|
|
@@ -441,11 +421,11 @@ The user system uses MongoDB with Mongoose for data persistence:
|
|
|
441
421
|
|
|
442
422
|
### Security Features
|
|
443
423
|
|
|
444
|
-
-
|
|
445
|
-
-
|
|
446
|
-
-
|
|
447
|
-
-
|
|
448
|
-
-
|
|
424
|
+
- **Password Hashing**: Uses bcrypt with configurable salt rounds
|
|
425
|
+
- **Token Management**: Secure session tokens with expiration
|
|
426
|
+
- **Unique Constraints**: Enforced username and email uniqueness
|
|
427
|
+
- **External References**: Support for external app user/org IDs
|
|
428
|
+
- **Flexible Authentication**: Multiple authentication methods
|
|
449
429
|
|
|
450
430
|
## Hexagonal Architecture
|
|
451
431
|
|
|
@@ -466,9 +446,7 @@ class UpdateIntegrationStatus {
|
|
|
466
446
|
}
|
|
467
447
|
|
|
468
448
|
// Domain operation
|
|
469
|
-
const integration = await this.integrationRepository.findById(
|
|
470
|
-
integrationId
|
|
471
|
-
);
|
|
449
|
+
const integration = await this.integrationRepository.findById(integrationId);
|
|
472
450
|
if (!integration) {
|
|
473
451
|
throw new Error('Integration not found');
|
|
474
452
|
}
|
|
@@ -476,7 +454,7 @@ class UpdateIntegrationStatus {
|
|
|
476
454
|
// Update and persist
|
|
477
455
|
integration.status = newStatus;
|
|
478
456
|
integration.updatedAt = new Date();
|
|
479
|
-
|
|
457
|
+
|
|
480
458
|
return await this.integrationRepository.save(integration);
|
|
481
459
|
}
|
|
482
460
|
}
|
|
@@ -506,7 +484,7 @@ class IntegrationRepository {
|
|
|
506
484
|
userId,
|
|
507
485
|
config,
|
|
508
486
|
status: 'NEW',
|
|
509
|
-
createdAt: new Date()
|
|
487
|
+
createdAt: new Date()
|
|
510
488
|
});
|
|
511
489
|
return await integration.save();
|
|
512
490
|
}
|
|
@@ -522,7 +500,7 @@ const Integration = new Proxy(class {}, {
|
|
|
522
500
|
construct(target, args) {
|
|
523
501
|
const [params] = args;
|
|
524
502
|
const instance = new params.integrationClass(params);
|
|
525
|
-
|
|
503
|
+
|
|
526
504
|
// Attach domain properties
|
|
527
505
|
Object.assign(instance, {
|
|
528
506
|
id: params.id,
|
|
@@ -530,11 +508,11 @@ const Integration = new Proxy(class {}, {
|
|
|
530
508
|
entities: params.entities,
|
|
531
509
|
config: params.config,
|
|
532
510
|
status: params.status,
|
|
533
|
-
modules: params.modules
|
|
511
|
+
modules: params.modules
|
|
534
512
|
});
|
|
535
513
|
|
|
536
514
|
return instance;
|
|
537
|
-
}
|
|
515
|
+
}
|
|
538
516
|
});
|
|
539
517
|
```
|
|
540
518
|
|
|
@@ -587,7 +565,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
587
565
|
|
|
588
566
|
constructor() {
|
|
589
567
|
super();
|
|
590
|
-
|
|
568
|
+
|
|
591
569
|
// Define event handlers for various integration actions
|
|
592
570
|
this.events = {
|
|
593
571
|
// Webhook handler with real-time WebSocket broadcasting
|
|
@@ -596,8 +574,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
596
574
|
console.log('Received HubSpot webhook:', data);
|
|
597
575
|
|
|
598
576
|
// Broadcast to all connected WebSocket clients
|
|
599
|
-
const activeConnections =
|
|
600
|
-
await WebsocketConnection.getActiveConnections();
|
|
577
|
+
const activeConnections = await WebsocketConnection.getActiveConnections();
|
|
601
578
|
const message = JSON.stringify({
|
|
602
579
|
type: 'HUBSPOT_WEBHOOK',
|
|
603
580
|
data,
|
|
@@ -608,17 +585,16 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
608
585
|
});
|
|
609
586
|
},
|
|
610
587
|
},
|
|
611
|
-
|
|
588
|
+
|
|
612
589
|
// User action: Get sample data with formatted table output
|
|
613
590
|
[FriggConstants.defaultEvents.GET_SAMPLE_DATA]: {
|
|
614
591
|
type: FriggConstants.eventTypes.USER_ACTION,
|
|
615
592
|
handler: this.getSampleData,
|
|
616
593
|
title: 'Get Sample Data',
|
|
617
|
-
description:
|
|
618
|
-
'Get sample data from HubSpot and display in a formatted table',
|
|
594
|
+
description: 'Get sample data from HubSpot and display in a formatted table',
|
|
619
595
|
userActionType: 'QUICK_ACTION',
|
|
620
596
|
},
|
|
621
|
-
|
|
597
|
+
|
|
622
598
|
// User action: List available objects
|
|
623
599
|
GET_OBJECT_LIST: {
|
|
624
600
|
type: FriggConstants.eventTypes.USER_ACTION,
|
|
@@ -627,7 +603,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
627
603
|
description: 'Get list of available HubSpot objects',
|
|
628
604
|
userActionType: 'DATA',
|
|
629
605
|
},
|
|
630
|
-
|
|
606
|
+
|
|
631
607
|
// User action: Create records with dynamic forms
|
|
632
608
|
CREATE_RECORD: {
|
|
633
609
|
type: FriggConstants.eventTypes.USER_ACTION,
|
|
@@ -637,7 +613,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
637
613
|
userActionType: 'DATA',
|
|
638
614
|
},
|
|
639
615
|
};
|
|
640
|
-
|
|
616
|
+
|
|
641
617
|
// Extension system for modular functionality
|
|
642
618
|
this.extensions = {
|
|
643
619
|
hubspotWebhooks: {
|
|
@@ -711,7 +687,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
711
687
|
let res;
|
|
712
688
|
const objectType = args.objectType;
|
|
713
689
|
delete args.objectType;
|
|
714
|
-
|
|
690
|
+
|
|
715
691
|
switch (objectType.toLowerCase()) {
|
|
716
692
|
case 'deal':
|
|
717
693
|
res = await this.hubspot.api.createDeal({ ...args });
|
|
@@ -742,7 +718,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
742
718
|
},
|
|
743
719
|
required: [],
|
|
744
720
|
};
|
|
745
|
-
|
|
721
|
+
|
|
746
722
|
let uiSchema = {
|
|
747
723
|
type: 'HorizontalLayout',
|
|
748
724
|
elements: [
|
|
@@ -768,7 +744,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
768
744
|
{ type: 'Control', scope: '#/properties/amount' }
|
|
769
745
|
);
|
|
770
746
|
break;
|
|
771
|
-
|
|
747
|
+
|
|
772
748
|
case 'company':
|
|
773
749
|
jsonSchema.properties = {
|
|
774
750
|
...jsonSchema.properties,
|
|
@@ -781,7 +757,7 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
781
757
|
{ type: 'Control', scope: '#/properties/website' }
|
|
782
758
|
);
|
|
783
759
|
break;
|
|
784
|
-
|
|
760
|
+
|
|
785
761
|
case 'contact':
|
|
786
762
|
jsonSchema.properties = {
|
|
787
763
|
...jsonSchema.properties,
|
|
@@ -789,25 +765,16 @@ class HubSpotIntegration extends IntegrationBase {
|
|
|
789
765
|
lastname: { type: 'string', title: 'Last Name' },
|
|
790
766
|
email: { type: 'string', title: 'Email Address' },
|
|
791
767
|
};
|
|
792
|
-
jsonSchema.required = [
|
|
793
|
-
'firstname',
|
|
794
|
-
'lastname',
|
|
795
|
-
'email',
|
|
796
|
-
];
|
|
768
|
+
jsonSchema.required = ['firstname', 'lastname', 'email'];
|
|
797
769
|
uiSchema.elements.push(
|
|
798
|
-
{
|
|
799
|
-
type: 'Control',
|
|
800
|
-
scope: '#/properties/firstname',
|
|
801
|
-
},
|
|
770
|
+
{ type: 'Control', scope: '#/properties/firstname' },
|
|
802
771
|
{ type: 'Control', scope: '#/properties/lastname' },
|
|
803
772
|
{ type: 'Control', scope: '#/properties/email' }
|
|
804
773
|
);
|
|
805
774
|
break;
|
|
806
|
-
|
|
775
|
+
|
|
807
776
|
default:
|
|
808
|
-
throw new Error(
|
|
809
|
-
`Unsupported object type: ${data.name}`
|
|
810
|
-
);
|
|
777
|
+
throw new Error(`Unsupported object type: ${data.name}`);
|
|
811
778
|
}
|
|
812
779
|
|
|
813
780
|
return {
|
|
@@ -829,25 +796,28 @@ module.exports = HubSpotIntegration;
|
|
|
829
796
|
```
|
|
830
797
|
|
|
831
798
|
index.js
|
|
832
|
-
|
|
833
799
|
```js
|
|
834
800
|
const HubSpotIntegration = require('./src/integrations/HubSpotIntegration');
|
|
835
801
|
|
|
836
802
|
const appDefinition = {
|
|
837
|
-
integrations: [
|
|
803
|
+
integrations: [
|
|
804
|
+
HubSpotIntegration,
|
|
805
|
+
],
|
|
838
806
|
user: {
|
|
839
807
|
usePassword: true,
|
|
840
808
|
primary: 'individual',
|
|
841
809
|
organizationUserRequired: true,
|
|
842
810
|
individualUserRequired: true,
|
|
843
|
-
}
|
|
844
|
-
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
845
813
|
|
|
846
814
|
module.exports = {
|
|
847
815
|
Definition: appDefinition,
|
|
848
|
-
}
|
|
816
|
+
}
|
|
817
|
+
|
|
849
818
|
```
|
|
850
819
|
|
|
820
|
+
|
|
851
821
|
### Key Features Demonstrated
|
|
852
822
|
|
|
853
823
|
This real-world example showcases:
|
|
@@ -860,6 +830,7 @@ This real-world example showcases:
|
|
|
860
830
|
**🔗 Deep Linking**: Direct links to HubSpot records in formatted data
|
|
861
831
|
**⚡ Real-time Updates**: WebSocket connections for live data streaming
|
|
862
832
|
|
|
833
|
+
|
|
863
834
|
## Testing
|
|
864
835
|
|
|
865
836
|
### Running Tests
|
|
@@ -889,15 +860,13 @@ describe('CreateIntegration Use-Case', () => {
|
|
|
889
860
|
useCase = new CreateIntegration({
|
|
890
861
|
integrationRepository,
|
|
891
862
|
integrationClasses: [TestIntegration],
|
|
892
|
-
moduleFactory
|
|
863
|
+
moduleFactory
|
|
893
864
|
});
|
|
894
865
|
});
|
|
895
866
|
|
|
896
867
|
describe('happy path', () => {
|
|
897
868
|
it('creates an integration and returns DTO', async () => {
|
|
898
|
-
const result = await useCase.execute(['entity-1'], 'user-1', {
|
|
899
|
-
type: 'test',
|
|
900
|
-
});
|
|
869
|
+
const result = await useCase.execute(['entity-1'], 'user-1', { type: 'test' });
|
|
901
870
|
expect(result.id).toBeDefined();
|
|
902
871
|
expect(result.status).toBe('NEW');
|
|
903
872
|
});
|
|
@@ -905,9 +874,8 @@ describe('CreateIntegration Use-Case', () => {
|
|
|
905
874
|
|
|
906
875
|
describe('error cases', () => {
|
|
907
876
|
it('throws error for unknown integration type', async () => {
|
|
908
|
-
await expect(
|
|
909
|
-
|
|
910
|
-
).rejects.toThrow('No integration class found for type: unknown');
|
|
877
|
+
await expect(useCase.execute(['entity-1'], 'user-1', { type: 'unknown' }))
|
|
878
|
+
.rejects.toThrow('No integration class found for type: unknown');
|
|
911
879
|
});
|
|
912
880
|
});
|
|
913
881
|
});
|
|
@@ -918,10 +886,7 @@ describe('CreateIntegration Use-Case', () => {
|
|
|
918
886
|
The framework provides test doubles for external dependencies:
|
|
919
887
|
|
|
920
888
|
```javascript
|
|
921
|
-
const {
|
|
922
|
-
TestIntegrationRepository,
|
|
923
|
-
TestModuleFactory,
|
|
924
|
-
} = require('@friggframework/core/test');
|
|
889
|
+
const { TestIntegrationRepository, TestModuleFactory } = require('@friggframework/core/test');
|
|
925
890
|
|
|
926
891
|
// Mock repository for testing
|
|
927
892
|
const testRepo = new TestIntegrationRepository();
|
|
@@ -981,7 +946,7 @@ const {
|
|
|
981
946
|
CreateIntegration,
|
|
982
947
|
UpdateIntegration,
|
|
983
948
|
DeleteIntegration,
|
|
984
|
-
|
|
949
|
+
|
|
985
950
|
// Modules
|
|
986
951
|
OAuth2Requester,
|
|
987
952
|
ApiKeyRequester,
|
|
@@ -991,25 +956,25 @@ const {
|
|
|
991
956
|
connectToDatabase,
|
|
992
957
|
mongoose,
|
|
993
958
|
UserModel,
|
|
994
|
-
|
|
959
|
+
|
|
995
960
|
// Utilities
|
|
996
961
|
Encrypt,
|
|
997
962
|
Cryptor,
|
|
998
963
|
BaseError,
|
|
999
964
|
debug,
|
|
1000
|
-
TimeoutCatcher
|
|
965
|
+
TimeoutCatcher
|
|
1001
966
|
} = require('@friggframework/core');
|
|
1002
967
|
```
|
|
1003
968
|
|
|
1004
969
|
### Environment Configuration
|
|
1005
970
|
|
|
1006
|
-
| Variable
|
|
1007
|
-
|
|
1008
|
-
| `MONGO_URI`
|
|
1009
|
-
| `FRIGG_ENCRYPTION_KEY` | Yes
|
|
1010
|
-
| `AWS_REGION`
|
|
1011
|
-
| `DEBUG`
|
|
1012
|
-
| `LOG_LEVEL`
|
|
971
|
+
| Variable | Required | Description |
|
|
972
|
+
|----------|----------|-------------|
|
|
973
|
+
| `MONGO_URI` | Yes | MongoDB connection string |
|
|
974
|
+
| `FRIGG_ENCRYPTION_KEY` | Yes | 256-bit encryption key |
|
|
975
|
+
| `AWS_REGION` | No | AWS region for services |
|
|
976
|
+
| `DEBUG` | No | Debug logging pattern |
|
|
977
|
+
| `LOG_LEVEL` | No | Logging level (debug, info, warn, error) |
|
|
1013
978
|
|
|
1014
979
|
## License
|
|
1015
980
|
|
|
@@ -1019,9 +984,9 @@ This project is licensed under the MIT License - see the [LICENSE.md](../../LICE
|
|
|
1019
984
|
|
|
1020
985
|
## Support
|
|
1021
986
|
|
|
1022
|
-
-
|
|
1023
|
-
-
|
|
1024
|
-
-
|
|
1025
|
-
-
|
|
987
|
+
- 📖 [Documentation](https://docs.friggframework.org)
|
|
988
|
+
- 💬 [Community Slack](https://friggframework.slack.com)
|
|
989
|
+
- 🐛 [Issue Tracker](https://github.com/friggframework/frigg/issues)
|
|
990
|
+
- 📧 [Email Support](mailto:support@friggframework.org)
|
|
1026
991
|
|
|
1027
992
|
Built with ❤️ by the Frigg Framework team.
|