@mettlecast/domain-runtime 0.2.93 → 0.2.94

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.
@@ -1,11 +1,27 @@
1
1
  import type { SQSEvent, SQSBatchResponse } from 'aws-lambda';
2
2
  import type { SubscriberDefinition } from '../primitives/events.js';
3
+ import type { ActionRegistry } from './actions.js';
3
4
  /**
4
5
  * Options for createSubscriberLambdaHandler.
5
6
  */
6
7
  export interface CreateSubscriberHandlerOptions {
7
8
  /** Optional list of secret names to pre-fetch. */
8
9
  secretNames?: string[];
10
+ /**
11
+ * Action registry for the subscriber's `ctx.actions` proxy. Registered
12
+ * entries run in-process inside this Lambda; domains listed in
13
+ * `lambdaArns` are dispatched via Lambda invoke (cross-domain).
14
+ *
15
+ * When omitted, `ctx.actions` is an empty proxy — subscribers that call
16
+ * `ctx.actions.otherDomain.someAction(...)` would fail. The generated
17
+ * scaffold wires this from the domain registry so subscribers can invoke
18
+ * actions (e.g. `on-member-invited` calling `email.send-template-email`).
19
+ */
20
+ actionRegistry?: ActionRegistry;
21
+ /** Map of domainId → action Lambda ARN for cross-domain calls. */
22
+ lambdaArns?: Record<string, string>;
23
+ /** This subscriber's owning domain ID (used in the invocation envelope). */
24
+ callerDomainId?: string;
9
25
  }
10
26
  /**
11
27
  * Wrap a SubscriberDefinition into an AWS Lambda SQS batch handler.
@@ -17,6 +17,13 @@ export function createSubscriberLambdaHandler(subscriber, options) {
17
17
  databaseUrl: process.env['DATABASE_URL'],
18
18
  eventBusName: process.env['EVENT_BUS_NAME'],
19
19
  secretNames: options?.secretNames,
20
+ // Wire the subscriber's `ctx.actions` proxy. Passing an always-truthy
21
+ // registry (even an empty `{}`) makes hydrateCtx construct a
22
+ // createActionsProxy so `lambdaArns` cross-domain dispatch is honoured;
23
+ // without it ctx.actions is an empty object and any action call throws.
24
+ actionRegistry: options?.actionRegistry ?? {},
25
+ lambdaArns: options?.lambdaArns,
26
+ callerDomainId: options?.callerDomainId,
20
27
  });
21
28
  try {
22
29
  // Process all records in parallel via Promise.allSettled
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mettlecast/domain-runtime",
3
- "version": "0.2.93",
3
+ "version": "0.2.94",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",