@burdenoff/be-sdk 2026.1015.2 → 2026.1017.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/chunk-N2UT3ESH.js +1506 -0
- package/dist/chunk-N2UT3ESH.js.map +1 -0
- package/dist/index-DfYu1p9e.d.ts +530 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-Z5BURBFZ.js +0 -694
- package/dist/chunk-Z5BURBFZ.js.map +0 -1
- package/dist/index-PJZzGd8r.d.ts +0 -324
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/platform/index.ts","../src/platform/httpClient.ts","../src/platform/leaderLock.ts","../src/platform/rateLimit.ts","../src/platform/paginator.ts","../src/platform/dataLoaderFactory.ts","../src/platform/cacheInvalidation.ts","../src/platform/pgPartition.ts","../src/platform/llmClient.ts"],"names":["breakers","Map","hostOf","url","URL","host","getBreaker","b","get","failures","openedAt","state","set","defaultRetryOn","status","jitter","delay","Math","floor","random","sleep","ms","Promise","r","setTimeout","CircuitBreakerOpenError","Error","name","__resetHttpClientBreakers","clear","executeOnce","init","timeoutMs","signal","AbortSignal","timeout","fetch","httpClient","config","fullUrl","baseUrl","test","replace","breaker","breakerThreshold","threshold","cooldownMs","Date","now","logger","info","attempts","retry","initialDelay","initialDelayMs","maxDelay","maxDelayMs","retryOn","defaultTimeoutMs","headers","defaultHeaders","lastErr","attempt","response","warn","min","err","error","String","createHttpClient","RELEASE_LUA","RENEW_LUA","leaderKey","generateToken","toString","slice","process","pid","defaultRenewMs","ttlMs","max","acquireLease","redis","key","token","ttlSeconds","ceil","renewLease","eval","releaseLease","normalizeRedisUrl","startsWith","withLeaderLock","fn","options","renewMs","acquired","stopped","renewTimer","setInterval","catch","unref","result","clearInterval","createLeaderLease","held","released","inFlight","acquireOrRenew","runAttempt","finally","timer","renew","release","isHeld","rateLimitIncr","input","fullKey","count","incr","pexpire","windowMs","ttl","pttl","resetAt","remaining","limit","allowed","DEFAULT_GRAPHQL_PAGE_LIMIT","MAX_GRAPHQL_PAGE_LIMIT","clampLimit","opts","def","defaultLimit","maxLimit","minLimit","Number","isNaN","clampOffset","clampGraphqlLimit","normalizeOffsetPagination","offset","normalizeCursorPagination","first","after","trim","length","take","encodeCursor","payload","Buffer","from","JSON","stringify","decodeCursor","cursor","decoded","parse","Array","isArray","value","Object","entries","keys","buildConnection","items","nodes","edges","map","node","cursorForNode","firstEdge","lastEdge","at","pageInfo","hasNextPage","hasPreviousPage","startCursor","endCursor","totalCount","buildOffsetPage","total","pagination","nextOffset","hasMore","toPrismaPage","skip","paginate","model","undefined","findMany","id","where","orderBy","trimmed","nextCursor","buildLoaders","ctx","builder","resolveReferenceLoader","loaderName","keyField","reference","loader","loaders","load","VERSION_PREFIX","getNamespaceVersion","namespace","v","n","parseInt","isFinite","buildCacheKey","parts","ver","join","invalidateNamespace","pad2","monthlyPartitionName","table","year","month","ensureMonthlyPartitions","prisma","created","cur","UTC","getUTCFullYear","getUTCMonth","end","to","y","m","next","partition","lower","upper","$executeRawUnsafe","push","setUTCMonth","dropOldPartitions","rows","$queryRawUnsafe","dropped","cutoffYear","beforeDate","cutoffMonth","row","partitionRe","exec","partition_name","mo","DEFAULTS","maxAttempts","maxOutputTokensCap","LLMRouter","adapters","register","adapter","resolveChain","envChain","env","split","s","filter","Boolean","complete","req","cappedReq","maxTokens","chain","providerName","ctrl","AbortController","t","abort","provider","clearTimeout"],"mappings":";;;;AAAA,IAAA,gBAAA,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgDA,IAAMA,QAAAA,uBAAeC,GAAAA,EAAAA;AAErB,SAASC,OAAOC,GAAAA,EAAW;AACzB,EAAA,IAAI;AACF,IAAA,OAAO,IAAIC,GAAAA,CAAID,GAAAA,CAAAA,CAAKE,IAAAA;EACtB,CAAA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AAUK,GAAAA;AACVjB,QAAAA,MAAAA,CAAOe,KAAK,0BAAA,EAA4B;AAAEqN,UAAAA,QAAAA,EAAUlB,OAAAA,CAAQxO,IAAAA;AAAMmC,UAAAA,OAAAA;AAASI,UAAAA,GAAAA,EAAKE,OAAOF,GAAAA;SAAK,CAAA;AAC5F,QAAA,IAAIJ,OAAAA,GAAU,IAAA,CAAKqE,IAAAA,CAAK2H,WAAAA,GAAc,CAAA,EAAG;AACvC,UAAA,MAAM9O,KAAAA,GAAQ,IAAA,CAAKmH,IAAAA,CAAK7E,cAAAA,GAAiB,CAAA,IAAKQ,OAAAA;AAC9C,UAAA,MAAM1C,MAAAA,CAAML,OAAAA,CAAOC,KAAAA,CAAAA,CAAAA;AACrB,QAAA;MACF,CAAA,SAAA;AACEsQ,QAAAA,YAAAA,CAAaH,CAAAA,CAAAA;AACf,MAAA;AACF,IAAA;AACA,IAAA,MAAMtN,OAAAA,YAAmBnC,QAAQmC,OAAAA,GAAU,IAAInC,MAAM,CAAA,oBAAA,EAAuB,IAAA,CAAKyG,IAAAA,CAAK2H,WAAW,CAAA,SAAA,CAAW,CAAA;AAC9G,EAAA;AACF","file":"chunk-Z5BURBFZ.js","sourcesContent":["/**\n * @burdenoff/be-sdk/platform\n *\n * Reusable platform primitives consumed fleet-wide by Burdenoff svcs.\n */\nexport { httpClient, createHttpClient, CircuitBreakerOpenError, __resetHttpClientBreakers } from './httpClient.js';\nexport type { HttpClientConfig, HttpClientInit, RetryConfig, BreakerConfig } from './httpClient.js';\n\nexport { withLeaderLock, createLeaderLease, normalizeRedisUrl } from './leaderLock.js';\nexport type {\n LeaderLockRedis,\n LeaderLockOptions,\n LeaderLockResult,\n CreateLeaderLeaseOptions,\n LeaderLease,\n} from './leaderLock.js';\n\nexport { rateLimitIncr } from './rateLimit.js';\nexport type { RateLimitRedis, RateLimitInput, RateLimitResult } from './rateLimit.js';\n\nexport {\n DEFAULT_GRAPHQL_PAGE_LIMIT,\n MAX_GRAPHQL_PAGE_LIMIT,\n buildConnection,\n buildOffsetPage,\n clampGraphqlLimit,\n clampLimit,\n clampOffset,\n decodeCursor,\n encodeCursor,\n normalizeCursorPagination,\n normalizeOffsetPagination,\n paginate,\n toPrismaPage,\n} from './paginator.js';\nexport type { ClampLimitOptions, PaginateInput, PaginateResult, PrismaModelLike } from './paginator.js';\nexport type {\n BuildConnectionOptions,\n ConnectionEdge,\n ConnectionResult,\n CursorPaginationInput,\n CursorPayload,\n CursorPayloadValue,\n NormalizedCursorPagination,\n NormalizedOffsetPagination,\n OffsetPageResult,\n OffsetPaginationInput,\n PageInfo,\n} from './paginator.js';\n\nexport { buildLoaders, resolveReferenceLoader } from './dataLoaderFactory.js';\nexport type { DataLoaderLike, LoaderMap, LoaderBuilder, ReferenceObject } from './dataLoaderFactory.js';\n\nexport { buildCacheKey, getNamespaceVersion, invalidateNamespace } from './cacheInvalidation.js';\nexport type { CacheVersionRedis } from './cacheInvalidation.js';\n\nexport { monthlyPartitionName, ensureMonthlyPartitions, dropOldPartitions } from './pgPartition.js';\nexport type { PrismaRawClient, EnsureMonthlyOptions, DropOldOptions } from './pgPartition.js';\n\nexport { LLMRouter } from './llmClient.js';\nexport type { LLMRequest, LLMResponse, LLMProviderAdapter, LLMRouterOptions } from './llmClient.js';\n","/**\n * httpClient — hardened wrapper around global `fetch` with:\n * - per-request AbortSignal.timeout (default 5s)\n * - retries (default 3) with exponential backoff + full jitter\n * - per-host circuit breaker (opens at 5 consecutive 5xx, half-open after 30s)\n * - structured logging via existing be-sdk logger\n *\n * No required upstream dependency — we use the runtime `fetch` so the same\n * code path works on Bun and Node 20+. Consumers may pass an undici Agent\n * via `init.dispatcher` if they need keep-alive pooling; we forward unknown\n * init fields through.\n */\n\nimport { logger } from '../logger/index.js';\n\nexport interface RetryConfig {\n /** Total attempts including the first (default 3) */\n attempts?: number;\n /** Initial backoff in ms (default 100) */\n initialDelayMs?: number;\n /** Maximum backoff in ms (default 2000) */\n maxDelayMs?: number;\n /** Status codes that trigger a retry (default 408, 425, 429, 5xx) */\n retryOn?: (status: number) => boolean;\n}\n\nexport interface BreakerConfig {\n /** Consecutive 5xx failures to open breaker (default 5) */\n threshold?: number;\n /** Time in ms before HALF_OPEN trial (default 30000) */\n cooldownMs?: number;\n}\n\nexport interface HttpClientConfig {\n baseUrl?: string;\n defaultTimeoutMs?: number;\n retry?: RetryConfig;\n breaker?: BreakerConfig;\n /** Default headers merged into every request */\n defaultHeaders?: Record<string, string>;\n}\n\ninterface BreakerState {\n failures: number;\n openedAt: number | null;\n state: 'CLOSED' | 'OPEN' | 'HALF_OPEN';\n}\n\nconst breakers = new Map<string, BreakerState>();\n\nfunction hostOf(url: string): string {\n try {\n return new URL(url).host;\n } catch {\n return url;\n }\n}\n\nfunction getBreaker(host: string): BreakerState {\n let b = breakers.get(host);\n if (!b) {\n b = { failures: 0, openedAt: null, state: 'CLOSED' };\n breakers.set(host, b);\n }\n return b;\n}\n\nfunction defaultRetryOn(status: number): boolean {\n return status === 408 || status === 425 || status === 429 || (status >= 500 && status <= 599);\n}\n\nfunction jitter(delay: number): number {\n return Math.floor(Math.random() * delay);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nexport class CircuitBreakerOpenError extends Error {\n constructor(host: string) {\n super(`circuit breaker OPEN for host=${host}`);\n this.name = 'CircuitBreakerOpenError';\n }\n}\n\nexport interface HttpClientInit extends RequestInit {\n timeoutMs?: number;\n retry?: RetryConfig;\n}\n\n/**\n * Reset all breaker state (test helper).\n */\nexport function __resetHttpClientBreakers(): void {\n breakers.clear();\n}\n\nasync function executeOnce(url: string, init: HttpClientInit, timeoutMs: number): Promise<Response> {\n const signal = init.signal ?? AbortSignal.timeout(timeoutMs);\n return fetch(url, { ...init, signal });\n}\n\nexport async function httpClient(\n url: string,\n init: HttpClientInit = {},\n config: HttpClientConfig = {}\n): Promise<Response> {\n const fullUrl =\n config.baseUrl && !/^https?:\\/\\//i.test(url)\n ? `${config.baseUrl.replace(/\\/$/, '')}/${url.replace(/^\\//, '')}`\n : url;\n const host = hostOf(fullUrl);\n const breaker = getBreaker(host);\n const breakerThreshold = config.breaker?.threshold ?? 5;\n const cooldownMs = config.breaker?.cooldownMs ?? 30_000;\n\n if (breaker.state === 'OPEN') {\n if (breaker.openedAt && Date.now() - breaker.openedAt >= cooldownMs) {\n breaker.state = 'HALF_OPEN';\n logger.info('httpClient.breaker.halfOpen', { host });\n } else {\n throw new CircuitBreakerOpenError(host);\n }\n }\n\n const attempts = init.retry?.attempts ?? config.retry?.attempts ?? 3;\n const initialDelay = init.retry?.initialDelayMs ?? config.retry?.initialDelayMs ?? 100;\n const maxDelay = init.retry?.maxDelayMs ?? config.retry?.maxDelayMs ?? 2_000;\n const retryOn = init.retry?.retryOn ?? config.retry?.retryOn ?? defaultRetryOn;\n const timeoutMs = init.timeoutMs ?? config.defaultTimeoutMs ?? 5_000;\n\n const headers = { ...(config.defaultHeaders ?? {}), ...((init.headers as Record<string, string> | undefined) ?? {}) };\n\n let lastErr: unknown;\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n const response = await executeOnce(fullUrl, { ...init, headers }, timeoutMs);\n if (response.status >= 500) {\n breaker.failures += 1;\n if (breaker.failures >= breakerThreshold) {\n breaker.state = 'OPEN';\n breaker.openedAt = Date.now();\n logger.warn('httpClient.breaker.open', { host, failures: breaker.failures });\n }\n if (attempt < attempts && retryOn(response.status)) {\n const delay = Math.min(initialDelay * 2 ** (attempt - 1), maxDelay);\n await sleep(jitter(delay));\n continue;\n }\n return response;\n }\n // success path\n breaker.failures = 0;\n if (breaker.state === 'HALF_OPEN') {\n breaker.state = 'CLOSED';\n breaker.openedAt = null;\n logger.info('httpClient.breaker.closed', { host });\n }\n if (attempt < attempts && retryOn(response.status)) {\n const delay = Math.min(initialDelay * 2 ** (attempt - 1), maxDelay);\n await sleep(jitter(delay));\n continue;\n }\n return response;\n } catch (err) {\n lastErr = err;\n breaker.failures += 1;\n if (breaker.failures >= breakerThreshold) {\n breaker.state = 'OPEN';\n breaker.openedAt = Date.now();\n logger.warn('httpClient.breaker.open', { host, failures: breaker.failures });\n }\n if (attempt >= attempts) break;\n const delay = Math.min(initialDelay * 2 ** (attempt - 1), maxDelay);\n await sleep(jitter(delay));\n }\n }\n\n logger.error('httpClient.exhausted', { url: fullUrl, attempts, host });\n throw lastErr instanceof Error ? lastErr : new Error(`httpClient failed: ${String(lastErr)}`);\n}\n\nexport function createHttpClient(\n config: HttpClientConfig = {}\n): (url: string, init?: HttpClientInit) => Promise<Response> {\n return (url: string, init: HttpClientInit = {}) => httpClient(url, init, config);\n}\n","/**\n * Redis-based leader election primitives.\n *\n * Two public entry points share one core (`besdk:leader:{name}` key,\n * `SET NX EX` acquire, Redis-side compare-and-renew / compare-and-delete\n * LUA scripts, per-holder token):\n *\n * - {@link withLeaderLock} — run-once wrapper: acquire, run `fn()` while\n * auto-renewing, release. Resolves `{ acquired: false }` (without running\n * `fn`) when another holder owns the lease.\n * - {@link createLeaderLease} — long-lived, self-renewing lease HANDLE for a\n * continuously-running singleton worker: acquire, auto-renew every\n * `ttlMs/3`, and re-acquire on failover, until `release()`.\n *\n * The Redis client is duck-typed (ioredis-compatible) so consumers can pass\n * either ioredis or any client exposing the same `set`/`eval` shape.\n */\n\nimport { logger } from '../logger/index.js';\n\nexport interface LeaderLockRedis {\n /** ioredis: set(key, val, 'EX', seconds, 'NX') -> 'OK' | null */\n set(key: string, value: string, ex: 'EX', seconds: number, nx: 'NX'): Promise<'OK' | null>;\n /** Redis LUA EVAL for compare-and-delete / compare-and-renew (server-side script) */\n eval(script: string, numKeys: number, ...args: string[]): Promise<unknown>;\n}\n\nexport interface LeaderLockOptions {\n ttlMs: number;\n renewMs?: number;\n}\n\nexport interface LeaderLockResult<T> {\n acquired: boolean;\n result?: T;\n}\n\nconst RELEASE_LUA = `\nif redis.call(\"get\", KEYS[1]) == ARGV[1] then\n return redis.call(\"del\", KEYS[1])\nelse\n return 0\nend\n`;\n\nconst RENEW_LUA = `\nif redis.call(\"get\", KEYS[1]) == ARGV[1] then\n return redis.call(\"pexpire\", KEYS[1], ARGV[2])\nelse\n return 0\nend\n`;\n\n// ---------------------------------------------------------------------------\n// Shared core primitives (used by BOTH withLeaderLock and createLeaderLease)\n// ---------------------------------------------------------------------------\n\n/** Standard Redis key for a named leader lease. */\nfunction leaderKey(name: string): string {\n return `besdk:leader:${name}`;\n}\n\nfunction generateToken(): string {\n return `${Date.now()}-${Math.random().toString(36).slice(2)}-${process.pid}`;\n}\n\nfunction defaultRenewMs(ttlMs: number): number {\n return Math.max(1_000, Math.floor(ttlMs / 3));\n}\n\n/** Attempt to acquire the lease with `SET key token EX ttl NX`. */\nasync function acquireLease(redis: LeaderLockRedis, key: string, token: string, ttlMs: number): Promise<boolean> {\n const ttlSeconds = Math.max(1, Math.ceil(ttlMs / 1000));\n return (await redis.set(key, token, 'EX', ttlSeconds, 'NX')) === 'OK';\n}\n\n/** Compare-and-renew: extend the lease only if we still own it (Redis-side). */\nasync function renewLease(redis: LeaderLockRedis, key: string, token: string, ttlMs: number): Promise<boolean> {\n return (await redis.eval(RENEW_LUA, 1, key, token, String(ttlMs))) === 1;\n}\n\n/** Compare-and-delete: release the lease only if we still own it (Redis-side). */\nasync function releaseLease(redis: LeaderLockRedis, key: string, token: string): Promise<void> {\n await redis.eval(RELEASE_LUA, 1, key, token);\n}\n\n/**\n * Normalise a Valkey/Redis URL to an ioredis-understood scheme:\n * - `valkeys://…` → `rediss://…` (TLS)\n * - `valkey://…` → `redis://…`\n * Any other scheme (incl. `redis://` / `rediss://`) is returned unchanged.\n *\n * Consumers building the ioredis client they hand to {@link createLeaderLease}\n * or {@link withLeaderLock} should run their `VALKEY_URL`/`REDIS_URL` through\n * this so they can retire their own copy of the same normaliser.\n */\nexport function normalizeRedisUrl(url: string): string {\n if (url.startsWith('valkeys://')) return url.replace(/^valkeys:\\/\\//, 'rediss://');\n if (url.startsWith('valkey://')) return url.replace(/^valkey:\\/\\//, 'redis://');\n return url;\n}\n\n// ---------------------------------------------------------------------------\n// withLeaderLock — run-once wrapper (public behaviour unchanged)\n// ---------------------------------------------------------------------------\n\nexport async function withLeaderLock<T>(\n redis: LeaderLockRedis,\n name: string,\n fn: () => Promise<T>,\n options: LeaderLockOptions\n): Promise<LeaderLockResult<T>> {\n const key = leaderKey(name);\n const token = generateToken();\n const ttlMs = options.ttlMs;\n const renewMs = options.renewMs ?? defaultRenewMs(ttlMs);\n\n const acquired = await acquireLease(redis, key, token, ttlMs);\n if (!acquired) {\n return { acquired: false };\n }\n\n logger.info('leaderLock.acquired', { name, token, ttlMs });\n\n let stopped = false;\n const renewTimer = setInterval(() => {\n if (stopped) return;\n renewLease(redis, key, token, ttlMs).catch((err: unknown) => {\n logger.warn('leaderLock.renew.failed', { name, err: String(err) });\n });\n }, renewMs);\n // Don't keep the process alive just for this timer.\n if (typeof (renewTimer as unknown as { unref?: () => void }).unref === 'function') {\n (renewTimer as unknown as { unref: () => void }).unref();\n }\n\n try {\n const result = await fn();\n return { acquired: true, result };\n } finally {\n stopped = true;\n clearInterval(renewTimer);\n try {\n await releaseLease(redis, key, token);\n logger.info('leaderLock.released', { name, token });\n } catch (err) {\n logger.warn('leaderLock.release.failed', { name, err: String(err) });\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// createLeaderLease — long-lived, self-renewing lease handle\n// ---------------------------------------------------------------------------\n\nexport interface CreateLeaderLeaseOptions {\n /** Logical lease name; becomes the `besdk:leader:{name}` Redis key. */\n name: string;\n /** Lease length in ms. Auto-renew keeps the lease alive within this window. */\n ttlMs: number;\n /**\n * ioredis-shaped client used for lease coordination — the same shape\n * {@link withLeaderLock} requires (`set(key, val, 'EX', secs, 'NX')` +\n * `eval(script, numKeys, ...args)`). Build it from a `normalizeRedisUrl`-d\n * `VALKEY_URL`/`REDIS_URL`.\n */\n redis: LeaderLockRedis;\n /** Auto-renew cadence in ms. Default: `max(1000, ttlMs/3)`. */\n renewMs?: number;\n}\n\nexport interface LeaderLease {\n /**\n * Acquire the lease if free, or renew it if already held. Resolves to whether\n * THIS handle currently holds the lease. The first call is the initial\n * acquire; the background timer keeps calling this until {@link release}.\n */\n renew(): Promise<boolean>;\n /** Stop auto-renewing and release the lease (only if still owned). */\n release(): Promise<void>;\n /** Whether this handle currently holds the lease (local, no Redis round-trip). */\n isHeld(): boolean;\n}\n\n/**\n * Create a self-renewing leader lease for a continuously-running singleton\n * worker. On creation an auto-renew timer starts (`renewMs`, default `ttlMs/3`,\n * unref'd) that acquires-if-free / renews-if-held — so a replica that starts as\n * a follower automatically takes over when the current holder dies and its\n * lease expires. Call `renew()` once up front to acquire deterministically:\n *\n * ```ts\n * const lease = createLeaderLease({ name: 'notification-sweep', ttlMs: 90_000, redis });\n * if (await lease.renew()) startWorker(); // became leader\n * // ...auto-renews in the background...\n * await lease.release(); // on graceful shutdown\n * ```\n */\nexport function createLeaderLease(options: CreateLeaderLeaseOptions): LeaderLease {\n const { name, ttlMs, redis } = options;\n const key = leaderKey(name);\n const token = generateToken();\n const renewMs = options.renewMs ?? defaultRenewMs(ttlMs);\n\n let held = false;\n let released = false;\n let inFlight: Promise<boolean> | null = null;\n\n const acquireOrRenew = async (): Promise<boolean> => {\n if (released) return false;\n try {\n if (held) {\n if (await renewLease(redis, key, token, ttlMs)) {\n return true;\n }\n // Lost the lease (expired, or claimed by another holder). Fall through\n // and try a fresh acquire — this is the failover path.\n held = false;\n }\n const acquired = await acquireLease(redis, key, token, ttlMs);\n if (acquired && !held) {\n logger.info('leaderLease.acquired', { name, token, ttlMs });\n }\n held = acquired;\n return held;\n } catch (err) {\n logger.warn('leaderLease.renew.failed', { name, err: String(err) });\n return held;\n }\n };\n\n // Coalesce overlapping attempts (background tick vs. an explicit renew())\n // so the local `held` flag can't be updated by two races at once.\n const runAttempt = (): Promise<boolean> => {\n if (inFlight) return inFlight;\n const attempt = acquireOrRenew().finally(() => {\n if (inFlight === attempt) inFlight = null;\n });\n inFlight = attempt;\n return attempt;\n };\n\n const timer = setInterval(() => {\n if (released) return;\n void runAttempt();\n }, renewMs);\n // Don't keep the process alive just for this timer.\n if (typeof (timer as unknown as { unref?: () => void }).unref === 'function') {\n (timer as unknown as { unref: () => void }).unref();\n }\n\n return {\n renew(): Promise<boolean> {\n return runAttempt();\n },\n async release(): Promise<void> {\n if (released) return;\n released = true;\n clearInterval(timer);\n if (inFlight) {\n try {\n await inFlight;\n } catch {\n // ignore — we're releasing anyway\n }\n }\n if (!held) return;\n held = false;\n try {\n await releaseLease(redis, key, token);\n logger.info('leaderLease.released', { name, token });\n } catch (err) {\n logger.warn('leaderLease.release.failed', { name, err: String(err) });\n }\n },\n isHeld(): boolean {\n return held && !released;\n },\n };\n}\n","/**\n * rateLimitIncr — atomic INCR-based rate limit using EXPIRE NX.\n *\n * Strategy:\n * 1. INCR key\n * 2. If returned value === 1 (i.e. first increment), EXPIRE key with windowMs\n * 3. Compute remaining + resetAt\n *\n * This is two round-trips in the worst case. A future Lua/EVALSHA variant\n * can collapse it into a single round-trip; the public API is stable.\n *\n * Returns `allowed=false` if `count > limit`. The key is `besdk:rl:{key}`.\n */\n\nexport interface RateLimitRedis {\n incr(key: string): Promise<number>;\n pexpire(key: string, ms: number): Promise<number | 'OK'>;\n pttl(key: string): Promise<number>;\n}\n\nexport interface RateLimitInput {\n key: string;\n limit: number;\n windowMs: number;\n}\n\nexport interface RateLimitResult {\n allowed: boolean;\n count: number;\n remaining: number;\n resetAt: number;\n}\n\nexport async function rateLimitIncr(redis: RateLimitRedis, input: RateLimitInput): Promise<RateLimitResult> {\n const fullKey = `besdk:rl:${input.key}`;\n const count = await redis.incr(fullKey);\n if (count === 1) {\n await redis.pexpire(fullKey, input.windowMs);\n }\n let ttl = -1;\n try {\n ttl = await redis.pttl(fullKey);\n } catch {\n ttl = input.windowMs;\n }\n const resetAt = Date.now() + (ttl > 0 ? ttl : input.windowMs);\n const remaining = Math.max(0, input.limit - count);\n return {\n allowed: count <= input.limit,\n count,\n remaining,\n resetAt,\n };\n}\n","/**\n * Paginator — Relay-style cursor pagination + safe limit clamping.\n *\n * Use `clampLimit` at resolver entry to enforce sane defaults/maxes.\n * Use `paginate` to translate a Relay-style { first, after } into a\n * Prisma-ready { take, skip, cursor } and return a connection-shaped\n * result.\n */\n\nexport interface ClampLimitOptions {\n defaultLimit?: number;\n maxLimit?: number;\n minLimit?: number;\n}\n\nexport const DEFAULT_GRAPHQL_PAGE_LIMIT = 50;\nexport const MAX_GRAPHQL_PAGE_LIMIT = 100;\n\nexport function clampLimit(input: number | undefined | null, opts: ClampLimitOptions = {}): number {\n const def = opts.defaultLimit ?? 50;\n const max = opts.maxLimit ?? 200;\n const min = opts.minLimit ?? 1;\n if (input == null || Number.isNaN(input)) return def;\n return Math.min(Math.max(Math.floor(input), min), max);\n}\n\nexport function clampOffset(input: number | undefined | null): number {\n if (input == null || Number.isNaN(input)) return 0;\n return Math.max(0, Math.floor(input));\n}\n\nexport function clampGraphqlLimit(input: number | undefined | null, opts: ClampLimitOptions = {}): number {\n return clampLimit(input, {\n defaultLimit: opts.defaultLimit ?? DEFAULT_GRAPHQL_PAGE_LIMIT,\n maxLimit: opts.maxLimit ?? MAX_GRAPHQL_PAGE_LIMIT,\n minLimit: opts.minLimit ?? 1,\n });\n}\n\nexport interface OffsetPaginationInput {\n limit?: number | null;\n offset?: number | null;\n}\n\nexport interface NormalizedOffsetPagination {\n limit: number;\n offset: number;\n}\n\nexport function normalizeOffsetPagination(\n input: OffsetPaginationInput | null | undefined,\n opts: ClampLimitOptions = {}\n): NormalizedOffsetPagination {\n return {\n limit: clampGraphqlLimit(input?.limit, opts),\n offset: clampOffset(input?.offset),\n };\n}\n\nexport interface CursorPaginationInput {\n first?: number | null;\n after?: string | null;\n}\n\nexport interface NormalizedCursorPagination {\n first: number;\n after: string | null;\n take: number;\n}\n\nexport function normalizeCursorPagination(\n input: CursorPaginationInput | null | undefined,\n opts: ClampLimitOptions = {}\n): NormalizedCursorPagination {\n const first = clampGraphqlLimit(input?.first, opts);\n const after = typeof input?.after === 'string' && input.after.trim().length > 0 ? input.after : null;\n return { first, after, take: first + 1 };\n}\n\nexport type CursorPayloadValue = string | number | boolean | null;\nexport type CursorPayload = Record<string, CursorPayloadValue>;\n\nexport function encodeCursor(payload: CursorPayload): string {\n return Buffer.from(JSON.stringify(payload), 'utf8').toString('base64url');\n}\n\nexport function decodeCursor(cursor: string | null | undefined): CursorPayload | null {\n if (typeof cursor !== 'string' || cursor.trim().length === 0) return null;\n\n try {\n const decoded: unknown = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));\n if (decoded == null || typeof decoded !== 'object' || Array.isArray(decoded)) return null;\n\n const payload: CursorPayload = {};\n for (const [key, value] of Object.entries(decoded)) {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || value == null) {\n payload[key] = value;\n }\n }\n\n return Object.keys(payload).length > 0 ? payload : null;\n } catch {\n return null;\n }\n}\n\nexport interface PageInfo {\n hasNextPage: boolean;\n hasPreviousPage: boolean;\n startCursor: string | null;\n endCursor: string | null;\n}\n\nexport interface ConnectionEdge<TItem> {\n node: TItem;\n cursor: string;\n}\n\nexport interface ConnectionResult<TItem> {\n edges: ConnectionEdge<TItem>[];\n nodes: TItem[];\n pageInfo: PageInfo;\n totalCount?: number | null;\n}\n\nexport interface BuildConnectionOptions<TItem> {\n limit: number;\n cursorForNode: (item: TItem) => string;\n hasPreviousPage?: boolean;\n totalCount?: number | null;\n}\n\nexport function buildConnection<TItem>(items: TItem[], opts: BuildConnectionOptions<TItem>): ConnectionResult<TItem> {\n const nodes = items.length > opts.limit ? items.slice(0, opts.limit) : items;\n const edges = nodes.map((node) => ({ node, cursor: opts.cursorForNode(node) }));\n const firstEdge = edges[0];\n const lastEdge = edges.at(-1);\n\n return {\n edges,\n nodes,\n pageInfo: {\n hasNextPage: items.length > opts.limit,\n hasPreviousPage: opts.hasPreviousPage ?? false,\n startCursor: firstEdge?.cursor ?? null,\n endCursor: lastEdge?.cursor ?? null,\n },\n totalCount: opts.totalCount,\n };\n}\n\nexport interface OffsetPageResult<TItem> {\n items: TItem[];\n total: number;\n limit: number;\n offset: number;\n hasMore: boolean;\n nextOffset: number | null;\n}\n\nexport function buildOffsetPage<TItem>(\n items: TItem[],\n total: number,\n pagination: NormalizedOffsetPagination\n): OffsetPageResult<TItem> {\n const nextOffset = pagination.offset + items.length;\n const hasMore = nextOffset < total;\n\n return {\n items,\n total,\n limit: pagination.limit,\n offset: pagination.offset,\n hasMore,\n nextOffset: hasMore ? nextOffset : null,\n };\n}\n\n// ============================================================================\n// Prisma convenience helpers\n// ============================================================================\n\n/**\n * Convert a normalized offset pagination result to Prisma's `take`/`skip` args.\n *\n * ```ts\n * const pg = normalizeOffsetPagination(args);\n * const rows = await prisma.tag.findMany({ ...toPrismaPage(pg), where });\n * ```\n *\n * `limit` is clamped to MAX_GRAPHQL_PAGE_LIMIT (100) by `normalizeOffsetPagination`.\n * Always call normalizeOffsetPagination first — never pass a raw limit directly.\n */\nexport function toPrismaPage(pagination: NormalizedOffsetPagination): { take: number; skip: number } {\n return { take: pagination.limit, skip: pagination.offset };\n}\n\nexport interface PaginateInput<TWhere, TOrderBy> {\n take?: number | null;\n cursor?: string | null;\n where?: TWhere;\n orderBy?: TOrderBy;\n}\n\nexport interface PaginateResult<TItem> {\n items: TItem[];\n hasMore: boolean;\n nextCursor: string | null;\n}\n\nexport interface PrismaModelLike<TItem, TWhere, TOrderBy> {\n findMany(args: {\n take?: number;\n skip?: number;\n cursor?: { id: string };\n where?: TWhere;\n orderBy?: TOrderBy;\n }): Promise<TItem[]>;\n}\n\nexport async function paginate<TItem extends { id: string }, TWhere = unknown, TOrderBy = unknown>(\n model: PrismaModelLike<TItem, TWhere, TOrderBy>,\n input: PaginateInput<TWhere, TOrderBy>,\n opts: ClampLimitOptions = {}\n): Promise<PaginateResult<TItem>> {\n // Use GraphQL-aware cap (max=100) so paginate() is safe to call directly from resolvers.\n const take = clampGraphqlLimit(input.take ?? undefined, opts);\n // fetch +1 to detect hasMore\n const items = await model.findMany({\n take: take + 1,\n skip: input.cursor ? 1 : 0,\n cursor: input.cursor ? { id: input.cursor } : undefined,\n where: input.where,\n orderBy: input.orderBy,\n });\n const hasMore = items.length > take;\n const trimmed = hasMore ? items.slice(0, take) : items;\n const nextCursor = hasMore && trimmed.length > 0 ? (trimmed[trimmed.length - 1] as { id: string }).id : null;\n return { items: trimmed, hasMore, nextCursor };\n}\n","/**\n * DataLoaderFactory — per-request DataLoader collection.\n *\n * Each GraphQL request creates a fresh loader set scoped to its context\n * (db, workspaceId, requestId). Loaders are addressed by name and reused\n * within the request to coalesce N+1 fan-outs into a single batched query.\n *\n * Also ships `resolveReferenceLoader` — a convenience for Apollo Federation\n * `__resolveReference` resolvers so entity hydration stays N+1-free.\n *\n * This module is intentionally framework-agnostic; consumers may pair it\n * with the existing `SimpleDataLoader` in `src/dataloader/index.ts` or the\n * upstream `dataloader` npm package.\n */\n\nexport interface DataLoaderLike<K, V> {\n load(key: K): Promise<V>;\n loadMany(keys: readonly K[]): Promise<(V | Error)[]>;\n clear(key: K): this;\n clearAll(): this;\n prime(key: K, value: V): this;\n}\n\nexport type LoaderMap = Record<string, DataLoaderLike<unknown, unknown>>;\n\nexport type LoaderBuilder<Ctx, M extends LoaderMap> = (ctx: Ctx) => M;\n\n/**\n * Build a fresh loader collection from a context.\n *\n * @example\n * const loaders = buildLoaders(ctx, (c) => ({\n * userById: createSimpleLoader(async ids => c.db.user.findMany({ where: { id: { in: [...ids] } } }), u => u.id),\n * tagById: createSimpleLoader(...),\n * }));\n * await loaders.userById.load('user-123');\n */\nexport function buildLoaders<Ctx, M extends LoaderMap>(ctx: Ctx, builder: LoaderBuilder<Ctx, M>): M {\n return builder(ctx);\n}\n\n/**\n * `__resolveReference` helper for Apollo Federation.\n *\n * Given a context that contains a `loaders` map, returns a resolver\n * function bound to a specific loader name. Field references shaped as\n * `{ id: string }` (or `{ __keyField: string }`) are forwarded to\n * `loader.load(...)`.\n */\nexport interface ReferenceObject {\n id?: string;\n [key: string]: unknown;\n}\n\nexport function resolveReferenceLoader<T, Ctx extends { loaders: LoaderMap }>(\n loaderName: string,\n keyField: string = 'id'\n): (reference: ReferenceObject, ctx: Ctx) => Promise<T | null> {\n return async (reference, ctx) => {\n const loader = ctx.loaders[loaderName] as DataLoaderLike<string, T> | undefined;\n if (!loader) {\n throw new Error(`resolveReferenceLoader: loader \"${loaderName}\" not found on ctx.loaders`);\n }\n const key = reference[keyField];\n if (typeof key !== 'string') {\n return null;\n }\n return loader.load(key);\n };\n}\n","/**\n * Versioned-key cache invalidation helper.\n *\n * Pattern:\n * - Store `v:{namespace}` integer in Redis\n * - Compose keys as `${namespace}:v${ver}:${rest}`\n * - Invalidate via INCR `v:{namespace}` — no KEYS / SCAN required\n *\n * Use this instead of cacheClearPattern() for Azure Managed Redis (O(N)\n * blocking on KEYS is unsafe in prod).\n */\n\nexport interface CacheVersionRedis {\n get(key: string): Promise<string | null>;\n incr(key: string): Promise<number>;\n}\n\nconst VERSION_PREFIX = 'besdk:cv:';\n\nexport async function getNamespaceVersion(redis: CacheVersionRedis, namespace: string): Promise<number> {\n const v = await redis.get(`${VERSION_PREFIX}${namespace}`);\n if (!v) return 1;\n const n = Number.parseInt(v, 10);\n return Number.isFinite(n) && n > 0 ? n : 1;\n}\n\nexport async function buildCacheKey(redis: CacheVersionRedis, namespace: string, ...parts: string[]): Promise<string> {\n const ver = await getNamespaceVersion(redis, namespace);\n return `${namespace}:v${ver}:${parts.join(':')}`;\n}\n\nexport async function invalidateNamespace(redis: CacheVersionRedis, namespace: string): Promise<number> {\n return redis.incr(`${VERSION_PREFIX}${namespace}`);\n}\n","/**\n * PG declarative partition + retention DSL.\n *\n * Helpers:\n * - ensureMonthlyPartitions(prisma, { table, from, to })\n * - dropOldPartitions(prisma, { table, beforeDate })\n *\n * Used by retention jobs / migrations to keep append-only tables\n * (ActivityLog, Message, TrackingEvent, ApplicationUsage, AuditLog)\n * bounded. Caller is responsible for ensuring the parent table is\n * already declared as PARTITION BY RANGE (created_at).\n */\n\nexport interface PrismaRawClient {\n $executeRawUnsafe(query: string, ...values: unknown[]): Promise<unknown>;\n $queryRawUnsafe<T = unknown>(query: string, ...values: unknown[]): Promise<T>;\n}\n\nfunction pad2(n: number): string {\n return n < 10 ? `0${n}` : `${n}`;\n}\n\nexport function monthlyPartitionName(table: string, year: number, month: number): string {\n return `${table}_y${year}m${pad2(month)}`;\n}\n\nexport interface EnsureMonthlyOptions {\n table: string;\n from: Date;\n to: Date;\n}\n\nexport async function ensureMonthlyPartitions(prisma: PrismaRawClient, opts: EnsureMonthlyOptions): Promise<string[]> {\n const created: string[] = [];\n const cur = new Date(Date.UTC(opts.from.getUTCFullYear(), opts.from.getUTCMonth(), 1));\n const end = new Date(Date.UTC(opts.to.getUTCFullYear(), opts.to.getUTCMonth(), 1));\n while (cur <= end) {\n const y = cur.getUTCFullYear();\n const m = cur.getUTCMonth() + 1;\n const next = new Date(Date.UTC(y, m, 1));\n const partition = monthlyPartitionName(opts.table, y, m);\n const lower = `${y}-${pad2(m)}-01`;\n const upper = `${next.getUTCFullYear()}-${pad2(next.getUTCMonth() + 1)}-01`;\n await prisma.$executeRawUnsafe(\n `CREATE TABLE IF NOT EXISTS \"${partition}\" PARTITION OF \"${opts.table}\" FOR VALUES FROM ('${lower}') TO ('${upper}');`\n );\n created.push(partition);\n cur.setUTCMonth(cur.getUTCMonth() + 1);\n }\n return created;\n}\n\nexport interface DropOldOptions {\n table: string;\n beforeDate: Date;\n}\n\ninterface PartitionRow {\n partition_name: string;\n}\n\nexport async function dropOldPartitions(prisma: PrismaRawClient, opts: DropOldOptions): Promise<string[]> {\n // Find inherited tables of the parent, parse year/month from suffix, drop ones before threshold.\n const rows = await prisma.$queryRawUnsafe<PartitionRow[]>(\n `SELECT child.relname AS partition_name\n FROM pg_inherits\n JOIN pg_class parent ON pg_inherits.inhparent = parent.oid\n JOIN pg_class child ON pg_inherits.inhrelid = child.oid\n WHERE parent.relname = $1`,\n opts.table\n );\n const dropped: string[] = [];\n const cutoffYear = opts.beforeDate.getUTCFullYear();\n const cutoffMonth = opts.beforeDate.getUTCMonth() + 1;\n for (const row of rows) {\n const partitionRe = /_y(\\d{4})m(\\d{2})$/;\n const m = partitionRe.exec(row.partition_name);\n if (!m) continue;\n const y = Number(m[1]);\n const mo = Number(m[2]);\n if (y < cutoffYear || (y === cutoffYear && mo < cutoffMonth)) {\n await prisma.$executeRawUnsafe(`DROP TABLE IF EXISTS \"${row.partition_name}\";`);\n dropped.push(row.partition_name);\n }\n }\n return dropped;\n}\n","/**\n * Multi-provider LLM wrapper with timeout, retries, jitter, provider\n * fallback chain, token cap, and streaming passthrough.\n *\n * No hard dependency on a specific SDK — consumers register adapters.\n * Provider chain order is controlled by env `LLM_PROVIDER_CHAIN`\n * (comma-separated, e.g. `anthropic,openai,openrouter`).\n *\n * The wrapper is intentionally minimal — callers should construct it\n * once at boot, register adapters, and inject the singleton.\n */\n\nimport { logger } from '../logger/index.js';\n\nexport interface LLMRequest {\n model?: string;\n messages: Array<{ role: 'system' | 'user' | 'assistant'; content: string }>;\n maxTokens?: number;\n temperature?: number;\n stream?: boolean;\n /** Override timeout for this request. */\n timeoutMs?: number;\n}\n\nexport interface LLMResponse {\n provider: string;\n content: string;\n inputTokens?: number;\n outputTokens?: number;\n raw?: unknown;\n}\n\nexport interface LLMProviderAdapter {\n name: string;\n complete(req: LLMRequest, signal: AbortSignal): Promise<LLMResponse>;\n}\n\nexport interface LLMRouterOptions {\n /** Default per-attempt timeout (ms). */\n timeoutMs?: number;\n /** Max attempts across providers. */\n maxAttempts?: number;\n /** Initial backoff (ms). */\n initialDelayMs?: number;\n /** Hard cap on output tokens regardless of caller request. */\n maxOutputTokensCap?: number;\n}\n\nconst DEFAULTS: Required<LLMRouterOptions> = {\n timeoutMs: 30_000,\n maxAttempts: 3,\n initialDelayMs: 500,\n maxOutputTokensCap: 4096,\n};\n\nfunction jitter(n: number): number {\n return Math.floor(Math.random() * n);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nexport class LLMRouter {\n private readonly adapters: Map<string, LLMProviderAdapter> = new Map();\n private readonly opts: Required<LLMRouterOptions>;\n\n constructor(opts: LLMRouterOptions = {}) {\n this.opts = { ...DEFAULTS, ...opts };\n }\n\n register(adapter: LLMProviderAdapter): void {\n this.adapters.set(adapter.name, adapter);\n }\n\n private resolveChain(): string[] {\n const envChain = process.env['LLM_PROVIDER_CHAIN']?.trim();\n if (envChain) {\n return envChain\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n }\n return Array.from(this.adapters.keys());\n }\n\n async complete(req: LLMRequest): Promise<LLMResponse> {\n const cappedReq: LLMRequest = {\n ...req,\n maxTokens: Math.min(req.maxTokens ?? this.opts.maxOutputTokensCap, this.opts.maxOutputTokensCap),\n };\n const chain = this.resolveChain();\n if (chain.length === 0) {\n throw new Error('LLMRouter: no providers registered');\n }\n\n let lastErr: unknown = null;\n for (let attempt = 0; attempt < this.opts.maxAttempts; attempt++) {\n const providerName = chain[attempt % chain.length];\n const adapter = providerName ? this.adapters.get(providerName) : undefined;\n if (!adapter) {\n logger.warn('llmRouter.provider.notRegistered', { providerName });\n continue;\n }\n const timeoutMs = req.timeoutMs ?? this.opts.timeoutMs;\n const ctrl = new AbortController();\n const t = setTimeout(() => ctrl.abort(), timeoutMs);\n try {\n const response = await adapter.complete(cappedReq, ctrl.signal);\n return response;\n } catch (err) {\n lastErr = err;\n logger.warn('llmRouter.attempt.failed', { provider: adapter.name, attempt, err: String(err) });\n if (attempt < this.opts.maxAttempts - 1) {\n const delay = this.opts.initialDelayMs * 2 ** attempt;\n await sleep(jitter(delay));\n }\n } finally {\n clearTimeout(t);\n }\n }\n throw lastErr instanceof Error ? lastErr : new Error(`LLMRouter exhausted ${this.opts.maxAttempts} attempts`);\n }\n}\n"]}
|
package/dist/index-PJZzGd8r.d.ts
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
interface RetryConfig {
|
|
2
|
-
attempts?: number;
|
|
3
|
-
initialDelayMs?: number;
|
|
4
|
-
maxDelayMs?: number;
|
|
5
|
-
retryOn?: (status: number) => boolean;
|
|
6
|
-
}
|
|
7
|
-
interface BreakerConfig {
|
|
8
|
-
threshold?: number;
|
|
9
|
-
cooldownMs?: number;
|
|
10
|
-
}
|
|
11
|
-
interface HttpClientConfig {
|
|
12
|
-
baseUrl?: string;
|
|
13
|
-
defaultTimeoutMs?: number;
|
|
14
|
-
retry?: RetryConfig;
|
|
15
|
-
breaker?: BreakerConfig;
|
|
16
|
-
defaultHeaders?: Record<string, string>;
|
|
17
|
-
}
|
|
18
|
-
declare class CircuitBreakerOpenError extends Error {
|
|
19
|
-
constructor(host: string);
|
|
20
|
-
}
|
|
21
|
-
interface HttpClientInit extends RequestInit {
|
|
22
|
-
timeoutMs?: number;
|
|
23
|
-
retry?: RetryConfig;
|
|
24
|
-
}
|
|
25
|
-
declare function __resetHttpClientBreakers(): void;
|
|
26
|
-
declare function httpClient(url: string, init?: HttpClientInit, config?: HttpClientConfig): Promise<Response>;
|
|
27
|
-
declare function createHttpClient(config?: HttpClientConfig): (url: string, init?: HttpClientInit) => Promise<Response>;
|
|
28
|
-
|
|
29
|
-
interface LeaderLockRedis {
|
|
30
|
-
set(key: string, value: string, ex: 'EX', seconds: number, nx: 'NX'): Promise<'OK' | null>;
|
|
31
|
-
eval(script: string, numKeys: number, ...args: string[]): Promise<unknown>;
|
|
32
|
-
}
|
|
33
|
-
interface LeaderLockOptions {
|
|
34
|
-
ttlMs: number;
|
|
35
|
-
renewMs?: number;
|
|
36
|
-
}
|
|
37
|
-
interface LeaderLockResult<T> {
|
|
38
|
-
acquired: boolean;
|
|
39
|
-
result?: T;
|
|
40
|
-
}
|
|
41
|
-
declare function normalizeRedisUrl(url: string): string;
|
|
42
|
-
declare function withLeaderLock<T>(redis: LeaderLockRedis, name: string, fn: () => Promise<T>, options: LeaderLockOptions): Promise<LeaderLockResult<T>>;
|
|
43
|
-
interface CreateLeaderLeaseOptions {
|
|
44
|
-
name: string;
|
|
45
|
-
ttlMs: number;
|
|
46
|
-
redis: LeaderLockRedis;
|
|
47
|
-
renewMs?: number;
|
|
48
|
-
}
|
|
49
|
-
interface LeaderLease {
|
|
50
|
-
renew(): Promise<boolean>;
|
|
51
|
-
release(): Promise<void>;
|
|
52
|
-
isHeld(): boolean;
|
|
53
|
-
}
|
|
54
|
-
declare function createLeaderLease(options: CreateLeaderLeaseOptions): LeaderLease;
|
|
55
|
-
|
|
56
|
-
interface RateLimitRedis {
|
|
57
|
-
incr(key: string): Promise<number>;
|
|
58
|
-
pexpire(key: string, ms: number): Promise<number | 'OK'>;
|
|
59
|
-
pttl(key: string): Promise<number>;
|
|
60
|
-
}
|
|
61
|
-
interface RateLimitInput {
|
|
62
|
-
key: string;
|
|
63
|
-
limit: number;
|
|
64
|
-
windowMs: number;
|
|
65
|
-
}
|
|
66
|
-
interface RateLimitResult {
|
|
67
|
-
allowed: boolean;
|
|
68
|
-
count: number;
|
|
69
|
-
remaining: number;
|
|
70
|
-
resetAt: number;
|
|
71
|
-
}
|
|
72
|
-
declare function rateLimitIncr(redis: RateLimitRedis, input: RateLimitInput): Promise<RateLimitResult>;
|
|
73
|
-
|
|
74
|
-
interface ClampLimitOptions {
|
|
75
|
-
defaultLimit?: number;
|
|
76
|
-
maxLimit?: number;
|
|
77
|
-
minLimit?: number;
|
|
78
|
-
}
|
|
79
|
-
declare const DEFAULT_GRAPHQL_PAGE_LIMIT = 50;
|
|
80
|
-
declare const MAX_GRAPHQL_PAGE_LIMIT = 100;
|
|
81
|
-
declare function clampLimit(input: number | undefined | null, opts?: ClampLimitOptions): number;
|
|
82
|
-
declare function clampOffset(input: number | undefined | null): number;
|
|
83
|
-
declare function clampGraphqlLimit(input: number | undefined | null, opts?: ClampLimitOptions): number;
|
|
84
|
-
interface OffsetPaginationInput {
|
|
85
|
-
limit?: number | null;
|
|
86
|
-
offset?: number | null;
|
|
87
|
-
}
|
|
88
|
-
interface NormalizedOffsetPagination {
|
|
89
|
-
limit: number;
|
|
90
|
-
offset: number;
|
|
91
|
-
}
|
|
92
|
-
declare function normalizeOffsetPagination(input: OffsetPaginationInput | null | undefined, opts?: ClampLimitOptions): NormalizedOffsetPagination;
|
|
93
|
-
interface CursorPaginationInput {
|
|
94
|
-
first?: number | null;
|
|
95
|
-
after?: string | null;
|
|
96
|
-
}
|
|
97
|
-
interface NormalizedCursorPagination {
|
|
98
|
-
first: number;
|
|
99
|
-
after: string | null;
|
|
100
|
-
take: number;
|
|
101
|
-
}
|
|
102
|
-
declare function normalizeCursorPagination(input: CursorPaginationInput | null | undefined, opts?: ClampLimitOptions): NormalizedCursorPagination;
|
|
103
|
-
type CursorPayloadValue = string | number | boolean | null;
|
|
104
|
-
type CursorPayload = Record<string, CursorPayloadValue>;
|
|
105
|
-
declare function encodeCursor(payload: CursorPayload): string;
|
|
106
|
-
declare function decodeCursor(cursor: string | null | undefined): CursorPayload | null;
|
|
107
|
-
interface PageInfo {
|
|
108
|
-
hasNextPage: boolean;
|
|
109
|
-
hasPreviousPage: boolean;
|
|
110
|
-
startCursor: string | null;
|
|
111
|
-
endCursor: string | null;
|
|
112
|
-
}
|
|
113
|
-
interface ConnectionEdge<TItem> {
|
|
114
|
-
node: TItem;
|
|
115
|
-
cursor: string;
|
|
116
|
-
}
|
|
117
|
-
interface ConnectionResult<TItem> {
|
|
118
|
-
edges: ConnectionEdge<TItem>[];
|
|
119
|
-
nodes: TItem[];
|
|
120
|
-
pageInfo: PageInfo;
|
|
121
|
-
totalCount?: number | null;
|
|
122
|
-
}
|
|
123
|
-
interface BuildConnectionOptions<TItem> {
|
|
124
|
-
limit: number;
|
|
125
|
-
cursorForNode: (item: TItem) => string;
|
|
126
|
-
hasPreviousPage?: boolean;
|
|
127
|
-
totalCount?: number | null;
|
|
128
|
-
}
|
|
129
|
-
declare function buildConnection<TItem>(items: TItem[], opts: BuildConnectionOptions<TItem>): ConnectionResult<TItem>;
|
|
130
|
-
interface OffsetPageResult<TItem> {
|
|
131
|
-
items: TItem[];
|
|
132
|
-
total: number;
|
|
133
|
-
limit: number;
|
|
134
|
-
offset: number;
|
|
135
|
-
hasMore: boolean;
|
|
136
|
-
nextOffset: number | null;
|
|
137
|
-
}
|
|
138
|
-
declare function buildOffsetPage<TItem>(items: TItem[], total: number, pagination: NormalizedOffsetPagination): OffsetPageResult<TItem>;
|
|
139
|
-
declare function toPrismaPage(pagination: NormalizedOffsetPagination): {
|
|
140
|
-
take: number;
|
|
141
|
-
skip: number;
|
|
142
|
-
};
|
|
143
|
-
interface PaginateInput<TWhere, TOrderBy> {
|
|
144
|
-
take?: number | null;
|
|
145
|
-
cursor?: string | null;
|
|
146
|
-
where?: TWhere;
|
|
147
|
-
orderBy?: TOrderBy;
|
|
148
|
-
}
|
|
149
|
-
interface PaginateResult<TItem> {
|
|
150
|
-
items: TItem[];
|
|
151
|
-
hasMore: boolean;
|
|
152
|
-
nextCursor: string | null;
|
|
153
|
-
}
|
|
154
|
-
interface PrismaModelLike<TItem, TWhere, TOrderBy> {
|
|
155
|
-
findMany(args: {
|
|
156
|
-
take?: number;
|
|
157
|
-
skip?: number;
|
|
158
|
-
cursor?: {
|
|
159
|
-
id: string;
|
|
160
|
-
};
|
|
161
|
-
where?: TWhere;
|
|
162
|
-
orderBy?: TOrderBy;
|
|
163
|
-
}): Promise<TItem[]>;
|
|
164
|
-
}
|
|
165
|
-
declare function paginate<TItem extends {
|
|
166
|
-
id: string;
|
|
167
|
-
}, TWhere = unknown, TOrderBy = unknown>(model: PrismaModelLike<TItem, TWhere, TOrderBy>, input: PaginateInput<TWhere, TOrderBy>, opts?: ClampLimitOptions): Promise<PaginateResult<TItem>>;
|
|
168
|
-
|
|
169
|
-
interface DataLoaderLike<K, V> {
|
|
170
|
-
load(key: K): Promise<V>;
|
|
171
|
-
loadMany(keys: readonly K[]): Promise<(V | Error)[]>;
|
|
172
|
-
clear(key: K): this;
|
|
173
|
-
clearAll(): this;
|
|
174
|
-
prime(key: K, value: V): this;
|
|
175
|
-
}
|
|
176
|
-
type LoaderMap = Record<string, DataLoaderLike<unknown, unknown>>;
|
|
177
|
-
type LoaderBuilder<Ctx, M extends LoaderMap> = (ctx: Ctx) => M;
|
|
178
|
-
declare function buildLoaders<Ctx, M extends LoaderMap>(ctx: Ctx, builder: LoaderBuilder<Ctx, M>): M;
|
|
179
|
-
interface ReferenceObject {
|
|
180
|
-
id?: string;
|
|
181
|
-
[key: string]: unknown;
|
|
182
|
-
}
|
|
183
|
-
declare function resolveReferenceLoader<T, Ctx extends {
|
|
184
|
-
loaders: LoaderMap;
|
|
185
|
-
}>(loaderName: string, keyField?: string): (reference: ReferenceObject, ctx: Ctx) => Promise<T | null>;
|
|
186
|
-
|
|
187
|
-
interface CacheVersionRedis {
|
|
188
|
-
get(key: string): Promise<string | null>;
|
|
189
|
-
incr(key: string): Promise<number>;
|
|
190
|
-
}
|
|
191
|
-
declare function getNamespaceVersion(redis: CacheVersionRedis, namespace: string): Promise<number>;
|
|
192
|
-
declare function buildCacheKey(redis: CacheVersionRedis, namespace: string, ...parts: string[]): Promise<string>;
|
|
193
|
-
declare function invalidateNamespace(redis: CacheVersionRedis, namespace: string): Promise<number>;
|
|
194
|
-
|
|
195
|
-
interface PrismaRawClient {
|
|
196
|
-
$executeRawUnsafe(query: string, ...values: unknown[]): Promise<unknown>;
|
|
197
|
-
$queryRawUnsafe<T = unknown>(query: string, ...values: unknown[]): Promise<T>;
|
|
198
|
-
}
|
|
199
|
-
declare function monthlyPartitionName(table: string, year: number, month: number): string;
|
|
200
|
-
interface EnsureMonthlyOptions {
|
|
201
|
-
table: string;
|
|
202
|
-
from: Date;
|
|
203
|
-
to: Date;
|
|
204
|
-
}
|
|
205
|
-
declare function ensureMonthlyPartitions(prisma: PrismaRawClient, opts: EnsureMonthlyOptions): Promise<string[]>;
|
|
206
|
-
interface DropOldOptions {
|
|
207
|
-
table: string;
|
|
208
|
-
beforeDate: Date;
|
|
209
|
-
}
|
|
210
|
-
declare function dropOldPartitions(prisma: PrismaRawClient, opts: DropOldOptions): Promise<string[]>;
|
|
211
|
-
|
|
212
|
-
interface LLMRequest {
|
|
213
|
-
model?: string;
|
|
214
|
-
messages: Array<{
|
|
215
|
-
role: 'system' | 'user' | 'assistant';
|
|
216
|
-
content: string;
|
|
217
|
-
}>;
|
|
218
|
-
maxTokens?: number;
|
|
219
|
-
temperature?: number;
|
|
220
|
-
stream?: boolean;
|
|
221
|
-
timeoutMs?: number;
|
|
222
|
-
}
|
|
223
|
-
interface LLMResponse {
|
|
224
|
-
provider: string;
|
|
225
|
-
content: string;
|
|
226
|
-
inputTokens?: number;
|
|
227
|
-
outputTokens?: number;
|
|
228
|
-
raw?: unknown;
|
|
229
|
-
}
|
|
230
|
-
interface LLMProviderAdapter {
|
|
231
|
-
name: string;
|
|
232
|
-
complete(req: LLMRequest, signal: AbortSignal): Promise<LLMResponse>;
|
|
233
|
-
}
|
|
234
|
-
interface LLMRouterOptions {
|
|
235
|
-
timeoutMs?: number;
|
|
236
|
-
maxAttempts?: number;
|
|
237
|
-
initialDelayMs?: number;
|
|
238
|
-
maxOutputTokensCap?: number;
|
|
239
|
-
}
|
|
240
|
-
declare class LLMRouter {
|
|
241
|
-
private readonly adapters;
|
|
242
|
-
private readonly opts;
|
|
243
|
-
constructor(opts?: LLMRouterOptions);
|
|
244
|
-
register(adapter: LLMProviderAdapter): void;
|
|
245
|
-
private resolveChain;
|
|
246
|
-
complete(req: LLMRequest): Promise<LLMResponse>;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
type index_BreakerConfig = BreakerConfig;
|
|
250
|
-
type index_BuildConnectionOptions<TItem> = BuildConnectionOptions<TItem>;
|
|
251
|
-
type index_CacheVersionRedis = CacheVersionRedis;
|
|
252
|
-
type index_CircuitBreakerOpenError = CircuitBreakerOpenError;
|
|
253
|
-
declare const index_CircuitBreakerOpenError: typeof CircuitBreakerOpenError;
|
|
254
|
-
type index_ClampLimitOptions = ClampLimitOptions;
|
|
255
|
-
type index_ConnectionEdge<TItem> = ConnectionEdge<TItem>;
|
|
256
|
-
type index_ConnectionResult<TItem> = ConnectionResult<TItem>;
|
|
257
|
-
type index_CreateLeaderLeaseOptions = CreateLeaderLeaseOptions;
|
|
258
|
-
type index_CursorPaginationInput = CursorPaginationInput;
|
|
259
|
-
type index_CursorPayload = CursorPayload;
|
|
260
|
-
type index_CursorPayloadValue = CursorPayloadValue;
|
|
261
|
-
declare const index_DEFAULT_GRAPHQL_PAGE_LIMIT: typeof DEFAULT_GRAPHQL_PAGE_LIMIT;
|
|
262
|
-
type index_DataLoaderLike<K, V> = DataLoaderLike<K, V>;
|
|
263
|
-
type index_DropOldOptions = DropOldOptions;
|
|
264
|
-
type index_EnsureMonthlyOptions = EnsureMonthlyOptions;
|
|
265
|
-
type index_HttpClientConfig = HttpClientConfig;
|
|
266
|
-
type index_HttpClientInit = HttpClientInit;
|
|
267
|
-
type index_LLMProviderAdapter = LLMProviderAdapter;
|
|
268
|
-
type index_LLMRequest = LLMRequest;
|
|
269
|
-
type index_LLMResponse = LLMResponse;
|
|
270
|
-
type index_LLMRouter = LLMRouter;
|
|
271
|
-
declare const index_LLMRouter: typeof LLMRouter;
|
|
272
|
-
type index_LLMRouterOptions = LLMRouterOptions;
|
|
273
|
-
type index_LeaderLease = LeaderLease;
|
|
274
|
-
type index_LeaderLockOptions = LeaderLockOptions;
|
|
275
|
-
type index_LeaderLockRedis = LeaderLockRedis;
|
|
276
|
-
type index_LeaderLockResult<T> = LeaderLockResult<T>;
|
|
277
|
-
type index_LoaderBuilder<Ctx, M extends LoaderMap> = LoaderBuilder<Ctx, M>;
|
|
278
|
-
type index_LoaderMap = LoaderMap;
|
|
279
|
-
declare const index_MAX_GRAPHQL_PAGE_LIMIT: typeof MAX_GRAPHQL_PAGE_LIMIT;
|
|
280
|
-
type index_NormalizedCursorPagination = NormalizedCursorPagination;
|
|
281
|
-
type index_NormalizedOffsetPagination = NormalizedOffsetPagination;
|
|
282
|
-
type index_OffsetPageResult<TItem> = OffsetPageResult<TItem>;
|
|
283
|
-
type index_OffsetPaginationInput = OffsetPaginationInput;
|
|
284
|
-
type index_PageInfo = PageInfo;
|
|
285
|
-
type index_PaginateInput<TWhere, TOrderBy> = PaginateInput<TWhere, TOrderBy>;
|
|
286
|
-
type index_PaginateResult<TItem> = PaginateResult<TItem>;
|
|
287
|
-
type index_PrismaModelLike<TItem, TWhere, TOrderBy> = PrismaModelLike<TItem, TWhere, TOrderBy>;
|
|
288
|
-
type index_PrismaRawClient = PrismaRawClient;
|
|
289
|
-
type index_RateLimitInput = RateLimitInput;
|
|
290
|
-
type index_RateLimitRedis = RateLimitRedis;
|
|
291
|
-
type index_RateLimitResult = RateLimitResult;
|
|
292
|
-
type index_ReferenceObject = ReferenceObject;
|
|
293
|
-
type index_RetryConfig = RetryConfig;
|
|
294
|
-
declare const index___resetHttpClientBreakers: typeof __resetHttpClientBreakers;
|
|
295
|
-
declare const index_buildCacheKey: typeof buildCacheKey;
|
|
296
|
-
declare const index_buildConnection: typeof buildConnection;
|
|
297
|
-
declare const index_buildLoaders: typeof buildLoaders;
|
|
298
|
-
declare const index_buildOffsetPage: typeof buildOffsetPage;
|
|
299
|
-
declare const index_clampGraphqlLimit: typeof clampGraphqlLimit;
|
|
300
|
-
declare const index_clampLimit: typeof clampLimit;
|
|
301
|
-
declare const index_clampOffset: typeof clampOffset;
|
|
302
|
-
declare const index_createHttpClient: typeof createHttpClient;
|
|
303
|
-
declare const index_createLeaderLease: typeof createLeaderLease;
|
|
304
|
-
declare const index_decodeCursor: typeof decodeCursor;
|
|
305
|
-
declare const index_dropOldPartitions: typeof dropOldPartitions;
|
|
306
|
-
declare const index_encodeCursor: typeof encodeCursor;
|
|
307
|
-
declare const index_ensureMonthlyPartitions: typeof ensureMonthlyPartitions;
|
|
308
|
-
declare const index_getNamespaceVersion: typeof getNamespaceVersion;
|
|
309
|
-
declare const index_httpClient: typeof httpClient;
|
|
310
|
-
declare const index_invalidateNamespace: typeof invalidateNamespace;
|
|
311
|
-
declare const index_monthlyPartitionName: typeof monthlyPartitionName;
|
|
312
|
-
declare const index_normalizeCursorPagination: typeof normalizeCursorPagination;
|
|
313
|
-
declare const index_normalizeOffsetPagination: typeof normalizeOffsetPagination;
|
|
314
|
-
declare const index_normalizeRedisUrl: typeof normalizeRedisUrl;
|
|
315
|
-
declare const index_paginate: typeof paginate;
|
|
316
|
-
declare const index_rateLimitIncr: typeof rateLimitIncr;
|
|
317
|
-
declare const index_resolveReferenceLoader: typeof resolveReferenceLoader;
|
|
318
|
-
declare const index_toPrismaPage: typeof toPrismaPage;
|
|
319
|
-
declare const index_withLeaderLock: typeof withLeaderLock;
|
|
320
|
-
declare namespace index {
|
|
321
|
-
export { type index_BreakerConfig as BreakerConfig, type index_BuildConnectionOptions as BuildConnectionOptions, type index_CacheVersionRedis as CacheVersionRedis, index_CircuitBreakerOpenError as CircuitBreakerOpenError, type index_ClampLimitOptions as ClampLimitOptions, type index_ConnectionEdge as ConnectionEdge, type index_ConnectionResult as ConnectionResult, type index_CreateLeaderLeaseOptions as CreateLeaderLeaseOptions, type index_CursorPaginationInput as CursorPaginationInput, type index_CursorPayload as CursorPayload, type index_CursorPayloadValue as CursorPayloadValue, index_DEFAULT_GRAPHQL_PAGE_LIMIT as DEFAULT_GRAPHQL_PAGE_LIMIT, type index_DataLoaderLike as DataLoaderLike, type index_DropOldOptions as DropOldOptions, type index_EnsureMonthlyOptions as EnsureMonthlyOptions, type index_HttpClientConfig as HttpClientConfig, type index_HttpClientInit as HttpClientInit, type index_LLMProviderAdapter as LLMProviderAdapter, type index_LLMRequest as LLMRequest, type index_LLMResponse as LLMResponse, index_LLMRouter as LLMRouter, type index_LLMRouterOptions as LLMRouterOptions, type index_LeaderLease as LeaderLease, type index_LeaderLockOptions as LeaderLockOptions, type index_LeaderLockRedis as LeaderLockRedis, type index_LeaderLockResult as LeaderLockResult, type index_LoaderBuilder as LoaderBuilder, type index_LoaderMap as LoaderMap, index_MAX_GRAPHQL_PAGE_LIMIT as MAX_GRAPHQL_PAGE_LIMIT, type index_NormalizedCursorPagination as NormalizedCursorPagination, type index_NormalizedOffsetPagination as NormalizedOffsetPagination, type index_OffsetPageResult as OffsetPageResult, type index_OffsetPaginationInput as OffsetPaginationInput, type index_PageInfo as PageInfo, type index_PaginateInput as PaginateInput, type index_PaginateResult as PaginateResult, type index_PrismaModelLike as PrismaModelLike, type index_PrismaRawClient as PrismaRawClient, type index_RateLimitInput as RateLimitInput, type index_RateLimitRedis as RateLimitRedis, type index_RateLimitResult as RateLimitResult, type index_ReferenceObject as ReferenceObject, type index_RetryConfig as RetryConfig, index___resetHttpClientBreakers as __resetHttpClientBreakers, index_buildCacheKey as buildCacheKey, index_buildConnection as buildConnection, index_buildLoaders as buildLoaders, index_buildOffsetPage as buildOffsetPage, index_clampGraphqlLimit as clampGraphqlLimit, index_clampLimit as clampLimit, index_clampOffset as clampOffset, index_createHttpClient as createHttpClient, index_createLeaderLease as createLeaderLease, index_decodeCursor as decodeCursor, index_dropOldPartitions as dropOldPartitions, index_encodeCursor as encodeCursor, index_ensureMonthlyPartitions as ensureMonthlyPartitions, index_getNamespaceVersion as getNamespaceVersion, index_httpClient as httpClient, index_invalidateNamespace as invalidateNamespace, index_monthlyPartitionName as monthlyPartitionName, index_normalizeCursorPagination as normalizeCursorPagination, index_normalizeOffsetPagination as normalizeOffsetPagination, index_normalizeRedisUrl as normalizeRedisUrl, index_paginate as paginate, index_rateLimitIncr as rateLimitIncr, index_resolveReferenceLoader as resolveReferenceLoader, index_toPrismaPage as toPrismaPage, index_withLeaderLock as withLeaderLock };
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export { createLeaderLease as $, type PaginateResult as A, type BreakerConfig as B, type CacheVersionRedis as C, DEFAULT_GRAPHQL_PAGE_LIMIT as D, type EnsureMonthlyOptions as E, type PrismaModelLike as F, type PrismaRawClient as G, type HttpClientConfig as H, type RateLimitRedis as I, type RateLimitResult as J, type ReferenceObject as K, type LLMProviderAdapter as L, MAX_GRAPHQL_PAGE_LIMIT as M, type NormalizedCursorPagination as N, type OffsetPageResult as O, type PageInfo as P, type RetryConfig as Q, type RateLimitInput as R, buildCacheKey as S, buildConnection as T, buildLoaders as U, buildOffsetPage as V, clampGraphqlLimit as W, clampLimit as X, clampOffset as Y, createHttpClient as Z, __resetHttpClientBreakers as _, type BuildConnectionOptions as a, decodeCursor as a0, dropOldPartitions as a1, encodeCursor as a2, ensureMonthlyPartitions as a3, getNamespaceVersion as a4, httpClient as a5, invalidateNamespace as a6, monthlyPartitionName as a7, normalizeCursorPagination as a8, normalizeOffsetPagination as a9, normalizeRedisUrl as aa, paginate as ab, rateLimitIncr as ac, resolveReferenceLoader as ad, toPrismaPage as ae, withLeaderLock as af, CircuitBreakerOpenError as b, type ClampLimitOptions as c, type ConnectionEdge as d, type ConnectionResult as e, type CreateLeaderLeaseOptions as f, type CursorPaginationInput as g, type CursorPayload as h, index as i, type CursorPayloadValue as j, type DataLoaderLike as k, type DropOldOptions as l, type HttpClientInit as m, type LLMRequest as n, type LLMResponse as o, LLMRouter as p, type LLMRouterOptions as q, type LeaderLease as r, type LeaderLockOptions as s, type LeaderLockRedis as t, type LeaderLockResult as u, type LoaderBuilder as v, type LoaderMap as w, type NormalizedOffsetPagination as x, type OffsetPaginationInput as y, type PaginateInput as z };
|