@electric-ax/agents-server 0.4.3 → 0.4.5

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.
@@ -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","owner_user_id","label","kind","admin_status","wake_stream","wake_stream_offset","last_seen_at","liveness_lease_expires_at","created_at","updated_at"`
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(target: URL, tenantId: string): void {
236
- const tenantWhere = `tenant_id = ${sqlStringLiteral(tenantId)}`
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`,