@friggframework/core 2.0.0--canary.703.12b980b.0 → 2.0.0--canary.707.df80bfd.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 +11 -0
- package/CLAUDE.md +28 -0
- package/README.md +105 -0
- package/application/commands/integration-commands.js +20 -10
- package/application/commands/scheduler-commands.js +11 -7
- package/application/commands/user-commands.js +17 -5
- package/application/index.js +6 -2
- package/core/Worker.js +31 -7
- package/core/create-handler.js +9 -0
- package/credential/repositories/credential-repository-documentdb.js +34 -0
- package/credential/repositories/credential-repository-interface.js +15 -0
- package/credential/repositories/credential-repository-mongo.js +23 -0
- package/credential/repositories/credential-repository-postgres.js +28 -0
- package/credential/use-cases/credential-operations-for-user.js +202 -0
- package/credential/use-cases/reauthorize-credential-for-user.js +73 -0
- package/database/config.js +48 -24
- package/database/documentdb-encryption-service.js +9 -22
- package/database/documentdb-utils.js +2 -2
- package/database/encryption/README.md +78 -14
- package/database/encryption/documentdb-encryption-service.md +78 -1
- package/database/encryption/encryption-config.js +219 -0
- package/database/encryption/encryption-schema-registry.js +121 -24
- package/database/encryption/field-encryption-service.js +69 -5
- package/database/encryption/integration-mapping-encryption.js +1 -1
- package/database/encryption/test-support/fake-ciphertext.js +15 -0
- package/database/organization-where.js +18 -0
- package/database/prisma.js +15 -38
- package/database/unique-violation.js +25 -0
- package/database/use-cases/check-encryption-health-use-case.js +43 -52
- package/errors/index.js +0 -4
- package/extensions/bootstrap-runner.js +43 -0
- package/extensions/extension-loader.js +230 -0
- package/extensions/index.js +44 -0
- package/extensions/initialize-app.js +123 -0
- package/extensions/prisma-composer.js +270 -0
- package/extensions/route-mounter.js +103 -0
- package/extensions/schema-composer.js +188 -0
- package/generated/prisma-mongodb/edge.js +33 -42
- package/generated/prisma-mongodb/index-browser.js +30 -39
- package/generated/prisma-mongodb/index.d.ts +3187 -2005
- package/generated/prisma-mongodb/index.js +33 -42
- package/generated/prisma-mongodb/package.json +1 -1
- package/generated/prisma-mongodb/schema.prisma +86 -59
- package/generated/prisma-mongodb/wasm.js +33 -42
- package/generated/prisma-postgresql/edge.js +33 -42
- package/generated/prisma-postgresql/index-browser.js +30 -39
- package/generated/prisma-postgresql/index.d.ts +3380 -2177
- package/generated/prisma-postgresql/index.js +33 -42
- package/generated/prisma-postgresql/package.json +1 -1
- package/generated/prisma-postgresql/schema.prisma +81 -57
- package/generated/prisma-postgresql/wasm.js +33 -42
- package/handlers/WEBHOOKS.md +0 -29
- package/handlers/app-definition-loader.js +128 -19
- package/handlers/app-handler-helpers.js +27 -8
- package/handlers/backend-utils.js +31 -25
- package/handlers/integration-event-dispatcher.js +3 -7
- package/handlers/middleware/admin-auth.js +14 -1
- package/handlers/routers/auth.js +46 -10
- package/handlers/routers/health.js +13 -4
- package/handlers/routers/integration-defined-routers.js +144 -92
- package/handlers/routers/integration-webhook-routers.js +100 -50
- package/handlers/workers/integration-defined-workers.js +5 -2
- package/index.js +66 -16
- package/infrastructure/scheduler/index.js +19 -6
- package/infrastructure/scheduler/netlify-scheduler-adapter.js +216 -0
- package/infrastructure/scheduler/scheduled-job-repository.js +118 -0
- package/infrastructure/scheduler/scheduler-service-factory.js +55 -7
- package/integrations/index.js +1 -14
- package/integrations/integration-base.js +2 -163
- package/integrations/integration-router.js +132 -102
- package/integrations/repositories/integration-mapping-repository-documentdb.js +0 -50
- package/integrations/repositories/integration-mapping-repository-interface.js +0 -15
- package/integrations/repositories/integration-mapping-repository-mongo.js +0 -29
- package/integrations/repositories/integration-mapping-repository-postgres.js +0 -30
- package/integrations/repositories/integration-mapping-repository.js +0 -29
- package/integrations/repositories/integration-not-found.js +14 -0
- package/integrations/repositories/integration-repository-documentdb.js +37 -9
- package/integrations/repositories/integration-repository-interface.js +17 -4
- package/integrations/repositories/integration-repository-mongo.js +64 -96
- package/integrations/repositories/integration-repository-postgres.js +63 -81
- package/integrations/repositories/process-repository-mongo.js +1 -1
- package/integrations/schedule-config.js +80 -0
- package/integrations/tests/doubles/test-integration-repository.js +12 -1
- package/integrations/use-cases/create-integration.js +56 -31
- package/integrations/use-cases/delete-integration-for-user.js +4 -4
- package/integrations/use-cases/dispatch-ongoing-syncs.js +100 -0
- package/integrations/use-cases/get-integration-for-user.js +2 -4
- package/integrations/use-cases/get-integration-instance.js +4 -4
- package/integrations/use-cases/get-integrations-for-user.js +79 -39
- package/integrations/use-cases/get-possible-integrations.js +2 -7
- package/integrations/use-cases/index.js +7 -1
- package/integrations/use-cases/integration-operations-for-user.js +256 -0
- package/integrations/use-cases/resolve-integration-ownership.js +177 -0
- package/integrations/use-cases/update-integration.js +4 -4
- package/integrations/utils/map-integration-dto.js +43 -14
- package/management-api/create-management-api-router.js +49 -0
- package/management-api/error-response.js +116 -0
- package/management-api/management-api-config.js +151 -0
- package/management-api/meta-router.js +76 -0
- package/management-api/openapi/build-openapi.js +144 -0
- package/management-api/openapi/components.js +415 -0
- package/management-api/openapi/v1-operations.js +83 -0
- package/management-api/openapi/v2-operations.js +264 -0
- package/management-api/route-registry.js +411 -0
- package/management-api/test-support/http-client.js +39 -0
- package/management-api/use-cases/get-management-api-meta.js +57 -0
- package/management-api/v1-deprecation.js +120 -0
- package/management-api/v2/create-v2-router.js +85 -0
- package/management-api/v2/dependencies.js +281 -0
- package/management-api/v2/dto.js +143 -0
- package/management-api/v2/handlers/authorization.js +94 -0
- package/management-api/v2/handlers/credentials.js +33 -0
- package/management-api/v2/handlers/entities.js +77 -0
- package/management-api/v2/handlers/integrations.js +128 -0
- package/management-api/v2/handlers/proxy.js +34 -0
- package/management-api/v2/request.js +85 -0
- package/management-api/v2/test-support/fake-dependencies.js +103 -0
- package/modules/domain/authorization-session.js +144 -0
- package/modules/entity-scope.js +15 -0
- package/modules/entity-type-registry.js +311 -0
- package/modules/index.js +14 -0
- package/modules/module-factory.js +12 -0
- package/modules/module.js +53 -2
- package/modules/proxy/proxy-bases.js +169 -0
- package/modules/proxy/proxy-errors.js +31 -0
- package/modules/proxy/proxy-path.js +183 -0
- package/modules/proxy/proxy-policy.js +277 -0
- package/modules/repositories/authorization-session-repository-documentdb.js +112 -0
- package/modules/repositories/authorization-session-repository-factory.js +31 -0
- package/modules/repositories/authorization-session-repository-interface.js +47 -0
- package/modules/repositories/authorization-session-repository-prisma.js +87 -0
- package/modules/repositories/entity-not-found.js +18 -0
- package/modules/repositories/module-repository-documentdb.js +51 -6
- package/modules/repositories/module-repository-interface.js +19 -2
- package/modules/repositories/module-repository-mongo.js +67 -74
- package/modules/repositories/module-repository-postgres.js +66 -74
- package/modules/repositories/module-repository.js +2 -1
- package/modules/requester/proxy-request.js +245 -0
- package/modules/requester/requester.js +35 -5
- package/modules/scope-config.js +192 -0
- package/modules/scope-policy.js +112 -0
- package/modules/scope-resolution.js +288 -0
- package/modules/scope-visibility.js +247 -0
- package/modules/tests/doubles/in-memory-authorization-session-repository.js +45 -0
- package/modules/tests/doubles/ownership-matching.js +18 -0
- package/modules/use-cases/authorize-entity-for-user.js +61 -0
- package/modules/use-cases/create-entity-from-credential.js +113 -0
- package/modules/use-cases/entity-operations-for-user.js +162 -0
- package/modules/use-cases/entity-types.js +139 -0
- package/modules/use-cases/execute-entity-proxy-request.js +331 -0
- package/modules/use-cases/get-authorization-requirements.js +100 -0
- package/modules/use-cases/get-entities-for-user.js +26 -13
- package/modules/use-cases/get-entity-module-for-user.js +113 -0
- package/modules/use-cases/get-entity-options-by-id.js +10 -4
- package/modules/use-cases/get-entity-options-by-type.js +1 -1
- package/modules/use-cases/get-module-instance-from-type.js +1 -1
- package/modules/use-cases/get-module.js +10 -4
- package/modules/use-cases/manage-access.js +21 -0
- package/modules/use-cases/multi-step-authorization.js +329 -0
- package/modules/use-cases/process-authorization-callback.js +53 -19
- package/modules/use-cases/refresh-entity-options.js +10 -4
- package/modules/use-cases/test-module-auth.js +10 -4
- package/package.json +6 -7
- package/prisma-mongodb/schema.prisma +86 -59
- package/prisma-postgresql/migrations/20261003000000_add_authorization_session/migration.sql +28 -0
- package/prisma-postgresql/migrations/20261015000000_add_organization_membership/migration.sql +26 -0
- package/prisma-postgresql/migrations/20261016000000_add_entity_integration_organization/migration.sql +25 -0
- package/prisma-postgresql/migrations/20261017000000_add_scheduled_job/migration.sql +28 -0
- package/prisma-postgresql/schema.prisma +81 -57
- package/providers/index.js +23 -0
- package/providers/resolve-provider.js +93 -0
- package/providers/runtime-detection.js +124 -0
- package/queues/index.js +25 -0
- package/queues/providers/index.js +11 -0
- package/queues/providers/netlify-background-provider.js +150 -0
- package/queues/providers/qstash-queue-provider.js +219 -0
- package/queues/providers/sqs-queue-provider.js +70 -0
- package/queues/queue-client-interface.js +55 -0
- package/queues/queue-message-auth.js +193 -0
- package/queues/queue-provider-factory.js +101 -0
- package/queues/queue-provider.js +65 -0
- package/queues/queuer-util.js +2 -9
- package/queues/sqs-queue-client.js +81 -0
- package/types/index.d.ts +2 -0
- package/types/modules/index.d.ts +214 -0
- package/types/user/index.d.ts +134 -0
- package/user/adopter-jwt-config.js +177 -0
- package/user/adopter-jwt-errors.js +59 -0
- package/user/adopter-token-verifier.js +122 -0
- package/user/app-user-helpers.js +97 -0
- package/user/create-user-authentication.js +64 -0
- package/user/membership.js +51 -0
- package/user/repositories/organization-membership-record.js +19 -0
- package/user/repositories/organization-membership-repository-documentdb.js +106 -0
- package/user/repositories/organization-membership-repository-factory.js +42 -0
- package/user/repositories/organization-membership-repository-interface.js +57 -0
- package/user/repositories/organization-membership-repository-mongo.js +13 -0
- package/user/repositories/organization-membership-repository-postgres.js +29 -0
- package/user/repositories/organization-membership-repository-prisma.js +81 -0
- package/user/repositories/user-repository-documentdb.js +27 -2
- package/user/repositories/user-repository-interface.js +18 -0
- package/user/repositories/user-repository-mongo.js +24 -0
- package/user/repositories/user-repository-postgres.js +18 -0
- package/user/tests/doubles/adopter-jwt-fixtures.js +220 -0
- package/user/use-cases/authenticate-user.js +7 -1
- package/user/use-cases/ensure-organization-membership.js +92 -0
- package/user/use-cases/find-individual-users-by-organization.js +54 -0
- package/user/use-cases/get-user-from-adopter-jwt.js +95 -124
- package/user/use-cases/get-user-from-x-frigg-headers.js +83 -80
- package/user/user.js +64 -1
- package/errors/mapping-already-exists-error.js +0 -14
- package/handlers/workers/integration-triggers.js +0 -25
- package/infrastructure/scheduler/recurrence.js +0 -204
- package/integrations/define/DESIGN.md +0 -122
- package/integrations/define/config.js +0 -98
- package/integrations/define/define-app.js +0 -66
- package/integrations/define/define-extension.js +0 -154
- package/integrations/define/define-integration.js +0 -335
- package/integrations/define/examples/deal-alerts.js +0 -140
- package/integrations/define/extension-binding.js +0 -174
- package/integrations/define/index.js +0 -11
- package/integrations/define/json-schema-lite.js +0 -68
- package/integrations/define/subscriptions.js +0 -186
- package/integrations/define/tests/fixtures/hubspot.js +0 -109
- package/integrations/define/tests/fixtures/slack.js +0 -26
- package/integrations/define/use.js +0 -39
- package/integrations/definitions/README.md +0 -278
- package/integrations/definitions/canonical.js +0 -11
- package/integrations/definitions/capabilities/AUDIT.md +0 -480
- package/integrations/definitions/capabilities/acmeerp.capabilities.json +0 -633
- package/integrations/definitions/capabilities/asana.capabilities.json +0 -279
- package/integrations/definitions/capabilities/calendly.capabilities.json +0 -385
- package/integrations/definitions/capabilities/docusign.capabilities.json +0 -314
- package/integrations/definitions/capabilities/fathom.capabilities.json +0 -238
- package/integrations/definitions/capabilities/github.capabilities.json +0 -585
- package/integrations/definitions/capabilities/hubspot.capabilities.json +0 -822
- package/integrations/definitions/capabilities/jira.capabilities.json +0 -391
- package/integrations/definitions/capabilities/klaviyo.capabilities.json +0 -503
- package/integrations/definitions/capabilities/linear.capabilities.json +0 -378
- package/integrations/definitions/capabilities/netsuite.capabilities.json +0 -535
- package/integrations/definitions/capabilities/notion.capabilities.json +0 -208
- package/integrations/definitions/capabilities/phone.capabilities.json +0 -511
- package/integrations/definitions/capabilities/pipedrive.capabilities.json +0 -430
- package/integrations/definitions/capabilities/quickbooks.capabilities.json +0 -635
- package/integrations/definitions/capabilities/salesforce.capabilities.json +0 -568
- package/integrations/definitions/capabilities/shopify.capabilities.json +0 -1128
- package/integrations/definitions/capabilities/slack.capabilities.json +0 -373
- package/integrations/definitions/capabilities/stripe.capabilities.json +0 -630
- package/integrations/definitions/capabilities/webflow.capabilities.json +0 -196
- package/integrations/definitions/capabilities/zendesk.capabilities.json +0 -422
- package/integrations/definitions/compile.js +0 -80
- package/integrations/definitions/config-form.js +0 -137
- package/integrations/definitions/examples/acme-erp-quickbooks.definition.json +0 -467
- package/integrations/definitions/examples/asana-slack.definition.json +0 -219
- package/integrations/definitions/examples/calendly-salesforce.definition.json +0 -459
- package/integrations/definitions/examples/docusign-salesforce.definition.json +0 -305
- package/integrations/definitions/examples/fathom-hubspot-notion.definition.json +0 -575
- package/integrations/definitions/examples/github-linear.definition.json +0 -322
- package/integrations/definitions/examples/hubspot-slack.definition.json +0 -427
- package/integrations/definitions/examples/klaviyo-hubspot.definition.json +0 -336
- package/integrations/definitions/examples/phone-hubspot.definition.json +0 -633
- package/integrations/definitions/examples/pipedrive-hubspot.definition.json +0 -136
- package/integrations/definitions/examples/pipedrive-phone.definition.json +0 -340
- package/integrations/definitions/examples/records/phone-hubspot.definition-version.json +0 -652
- package/integrations/definitions/examples/records/phone-hubspot.integration.json +0 -86
- package/integrations/definitions/examples/records/phone-hubspot.mappings.json +0 -39
- package/integrations/definitions/examples/records/phone-hubspot.workflow-run.json +0 -62
- package/integrations/definitions/examples/shopify-klaviyo.definition.json +0 -488
- package/integrations/definitions/examples/shopify-netsuite.definition.json +0 -622
- package/integrations/definitions/examples/stripe-quickbooks.definition.json +0 -476
- package/integrations/definitions/examples/webflow-hubspot-slack.definition.json +0 -262
- package/integrations/definitions/examples/zendesk-jira.definition.json +0 -604
- package/integrations/definitions/expressions.js +0 -229
- package/integrations/definitions/index.js +0 -48
- package/integrations/definitions/integration-runtime.js +0 -779
- package/integrations/definitions/interpreter.js +0 -104
- package/integrations/definitions/manifests.js +0 -177
- package/integrations/definitions/renderers/common.js +0 -67
- package/integrations/definitions/renderers/html.js +0 -129
- package/integrations/definitions/renderers/hubspot.js +0 -59
- package/integrations/definitions/renderers/preview.js +0 -154
- package/integrations/definitions/renderers/slack.js +0 -146
- package/integrations/definitions/repositories/definition-version-repository.js +0 -67
- package/integrations/definitions/repositories/workflow-run-repository.js +0 -80
- package/integrations/definitions/router.js +0 -170
- package/integrations/definitions/runtime.js +0 -268
- package/integrations/definitions/schema/capability-manifest.v0.1.schema.json +0 -549
- package/integrations/definitions/schema/installation.v0.1.schema.json +0 -130
- package/integrations/definitions/schema/integration-definition.v0.1.schema.json +0 -909
- package/integrations/definitions/schema/records.md +0 -105
- package/integrations/definitions/schema-check.js +0 -58
- package/integrations/definitions/scripts/check-manifests.js +0 -220
- package/integrations/definitions/scripts/validate.js +0 -66
- package/integrations/definitions/steps.js +0 -123
- package/integrations/definitions/sync-engine.js +0 -297
- package/integrations/definitions/tests/helpers-fake-crm.js +0 -49
- package/integrations/definitions/transforms.js +0 -91
- package/integrations/definitions/use-cases/definition-use-cases.js +0 -245
- package/integrations/definitions/validate.js +0 -436
- package/integrations/definitions/versioning.js +0 -176
- package/integrations/definitions/webhooks.js +0 -119
- package/integrations/integration-types.js +0 -73
- package/integrations/triggers.js +0 -244
- package/integrations/use-cases/run-trigger-tick.js +0 -155
- package/integrations/use-cases/run-trigger.js +0 -77
- package/prisma-postgresql/migrations/20261018000000_add_data_defined_integrations/migration.sql +0 -66
- package/prisma-postgresql/migrations/20261019000000_workflow_run_waits/migration.sql +0 -7
- package/prisma-postgresql/migrations/20261019120000_definition_workspace/migration.sql +0 -5
|
@@ -1,117 +1,169 @@
|
|
|
1
1
|
const { createAppHandler } = require('./../app-handler-helpers');
|
|
2
|
-
const {
|
|
3
|
-
loadAppDefinition,
|
|
4
|
-
} = require('../app-definition-loader');
|
|
2
|
+
const { loadAppDefinition } = require('../app-definition-loader');
|
|
5
3
|
const express = require('express');
|
|
6
4
|
const { Router } = express;
|
|
7
5
|
const { loadRouterFromObject } = require('../backend-utils');
|
|
8
6
|
const { getExtensionRoutes } = require('../../integrations/extension');
|
|
9
7
|
|
|
10
|
-
const handlers = {};
|
|
11
|
-
const { integrations: integrationClasses } = loadAppDefinition();
|
|
12
|
-
|
|
13
8
|
const routeKey = (method, path) => `${(method || 'ANY').toUpperCase()} ${path}`;
|
|
14
9
|
|
|
15
10
|
// Serverless function keys must be alphanumeric; binding keys are developer-chosen.
|
|
16
11
|
const sanitizeBindingKey = (name) => String(name).replace(/[^A-Za-z0-9]/g, '');
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
for
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Builds the Express routers for every integration's Definition.routes and
|
|
15
|
+
* extension bindings. Pure: no handler wrapping, so the AWS handlers below
|
|
16
|
+
* and other hosts (provider-netlify's integration-routes function) mount the
|
|
17
|
+
* very same routers.
|
|
18
|
+
*
|
|
19
|
+
* @param {Array<Function>} integrationClasses
|
|
20
|
+
* @returns {Array<{ key: string, eventName: string, router: import('express').Router, useDatabase: boolean }>}
|
|
21
|
+
* One entry per integration, then one per extension binding (key
|
|
22
|
+
* `${name}__${binding}`), in declaration order.
|
|
23
|
+
*/
|
|
24
|
+
function buildIntegrationRouters(integrationClasses) {
|
|
25
|
+
const entries = [];
|
|
26
|
+
const keys = new Set();
|
|
27
|
+
//todo: this should be in a use case class
|
|
28
|
+
for (const IntegrationClass of integrationClasses) {
|
|
29
|
+
const router = Router();
|
|
30
|
+
const basePath = `/api/${IntegrationClass.Definition.name}-integration`;
|
|
31
|
+
// Track (method, path) tuples to fail fast on conflicts between Definition.routes,
|
|
32
|
+
// extension routes, or two extensions claiming the same path.
|
|
33
|
+
const claimedRoutes = new Map();
|
|
34
|
+
const claim = (method, path, source) => {
|
|
35
|
+
const key = routeKey(method, path);
|
|
36
|
+
if (claimedRoutes.has(key)) {
|
|
37
|
+
const prev = claimedRoutes.get(key);
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Integration "${IntegrationClass.Definition.name}" route conflict: ` +
|
|
40
|
+
`${key} declared by ${prev} and ${source}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
claimedRoutes.set(key, source);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
console.log(
|
|
47
|
+
`\n│ Configuring routes for ${IntegrationClass.Definition.name} Integration:`
|
|
48
|
+
);
|
|
36
49
|
|
|
37
|
-
|
|
50
|
+
const routes = IntegrationClass.Definition.routes || [];
|
|
51
|
+
for (const routeDef of routes) {
|
|
52
|
+
if (typeof routeDef === 'function') {
|
|
53
|
+
router.use(basePath, routeDef(IntegrationClass));
|
|
54
|
+
console.log(`│ ANY ${basePath}/* (function handler)`);
|
|
55
|
+
} else if (routeDef instanceof express.Router) {
|
|
56
|
+
router.use(basePath, routeDef);
|
|
57
|
+
console.log(`│ ANY ${basePath}/* (express router)`);
|
|
58
|
+
} else if (typeof routeDef === 'object') {
|
|
59
|
+
claim(routeDef.method, routeDef.path, 'Definition.routes');
|
|
60
|
+
router.use(
|
|
61
|
+
basePath,
|
|
62
|
+
loadRouterFromObject(IntegrationClass, routeDef)
|
|
63
|
+
);
|
|
64
|
+
const method = (routeDef.method || 'ANY').toUpperCase();
|
|
65
|
+
const fullPath = `${basePath}${routeDef.path}`;
|
|
66
|
+
console.log(`│ ${method} ${fullPath}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
38
69
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
// Each extension binding gets its own namespaced handler (/{bindingName}),
|
|
71
|
+
// so two modules' extensions can share a path like /webhooks without colliding.
|
|
72
|
+
const bindingGroups = new Map();
|
|
73
|
+
for (const extRoute of getExtensionRoutes(IntegrationClass)) {
|
|
74
|
+
const namespacedPath = `/${extRoute.bindingName}${extRoute.path}`;
|
|
75
|
+
claim(
|
|
76
|
+
extRoute.method,
|
|
77
|
+
namespacedPath,
|
|
78
|
+
`extension "${extRoute.extensionName}" (binding "${extRoute.bindingName}")`
|
|
79
|
+
);
|
|
80
|
+
if (!bindingGroups.has(extRoute.bindingName)) {
|
|
81
|
+
bindingGroups.set(extRoute.bindingName, {
|
|
82
|
+
router: Router(),
|
|
83
|
+
useDatabase: extRoute.useDatabase,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const group = bindingGroups.get(extRoute.bindingName);
|
|
87
|
+
group.router.use(
|
|
88
|
+
`${basePath}/${extRoute.bindingName}`,
|
|
89
|
+
loadRouterFromObject(IntegrationClass, extRoute)
|
|
90
|
+
);
|
|
91
|
+
console.log(
|
|
92
|
+
`│ ${extRoute.method.toUpperCase()} ${basePath}/${
|
|
93
|
+
extRoute.bindingName
|
|
94
|
+
}${extRoute.path} (extension: ${
|
|
95
|
+
extRoute.extensionName
|
|
96
|
+
}, useDatabase: ${extRoute.useDatabase})`
|
|
52
97
|
);
|
|
53
|
-
const method = (routeDef.method || 'ANY').toUpperCase();
|
|
54
|
-
const fullPath = `${basePath}${routeDef.path}`;
|
|
55
|
-
console.log(`│ ${method} ${fullPath}`);
|
|
56
98
|
}
|
|
57
|
-
|
|
99
|
+
console.log('│');
|
|
58
100
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
101
|
+
entries.push({
|
|
102
|
+
key: `${IntegrationClass.Definition.name}`,
|
|
103
|
+
eventName: `HTTP Event: ${IntegrationClass.Definition.name}`,
|
|
104
|
+
router,
|
|
105
|
+
useDatabase: true,
|
|
106
|
+
});
|
|
107
|
+
keys.add(`${IntegrationClass.Definition.name}`);
|
|
108
|
+
|
|
109
|
+
for (const [bindingName, group] of bindingGroups) {
|
|
110
|
+
// Wire contract: integration-builder.js (devtools) derives the identical
|
|
111
|
+
// function key for the serverless config. Keep both in sync.
|
|
112
|
+
const fnKey = `${
|
|
113
|
+
IntegrationClass.Definition.name
|
|
114
|
+
}__${sanitizeBindingKey(bindingName)}`;
|
|
115
|
+
// Distinct binding keys can sanitize to the same fnKey — fail loud rather than overwrite.
|
|
116
|
+
if (keys.has(fnKey)) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`Integration "${IntegrationClass.Definition.name}" extension handler conflict: ` +
|
|
119
|
+
`binding "${bindingName}" sanitizes to "${fnKey}", which is already taken. ` +
|
|
120
|
+
`Use binding keys that are distinct after stripping non-alphanumeric characters.`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
entries.push({
|
|
124
|
+
key: fnKey,
|
|
125
|
+
eventName: `HTTP Event: ${IntegrationClass.Definition.name} extension ${bindingName}`,
|
|
126
|
+
router: group.router,
|
|
127
|
+
useDatabase: group.useDatabase,
|
|
73
128
|
});
|
|
129
|
+
keys.add(fnKey);
|
|
74
130
|
}
|
|
75
|
-
const group = bindingGroups.get(extRoute.bindingName);
|
|
76
|
-
group.router.use(
|
|
77
|
-
`${basePath}/${extRoute.bindingName}`,
|
|
78
|
-
loadRouterFromObject(IntegrationClass, extRoute)
|
|
79
|
-
);
|
|
80
|
-
console.log(
|
|
81
|
-
`│ ${extRoute.method.toUpperCase()} ${basePath}/${extRoute.bindingName}${extRoute.path} (extension: ${extRoute.extensionName}, useDatabase: ${extRoute.useDatabase})`
|
|
82
|
-
);
|
|
83
131
|
}
|
|
84
|
-
|
|
132
|
+
return entries;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* One router serving every integration-defined route and extension binding,
|
|
137
|
+
* for hosts that run them all in one function (provider-netlify).
|
|
138
|
+
*
|
|
139
|
+
* @param {Array<Function>} [integrationClasses] - defaults to the app's.
|
|
140
|
+
* @returns {import('express').Router}
|
|
141
|
+
*/
|
|
142
|
+
function createIntegrationDefinedRouter(integrationClasses) {
|
|
143
|
+
const classes = integrationClasses || loadAppDefinition().integrations;
|
|
144
|
+
const combined = Router();
|
|
145
|
+
for (const entry of buildIntegrationRouters(classes)) {
|
|
146
|
+
combined.use(entry.router);
|
|
147
|
+
}
|
|
148
|
+
return combined;
|
|
149
|
+
}
|
|
85
150
|
|
|
86
|
-
|
|
151
|
+
// The AWS handlers (one Lambda per integration and per extension binding,
|
|
152
|
+
// see devtools integration-builder). Built at require time on purpose: a
|
|
153
|
+
// route conflict fails the cold start, not the first request.
|
|
154
|
+
const handlers = {};
|
|
155
|
+
for (const entry of buildIntegrationRouters(loadAppDefinition().integrations)) {
|
|
156
|
+
handlers[entry.key] = {
|
|
87
157
|
handler: createAppHandler(
|
|
88
|
-
|
|
89
|
-
router
|
|
158
|
+
entry.eventName,
|
|
159
|
+
entry.router,
|
|
160
|
+
entry.useDatabase
|
|
90
161
|
),
|
|
91
162
|
};
|
|
92
|
-
|
|
93
|
-
for (const [bindingName, group] of bindingGroups) {
|
|
94
|
-
// Wire contract: integration-builder.js (devtools) derives the identical
|
|
95
|
-
// function key for the serverless config. Keep both in sync.
|
|
96
|
-
const fnKey = `${IntegrationClass.Definition.name}__${sanitizeBindingKey(
|
|
97
|
-
bindingName
|
|
98
|
-
)}`;
|
|
99
|
-
// Distinct binding keys can sanitize to the same fnKey — fail loud rather than overwrite.
|
|
100
|
-
if (Object.prototype.hasOwnProperty.call(handlers, fnKey)) {
|
|
101
|
-
throw new Error(
|
|
102
|
-
`Integration "${IntegrationClass.Definition.name}" extension handler conflict: ` +
|
|
103
|
-
`binding "${bindingName}" sanitizes to "${fnKey}", which is already taken. ` +
|
|
104
|
-
`Use binding keys that are distinct after stripping non-alphanumeric characters.`
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
handlers[fnKey] = {
|
|
108
|
-
handler: createAppHandler(
|
|
109
|
-
`HTTP Event: ${IntegrationClass.Definition.name} extension ${bindingName}`,
|
|
110
|
-
group.router,
|
|
111
|
-
group.useDatabase
|
|
112
|
-
),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
163
|
}
|
|
116
164
|
|
|
117
|
-
module.exports = {
|
|
165
|
+
module.exports = {
|
|
166
|
+
handlers,
|
|
167
|
+
buildIntegrationRouters,
|
|
168
|
+
createIntegrationDefinedRouter,
|
|
169
|
+
};
|
|
@@ -6,70 +6,120 @@ const {
|
|
|
6
6
|
IntegrationEventDispatcher,
|
|
7
7
|
} = require('../integration-event-dispatcher');
|
|
8
8
|
|
|
9
|
-
const handlers = {};
|
|
10
|
-
const { integrations: integrationClasses } = loadAppDefinition();
|
|
11
|
-
|
|
12
9
|
// `webhooks.received` is counted at the DB-connected ON_WEBHOOK dispatch (see
|
|
13
10
|
// usage-rollup-subscriber), not in this DB-free receipt handler.
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Builds the webhook receiver router for every integration with webhooks
|
|
14
|
+
* enabled. Pure: no handler wrapping, so the AWS handlers below and other
|
|
15
|
+
* hosts (provider-netlify's webhooks function) mount the same routers.
|
|
16
|
+
*
|
|
17
|
+
* @param {Array<Function>} integrationClasses
|
|
18
|
+
* @returns {Array<{ key: string, eventName: string, router: import('express').Router }>}
|
|
19
|
+
*/
|
|
20
|
+
function buildWebhookRouters(integrationClasses) {
|
|
21
|
+
const entries = [];
|
|
22
|
+
for (const IntegrationClass of integrationClasses) {
|
|
23
|
+
const webhookConfig = IntegrationClass.Definition.webhooks;
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// drives usage attribution.
|
|
33
|
-
await (integrationId ? runInContext({ [LOGGER_SCOPE_KEY]: { integrationId } }, dispatch) : dispatch());
|
|
34
|
-
} catch (error) {
|
|
35
|
-
next(error);
|
|
25
|
+
// Skip if webhooks not enabled
|
|
26
|
+
if (
|
|
27
|
+
!webhookConfig ||
|
|
28
|
+
(typeof webhookConfig === 'object' && !webhookConfig.enabled)
|
|
29
|
+
) {
|
|
30
|
+
continue;
|
|
36
31
|
}
|
|
37
|
-
};
|
|
38
|
-
const basePath = `/api/${IntegrationClass.Definition.name}-integration/webhooks`;
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const router = Router();
|
|
34
|
+
const basePath = `/api/${IntegrationClass.Definition.name}-integration/webhooks`;
|
|
35
|
+
|
|
36
|
+
console.log(
|
|
37
|
+
`\n│ Configuring webhook routes for ${IntegrationClass.Definition.name}:`
|
|
38
|
+
);
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
// General webhook route (no integration ID)
|
|
41
|
+
router.post(basePath, async (req, res, next) => {
|
|
42
|
+
try {
|
|
43
|
+
const integrationInstance = new IntegrationClass();
|
|
44
|
+
const dispatcher = new IntegrationEventDispatcher(
|
|
45
|
+
integrationInstance
|
|
46
|
+
);
|
|
47
|
+
await dispatcher.dispatchHttp({
|
|
48
|
+
event: 'WEBHOOK_RECEIVED',
|
|
49
|
+
req,
|
|
50
|
+
res,
|
|
51
|
+
next,
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
next(error);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
console.log(`│ POST ${basePath}`);
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
// Integration-specific webhook route (with integration ID)
|
|
60
|
+
router.post(`${basePath}/:integrationId`, async (req, res, next) => {
|
|
61
|
+
try {
|
|
62
|
+
const integrationInstance = new IntegrationClass();
|
|
63
|
+
const dispatcher = new IntegrationEventDispatcher(
|
|
64
|
+
integrationInstance
|
|
65
|
+
);
|
|
66
|
+
// Logs only: the id comes from an unauthenticated URL, so it must
|
|
67
|
+
// not reach the telemetry context that drives usage attribution.
|
|
68
|
+
await runInContext(
|
|
69
|
+
{
|
|
70
|
+
[LOGGER_SCOPE_KEY]: {
|
|
71
|
+
integrationId: req.params.integrationId,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
() =>
|
|
75
|
+
dispatcher.dispatchHttp({
|
|
76
|
+
event: 'WEBHOOK_RECEIVED',
|
|
77
|
+
req,
|
|
78
|
+
res,
|
|
79
|
+
next,
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
next(error);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
console.log(`│ POST ${basePath}/:integrationId`);
|
|
87
|
+
console.log('│');
|
|
51
88
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Registered integrations keep their own routes (a local server mounts every router on one app).
|
|
58
|
-
const registered = new Set(integrationClasses.map((c) => `${c.Definition.name}-integration`));
|
|
59
|
-
const isProvidedPath = (req) => /^[A-Za-z0-9_.-]+-integration$/.test(req.params.integrationType || '') && !registered.has(req.params.integrationType);
|
|
60
|
-
router.post(providedPath, (req, res, next) => (isProvidedPath(req) ? receive(req, res, next) : next()));
|
|
61
|
-
router.post(`${providedPath}/:integrationId`, (req, res, next) => (isProvidedPath(req) ? receive(req, res, next, req.params.integrationId) : next()));
|
|
62
|
-
console.log(`│ POST /api/<provided type>-integration/webhooks[/:integrationId]`);
|
|
89
|
+
entries.push({
|
|
90
|
+
key: `${IntegrationClass.Definition.name}Webhook`,
|
|
91
|
+
eventName: `HTTP Event: ${IntegrationClass.Definition.name} Webhook`,
|
|
92
|
+
router,
|
|
93
|
+
});
|
|
63
94
|
}
|
|
64
|
-
|
|
95
|
+
return entries;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* One router serving every integration's webhook routes, for hosts that run
|
|
100
|
+
* them all in one function (provider-netlify).
|
|
101
|
+
*
|
|
102
|
+
* @param {Array<Function>} [integrationClasses] - defaults to the app's.
|
|
103
|
+
* @returns {import('express').Router}
|
|
104
|
+
*/
|
|
105
|
+
function createWebhookRouter(integrationClasses) {
|
|
106
|
+
const classes = integrationClasses || loadAppDefinition().integrations;
|
|
107
|
+
const combined = Router();
|
|
108
|
+
for (const entry of buildWebhookRouters(classes)) {
|
|
109
|
+
combined.use(entry.router);
|
|
110
|
+
}
|
|
111
|
+
return combined;
|
|
112
|
+
}
|
|
65
113
|
|
|
66
|
-
|
|
114
|
+
const handlers = {};
|
|
115
|
+
for (const entry of buildWebhookRouters(loadAppDefinition().integrations)) {
|
|
116
|
+
handlers[entry.key] = {
|
|
67
117
|
handler: createAppHandler(
|
|
68
|
-
|
|
69
|
-
router,
|
|
118
|
+
entry.eventName,
|
|
119
|
+
entry.router,
|
|
70
120
|
false // shouldUseDatabase = false
|
|
71
121
|
),
|
|
72
122
|
};
|
|
73
123
|
}
|
|
74
124
|
|
|
75
|
-
module.exports = { handlers };
|
|
125
|
+
module.exports = { handlers, buildWebhookRouters, createWebhookRouter };
|
|
@@ -10,10 +10,13 @@ const { createQueueWorker } = require('../backend-utils');
|
|
|
10
10
|
// const { getExtensionWorkers } = require('../../integrations/extension');
|
|
11
11
|
|
|
12
12
|
const handlers = {};
|
|
13
|
-
const { integrations: integrationClasses } =
|
|
13
|
+
const { integrations: integrationClasses, moduleDefinitions } =
|
|
14
|
+
loadAppDefinition();
|
|
14
15
|
|
|
15
16
|
integrationClasses.forEach((IntegrationClass) => {
|
|
16
|
-
const defaultQueueWorker = createQueueWorker(IntegrationClass
|
|
17
|
+
const defaultQueueWorker = createQueueWorker(IntegrationClass, {
|
|
18
|
+
moduleDefinitions,
|
|
19
|
+
});
|
|
17
20
|
|
|
18
21
|
handlers[`${IntegrationClass.Definition.name}`] = {
|
|
19
22
|
queueWorker: createHandler({
|
package/index.js
CHANGED
|
@@ -25,6 +25,14 @@ const {
|
|
|
25
25
|
UserRepositoryMongo,
|
|
26
26
|
UserRepositoryPostgres,
|
|
27
27
|
} = require('./user/repositories/user-repository-factory');
|
|
28
|
+
const {
|
|
29
|
+
createOrganizationMembershipRepository,
|
|
30
|
+
OrganizationMembershipRepositoryMongo,
|
|
31
|
+
OrganizationMembershipRepositoryPostgres,
|
|
32
|
+
} = require('./user/repositories/organization-membership-repository-factory');
|
|
33
|
+
const {
|
|
34
|
+
EnsureOrganizationMembership,
|
|
35
|
+
} = require('./user/use-cases/ensure-organization-membership');
|
|
28
36
|
const {
|
|
29
37
|
GetUserFromXFriggHeaders,
|
|
30
38
|
} = require('./user/use-cases/get-user-from-x-frigg-headers');
|
|
@@ -57,7 +65,6 @@ const {
|
|
|
57
65
|
HaltError,
|
|
58
66
|
RequiredPropertyError,
|
|
59
67
|
ParameterTypeError,
|
|
60
|
-
MappingAlreadyExistsError,
|
|
61
68
|
} = require('./errors/index');
|
|
62
69
|
const {
|
|
63
70
|
IntegrationBase,
|
|
@@ -66,12 +73,6 @@ const {
|
|
|
66
73
|
checkRequiredParams,
|
|
67
74
|
getModulesDefinitionFromIntegrationClasses,
|
|
68
75
|
LoadIntegrationContextUseCase,
|
|
69
|
-
defineIntegration,
|
|
70
|
-
defineApp,
|
|
71
|
-
use,
|
|
72
|
-
defineExtension,
|
|
73
|
-
reconcileAppSubscriptions,
|
|
74
|
-
createReconcileSubscriptionsScript,
|
|
75
76
|
} = require('./integrations/index');
|
|
76
77
|
const {
|
|
77
78
|
ReportBase,
|
|
@@ -106,11 +107,36 @@ const {
|
|
|
106
107
|
Requester,
|
|
107
108
|
ModuleConstants,
|
|
108
109
|
ModuleFactory,
|
|
110
|
+
getEntityTypeRegistry,
|
|
111
|
+
EntityRegistryError,
|
|
112
|
+
resolveScope,
|
|
113
|
+
listBindingScopes,
|
|
114
|
+
OwnershipConfigError,
|
|
109
115
|
} = require('./modules/index');
|
|
116
|
+
const {
|
|
117
|
+
ManagementApiConfigError,
|
|
118
|
+
} = require('./management-api/management-api-config');
|
|
110
119
|
const application = require('./application');
|
|
111
120
|
const utils = require('./utils');
|
|
112
121
|
|
|
113
|
-
const {
|
|
122
|
+
const {
|
|
123
|
+
QueuerUtil,
|
|
124
|
+
QueueProvider,
|
|
125
|
+
QueueClientInterface,
|
|
126
|
+
createQueueProvider,
|
|
127
|
+
QUEUE_PROVIDERS,
|
|
128
|
+
} = require('./queues');
|
|
129
|
+
const {
|
|
130
|
+
resolveProvider,
|
|
131
|
+
determineProviderName,
|
|
132
|
+
providerPackageName,
|
|
133
|
+
KNOWN_PROVIDERS,
|
|
134
|
+
isDeployedRuntime,
|
|
135
|
+
} = require('./providers');
|
|
136
|
+
|
|
137
|
+
// App-level core extensions (appDefinition.coreExtensions): Prisma models, encrypted
|
|
138
|
+
// fields, admin routes and bootstrap hooks (friggframework/frigg#545).
|
|
139
|
+
const extensions = require('./extensions');
|
|
114
140
|
|
|
115
141
|
module.exports = {
|
|
116
142
|
// assertions
|
|
@@ -137,6 +163,10 @@ module.exports = {
|
|
|
137
163
|
createUserRepository,
|
|
138
164
|
UserRepositoryMongo,
|
|
139
165
|
UserRepositoryPostgres,
|
|
166
|
+
createOrganizationMembershipRepository,
|
|
167
|
+
OrganizationMembershipRepositoryMongo,
|
|
168
|
+
OrganizationMembershipRepositoryPostgres,
|
|
169
|
+
EnsureOrganizationMembership,
|
|
140
170
|
GetUserFromXFriggHeaders,
|
|
141
171
|
GetUserFromAdopterJwt,
|
|
142
172
|
AuthenticateUser,
|
|
@@ -151,22 +181,15 @@ module.exports = {
|
|
|
151
181
|
HaltError,
|
|
152
182
|
RequiredPropertyError,
|
|
153
183
|
ParameterTypeError,
|
|
154
|
-
MappingAlreadyExistsError,
|
|
155
184
|
|
|
156
185
|
// integrations
|
|
157
186
|
IntegrationBase,
|
|
158
187
|
Options,
|
|
159
188
|
checkRequiredParams,
|
|
160
189
|
createIntegrationRouter,
|
|
190
|
+
// Deprecated (ADR-059): use getEntityTypeRegistry.
|
|
161
191
|
getModulesDefinitionFromIntegrationClasses,
|
|
162
192
|
LoadIntegrationContextUseCase,
|
|
163
|
-
// one-file integrations (ADR-054)
|
|
164
|
-
defineIntegration,
|
|
165
|
-
defineApp,
|
|
166
|
-
use,
|
|
167
|
-
defineExtension,
|
|
168
|
-
reconcileAppSubscriptions,
|
|
169
|
-
createReconcileSubscriptionsScript,
|
|
170
193
|
CreateProcess,
|
|
171
194
|
UpdateProcessState,
|
|
172
195
|
UpdateProcessMetrics,
|
|
@@ -221,8 +244,35 @@ module.exports = {
|
|
|
221
244
|
Requester,
|
|
222
245
|
ModuleConstants,
|
|
223
246
|
ModuleFactory,
|
|
247
|
+
getEntityTypeRegistry,
|
|
248
|
+
EntityRegistryError,
|
|
249
|
+
resolveScope,
|
|
250
|
+
listBindingScopes,
|
|
251
|
+
OwnershipConfigError,
|
|
252
|
+
ManagementApiConfigError,
|
|
224
253
|
// queues
|
|
225
254
|
QueuerUtil,
|
|
255
|
+
QueueProvider,
|
|
256
|
+
QueueClientInterface,
|
|
257
|
+
createQueueProvider,
|
|
258
|
+
QUEUE_PROVIDERS,
|
|
259
|
+
|
|
260
|
+
// provider plugins (appDefinition.provider)
|
|
261
|
+
resolveProvider,
|
|
262
|
+
determineProviderName,
|
|
263
|
+
providerPackageName,
|
|
264
|
+
KNOWN_PROVIDERS,
|
|
265
|
+
isDeployedRuntime,
|
|
266
|
+
|
|
267
|
+
// app-level extensions
|
|
268
|
+
extensions,
|
|
269
|
+
loadExtensions: extensions.loadExtensions,
|
|
270
|
+
composeSchemas: extensions.composeSchemas,
|
|
271
|
+
composeExtensionPrisma: extensions.composeExtensionPrisma,
|
|
272
|
+
mountExtensionRoutes: extensions.mountExtensionRoutes,
|
|
273
|
+
createExtensionRoutesRouter: extensions.createExtensionRoutesRouter,
|
|
274
|
+
runExtensionBootstraps: extensions.runExtensionBootstraps,
|
|
275
|
+
initializeApp: extensions.initializeApp,
|
|
226
276
|
|
|
227
277
|
// utils
|
|
228
278
|
...utils,
|
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
* Follows hexagonal architecture with interface + adapters pattern.
|
|
6
6
|
*
|
|
7
7
|
* Providers:
|
|
8
|
-
* - eventbridge: AWS EventBridge Scheduler (production)
|
|
8
|
+
* - eventbridge: AWS EventBridge Scheduler (production on AWS)
|
|
9
|
+
* - netlify: poll-and-dispatch from a Netlify scheduled function
|
|
9
10
|
* - mock: In-memory mock scheduler (local development)
|
|
11
|
+
*
|
|
12
|
+
* Adapters are lazy getters (friggframework/frigg#545, 1176a004): the
|
|
13
|
+
* EventBridge adapter requires @aws-sdk/client-scheduler, which is not a
|
|
14
|
+
* core dependency, and core/index -> application -> scheduler-commands ->
|
|
15
|
+
* this barrel runs on every require('@friggframework/core'). An eager
|
|
16
|
+
* require crashed any deployment without that SDK (e.g. a pruned Netlify
|
|
17
|
+
* function bundle).
|
|
10
18
|
*/
|
|
11
19
|
|
|
12
20
|
const { SchedulerServiceInterface } = require('./scheduler-service-interface');
|
|
13
|
-
const { EventBridgeSchedulerAdapter } = require('./eventbridge-scheduler-adapter');
|
|
14
|
-
const { MockSchedulerAdapter } = require('./mock-scheduler-adapter');
|
|
15
21
|
const {
|
|
16
22
|
createSchedulerService,
|
|
17
23
|
SCHEDULER_PROVIDERS,
|
|
@@ -22,9 +28,16 @@ module.exports = {
|
|
|
22
28
|
// Interface (Port)
|
|
23
29
|
SchedulerServiceInterface,
|
|
24
30
|
|
|
25
|
-
// Adapters
|
|
26
|
-
EventBridgeSchedulerAdapter
|
|
27
|
-
|
|
31
|
+
// Adapters (loaded on access)
|
|
32
|
+
get EventBridgeSchedulerAdapter() {
|
|
33
|
+
return require('./eventbridge-scheduler-adapter').EventBridgeSchedulerAdapter;
|
|
34
|
+
},
|
|
35
|
+
get MockSchedulerAdapter() {
|
|
36
|
+
return require('./mock-scheduler-adapter').MockSchedulerAdapter;
|
|
37
|
+
},
|
|
38
|
+
get NetlifySchedulerAdapter() {
|
|
39
|
+
return require('./netlify-scheduler-adapter').NetlifySchedulerAdapter;
|
|
40
|
+
},
|
|
28
41
|
|
|
29
42
|
// Factory
|
|
30
43
|
createSchedulerService,
|