@electric-ax/agents-server 0.4.3 → 0.4.4
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/entrypoint.js +375 -115
- package/dist/index.cjs +1434 -1188
- package/dist/index.d.cts +270 -160
- package/dist/index.d.ts +270 -160
- package/dist/index.js +1434 -1188
- package/drizzle/0007_runner_diagnostics_and_principal.sql +22 -0
- package/drizzle/0008_runner_runtime_diagnostics.sql +50 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +4 -4
- package/src/db/schema.ts +33 -10
- package/src/electric-agents-types.ts +49 -3
- package/src/entity-registry.ts +136 -26
- package/src/host.ts +4 -5
- package/src/principal.ts +23 -11
- package/src/routing/context.ts +1 -1
- package/src/routing/dispatch-policy.ts +123 -20
- package/src/routing/durable-streams-routing-adapter.ts +6 -7
- package/src/routing/electric-proxy-router.ts +1 -0
- package/src/routing/entities-router.ts +4 -4
- package/src/routing/hooks.ts +8 -1
- package/src/routing/runners-router.ts +257 -20
- package/src/runtime.ts +4 -7
- package/src/server.ts +20 -15
- package/src/standalone-runtime.ts +4 -7
- package/src/stream-client.ts +16 -59
- package/src/utils/server-utils.ts +22 -4
|
@@ -95,6 +95,7 @@ export function buildElectricProxyTarget(options: {
|
|
|
95
95
|
electricUrl: string
|
|
96
96
|
electricSecret?: string
|
|
97
97
|
tenantId: string
|
|
98
|
+
principalUrl?: string
|
|
98
99
|
}): URL {
|
|
99
100
|
const targetPath = options.incomingUrl.pathname.replace(
|
|
100
101
|
`/_electric/electric`,
|
|
@@ -130,9 +131,19 @@ export function buildElectricProxyTarget(options: {
|
|
|
130
131
|
} else if (table === `runners`) {
|
|
131
132
|
target.searchParams.set(
|
|
132
133
|
`columns`,
|
|
133
|
-
`"tenant_id","id","
|
|
134
|
+
`"tenant_id","id","owner_principal","label","kind","admin_status","wake_stream","created_at","updated_at"`
|
|
134
135
|
)
|
|
135
|
-
applyTenantShapeWhere(target, options.tenantId
|
|
136
|
+
applyTenantShapeWhere(target, options.tenantId, [
|
|
137
|
+
`owner_principal = ${sqlStringLiteral(options.principalUrl ?? ``)}`,
|
|
138
|
+
])
|
|
139
|
+
} else if (table === `runner_runtime_diagnostics`) {
|
|
140
|
+
target.searchParams.set(
|
|
141
|
+
`columns`,
|
|
142
|
+
`"tenant_id","runner_id","owner_principal","wake_stream_offset","last_seen_at","liveness_lease_expires_at","diagnostics","updated_at"`
|
|
143
|
+
)
|
|
144
|
+
applyTenantShapeWhere(target, options.tenantId, [
|
|
145
|
+
`owner_principal = ${sqlStringLiteral(options.principalUrl ?? ``)}`,
|
|
146
|
+
])
|
|
136
147
|
} else if (table === `entity_dispatch_state`) {
|
|
137
148
|
target.searchParams.set(
|
|
138
149
|
`columns`,
|
|
@@ -232,8 +243,15 @@ export function decodeJsonObject(
|
|
|
232
243
|
return null
|
|
233
244
|
}
|
|
234
245
|
|
|
235
|
-
function applyTenantShapeWhere(
|
|
236
|
-
|
|
246
|
+
function applyTenantShapeWhere(
|
|
247
|
+
target: URL,
|
|
248
|
+
tenantId: string,
|
|
249
|
+
extraConditions: Array<string> = []
|
|
250
|
+
): void {
|
|
251
|
+
const tenantWhere = [
|
|
252
|
+
`tenant_id = ${sqlStringLiteral(tenantId)}`,
|
|
253
|
+
...extraConditions,
|
|
254
|
+
].join(` AND `)
|
|
237
255
|
const existingWhere = target.searchParams.get(`where`)
|
|
238
256
|
target.searchParams.set(
|
|
239
257
|
`where`,
|