@automagik/omni 2.260910.10 → 2.260910.11
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/commands/automations.d.ts +7 -1
- package/dist/commands/automations.d.ts.map +1 -1
- package/dist/commands/events.d.ts +3 -1
- package/dist/commands/events.d.ts.map +1 -1
- package/dist/index.js +99 -50
- package/dist/sdk/client.d.ts +14 -5
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +10 -1
- package/dist/sdk/types.generated.d.ts +156 -92
- package/dist/sdk/types.generated.d.ts.map +1 -1
- package/dist/server/index.js +157 -32
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -76973,7 +76973,7 @@ var require_ClientVoiceManager = __commonJS((exports, module) => {
|
|
|
76973
76973
|
|
|
76974
76974
|
// ../../node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist/index.js
|
|
76975
76975
|
var require_dist9 = __commonJS((exports, module) => {
|
|
76976
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
76976
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist";
|
|
76977
76977
|
var __create2 = Object.create;
|
|
76978
76978
|
var __defProp2 = Object.defineProperty;
|
|
76979
76979
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -162253,7 +162253,7 @@ var require_indexes = __commonJS((exports, module) => {
|
|
|
162253
162253
|
|
|
162254
162254
|
// ../../node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream/index.js
|
|
162255
162255
|
var require_thread_stream = __commonJS((exports, module) => {
|
|
162256
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
162256
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream";
|
|
162257
162257
|
var { version } = require_package5();
|
|
162258
162258
|
var { EventEmitter: EventEmitter3 } = __require("events");
|
|
162259
162259
|
var { Worker } = __require("worker_threads");
|
|
@@ -162674,7 +162674,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
162674
162674
|
|
|
162675
162675
|
// ../../node_modules/.bun/pino@9.14.0/node_modules/pino/lib/transport.js
|
|
162676
162676
|
var require_transport2 = __commonJS((exports, module) => {
|
|
162677
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
162677
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/pino@9.14.0/node_modules/pino/lib";
|
|
162678
162678
|
var { createRequire: createRequire2 } = __require("module");
|
|
162679
162679
|
var getCallers = require_caller();
|
|
162680
162680
|
var { join: join8, isAbsolute, sep: sep2 } = __require("path");
|
|
@@ -244418,7 +244418,7 @@ var require_client3 = __commonJS((exports) => {
|
|
|
244418
244418
|
|
|
244419
244419
|
// ../../node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js
|
|
244420
244420
|
var require_esmLoader = __commonJS((exports) => {
|
|
244421
|
-
var __filename = "/home/runner/work/omni/omni
|
|
244421
|
+
var __filename = "/home/runner/work/omni/omni/node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js";
|
|
244422
244422
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
244423
244423
|
var core3 = require_cjs6();
|
|
244424
244424
|
var importInTheMiddle = require_import_in_the_middle();
|
|
@@ -251644,7 +251644,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
251644
251644
|
var require_package7 = __commonJS((exports, module) => {
|
|
251645
251645
|
module.exports = {
|
|
251646
251646
|
name: "@omni/api",
|
|
251647
|
-
version: "2.260910.
|
|
251647
|
+
version: "2.260910.11",
|
|
251648
251648
|
private: true,
|
|
251649
251649
|
type: "module",
|
|
251650
251650
|
exports: {
|
|
@@ -278746,7 +278746,7 @@ var require_src45 = __commonJS((exports) => {
|
|
|
278746
278746
|
|
|
278747
278747
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/channelz.js
|
|
278748
278748
|
var require_channelz = __commonJS((exports) => {
|
|
278749
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
278749
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
278750
278750
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
278751
278751
|
exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
|
|
278752
278752
|
exports.unregisterChannelzRef = unregisterChannelzRef;
|
|
@@ -284149,7 +284149,7 @@ var require_duration = __commonJS((exports) => {
|
|
|
284149
284149
|
|
|
284150
284150
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/orca.js
|
|
284151
284151
|
var require_orca = __commonJS((exports) => {
|
|
284152
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
284152
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
284153
284153
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
284154
284154
|
exports.OrcaOobMetricsSubchannelWrapper = exports.GRPC_METRICS_HEADER = exports.ServerMetricRecorder = exports.PerRequestMetricRecorder = undefined;
|
|
284155
284155
|
exports.createOrcaClient = createOrcaClient;
|
|
@@ -313279,6 +313279,7 @@ var init_scopes = __esm(() => {
|
|
|
313279
313279
|
"POST /events/consumers/:name/ack": "events:write",
|
|
313280
313280
|
"GET /events": "events:read",
|
|
313281
313281
|
"GET /events/analytics": "events:read",
|
|
313282
|
+
"GET /events/types": "events:read",
|
|
313282
313283
|
"GET /events/timeline/:personId": "events:read",
|
|
313283
313284
|
"POST /events/search": "events:read",
|
|
313284
313285
|
"GET /events/:id": "events:read",
|
|
@@ -314144,6 +314145,7 @@ var init_route_ownership = __esm(() => {
|
|
|
314144
314145
|
"GET /api/v2/events/schemas",
|
|
314145
314146
|
"GET /api/v2/events/schemas/:eventType",
|
|
314146
314147
|
"GET /api/v2/events/timeline/:personId",
|
|
314148
|
+
"GET /api/v2/events/types",
|
|
314147
314149
|
"GET /api/v2/follow-up/agents/:id",
|
|
314148
314150
|
"GET /api/v2/follow-up/chats/:id",
|
|
314149
314151
|
"GET /api/v2/follow-up/instances/:id",
|
|
@@ -368514,17 +368516,38 @@ class AutomationService {
|
|
|
368514
368516
|
}
|
|
368515
368517
|
async test(id, event) {
|
|
368516
368518
|
const automation = await this.getById(id);
|
|
368517
|
-
|
|
368518
|
-
|
|
368519
|
-
}
|
|
368520
|
-
const matched =
|
|
368519
|
+
const triggerMatched = automation.triggerEventType === event.type;
|
|
368520
|
+
const conditionLogic = automation.conditionLogic ?? "and";
|
|
368521
|
+
const conditionResult = evaluateConditionsWithDetails(automation.triggerConditions, { ...event.metadata ?? {}, ...event.payload }, conditionLogic);
|
|
368522
|
+
const matched = triggerMatched && conditionResult.matched;
|
|
368523
|
+
const context20 = createTemplateContext(event.payload, {
|
|
368524
|
+
event: event.id ? {
|
|
368525
|
+
id: event.id,
|
|
368526
|
+
type: event.type,
|
|
368527
|
+
timestamp: event.timestamp ?? Date.now(),
|
|
368528
|
+
metadata: event.metadata ?? {}
|
|
368529
|
+
} : undefined,
|
|
368530
|
+
automation: { id: automation.id, managedByAgentId: automation.managedByAgentId }
|
|
368531
|
+
});
|
|
368521
368532
|
return {
|
|
368522
368533
|
matched,
|
|
368523
|
-
|
|
368534
|
+
triggerMatched,
|
|
368535
|
+
conditionsMatched: conditionResult.matched,
|
|
368536
|
+
conditionLogic,
|
|
368537
|
+
conditions: conditionResult.conditions.map((c) => ({
|
|
368538
|
+
field: c.field,
|
|
368539
|
+
operator: c.operator,
|
|
368540
|
+
expected: c.expectedValue,
|
|
368541
|
+
actual: c.actualValue,
|
|
368542
|
+
resolved: c.actualValue !== undefined,
|
|
368543
|
+
matched: c.matched
|
|
368544
|
+
})),
|
|
368524
368545
|
actions: automation.actions.map((a) => ({
|
|
368525
368546
|
type: a.type,
|
|
368526
|
-
wouldExecute: matched
|
|
368547
|
+
wouldExecute: matched,
|
|
368548
|
+
config: substituteTemplateObject(a.config ?? {}, context20)
|
|
368527
368549
|
})),
|
|
368550
|
+
eventId: event.id ?? null,
|
|
368528
368551
|
dryRun: true
|
|
368529
368552
|
};
|
|
368530
368553
|
}
|
|
@@ -368537,7 +368560,7 @@ class AutomationService {
|
|
|
368537
368560
|
results: []
|
|
368538
368561
|
};
|
|
368539
368562
|
}
|
|
368540
|
-
const correlationId = crypto.randomUUID();
|
|
368563
|
+
const correlationId = event.id ?? crypto.randomUUID();
|
|
368541
368564
|
const context20 = createTemplateContext(event.payload);
|
|
368542
368565
|
const actionDeps = {
|
|
368543
368566
|
eventBus: this.eventBus,
|
|
@@ -370491,6 +370514,9 @@ var init_dead_letters = __esm(() => {
|
|
|
370491
370514
|
function escapeLikePattern(value) {
|
|
370492
370515
|
return value.replace(/([\\%_])/g, "\\$1");
|
|
370493
370516
|
}
|
|
370517
|
+
function consumerTypeMatches(filter, eventType) {
|
|
370518
|
+
return filter.endsWith("*") ? eventType.startsWith(filter.slice(0, -1)) : filter === eventType;
|
|
370519
|
+
}
|
|
370494
370520
|
|
|
370495
370521
|
class EventService {
|
|
370496
370522
|
pool;
|
|
@@ -370722,6 +370748,31 @@ class EventService {
|
|
|
370722
370748
|
timeline
|
|
370723
370749
|
};
|
|
370724
370750
|
}
|
|
370751
|
+
async getTypes(options = {}) {
|
|
370752
|
+
const autos = options.automations ?? [];
|
|
370753
|
+
const [observed, schemas2, consumers] = await Promise.all([
|
|
370754
|
+
this.db.select({
|
|
370755
|
+
eventType: omniEvents.eventType,
|
|
370756
|
+
count: sql`count(*)::int`,
|
|
370757
|
+
lastSeen: sql`max(${omniEvents.receivedAt})::text`
|
|
370758
|
+
}).from(omniEvents).where(options.since ? gte(omniEvents.receivedAt, options.since) : undefined).groupBy(omniEvents.eventType).orderBy(desc(sql`count(*)`)),
|
|
370759
|
+
this.db.select({ eventType: eventSchemas.eventType, version: eventSchemas.version, enabled: eventSchemas.enabled }).from(eventSchemas),
|
|
370760
|
+
this.db.select({ name: durableConsumers.name, eventType: durableConsumers.eventType }).from(durableConsumers)
|
|
370761
|
+
]);
|
|
370762
|
+
const schemaByType = new Map(schemas2.map((s) => [s.eventType, s]));
|
|
370763
|
+
return observed.map((row) => {
|
|
370764
|
+
const schema3 = schemaByType.get(row.eventType);
|
|
370765
|
+
return {
|
|
370766
|
+
eventType: row.eventType,
|
|
370767
|
+
count: row.count,
|
|
370768
|
+
lastSeen: new Date(row.lastSeen).toISOString(),
|
|
370769
|
+
schemaVersion: schema3?.version ?? null,
|
|
370770
|
+
schemaEnabled: schema3?.enabled ?? null,
|
|
370771
|
+
consumers: consumers.filter((c) => consumerTypeMatches(c.eventType, row.eventType)).map((c) => c.name),
|
|
370772
|
+
automations: autos.filter((a) => a.triggerEventType === row.eventType).map((a) => a.name)
|
|
370773
|
+
};
|
|
370774
|
+
});
|
|
370775
|
+
}
|
|
370725
370776
|
}
|
|
370726
370777
|
var TRACE_MAX_ANCESTORS = 50, TRACE_MAX_DEPTH = 10, TRACE_MAX_NODES = 200;
|
|
370727
370778
|
var init_events2 = __esm(() => {
|
|
@@ -378977,6 +379028,7 @@ function registerAutomationSchemas(registry4) {
|
|
|
378977
379028
|
registry4.register("CreateAutomationRequest", CreateAutomationSchema);
|
|
378978
379029
|
registry4.register("AutomationLog", AutomationLogSchema);
|
|
378979
379030
|
registry4.register("TestAutomationRequest", TestAutomationSchema);
|
|
379031
|
+
registry4.register("AutomationTestResult", AutomationTestResultSchema);
|
|
378980
379032
|
registry4.register("AutomationMetrics", AutomationMetricsSchema);
|
|
378981
379033
|
registry4.registerPath({
|
|
378982
379034
|
method: "get",
|
|
@@ -379094,24 +379146,16 @@ function registerAutomationSchemas(registry4) {
|
|
|
379094
379146
|
path: "/automations/{id}/test",
|
|
379095
379147
|
operationId: "testAutomation",
|
|
379096
379148
|
tags: ["Automations"],
|
|
379097
|
-
summary: "Test automation",
|
|
379098
|
-
description: "
|
|
379149
|
+
summary: "Test automation (dry run)",
|
|
379150
|
+
description: "Dry-run an automation against a hand-written event or a REAL journaled event (`eventId`, #1073): " + "trigger match, per-condition verdicts and rendered action templates. Executes nothing, writes no execution log.",
|
|
379099
379151
|
request: {
|
|
379100
379152
|
params: exports_external.object({ id: exports_external.string().uuid().openapi({ description: "Automation UUID" }) }),
|
|
379101
379153
|
body: { content: { "application/json": { schema: TestAutomationSchema } } }
|
|
379102
379154
|
},
|
|
379103
379155
|
responses: {
|
|
379104
379156
|
200: {
|
|
379105
|
-
description: "
|
|
379106
|
-
content: {
|
|
379107
|
-
"application/json": {
|
|
379108
|
-
schema: exports_external.object({
|
|
379109
|
-
matched: exports_external.boolean(),
|
|
379110
|
-
conditionResults: exports_external.array(exports_external.object({ condition: ConditionSchema, passed: exports_external.boolean() })).optional(),
|
|
379111
|
-
wouldExecute: exports_external.array(ActionSchema).optional()
|
|
379112
|
-
})
|
|
379113
|
-
}
|
|
379114
|
-
}
|
|
379157
|
+
description: "Dry-run result",
|
|
379158
|
+
content: { "application/json": { schema: AutomationTestResultSchema } }
|
|
379115
379159
|
},
|
|
379116
379160
|
404: { description: "Not found", content: { "application/json": { schema: ErrorSchema } } }
|
|
379117
379161
|
}
|
|
@@ -379122,7 +379166,7 @@ function registerAutomationSchemas(registry4) {
|
|
|
379122
379166
|
operationId: "executeAutomation",
|
|
379123
379167
|
tags: ["Automations"],
|
|
379124
379168
|
summary: "Execute automation",
|
|
379125
|
-
description: "Execute automation with a provided event payload. Actually runs the actions (not a dry run).",
|
|
379169
|
+
description: "Execute automation with a provided event payload or a journaled event (`eventId`). Actually runs the actions (not a dry run).",
|
|
379126
379170
|
request: {
|
|
379127
379171
|
params: exports_external.object({ id: exports_external.string().uuid().openapi({ description: "Automation UUID" }) }),
|
|
379128
379172
|
body: { content: { "application/json": { schema: TestAutomationSchema } } }
|
|
@@ -379209,7 +379253,7 @@ function registerAutomationSchemas(registry4) {
|
|
|
379209
379253
|
}
|
|
379210
379254
|
});
|
|
379211
379255
|
}
|
|
379212
|
-
var ConditionSchema, WebhookActionSchema, SendMessageActionSchema, EmitEventActionSchema, LogActionSchema, CallAgentActionSchema, ActionSchema, DebounceSchema, AutomationSchema, CreateAutomationSchema, AutomationLogSchema, TestAutomationSchema, AutomationMetricsSchema;
|
|
379256
|
+
var ConditionSchema, WebhookActionSchema, SendMessageActionSchema, EmitEventActionSchema, LogActionSchema, CallAgentActionSchema, ActionSchema, DebounceSchema, AutomationSchema, CreateAutomationSchema, AutomationLogSchema, TestAutomationSchema, AutomationTestResultSchema, AutomationMetricsSchema;
|
|
379213
379257
|
var init_automations3 = __esm(() => {
|
|
379214
379258
|
init_zod_openapi();
|
|
379215
379259
|
init_common4();
|
|
@@ -379329,8 +379373,32 @@ var init_automations3 = __esm(() => {
|
|
|
379329
379373
|
event: exports_external.object({
|
|
379330
379374
|
type: exports_external.string().min(1).openapi({ description: "Event type" }),
|
|
379331
379375
|
payload: exports_external.record(exports_external.string(), exports_external.unknown()).openapi({ description: "Event payload" })
|
|
379376
|
+
}).optional().openapi({ description: "Hand-written event. Exactly one of event / eventId is required" }),
|
|
379377
|
+
eventId: exports_external.string().uuid().optional().openapi({
|
|
379378
|
+
description: "Id of a REAL journaled event (omni_events) to run against (#1073): its rawPayload is the payload, " + "its envelope metadata is merged for conditions. Exactly one of event / eventId is required"
|
|
379332
379379
|
})
|
|
379333
379380
|
});
|
|
379381
|
+
AutomationTestResultSchema = exports_external.object({
|
|
379382
|
+
matched: exports_external.boolean().openapi({ description: "triggerMatched AND conditionsMatched" }),
|
|
379383
|
+
triggerMatched: exports_external.boolean().openapi({ description: "Event type equals the automation trigger" }),
|
|
379384
|
+
conditionsMatched: exports_external.boolean().openapi({ description: "Condition set verdict under conditionLogic" }),
|
|
379385
|
+
conditionLogic: exports_external.enum(["and", "or"]),
|
|
379386
|
+
conditions: exports_external.array(exports_external.object({
|
|
379387
|
+
field: exports_external.string(),
|
|
379388
|
+
operator: exports_external.string(),
|
|
379389
|
+
expected: exports_external.unknown().optional(),
|
|
379390
|
+
actual: exports_external.unknown().optional(),
|
|
379391
|
+
resolved: exports_external.boolean().openapi({ description: "false = the dot path resolved to nothing in the payload" }),
|
|
379392
|
+
matched: exports_external.boolean()
|
|
379393
|
+
})).openapi({ description: "Per-condition verdicts" }),
|
|
379394
|
+
actions: exports_external.array(exports_external.object({
|
|
379395
|
+
type: exports_external.string(),
|
|
379396
|
+
wouldExecute: exports_external.boolean(),
|
|
379397
|
+
config: exports_external.record(exports_external.string(), exports_external.unknown()).openapi({ description: "Action config with templates rendered" })
|
|
379398
|
+
})).openapi({ description: "Rendered actions \u2014 never executed" }),
|
|
379399
|
+
eventId: exports_external.string().uuid().nullable(),
|
|
379400
|
+
dryRun: exports_external.literal(true)
|
|
379401
|
+
});
|
|
379334
379402
|
AutomationMetricsSchema = exports_external.object({
|
|
379335
379403
|
running: exports_external.boolean().openapi({ description: "Engine running" }),
|
|
379336
379404
|
instanceQueues: exports_external.array(exports_external.object({
|
|
@@ -380274,6 +380342,32 @@ function registerEventSchemas(registry4) {
|
|
|
380274
380342
|
200: { description: "Analytics data", content: { "application/json": { schema: EventAnalyticsSchema } } }
|
|
380275
380343
|
}
|
|
380276
380344
|
});
|
|
380345
|
+
registry4.registerPath({
|
|
380346
|
+
method: "get",
|
|
380347
|
+
path: "/events/types",
|
|
380348
|
+
operationId: "listEventTypes",
|
|
380349
|
+
tags: ["Events"],
|
|
380350
|
+
summary: "List observed event types",
|
|
380351
|
+
description: "Inventory of event types observed in the journal: volume and last seen in the window, registered schema version, and subscribed durable consumers / enabled automations.",
|
|
380352
|
+
request: {
|
|
380353
|
+
query: exports_external.object({
|
|
380354
|
+
since: exports_external.string().datetime().optional().openapi({ description: "Only count events received at/after this time" })
|
|
380355
|
+
})
|
|
380356
|
+
},
|
|
380357
|
+
responses: {
|
|
380358
|
+
200: {
|
|
380359
|
+
description: "Event type inventory",
|
|
380360
|
+
content: {
|
|
380361
|
+
"application/json": {
|
|
380362
|
+
schema: exports_external.object({
|
|
380363
|
+
items: exports_external.array(EventTypeInventoryRowSchema),
|
|
380364
|
+
meta: exports_external.object({ since: exports_external.string().datetime().nullable() })
|
|
380365
|
+
})
|
|
380366
|
+
}
|
|
380367
|
+
}
|
|
380368
|
+
}
|
|
380369
|
+
}
|
|
380370
|
+
});
|
|
380277
380371
|
registry4.registerPath({
|
|
380278
380372
|
method: "get",
|
|
380279
380373
|
path: "/events/timeline/{personId}",
|
|
@@ -380387,7 +380481,7 @@ function registerEventSchemas(registry4) {
|
|
|
380387
380481
|
}
|
|
380388
380482
|
});
|
|
380389
380483
|
}
|
|
380390
|
-
var EventSchema, EventSummarySchema, EventAnalyticsSchema, EventTraceSchema, EventSearchSchema;
|
|
380484
|
+
var EventSchema, EventTypeInventoryRowSchema, EventSummarySchema, EventAnalyticsSchema, EventTraceSchema, EventSearchSchema;
|
|
380391
380485
|
var init_events3 = __esm(() => {
|
|
380392
380486
|
init_zod_openapi();
|
|
380393
380487
|
init_common4();
|
|
@@ -380408,6 +380502,15 @@ var init_events3 = __esm(() => {
|
|
|
380408
380502
|
processedAt: exports_external.string().datetime().nullable().openapi({ description: "When event was processed" }),
|
|
380409
380503
|
causationId: exports_external.string().uuid().nullable().openapi({ description: "Id of the immediate parent event (null for roots and pre-#957 rows)" })
|
|
380410
380504
|
});
|
|
380505
|
+
EventTypeInventoryRowSchema = exports_external.object({
|
|
380506
|
+
eventType: exports_external.string().openapi({ description: "Event type" }),
|
|
380507
|
+
count: exports_external.number().int().openapi({ description: "Events observed in the window" }),
|
|
380508
|
+
lastSeen: exports_external.string().datetime().openapi({ description: "Most recent receivedAt in the window" }),
|
|
380509
|
+
schemaVersion: exports_external.number().int().nullable().openapi({ description: "Registered schema version (null = unregistered)" }),
|
|
380510
|
+
schemaEnabled: exports_external.boolean().nullable().openapi({ description: "Whether the registered schema gate is enabled" }),
|
|
380511
|
+
consumers: exports_external.array(exports_external.string()).openapi({ description: "Durable consumer names subscribed to this type" }),
|
|
380512
|
+
automations: exports_external.array(exports_external.string()).openapi({ description: "Enabled automations triggered by this type" })
|
|
380513
|
+
}).openapi("EventTypeInventoryRow");
|
|
380411
380514
|
EventSummarySchema = exports_external.object({
|
|
380412
380515
|
id: exports_external.string().uuid().openapi({ description: "Event UUID" }),
|
|
380413
380516
|
eventType: exports_external.string().openapi({ description: "Event type" }),
|
|
@@ -384942,6 +385045,18 @@ var init_auth3 = __esm(() => {
|
|
|
384942
385045
|
});
|
|
384943
385046
|
|
|
384944
385047
|
// ../api/src/routes/v2/automations.ts
|
|
385048
|
+
async function resolveTestEvent(services, body) {
|
|
385049
|
+
if (body.event)
|
|
385050
|
+
return body.event;
|
|
385051
|
+
const row = await services.events.getById(body.eventId);
|
|
385052
|
+
return {
|
|
385053
|
+
id: row.id,
|
|
385054
|
+
type: row.eventType,
|
|
385055
|
+
payload: row.rawPayload ?? {},
|
|
385056
|
+
metadata: row.metadata ?? undefined,
|
|
385057
|
+
timestamp: row.receivedAt.getTime()
|
|
385058
|
+
};
|
|
385059
|
+
}
|
|
384945
385060
|
var automationsRoutes, conditionSchema, webhookActionSchema, sendMessageActionSchema, emitEventActionSchema, logActionSchema, callAgentActionSchema, actionSchema, debounceSchema, createAutomationSchema, updateAutomationSchema, listQuerySchema5, testAutomationSchema, logsQuerySchema;
|
|
384946
385061
|
var init_automations4 = __esm(() => {
|
|
384947
385062
|
init_dist6();
|
|
@@ -385046,7 +385161,10 @@ var init_automations4 = __esm(() => {
|
|
|
385046
385161
|
event: exports_external.object({
|
|
385047
385162
|
type: exports_external.string().min(1).describe("Event type"),
|
|
385048
385163
|
payload: exports_external.record(exports_external.string(), exports_external.unknown()).describe("Event payload")
|
|
385049
|
-
})
|
|
385164
|
+
}).optional(),
|
|
385165
|
+
eventId: exports_external.string().uuid().optional().describe("Id of a journaled omni_events row to run against")
|
|
385166
|
+
}).refine((b3) => (b3.event ? 1 : 0) + (b3.eventId ? 1 : 0) === 1, {
|
|
385167
|
+
message: 'Provide exactly one of "event" or "eventId"'
|
|
385050
385168
|
});
|
|
385051
385169
|
logsQuerySchema = exports_external.object({
|
|
385052
385170
|
limit: exports_external.coerce.number().int().min(1).max(100).default(50),
|
|
@@ -385120,15 +385238,15 @@ var init_automations4 = __esm(() => {
|
|
|
385120
385238
|
});
|
|
385121
385239
|
automationsRoutes.post("/:id/test", zValidator("json", testAutomationSchema), async (c) => {
|
|
385122
385240
|
const id = c.req.param("id");
|
|
385123
|
-
const { event } = c.req.valid("json");
|
|
385124
385241
|
const services = c.get("services");
|
|
385242
|
+
const event = await resolveTestEvent(services, c.req.valid("json"));
|
|
385125
385243
|
const result = await services.automations.test(id, event);
|
|
385126
385244
|
return c.json(result);
|
|
385127
385245
|
});
|
|
385128
385246
|
automationsRoutes.post("/:id/execute", zValidator("json", testAutomationSchema), async (c) => {
|
|
385129
385247
|
const id = c.req.param("id");
|
|
385130
|
-
const { event } = c.req.valid("json");
|
|
385131
385248
|
const services = c.get("services");
|
|
385249
|
+
const event = await resolveTestEvent(services, c.req.valid("json"));
|
|
385132
385250
|
const result = await services.automations.execute(id, event);
|
|
385133
385251
|
return c.json(result);
|
|
385134
385252
|
});
|
|
@@ -386823,6 +386941,13 @@ var init_events4 = __esm(() => {
|
|
|
386823
386941
|
});
|
|
386824
386942
|
return c.json(analytics);
|
|
386825
386943
|
});
|
|
386944
|
+
eventsRoutes.get("/types", zValidator("query", exports_external.object({ since: optionalDateParam("since") })), async (c) => {
|
|
386945
|
+
const { since } = c.req.valid("query");
|
|
386946
|
+
const services = c.get("services");
|
|
386947
|
+
const automations3 = await services.automations.list({ enabled: true });
|
|
386948
|
+
const items = await services.events.getTypes({ since, automations: automations3 });
|
|
386949
|
+
return c.json({ items, meta: { since: since?.toISOString() ?? null } });
|
|
386950
|
+
});
|
|
386826
386951
|
eventsRoutes.get("/timeline/:personId", zValidator("query", timelineQuerySchema), async (c) => {
|
|
386827
386952
|
const personId = c.req.param("personId");
|
|
386828
386953
|
const query = c.req.valid("query");
|