@friggframework/devtools 2.0.0--canary.700.80ec1cc.0 → 2.0.0--canary.702.047d3c4.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/README.md +1 -0
- package/frigg-cli/README.md +46 -1
- package/frigg-cli/__tests__/unit/commands/build.test.js +3 -0
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +3 -0
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +92 -0
- package/frigg-cli/build-command/index.js +6 -0
- package/frigg-cli/deploy-command/index.js +6 -0
- package/frigg-cli/index.js +19 -1
- package/frigg-cli/init-command/backend-first-handler.js +25 -46
- package/frigg-cli/start-command/index.js +4 -0
- package/frigg-cli/start-command/start-command.test.js +3 -0
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +63 -0
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +133 -0
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +326 -0
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +241 -0
- package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +119 -0
- package/frigg-cli/validate-command/checks/config.js +468 -0
- package/frigg-cli/validate-command/checks/integrations.js +274 -0
- package/frigg-cli/validate-command/fixtures/bad-module/index.js +18 -0
- package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +76 -0
- package/frigg-cli/validate-command/fixtures/fathom-module/index.js +6 -0
- package/frigg-cli/validate-command/format-report.js +60 -0
- package/frigg-cli/validate-command/index.js +151 -0
- package/frigg-cli/validate-command/load-app-definition.js +93 -0
- package/frigg-cli/validate-command/load-module-definition.js +64 -0
- package/frigg-cli/validate-command/schema-issues.js +154 -0
- package/frigg-cli/validate-command/validate-app-definition.js +60 -0
- package/frigg-cli/validate-command/validate-module-definition.js +46 -0
- package/infrastructure/app-definition-schema-contract.test.js +607 -0
- package/infrastructure/create-frigg-infrastructure.js +4 -1
- package/infrastructure/create-frigg-infrastructure.test.js +51 -0
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +60 -98
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
- package/infrastructure/domains/integration/integration-builder.js +0 -19
- package/infrastructure/domains/integration/integration-builder.test.js +0 -22
- package/infrastructure/domains/shared/function-environments.js +1 -9
- package/infrastructure/domains/shared/function-environments.test.js +0 -14
- package/infrastructure/infrastructure-composer.js +0 -2
- package/package.json +7 -7
- package/infrastructure/domains/scheduler/trigger-builder.js +0 -114
- package/infrastructure/domains/scheduler/trigger-builder.test.js +0 -82
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TriggerBuilder (ADR-055 §2): one tick function per integration with triggers, one schedule per distinct tick and
|
|
3
|
-
* one per `at` trigger, never anything per installation.
|
|
4
|
-
*/
|
|
5
|
-
const { TriggerBuilder, rateExpression } = require('./trigger-builder');
|
|
6
|
-
const { applyFunctionEnvironments } = require('../shared/function-environments');
|
|
7
|
-
|
|
8
|
-
const poll = { every: '15m', handler: 'poll' };
|
|
9
|
-
|
|
10
|
-
describe('TriggerBuilder', () => {
|
|
11
|
-
beforeEach(() => { jest.spyOn(console, 'log').mockImplementation(() => {}); });
|
|
12
|
-
afterEach(() => { jest.restoreAllMocks(); });
|
|
13
|
-
|
|
14
|
-
it('runs when, and only when, an integration declares triggers (code or per installation)', () => {
|
|
15
|
-
const b = new TriggerBuilder();
|
|
16
|
-
expect(b.shouldExecute({ integrations: [{ Definition: { name: 'a', triggers: { poll } } }] })).toBe(true);
|
|
17
|
-
expect(b.shouldExecute({ integrations: [{ Definition: { name: 'dd', instanceTriggers: { tick: '5m' } } }] })).toBe(true);
|
|
18
|
-
expect(b.shouldExecute({ integrations: [{ Definition: { name: 'a', webhooks: true } }] })).toBe(false);
|
|
19
|
-
expect(b.shouldExecute({ integrations: [{ Definition: { name: 'a', triggers: {} } }] })).toBe(false);
|
|
20
|
-
expect(b.shouldExecute({})).toBe(false);
|
|
21
|
-
expect(b.getDependencies()).toEqual(['IntegrationBuilder']);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('writes rate() in the largest whole unit EventBridge accepts', () => {
|
|
25
|
-
expect([1, 5, 60, 90, 120, 1440].map(rateExpression)).toEqual(['rate(1 minute)', 'rate(5 minutes)', 'rate(1 hour)', 'rate(90 minutes)', 'rate(2 hours)', 'rate(1 day)']);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('emits one function per integration: a schedule per distinct tick and one per at trigger, with its zone', async () => {
|
|
29
|
-
const appDefinition = {
|
|
30
|
-
integrations: [
|
|
31
|
-
{ Definition: { name: 'crm', triggers: {
|
|
32
|
-
poll,
|
|
33
|
-
sync: { every: '1h', configurable: { min: '15m' }, handler: 'sync' }, // 15m tick: same schedule as poll
|
|
34
|
-
digest: { cron: '0 8 * * 1-5', timezone: 'America/New_York', handler: 'digest' }, // 5m
|
|
35
|
-
nightly: { at: 'cron(0 3 * * ? *)', timezone: 'Europe/London', handler: 'nightly' },
|
|
36
|
-
} } },
|
|
37
|
-
{ Definition: { name: 'plain' } },
|
|
38
|
-
],
|
|
39
|
-
};
|
|
40
|
-
const result = await new TriggerBuilder().build(appDefinition, {});
|
|
41
|
-
expect(Object.keys(result.functions)).toEqual(['crmTriggers']);
|
|
42
|
-
const fn = result.functions.crmTriggers;
|
|
43
|
-
expect(fn).toMatchObject({
|
|
44
|
-
handler: 'node_modules/@friggframework/core/handlers/workers/integration-triggers.handlers.crm.tick',
|
|
45
|
-
skipEsbuild: true,
|
|
46
|
-
layers: [{ Ref: 'PrismaLambdaLayer' }],
|
|
47
|
-
timeout: 300,
|
|
48
|
-
});
|
|
49
|
-
expect(fn.events).toEqual([
|
|
50
|
-
{ schedule: { rate: ['rate(5 minutes)'], inputTransformer: { inputPathsMap: { time: '$.time' }, inputTemplate: '{"tick":"5m","time":<time>}' } } },
|
|
51
|
-
{ schedule: { rate: ['rate(15 minutes)'], inputTransformer: { inputPathsMap: { time: '$.time' }, inputTemplate: '{"tick":"15m","time":<time>}' } } },
|
|
52
|
-
{ schedule: { method: 'scheduler', rate: ['cron(0 3 * * ? *)'], timezone: 'Europe/London', input: { at: 'nightly', time: '<aws.scheduler.scheduled-time>' } } },
|
|
53
|
-
]);
|
|
54
|
-
// The tick never calls EventBridge Scheduler at runtime: no scheduler IAM, no resources.
|
|
55
|
-
expect(result.iamStatements).toEqual([]);
|
|
56
|
-
expect(result.resources).toEqual({});
|
|
57
|
-
// The inputTemplate is valid JSON once EventBridge fills <time>.
|
|
58
|
-
expect(JSON.parse(fn.events[0].schedule.inputTransformer.inputTemplate.replace('<time>', '"2026-10-19T12:00:00Z"'))).toEqual({ tick: '5m', time: '2026-10-19T12:00:00Z' });
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('leaves the Prisma layer off when the app bundles Prisma', async () => {
|
|
62
|
-
const result = await new TriggerBuilder().build({ usePrismaLambdaLayer: false, integrations: [{ Definition: { name: 'crm', triggers: { poll } } }] }, {});
|
|
63
|
-
expect(result.functions.crmTriggers.layers).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('fails validation, naming the integration, when a trigger cannot be provisioned', () => {
|
|
67
|
-
const v = new TriggerBuilder().validate({ integrations: [{ Definition: { name: 'crm', triggers: { bad: { every: 'often', handler: 'x' } } } }] });
|
|
68
|
-
expect(v.valid).toBe(false);
|
|
69
|
-
expect(v.errors[0]).toMatch(/Integration "crm" declares invalid triggers: bad: every "often"/);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('scoped env: the queue URL reaches the tick function, through the shared function-name contract', async () => {
|
|
73
|
-
const { IntegrationBuilder } = require('../integration/integration-builder');
|
|
74
|
-
const integration = { Definition: { name: 'crm', triggers: { poll } } };
|
|
75
|
-
const ib = new IntegrationBuilder();
|
|
76
|
-
const result = { functionEnvironments: {}, environment: {} };
|
|
77
|
-
ib.setQueueUrlEnvironment('crm', { Ref: 'CrmQueue' }, result, { lambda: { scopedEnvironment: true }, integrations: [integration] });
|
|
78
|
-
const functions = { auth: {}, crm: {}, crmQueueWorker: {}, ...(await new TriggerBuilder().build({ integrations: [integration] }, {})).functions };
|
|
79
|
-
applyFunctionEnvironments(functions, result.functionEnvironments);
|
|
80
|
-
expect(functions.crmTriggers.environment).toEqual({ CRM_QUEUE_URL: { Ref: 'CrmQueue' } });
|
|
81
|
-
});
|
|
82
|
-
});
|