@process.co/element-types 0.0.25 → 0.0.27

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,8 +1,10 @@
1
1
  /**
2
2
  * Webhook ingress filter chain — author-facing types.
3
3
  *
4
- * Authors call `params.$.http.configureIngressFilters(...)` from `hooks.save`
5
- * to declare a Go-native filter chain that runs at the edge **instead of**
4
+ * Authors declare a static Go-native filter chain with
5
+ * `defineSignal({ ingress: { filters } })`, and may call
6
+ * `params.$.http.configureIngressFilters(...)` from `hooks.save` to replace
7
+ * that default chain. The final chain runs at the edge **instead of**
6
8
  * proxying the request back to Node. The chain is validated at publish time
7
9
  * and persisted onto the element's stash row at {@link INGRESS_FILTERS_KEY}.
8
10
  *
@@ -10,8 +12,8 @@
10
12
  * each filter in order. When the chain is absent the edge falls back to
11
13
  * `ext_proc` (proxy back to the Node API).
12
14
  *
13
- * Style mirrors {@link ./http-request-cache.ts}: a single save-hook host
14
- * method with a typed options shape that materializes onto the element row.
15
+ * Style mirrors {@link ./http-request-cache.ts}: public authoring shape first,
16
+ * reserved `$` materialized row field at save/publish time.
15
17
  */
16
18
 
17
19
  /** Where to read auth material from on the inbound HTTP request. */
