@mettlecast/domain-cdk-packer 0.2.96 → 0.2.98
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/dist/DomainStack.js
CHANGED
|
@@ -217,7 +217,18 @@ export class DomainStack extends cdk.Stack {
|
|
|
217
217
|
const createPrimitiveHandlers = (entries, primitiveType) => {
|
|
218
218
|
const lambdas = [];
|
|
219
219
|
const byId = new Map();
|
|
220
|
-
|
|
220
|
+
// Cross-domain invocation resolves one deterministic internal-action
|
|
221
|
+
// Lambda per domain. Splitting actions by outbound access would create
|
|
222
|
+
// multiple groups with the same physical name and leave some actions
|
|
223
|
+
// unreachable through ctx.actions. Use internet-capable networking when
|
|
224
|
+
// any action needs it so all internal actions stay in that one group.
|
|
225
|
+
const groups = primitiveType === 'action'
|
|
226
|
+
? [{
|
|
227
|
+
outboundAccess: entries.some(entry => normaliseOutboundAccess(entry.outboundAccess) === 'internet') ? 'internet' : 'internal',
|
|
228
|
+
entries,
|
|
229
|
+
}]
|
|
230
|
+
: splitByOutboundAccess(entries);
|
|
231
|
+
for (const group of groups) {
|
|
221
232
|
if (primitiveType === 'action') {
|
|
222
233
|
// Split API-exposed actions from internal actions so they can be
|
|
223
234
|
// grouped into a single Lambda each (instead of one Lambda per action).
|
|
@@ -52,6 +52,17 @@ const registry = {
|
|
|
52
52
|
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
53
53
|
outputSchema: { type: 'object', properties: {}, required: [] },
|
|
54
54
|
},
|
|
55
|
+
{
|
|
56
|
+
id: 'internet-helper',
|
|
57
|
+
kind: 'action',
|
|
58
|
+
handlerFile: 'src/handlers/internet-helper.ts',
|
|
59
|
+
backendAccess: 'domain',
|
|
60
|
+
exposure: { type: 'internal' },
|
|
61
|
+
idempotent: false,
|
|
62
|
+
outboundAccess: 'internet',
|
|
63
|
+
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
64
|
+
outputSchema: { type: 'object', properties: {}, required: [] },
|
|
65
|
+
},
|
|
55
66
|
],
|
|
56
67
|
integrations: [],
|
|
57
68
|
events: [],
|
|
@@ -61,6 +72,7 @@ const registry = {
|
|
|
61
72
|
beforeAll(() => {
|
|
62
73
|
fs.mkdirSync(path.join(DOMAIN_ROOT, 'src', 'handlers'), { recursive: true });
|
|
63
74
|
fs.writeFileSync(path.join(DOMAIN_ROOT, 'src', 'handlers', 'internal-helper.ts'), `export const internalHelper = { id: "internal-helper", backendAccess: "domain", exposure: { type: "internal" }, input: { parse: (x) => x }, output: { parse: (x) => x }, idempotent: false, handler: async () => ({ ok: true }) };\n`);
|
|
75
|
+
fs.writeFileSync(path.join(DOMAIN_ROOT, 'src', 'handlers', 'internet-helper.ts'), `export const internetHelper = { id: "internet-helper", backendAccess: "domain", exposure: { type: "internal" }, input: { parse: (x) => x }, output: { parse: (x) => x }, idempotent: false, handler: async () => ({ ok: true }) };\n`);
|
|
64
76
|
fs.writeFileSync(path.join(DOMAIN_ROOT, 'src', 'handlers', 'on-thing-created.ts'), `export const onThingCreated = { id: "on-thing-created", event: "thing.created", semverRange: "^1", handler: async () => {} };\n`);
|
|
65
77
|
fs.mkdirSync(path.join(DIST_ROOT, 'action'), { recursive: true });
|
|
66
78
|
fs.mkdirSync(path.join(DIST_ROOT, 'subscriber'), { recursive: true });
|
|
@@ -70,7 +82,7 @@ afterAll(() => {
|
|
|
70
82
|
fs.rmSync(path.join(process.cwd(), 'dist', 'domains', 'test-domain'), { recursive: true, force: true });
|
|
71
83
|
});
|
|
72
84
|
describe('DomainStack cross-domain action wiring (#5226)', () => {
|
|
73
|
-
it('
|
|
85
|
+
it('keeps mixed network-access internal actions in one deterministic Lambda', () => {
|
|
74
86
|
const app = new cdk.App();
|
|
75
87
|
const stack = new DomainStack(app, 'TestCrossDomainStack', {
|
|
76
88
|
registry,
|
|
@@ -81,7 +93,9 @@ describe('DomainStack cross-domain action wiring (#5226)', () => {
|
|
|
81
93
|
});
|
|
82
94
|
const template = Template.fromStack(stack);
|
|
83
95
|
const lambdas = template.findResources('AWS::Lambda::Function');
|
|
84
|
-
const
|
|
96
|
+
const actionLambdas = Object.values(lambdas).filter(l => l.Properties.FunctionName === 'test-dev-test-domain-action');
|
|
97
|
+
expect(actionLambdas).toHaveLength(1);
|
|
98
|
+
const [actionLambda] = actionLambdas;
|
|
85
99
|
expect(actionLambda).toBeDefined();
|
|
86
100
|
});
|
|
87
101
|
it('injects TIB_ACTION_LAMBDA_ARNS into subscriber and action Lambdas', () => {
|