@friggframework/devtools 2.0.0--canary.711.f8b6445.0 → 2.0.0--canary.667.f74cf3b.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/frigg-cli/README.md +30 -77
  2. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  3. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -594
  4. package/frigg-cli/generate-command/index.js +0 -1
  5. package/frigg-cli/generate-iam-command.js +0 -1
  6. package/frigg-cli/index.js +4 -9
  7. package/frigg-cli/init-command/backend-first-handler.js +554 -397
  8. package/frigg-cli/init-command/index.js +35 -82
  9. package/frigg-cli/install-command/commit-changes.js +8 -40
  10. package/frigg-cli/install-command/environment-variables.js +0 -15
  11. package/frigg-cli/install-command/index.js +21 -96
  12. package/frigg-cli/install-command/install-package.js +4 -77
  13. package/frigg-cli/install-command/integration-file.js +11 -20
  14. package/frigg-cli/install-command/template.js +75 -102
  15. package/frigg-cli/install-command/validate-package.js +4 -36
  16. package/frigg-cli/package.json +1 -1
  17. package/frigg-cli/test/init-command.test.js +2 -9
  18. package/infrastructure/__tests__/management-api-gateway-routes.test.js +281 -0
  19. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
  20. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
  21. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
  22. package/infrastructure/domains/database/aurora-builder.js +2 -13
  23. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  24. package/infrastructure/domains/security/iam-generator.js +5 -112
  25. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  26. package/infrastructure/domains/shared/utilities/base-definition-factory.js +21 -7
  27. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +13 -22
  28. package/package.json +8 -10
  29. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  30. package/frigg-cli/init-command/deployment-modes.js +0 -7
  31. package/frigg-cli/init-command/safe-path.js +0 -58
  32. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  33. package/frigg-cli/install-command/app-definition.js +0 -174
  34. package/frigg-cli/install-command/resolve-module.js +0 -69
  35. package/frigg-cli/templates/backend/README.md +0 -267
  36. package/frigg-cli/templates/backend/env.example +0 -20
  37. package/frigg-cli/templates/backend/gitignore +0 -10
  38. package/frigg-cli/templates/backend/index.js +0 -114
  39. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  40. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
@@ -1,117 +1,90 @@
1
- /**
2
- * Source for a new integration class (`src/integrations/<Name>Integration.js`)
3
- * that wraps one installed API module.
4
- *
5
- * It follows the current IntegrationBase contract: a static `Definition`
6
- * (name, version, display, `modules: { <key>: { definition } }`) and event
7
- * handlers registered on `this.events` in the constructor. Calls to the API
8
- * module go through `this.<key>.api.<method>()`.
9
- */
1
+ const path = require('path');
10
2
 
