@lobu/runtime-server 24.1.0 → 24.1.1
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/component.json
CHANGED
|
@@ -6845,7 +6845,7 @@ function isSemanticallyEqual(existing, params) {
|
|
|
6845
6845
|
// from this comparison and from `score` below — they are reconciled in
|
|
6846
6846
|
// place by applyVolatileState instead of minting a new stored version.
|
|
6847
6847
|
durableMetadataState(existing.metadata) === durableMetadataState(params.metadata) && // Compare the value a supersede would WRITE: a null parentOriginId copies
|
|
6848
|
-
// the predecessor's parent (
|
|
6848
|
+
// the predecessor's parent (EVENT_SUPERSEDE_RULES), so only a caller-supplied
|
|
6849
6849
|
// parent can differ. Comparing the raw param would re-supersede a
|
|
6850
6850
|
// copied-parent head on every parentless re-sync, forever.
|
|
6851
6851
|
(params.parentOriginId == null || (existing.origin_parent_id ?? null) === params.parentOriginId) && existing.interaction_type === (params.interactionType ?? "none") && (existing.interaction_status ?? null) === (params.interactionStatus ?? null) && stableJson(existing.interaction_input_schema ?? null) === stableJson(params.interactionInputSchema ?? null) && stableJson(existing.interaction_input ?? null) === stableJson(params.interactionInput ?? null) && stableJson(existing.interaction_output ?? null) === stableJson(params.interactionOutput ?? null) && (existing.interaction_error ?? null) === (params.interactionError ?? null);
|
|
@@ -6889,37 +6889,42 @@ async function upsertEmbedding(eventId, embedding, embeddingModel, sql = getDb()
|
|
|
6889
6889
|
await sql.begin(async (tx) => replaceIfLive(tx));
|
|
6890
6890
|
}
|
|
6891
6891
|
}
|
|
6892
|
-
function
|
|
6893
|
-
return
|
|
6892
|
+
function requestedLineage(params) {
|
|
6893
|
+
return {
|
|
6894
|
+
origin_parent_id: params.parentOriginId ?? null,
|
|
6895
|
+
connector_key: params.connectorKey ?? null,
|
|
6896
|
+
connection_id: params.connectionId ?? null,
|
|
6897
|
+
feed_key: params.feedKey ?? null,
|
|
6898
|
+
feed_id: params.feedId ?? null,
|
|
6899
|
+
run_id: params.runId ?? null,
|
|
6900
|
+
automation_id: params.automationId ?? null,
|
|
6901
|
+
automation_version_id: params.automationVersionId ?? null,
|
|
6902
|
+
client_id: params.clientId ?? null,
|
|
6903
|
+
identity_ns: params.identity?.ns ?? null,
|
|
6904
|
+
identity_key: params.identity?.key ?? null
|
|
6905
|
+
};
|
|
6894
6906
|
}
|
|
6895
|
-
async function
|
|
6896
|
-
const rows = await sql
|
|
6897
|
-
SELECT
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
LIMIT 1
|
|
6904
|
-
`;
|
|
6905
|
-
const prior = rows[0];
|
|
6906
|
-
if (!prior) {
|
|
6907
|
+
async function loadPredecessorLineage(sql, supersedesEventId, organizationId) {
|
|
6908
|
+
const rows = await sql.unsafe(
|
|
6909
|
+
`SELECT ${INHERITED_COLUMNS.join(", ")} FROM events
|
|
6910
|
+
WHERE id = $1 AND organization_id = $2
|
|
6911
|
+
LIMIT 1`,
|
|
6912
|
+
[supersedesEventId, organizationId]
|
|
6913
|
+
);
|
|
6914
|
+
if (!rows[0]) {
|
|
6907
6915
|
throw new Error(
|
|
6908
|
-
`insertEvent: cannot supersede event ${supersedesEventId} \u2014 not found in organization ${
|
|
6916
|
+
`insertEvent: cannot supersede event ${supersedesEventId} \u2014 not found in organization ${organizationId}`
|
|
6909
6917
|
);
|
|
6910
6918
|
}
|
|
6911
|
-
return
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
identityNs: prior.identity_ns ?? null,
|
|
6921
|
-
identityKey: prior.identity_key ?? null
|
|
6922
|
-
};
|
|
6919
|
+
return rows[0];
|
|
6920
|
+
}
|
|
6921
|
+
function successorLineage(prior, requested) {
|
|
6922
|
+
return Object.fromEntries(
|
|
6923
|
+
INHERITED_COLUMNS.map((column) => [
|
|
6924
|
+
column,
|
|
6925
|
+
EVENT_SUPERSEDE_RULES[column] === "chain" ? prior[column] : requested[column] ?? prior[column]
|
|
6926
|
+
])
|
|
6927
|
+
);
|
|
6923
6928
|
}
|
|
6924
6929
|
function isEventsClientIdForeignKeyViolation(error) {
|
|
6925
6930
|
const err = error;
|
|
@@ -6992,7 +6997,6 @@ async function insertEvent(params, options) {
|
|
|
6992
6997
|
params = { ...params, metadata: enrichedMetadata };
|
|
6993
6998
|
}
|
|
6994
6999
|
const entityIdsValue = params.entityIds.length > 0 ? `{${params.entityIds.join(",")}}` : null;
|
|
6995
|
-
const requestedClientId = params.clientId ?? null;
|
|
6996
7000
|
const runInsert = async (activeSql) => {
|
|
6997
7001
|
let supersedesEventId = params.supersedesEventId ?? null;
|
|
6998
7002
|
let previousOccurredAt;
|
|
@@ -7051,25 +7055,18 @@ async function insertEvent(params, options) {
|
|
|
7051
7055
|
return insertRow(activeSql, supersedesEventId, previousOccurredAt);
|
|
7052
7056
|
};
|
|
7053
7057
|
const insertRow = async (sql2, supersedesEventId, previousOccurredAt) => {
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
runId: params.runId ?? null,
|
|
7060
|
-
automationId: params.automationId ?? null,
|
|
7061
|
-
automationVersionId: params.automationVersionId ?? null,
|
|
7062
|
-
parentOriginId: params.parentOriginId ?? null,
|
|
7063
|
-
identityNs: params.identity?.ns ?? null,
|
|
7064
|
-
identityKey: params.identity?.key ?? null
|
|
7065
|
-
};
|
|
7058
|
+
const requested = requestedLineage(params);
|
|
7059
|
+
let lineage = supersedesEventId == null ? requested : successorLineage(
|
|
7060
|
+
await loadPredecessorLineage(sql2, supersedesEventId, params.organizationId),
|
|
7061
|
+
requested
|
|
7062
|
+
);
|
|
7066
7063
|
if (browserConnector) {
|
|
7067
7064
|
lineage = {
|
|
7068
7065
|
...lineage,
|
|
7069
|
-
|
|
7066
|
+
origin_parent_id: sanitizeBrowserText(lineage.origin_parent_id) ?? null
|
|
7070
7067
|
};
|
|
7071
7068
|
}
|
|
7072
|
-
const insertWithClientId = (activeSql,
|
|
7069
|
+
const insertWithClientId = (activeSql, clientId2) => activeSql`
|
|
7073
7070
|
INSERT INTO events (
|
|
7074
7071
|
entity_ids, organization_id, origin_id, title,
|
|
7075
7072
|
payload_type, payload_text, payload_data, payload_template, attachments, metadata,
|
|
@@ -7096,17 +7093,17 @@ async function insertEvent(params, options) {
|
|
|
7096
7093
|
${params.authorName ?? null},
|
|
7097
7094
|
${params.sourceUrl ?? null},
|
|
7098
7095
|
${params.occurredAt ?? /* @__PURE__ */ new Date()},
|
|
7099
|
-
${lineage.
|
|
7096
|
+
${lineage.origin_parent_id},
|
|
7100
7097
|
${params.originType ?? null},
|
|
7101
|
-
${lineage.
|
|
7102
|
-
${lineage.
|
|
7103
|
-
${lineage.
|
|
7104
|
-
${lineage.
|
|
7105
|
-
${lineage.
|
|
7106
|
-
${lineage.
|
|
7107
|
-
${lineage.
|
|
7098
|
+
${lineage.connector_key},
|
|
7099
|
+
${lineage.connection_id},
|
|
7100
|
+
${lineage.feed_key},
|
|
7101
|
+
${lineage.feed_id},
|
|
7102
|
+
${lineage.run_id},
|
|
7103
|
+
${lineage.automation_id},
|
|
7104
|
+
${lineage.automation_version_id},
|
|
7108
7105
|
${params.semanticType},
|
|
7109
|
-
${
|
|
7106
|
+
${clientId2},
|
|
7110
7107
|
${params.createdBy ?? null},
|
|
7111
7108
|
${params.interactionType ?? "none"},
|
|
7112
7109
|
${params.interactionStatus ?? null},
|
|
@@ -7115,8 +7112,8 @@ async function insertEvent(params, options) {
|
|
|
7115
7112
|
${params.interactionOutput ? sql2.json(params.interactionOutput) : null},
|
|
7116
7113
|
${params.interactionError ?? null},
|
|
7117
7114
|
${supersedesEventId},
|
|
7118
|
-
${lineage.
|
|
7119
|
-
${lineage.
|
|
7115
|
+
${lineage.identity_ns},
|
|
7116
|
+
${lineage.identity_key},
|
|
7120
7117
|
(
|
|
7121
7118
|
SELECT COALESCE(array_agg(DISTINCT x.o), '{}'::text[])
|
|
7122
7119
|
FROM (
|
|
@@ -7126,7 +7123,7 @@ async function insertEvent(params, options) {
|
|
|
7126
7123
|
UNION ALL
|
|
7127
7124
|
SELECT c.organization_id AS o
|
|
7128
7125
|
FROM public.connections c
|
|
7129
|
-
WHERE c.id = ${lineage.
|
|
7126
|
+
WHERE c.id = ${lineage.connection_id}
|
|
7130
7127
|
) x
|
|
7131
7128
|
WHERE x.o IS NOT NULL
|
|
7132
7129
|
AND (x.o <> ${params.organizationId}::text OR ${params.organizationId}::text IS NULL)
|
|
@@ -7134,16 +7131,17 @@ async function insertEvent(params, options) {
|
|
|
7134
7131
|
)
|
|
7135
7132
|
RETURNING id, entity_ids, origin_id, title, semantic_type, created_at
|
|
7136
7133
|
`;
|
|
7134
|
+
const clientId = lineage.client_id;
|
|
7137
7135
|
let result;
|
|
7138
7136
|
const inTransaction = typeof sql2.savepoint === "function";
|
|
7139
7137
|
try {
|
|
7140
|
-
result = inTransaction ? await sql2.savepoint((sp) => insertWithClientId(sp,
|
|
7138
|
+
result = inTransaction ? await sql2.savepoint((sp) => insertWithClientId(sp, clientId)) : await insertWithClientId(sql2, clientId);
|
|
7141
7139
|
} catch (error) {
|
|
7142
|
-
if (!
|
|
7140
|
+
if (!clientId || !isEventsClientIdForeignKeyViolation(error)) {
|
|
7143
7141
|
throw error;
|
|
7144
7142
|
}
|
|
7145
7143
|
logger_default.warn(
|
|
7146
|
-
{ clientId
|
|
7144
|
+
{ clientId },
|
|
7147
7145
|
"[insert-event] retrying insert with client_id NULL \u2014 referenced oauth_clients row no longer exists"
|
|
7148
7146
|
);
|
|
7149
7147
|
result = await insertWithClientId(sql2, null);
|
|
@@ -7631,7 +7629,7 @@ function recordLifecycleEvent(params) {
|
|
|
7631
7629
|
);
|
|
7632
7630
|
});
|
|
7633
7631
|
}
|
|
7634
|
-
var AUDIT_EVENT_RETRY, EVENT_DEDUP_LOCK_NAMESPACE, DURABLE_ATTACHMENT_KEYS, VOLATILE_METADATA_KEYS, UNREAD_BADGE_PREFIX, AUDIT_IDEMPOTENCY_INDEX;
|
|
7632
|
+
var AUDIT_EVENT_RETRY, EVENT_DEDUP_LOCK_NAMESPACE, DURABLE_ATTACHMENT_KEYS, VOLATILE_METADATA_KEYS, UNREAD_BADGE_PREFIX, EVENT_SUPERSEDE_RULES, INHERITED_COLUMNS, AUDIT_IDEMPOTENCY_INDEX;
|
|
7635
7633
|
var init_insert_event = __esm({
|
|
7636
7634
|
"src/utils/insert-event.ts"() {
|
|
7637
7635
|
"use strict";
|
|
@@ -7667,6 +7665,50 @@ var init_insert_event = __esm({
|
|
|
7667
7665
|
"updated_at"
|
|
7668
7666
|
]);
|
|
7669
7667
|
UNREAD_BADGE_PREFIX = /^\(\d+\)\s+/;
|
|
7668
|
+
EVENT_SUPERSEDE_RULES = {
|
|
7669
|
+
id: "version",
|
|
7670
|
+
organization_id: "version",
|
|
7671
|
+
entity_ids: "version",
|
|
7672
|
+
origin_id: "version",
|
|
7673
|
+
title: "version",
|
|
7674
|
+
payload_type: "version",
|
|
7675
|
+
payload_text: "version",
|
|
7676
|
+
payload_data: "version",
|
|
7677
|
+
payload_template: "version",
|
|
7678
|
+
attachments: "version",
|
|
7679
|
+
metadata: "version",
|
|
7680
|
+
score: "version",
|
|
7681
|
+
author_name: "version",
|
|
7682
|
+
source_url: "version",
|
|
7683
|
+
occurred_at: "version",
|
|
7684
|
+
created_at: "version",
|
|
7685
|
+
origin_parent_id: "lineage",
|
|
7686
|
+
origin_type: "version",
|
|
7687
|
+
connector_key: "chain",
|
|
7688
|
+
connection_id: "chain",
|
|
7689
|
+
feed_key: "chain",
|
|
7690
|
+
feed_id: "chain",
|
|
7691
|
+
run_id: "lineage",
|
|
7692
|
+
automation_id: "lineage",
|
|
7693
|
+
automation_version_id: "lineage",
|
|
7694
|
+
semantic_type: "version",
|
|
7695
|
+
client_id: "lineage",
|
|
7696
|
+
created_by: "version",
|
|
7697
|
+
interaction_type: "version",
|
|
7698
|
+
interaction_status: "version",
|
|
7699
|
+
interaction_input_schema: "version",
|
|
7700
|
+
interaction_input: "version",
|
|
7701
|
+
interaction_output: "version",
|
|
7702
|
+
interaction_error: "version",
|
|
7703
|
+
supersedes_event_id: "version",
|
|
7704
|
+
superseded_by: "version",
|
|
7705
|
+
content_length: "version",
|
|
7706
|
+
search_tsv: "version",
|
|
7707
|
+
identity_ns: "chain",
|
|
7708
|
+
identity_key: "chain",
|
|
7709
|
+
linked_org_ids: "version"
|
|
7710
|
+
};
|
|
7711
|
+
INHERITED_COLUMNS = Object.keys(EVENT_SUPERSEDE_RULES).filter((column) => EVENT_SUPERSEDE_RULES[column] !== "version");
|
|
7670
7712
|
AUDIT_IDEMPOTENCY_INDEX = "idx_events_org_idempotency_key";
|
|
7671
7713
|
}
|
|
7672
7714
|
});
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobu/runtime-server",
|
|
3
|
-
"version": "24.1.
|
|
3
|
+
"version": "24.1.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@lobu/runtime-server",
|
|
9
|
-
"version": "24.1.
|
|
9
|
+
"version": "24.1.1",
|
|
10
10
|
"license": "BUSL-1.1",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
@@ -11795,7 +11795,7 @@
|
|
|
11795
11795
|
},
|
|
11796
11796
|
"vendor/connector-sdk": {
|
|
11797
11797
|
"name": "@lobu/connector-sdk",
|
|
11798
|
-
"version": "24.1.
|
|
11798
|
+
"version": "24.1.1",
|
|
11799
11799
|
"license": "BUSL-1.1",
|
|
11800
11800
|
"dependencies": {
|
|
11801
11801
|
"@lobu/core": "file:../core",
|
|
@@ -11810,7 +11810,7 @@
|
|
|
11810
11810
|
},
|
|
11811
11811
|
"vendor/core": {
|
|
11812
11812
|
"name": "@lobu/core",
|
|
11813
|
-
"version": "24.1.
|
|
11813
|
+
"version": "24.1.1",
|
|
11814
11814
|
"license": "Apache-2.0",
|
|
11815
11815
|
"dependencies": {
|
|
11816
11816
|
"@opentelemetry/api": "^1.9.0",
|
|
@@ -11839,7 +11839,7 @@
|
|
|
11839
11839
|
},
|
|
11840
11840
|
"vendor/views": {
|
|
11841
11841
|
"name": "@lobu/views",
|
|
11842
|
-
"version": "24.1.
|
|
11842
|
+
"version": "24.1.1",
|
|
11843
11843
|
"license": "Apache-2.0",
|
|
11844
11844
|
"dependencies": {
|
|
11845
11845
|
"@lobu/core": "file:../core"
|
package/package.json
CHANGED
package/vendor/core/package.json
CHANGED