@vertesia/common 1.4.0 → 1.5.0-dev.20260713.113008Z
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/lib/access-control.d.ts +31 -6
- package/lib/access-control.d.ts.map +1 -1
- package/lib/access-control.js +12 -2
- package/lib/access-control.js.map +1 -1
- package/lib/apikey.d.ts +29 -5
- package/lib/apikey.d.ts.map +1 -1
- package/lib/apikey.js.map +1 -1
- package/lib/apps.d.ts +78 -4
- package/lib/apps.d.ts.map +1 -1
- package/lib/apps.js +2 -0
- package/lib/apps.js.map +1 -1
- package/lib/audit-trail.d.ts +15 -2
- package/lib/audit-trail.d.ts.map +1 -1
- package/lib/audit-trail.js +20 -0
- package/lib/audit-trail.js.map +1 -1
- package/lib/environment.d.ts +7 -0
- package/lib/environment.d.ts.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/integrations.d.ts +13 -1
- package/lib/integrations.d.ts.map +1 -1
- package/lib/integrations.js.map +1 -1
- package/lib/platform-event-validation.d.ts +45 -0
- package/lib/platform-event-validation.d.ts.map +1 -0
- package/lib/platform-event-validation.js +323 -0
- package/lib/platform-event-validation.js.map +1 -0
- package/lib/platform-event.d.ts +665 -0
- package/lib/platform-event.d.ts.map +1 -0
- package/lib/platform-event.js +2 -0
- package/lib/platform-event.js.map +1 -0
- package/lib/project.d.ts +32 -0
- package/lib/project.d.ts.map +1 -1
- package/lib/project.js.map +1 -1
- package/lib/prompt.d.ts +1 -0
- package/lib/prompt.d.ts.map +1 -1
- package/lib/prompt.js.map +1 -1
- package/lib/query.d.ts +1 -0
- package/lib/query.d.ts.map +1 -1
- package/lib/rate-limiter.d.ts +72 -0
- package/lib/rate-limiter.d.ts.map +1 -1
- package/lib/roles/types.d.ts +1 -1
- package/lib/roles/types.js +1 -1
- package/lib/secrets.d.ts +59 -0
- package/lib/secrets.d.ts.map +1 -1
- package/lib/store/agent-run.d.ts +17 -1
- package/lib/store/agent-run.d.ts.map +1 -1
- package/lib/store/process-validation.js +19 -0
- package/lib/store/process-validation.js.map +1 -1
- package/lib/store/store.d.ts +234 -10
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +3 -1
- package/lib/store/store.js.map +1 -1
- package/lib/store/workflow.d.ts +6 -5
- package/lib/store/workflow.d.ts.map +1 -1
- package/lib/store/workflow.js.map +1 -1
- package/lib/sts-token-types.d.ts +1 -0
- package/lib/sts-token-types.d.ts.map +1 -1
- package/lib/sts-token-types.js.map +1 -1
- package/lib/user.d.ts +36 -1
- package/lib/user.d.ts.map +1 -1
- package/lib/user.js +39 -0
- package/lib/user.js.map +1 -1
- package/lib/vertesia-common.js +3 -2
- package/lib/vertesia-common.js.map +1 -1
- package/package.json +4 -7
- package/src/access-control.ts +31 -6
- package/src/apikey.ts +29 -5
- package/src/apps.ts +87 -4
- package/src/audit-trail.ts +34 -18
- package/src/environment.ts +7 -0
- package/src/index.ts +25 -0
- package/src/integrations.ts +14 -1
- package/src/platform-event-validation.test.ts +225 -0
- package/src/platform-event-validation.ts +359 -0
- package/src/platform-event.ts +771 -0
- package/src/project.ts +38 -0
- package/src/prompt.ts +1 -0
- package/src/query.ts +1 -0
- package/src/rate-limiter.ts +78 -0
- package/src/roles/types.ts +1 -1
- package/src/secrets.ts +69 -0
- package/src/store/agent-run.ts +22 -1
- package/src/store/process-validation.test.ts +62 -0
- package/src/store/process-validation.ts +18 -0
- package/src/store/store.ts +263 -10
- package/src/store/workflow.ts +7 -5
- package/src/sts-token-types.ts +1 -0
- package/src/user.ts +49 -1
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
import type { AuditMeter } from './audit-trail.js';
|
|
2
|
+
import type { ConversationVisibility, InteractionExecutionConfiguration } from './interaction.js';
|
|
3
|
+
import type { SystemRoles } from './project.js';
|
|
4
|
+
import type { AgentRunStatus, JsonLogicRule, ProcessDefinitionBody, ProcessRunType, WorkflowRuleInputType } from './store/index.js';
|
|
5
|
+
export type EventCategory = 'content' | 'workflow' | 'security' | 'billing' | 'system' | 'external';
|
|
6
|
+
export type EventPriority = 'high' | 'normal' | 'low';
|
|
7
|
+
export type WebhookSigningMode = 'signed' | 'legacy_unsigned';
|
|
8
|
+
/**
|
|
9
|
+
* Webhook delivery body format:
|
|
10
|
+
* - event_envelope: the full platform event + delivery metadata (default for new subscriptions)
|
|
11
|
+
* - legacy_notify_endpoint: pre-2025-10 notify_endpoints body {workflowId, runId, status, result}
|
|
12
|
+
* - workflow_notification: post-COMPLETION_RESULT_V1 notify_endpoints body
|
|
13
|
+
* {workflow_id, workflow_name, workflow_run_id, event_name, detail}
|
|
14
|
+
*/
|
|
15
|
+
export type WebhookPayloadMode = 'event_envelope' | 'legacy_notify_endpoint' | 'workflow_notification';
|
|
16
|
+
export type EventOutboxStatus = 'pending' | 'routing' | 'routed' | 'partially_routed' | 'failed' | 'dropped';
|
|
17
|
+
export type EventDeliveryIntentStatus = 'pending' | 'evaluating' | 'starting' | 'running' | 'succeeded' | 'retrying' | 'failed' | 'cancelled' | 'skipped';
|
|
18
|
+
export interface EventRef {
|
|
19
|
+
event_id: string;
|
|
20
|
+
root_event_id: string;
|
|
21
|
+
caused_by_event_id?: string;
|
|
22
|
+
hop_count: number;
|
|
23
|
+
event_category: EventCategory;
|
|
24
|
+
action: string;
|
|
25
|
+
resource_type: string;
|
|
26
|
+
resource_id: string;
|
|
27
|
+
account_id: string | null;
|
|
28
|
+
project_id: string | null;
|
|
29
|
+
tenant_id: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface PlatformEvent extends EventRef {
|
|
32
|
+
timestamp: string;
|
|
33
|
+
source: string;
|
|
34
|
+
audit_trail?: boolean;
|
|
35
|
+
replay_of?: string;
|
|
36
|
+
replay_root_event_id?: string;
|
|
37
|
+
replayed_by?: string;
|
|
38
|
+
request_id?: string | null;
|
|
39
|
+
status?: number;
|
|
40
|
+
success?: boolean;
|
|
41
|
+
principal_id?: string | null;
|
|
42
|
+
principal_type?: string | null;
|
|
43
|
+
effective_principal_id?: string | null;
|
|
44
|
+
roles?: string[];
|
|
45
|
+
account_name?: string | null;
|
|
46
|
+
project_name?: string | null;
|
|
47
|
+
provider?: string | null;
|
|
48
|
+
meters?: AuditMeter[];
|
|
49
|
+
resource_data?: Record<string, unknown>;
|
|
50
|
+
resource_version?: string;
|
|
51
|
+
details?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Lifecycle actions published by the workflow completion interceptor. The names intentionally
|
|
55
|
+
* match the legacy notify_endpoints event_name values so migrated webhook subscribers receive
|
|
56
|
+
* byte-identical status/event_name fields.
|
|
57
|
+
*/
|
|
58
|
+
export type WorkflowLifecycleAction = 'workflow_completed' | 'workflow_failed';
|
|
59
|
+
/**
|
|
60
|
+
* Resource flavor of a workflow lifecycle event, derived from the Temporal workflow type:
|
|
61
|
+
* ExecuteConversationWorkflow -> agent_run, ExecuteProcessWorkflow -> process_run,
|
|
62
|
+
* anything else -> workflow_run.
|
|
63
|
+
*/
|
|
64
|
+
export type WorkflowLifecycleResourceType = 'workflow_run' | 'agent_run' | 'process_run';
|
|
65
|
+
/**
|
|
66
|
+
* Body of POST /internal/events/publish (zeno-server, workload-identity gated). Sent by Temporal
|
|
67
|
+
* workers to publish a workflow lifecycle event to the event bus; the server fills event ids,
|
|
68
|
+
* tenant, timestamp and causality from caused_by.
|
|
69
|
+
*/
|
|
70
|
+
export interface PublishWorkflowLifecycleEventRequest {
|
|
71
|
+
account_id: string;
|
|
72
|
+
project_id: string;
|
|
73
|
+
action: WorkflowLifecycleAction;
|
|
74
|
+
resource_type: WorkflowLifecycleResourceType;
|
|
75
|
+
workflow_id: string;
|
|
76
|
+
workflow_run_id: string;
|
|
77
|
+
workflow_type: string;
|
|
78
|
+
/** Rule/subscription name that started the run (payload.wf_rule_name), used for filtering. */
|
|
79
|
+
workflow_rule_name?: string;
|
|
80
|
+
initiated_by?: string;
|
|
81
|
+
/** Workflow return value for completed runs. */
|
|
82
|
+
result?: unknown;
|
|
83
|
+
/** Error message for failed runs. */
|
|
84
|
+
error?: string;
|
|
85
|
+
/** EventRef of the event that started the workflow (payload.vars.event_ref), if any. */
|
|
86
|
+
caused_by?: EventRef;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A provider-neutral external work-item thread identity. The pair `(resource_type, resource_id)`
|
|
90
|
+
* derives a stable `eventThreadTag` (see `@dglabs/event-bus`), so all events of the same thread
|
|
91
|
+
* correlate to one agent run.
|
|
92
|
+
*/
|
|
93
|
+
export interface EventThreadRef {
|
|
94
|
+
resource_type: string;
|
|
95
|
+
resource_id: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Body of the internal, workload-identity-gated run-threads endpoint. Sent by a Temporal worker so an
|
|
99
|
+
* agent run can register additional external-thread identities on **itself** mid-run, so later events on
|
|
100
|
+
* those threads route to the same run. The server computes the thread tags from `(account, project,
|
|
101
|
+
* resource_type, resource_id)` and idempotently appends them to the run; the worker never supplies a raw
|
|
102
|
+
* tag.
|
|
103
|
+
*/
|
|
104
|
+
export interface AppendAgentRunThreadsRequest {
|
|
105
|
+
account_id: string;
|
|
106
|
+
project_id: string;
|
|
107
|
+
threads: EventThreadRef[];
|
|
108
|
+
}
|
|
109
|
+
export interface AppendAgentRunThreadsResponse {
|
|
110
|
+
/** The thread tags that are now present on the run (the full event-thread tag set). */
|
|
111
|
+
thread_tags: string[];
|
|
112
|
+
}
|
|
113
|
+
export interface EventSubscriptionFilter {
|
|
114
|
+
event_category?: (EventCategory | '*')[];
|
|
115
|
+
exclude_event_category?: EventCategory[];
|
|
116
|
+
action?: string[];
|
|
117
|
+
resource_type?: string[];
|
|
118
|
+
condition?: JsonLogicRule;
|
|
119
|
+
/** LLM-evaluated predicate applied after all structural filters have matched. */
|
|
120
|
+
semantic_condition?: EventSemanticCondition;
|
|
121
|
+
}
|
|
122
|
+
export type SemanticConditionMode = 'enforce' | 'shadow';
|
|
123
|
+
export type SemanticConditionOnError = 'fail_open' | 'fail_closed';
|
|
124
|
+
export type SemanticEvaluationStatus = 'pending' | 'running' | 'matched' | 'not_matched' | 'error';
|
|
125
|
+
/**
|
|
126
|
+
* Evaluates the semantic condition with a single LLM call (no tools). The event envelope —
|
|
127
|
+
* optionally enriched with an excerpt of the content object text — is classified against the
|
|
128
|
+
* instruction.
|
|
129
|
+
*/
|
|
130
|
+
export interface InteractionSemanticEvaluator {
|
|
131
|
+
type: 'interaction';
|
|
132
|
+
/**
|
|
133
|
+
* Optional stored interaction ref used as the classifier. When omitted a built-in ad-hoc
|
|
134
|
+
* classifier prompt is used.
|
|
135
|
+
*/
|
|
136
|
+
interaction_ref?: string;
|
|
137
|
+
config?: InteractionExecutionConfiguration;
|
|
138
|
+
/** Include an excerpt of the content object text when the event resource is a content object. */
|
|
139
|
+
enrich_with_content?: boolean;
|
|
140
|
+
/** Maximum characters of content text included in the classifier prompt. */
|
|
141
|
+
max_content_chars?: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Evaluates the semantic condition with a non-interactive agent run that may use tools to enrich its
|
|
145
|
+
* decision (fetch documents, inspect processes, ...). Slower and more expensive than the interaction
|
|
146
|
+
* evaluator; the delivery intent stays in `evaluating` until the agent completes.
|
|
147
|
+
*/
|
|
148
|
+
export interface AgentSemanticEvaluator {
|
|
149
|
+
type: 'agent';
|
|
150
|
+
/** Agent interaction ref. Defaults to the general-purpose system agent. */
|
|
151
|
+
interaction_ref?: string;
|
|
152
|
+
tool_names?: string[];
|
|
153
|
+
max_iterations?: number;
|
|
154
|
+
config?: InteractionExecutionConfiguration;
|
|
155
|
+
}
|
|
156
|
+
export type SemanticEvaluator = InteractionSemanticEvaluator | AgentSemanticEvaluator;
|
|
157
|
+
/**
|
|
158
|
+
* A natural-language predicate evaluated by an LLM after all structural filters
|
|
159
|
+
* (categories, actions, resource types, JSONLogic condition) have matched.
|
|
160
|
+
*/
|
|
161
|
+
export interface EventSemanticCondition {
|
|
162
|
+
/** Natural-language predicate, e.g. "the document appears to be a signed contract amendment". */
|
|
163
|
+
instruction: string;
|
|
164
|
+
/** Defaults to the interaction evaluator. */
|
|
165
|
+
evaluator?: SemanticEvaluator;
|
|
166
|
+
/**
|
|
167
|
+
* enforce: a negative verdict skips delivery. shadow: the verdict is recorded on the delivery
|
|
168
|
+
* intent but never blocks delivery. Defaults to enforce.
|
|
169
|
+
*/
|
|
170
|
+
mode?: SemanticConditionMode;
|
|
171
|
+
/**
|
|
172
|
+
* What to do when evaluation errors out after retries: fail_open delivers anyway, fail_closed
|
|
173
|
+
* does not deliver. Defaults to fail_closed.
|
|
174
|
+
*/
|
|
175
|
+
on_error?: SemanticConditionOnError;
|
|
176
|
+
}
|
|
177
|
+
export interface SemanticEvaluationRecord {
|
|
178
|
+
status: SemanticEvaluationStatus;
|
|
179
|
+
evaluator_type: 'interaction' | 'agent';
|
|
180
|
+
mode: SemanticConditionMode;
|
|
181
|
+
matched?: boolean;
|
|
182
|
+
rationale?: string;
|
|
183
|
+
error?: string;
|
|
184
|
+
/** Temporal workflow id of the evaluation agent run (agent evaluator only). */
|
|
185
|
+
workflow_id?: string;
|
|
186
|
+
agent_run_id?: string;
|
|
187
|
+
evaluated_at?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface WorkflowEventDeliveryTarget {
|
|
190
|
+
type: 'workflow';
|
|
191
|
+
endpoint: string;
|
|
192
|
+
workflow_class?: string;
|
|
193
|
+
task_queue?: string;
|
|
194
|
+
vars?: Record<string, unknown>;
|
|
195
|
+
input_type?: WorkflowRuleInputType;
|
|
196
|
+
migrated_rule_name?: string;
|
|
197
|
+
}
|
|
198
|
+
export interface WebhookEventDeliveryTarget {
|
|
199
|
+
type: 'webhook';
|
|
200
|
+
url: string;
|
|
201
|
+
/** Server-managed: whether a signing secret is stored. Set by the server, never by callers. */
|
|
202
|
+
has_secret: boolean;
|
|
203
|
+
/** Server-managed: label of the active signing secret. */
|
|
204
|
+
secret_label?: string;
|
|
205
|
+
signing_mode?: WebhookSigningMode;
|
|
206
|
+
payload_mode?: WebhookPayloadMode;
|
|
207
|
+
headers?: Record<string, string>;
|
|
208
|
+
encrypted_headers?: boolean;
|
|
209
|
+
timeout_ms?: number;
|
|
210
|
+
result_path?: string;
|
|
211
|
+
custom_data?: Record<string, unknown>;
|
|
212
|
+
}
|
|
213
|
+
export declare const DEFAULT_EVENT_AGENT_INTERACTION_REF = "sys:GeneralAgent";
|
|
214
|
+
/**
|
|
215
|
+
* How a matching event is applied to the external work-item thread's agent run:
|
|
216
|
+
* - `start` (default): always start a new run. Gating is done by the subscription filter; no
|
|
217
|
+
* `message_path` is needed.
|
|
218
|
+
* - `signal`: deliver only to an *existing* run on the thread (never start) — the follow-up path.
|
|
219
|
+
* `missing_thread` governs the no-run case.
|
|
220
|
+
* - `ensure`: deliver to the run on the thread, **starting one if none exists**.
|
|
221
|
+
*
|
|
222
|
+
* For `signal`/`ensure` the message is delivered **exactly once**: as the run's initial instruction
|
|
223
|
+
* when starting, or as a signal to an existing/restarted run. Correlation is the provider-neutral
|
|
224
|
+
* `eventThreadTag(event_ref)` — the started run is auto-tagged with it and follow-ups recompute the
|
|
225
|
+
* same tag to find the run.
|
|
226
|
+
*/
|
|
227
|
+
export type AgentDeliveryMatchMode = 'start' | 'signal' | 'ensure';
|
|
228
|
+
export interface AgentEventDeliveryTarget {
|
|
229
|
+
type: 'agent';
|
|
230
|
+
/** Behavior when an event matches. Defaults to `start`. */
|
|
231
|
+
on_match?: AgentDeliveryMatchMode;
|
|
232
|
+
/** Interaction ID, app ref, or system ref. Defaults to the general-purpose system agent. */
|
|
233
|
+
interaction_ref?: string;
|
|
234
|
+
data?: Record<string, unknown>;
|
|
235
|
+
config?: InteractionExecutionConfiguration;
|
|
236
|
+
interactive?: boolean;
|
|
237
|
+
visibility?: ConversationVisibility;
|
|
238
|
+
tags?: string[];
|
|
239
|
+
categories?: string[];
|
|
240
|
+
tool_names?: string[];
|
|
241
|
+
max_iterations?: number;
|
|
242
|
+
debug_mode?: boolean;
|
|
243
|
+
/** Signal sent to an existing/restarted run. Only `UserInput` is implemented. */
|
|
244
|
+
signal_name?: 'UserInput';
|
|
245
|
+
/** Dot-path to the message (initial instruction when starting, else the signal). Required for signal/ensure. */
|
|
246
|
+
message_path?: string;
|
|
247
|
+
/** Dot-path to a stable per-message id, carried on the signal for (future) exactly-once dedupe. */
|
|
248
|
+
client_message_id_path?: string;
|
|
249
|
+
/** Run statuses eligible to receive the signal when a run exists. Defaults to ['running']. */
|
|
250
|
+
statuses?: AgentRunStatus[];
|
|
251
|
+
/** If this dot-path resolves to a value, the delivery is skipped. */
|
|
252
|
+
skip_if_path_exists?: string;
|
|
253
|
+
/** Dot-path to the message author, for the loop guard. */
|
|
254
|
+
author_path?: string;
|
|
255
|
+
/** Regex patterns matched against the resolved author; a match skips the delivery (loop guard). */
|
|
256
|
+
ignore_author_patterns?: string[];
|
|
257
|
+
/** The message must start with one of these prefixes to be delivered. */
|
|
258
|
+
require_command_prefixes?: string[];
|
|
259
|
+
/** ...or contain one of these mentions. Combined with prefixes as OR. */
|
|
260
|
+
require_mentions?: string[];
|
|
261
|
+
/** `signal` mode only — no run yet (open/follow-up race): 'retry' (default) or 'skip'. Ignored for `ensure`. */
|
|
262
|
+
missing_thread?: 'retry' | 'skip';
|
|
263
|
+
/** Behaviour when only terminal runs match: `skip` (default) or `restart` then signal. */
|
|
264
|
+
on_terminal?: 'skip' | 'restart';
|
|
265
|
+
/** Extra fields merged into the signal's metadata; same `{{event.*}}` / `$event.x` templating as `data`. */
|
|
266
|
+
metadata?: Record<string, unknown>;
|
|
267
|
+
}
|
|
268
|
+
export interface ProcessEventDeliveryTarget {
|
|
269
|
+
type: 'process';
|
|
270
|
+
/**
|
|
271
|
+
* Stored process ID, app ref, or system ref. Required unless process_definition is supplied.
|
|
272
|
+
*/
|
|
273
|
+
process_ref?: string;
|
|
274
|
+
process_version?: number;
|
|
275
|
+
process_definition?: ProcessDefinitionBody;
|
|
276
|
+
run_type?: ProcessRunType;
|
|
277
|
+
data?: Record<string, unknown>;
|
|
278
|
+
config?: Record<string, unknown>;
|
|
279
|
+
visibility?: ConversationVisibility;
|
|
280
|
+
tags?: string[];
|
|
281
|
+
categories?: string[];
|
|
282
|
+
}
|
|
283
|
+
export type EventDeliveryTarget = WorkflowEventDeliveryTarget | WebhookEventDeliveryTarget | AgentEventDeliveryTarget | ProcessEventDeliveryTarget;
|
|
284
|
+
export type WorkflowEventDeliveryTargetInput = Omit<WorkflowEventDeliveryTarget, 'migrated_rule_name'>;
|
|
285
|
+
export type WebhookEventDeliveryTargetInput = Omit<WebhookEventDeliveryTarget, 'has_secret' | 'secret_label'> & {
|
|
286
|
+
/** Request rotation of the stored signing secret on update. */
|
|
287
|
+
rotate_signing_secret?: boolean;
|
|
288
|
+
};
|
|
289
|
+
export type EventDeliveryTargetInput = WorkflowEventDeliveryTargetInput | WebhookEventDeliveryTargetInput | AgentEventDeliveryTarget | ProcessEventDeliveryTarget;
|
|
290
|
+
export interface MatchedEventSubscriptionSnapshot {
|
|
291
|
+
subscription_id: string;
|
|
292
|
+
subscription_name: string;
|
|
293
|
+
target: EventDeliveryTarget;
|
|
294
|
+
priority: EventPriority;
|
|
295
|
+
run_as_role: SystemRoles;
|
|
296
|
+
/** Semantic condition carried from the subscription filter, evaluated at delivery time. */
|
|
297
|
+
semantic_condition?: EventSemanticCondition;
|
|
298
|
+
}
|
|
299
|
+
export interface EventSubscription {
|
|
300
|
+
id: string;
|
|
301
|
+
name: string;
|
|
302
|
+
description?: string;
|
|
303
|
+
account_id: string;
|
|
304
|
+
project_id?: string;
|
|
305
|
+
scope: 'account' | 'project';
|
|
306
|
+
filter: EventSubscriptionFilter;
|
|
307
|
+
target: EventDeliveryTarget;
|
|
308
|
+
run_as_role: SystemRoles;
|
|
309
|
+
is_system: boolean;
|
|
310
|
+
protected: boolean;
|
|
311
|
+
enabled: boolean;
|
|
312
|
+
priority?: EventPriority;
|
|
313
|
+
created_by?: string;
|
|
314
|
+
updated_by?: string;
|
|
315
|
+
created_at?: string;
|
|
316
|
+
updated_at?: string;
|
|
317
|
+
migrated_from_workflow_rule_id?: string;
|
|
318
|
+
/**
|
|
319
|
+
* System subscription ID replaced by this stored subscription. Set only for
|
|
320
|
+
* tenant-specific system overrides created by migrations or platform code.
|
|
321
|
+
*/
|
|
322
|
+
overrides_system_subscription_id?: string;
|
|
323
|
+
/**
|
|
324
|
+
* True when this system subscription was created from a legacy customer override.
|
|
325
|
+
*/
|
|
326
|
+
customer_override?: boolean;
|
|
327
|
+
}
|
|
328
|
+
export interface CreateEventSubscriptionPayload {
|
|
329
|
+
name: string;
|
|
330
|
+
description?: string;
|
|
331
|
+
scope?: 'account' | 'project';
|
|
332
|
+
filter: EventSubscriptionFilter;
|
|
333
|
+
target: EventDeliveryTargetInput;
|
|
334
|
+
/** Identity the delivery runs as. Required at creation so a subscription never silently runs as the originating (possibly deleted) user. Use "automation" for the standard identity. */
|
|
335
|
+
run_as_role: SystemRoles;
|
|
336
|
+
enabled?: boolean;
|
|
337
|
+
priority?: EventPriority;
|
|
338
|
+
}
|
|
339
|
+
export interface UpdateEventSubscriptionPayload {
|
|
340
|
+
name?: string;
|
|
341
|
+
description?: string;
|
|
342
|
+
filter?: EventSubscriptionFilter;
|
|
343
|
+
target?: EventDeliveryTargetInput;
|
|
344
|
+
run_as_role?: SystemRoles;
|
|
345
|
+
enabled?: boolean;
|
|
346
|
+
priority?: EventPriority;
|
|
347
|
+
}
|
|
348
|
+
export interface EventSubscriptionMutationResponse {
|
|
349
|
+
subscription: EventSubscription;
|
|
350
|
+
webhook_signing_secret?: string;
|
|
351
|
+
}
|
|
352
|
+
export interface EventDeliveryIntentSummary {
|
|
353
|
+
id: string;
|
|
354
|
+
event_id: string;
|
|
355
|
+
subscription_id: string;
|
|
356
|
+
subscription_name: string;
|
|
357
|
+
target_type: EventDeliveryTarget['type'];
|
|
358
|
+
workflow_class?: string | null;
|
|
359
|
+
priority: EventPriority;
|
|
360
|
+
status: EventDeliveryIntentStatus;
|
|
361
|
+
attempt_count: number;
|
|
362
|
+
workflow_id?: string | null;
|
|
363
|
+
workflow_run_id?: string | null;
|
|
364
|
+
response_status?: number | null;
|
|
365
|
+
last_error?: string | null;
|
|
366
|
+
next_attempt_at?: string | null;
|
|
367
|
+
started_at?: string | null;
|
|
368
|
+
completed_at?: string | null;
|
|
369
|
+
semantic_evaluation?: SemanticEvaluationRecord | null;
|
|
370
|
+
created_at: string;
|
|
371
|
+
updated_at: string;
|
|
372
|
+
}
|
|
373
|
+
export interface EventDeliverySummary {
|
|
374
|
+
event_id: string;
|
|
375
|
+
event_category: EventCategory;
|
|
376
|
+
action: string;
|
|
377
|
+
resource_type: string;
|
|
378
|
+
resource_id: string;
|
|
379
|
+
source: string;
|
|
380
|
+
priority: EventPriority;
|
|
381
|
+
status: EventOutboxStatus;
|
|
382
|
+
matched_subscription_count: number;
|
|
383
|
+
materialized_intent_count: number;
|
|
384
|
+
routing_attempt_count: number;
|
|
385
|
+
routing_error?: string | null;
|
|
386
|
+
routed_at?: string | null;
|
|
387
|
+
created_at: string;
|
|
388
|
+
updated_at: string;
|
|
389
|
+
intents: EventDeliveryIntentSummary[];
|
|
390
|
+
}
|
|
391
|
+
export type EventDeliverySortField = 'created_at' | 'status' | 'resource_type' | 'event_category' | 'action';
|
|
392
|
+
export interface ListEventDeliveriesPayload {
|
|
393
|
+
limit?: number;
|
|
394
|
+
event_id?: string;
|
|
395
|
+
resource_id?: string;
|
|
396
|
+
subscription_id?: string;
|
|
397
|
+
status?: EventDeliveryIntentStatus[];
|
|
398
|
+
outbox_status?: EventOutboxStatus[];
|
|
399
|
+
/** Filter by outbox event category (e.g. external, content). */
|
|
400
|
+
event_category?: EventCategory[];
|
|
401
|
+
/** Filter by outbox action (e.g. opened, created). */
|
|
402
|
+
action?: string[];
|
|
403
|
+
/** Filter by outbox resource type (e.g. github_issue, content_object). */
|
|
404
|
+
resource_type?: string[];
|
|
405
|
+
/** Sort field (default created_at). */
|
|
406
|
+
sort_by?: EventDeliverySortField;
|
|
407
|
+
/** Sort order (default desc). */
|
|
408
|
+
sort_order?: 'asc' | 'desc';
|
|
409
|
+
}
|
|
410
|
+
export interface ListEventDeliveriesResponse {
|
|
411
|
+
deliveries: EventDeliverySummary[];
|
|
412
|
+
}
|
|
413
|
+
export type EventSubscriptionSortField = 'name' | 'scope' | 'target_type' | 'enabled' | 'updated_at';
|
|
414
|
+
export interface ListEventSubscriptionsQuery {
|
|
415
|
+
enabled?: boolean;
|
|
416
|
+
target_type?: EventDeliveryTarget['type'][];
|
|
417
|
+
scope?: ('account' | 'project')[];
|
|
418
|
+
sort_by?: EventSubscriptionSortField;
|
|
419
|
+
sort_order?: 'asc' | 'desc';
|
|
420
|
+
}
|
|
421
|
+
export type EventIngestChannelSortField = 'name' | 'source' | 'enabled' | 'updated_at';
|
|
422
|
+
export interface ListEventIngestChannelsQuery {
|
|
423
|
+
enabled?: boolean;
|
|
424
|
+
source?: string[];
|
|
425
|
+
sort_by?: EventIngestChannelSortField;
|
|
426
|
+
sort_order?: 'asc' | 'desc';
|
|
427
|
+
}
|
|
428
|
+
export type EventDeliveryQueueSortField = 'subscription_name' | 'queued' | 'active' | 'failed' | 'oldest';
|
|
429
|
+
export interface EventDeliveryQueueSummaryPayload {
|
|
430
|
+
subscription_id?: string;
|
|
431
|
+
target_type?: EventDeliveryTarget['type'][];
|
|
432
|
+
sort_by?: EventDeliveryQueueSortField;
|
|
433
|
+
sort_order?: 'asc' | 'desc';
|
|
434
|
+
}
|
|
435
|
+
export interface EventOutboxQueueSummary {
|
|
436
|
+
total: number;
|
|
437
|
+
active: number;
|
|
438
|
+
failed: number;
|
|
439
|
+
dropped: number;
|
|
440
|
+
by_status: Record<string, number>;
|
|
441
|
+
oldest_active_at?: string;
|
|
442
|
+
}
|
|
443
|
+
export interface EventDeliveryQueueFailureSummary {
|
|
444
|
+
intent_id: string;
|
|
445
|
+
event_id: string;
|
|
446
|
+
status: EventDeliveryIntentStatus;
|
|
447
|
+
attempt_count: number;
|
|
448
|
+
last_error?: string | null;
|
|
449
|
+
updated_at: string;
|
|
450
|
+
}
|
|
451
|
+
export interface EventDeliveryQueueSubscriptionSummary {
|
|
452
|
+
subscription_id: string;
|
|
453
|
+
subscription_name: string;
|
|
454
|
+
target_type: EventDeliveryTarget['type'];
|
|
455
|
+
total: number;
|
|
456
|
+
queued: number;
|
|
457
|
+
deferred: number;
|
|
458
|
+
active: number;
|
|
459
|
+
failed: number;
|
|
460
|
+
skipped: number;
|
|
461
|
+
max_attempt_count: number;
|
|
462
|
+
oldest_queued_at?: string;
|
|
463
|
+
oldest_deferred_at?: string;
|
|
464
|
+
latest_failure?: EventDeliveryQueueFailureSummary;
|
|
465
|
+
}
|
|
466
|
+
export interface EventDeliveryQueueSummaryResponse {
|
|
467
|
+
generated_at: string;
|
|
468
|
+
outbox: EventOutboxQueueSummary;
|
|
469
|
+
deliveries: EventDeliveryQueueSubscriptionSummary[];
|
|
470
|
+
}
|
|
471
|
+
export interface PublishPlatformEventPayload {
|
|
472
|
+
event: PlatformEvent;
|
|
473
|
+
priority?: EventPriority;
|
|
474
|
+
}
|
|
475
|
+
export interface PublishPlatformEventResponse {
|
|
476
|
+
event_id: string;
|
|
477
|
+
outbox_id?: string;
|
|
478
|
+
status: EventOutboxStatus;
|
|
479
|
+
matched_subscription_count: number;
|
|
480
|
+
materialized_intent_count: number;
|
|
481
|
+
}
|
|
482
|
+
export interface WorkflowEventInput<T = Record<string, unknown>> {
|
|
483
|
+
event_ref: EventRef;
|
|
484
|
+
payload: T;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* A conditional rule for deriving `resource_type` + `resource_id` from the body, evaluated in order
|
|
488
|
+
* (first match wins) when a single dot-path can't serve every payload shape a channel receives. A
|
|
489
|
+
* sender whose one webhook delivers heterogeneous events (e.g. a GitHub App: issues, issue comments,
|
|
490
|
+
* PR reviews) needs different thread identities per event family; these rules express that without
|
|
491
|
+
* baking provider knowledge into the server.
|
|
492
|
+
*/
|
|
493
|
+
export interface EventIngestResourceRule {
|
|
494
|
+
/** Match when the captured `event_type` (see `event_type_header`) is one of these. */
|
|
495
|
+
event_type?: string[];
|
|
496
|
+
/** Match only when this dot-path resolves to a defined, non-null value (e.g. `issue.pull_request`). */
|
|
497
|
+
when_path_exists?: string;
|
|
498
|
+
/** Match only when this dot-path is undefined/null. */
|
|
499
|
+
when_path_absent?: string;
|
|
500
|
+
/** `resource_type` to set when this rule matches. */
|
|
501
|
+
resource_type?: string;
|
|
502
|
+
/** `resource_id` from a single dot-path. */
|
|
503
|
+
resource_id_path?: string;
|
|
504
|
+
/**
|
|
505
|
+
* ...or a composed `resource_id` from a `{{dot.path}}` template against the body, e.g.
|
|
506
|
+
* `{{repository.full_name}}#{{pull_request.number}}`. Takes precedence over `resource_id_path`.
|
|
507
|
+
*/
|
|
508
|
+
resource_id_template?: string;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Declarative mapping from a raw third-party webhook body to platform event fields, for senders that
|
|
512
|
+
* cannot shape their payload (GitHub, Slack, DocuSign, Salesforce, ...). Each `*_path` is a dot-path
|
|
513
|
+
* into the JSON body (array indices supported, e.g. `commits.0.id`). Extracted values override the
|
|
514
|
+
* channel defaults; the full raw body is always preserved under `event.details.payload`.
|
|
515
|
+
*/
|
|
516
|
+
export interface EventIngestTransform {
|
|
517
|
+
/** Dot-path to the value used as `event.action`, e.g. `event.type`. */
|
|
518
|
+
action_path?: string;
|
|
519
|
+
/** Dot-path to the value used as `event.resource_type`. */
|
|
520
|
+
resource_type_path?: string;
|
|
521
|
+
/** Dot-path to the value used as `event.resource_id`. */
|
|
522
|
+
resource_id_path?: string;
|
|
523
|
+
/**
|
|
524
|
+
* Request **header** carrying the event family (e.g. GitHub's `x-github-event`), captured into
|
|
525
|
+
* `event.details.event_type`. Lets subscriptions and `resource_rules` discriminate event shapes when
|
|
526
|
+
* one channel receives heterogeneous payloads whose `action` alone is ambiguous (e.g. `created` for
|
|
527
|
+
* both an issue comment and a PR review comment).
|
|
528
|
+
*/
|
|
529
|
+
event_type_header?: string;
|
|
530
|
+
/**
|
|
531
|
+
* Ordered conditional rules for `resource_type` + `resource_id` (first match wins). Used when a single
|
|
532
|
+
* `resource_id_path` can't serve every payload shape. Falls back to `resource_type_path` /
|
|
533
|
+
* `resource_id_path` / channel defaults when no rule matches.
|
|
534
|
+
*/
|
|
535
|
+
resource_rules?: EventIngestResourceRule[];
|
|
536
|
+
/** Dot-path to a deduplication key (same semantics as `idempotency_key`). */
|
|
537
|
+
idempotency_key_path?: string;
|
|
538
|
+
/**
|
|
539
|
+
* Request **header** to use as the deduplication key when the body has no stable per-delivery id —
|
|
540
|
+
* e.g. GitHub App's `x-github-delivery`, unique per delivery for all event types, which is the only
|
|
541
|
+
* reliable dedup key when one App webhook delivers heterogeneous payloads (issues + comments) to a
|
|
542
|
+
* single channel. Lower precedence than `idempotency_key_path`.
|
|
543
|
+
*/
|
|
544
|
+
idempotency_key_header?: string;
|
|
545
|
+
/** Dot-path to an ISO 8601 event timestamp. */
|
|
546
|
+
timestamp_path?: string;
|
|
547
|
+
/** Static fields merged into `event.details`. */
|
|
548
|
+
static_details?: Record<string, unknown>;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* How an ingest channel authenticates inbound requests in addition to the channel ingest token:
|
|
552
|
+
* - none (default): token only.
|
|
553
|
+
* - hmac: the sender signs the raw request body with a shared secret (GitHub/Stripe style) and the
|
|
554
|
+
* server verifies the signature. The token may then be optional (`token_optional`).
|
|
555
|
+
*/
|
|
556
|
+
export type EventIngestSignatureAlgorithm = 'sha256' | 'sha1';
|
|
557
|
+
export type EventIngestSignatureEncoding = 'hex' | 'base64';
|
|
558
|
+
/**
|
|
559
|
+
* Optional HMAC signature verification for an ingest channel. When configured, the server recomputes
|
|
560
|
+
* `HMAC(algorithm, signing_secret, rawBody)` and compares it (timing-safe) to the value in
|
|
561
|
+
* `header`, after stripping `prefix`. Covers GitHub-style `X-Hub-Signature-256: sha256=<hex>` and a
|
|
562
|
+
* plain Salesforce Apex-callout HMAC.
|
|
563
|
+
*/
|
|
564
|
+
export interface EventIngestSignatureConfig {
|
|
565
|
+
/** Request header carrying the signature, e.g. `x-hub-signature-256`. */
|
|
566
|
+
header: string;
|
|
567
|
+
algorithm?: EventIngestSignatureAlgorithm;
|
|
568
|
+
encoding?: EventIngestSignatureEncoding;
|
|
569
|
+
/** Literal prefix stripped from the header value before comparison, e.g. `sha256=`. */
|
|
570
|
+
prefix?: string;
|
|
571
|
+
/** Server-managed: whether a signing secret is stored for this channel. */
|
|
572
|
+
has_secret?: boolean;
|
|
573
|
+
/** Server-managed: label/hint of the stored signing secret. */
|
|
574
|
+
secret_hint?: string;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* An inbound channel that lets external systems publish events into the platform event bus. Events
|
|
578
|
+
* ingested through a channel get `event_category: 'external'` and `source: 'external:<source>'`, and
|
|
579
|
+
* are matched against event subscriptions like any other platform event.
|
|
580
|
+
*/
|
|
581
|
+
export interface EventIngestChannel {
|
|
582
|
+
id: string;
|
|
583
|
+
name: string;
|
|
584
|
+
description?: string;
|
|
585
|
+
account_id: string;
|
|
586
|
+
project_id: string;
|
|
587
|
+
/** Source label stamped on ingested events as `external:<source>`. */
|
|
588
|
+
source: string;
|
|
589
|
+
enabled: boolean;
|
|
590
|
+
/** Action used when the ingest payload does not specify one. */
|
|
591
|
+
default_action?: string;
|
|
592
|
+
/** Resource type used when the ingest payload does not specify one. */
|
|
593
|
+
default_resource_type?: string;
|
|
594
|
+
/** Optional mapping from raw third-party payloads to event fields. */
|
|
595
|
+
transform?: EventIngestTransform;
|
|
596
|
+
/** Optional HMAC signature verification config. */
|
|
597
|
+
signature?: EventIngestSignatureConfig;
|
|
598
|
+
priority: EventPriority;
|
|
599
|
+
/** Server-managed: whether an ingest token is active for this channel. */
|
|
600
|
+
has_token: boolean;
|
|
601
|
+
/** Server-managed: last characters of the active token, for identification. */
|
|
602
|
+
token_hint?: string;
|
|
603
|
+
created_by?: string;
|
|
604
|
+
updated_by?: string;
|
|
605
|
+
created_at?: string;
|
|
606
|
+
updated_at?: string;
|
|
607
|
+
}
|
|
608
|
+
export interface CreateEventIngestChannelPayload {
|
|
609
|
+
name: string;
|
|
610
|
+
description?: string;
|
|
611
|
+
/** Defaults to a slug derived from the name. */
|
|
612
|
+
source?: string;
|
|
613
|
+
default_action?: string;
|
|
614
|
+
default_resource_type?: string;
|
|
615
|
+
transform?: EventIngestTransform;
|
|
616
|
+
signature?: EventIngestSignatureConfig;
|
|
617
|
+
priority?: EventPriority;
|
|
618
|
+
enabled?: boolean;
|
|
619
|
+
}
|
|
620
|
+
export interface UpdateEventIngestChannelPayload {
|
|
621
|
+
name?: string;
|
|
622
|
+
description?: string;
|
|
623
|
+
source?: string;
|
|
624
|
+
default_action?: string;
|
|
625
|
+
default_resource_type?: string;
|
|
626
|
+
/** Pass null to remove the transform. */
|
|
627
|
+
transform?: EventIngestTransform | null;
|
|
628
|
+
/** Pass null to remove signature verification. */
|
|
629
|
+
signature?: EventIngestSignatureConfig | null;
|
|
630
|
+
priority?: EventPriority;
|
|
631
|
+
enabled?: boolean;
|
|
632
|
+
/** Request rotation of the channel ingest token on update. */
|
|
633
|
+
rotate_token?: boolean;
|
|
634
|
+
/** Request rotation of the HMAC signing secret on update. */
|
|
635
|
+
rotate_signing_secret?: boolean;
|
|
636
|
+
}
|
|
637
|
+
export interface EventIngestChannelMutationResponse {
|
|
638
|
+
channel: EventIngestChannel;
|
|
639
|
+
/** Returned once on creation or rotation; it cannot be retrieved later. */
|
|
640
|
+
ingest_token?: string;
|
|
641
|
+
/** Returned once on creation or rotation of the signing secret; it cannot be retrieved later. */
|
|
642
|
+
signing_secret?: string;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Body accepted by the public ingest webhook
|
|
646
|
+
* `POST /webhooks/events/:accountId/:projectId/:channelId`. All fields are optional: when omitted the
|
|
647
|
+
* channel transform / defaults are applied. The raw body is preserved under `event.details.payload`.
|
|
648
|
+
*/
|
|
649
|
+
export interface IngestExternalEventPayload {
|
|
650
|
+
action?: string;
|
|
651
|
+
resource_type?: string;
|
|
652
|
+
resource_id?: string;
|
|
653
|
+
/** Domain payload; defaults to the full raw body when omitted. */
|
|
654
|
+
payload?: Record<string, unknown>;
|
|
655
|
+
/** Extra fields merged into `event.details`. */
|
|
656
|
+
details?: Record<string, unknown>;
|
|
657
|
+
/** Deduplication key: the same key produces the same event id. */
|
|
658
|
+
idempotency_key?: string;
|
|
659
|
+
/** ISO 8601 event timestamp; defaults to ingest time. */
|
|
660
|
+
timestamp?: string;
|
|
661
|
+
}
|
|
662
|
+
export interface IngestExternalEventResponse {
|
|
663
|
+
event_id: string;
|
|
664
|
+
}
|
|
665
|
+
//# sourceMappingURL=platform-event.d.ts.map
|