11
- /** Turn an arbitrary label (e.g. "Google Drive", "Monday.com") into a JS identifier. */
12
- function toIdentifier(label) {
13
- const words = String(label)
14
- .split(/[^A-Za-z0-9]+/)
15
- .filter(Boolean);
16
- let identifier = words
17
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
18
- .join('');
19
- if (!identifier) {
20
- identifier = 'Module';
21
- }
22
- if (/^[0-9]/.test(identifier)) {
23
- identifier = `Module${identifier}`;
24
- }
25
- return identifier;
26
- }
3
+ function getIntegrationTemplate(apiModuleName, backendPath, ApiClass) {
4
+ // Find the sample data method
5
+ const apiMethods = Object.getOwnPropertyNames(ApiClass.prototype);
6
+ const sampleDataMethod =
7
+ apiMethods.find(
8
+ (method) =>
9
+ method.toLowerCase().includes('search') ||
10
+ method.toLowerCase().includes('list') ||
11
+ method.toLowerCase().includes('get')
12
+ ) || 'searchDeals';
27
13
 
28
- /** camelCase key for `Definition.modules` (e.g. "google-drive" -> "googleDrive"). */
29
- function toModuleKey(moduleName) {
30
- const words = String(moduleName)
31
- .split(/[^A-Za-z0-9]+/)
32
- .filter(Boolean);
33
- if (words.length === 0) {
34
- return 'module';
35
- }
36
- const key = words
37
- .map((word, i) =>
38
- i === 0
39
- ? word.charAt(0).toLowerCase() + word.slice(1)
40
- : word.charAt(0).toUpperCase() + word.slice(1)
41
- )
42
- .join('');
43
- return /^[0-9]/.test(key) ? `module${key}` : key;
44
- }
14
+ return `const { get, IntegrationBase, Options } = require('@friggframework/core');
15
+ const { Definition: ${apiModuleName}Module, Config: defaultConfig } = require('@friggframework/api-module-${apiModuleName.toLowerCase()}');
45
16
 
46
- const quote = (value) => JSON.stringify(value === undefined ? '' : value);
17
+ class ${apiModuleName}Integration extends IntegrationBase {
18
+ static Config = {
19
+ name: defaultConfig.name || '${apiModuleName.toLowerCase()}',
20
+ version: '1.0.0',
21
+ supportedVersions: ['1.0.0'],
22
+ events: ['SEARCH_DEALS'],
23
+ };
47
24
 
48
- /**
49
- * @param {object} params
50
- * @param {string} params.className - e.g. `HubSpotIntegration`
51
- * @param {string} params.packageName - e.g. `@friggframework/api-module-hubspot`
52
- * @param {string} params.moduleName - The module's `Definition.getName()`
53
- * @param {string} params.label - Human-readable name
54
- * @param {string} [params.description]
55
- * @param {string} [params.detailsUrl]
56
- * @param {string} [params.icon]
57
- * @param {string[]} [params.categories]
58
- * @returns {string}
59
- */
60
- function getIntegrationTemplate({
61
- className,
62
- packageName,
63
- moduleName,
64
- label,
65
- description,
66
- detailsUrl,
67
- icon,
68
- categories,
69
- }) {
70
- const moduleKey = toModuleKey(moduleName);
71
- const moduleVar = `${moduleKey}Module`;
72
- const category = Array.isArray(categories) ? categories.join(', ') : '';
25
+ static Options =
26
+ new Options({
27
+ module: ${apiModuleName}Module,
28
+ integrations: [${apiModuleName}Module],
29
+ display: {
30
+ name: defaultConfig.displayName || '${apiModuleName}',
31
+ description: defaultConfig.description || 'Sales & CRM, Marketing',
32
+ category: defaultConfig.category || 'Sales & CRM, Marketing',
33
+ detailsUrl: defaultConfig.detailsUrl || 'https://www.${apiModuleName.toLowerCase()}.com',
34
+ icon: defaultConfig.icon || 'https://friggframework.org/assets/img/${apiModuleName.toLowerCase()}.jpeg',
35
+ },
36
+ hasUserConfig: true,
37
+ });
73
38
 
74
- return `const { IntegrationBase } = require('@friggframework/core');
75
- const ${moduleVar} = require(${quote(packageName)});
39
+ static modules = {
40
+ ${apiModuleName.toLowerCase()}: ${apiModuleName}Module,
41
+ }
76
42
 
77
- class ${className} extends IntegrationBase {
78
- static Definition = {
79
- name: ${quote(moduleName)},
80
- version: '1.0.0',
81
- supportedVersions: ['1.0.0'],
82
- hasUserConfig: false,
43
+ /**
44
+ * HANDLE EVENTS
45
+ */
46
+ async receiveNotification(notifier, event, object = null) {
47
+ if (event === 'SEARCH_DEALS') {
48
+ return this.target.api.searchDeals(object);
49
+ }
50
+ }
83
51
 
84
- display: {
85
- label: ${quote(label)},
86
- description: ${quote(description)},
87
- category: ${quote(category)},
88
- detailsUrl: ${quote(detailsUrl)},
89
- icon: ${quote(icon)},
90
- },
52
+ /**
53
+ * ALL CUSTOM/OPTIONAL METHODS FOR AN INTEGRATION MANAGER
54
+ */
55
+ async getSampleData() {
56
+ const res = await this.target.api.${sampleDataMethod}();
57
+ return { data: res };
58
+ }
91
59
 
92
- // The API modules this integration uses. Each key becomes
93
- // \`this.<key>\` on an integration instance, e.g.
94
- // \`this.${moduleKey}.api\`.
95
- modules: {
96
- ${moduleKey}: { definition: ${moduleVar}.Definition },
97
- },
60
+ /**
61
+ * ALL REQUIRED METHODS FOR AN INTEGRATION MANAGER
62
+ */
63
+ async onCreate(params) {
64
+ // Validate that we have all of the data we need
65
+ // Set integration status as makes sense. Default ENABLED
66
+ // TODO turn this into a validateConfig method/function
67
+ this.record.status = 'ENABLED';
68
+ await this.record.save();
69
+ return this.record;
70
+ }
98
71
 
99
- // HTTP routes, served under /api/${moduleName}-integration/...
100
- // e.g. { path: '/sample', method: 'GET', event: 'GET_SAMPLE_DATA' }
101
- routes: [],
102
- };
72
+ async onUpdate(params) {
73
+ const newConfig = get(params, 'config');
74
+ const oldConfig = this.record.config;
75
+ // Just save whatever
76
+ this.record.markModified('config');
77
+ await this.record.save();
78
+ return this.validateConfig();
79
+ }
103
80
 
104
- constructor(params) {
105
- super(params);
106
- this.events = {
107
- // Map event names to handlers, e.g.
108
- // GET_SAMPLE_DATA: { handler: this.getSampleData.bind(this) },
109
- };
81
+ async getConfigOptions() {
82
+ const options = {}
83
+ return options;
110
84
  }
111
85
  }
112
86
 
113
- module.exports = ${className};
114
- `;
87
+ module.exports = ${apiModuleName}Integration;`;
115
88
  }
116
89
 
117
- module.exports = { getIntegrationTemplate, toIdentifier, toModuleKey };
90
+ module.exports = { getIntegrationTemplate };
@@ -1,28 +1,12 @@
1
- const spawn = require('cross-spawn');
1
+ const { execSync } = require('child_process');
2
2
  const axios = require('axios');
3
3
  const { logError } = require('./logger');
4
4
  const { checkbox } = require('@inquirer/prompts');
5
5
 
6
- const API_MODULE_PREFIX = '@friggframework/api-module-';
7
-
8
6
  async function searchPackages(apiModuleName) {
9
- // Arguments are passed as an array (no shell), so the search term can
10
- // never be interpreted as a command.
11
- const result = spawn.sync(
12
- 'npm',
13
- ['search', `${API_MODULE_PREFIX}${apiModuleName}`, '--json'],
14
- { encoding: 'utf8' }
15
- );
16
- if (result.error) {
17
- throw result.error;
18
- }
19
- if (result.status !== 0) {
20
- throw new Error(`npm search failed: ${result.stderr || result.status}`);
21
- }
22
- // npm search is a full-text search; keep only Frigg API modules.
23
- return JSON.parse(result.stdout || '[]').filter(
24
- (pkg) => pkg && pkg.name && pkg.name.startsWith(API_MODULE_PREFIX)
25
- );
7
+ const searchCommand = `npm search @friggframework/api-module-${apiModuleName} --json`;
8
+ const result = execSync(searchCommand, { encoding: 'utf8' });
9
+ return JSON.parse(result);
26
10
  }
27
11
 
28
12
  async function checkPackageExists(packageName) {
@@ -74,21 +58,6 @@ const searchAndSelectPackage = async (apiModuleName) => {
74
58
  };
75
59
  });
