MCPcopy Index your code
hub / github.com/simstudioai/sim / buildInsertId

Function buildInsertId

apps/sim/lib/data-drains/destinations/bigquery.ts:141–148  ·  view source on GitHub ↗

* Builds a stable `insertId` for best-effort dedup (~60s window). Prefixed * with `drainId` so (runId, sequence) collisions across drains do not * accidentally dedupe each other's rows. With UUID drain/run IDs the raw * form fits well under 128 chars; if anything pushes it over (e.g. a future *

(metadata: DeliveryMetadata, index: number)

Source from the content-addressed store, hash-verified

139 * suffix intact so BigQuery does not silently dedupe distinct rows.
140 */
141function buildInsertId(metadata: DeliveryMetadata, index: number): string {
142 const raw = `${metadata.drainId}-${metadata.runId}-${metadata.sequence}-${index}`
143 if (raw.length <= MAX_INSERT_ID_LENGTH) return raw
144 const prefixHash = createHash('sha1')
145 .update(`${metadata.drainId}-${metadata.runId}-${metadata.sequence}`)
146 .digest('hex')
147 return `${prefixHash}-${index}`
148}
149
150const RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504])
151const MAX_RETRY_ATTEMPTS = 3

Callers 1

insertAllFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected