@mettlecast/domain-runtime 0.2.52 → 0.2.53
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/primitives/action.d.ts +3 -0
- package/dist/primitives/action.js +2 -1
- package/dist/primitives/api.d.ts +3 -1
- package/dist/primitives/api.js +3 -1
- package/dist/primitives/events.d.ts +3 -1
- package/dist/primitives/events.js +2 -1
- package/dist/primitives/schedule-job.d.ts +5 -0
- package/dist/primitives/schedule-job.js +4 -2
- package/dist/primitives/webhook.d.ts +3 -0
- package/dist/primitives/webhook.js +2 -1
- package/dist/types/deployment.d.ts +2 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ZodSchema } from 'zod';
|
|
2
2
|
import type { DomainContext } from '../ctx/context.js';
|
|
3
|
+
import type { OutboundAccess } from '../types/index.js';
|
|
3
4
|
/** Who can call this action. */
|
|
4
5
|
export type ActionVisibility = 'private' | 'domain' | 'workspace';
|
|
5
6
|
/** Configuration for an action primitive. */
|
|
@@ -17,6 +18,8 @@ export interface ActionConfig {
|
|
|
17
18
|
* If true, the runtime checks ctx.idempotency before executing.
|
|
18
19
|
*/
|
|
19
20
|
idempotent?: boolean;
|
|
21
|
+
/** Whether this handler may use NAT-backed public internet egress. Defaults to internal. */
|
|
22
|
+
outboundAccess?: OutboundAccess;
|
|
20
23
|
/** Handler implementation. */
|
|
21
24
|
handler: (input: any, ctx: DomainContext) => Promise<any>;
|
|
22
25
|
}
|
|
@@ -5,6 +5,7 @@ const ActionConfigSchema = z.object({
|
|
|
5
5
|
input: z.unknown(),
|
|
6
6
|
output: z.unknown(),
|
|
7
7
|
idempotent: z.boolean().optional(),
|
|
8
|
+
outboundAccess: z.enum(['internal', 'internet']).default('internal'),
|
|
8
9
|
handler: z.function(),
|
|
9
10
|
});
|
|
10
11
|
/**
|
|
@@ -14,5 +15,5 @@ const ActionConfigSchema = z.object({
|
|
|
14
15
|
*/
|
|
15
16
|
export function defineAction(config) {
|
|
16
17
|
ActionConfigSchema.parse(config);
|
|
17
|
-
return { ...config, _kind: 'action' };
|
|
18
|
+
return { ...config, outboundAccess: config.outboundAccess ?? 'internal', _kind: 'action' };
|
|
18
19
|
}
|
package/dist/primitives/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthConfig, RateLimitConfig, TenancyMode, DeploymentConfig, ObservabilityConfig, ApiVersion } from '../types/index.js';
|
|
1
|
+
import type { AuthConfig, RateLimitConfig, TenancyMode, DeploymentConfig, ObservabilityConfig, ApiVersion, OutboundAccess } from '../types/index.js';
|
|
2
2
|
/** Configuration for an API primitive. */
|
|
3
3
|
export interface ApiConfig {
|
|
4
4
|
/** Machine-readable API identifier (kebab-case). */
|
|
@@ -20,6 +20,8 @@ export interface ApiConfig {
|
|
|
20
20
|
rateLimit?: RateLimitConfig;
|
|
21
21
|
/** Deployment overrides. */
|
|
22
22
|
deployment?: DeploymentConfig;
|
|
23
|
+
/** Whether this handler may use NAT-backed public internet egress. Defaults to internal. */
|
|
24
|
+
outboundAccess?: OutboundAccess;
|
|
23
25
|
/** Observability thresholds. */
|
|
24
26
|
observability?: ObservabilityConfig;
|
|
25
27
|
/** Example request/response payloads for documentation (no runtime impact). */
|
package/dist/primitives/api.js
CHANGED
|
@@ -6,6 +6,7 @@ const TenancyModeLiteral = { required: 'required', none: 'none', system: 'system
|
|
|
6
6
|
const VersionStatusLiteral = { preview: 'preview', stable: 'stable', deprecated: 'deprecated', sunset: 'sunset' };
|
|
7
7
|
const AuthTypeLiteral = { jwt: 'jwt', 'api-key': 'api-key', none: 'none' };
|
|
8
8
|
const DeploymentTargetLiteral = { single: 'single', split: 'split' };
|
|
9
|
+
const OutboundAccessLiteral = { internal: 'internal', internet: 'internet' };
|
|
9
10
|
/**
|
|
10
11
|
* Returns true when a Zod schema has been wrapped with `.default(...)` (Zod v4
|
|
11
12
|
* pattern). The wrapped schema exposes a `_def.typeName` of `ZodDefault`.
|
|
@@ -51,6 +52,7 @@ const ApiConfigSchema = z.object({
|
|
|
51
52
|
perIp: z.string().optional(),
|
|
52
53
|
}).optional(),
|
|
53
54
|
deployment: z.object({ target: z.nativeEnum(DeploymentTargetLiteral) }).passthrough().optional(),
|
|
55
|
+
outboundAccess: z.nativeEnum(OutboundAccessLiteral).default(OutboundAccessLiteral.internal),
|
|
54
56
|
observability: z.object({
|
|
55
57
|
sloP99Ms: z.number().positive().optional(),
|
|
56
58
|
alertOnErrorRate: z.number().min(0).max(1).optional(),
|
|
@@ -64,5 +66,5 @@ const ApiConfigSchema = z.object({
|
|
|
64
66
|
*/
|
|
65
67
|
export function defineApi(config) {
|
|
66
68
|
ApiConfigSchema.parse(config);
|
|
67
|
-
return { ...config, _kind: 'api' };
|
|
69
|
+
return { ...config, outboundAccess: config.outboundAccess ?? 'internal', _kind: 'api' };
|
|
68
70
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventVersion, SemverRange } from '../types/index.js';
|
|
1
|
+
import type { EventVersion, SemverRange, OutboundAccess } from '../types/index.js';
|
|
2
2
|
import type { DomainContext } from '../ctx/context.js';
|
|
3
3
|
/** Configuration for an event definition. */
|
|
4
4
|
export interface EventConfig {
|
|
@@ -22,6 +22,8 @@ export interface SubscriberConfig {
|
|
|
22
22
|
semverRange: SemverRange;
|
|
23
23
|
/** Concurrency limit for this subscriber's event processing. */
|
|
24
24
|
concurrency?: number;
|
|
25
|
+
/** Whether this handler may use NAT-backed public internet egress. Defaults to internal. */
|
|
26
|
+
outboundAccess?: OutboundAccess;
|
|
25
27
|
/** Handler receives typed event payload and full ctx. */
|
|
26
28
|
handler: (payload: unknown, ctx: DomainContext) => Promise<void>;
|
|
27
29
|
}
|
|
@@ -15,6 +15,7 @@ const SubscriberConfigSchema = z.object({
|
|
|
15
15
|
event: z.string().min(1),
|
|
16
16
|
semverRange: z.string().min(1),
|
|
17
17
|
concurrency: z.number().int().positive().optional(),
|
|
18
|
+
outboundAccess: z.enum(['internal', 'internet']).default('internal'),
|
|
18
19
|
handler: z.function(),
|
|
19
20
|
});
|
|
20
21
|
/**
|
|
@@ -31,5 +32,5 @@ export function defineEvent(config) {
|
|
|
31
32
|
*/
|
|
32
33
|
export function defineSubscriber(config) {
|
|
33
34
|
SubscriberConfigSchema.parse(config);
|
|
34
|
-
return { ...config, _kind: 'subscriber' };
|
|
35
|
+
return { ...config, outboundAccess: config.outboundAccess ?? 'internal', _kind: 'subscriber' };
|
|
35
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DomainContext } from '../ctx/context.js';
|
|
2
|
+
import type { OutboundAccess } from '../types/index.js';
|
|
2
3
|
/** Configuration for a schedule primitive (cron-triggered). */
|
|
3
4
|
export interface ScheduleConfig {
|
|
4
5
|
/** Machine-readable identifier. */
|
|
@@ -11,6 +12,8 @@ export interface ScheduleConfig {
|
|
|
11
12
|
description?: string;
|
|
12
13
|
/** Whether this schedule is enabled. Defaults to true. */
|
|
13
14
|
enabled?: boolean;
|
|
15
|
+
/** Whether this handler may use NAT-backed public internet egress. Defaults to internal. */
|
|
16
|
+
outboundAccess?: OutboundAccess;
|
|
14
17
|
/** Handler receives no input payload; uses ctx for all data access. */
|
|
15
18
|
handler: (ctx: DomainContext) => Promise<void>;
|
|
16
19
|
}
|
|
@@ -27,6 +30,8 @@ export interface JobConfig {
|
|
|
27
30
|
maxRetries?: number;
|
|
28
31
|
/** Visibility timeout in seconds for the SQS message. */
|
|
29
32
|
visibilityTimeoutSeconds?: number;
|
|
33
|
+
/** Whether this handler may use NAT-backed public internet egress. Defaults to internal. */
|
|
34
|
+
outboundAccess?: OutboundAccess;
|
|
30
35
|
/** Handler receives typed job payload and ctx. */
|
|
31
36
|
handler: (payload: unknown, ctx: DomainContext) => Promise<void>;
|
|
32
37
|
}
|
|
@@ -4,12 +4,14 @@ const ScheduleConfigSchema = z.object({
|
|
|
4
4
|
cron: z.string().min(1),
|
|
5
5
|
description: z.string().optional(),
|
|
6
6
|
enabled: z.boolean().optional(),
|
|
7
|
+
outboundAccess: z.enum(['internal', 'internet']).default('internal'),
|
|
7
8
|
handler: z.function(),
|
|
8
9
|
});
|
|
9
10
|
const JobConfigSchema = z.object({
|
|
10
11
|
id: z.string().min(1),
|
|
11
12
|
maxRetries: z.number().int().nonnegative().optional(),
|
|
12
13
|
visibilityTimeoutSeconds: z.number().int().positive().optional(),
|
|
14
|
+
outboundAccess: z.enum(['internal', 'internet']).default('internal'),
|
|
13
15
|
handler: z.function(),
|
|
14
16
|
});
|
|
15
17
|
/**
|
|
@@ -18,7 +20,7 @@ const JobConfigSchema = z.object({
|
|
|
18
20
|
*/
|
|
19
21
|
export function defineSchedule(config) {
|
|
20
22
|
ScheduleConfigSchema.parse(config);
|
|
21
|
-
return { ...config, _kind: 'schedule' };
|
|
23
|
+
return { ...config, outboundAccess: config.outboundAccess ?? 'internal', _kind: 'schedule' };
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Register a queue-triggered background job.
|
|
@@ -26,5 +28,5 @@ export function defineSchedule(config) {
|
|
|
26
28
|
*/
|
|
27
29
|
export function defineJob(config) {
|
|
28
30
|
JobConfigSchema.parse(config);
|
|
29
|
-
return { ...config, _kind: 'job' };
|
|
31
|
+
return { ...config, outboundAccess: config.outboundAccess ?? 'internal', _kind: 'job' };
|
|
30
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DomainContext } from '../ctx/context.js';
|
|
2
|
+
import type { OutboundAccess } from '../types/index.js';
|
|
2
3
|
/** Supported webhook provider origins. */
|
|
3
4
|
export type WebhookProvider = 'github' | 'stripe' | 'twilio' | 'custom';
|
|
4
5
|
/** HMAC algorithm for signature verification. */
|
|
@@ -20,6 +21,8 @@ export interface WebhookConfig {
|
|
|
20
21
|
path: string;
|
|
21
22
|
/** HMAC signature verification. Required for all providers except 'custom'. */
|
|
22
23
|
verification?: WebhookVerification;
|
|
24
|
+
/** Whether this handler may use NAT-backed public internet egress. Defaults to internal. */
|
|
25
|
+
outboundAccess?: OutboundAccess;
|
|
23
26
|
/** Handler receives raw parsed body and full ctx. */
|
|
24
27
|
handler: (body: unknown, ctx: DomainContext) => Promise<void>;
|
|
25
28
|
}
|
|
@@ -7,6 +7,7 @@ const WebhookConfigSchema = z.object({
|
|
|
7
7
|
type: z.enum(['hmac-sha256', 'hmac-sha1']),
|
|
8
8
|
secretRef: z.string().min(1),
|
|
9
9
|
}).optional(),
|
|
10
|
+
outboundAccess: z.enum(['internal', 'internet']).default('internal'),
|
|
10
11
|
handler: z.function(),
|
|
11
12
|
});
|
|
12
13
|
/**
|
|
@@ -15,5 +16,5 @@ const WebhookConfigSchema = z.object({
|
|
|
15
16
|
*/
|
|
16
17
|
export function defineWebhook(config) {
|
|
17
18
|
WebhookConfigSchema.parse(config);
|
|
18
|
-
return { ...config, _kind: 'webhook' };
|
|
19
|
+
return { ...config, outboundAccess: config.outboundAccess ?? 'internal', _kind: 'webhook' };
|
|
19
20
|
}
|
|
@@ -11,6 +11,8 @@ export interface DeploymentConfig {
|
|
|
11
11
|
/** CPU architecture. Defaults to arm64. */
|
|
12
12
|
architecture?: 'arm64' | 'x86_64';
|
|
13
13
|
}
|
|
14
|
+
/** Controls whether a VPC-attached primitive can reach the public internet. */
|
|
15
|
+
export type OutboundAccess = 'internal' | 'internet';
|
|
14
16
|
/** Observability and alerting thresholds. */
|
|
15
17
|
export interface ObservabilityConfig {
|
|
16
18
|
/** P99 latency SLO in milliseconds. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { Actor, Tenant } from './tenant.js';
|
|
2
2
|
export type { VersionStatus, SemverRange, ApiHandler, ApiVersion, EventVersion } from './versioning.js';
|
|
3
3
|
export type { AuthConfig, RateLimitConfig, TenancyMode } from './auth.js';
|
|
4
|
-
export type { DeploymentConfig, ObservabilityConfig, EnforcementMode } from './deployment.js';
|
|
4
|
+
export type { DeploymentConfig, ObservabilityConfig, EnforcementMode, OutboundAccess } from './deployment.js';
|
|
5
5
|
export type { DomainModuleConfig } from './enforcement.js';
|
|
6
6
|
export { DomainModuleConfigSchema } from './enforcement.js';
|
|
7
7
|
export type { AppError, Result, NotFoundError, ValidationError, ConflictError, UnauthorizedError, ForbiddenError, RateLimitedError, ExternalServiceError, InternalError } from './result.js';
|