@@ -45,17 +47,83 @@ export type IngressVerifyAuthFilter = {
45
47
  /**
46
48
  * Native Go implementation of `http::signal:new-requests`.
47
49
  *
48
- * Receives the published instance row as `config` and uses it to render the
49
- * static response, optionally body-only emit, and project the inbound HTTP
50
- * envelope onto Pulsar in the same shape the Node executor produced.
50
+ * This is a built-in filter for a specific element shape. The chain entry
51
+ * should usually be `{ type: 'http_new_requests' }`; the Go runtime reads
52
+ * authored fields such as `responseType`, `resBodyJSON`, `eventData`, and
53
+ * `resIncludeProcessTicket` from the published element row.
51
54
  */
52
55
  export type IngressHttpNewRequestsFilter = {
53
56
  type: 'http_new_requests';
54
- config: {
57
+ config?: {
55
58
  resStatusCode?: number;
56
59
  resBody?: string;
57
60
  resContentType?: string;
58
61
  emitBodyOnly?: boolean;
62
+ eventData?: 'full' | 'body';
63
+ responseType?: 'OK' | 'NO_CONTENT' | 'STATIC' | 'CUSTOM' | string;
64
+ responseTimeout?: number;
65
+ includeProcessTicket?: boolean;
66
+ summary?: string;
67
+ };
68
+ };
69
+
70
+ /** Validate the selected inbound payload against JSON Schema before emit. */
71
+ export type IngressValidateJSONSchemaFilter = {
72
+ type: 'validate_json_schema';
73
+ config: {
74
+ schema: Record<string, unknown>;
75
+ eventData?: 'full' | 'body';
76
+ responseType?: 'OK' | 'NO_CONTENT' | 'STATIC' | 'CUSTOM' | string;
77
+ };
78
+ };
79
+
80
+ /**
81
+ * Validate the inbound payload against a Zod schema hosted on Node.
82
+ *
83
+ * The Go edge cannot evaluate Zod schemas natively (they are TypeScript
84
+ * runtime objects, not data), so this filter delegates to a Node
85
+ * "validate" microservice at `_internal/zod-validate/:schemaBuildId`.
86
+ * The schema is registered against `schemaBuildId` at element publish
87
+ * time; the edge calls it as a sidecar and reads back a structured
88
+ * result. Aligns with the envoy-style filter chain so we keep full Zod
89
+ * validation on the edge without porting the engine to Go.
90
+ *
91
+ * `failOpen=true` lets the chain continue when the validate endpoint is
92
+ * unreachable. Default is `false` (reject with 502 on outage).
93
+ */
94
+ export type IngressValidateZodFilter = {
95
+ type: 'validate_zod';
96
+ config: {
97
+ /** Stable identity for the registered Zod schema. Required. */
98
+ schemaBuildId: string;
99
+ /** Optional S3 key for the edge-compatible validator artifact. */
100
+ artifactKey?: string;
101
+ /** Legacy/current S3 key for the compiled validator module. */
102
+ compiledValidatorKey?: string;
103
+ /** Optional friendly name used in error messages. */
104
+ schemaName?: string;
105
+ eventData?: 'full' | 'body';
106
+ responseType?: 'OK' | 'NO_CONTENT' | 'STATIC' | 'CUSTOM' | string;
107
+ /** Continue the chain when the validate endpoint cannot be reached. */
108
+ failOpen?: boolean;
109
+ /**
110
+ * Compile-time hint for how the edge should run this validator:
111
+ * `inline` (embedded QuickJS/Zod) or `sidecar` (trusted-tier endpoint).
112
+ * Absent ⇒ edge uses its deployment default (inline, sidecar fallback).
113
+ */
114
+ validatorBackend?: 'inline' | 'sidecar';
115
+ };
116
+ };
117
+
118
+ /**
119
+ * Generic chain equivalent of a source calling `$emit`. Compound filters such
120
+ * as `http_new_requests` may emit directly instead of composing this filter.
121
+ */
122
+ export type IngressEmitFilter = {
123
+ type: '$emit';
124
+ config: {
125
+ eventData?: 'full' | 'body';
126
+ emitBodyOnly?: boolean;
59
127
  summary?: string;
60
128
  };
61
129
  };
@@ -117,13 +185,16 @@ export type IngressJSONPathMetaFilter = {
117
185
  */
118
186
  export type IngressFilterDescriptor =
119
187
  | IngressVerifyAuthFilter
188
+ | IngressValidateJSONSchemaFilter
189
+ | IngressValidateZodFilter
190
+ | IngressEmitFilter
120
191
  | IngressHttpNewRequestsFilter
121
192
  | IngressRespondThenEmitFilter
122
193
  | IngressHMACVerifyFilter
123
194
  | IngressChallengeResponseFilter
124
195
  | IngressJSONPathMetaFilter;
125
196
 
126
- /** Save-only: hooks.save → `$.http.configureIngressFilters`. */
197
+ /** Save-only override: hooks.save → `$.http.configureIngressFilters`. */
127
198
  export type ConfigureIngressFiltersOptions = {
128
199
  filters: IngressFilterDescriptor[];
129
200
  };
@@ -138,6 +209,9 @@ export const INGRESS_FILTERS_KEY = '$ingressFilters' as const;
138
209
  /** Names accepted at publish time. Keep in sync with the Go filter registry. */
139
210
  export const INGRESS_FILTER_TYPES: ReadonlyArray<IngressFilterDescriptor['type']> = [
140
211
  'verify_auth',
212
+ 'validate_json_schema',
213
+ 'validate_zod',
214
+ '$emit',
141
215
  'http_new_requests',
142
216
  'respond_then_emit',
143
217
  'hmac_verify',
@@ -12,6 +12,16 @@ export type ISlotInstanceDefinition = {
12
12
  hideOnDisable?: boolean;
13
13
  actionsPath?: string;
14
14
  exportsPath?: string;
15
+ /** Milliseconds until the container scope times out (element data path). */
16
+ timeoutMsPath?: string;
17
+ /** FERN of the handler to run on timeout (element data path). */
18
+ timeoutHandlerFernPath?: string;
19
+ /** Dispatch mode: `execute` | `signal` (element data path). */
20
+ timeoutHandlerModePath?: string;
21
+ /** Payload path resolved at fire time (element data path). */
22
+ timeoutHandlerDataPath?: string;
23
+ /** Recovery policy: `resurrect` | `drop` (element data path). */
24
+ timeoutRecoveryPolicyPath?: string;
15
25
  };
16
26
 
17
27
  export type ISlotStaticInstanceDefinition = ISlotInstanceDefinition & {