@friggframework/devtools 2.0.0--canary.686.00d79d8.0 → 2.0.0--canary.688.e850868.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/frigg-cli/build-command/index.js +1 -32
- package/frigg-cli/deploy-command/index.js +2 -50
- package/frigg-cli/doctor-command/index.js +0 -7
- package/frigg-cli/generate-iam-command.js +0 -7
- package/frigg-cli/repair-command/index.js +0 -7
- package/frigg-cli/start-command/index.js +0 -58
- package/infrastructure/__tests__/template-generation.test.js +0 -7
- package/infrastructure/create-frigg-infrastructure.js +0 -14
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +6 -2
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +30 -0
- package/infrastructure/domains/shared/types/app-definition.js +1 -15
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +10 -26
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +1 -61
- package/infrastructure/infrastructure-composer.test.js +0 -7
- package/infrastructure/scripts/build-prisma-layer.js +5 -32
- package/infrastructure/scripts/build-prisma-layer.test.js +0 -35
- package/package.json +7 -7
- package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +0 -140
- package/frigg-cli/utils/provider-helper.js +0 -80
- package/infrastructure/__tests__/create-frigg-infrastructure-provider.test.js +0 -64
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -335
- package/infrastructure/provider-build.js +0 -119
- package/test/npm-install-guard.js +0 -104
- package/test/npm-install-guard.test.js +0 -53
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
const { spawnSync } = require('child_process');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
async function buildCommand(options
|
|
5
|
-
// A non-AWS provider (appDefinition.provider) builds through its plugin:
|
|
6
|
-
// platform config + function entry points, no serverless package
|
|
7
|
-
// (friggframework/frigg#545).
|
|
8
|
-
const providerResult = loadProviderIfConfigured();
|
|
9
|
-
if (providerResult) {
|
|
10
|
-
const { buildWithProvider } = require('../../infrastructure/provider-build');
|
|
11
|
-
buildWithProvider({
|
|
12
|
-
appDefinition: providerResult.appDefinition,
|
|
13
|
-
backendDir: providerResult.backendDir,
|
|
14
|
-
provider: providerResult.provider,
|
|
15
|
-
verbose: options.verbose,
|
|
16
|
-
});
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
4
|
+
async function buildCommand(options) {
|
|
20
5
|
console.log('Building the serverless application...');
|
|
21
6
|
|
|
22
7
|
// Suppress AWS SDK warning message about maintenance mode
|
|
@@ -78,20 +63,4 @@ async function buildCommand(options = {}) {
|
|
|
78
63
|
// });
|
|
79
64
|
}
|
|
80
65
|
|
|
81
|
-
/**
|
|
82
|
-
* The resolved non-AWS provider, or null for AWS / no app definition found.
|
|
83
|
-
*/
|
|
84
|
-
function loadProviderIfConfigured() {
|
|
85
|
-
const { loadProviderForCli } = require('../utils/provider-helper');
|
|
86
|
-
let result;
|
|
87
|
-
try {
|
|
88
|
-
result = loadProviderForCli();
|
|
89
|
-
} catch (error) {
|
|
90
|
-
// A non-AWS provider whose package is missing: say so, don't build for AWS.
|
|
91
|
-
console.error(error.message);
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
return result && result.provider ? result : null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
66
|
module.exports = { buildCommand };
|
|
@@ -310,16 +310,9 @@ async function pushOffloadedParametersOrAbort(appDefinition, options) {
|
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
async function deployCommand(options) {
|
|
313
|
-
const appDefinition = loadAppDefinition();
|
|
314
|
-
|
|
315
|
-
// A non-AWS provider (appDefinition.provider) deploys through its plugin
|
|
316
|
-
// (friggframework/frigg#545).
|
|
317
|
-
const providerName = appDefinition?.provider;
|
|
318
|
-
if (providerName && providerName !== 'aws') {
|
|
319
|
-
return deployWithProvider(appDefinition, providerName, options);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
313
|
console.log('Deploying the serverless application...');
|
|
314
|
+
|
|
315
|
+
const appDefinition = loadAppDefinition();
|
|
323
316
|
const environment = validateAndBuildEnvironment(appDefinition, options);
|
|
324
317
|
|
|
325
318
|
await pushOffloadedParametersOrAbort(appDefinition, options);
|
|
@@ -353,45 +346,4 @@ async function deployCommand(options) {
|
|
|
353
346
|
}
|
|
354
347
|
}
|
|
355
348
|
|
|
356
|
-
/**
|
|
357
|
-
* Deploy with a provider plugin: validate(), then deploy() (which runs its
|
|
358
|
-
* own preflightCheck()).
|
|
359
|
-
*/
|
|
360
|
-
async function deployWithProvider(appDefinition, providerName, options = {}) {
|
|
361
|
-
let provider;
|
|
362
|
-
try {
|
|
363
|
-
const { resolveProvider } = require('@friggframework/core/providers/resolve-provider');
|
|
364
|
-
provider = resolveProvider(appDefinition);
|
|
365
|
-
} catch (error) {
|
|
366
|
-
console.error(`Failed to load provider '${providerName}': ${error.message}`);
|
|
367
|
-
process.exit(1);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
console.log(`Deploying with ${providerName} provider...`);
|
|
371
|
-
|
|
372
|
-
if (typeof provider.validate === 'function') {
|
|
373
|
-
const validation = provider.validate(appDefinition);
|
|
374
|
-
if (validation.errors?.length > 0) {
|
|
375
|
-
console.error(`\nValidation errors for ${providerName}:`);
|
|
376
|
-
for (const error of validation.errors) console.error(` - ${error}`);
|
|
377
|
-
process.exit(1);
|
|
378
|
-
}
|
|
379
|
-
for (const warning of validation.warnings || []) console.warn(` Warning: ${warning}`);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
try {
|
|
383
|
-
const result = await provider.deploy(appDefinition, {
|
|
384
|
-
stage: options.stage,
|
|
385
|
-
prod: options.stage === 'production' || options.stage === 'prod',
|
|
386
|
-
dryRun: options.dryRun || false,
|
|
387
|
-
});
|
|
388
|
-
console.log('\nDeployment completed successfully.');
|
|
389
|
-
if (result?.url) console.log(` URL: ${result.url}`);
|
|
390
|
-
} catch (error) {
|
|
391
|
-
console.error(`\nDeployment failed: ${error.message}`);
|
|
392
|
-
for (const item of error.missing || []) console.error(` - ${item}`);
|
|
393
|
-
process.exit(1);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
349
|
module.exports = { deployCommand };
|
|
@@ -246,13 +246,6 @@ async function promptForStackSelection(region) {
|
|
|
246
246
|
*/
|
|
247
247
|
async function doctorCommand(stackName, options = {}) {
|
|
248
248
|
try {
|
|
249
|
-
// AWS-only (CloudFormation); a non-AWS provider has nothing to inspect.
|
|
250
|
-
if (require('../utils/provider-helper').isNonAwsProject()) {
|
|
251
|
-
output.error('The doctor command is only available for AWS deployments.');
|
|
252
|
-
output.log('Your appDefinition uses a non-AWS provider.');
|
|
253
|
-
process.exit(1);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
249
|
// Extract options with defaults
|
|
257
250
|
const region = options.region || process.env.AWS_REGION || 'us-east-1';
|
|
258
251
|
const format = options.format || 'console';
|
|
@@ -9,13 +9,6 @@ const { generateIAMCloudFormation, getFeatureSummary } = require('../infrastruct
|
|
|
9
9
|
*/
|
|
10
10
|
async function generateIamCommand(options = {}) {
|
|
11
11
|
try {
|
|
12
|
-
// AWS-only (CloudFormation); a non-AWS provider has nothing to inspect.
|
|
13
|
-
if (require('./utils/provider-helper').isNonAwsProject()) {
|
|
14
|
-
console.error('The generate-iam command is only available for AWS deployments.');
|
|
15
|
-
console.log('Your appDefinition uses a non-AWS provider.');
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
console.log('🔍 Finding Frigg application...');
|
|
20
13
|
|
|
21
14
|
// Find the backend package.json
|
|
@@ -453,13 +453,6 @@ async function handleReconcileRepair(stackIdentifier, report, options) {
|
|
|
453
453
|
*/
|
|
454
454
|
async function repairCommand(stackName, options = {}) {
|
|
455
455
|
try {
|
|
456
|
-
// AWS-only (CloudFormation); a non-AWS provider has nothing to inspect.
|
|
457
|
-
if (require('../utils/provider-helper').isNonAwsProject()) {
|
|
458
|
-
output.error('The repair command is only available for AWS deployments.');
|
|
459
|
-
output.log('Your appDefinition uses a non-AWS provider.');
|
|
460
|
-
process.exit(1);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
456
|
// Validate required parameter
|
|
464
457
|
if (!stackName) {
|
|
465
458
|
console.error('Error: Stack name is required');
|
|
@@ -37,12 +37,6 @@ async function startCommand(options) {
|
|
|
37
37
|
console.log(chalk.green('✓ Database checks passed\n'));
|
|
38
38
|
console.log('Starting backend and optional frontend...');
|
|
39
39
|
|
|
40
|
-
// A non-AWS provider runs its own local dev server (friggframework/frigg#545).
|
|
41
|
-
const providerResult = loadNonAwsProvider();
|
|
42
|
-
if (providerResult) {
|
|
43
|
-
return startWithProvider(providerResult, options);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
40
|
// Suppress AWS SDK warning message about maintenance mode
|
|
47
41
|
process.env.AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE = '1';
|
|
48
42
|
// Skip AWS discovery for local development
|
|
@@ -152,56 +146,4 @@ async function performDatabaseChecks(verbose) {
|
|
|
152
146
|
// connection when it starts.
|
|
153
147
|
}
|
|
154
148
|
|
|
155
|
-
function loadNonAwsProvider() {
|
|
156
|
-
try {
|
|
157
|
-
const { loadProviderForCli } = require('../utils/provider-helper');
|
|
158
|
-
const result = loadProviderForCli();
|
|
159
|
-
return result && result.provider ? result : null;
|
|
160
|
-
} catch {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Local dev server per provider: Netlify -> `netlify dev` (reads netlify.toml
|
|
167
|
-
* and serves the generated functions), run from the project root that holds
|
|
168
|
-
* backend/ and netlify.toml.
|
|
169
|
-
*/
|
|
170
|
-
function startWithProvider({ providerName, backendDir }, options = {}) {
|
|
171
|
-
const DEV_COMMANDS = {
|
|
172
|
-
netlify: { command: 'netlify', args: ['dev'] },
|
|
173
|
-
};
|
|
174
|
-
const devCmd = DEV_COMMANDS[providerName];
|
|
175
|
-
if (!devCmd) {
|
|
176
|
-
console.error(chalk.red(
|
|
177
|
-
`Provider '${providerName}' does not have a local dev server configured.\n` +
|
|
178
|
-
` Supported providers for local dev: ${Object.keys(DEV_COMMANDS).join(', ')}, aws`
|
|
179
|
-
));
|
|
180
|
-
process.exit(1);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const cwd = require('node:path').dirname(backendDir);
|
|
184
|
-
console.log(chalk.blue(`Starting local dev server (${providerName})...`));
|
|
185
|
-
if (options.verbose) {
|
|
186
|
-
console.log(`Executing command: ${devCmd.command} ${devCmd.args.join(' ')}`);
|
|
187
|
-
console.log(`Working directory: ${cwd}`);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const childProcess = spawn(devCmd.command, devCmd.args, {
|
|
191
|
-
cwd,
|
|
192
|
-
stdio: 'inherit',
|
|
193
|
-
env: { ...process.env },
|
|
194
|
-
});
|
|
195
|
-
childProcess.on('error', (error) => {
|
|
196
|
-
if (error.code === 'ENOENT') {
|
|
197
|
-
console.error(chalk.red(`'${devCmd.command}' not found. Install it with: npm install -g ${devCmd.command}-cli`));
|
|
198
|
-
} else {
|
|
199
|
-
console.error(`Error executing command: ${error.message}`);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
childProcess.on('close', (code) => {
|
|
203
|
-
if (code !== 0) console.log(`Child process exited with code ${code}`);
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
149
|
module.exports = { startCommand };
|
|
@@ -5,13 +5,6 @@
|
|
|
5
5
|
* valid, consistent CloudFormation templates.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
// Composing must not build the real Prisma layer: that runs npm install
|
|
9
|
-
// under packages/devtools, and two workers doing it at once once pruned the
|
|
10
|
-
// repository's root node_modules (test/npm-install-guard.js).
|
|
11
|
-
jest.mock('../domains/shared/utilities/prisma-layer-manager', () => ({
|
|
12
|
-
ensurePrismaLayerExists: jest.fn(async () => {}),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
8
|
const { composeServerlessDefinition } = require('../infrastructure-composer');
|
|
16
9
|
|
|
17
10
|
describe('CloudFormation Template Generation', () => {
|
|
@@ -35,20 +35,6 @@ async function createFriggInfrastructure() {
|
|
|
35
35
|
throw new Error('Could not find index.js');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// A non-AWS provider (appDefinition.provider, e.g. 'netlify') builds
|
|
39
|
-
// through its provider plugin instead of serverless/CloudFormation
|
|
40
|
-
// (friggframework/frigg#545). Checked before the cache: the cache holds
|
|
41
|
-
// serverless definitions only. Returns an empty serverless definition,
|
|
42
|
-
// so an osls invocation has nothing to package.
|
|
43
|
-
{
|
|
44
|
-
const { isNonAwsProvider, buildWithProvider } = require('./provider-build');
|
|
45
|
-
const appDefinition = require(backendFilePath).Definition;
|
|
46
|
-
if (isNonAwsProvider(appDefinition)) {
|
|
47
|
-
buildWithProvider({ appDefinition, backendDir });
|
|
48
|
-
return {};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
38
|
const cachePath = getCachePath(backendDir);
|
|
53
39
|
const lockPath = getLockPath(backendDir);
|
|
54
40
|
|
|
@@ -141,10 +141,12 @@ 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';
|
|
144
146
|
result.resources.AdminScriptQueue = {
|
|
145
147
|
Type: 'AWS::SQS::Queue',
|
|
146
148
|
Properties: {
|
|
147
|
-
QueueName: '${self:
|
|
149
|
+
QueueName: '${self:custom.AdminScriptQueue}',
|
|
148
150
|
MessageRetentionPeriod: 86400, // 1 day
|
|
149
151
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
150
152
|
RedrivePolicy: {
|
|
@@ -264,10 +266,12 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
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';
|
|
267
271
|
result.resources.ReportQueue = {
|
|
268
272
|
Type: 'AWS::SQS::Queue',
|
|
269
273
|
Properties: {
|
|
270
|
-
QueueName: '${self:
|
|
274
|
+
QueueName: '${self:custom.ReportQueue}',
|
|
271
275
|
MessageRetentionPeriod: 86400, // 1 day
|
|
272
276
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
273
277
|
RedrivePolicy: {
|
|
@@ -168,6 +168,21 @@ describe('AdminScriptBuilder', () => {
|
|
|
168
168
|
expect(result.resources.AdminScriptQueue.Properties.VisibilityTimeout).toBe(900); // 15 minutes
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
+
it('registers AdminScriptQueue under custom so frigg start creates it locally', async () => {
|
|
172
|
+
const appDefinition = {
|
|
173
|
+
adminScripts: [{ Definition: { name: 'test-script' } }],
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
177
|
+
|
|
178
|
+
expect(result.custom.AdminScriptQueue).toBe(
|
|
179
|
+
'${self:service}-${self:provider.stage}-AdminScriptQueue'
|
|
180
|
+
);
|
|
181
|
+
expect(result.resources.AdminScriptQueue.Properties.QueueName).toBe(
|
|
182
|
+
'${self:custom.AdminScriptQueue}'
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
|
|
171
186
|
it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
|
|
172
187
|
const appDefinition = {
|
|
173
188
|
adminScripts: [
|
|
@@ -621,6 +636,21 @@ describe('AdminScriptBuilder', () => {
|
|
|
621
636
|
});
|
|
622
637
|
|
|
623
638
|
describe('reports (ReportQueue + reportExecutor)', () => {
|
|
639
|
+
it('registers ReportQueue under custom so frigg start creates it locally', async () => {
|
|
640
|
+
const appDefinition = {
|
|
641
|
+
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
645
|
+
|
|
646
|
+
expect(result.custom.ReportQueue).toBe(
|
|
647
|
+
'${self:service}-${self:provider.stage}-ReportQueue'
|
|
648
|
+
);
|
|
649
|
+
expect(result.resources.ReportQueue.Properties.QueueName).toBe(
|
|
650
|
+
'${self:custom.ReportQueue}'
|
|
651
|
+
);
|
|
652
|
+
});
|
|
653
|
+
|
|
624
654
|
it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
|
|
625
655
|
const appDefinition = {
|
|
626
656
|
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
* @typedef {Object} AppDefinition
|
|
130
130
|
* @property {string} name - Application name
|
|
131
131
|
* @property {string} stage - Deployment stage (e.g., 'dev', 'production')
|
|
132
|
-
* @property {string} provider -
|
|
132
|
+
* @property {string} provider - Cloud provider (e.g., 'aws')
|
|
133
133
|
* @property {string} region - AWS region
|
|
134
134
|
*
|
|
135
135
|
* @property {VpcDefinition} [vpc] - VPC configuration
|
|
@@ -144,20 +144,6 @@
|
|
|
144
144
|
* @property {AdminConfig} [admin] - Admin configuration
|
|
145
145
|
*
|
|
146
146
|
* @property {Object} [environment] - Environment variables
|
|
147
|
-
*
|
|
148
|
-
* @property {ExtensionDefinition[]} [extensions] - App-level extensions that add custom Prisma models, encrypted fields, admin routes and bootstrap hooks (not an integration's Definition.extensions)
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* App-level extension: custom models, encryption, admin routes and bootstrap
|
|
153
|
-
* @typedef {Object} ExtensionDefinition
|
|
154
|
-
* @property {string} name - Unique identifier for this extension
|
|
155
|
-
* @property {string} [schema] - Absolute path to a .prisma schema fragment
|
|
156
|
-
* @property {Object<string, {fields: string[]}>} [encryption] - Model name → encrypted fields mapping
|
|
157
|
-
* @property {Object} [routes] - Express router configuration
|
|
158
|
-
* @property {string} routes.path - Base URL path for the extension routes
|
|
159
|
-
* @property {Function|Object} routes.handler - Router factory (prisma, appDefinition) → Router, or { router } object
|
|
160
|
-
* @property {Function} [bootstrap] - Async function (prisma, appDefinition) → void, run by initializeApp()
|
|
161
147
|
*/
|
|
162
148
|
|
|
163
149
|
/**
|
|
@@ -10,24 +10,6 @@
|
|
|
10
10
|
const { buildEnvironment } = require('../environment-builder');
|
|
11
11
|
const { nestedNodeModulesExcludes } = require('./nested-node-modules');
|
|
12
12
|
const { buildLoggingProviderConfig } = require('./logging-config');
|
|
13
|
-
const {
|
|
14
|
-
getGatewayRoutes,
|
|
15
|
-
} = require('@friggframework/core/management-api/route-registry');
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* HTTP API events for one function, from core's Management API route
|
|
19
|
-
* registry (ADR-053): the same registry mounts the Express routers and
|
|
20
|
-
* builds the OpenAPI documents, so the three cannot drift.
|
|
21
|
-
*/
|
|
22
|
-
function managementApiEvents(AppDefinition, functionName) {
|
|
23
|
-
const managementApi = AppDefinition.managementApi || {};
|
|
24
|
-
return getGatewayRoutes({
|
|
25
|
-
v1: managementApi.v1 !== false,
|
|
26
|
-
proxy: managementApi.proxy?.enable === true,
|
|
27
|
-
})
|
|
28
|
-
.filter((route) => route.function === functionName)
|
|
29
|
-
.map(({ method, path }) => ({ httpApi: { path, method } }));
|
|
30
|
-
}
|
|
31
13
|
|
|
32
14
|
/**
|
|
33
15
|
* Create base serverless definition with core functions and resources
|
|
@@ -304,12 +286,16 @@ function createBaseDefinition(
|
|
|
304
286
|
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
305
287
|
skipEsbuild: true, // Handlers in node_modules don't need bundling
|
|
306
288
|
package: skipEsbuildPackageConfig,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
289
|
+
events: [
|
|
290
|
+
{ httpApi: { path: '/api/integrations', method: 'ANY' } },
|
|
291
|
+
{
|
|
292
|
+
httpApi: {
|
|
293
|
+
path: '/api/integrations/{proxy+}',
|
|
294
|
+
method: 'ANY',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
{ httpApi: { path: '/api/authorize', method: 'ANY' } },
|
|
298
|
+
],
|
|
313
299
|
},
|
|
314
300
|
user: {
|
|
315
301
|
handler: 'node_modules/@friggframework/core/handlers/routers/user.handler',
|
|
@@ -326,8 +312,6 @@ function createBaseDefinition(
|
|
|
326
312
|
events: [
|
|
327
313
|
{ httpApi: { path: '/health', method: 'GET' } },
|
|
328
314
|
{ httpApi: { path: '/health/{proxy+}', method: 'GET' } },
|
|
329
|
-
// GET /api/meta and the OpenAPI documents: public, DB-free.
|
|
330
|
-
...managementApiEvents(AppDefinition, 'health'),
|
|
331
315
|
],
|
|
332
316
|
},
|
|
333
317
|
// Reporting is an admin operation (ADR-010): the report router runs on the admin-scripts Lambda, not as a standalone function here.
|
|
@@ -94,67 +94,7 @@ describe('Base Definition Factory', () => {
|
|
|
94
94
|
|
|
95
95
|
expect(result.functions.auth.handler).toBe('node_modules/@friggframework/core/handlers/routers/auth.handler');
|
|
96
96
|
expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
97
|
-
expect(
|
|
98
|
-
result.functions.auth.events.map(
|
|
99
|
-
(e) => `${e.httpApi.method} ${e.httpApi.path}`
|
|
100
|
-
)
|
|
101
|
-
).toEqual([
|
|
102
|
-
// v1 (deprecated, ADR-053)
|
|
103
|
-
'ANY /api/integrations',
|
|
104
|
-
'ANY /api/integrations/{proxy+}',
|
|
105
|
-
'ANY /api/authorize',
|
|
106
|
-
'ANY /api/entity',
|
|
107
|
-
'ANY /api/entity/{proxy+}',
|
|
108
|
-
'ANY /api/entities/{proxy+}',
|
|
109
|
-
// v2, per resource: never ANY /api/v2/{proxy+}, which would
|
|
110
|
-
// shadow /api/v2/reports on the admin-scripts Lambda
|
|
111
|
-
'ANY /api/v2/integrations',
|
|
112
|
-
'ANY /api/v2/integrations/{proxy+}',
|
|
113
|
-
'ANY /api/v2/entities',
|
|
114
|
-
'ANY /api/v2/entities/{proxy+}',
|
|
115
|
-
'ANY /api/v2/credentials',
|
|
116
|
-
'ANY /api/v2/credentials/{proxy+}',
|
|
117
|
-
'ANY /api/v2/authorize',
|
|
118
|
-
]);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('takes the Management API routes from the core route registry', () => {
|
|
122
|
-
const { getGatewayRoutes } = require('@friggframework/core/management-api/route-registry');
|
|
123
|
-
const result = createBaseDefinition({}, {}, {});
|
|
124
|
-
const declared = (fn) =>
|
|
125
|
-
result.functions[fn].events
|
|
126
|
-
.map((e) => `${e.httpApi.method} ${e.httpApi.path}`)
|
|
127
|
-
.filter((route) => route.includes('/api/'));
|
|
128
|
-
const registry = (fn) =>
|
|
129
|
-
getGatewayRoutes()
|
|
130
|
-
.filter((r) => r.function === fn)
|
|
131
|
-
.map((r) => `${r.method} ${r.path}`);
|
|
132
|
-
expect(declared('auth')).toEqual(registry('auth'));
|
|
133
|
-
expect(declared('health')).toEqual(registry('health'));
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('serves /api/meta from the DB-free health function', () => {
|
|
137
|
-
const result = createBaseDefinition({}, {}, {});
|
|
138
|
-
expect(
|
|
139
|
-
result.functions.health.events.map((e) => `${e.httpApi.method} ${e.httpApi.path}`)
|
|
140
|
-
).toEqual([
|
|
141
|
-
'GET /health',
|
|
142
|
-
'GET /health/{proxy+}',
|
|
143
|
-
'GET /api/meta',
|
|
144
|
-
'GET /api/meta/{proxy+}',
|
|
145
|
-
]);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('drops the v1 routes when managementApi.v1 is false, keeping the OAuth redirect', () => {
|
|
149
|
-
const result = createBaseDefinition({ managementApi: { v1: false } }, {}, {});
|
|
150
|
-
const routes = result.functions.auth.events.map(
|
|
151
|
-
(e) => `${e.httpApi.method} ${e.httpApi.path}`
|
|
152
|
-
);
|
|
153
|
-
expect(routes).not.toContain('ANY /api/integrations');
|
|
154
|
-
expect(routes).not.toContain('ANY /api/authorize');
|
|
155
|
-
expect(routes).not.toContain('ANY /api/entity');
|
|
156
|
-
expect(routes).toContain('GET /api/integrations/redirect/{appId}');
|
|
157
|
-
expect(routes).toContain('ANY /api/v2/integrations');
|
|
97
|
+
expect(result.functions.auth.events).toHaveLength(3);
|
|
158
98
|
});
|
|
159
99
|
|
|
160
100
|
it('should NOT include legacy dbMigrate function', () => {
|
|
@@ -2,13 +2,6 @@ const {
|
|
|
2
2
|
composeServerlessDefinition,
|
|
3
3
|
applySsmPreloadNodeOptions,
|
|
4
4
|
} = require('./infrastructure-composer');
|
|
5
|
-
// Composing must not build the real Prisma layer: that runs npm install
|
|
6
|
-
// under packages/devtools, and two workers doing it at once once pruned the
|
|
7
|
-
// repository's root node_modules (test/npm-install-guard.js).
|
|
8
|
-
jest.mock('./domains/shared/utilities/prisma-layer-manager', () => ({
|
|
9
|
-
ensurePrismaLayerExists: jest.fn(async () => {}),
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
5
|
const {
|
|
13
6
|
SSM_PRELOAD_NODE_OPTIONS,
|
|
14
7
|
} = require('./domains/parameters/offload-utils');
|
|
@@ -249,36 +249,6 @@ async function createLayerStructure() {
|
|
|
249
249
|
logSuccess(`Created ${LAYER_NODE_MODULES}`);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
/**
|
|
253
|
-
* Run `npm install --omit=dev` confined to the layer directory.
|
|
254
|
-
*
|
|
255
|
-
* npm resolves its project root by walking up from cwd to the nearest
|
|
256
|
-
* package.json. If the layer's package.json is missing when npm starts (a
|
|
257
|
-
* concurrent build cleaned the directory, as two jest workers composing at
|
|
258
|
-
* once did), npm walked up into the enclosing workspace and ran
|
|
259
|
-
* `install --omit=dev` there, pruning the devDependencies (jest, jest-util)
|
|
260
|
-
* out of the repository's root node_modules. So: the package.json must exist,
|
|
261
|
-
* and `--prefix` pins npm's root to the layer directory while
|
|
262
|
-
* `--workspaces=false` stops it acting on an enclosing workspace.
|
|
263
|
-
*
|
|
264
|
-
* @param {string} layerNodejsDir - absolute path of <layer>/nodejs
|
|
265
|
-
* @param {Object} [options]
|
|
266
|
-
* @param {Object} [options.env]
|
|
267
|
-
* @param {Function} [options.exec] - execSync stand-in (tests)
|
|
268
|
-
*/
|
|
269
|
-
function runLayerInstall(layerNodejsDir, { env = process.env, exec = execSync } = {}) {
|
|
270
|
-
const manifest = path.join(layerNodejsDir, 'package.json');
|
|
271
|
-
if (!fs.existsSync(manifest)) {
|
|
272
|
-
throw new Error(
|
|
273
|
-
`Refusing to run npm install: ${manifest} does not exist (npm would install into an enclosing project)`
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
exec(
|
|
277
|
-
`npm install --omit=dev --no-package-lock --workspaces=false --prefix ${JSON.stringify(layerNodejsDir)}`,
|
|
278
|
-
{ cwd: layerNodejsDir, stdio: 'inherit', env }
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
252
|
/**
|
|
283
253
|
* Install Prisma client directly into layer (RUNTIME ONLY - NO CLI)
|
|
284
254
|
*
|
|
@@ -315,7 +285,11 @@ async function installPrismaPackages() {
|
|
|
315
285
|
PRISMA_CLI_BINARY_TARGETS: 'rhel-openssl-3.0.x',
|
|
316
286
|
};
|
|
317
287
|
|
|
318
|
-
|
|
288
|
+
execSync('npm install --omit=dev --no-package-lock', {
|
|
289
|
+
cwd: path.join(LAYER_OUTPUT_PATH, 'nodejs'),
|
|
290
|
+
stdio: 'inherit',
|
|
291
|
+
env,
|
|
292
|
+
});
|
|
319
293
|
logSuccess('Prisma packages installed with Lambda binary target');
|
|
320
294
|
} catch (error) {
|
|
321
295
|
throw new Error(`Failed to install Prisma packages: ${error.message}`);
|
|
@@ -719,7 +693,6 @@ if (require.main === module) {
|
|
|
719
693
|
|
|
720
694
|
module.exports = {
|
|
721
695
|
buildPrismaLayer,
|
|
722
|
-
runLayerInstall,
|
|
723
696
|
getGeneratedClientPackages,
|
|
724
697
|
getMigrationsPackages,
|
|
725
698
|
getMigrationSourcePath,
|
|
@@ -168,38 +168,3 @@ describe('getMigrationDestinationPath()', () => {
|
|
|
168
168
|
);
|
|
169
169
|
});
|
|
170
170
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
describe('runLayerInstall', () => {
|
|
174
|
-
const fs = require('fs');
|
|
175
|
-
const os = require('os');
|
|
176
|
-
const path = require('path');
|
|
177
|
-
const { runLayerInstall } = require('./build-prisma-layer');
|
|
178
|
-
|
|
179
|
-
it('refuses when the layer package.json is missing (npm would walk up into the workspace)', () => {
|
|
180
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'layer-'));
|
|
181
|
-
const exec = jest.fn();
|
|
182
|
-
try {
|
|
183
|
-
expect(() => runLayerInstall(dir, { exec })).toThrow(/Refusing to run npm install/);
|
|
184
|
-
expect(exec).not.toHaveBeenCalled();
|
|
185
|
-
} finally {
|
|
186
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('pins npm to the layer directory and off any enclosing workspace', () => {
|
|
191
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'layer-'));
|
|
192
|
-
fs.writeFileSync(path.join(dir, 'package.json'), '{}');
|
|
193
|
-
const exec = jest.fn();
|
|
194
|
-
try {
|
|
195
|
-
runLayerInstall(dir, { exec, env: { X: '1' } });
|
|
196
|
-
const [command, options] = exec.mock.calls[0];
|
|
197
|
-
expect(command).toContain('npm install --omit=dev');
|
|
198
|
-
expect(command).toContain('--workspaces=false');
|
|
199
|
-
expect(command).toContain(`--prefix ${JSON.stringify(dir)}`);
|
|
200
|
-
expect(options).toMatchObject({ cwd: dir, env: { X: '1' } });
|
|
201
|
-
} finally {
|
|
202
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.
|
|
4
|
+
"version": "2.0.0--canary.688.e850868.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"@babel/eslint-parser": "^7.18.9",
|
|
27
27
|
"@babel/parser": "^7.25.3",
|
|
28
28
|
"@babel/traverse": "^7.25.3",
|
|
29
|
-
"@friggframework/core": "2.0.0--canary.
|
|
30
|
-
"@friggframework/schemas": "2.0.0--canary.
|
|
31
|
-
"@friggframework/test": "2.0.0--canary.
|
|
29
|
+
"@friggframework/core": "2.0.0--canary.688.e850868.0",
|
|
30
|
+
"@friggframework/schemas": "2.0.0--canary.688.e850868.0",
|
|
31
|
+
"@friggframework/test": "2.0.0--canary.688.e850868.0",
|
|
32
32
|
"@hapi/boom": "^10.0.1",
|
|
33
33
|
"@inquirer/prompts": "^5.3.8",
|
|
34
34
|
"axios": "^1.18.0",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"validate-npm-package-name": "^5.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
60
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
59
|
+
"@friggframework/eslint-config": "2.0.0--canary.688.e850868.0",
|
|
60
|
+
"@friggframework/prettier-config": "2.0.0--canary.688.e850868.0",
|
|
61
61
|
"aws-sdk-client-mock": "^4.1.0",
|
|
62
62
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
63
63
|
"jest": "^30.1.3",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "e850868f19706ee89566fd9724603dee1e03a711"
|
|
93
93
|
}
|