76
60
 
77
- // Without a terminal to prompt on, take the exact match
78
- // (`frigg install hubspot` -> @friggframework/api-module-hubspot).
79
- if (!process.stdin.isTTY) {
80
- const exact = `${API_MODULE_PREFIX}${apiModuleName}`;
81
- if (filteredResults.some((pkg) => pkg.name === exact)) {
82
- return [exact];
83
- }
84
- logError(
85
- `No exact match for ${exact}, and there is no terminal to choose from: ${filteredResults
86
- .map((pkg) => pkg.name)
87
- .join(', ')}`
88
- );
89
- process.exit(1);
90
- }
91
-
92
61
  const selectedPackages = await checkbox({
93
62
  message: 'Select the packages to install:',
94
63
  choices,
@@ -99,7 +68,6 @@ const searchAndSelectPackage = async (apiModuleName) => {
99
68
  };
100
69
 
101
70
  module.exports = {
102
- API_MODULE_PREFIX,
103
71
  validatePackageExists,
104
72
  checkPackageExists,
105
73
  searchPackages,
@@ -26,7 +26,7 @@
26
26
  "lodash": "4.18.1",
27
27
  "node-cache": "^5.1.2",
28
28
  "open": "^8.4.2",
29
- "osls": "^3.78.0",
29
+ "osls": "^3.58.0",
30
30
  "semver": "^7.6.0",
31
31
  "validate-npm-package-name": "^5.0.0"
32
32
  },
@@ -123,19 +123,12 @@ describe('Init Command', () => {
123
123
  );
124
124
  });
125
125
 
126
- it('forwards every supported init flag to BackendFirstHandler', async () => {
127
- // The flags `frigg init` registers and initCommand forwards
128
- // (see init-command/index.js). `yes` is the non-interactive flag
129
- // (`--yes`: accept defaults, no prompts); `install: false` and
130
- // `git: false` are what `--no-install` / `--no-git` produce. The
131
- // old `frontend` option is gone: init scaffolds a backend only.
126
+ it('should pass options to BackendFirstHandler', async () => {
132
127
  const options = {
133
128
  force: true,
134
129
  verbose: true,
135
130
  mode: 'standalone',
136
- yes: true,
137
- install: false,
138
- git: false
131
+ frontend: false
139
132
  };
140
133
 
141
134
  await initCommand(mockProjectName, options);
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Management API ↔ API Gateway route coverage
3
+ *
4
+ * The Management API is an Express app (core's createIntegrationRouter)
5
+ * served by the `auth` Lambda. API Gateway HTTP APIs have no implicit
6
+ * catch-all: a request whose path matches no declared route gets a gateway
7
+ * 404 and never reaches Express. So every route the integration router
8
+ * registers must be covered by an httpApi event on the `auth` function, and
9
+ * no more-specific route on another function may shadow it.
10
+ *
11
+ * The Express routes are read from the live router (not a hard-coded list),
12
+ * so a route added to core later fails this test until the gateway routes
13
+ * are updated alongside it.
14
+ */
15
+
16
+ // Avoid AWS calls: hand the builders a fixed discovery result.
17
+ jest.mock('../domains/shared/resource-discovery', () => {
18
+ const actual = jest.requireActual('../domains/shared/resource-discovery');
19
+ return {
20
+ ...actual,
21
+ gatherDiscoveredResources: jest.fn().mockResolvedValue({
22
+ defaultVpcId: 'vpc-123456',
23
+ vpcCidr: '172.31.0.0/16',
24
+ defaultSecurityGroupId: 'sg-123456',
25
+ privateSubnetId1: 'subnet-123456',
26
+ privateSubnetId2: 'subnet-789012',
27
+ publicSubnetId1: 'subnet-public-1',
28
+ publicSubnetId2: 'subnet-public-2',
29
+ defaultRouteTableId: 'rtb-123456',
30
+ defaultKmsKeyId:
31
+ 'arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012',
32
+ existingNatGatewayId: 'nat-default123',
33
+ auroraClusterEndpoint:
34
+ 'test-cluster.cluster-abc123.us-east-1.rds.amazonaws.com',
35
+ auroraPort: 5432,
36
+ auroraEngine: 'aurora-postgresql',
37
+ }),
38
+ };
39
+ });
40
+
41
+ // createIntegrationRouter loads the app definition from the consuming
42
+ // backend; give it an empty one so the router can be built in isolation.
43
+ jest.mock('@friggframework/core/handlers/app-definition-loader', () => ({
44
+ loadAppDefinition: () => ({ integrations: [], userConfig: {} }),
45
+ }));
46
+
47
+ const { composeServerlessDefinition } = require('../infrastructure-composer');
48
+
49
+ // Routes the auth Lambda's handler (core/handlers/routers/auth.js) adds on
50
+ // top of createIntegrationRouter().
51
+ const AUTH_HANDLER_EXTRA_ROUTES = [
52
+ { method: 'GET', path: '/api/integrations/redirect/:appId' },
53
+ ];
54
+
55
+ function getIntegrationRouterRoutes() {
56
+ const { createIntegrationRouter } = require('@friggframework/core');
57
+ // The repository factories pick an adapter from DB_TYPE (or the backend's
58
+ // app definition, which doesn't exist here). Nothing connects.
59
+ const previousDbType = process.env.DB_TYPE;
60
+ process.env.DB_TYPE = 'postgresql';
61
+ let app;
62
+ try {
63
+ app = createIntegrationRouter();
64
+ } finally {
65
+ if (previousDbType === undefined) delete process.env.DB_TYPE;
66
+ else process.env.DB_TYPE = previousDbType;
67
+ }
68
+ const stack = (app._router || app.router).stack;
69
+ const routes = [];
70
+ for (const layer of stack) {
71
+ if (!layer.route) continue;
72
+ for (const method of Object.keys(layer.route.methods)) {
73
+ routes.push({
74
+ method: method === '_all' ? 'ANY' : method.toUpperCase(),
75
+ path: layer.route.path,
76
+ });
77
+ }
78
+ }
79
+ return routes;
80
+ }
81
+
82
+ function getGatewayRoutes(definition) {
83
+ const routes = [];
84
+ for (const [functionName, fn] of Object.entries(definition.functions)) {
85
+ for (const event of fn.events || []) {
86
+ if (!event.httpApi) continue;
87
+ routes.push({
88
+ functionName,
89
+ method: String(event.httpApi.method).toUpperCase(),
90
+ path: event.httpApi.path,
91
+ });
92
+ }
93
+ }
94
+ return routes;
95
+ }
96
+
97
+ const segmentsOf = (p) => p.split('/').filter(Boolean);
98
+
99
+ // Turn an Express path into a concrete request path, e.g.
100
+ // /api/entities/:entityId/options -> /api/entities/sample-entityId/options
101
+ const toConcretePath = (expressPath) =>
102
+ expressPath.replace(/:([A-Za-z0-9_]+)/g, 'sample-$1');
103
+
104
+ /**
105
+ * HTTP API path matching: literal segments match exactly, {param} matches
106
+ * one segment, a trailing {proxy+} greedily matches one or more segments.
107
+ * Returns null on no match, otherwise a specificity descriptor.
108
+ */
109
+ function matchGatewayPath(gatewayPath, requestPath) {
110
+ const g = segmentsOf(gatewayPath);
111
+ const r = segmentsOf(requestPath);
112
+ let literals = 0;
113
+ for (let i = 0; i < g.length; i++) {
114
+ const seg = g[i];
115
+ if (/^\{[^}]+\+\}$/.test(seg)) {
116
+ if (i !== g.length - 1 || r.length <= i) return null;
117
+ return { greedy: true, literals, prefixLength: i };
118
+ }
119
+ if (i >= r.length) return null;
120
+ if (/^\{[^}]+\}$/.test(seg)) continue;
121
+ if (seg !== r[i]) return null;
122
+ literals++;
123
+ }
124
+ if (g.length !== r.length) return null;
125
+ return { greedy: false, literals, prefixLength: g.length };
126
+ }
127
+
128
+ /**
129
+ * Select the route API Gateway would invoke: a non-greedy match beats a
130
+ * greedy one, then more literal segments, then the longer greedy prefix,
131
+ * then an explicit method beats ANY.
132
+ */
133
+ function selectGatewayRoute(gatewayRoutes, method, requestPath) {
134
+ const candidates = gatewayRoutes
135
+ .filter(
136
+ (r) => r.method === 'ANY' || method === 'ANY' || r.method === method
137
+ )
138
+ .map((r) => ({
139
+ route: r,
140
+ match: matchGatewayPath(r.path, requestPath),
141
+ }))
142
+ .filter((c) => c.match);
143
+ candidates.sort(
144
+ (a, b) =>
145
+ Number(a.match.greedy) - Number(b.match.greedy) ||
146
+ b.match.literals - a.match.literals ||
147
+ b.match.prefixLength - a.match.prefixLength ||
148
+ Number(a.route.method === 'ANY') - Number(b.route.method === 'ANY')
149
+ );
150
+ return candidates.length ? candidates[0].route : null;
151
+ }
152
+
153
+ describe('Management API routes are reachable through API Gateway', () => {
154
+ let gatewayRoutes;
155
+ let managementRoutes;
156
+ const originalArgv = process.argv;
157
+
158
+ beforeAll(async () => {
159
+ process.argv = ['node', 'test'];
160
+ process.env.AWS_REGION = 'us-east-1';
161
+ // The builders narrate their progress; keep the test output quiet.
162
+ const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
163
+ const warnSpy = jest
164
+ .spyOn(console, 'warn')
165
+ .mockImplementation(() => {});
166
+ try {
167
+ const definition = await composeServerlessDefinition({
168
+ name: 'route-coverage-app',
169
+ provider: 'aws',
170
+ usePrismaLambdaLayer: false,
171
+ database: { postgres: { enable: true } },
172
+ websockets: { enable: true },
173
+ adminScripts: [
174
+ class ExampleScript {
175
+ static Definition = { name: 'example-script' };
176
+ },
177
+ ],
178
+ admin: { includeBuiltinReports: true },
179
+ integrations: [
180
+ {
181
+ Definition: {
182
+ name: 'acme',
183
+ webhooks: true,
184
+ extensions: {
185
+ inbound: {
186
+ extension: {
187
+ routes: [
188
+ { path: '/events', method: 'POST' },
189
+ ],
190
+ },
191
+ },
192
+ },
193
+ },
194
+ },
195
+ // Integration names share the /api/ namespace with the
196
+ // Management API; make sure they don't shadow it.
197
+ { Definition: { name: 'entities' } },
198
+ ],
199
+ });
200
+ gatewayRoutes = getGatewayRoutes(definition);
201
+ } finally {
202
+ logSpy.mockRestore();
203
+ warnSpy.mockRestore();
204
+ }
205
+ managementRoutes = [
206
+ ...getIntegrationRouterRoutes(),
207
+ ...AUTH_HANDLER_EXTRA_ROUTES,
208
+ ];
209
+ });
210
+
211
+ afterAll(() => {
212
+ process.argv = originalArgv;
213
+ delete process.env.AWS_REGION;
214
+ });
215
+
216
+ it('reads the Management API routes from the core integration router', () => {
217
+ const paths = managementRoutes.map((r) => r.path);
218
+ expect(paths).toEqual(
219
+ expect.arrayContaining([
220
+ '/api/integrations',
221
+ '/api/authorize',
222
+ '/api/entity',
223
+ '/api/entity/options/:credentialId',
224
+ '/api/entities/:entityId',
225
+ ])
226
+ );
227
+ });
228
+
229
+ it('routes every Management API route to the auth function', () => {
230
+ const unreachable = managementRoutes
231
+ .map(({ method, path: expressPath }) => {
232
+ const requestPath = toConcretePath(expressPath);
233
+ const selected = selectGatewayRoute(
234
+ gatewayRoutes,
235
+ method,
236
+ requestPath
237
+ );
238
+ return {
239
+ route: `${method} ${expressPath}`,
240
+ reachedBy: selected
241
+ ? `${selected.method} ${selected.path} -> ${selected.functionName}`
242
+ : 'no API Gateway route',
243
+ ok: selected && selected.functionName === 'auth',
244
+ };
245
+ })
246
+ .filter((r) => !r.ok)
247
+ .map(({ route, reachedBy }) => `${route} (${reachedBy})`);
248
+
249
+ expect(unreachable).toEqual([]);
250
+ });
251
+
252
+ it.each([
253
+ ['GET', '/api/v2/reports', 'reportRouter'],
254
+ ['POST', '/api/v2/reports/daily/run', 'reportRouter'],
255
+ ['GET', '/admin/scripts/example-script', 'adminScriptRouter'],
256
+ ['POST', '/api/acme-integration/webhooks', 'acmeWebhook'],
257
+ ['POST', '/api/acme-integration/inbound/events', 'acme__inbound'],
258
+ ['GET', '/api/acme-integration/custom', 'acme'],
259
+ ['GET', '/api/entities-integration/custom', 'entities'],
260
+ ['POST', '/user/login', 'user'],
261
+ ['GET', '/health/ready', 'health'],
262
+ ])('leaves %s %s on %s', (method, requestPath, functionName) => {
263
+ const selected = selectGatewayRoute(gatewayRoutes, method, requestPath);
264
+ expect(selected && selected.functionName).toBe(functionName);
265
+ });
266
+
267
+ it('declares no method + path pair on more than one function', () => {
268
+ const seen = new Map();
269
+ const duplicates = [];
270
+ for (const r of gatewayRoutes) {
271
+ const key = `${r.method} ${r.path}`;
272
+ if (seen.has(key) && seen.get(key) !== r.functionName) {
273
+ duplicates.push(
274
+ `${key}: ${seen.get(key)} and ${r.functionName}`
275
+ );
276
+ }
277
+ seen.set(key, r.functionName);
278
+ }
279
+ expect(duplicates).toEqual([]);
280
+ });
281
+ });
@@ -11,30 +11,10 @@ Frigg Framework supports automatic provisioning of Amazon Aurora Serverless v2 P
11
11
  - **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-1.0 ACU default)
12
12
  - **VPC Integration**: Deployed in same private subnets as Lambda functions
13
13
  - **Secrets Manager**: Automatic credential management and rotation
14
- - **Management Modes**: discover, create-new, use-existing, external (bring your own `DATABASE_URL`)
14
+ - **Three Management Modes**: discover, create-new, use-existing
15
15
  - **Security**: Private subnet deployment with security group isolation
16
16
  - **High Availability**: Multi-AZ deployment with automatic failover
17
17
 
18
- ### Bring your own PostgreSQL (`management: 'external'`)
19
-
20
- To connect to a PostgreSQL that Frigg does not manage (any hosted provider, or
21
- a database you run yourself), set `management: 'external'`. Frigg then creates
22
- and discovers no database resources (no RDS/Aurora, no Secrets Manager secret)
23
- and needs no VPC for the database; the app connects through `DATABASE_URL`.
24
- This check takes precedence over a top-level `managementMode`. The migration
25
- infrastructure is still composed, so migrations run against `DATABASE_URL`.
26
-
27
- ```javascript
28
- const appDefinition = {
29
- vpc: { enable: false },
30
- database: { postgres: { enable: true, management: 'external' } },
31
- environment: { DATABASE_URL: true }, // read from the shell that runs `frigg deploy` (not .env)
32
- };
33
- ```
34
-
35
- Use `sslmode=require` in the URL. This is the default for apps scaffolded by
36
- `frigg init`.
37
-
38
18
  ---
39
19
 
40
20
  ## Configuration Schema
@@ -141,12 +141,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
141
141
  }
142
142
 
143
143
  createAdminScriptQueue(result, appDefinition) {
144
- // Registered under custom so the serverless plugin creates it in LocalStack offline
145
- result.custom.AdminScriptQueue = '${self:service}-${self:provider.stage}-AdminScriptQueue';
146
144
  result.resources.AdminScriptQueue = {
147
145
  Type: 'AWS::SQS::Queue',
148
146
  Properties: {
149
- QueueName: '${self:custom.AdminScriptQueue}',
147
+ QueueName: '${self:service}-${self:provider.stage}-AdminScriptQueue',
150
148
  MessageRetentionPeriod: 86400, // 1 day
151
149
  VisibilityTimeout: 900, // 15 minutes (Lambda max)
152
150
  RedrivePolicy: {
@@ -266,12 +264,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
266
264
  }
267
265
 
268
266
  createReportQueue(result, appDefinition) {
269
- // Registered under custom so the serverless plugin creates it in LocalStack offline
270
- result.custom.ReportQueue = '${self:service}-${self:provider.stage}-ReportQueue';
271
267
  result.resources.ReportQueue = {
272
268
  Type: 'AWS::SQS::Queue',
273
269
  Properties: {
274
- QueueName: '${self:custom.ReportQueue}',
270
+ QueueName: '${self:service}-${self:provider.stage}-ReportQueue',
275
271
  MessageRetentionPeriod: 86400, // 1 day
276
272
  VisibilityTimeout: 900, // 15 minutes (Lambda max)
277
273
  RedrivePolicy: {