@burdenoff/be-sdk 2026.622.1 → 2026.624.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.
@@ -0,0 +1,302 @@
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 withLeaderLock<T>(redis: LeaderLockRedis, name: string, fn: () => Promise<T>, options: LeaderLockOptions): Promise<LeaderLockResult<T>>;
42
+
43
+ interface RateLimitRedis {
44
+ incr(key: string): Promise<number>;
45
+ pexpire(key: string, ms: number): Promise<number | 'OK'>;
46
+ pttl(key: string): Promise<number>;
47
+ }
48
+ interface RateLimitInput {
49
+ key: string;
50
+ limit: number;
51
+ windowMs: number;
52
+ }
53
+ interface RateLimitResult {
54
+ allowed: boolean;
55
+ count: number;
56
+ remaining: number;
57
+ resetAt: number;
58
+ }
59
+ declare function rateLimitIncr(redis: RateLimitRedis, input: RateLimitInput): Promise<RateLimitResult>;
60
+
61
+ interface ClampLimitOptions {
62
+ defaultLimit?: number;
63
+ maxLimit?: number;
64
+ minLimit?: number;
65
+ }
66
+ declare const DEFAULT_GRAPHQL_PAGE_LIMIT = 50;
67
+ declare const MAX_GRAPHQL_PAGE_LIMIT = 100;
68
+ declare function clampLimit(input: number | undefined | null, opts?: ClampLimitOptions): number;
69
+ declare function clampOffset(input: number | undefined | null): number;
70
+ declare function clampGraphqlLimit(input: number | undefined | null, opts?: ClampLimitOptions): number;
71
+ interface OffsetPaginationInput {
72
+ limit?: number | null;
73
+ offset?: number | null;
74
+ }
75
+ interface NormalizedOffsetPagination {
76
+ limit: number;
77
+ offset: number;
78
+ }
79
+ declare function normalizeOffsetPagination(input: OffsetPaginationInput | null | undefined, opts?: ClampLimitOptions): NormalizedOffsetPagination;
80
+ interface CursorPaginationInput {
81
+ first?: number | null;
82
+ after?: string | null;
83
+ }
84
+ interface NormalizedCursorPagination {
85
+ first: number;
86
+ after: string | null;
87
+ take: number;
88
+ }
89
+ declare function normalizeCursorPagination(input: CursorPaginationInput | null | undefined, opts?: ClampLimitOptions): NormalizedCursorPagination;
90
+ type CursorPayloadValue = string | number | boolean | null;
91
+ type CursorPayload = Record<string, CursorPayloadValue>;
92
+ declare function encodeCursor(payload: CursorPayload): string;
93
+ declare function decodeCursor(cursor: string | null | undefined): CursorPayload | null;
94
+ interface PageInfo {
95
+ hasNextPage: boolean;
96
+ hasPreviousPage: boolean;
97
+ startCursor: string | null;
98
+ endCursor: string | null;
99
+ }
100
+ interface ConnectionEdge<TItem> {
101
+ node: TItem;
102
+ cursor: string;
103
+ }
104
+ interface ConnectionResult<TItem> {
105
+ edges: ConnectionEdge<TItem>[];
106
+ nodes: TItem[];
107
+ pageInfo: PageInfo;
108
+ totalCount?: number | null;
109
+ }
110
+ interface BuildConnectionOptions<TItem> {
111
+ limit: number;
112
+ cursorForNode: (item: TItem) => string;
113
+ hasPreviousPage?: boolean;
114
+ totalCount?: number | null;
115
+ }
116
+ declare function buildConnection<TItem>(items: TItem[], opts: BuildConnectionOptions<TItem>): ConnectionResult<TItem>;
117
+ interface OffsetPageResult<TItem> {
118
+ items: TItem[];
119
+ total: number;
120
+ limit: number;
121
+ offset: number;
122
+ hasMore: boolean;
123
+ nextOffset: number | null;
124
+ }
125
+ declare function buildOffsetPage<TItem>(items: TItem[], total: number, pagination: NormalizedOffsetPagination): OffsetPageResult<TItem>;
126
+ interface PaginateInput<TWhere, TOrderBy> {
127
+ take?: number | null;
128
+ cursor?: string | null;
129
+ where?: TWhere;
130
+ orderBy?: TOrderBy;
131
+ }
132
+ interface PaginateResult<TItem> {
133
+ items: TItem[];
134
+ hasMore: boolean;
135
+ nextCursor: string | null;
136
+ }
137
+ interface PrismaModelLike<TItem, TWhere, TOrderBy> {
138
+ findMany(args: {
139
+ take?: number;
140
+ skip?: number;
141
+ cursor?: {
142
+ id: string;
143
+ };
144
+ where?: TWhere;
145
+ orderBy?: TOrderBy;
146
+ }): Promise<TItem[]>;
147
+ }
148
+ declare function paginate<TItem extends {
149
+ id: string;
150
+ }, TWhere = unknown, TOrderBy = unknown>(model: PrismaModelLike<TItem, TWhere, TOrderBy>, input: PaginateInput<TWhere, TOrderBy>, opts?: ClampLimitOptions): Promise<PaginateResult<TItem>>;
151
+
152
+ interface DataLoaderLike<K, V> {
153
+ load(key: K): Promise<V>;
154
+ loadMany(keys: readonly K[]): Promise<(V | Error)[]>;
155
+ clear(key: K): this;
156
+ clearAll(): this;
157
+ prime(key: K, value: V): this;
158
+ }
159
+ type LoaderMap = Record<string, DataLoaderLike<unknown, unknown>>;
160
+ type LoaderBuilder<Ctx, M extends LoaderMap> = (ctx: Ctx) => M;
161
+ declare function buildLoaders<Ctx, M extends LoaderMap>(ctx: Ctx, builder: LoaderBuilder<Ctx, M>): M;
162
+ interface ReferenceObject {
163
+ id?: string;
164
+ [key: string]: unknown;
165
+ }
166
+ declare function resolveReferenceLoader<T, Ctx extends {
167
+ loaders: LoaderMap;
168
+ }>(loaderName: string, keyField?: string): (reference: ReferenceObject, ctx: Ctx) => Promise<T | null>;
169
+
170
+ interface CacheVersionRedis {
171
+ get(key: string): Promise<string | null>;
172
+ incr(key: string): Promise<number>;
173
+ }
174
+ declare function getNamespaceVersion(redis: CacheVersionRedis, namespace: string): Promise<number>;
175
+ declare function buildCacheKey(redis: CacheVersionRedis, namespace: string, ...parts: string[]): Promise<string>;
176
+ declare function invalidateNamespace(redis: CacheVersionRedis, namespace: string): Promise<number>;
177
+
178
+ interface PrismaRawClient {
179
+ $executeRawUnsafe(query: string, ...values: unknown[]): Promise<unknown>;
180
+ $queryRawUnsafe<T = unknown>(query: string, ...values: unknown[]): Promise<T>;
181
+ }
182
+ declare function monthlyPartitionName(table: string, year: number, month: number): string;
183
+ interface EnsureMonthlyOptions {
184
+ table: string;
185
+ from: Date;
186
+ to: Date;
187
+ }
188
+ declare function ensureMonthlyPartitions(prisma: PrismaRawClient, opts: EnsureMonthlyOptions): Promise<string[]>;
189
+ interface DropOldOptions {
190
+ table: string;
191
+ beforeDate: Date;
192
+ }
193
+ declare function dropOldPartitions(prisma: PrismaRawClient, opts: DropOldOptions): Promise<string[]>;
194
+
195
+ interface LLMRequest {
196
+ model?: string;
197
+ messages: Array<{
198
+ role: 'system' | 'user' | 'assistant';
199
+ content: string;
200
+ }>;
201
+ maxTokens?: number;
202
+ temperature?: number;
203
+ stream?: boolean;
204
+ timeoutMs?: number;
205
+ }
206
+ interface LLMResponse {
207
+ provider: string;
208
+ content: string;
209
+ inputTokens?: number;
210
+ outputTokens?: number;
211
+ raw?: unknown;
212
+ }
213
+ interface LLMProviderAdapter {
214
+ name: string;
215
+ complete(req: LLMRequest, signal: AbortSignal): Promise<LLMResponse>;
216
+ }
217
+ interface LLMRouterOptions {
218
+ timeoutMs?: number;
219
+ maxAttempts?: number;
220
+ initialDelayMs?: number;
221
+ maxOutputTokensCap?: number;
222
+ }
223
+ declare class LLMRouter {
224
+ private readonly adapters;
225
+ private readonly opts;
226
+ constructor(opts?: LLMRouterOptions);
227
+ register(adapter: LLMProviderAdapter): void;
228
+ private resolveChain;
229
+ complete(req: LLMRequest): Promise<LLMResponse>;
230
+ }
231
+
232
+ type index_BreakerConfig = BreakerConfig;
233
+ type index_BuildConnectionOptions<TItem> = BuildConnectionOptions<TItem>;
234
+ type index_CacheVersionRedis = CacheVersionRedis;
235
+ type index_CircuitBreakerOpenError = CircuitBreakerOpenError;
236
+ declare const index_CircuitBreakerOpenError: typeof CircuitBreakerOpenError;
237
+ type index_ClampLimitOptions = ClampLimitOptions;
238
+ type index_ConnectionEdge<TItem> = ConnectionEdge<TItem>;
239
+ type index_ConnectionResult<TItem> = ConnectionResult<TItem>;
240
+ type index_CursorPaginationInput = CursorPaginationInput;
241
+ type index_CursorPayload = CursorPayload;
242
+ type index_CursorPayloadValue = CursorPayloadValue;
243
+ declare const index_DEFAULT_GRAPHQL_PAGE_LIMIT: typeof DEFAULT_GRAPHQL_PAGE_LIMIT;
244
+ type index_DataLoaderLike<K, V> = DataLoaderLike<K, V>;
245
+ type index_DropOldOptions = DropOldOptions;
246
+ type index_EnsureMonthlyOptions = EnsureMonthlyOptions;
247
+ type index_HttpClientConfig = HttpClientConfig;
248
+ type index_HttpClientInit = HttpClientInit;
249
+ type index_LLMProviderAdapter = LLMProviderAdapter;
250
+ type index_LLMRequest = LLMRequest;
251
+ type index_LLMResponse = LLMResponse;
252
+ type index_LLMRouter = LLMRouter;
253
+ declare const index_LLMRouter: typeof LLMRouter;
254
+ type index_LLMRouterOptions = LLMRouterOptions;
255
+ type index_LeaderLockOptions = LeaderLockOptions;
256
+ type index_LeaderLockRedis = LeaderLockRedis;
257
+ type index_LeaderLockResult<T> = LeaderLockResult<T>;
258
+ type index_LoaderBuilder<Ctx, M extends LoaderMap> = LoaderBuilder<Ctx, M>;
259
+ type index_LoaderMap = LoaderMap;
260
+ declare const index_MAX_GRAPHQL_PAGE_LIMIT: typeof MAX_GRAPHQL_PAGE_LIMIT;
261
+ type index_NormalizedCursorPagination = NormalizedCursorPagination;
262
+ type index_NormalizedOffsetPagination = NormalizedOffsetPagination;
263
+ type index_OffsetPageResult<TItem> = OffsetPageResult<TItem>;
264
+ type index_OffsetPaginationInput = OffsetPaginationInput;
265
+ type index_PageInfo = PageInfo;
266
+ type index_PaginateInput<TWhere, TOrderBy> = PaginateInput<TWhere, TOrderBy>;
267
+ type index_PaginateResult<TItem> = PaginateResult<TItem>;
268
+ type index_PrismaModelLike<TItem, TWhere, TOrderBy> = PrismaModelLike<TItem, TWhere, TOrderBy>;
269
+ type index_PrismaRawClient = PrismaRawClient;
270
+ type index_RateLimitInput = RateLimitInput;
271
+ type index_RateLimitRedis = RateLimitRedis;
272
+ type index_RateLimitResult = RateLimitResult;
273
+ type index_ReferenceObject = ReferenceObject;
274
+ type index_RetryConfig = RetryConfig;
275
+ declare const index___resetHttpClientBreakers: typeof __resetHttpClientBreakers;
276
+ declare const index_buildCacheKey: typeof buildCacheKey;
277
+ declare const index_buildConnection: typeof buildConnection;
278
+ declare const index_buildLoaders: typeof buildLoaders;
279
+ declare const index_buildOffsetPage: typeof buildOffsetPage;
280
+ declare const index_clampGraphqlLimit: typeof clampGraphqlLimit;
281
+ declare const index_clampLimit: typeof clampLimit;
282
+ declare const index_clampOffset: typeof clampOffset;
283
+ declare const index_createHttpClient: typeof createHttpClient;
284
+ declare const index_decodeCursor: typeof decodeCursor;
285
+ declare const index_dropOldPartitions: typeof dropOldPartitions;
286
+ declare const index_encodeCursor: typeof encodeCursor;
287
+ declare const index_ensureMonthlyPartitions: typeof ensureMonthlyPartitions;
288
+ declare const index_getNamespaceVersion: typeof getNamespaceVersion;
289
+ declare const index_httpClient: typeof httpClient;
290
+ declare const index_invalidateNamespace: typeof invalidateNamespace;
291
+ declare const index_monthlyPartitionName: typeof monthlyPartitionName;
292
+ declare const index_normalizeCursorPagination: typeof normalizeCursorPagination;
293
+ declare const index_normalizeOffsetPagination: typeof normalizeOffsetPagination;
294
+ declare const index_paginate: typeof paginate;
295
+ declare const index_rateLimitIncr: typeof rateLimitIncr;
296
+ declare const index_resolveReferenceLoader: typeof resolveReferenceLoader;
297
+ declare const index_withLeaderLock: typeof withLeaderLock;
298
+ declare namespace index {
299
+ 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_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_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_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_paginate as paginate, index_rateLimitIncr as rateLimitIncr, index_resolveReferenceLoader as resolveReferenceLoader, index_withLeaderLock as withLeaderLock };
300
+ }
301
+
302
+ export { encodeCursor as $, type PrismaRawClient as A, type BreakerConfig as B, type CacheVersionRedis as C, DEFAULT_GRAPHQL_PAGE_LIMIT as D, type EnsureMonthlyOptions as E, type RateLimitRedis as F, type RateLimitResult as G, type HttpClientConfig as H, type ReferenceObject as I, type RetryConfig as J, buildCacheKey as K, type LLMProviderAdapter as L, MAX_GRAPHQL_PAGE_LIMIT as M, type NormalizedCursorPagination as N, type OffsetPageResult as O, type PageInfo as P, buildConnection as Q, type RateLimitInput as R, buildLoaders as S, buildOffsetPage as T, clampGraphqlLimit as U, clampLimit as V, clampOffset as W, createHttpClient as X, decodeCursor as Y, dropOldPartitions as Z, __resetHttpClientBreakers as _, type BuildConnectionOptions as a, ensureMonthlyPartitions as a0, getNamespaceVersion as a1, httpClient as a2, invalidateNamespace as a3, monthlyPartitionName as a4, normalizeCursorPagination as a5, normalizeOffsetPagination as a6, paginate as a7, rateLimitIncr as a8, resolveReferenceLoader as a9, withLeaderLock as aa, CircuitBreakerOpenError as b, type ClampLimitOptions as c, type ConnectionEdge as d, type ConnectionResult as e, type CursorPaginationInput as f, type CursorPayload as g, type CursorPayloadValue as h, index as i, type DataLoaderLike as j, type DropOldOptions as k, type HttpClientInit as l, type LLMRequest as m, type LLMResponse as n, LLMRouter as o, type LLMRouterOptions as p, type LeaderLockOptions as q, type LeaderLockRedis as r, type LeaderLockResult as s, type LoaderBuilder as t, type LoaderMap as u, type NormalizedOffsetPagination as v, type OffsetPaginationInput as w, type PaginateInput as x, type PaginateResult as y, type PrismaModelLike as z };
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export { i as Crypto } from './index-e_18DzAg.js';
35
35
  export { i as Gateway } from './index-Bm6MYdqS.js';
36
36
  export { i as FeatureFlags } from './index-BdPnlJ8_.js';
37
37
  export { i as Captcha, R as RecaptchaVerifyOptions, a as RecaptchaVerifyResult, b as isCaptchaEnabled, v as verifyCaptcha, c as verifyCaptchaIfEnabled } from './index-B70b5mYS.js';
38
- export { i as Platform } from './index-BQ1yJn1K.js';
38
+ export { i as Platform } from './index-DgWLSDv2.js';
39
39
  export { C as CircuitBreakerConfig, h as DEFAULT_CIRCUIT_BREAKER_CONFIG, i as DEFAULT_GATEWAY_RETRY_CONFIG, D as DEFAULT_GATEWAY_ROUTING, b as DEFAULT_LAYER_RESOURCES, c as DEFAULT_LAYER_STREAMS, f as GatewayRequestHeaders, g as GatewayRetryConfig, G as GatewayRoutingConfig, L as LayerConfig, a as LayerFullConfig, d as LayerGatewayConfig, e as LayerResourceUrls, S as ServiceLayer } from './layer-GNAVXBMf.js';
40
40
  import './types-sKXodL2N.js';
41
41
  import 'graphql';
package/dist/index.js CHANGED
@@ -13,42 +13,42 @@ export { middleware_exports as Middleware } from './chunk-2HANKZZM.js';
13
13
  import { TenantNotificationsModule, NotificationsModule } from './chunk-IUL5TEKE.js';
14
14
  export { tenant_notifications_exports as Notifications, NotificationsModule } from './chunk-IUL5TEKE.js';
15
15
  export { observability_exports as Observability } from './chunk-5LXDPGDH.js';
16
- export { platform_exports as Platform } from './chunk-PHKK7725.js';
17
- export { export_exports as Export } from './chunk-WD2TUTAS.js';
16
+ export { platform_exports as Platform } from './chunk-UCLDHOZC.js';
17
+ import { DatabaseModule } from './chunk-4OQRBSHM.js';
18
+ export { DatabaseModule } from './chunk-4OQRBSHM.js';
19
+ export { export_exports as Export } from './chunk-UJI2S556.js';
18
20
  export { feature_flags_exports as FeatureFlags } from './chunk-YEA4BZOL.js';
19
- import { GraphModule } from './chunk-Z2423JIB.js';
20
- export { graph_exports as Graph, GraphModule } from './chunk-Z2423JIB.js';
21
- import './chunk-5CESUKWC.js';
22
- import { EventsModule } from './chunk-H3AXO5SY.js';
23
- export { event_queue_exports as EventQueue, EventsModule } from './chunk-H3AXO5SY.js';
24
- import './chunk-OHEPNJ2X.js';
25
- import { QueueType, EventQueueFactory } from './chunk-MQCVQCFA.js';
26
21
  export { graphql_exports as GraphQL } from './chunk-X4NELQLV.js';
27
22
  import './chunk-QLVKMWFA.js';
28
- import './chunk-MHNA7IS7.js';
23
+ import { GraphModule } from './chunk-DZK5UGDA.js';
24
+ export { graph_exports as Graph, GraphModule } from './chunk-DZK5UGDA.js';
25
+ import './chunk-5CESUKWC.js';
29
26
  export { i18n_exports as I18n, createTranslator, getLanguage, getLocale, hasI18n, t } from './chunk-ULFFX3YE.js';
30
- export { init_exports as Init } from './chunk-Y7GCABRS.js';
31
- import { GatewayClient, GatewayError, GatewayErrorType } from './chunk-3H4TRD6E.js';
32
- export { gateway_exports as Gateway } from './chunk-3H4TRD6E.js';
33
- import './chunk-L2P4CJUR.js';
27
+ export { init_exports as Init } from './chunk-F5BPKP75.js';
28
+ import { GatewayClient, GatewayError, GatewayErrorType } from './chunk-OWUVYM2S.js';
29
+ export { gateway_exports as Gateway } from './chunk-OWUVYM2S.js';
30
+ import './chunk-B527JLOB.js';
34
31
  export { layer_exports as Layer } from './chunk-UIMPJNWC.js';
35
32
  import './chunk-VFCMR5GX.js';
36
33
  import { ContextManager } from './chunk-DXX6C6X6.js';
37
34
  export { ContextManager } from './chunk-DXX6C6X6.js';
38
- import { AuthModule } from './chunk-SS4XWRYR.js';
39
- export { AuthModule } from './chunk-SS4XWRYR.js';
40
- export { utils_exports as Utils } from './chunk-B7I4TABG.js';
41
35
  export { cache_exports as Cache } from './chunk-UYE4IEPT.js';
42
36
  export { captcha_exports as Captcha, isCaptchaEnabled, verifyCaptcha, verifyCaptchaIfEnabled } from './chunk-YMZEUTD2.js';
43
37
  export { createInternalClient, createInternalClientForTenant, createInternalClientForWorkspaces } from './chunk-VI4VSNTI.js';
44
- export { crypto_exports as Crypto } from './chunk-SBS4S2PJ.js';
45
- import { DatabaseModule } from './chunk-4OQRBSHM.js';
46
- export { DatabaseModule } from './chunk-4OQRBSHM.js';
38
+ import { AuthModule } from './chunk-SS4XWRYR.js';
39
+ export { AuthModule } from './chunk-SS4XWRYR.js';
40
+ export { utils_exports as Utils } from './chunk-B7I4TABG.js';
47
41
  import { APIError, NetworkError, TimeoutError, ValidationError } from './chunk-EZ4PKRUK.js';
48
42
  export { DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_GATEWAY_RETRY_CONFIG, DEFAULT_GATEWAY_ROUTING, DEFAULT_LAYER_RESOURCES, DEFAULT_LAYER_STREAMS } from './chunk-YFOHAHZE.js';
43
+ export { dataloader_exports as DataLoader } from './chunk-NUB5GQTU.js';
44
+ import { EventsModule } from './chunk-H3AXO5SY.js';
45
+ export { event_queue_exports as EventQueue, EventsModule } from './chunk-H3AXO5SY.js';
46
+ import './chunk-OHEPNJ2X.js';
47
+ import { QueueType, EventQueueFactory } from './chunk-MQCVQCFA.js';
48
+ import './chunk-MHNA7IS7.js';
49
49
  import { logger } from './chunk-CBZNP6RF.js';
50
50
  export { logger_exports as Logger } from './chunk-CBZNP6RF.js';
51
- export { dataloader_exports as DataLoader } from './chunk-NUB5GQTU.js';
51
+ export { crypto_exports as Crypto } from './chunk-SBS4S2PJ.js';
52
52
  import { __name } from './chunk-XE4OXN2W.js';
53
53
  import { GraphQLClient } from 'graphql-request';
54
54
 
@@ -1,6 +1,6 @@
1
- export { getSDKState, initializeBurdenoffSDK, isSDKInitialized, resetSDK } from '../chunk-Y7GCABRS.js';
2
- import '../chunk-3H4TRD6E.js';
3
- import '../chunk-L2P4CJUR.js';
1
+ export { getSDKState, initializeBurdenoffSDK, isSDKInitialized, resetSDK } from '../chunk-F5BPKP75.js';
2
+ import '../chunk-OWUVYM2S.js';
3
+ import '../chunk-B527JLOB.js';
4
4
  import '../chunk-UIMPJNWC.js';
5
5
  import '../chunk-VFCMR5GX.js';
6
6
  import '../chunk-DXX6C6X6.js';
@@ -1 +1 @@
1
- export { B as BreakerConfig, C as CacheVersionRedis, a as CircuitBreakerOpenError, b as ClampLimitOptions, D as DataLoaderLike, c as DropOldOptions, E as EnsureMonthlyOptions, H as HttpClientConfig, d as HttpClientInit, L as LLMProviderAdapter, e as LLMRequest, f as LLMResponse, g as LLMRouter, h as LLMRouterOptions, j as LeaderLockOptions, k as LeaderLockRedis, l as LeaderLockResult, m as LoaderBuilder, n as LoaderMap, P as PaginateInput, o as PaginateResult, p as PrismaModelLike, q as PrismaRawClient, R as RateLimitInput, r as RateLimitRedis, s as RateLimitResult, t as ReferenceObject, u as RetryConfig, _ as __resetHttpClientBreakers, v as buildCacheKey, w as buildLoaders, x as clampLimit, y as createHttpClient, z as dropOldPartitions, A as ensureMonthlyPartitions, F as getNamespaceVersion, G as httpClient, I as invalidateNamespace, J as monthlyPartitionName, K as paginate, M as rateLimitIncr, N as resolveReferenceLoader, O as withLeaderLock } from '../index-BQ1yJn1K.js';
1
+ export { B as BreakerConfig, a as BuildConnectionOptions, C as CacheVersionRedis, b as CircuitBreakerOpenError, c as ClampLimitOptions, d as ConnectionEdge, e as ConnectionResult, f as CursorPaginationInput, g as CursorPayload, h as CursorPayloadValue, D as DEFAULT_GRAPHQL_PAGE_LIMIT, j as DataLoaderLike, k as DropOldOptions, E as EnsureMonthlyOptions, H as HttpClientConfig, l as HttpClientInit, L as LLMProviderAdapter, m as LLMRequest, n as LLMResponse, o as LLMRouter, p as LLMRouterOptions, q as LeaderLockOptions, r as LeaderLockRedis, s as LeaderLockResult, t as LoaderBuilder, u as LoaderMap, M as MAX_GRAPHQL_PAGE_LIMIT, N as NormalizedCursorPagination, v as NormalizedOffsetPagination, O as OffsetPageResult, w as OffsetPaginationInput, P as PageInfo, x as PaginateInput, y as PaginateResult, z as PrismaModelLike, A as PrismaRawClient, R as RateLimitInput, F as RateLimitRedis, G as RateLimitResult, I as ReferenceObject, J as RetryConfig, _ as __resetHttpClientBreakers, K as buildCacheKey, Q as buildConnection, S as buildLoaders, T as buildOffsetPage, U as clampGraphqlLimit, V as clampLimit, W as clampOffset, X as createHttpClient, Y as decodeCursor, Z as dropOldPartitions, $ as encodeCursor, a0 as ensureMonthlyPartitions, a1 as getNamespaceVersion, a2 as httpClient, a3 as invalidateNamespace, a4 as monthlyPartitionName, a5 as normalizeCursorPagination, a6 as normalizeOffsetPagination, a7 as paginate, a8 as rateLimitIncr, a9 as resolveReferenceLoader, aa as withLeaderLock } from '../index-DgWLSDv2.js';
@@ -1,4 +1,4 @@
1
- export { CircuitBreakerOpenError, LLMRouter, __resetHttpClientBreakers, buildCacheKey, buildLoaders, clampLimit, createHttpClient, dropOldPartitions, ensureMonthlyPartitions, getNamespaceVersion, httpClient, invalidateNamespace, monthlyPartitionName, paginate, rateLimitIncr, resolveReferenceLoader, withLeaderLock } from '../chunk-PHKK7725.js';
1
+ export { CircuitBreakerOpenError, DEFAULT_GRAPHQL_PAGE_LIMIT, LLMRouter, MAX_GRAPHQL_PAGE_LIMIT, __resetHttpClientBreakers, buildCacheKey, buildConnection, buildLoaders, buildOffsetPage, clampGraphqlLimit, clampLimit, clampOffset, createHttpClient, decodeCursor, dropOldPartitions, encodeCursor, ensureMonthlyPartitions, getNamespaceVersion, httpClient, invalidateNamespace, monthlyPartitionName, normalizeCursorPagination, normalizeOffsetPagination, paginate, rateLimitIncr, resolveReferenceLoader, withLeaderLock } from '../chunk-UCLDHOZC.js';
2
2
  import '../chunk-CBZNP6RF.js';
3
3
  import '../chunk-XE4OXN2W.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/telemetry/health.ts","../../src/telemetry/metrics-endpoint.ts","../../src/telemetry/prisma-logging.ts","../../src/telemetry/index.ts"],"names":["createHealthRoutes","_deps","Proxy","get","_target","prop","undefined","loadDefaultRegistry","mod","collectDefaultMetrics","register","createMetricsRoutesImpl","app","opts","path","ctx","registry","ctxWithSet","set","status","headers","contentType","metrics","createMetricsRoutes","createPrismaLoggingExtension","logger","name","query","$allOperations","model","operation","args","start","Date","now","result","debug","duration_ms","redactSensitiveFields","err","error","Error","message","String","resolveEnv","explicit","fromEnv","process","env","resolveVersion","resolveEndpoint","proto","resolveSampling","Number","isFinite","Math","min","max","parsed","resolveOtelSdkEnabled","sdkDisabled","otelEnabled","bootstrapTelemetry","cfg","serviceVersion","otlpEndpoint","sampleRatio","createPinoLogger","serviceName","version","setActiveTelemetryLogger","instrumentation","setupInstrumentation","tracing","samplingRate","otelSdk","createOtelSdk","boundary","module","info","metricsEnabled","metricsDropReason","warn","reason","shutdown","defaultLogger","setLevel","getLevel"],"mappings":";;;;;;;;AAmFO,SAASA,kBAAAA,CAAmBC,KAAAA,GAAoB,EAAC,EAAC;AAEvD,EAAA,OAAO,IAAIC,KAAAA,CACT,EAAC,EACD;AACEC,IAAAA,GAAAA,CAAIC,SAASC,IAAAA,EAAI;AAIf,MAAA,IAAIA,IAAAA,KAAS,KAAA,IAASA,IAAAA,KAAS,MAAA,EAAQ,OAAOC,MAAAA;AAC9C,MAAA,OAAOA,MAAAA;AACT,IAAA;GACF,CAAA;AAEJ;AAdgBN,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA;;;AC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QAAAA,IAAQ,IAAQ,MAAA,CAAA;AAE9C,EAAA,OAAO;AACLnB,IAAAA,WAAAA,EAAaL,GAAAA,CAAIK,WAAAA;AACjBJ,IAAAA,cAAAA;AACAhB,IAAAA,GAAAA;IACAvB,MAAAA,EAAQA,OAAAA;AACR8C,IAAAA,eAAAA;AACAa,IAAAA;AACF,GAAA;AACF;AA7FsBtB,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA","file":"index.js","sourcesContent":["/**\n * `/health`, `/health/live`, `/health/ready` Elysia routes with a 1s\n * result cache so readiness checks can't stampede Postgres.\n *\n * Dependencies (prisma, eventQueue, valkey) are optional — omit any client and\n * the readiness check simply skips it.\n */\n\ninterface PrismaLike {\n $queryRaw: (strings: TemplateStringsArray) => Promise<unknown>;\n}\ninterface EventQueueLike {\n isConnected?: () => boolean | Promise<boolean>;\n healthCheck?: () => Promise<{ ok: boolean }>;\n}\ninterface ValkeyLike {\n ping: () => Promise<unknown>;\n}\n\nexport interface HealthDeps {\n prisma?: PrismaLike;\n eventQueue?: EventQueueLike;\n valkey?: ValkeyLike;\n /** Service version reported on /health. */\n version?: string;\n /** Service name reported on /health. */\n serviceName?: string;\n}\n\ninterface CachedStatus {\n ready: boolean;\n checked: Record<string, { ok: boolean; error?: string }>;\n at: number;\n}\n\nconst CACHE_TTL_MS = 1000;\n\nasync function probeReady(deps: HealthDeps): Promise<CachedStatus> {\n const checked: Record<string, { ok: boolean; error?: string }> = {};\n\n if (deps.prisma) {\n try {\n await deps.prisma.$queryRaw`SELECT 1`;\n checked['postgres'] = { ok: true };\n } catch (err) {\n checked['postgres'] = {\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (deps.eventQueue) {\n try {\n const connected =\n typeof deps.eventQueue.isConnected === 'function'\n ? await Promise.resolve(deps.eventQueue.isConnected())\n : ((await deps.eventQueue.healthCheck?.())?.ok ?? true);\n checked['eventQueue'] = { ok: Boolean(connected) };\n } catch (err) {\n checked['eventQueue'] = {\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (deps.valkey) {\n try {\n await deps.valkey.ping();\n checked['valkey'] = { ok: true };\n } catch (err) {\n checked['valkey'] = {\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n const ready = Object.values(checked).every((c) => c.ok);\n return { ready, checked, at: Date.now() };\n}\n\nexport function createHealthRoutes(_deps: HealthDeps = {}): unknown {\n // Return an Elysia app lazily so be-sdk doesn't hard-require elysia.\n return new Proxy(\n {},\n {\n get(_target, prop): unknown {\n // Tell TypeScript consumers the returned object is an Elysia plugin;\n // the actual mount happens via `createHealthRoutesImpl`. Services\n // that prefer direct use can call `createHealthRoutesImpl(elysia, deps)`.\n if (prop === 'use' || prop === 'then') return undefined;\n return undefined;\n },\n }\n );\n}\n\n/**\n * Mount health routes on an existing Elysia app. Callers hold a reference\n * to Elysia themselves; be-sdk stays decoupled.\n */\nexport function createHealthRoutesImpl<\n App extends {\n get: (path: string, handler: (ctx: unknown) => unknown) => App;\n },\n>(app: App, deps: HealthDeps = {}): App {\n let cache: CachedStatus | null = null;\n\n const getStatus = async (): Promise<CachedStatus> => {\n if (cache && Date.now() - cache.at < CACHE_TTL_MS) return cache;\n cache = await probeReady(deps);\n return cache;\n };\n\n app.get('/health/live', () => ({\n status: 'ok',\n serviceName: deps.serviceName,\n version: deps.version,\n }));\n\n app.get('/health/ready', async (ctx: unknown): Promise<unknown> => {\n const status = await getStatus();\n const ctxWithSet = ctx as { set?: { status?: number } };\n if (!status.ready && ctxWithSet.set) ctxWithSet.set.status = 503;\n return {\n status: status.ready ? 'ok' : 'degraded',\n serviceName: deps.serviceName,\n version: deps.version,\n checks: status.checked,\n };\n });\n\n app.get('/health', async (ctx: unknown): Promise<unknown> => {\n const status = await getStatus();\n const ctxWithSet = ctx as { set?: { status?: number } };\n if (!status.ready && ctxWithSet.set) ctxWithSet.set.status = 503;\n return {\n status: status.ready ? 'ok' : 'degraded',\n serviceName: deps.serviceName,\n version: deps.version,\n checks: status.checked,\n uptime_s: Math.round(process.uptime()),\n };\n });\n\n return app;\n}\n","/**\n * Prometheus `/metrics` route mounter. Uses the shared `prom-client`\n * default registry so all instrumentation (GraphQL Envelop, Prisma,\n * runtime) shows up on a single endpoint.\n */\n\ninterface PromRegistryLike {\n metrics: () => Promise<string> | string;\n contentType?: string;\n}\n\nexport interface MetricsMountOptions {\n registry?: PromRegistryLike;\n path?: string;\n}\n\nexport async function loadDefaultRegistry(): Promise<PromRegistryLike | null> {\n try {\n const mod = (await import('prom-client')) as unknown as {\n register: PromRegistryLike;\n collectDefaultMetrics: (opts?: Record<string, unknown>) => void;\n };\n // Kick runtime metrics into the default registry if not already.\n try {\n mod.collectDefaultMetrics({ register: mod.register });\n } catch {\n // Already registered — ignore duplicate-metric errors.\n }\n return mod.register;\n } catch {\n return null;\n }\n}\n\nexport function createMetricsRoutesImpl<\n App extends {\n get: (path: string, handler: (ctx: unknown) => unknown) => App;\n },\n>(app: App, opts: MetricsMountOptions = {}): App {\n const path = opts.path ?? '/metrics';\n\n app.get(path, async (ctx: unknown): Promise<unknown> => {\n const registry = opts.registry ?? (await loadDefaultRegistry());\n const ctxWithSet = ctx as { set?: { status?: number; headers?: Record<string, string> } };\n if (!registry) {\n if (ctxWithSet.set) ctxWithSet.set.status = 503;\n return '# prom-client not installed\\n';\n }\n if (ctxWithSet.set) {\n ctxWithSet.set.status = 200;\n ctxWithSet.set.headers = {\n 'content-type': registry.contentType ?? 'text/plain; version=0.0.4; charset=utf-8',\n };\n }\n return registry.metrics();\n });\n\n return app;\n}\n\n/**\n * Legacy export name used by the service template. Composes the Elysia\n * plugin-style function that `new Elysia().use(...)` accepts.\n */\nexport function createMetricsRoutes(opts: MetricsMountOptions = {}): unknown {\n return (app: Parameters<typeof createMetricsRoutesImpl>[0]): unknown => createMetricsRoutesImpl(app, opts);\n}\n","/**\n * Prisma client extension that pipes query events through the SDK logger\n * with trace/span correlation fields auto-injected. The\n * `@prisma/instrumentation` peer provides the spans\n * themselves; this extension only adds structured log events on top.\n */\nimport type { Logger } from '../logger/index.js';\nimport { redactSensitiveFields } from '../logger/index.js';\n\ntype PrismaQueryArgs = {\n model?: string;\n operation: string;\n args: unknown;\n query: (args: unknown) => Promise<unknown>;\n};\n\n/**\n * Returns a Prisma Client extension object compatible with the\n * `$extends()` API (Prisma v5+).\n *\n * ```ts\n * export const prisma = new PrismaClient().$extends(\n * createPrismaLoggingExtension(logger)\n * );\n * ```\n */\nexport function createPrismaLoggingExtension(logger: Logger): {\n name: string;\n query: {\n $allOperations: (args: PrismaQueryArgs) => Promise<unknown>;\n };\n} {\n return {\n name: 'burdenoff-pino-logging',\n query: {\n async $allOperations({ model, operation, args, query }: PrismaQueryArgs): Promise<unknown> {\n const start = Date.now();\n try {\n const result = await query(args);\n logger.debug('prisma.query', {\n model,\n operation,\n duration_ms: Date.now() - start,\n args: redactSensitiveFields(args),\n });\n return result;\n } catch (err) {\n logger.error('prisma.error', {\n model,\n operation,\n duration_ms: Date.now() - start,\n error: err instanceof Error ? err.message : String(err),\n });\n throw err;\n }\n },\n },\n };\n}\n","/**\n * Unified telemetry bootstrap for Burdenoff services.\n *\n * Composes the existing `instrumentation/` + `observability/` + `logger/`\n * modules and adds:\n * - `bootstrapTelemetry({ serviceName, boundary, module, env })` — single\n * call that initializes OTel, wires Pino logger with trace fields,\n * exposes GraphQL Yoga plugins, registers process exit hooks.\n * - `createHealthRoutes({ prisma, nats, valkey, version })` — `/health`,\n * `/health/live`, `/health/ready` Elysia routes.\n * - `createMetricsRoutes(registry?)` — `/metrics` Prometheus exposition.\n * - `createPrismaLoggingExtension(logger)` — Prisma extension that pipes\n * query events through Pino with trace/span correlation ids.\n *\n * The module does not pull in `@opentelemetry/sdk-node` or `pino` as direct\n * deps — services install those as optional peers, and imports are lazy so\n * services that don't install them still load.\n */\n\nimport type { Logger as BaseLogger } from '../logger/index.js';\nimport { logger as defaultLogger } from '../logger/index.js';\nimport {\n initializeInstrumentation,\n setupInstrumentation,\n type SetupInstrumentationOptions,\n type InstrumentationSetupResult,\n} from '../instrumentation/index.js';\nimport { setActiveTelemetryLogger } from './logger-state.js';\nimport type { OtelSdkHandle } from './sdk.js';\n\nexport { createHealthRoutes } from './health.js';\nexport { createMetricsRoutes } from './metrics-endpoint.js';\nexport { createPrismaLoggingExtension } from './prisma-logging.js';\nexport { DEFAULT_REDACT_PATHS } from './pino-redaction.js';\nexport { createPinoLogger } from './pino-logger.js';\n\nexport type Boundary = 'wspace' | 'global' | 'gateway';\nexport type Env = 'alpha' | 'prod' | 'dev';\n\nexport interface TelemetryConfig {\n /** Full service name, e.g. \"wspace-auth-svc\". */\n serviceName: string;\n /** Semver of the service deployment; defaults to `process.env.npm_package_version`. */\n serviceVersion?: string;\n /** Monorepo boundary: `wspace`, `global`, or `gateway`. */\n boundary: Boundary;\n /** Module slug, e.g. `auth` (omit for gateways). */\n module?: string;\n /** Deployment environment; defaults to alpha for non-production NODE_ENV. */\n env?: Env;\n /**\n * OTLP endpoint for spans/metrics/logs. Defaults to\n * `$OTEL_EXPORTER_OTLP_ENDPOINT` or\n * `http://alloy.sre.svc.cluster.local:4318`.\n */\n otlpEndpoint?: string;\n /** Head-based sampling ratio. Default: alpha=1.0, prod=0.1. */\n sampleRatio?: number;\n /** Extra options forwarded to `setupInstrumentation`. */\n instrumentation?: SetupInstrumentationOptions;\n}\n\nexport interface TelemetryHandle {\n /** The configured service name (for use in health routes, etc.). */\n serviceName: string;\n /** The resolved service version. */\n serviceVersion: string;\n /** Environment. */\n env: Env;\n /** The Pino-backed logger. */\n logger: BaseLogger;\n /** Initialized instrumentation (tracer + metrics + plugins). */\n instrumentation: InstrumentationSetupResult;\n /** Cleanup hook; services call on SIGTERM. */\n shutdown: () => Promise<void>;\n}\n\nfunction resolveEnv(explicit?: Env): Env {\n if (explicit) return explicit;\n const fromEnv = process.env['DEPLOY_ENV'] ?? process.env['NODE_ENV'] ?? '';\n if (fromEnv === 'production' || fromEnv === 'prod') return 'prod';\n if (fromEnv === 'development' || fromEnv === 'dev') return 'dev';\n return 'alpha';\n}\n\nfunction resolveVersion(explicit?: string): string {\n if (explicit) return explicit;\n return process.env['npm_package_version'] ?? process.env['SERVICE_VERSION'] ?? '0.0.0';\n}\n\nfunction resolveEndpoint(explicit?: string): string {\n if (explicit) return explicit;\n const proto = 'http';\n return process.env['OTEL_EXPORTER_OTLP_ENDPOINT'] ?? `${proto}://alloy.sre.svc.cluster.local:4318`;\n}\n\nfunction resolveSampling(explicit: number | undefined, env: Env): number {\n if (typeof explicit === 'number' && Number.isFinite(explicit)) return Math.min(1, Math.max(0, explicit));\n const fromEnv = process.env['OTEL_TRACES_SAMPLER_ARG'];\n if (fromEnv) {\n const parsed = Number(fromEnv);\n if (Number.isFinite(parsed)) return Math.min(1, Math.max(0, parsed));\n }\n if (env === 'prod') return 0.1;\n return 1.0;\n}\n\nfunction resolveOtelSdkEnabled(): boolean {\n const sdkDisabled = process.env['OTEL_SDK_DISABLED'];\n if (sdkDisabled === 'true' || sdkDisabled === '1') return false;\n const otelEnabled = process.env['OTEL_ENABLED'];\n if (otelEnabled === 'false' || otelEnabled === '0') return false;\n return true;\n}\n\n/**\n * Bootstrap the full telemetry stack for a service.\n *\n * Services call this ONCE at startup **before** importing Prisma / GraphQL\n * Yoga / NATS so OTel can auto-instrument their dependencies.\n *\n * ```ts\n * // src/telemetry.ts\n * import { bootstrapTelemetry } from '@burdenoff/be-sdk/telemetry';\n * export const telemetry = await bootstrapTelemetry({\n * serviceName: 'wspace-auth-svc',\n * boundary: 'wspace',\n * module: 'auth',\n * });\n *\n * // src/index.ts — must be the FIRST import line.\n * import './telemetry.js';\n * ```\n */\nexport async function bootstrapTelemetry(cfg: TelemetryConfig): Promise<TelemetryHandle> {\n const env = resolveEnv(cfg.env);\n const serviceVersion = resolveVersion(cfg.serviceVersion);\n const otlpEndpoint = resolveEndpoint(cfg.otlpEndpoint);\n const sampleRatio = resolveSampling(cfg.sampleRatio, env);\n\n // Pino logger with trace/span correlation + redaction.\n // createPinoLogger is async (loads pino via dynamic import); awaiting it\n // is required — without await, `logger` is a Promise and calls like\n // logger.warn(...) crash with \"logger.warn is not a function\" during the\n // sdk-node fallback path.\n const { createPinoLogger } = await import('./pino-logger.js');\n const logger = await createPinoLogger({\n serviceName: cfg.serviceName,\n env,\n version: serviceVersion,\n });\n setActiveTelemetryLogger(logger);\n\n // Initialize core instrumentation (tracer, metrics registry, envelop plugins).\n // `setupInstrumentation` internally calls `initializeInstrumentation`.\n const instrumentation = setupInstrumentation(cfg.serviceName, {\n ...cfg.instrumentation,\n tracing: {\n serviceName: cfg.serviceName,\n ...(cfg.instrumentation?.tracing ?? {}),\n samplingRate: sampleRatio,\n },\n metrics: {\n serviceName: cfg.serviceName,\n ...(cfg.instrumentation?.metrics ?? {}),\n },\n });\n\n // Start the NodeSDK exporter pipeline if sdk-node is present (optional).\n let otelSdk: OtelSdkHandle | undefined;\n if (resolveOtelSdkEnabled()) {\n try {\n const { createOtelSdk } = await import('./sdk.js');\n otelSdk = await createOtelSdk({\n serviceName: cfg.serviceName,\n serviceVersion,\n boundary: cfg.boundary,\n module: cfg.module,\n env,\n otlpEndpoint,\n sampleRatio,\n });\n // Explicit success log includes metrics path status so an operator can\n // distinguish traces-only startup from full traces+metrics startup.\n logger.info('[telemetry] OpenTelemetry exporter pipeline started', {\n serviceName: cfg.serviceName,\n otlpEndpoint: otlpEndpoint ? '<configured>' : '<not set>',\n sampleRatio,\n metricsEnabled: otelSdk.metricsEnabled,\n });\n\n if (!otelSdk.metricsEnabled && otelSdk.metricsDropReason) {\n logger.warn('[telemetry] OpenTelemetry metrics reader disabled; continuing with traces only', {\n serviceName: cfg.serviceName,\n reason: otelSdk.metricsDropReason,\n });\n }\n } catch (err) {\n logger.warn('[telemetry] OpenTelemetry exporter pipeline failed to start; continuing with logs only', {\n error: err instanceof Error ? err.message : String(err),\n });\n }\n } else {\n logger.info('[telemetry] OTel SDK exporter disabled by env');\n }\n\n const shutdown = async (): Promise<void> => {\n try {\n if (otelSdk?.shutdown) await otelSdk.shutdown();\n } catch (err) {\n logger.warn('[telemetry] shutdown error (ignored)', {\n error: err instanceof Error ? err.message : String(err),\n });\n }\n };\n\n // Mirror defaultLogger so services that still use the singleton get trace-enriched output.\n defaultLogger.setLevel(logger.getLevel?.() ?? 'info');\n\n return {\n serviceName: cfg.serviceName,\n serviceVersion,\n env,\n logger: logger,\n instrumentation,\n shutdown,\n };\n}\n\n// Re-export what services typically import.\nexport { initializeInstrumentation, setupInstrumentation };\n"]}
1
+ {"version":3,"sources":["../../src/telemetry/health.ts","../../src/telemetry/metrics-endpoint.ts","../../src/telemetry/prisma-logging.ts","../../src/telemetry/index.ts"],"names":["createHealthRoutes","_deps","Proxy","get","_target","prop","undefined","loadDefaultRegistry","mod","collectDefaultMetrics","register","createMetricsRoutesImpl","app","opts","path","ctx","registry","ctxWithSet","set","status","headers","contentType","metrics","createMetricsRoutes","createPrismaLoggingExtension","logger","name","query","$allOperations","model","operation","args","start","Date","now","result","debug","duration_ms","redactSensitiveFields","err","error","Error","message","String","resolveEnv","explicit","fromEnv","process","env","resolveVersion","resolveEndpoint","proto","resolveSampling","Number","isFinite","Math","min","max","parsed","resolveOtelSdkEnabled","sdkDisabled","otelEnabled","bootstrapTelemetry","cfg","serviceVersion","otlpEndpoint","sampleRatio","createPinoLogger","serviceName","version","setActiveTelemetryLogger","instrumentation","setupInstrumentation","tracing","samplingRate","otelSdk","createOtelSdk","boundary","module","info","metricsEnabled","metricsDropReason","warn","reason","shutdown","defaultLogger","setLevel","getLevel"],"mappings":";;;;;;;;AAmFO,SAASA,kBAAAA,CAAmBC,KAAAA,GAAoB,EAAC,EAAC;AAEvD,EAAA,OAAO,IAAIC,KAAAA,CACT,EAAC,EACD;AACEC,IAAAA,GAAAA,CAAIC,SAASC,IAAAA,EAAI;AAIf,MAAA,IAAIA,IAAAA,KAAS,KAAA,IAASA,IAAAA,KAAS,MAAA,EAAQ,OAAO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J,GAAAA;OACrD,CAAA;AACF,IAAA;EACF,CAAA,EARiB,UAAA,CAAA;AAWjB8C,EAAAA,MAAAA,CAAcC,QAAAA,CAAS7D,OAAAA,CAAO8D,QAAAA,IAAQ,IAAQ,MAAA,CAAA;AAE9C,EAAA,OAAO;AACLnB,IAAAA,WAAAA,EAAaL,GAAAA,CAAIK,WAAAA;AACjBJ,IAAAA,cAAAA;AACAhB,IAAAA,GAAAA;IACAvB,MAAAA,EAAQA,OAAAA;AACR8C,IAAAA,eAAAA;AACAa,IAAAA;AACF,GAAA;AACF;AA7FsBtB,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA","file":"index.js","sourcesContent":["/**\n * `/health`, `/health/live`, `/health/ready` Elysia routes with a 1s\n * result cache so readiness checks can't stampede Postgres.\n *\n * Dependencies (prisma, eventQueue, valkey) are optional — omit any client and\n * the readiness check simply skips it.\n */\n\ninterface PrismaLike {\n $queryRaw: (strings: TemplateStringsArray) => Promise<unknown>;\n}\ninterface EventQueueLike {\n isConnected?: () => boolean | Promise<boolean>;\n healthCheck?: () => Promise<{ ok: boolean }>;\n}\ninterface ValkeyLike {\n ping: () => Promise<unknown>;\n}\n\nexport interface HealthDeps {\n prisma?: PrismaLike;\n eventQueue?: EventQueueLike;\n valkey?: ValkeyLike;\n /** Service version reported on /health. */\n version?: string;\n /** Service name reported on /health. */\n serviceName?: string;\n}\n\ninterface CachedStatus {\n ready: boolean;\n checked: Record<string, { ok: boolean; error?: string }>;\n at: number;\n}\n\nconst CACHE_TTL_MS = 1000;\n\nasync function probeReady(deps: HealthDeps): Promise<CachedStatus> {\n const checked: Record<string, { ok: boolean; error?: string }> = {};\n\n if (deps.prisma) {\n try {\n await deps.prisma.$queryRaw`SELECT 1`;\n checked['postgres'] = { ok: true };\n } catch (err) {\n checked['postgres'] = {\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (deps.eventQueue) {\n try {\n const connected =\n typeof deps.eventQueue.isConnected === 'function'\n ? await Promise.resolve(deps.eventQueue.isConnected())\n : ((await deps.eventQueue.healthCheck?.())?.ok ?? true);\n checked['eventQueue'] = { ok: Boolean(connected) };\n } catch (err) {\n checked['eventQueue'] = {\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n if (deps.valkey) {\n try {\n await deps.valkey.ping();\n checked['valkey'] = { ok: true };\n } catch (err) {\n checked['valkey'] = {\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n }\n\n const ready = Object.values(checked).every((c) => c.ok);\n return { ready, checked, at: Date.now() };\n}\n\nexport function createHealthRoutes(_deps: HealthDeps = {}): unknown {\n // Return an Elysia app lazily so be-sdk doesn't hard-require elysia.\n return new Proxy(\n {},\n {\n get(_target, prop): unknown {\n // Tell TypeScript consumers the returned object is an Elysia plugin;\n // the actual mount happens via `createHealthRoutesImpl`. Services\n // that prefer direct use can call `createHealthRoutesImpl(elysia, deps)`.\n if (prop === 'use' || prop === 'then') return undefined;\n return undefined;\n },\n }\n );\n}\n\n/**\n * Mount health routes on an existing Elysia app. Callers hold a reference\n * to Elysia themselves; be-sdk stays decoupled.\n */\nexport function createHealthRoutesImpl<\n App extends {\n get: (path: string, handler: (ctx: unknown) => unknown) => App;\n },\n>(app: App, deps: HealthDeps = {}): App {\n let cache: CachedStatus | null = null;\n\n const getStatus = async (): Promise<CachedStatus> => {\n if (cache && Date.now() - cache.at < CACHE_TTL_MS) return cache;\n cache = await probeReady(deps);\n return cache;\n };\n\n app.get('/health/live', () => ({\n status: 'ok',\n serviceName: deps.serviceName,\n version: deps.version,\n }));\n\n app.get('/health/ready', async (ctx: unknown): Promise<unknown> => {\n const status = await getStatus();\n const ctxWithSet = ctx as { set?: { status?: number } };\n if (!status.ready && ctxWithSet.set) ctxWithSet.set.status = 503;\n return {\n status: status.ready ? 'ok' : 'degraded',\n serviceName: deps.serviceName,\n version: deps.version,\n checks: status.checked,\n };\n });\n\n app.get('/health', async (ctx: unknown): Promise<unknown> => {\n const status = await getStatus();\n const ctxWithSet = ctx as { set?: { status?: number } };\n if (!status.ready && ctxWithSet.set) ctxWithSet.set.status = 503;\n return {\n status: status.ready ? 'ok' : 'degraded',\n serviceName: deps.serviceName,\n version: deps.version,\n checks: status.checked,\n uptime_s: Math.round(process.uptime()),\n };\n });\n\n return app;\n}\n","/**\n * Prometheus `/metrics` route mounter. Uses the shared `prom-client`\n * default registry so all instrumentation (GraphQL Envelop, Prisma,\n * runtime) shows up on a single endpoint.\n */\n\ninterface PromRegistryLike {\n metrics: () => Promise<string> | string;\n contentType?: string;\n}\n\nexport interface MetricsMountOptions {\n registry?: PromRegistryLike;\n path?: string;\n}\n\nexport async function loadDefaultRegistry(): Promise<PromRegistryLike | null> {\n try {\n const mod = (await import('prom-client')) as unknown as {\n register: PromRegistryLike;\n collectDefaultMetrics: (opts?: Record<string, unknown>) => void;\n };\n // Kick runtime metrics into the default registry if not already.\n try {\n mod.collectDefaultMetrics({ register: mod.register });\n } catch {\n // Already registered — ignore duplicate-metric errors.\n }\n return mod.register;\n } catch {\n return null;\n }\n}\n\nexport function createMetricsRoutesImpl<\n App extends {\n get: (path: string, handler: (ctx: unknown) => unknown) => App;\n },\n>(app: App, opts: MetricsMountOptions = {}): App {\n const path = opts.path ?? '/metrics';\n\n app.get(path, async (ctx: unknown): Promise<unknown> => {\n const registry = opts.registry ?? (await loadDefaultRegistry());\n const ctxWithSet = ctx as { set?: { status?: number; headers?: Record<string, string> } };\n if (!registry) {\n if (ctxWithSet.set) ctxWithSet.set.status = 503;\n return '# prom-client not installed\\n';\n }\n if (ctxWithSet.set) {\n ctxWithSet.set.status = 200;\n ctxWithSet.set.headers = {\n 'content-type': registry.contentType ?? 'text/plain; version=0.0.4; charset=utf-8',\n };\n }\n return registry.metrics();\n });\n\n return app;\n}\n\n/**\n * Legacy export name used by the service template. Composes the Elysia\n * plugin-style function that `new Elysia().use(...)` accepts.\n */\nexport function createMetricsRoutes(opts: MetricsMountOptions = {}): unknown {\n return (app: Parameters<typeof createMetricsRoutesImpl>[0]): unknown => createMetricsRoutesImpl(app, opts);\n}\n","/**\n * Prisma client extension that pipes query events through the SDK logger\n * with trace/span correlation fields auto-injected. The\n * `@prisma/instrumentation` peer provides the spans\n * themselves; this extension only adds structured log events on top.\n */\nimport type { Logger } from '../logger/index.js';\nimport { redactSensitiveFields } from '../logger/index.js';\n\ntype PrismaQueryArgs = {\n model?: string;\n operation: string;\n args: unknown;\n query: (args: unknown) => Promise<unknown>;\n};\n\n/**\n * Returns a Prisma Client extension object compatible with the\n * `$extends()` API (Prisma v5+).\n *\n * ```ts\n * export const prisma = new PrismaClient().$extends(\n * createPrismaLoggingExtension(logger)\n * );\n * ```\n */\nexport function createPrismaLoggingExtension(logger: Logger): {\n name: string;\n query: {\n $allOperations: (args: PrismaQueryArgs) => Promise<unknown>;\n };\n} {\n return {\n name: 'burdenoff-pino-logging',\n query: {\n async $allOperations({ model, operation, args, query }: PrismaQueryArgs): Promise<unknown> {\n const start = Date.now();\n try {\n const result = await query(args);\n logger.debug('prisma.query', {\n model,\n operation,\n duration_ms: Date.now() - start,\n args: redactSensitiveFields(args),\n });\n return result;\n } catch (err) {\n logger.error('prisma.error', {\n model,\n operation,\n duration_ms: Date.now() - start,\n error: err instanceof Error ? err.message : String(err),\n });\n throw err;\n }\n },\n },\n };\n}\n","/**\n * Unified telemetry bootstrap for Burdenoff services.\n *\n * Composes the existing `instrumentation/` + `observability/` + `logger/`\n * modules and adds:\n * - `bootstrapTelemetry({ serviceName, boundary, module, env })` — single\n * call that initializes OTel, wires Pino logger with trace fields,\n * exposes GraphQL Yoga plugins, registers process exit hooks.\n * - `createHealthRoutes({ prisma, nats, valkey, version })` — `/health`,\n * `/health/live`, `/health/ready` Elysia routes.\n * - `createMetricsRoutes(registry?)` — `/metrics` Prometheus exposition.\n * - `createPrismaLoggingExtension(logger)` — Prisma extension that pipes\n * query events through Pino with trace/span correlation ids.\n *\n * The module does not pull in `@opentelemetry/sdk-node` or `pino` as direct\n * deps — services install those as optional peers, and imports are lazy so\n * services that don't install them still load.\n */\n\nimport type { Logger as BaseLogger } from '../logger/index.js';\nimport { logger as defaultLogger } from '../logger/index.js';\nimport {\n initializeInstrumentation,\n setupInstrumentation,\n type SetupInstrumentationOptions,\n type InstrumentationSetupResult,\n} from '../instrumentation/index.js';\nimport { setActiveTelemetryLogger } from './logger-state.js';\nimport type { OtelSdkHandle } from './sdk.js';\n\nexport { createHealthRoutes } from './health.js';\nexport { createMetricsRoutes } from './metrics-endpoint.js';\nexport { createPrismaLoggingExtension } from './prisma-logging.js';\nexport { DEFAULT_REDACT_PATHS } from './pino-redaction.js';\nexport { createPinoLogger } from './pino-logger.js';\n\nexport type Boundary = 'wspace' | 'global' | 'gateway';\nexport type Env = 'alpha' | 'prod' | 'dev';\n\nexport interface TelemetryConfig {\n /** Full service name, e.g. \"wspace-auth-svc\". */\n serviceName: string;\n /** Semver of the service deployment; defaults to `process.env.npm_package_version`. */\n serviceVersion?: string;\n /** Monorepo boundary: `wspace`, `global`, or `gateway`. */\n boundary: Boundary;\n /** Module slug, e.g. `auth` (omit for gateways). */\n module?: string;\n /** Deployment environment; defaults to alpha for non-production NODE_ENV. */\n env?: Env;\n /**\n * OTLP endpoint for spans/metrics/logs. Defaults to\n * `$OTEL_EXPORTER_OTLP_ENDPOINT` or\n * `http://alloy.sre.svc.cluster.local:4318`.\n */\n otlpEndpoint?: string;\n /** Head-based sampling ratio. Default: alpha=1.0, prod=0.1. */\n sampleRatio?: number;\n /** Extra options forwarded to `setupInstrumentation`. */\n instrumentation?: SetupInstrumentationOptions;\n}\n\nexport interface TelemetryHandle {\n /** The configured service name (for use in health routes, etc.). */\n serviceName: string;\n /** The resolved service version. */\n serviceVersion: string;\n /** Environment. */\n env: Env;\n /** The Pino-backed logger. */\n logger: BaseLogger;\n /** Initialized instrumentation (tracer + metrics + plugins). */\n instrumentation: InstrumentationSetupResult;\n /** Cleanup hook; services call on SIGTERM. */\n shutdown: () => Promise<void>;\n}\n\nfunction resolveEnv(explicit?: Env): Env {\n if (explicit) return explicit;\n const fromEnv = process.env['DEPLOY_ENV'] ?? process.env['NODE_ENV'] ?? '';\n if (fromEnv === 'production' || fromEnv === 'prod') return 'prod';\n if (fromEnv === 'development' || fromEnv === 'dev') return 'dev';\n return 'alpha';\n}\n\nfunction resolveVersion(explicit?: string): string {\n if (explicit) return explicit;\n return process.env['npm_package_version'] ?? process.env['SERVICE_VERSION'] ?? '0.0.0';\n}\n\nfunction resolveEndpoint(explicit?: string): string {\n if (explicit) return explicit;\n const proto = 'http';\n // NOTE (ACA / current prod): the `alloy.sre.svc.cluster.local` fallback is a\n // LEGACY Kubernetes in-cluster DNS name and does NOT resolve on Azure\n // Container Apps. In ACA, service metrics reach Grafana/Azure Monitor via the\n // Prometheus `/metrics` *pull* path (the otel-collector scrapes each app) —\n // see `~/products/dev/platform/context/sre/HOW_TO_INTEGRATE_SRE_BACKEND.md`.\n // OTLP *push* (traces/metrics) only works where `OTEL_EXPORTER_OTLP_ENDPOINT`\n // is explicitly set to the env's otel-collector OTLP receiver. Kept as the\n // default for local/K8s remnants; override via env in ACA.\n return process.env['OTEL_EXPORTER_OTLP_ENDPOINT'] ?? `${proto}://alloy.sre.svc.cluster.local:4318`;\n}\n\nfunction resolveSampling(explicit: number | undefined, env: Env): number {\n if (typeof explicit === 'number' && Number.isFinite(explicit)) return Math.min(1, Math.max(0, explicit));\n const fromEnv = process.env['OTEL_TRACES_SAMPLER_ARG'];\n if (fromEnv) {\n const parsed = Number(fromEnv);\n if (Number.isFinite(parsed)) return Math.min(1, Math.max(0, parsed));\n }\n if (env === 'prod') return 0.1;\n return 1.0;\n}\n\nfunction resolveOtelSdkEnabled(): boolean {\n const sdkDisabled = process.env['OTEL_SDK_DISABLED'];\n if (sdkDisabled === 'true' || sdkDisabled === '1') return false;\n const otelEnabled = process.env['OTEL_ENABLED'];\n if (otelEnabled === 'false' || otelEnabled === '0') return false;\n return true;\n}\n\n/**\n * Bootstrap the full telemetry stack for a service.\n *\n * Services call this ONCE at startup **before** importing Prisma / GraphQL\n * Yoga / NATS so OTel can auto-instrument their dependencies.\n *\n * ```ts\n * // src/telemetry.ts\n * import { bootstrapTelemetry } from '@burdenoff/be-sdk/telemetry';\n * export const telemetry = await bootstrapTelemetry({\n * serviceName: 'wspace-auth-svc',\n * boundary: 'wspace',\n * module: 'auth',\n * });\n *\n * // src/index.ts — must be the FIRST import line.\n * import './telemetry.js';\n * ```\n */\nexport async function bootstrapTelemetry(cfg: TelemetryConfig): Promise<TelemetryHandle> {\n const env = resolveEnv(cfg.env);\n const serviceVersion = resolveVersion(cfg.serviceVersion);\n const otlpEndpoint = resolveEndpoint(cfg.otlpEndpoint);\n const sampleRatio = resolveSampling(cfg.sampleRatio, env);\n\n // Pino logger with trace/span correlation + redaction.\n // createPinoLogger is async (loads pino via dynamic import); awaiting it\n // is required — without await, `logger` is a Promise and calls like\n // logger.warn(...) crash with \"logger.warn is not a function\" during the\n // sdk-node fallback path.\n const { createPinoLogger } = await import('./pino-logger.js');\n const logger = await createPinoLogger({\n serviceName: cfg.serviceName,\n env,\n version: serviceVersion,\n });\n setActiveTelemetryLogger(logger);\n\n // Initialize core instrumentation (tracer, metrics registry, envelop plugins).\n // `setupInstrumentation` internally calls `initializeInstrumentation`.\n const instrumentation = setupInstrumentation(cfg.serviceName, {\n ...cfg.instrumentation,\n tracing: {\n serviceName: cfg.serviceName,\n ...(cfg.instrumentation?.tracing ?? {}),\n samplingRate: sampleRatio,\n },\n metrics: {\n serviceName: cfg.serviceName,\n ...(cfg.instrumentation?.metrics ?? {}),\n },\n });\n\n // Start the NodeSDK exporter pipeline if sdk-node is present (optional).\n let otelSdk: OtelSdkHandle | undefined;\n if (resolveOtelSdkEnabled()) {\n try {\n const { createOtelSdk } = await import('./sdk.js');\n otelSdk = await createOtelSdk({\n serviceName: cfg.serviceName,\n serviceVersion,\n boundary: cfg.boundary,\n module: cfg.module,\n env,\n otlpEndpoint,\n sampleRatio,\n });\n // Explicit success log includes metrics path status so an operator can\n // distinguish traces-only startup from full traces+metrics startup.\n logger.info('[telemetry] OpenTelemetry exporter pipeline started', {\n serviceName: cfg.serviceName,\n otlpEndpoint: otlpEndpoint ? '<configured>' : '<not set>',\n sampleRatio,\n metricsEnabled: otelSdk.metricsEnabled,\n });\n\n if (!otelSdk.metricsEnabled && otelSdk.metricsDropReason) {\n logger.warn('[telemetry] OpenTelemetry metrics reader disabled; continuing with traces only', {\n serviceName: cfg.serviceName,\n reason: otelSdk.metricsDropReason,\n });\n }\n } catch (err) {\n logger.warn('[telemetry] OpenTelemetry exporter pipeline failed to start; continuing with logs only', {\n error: err instanceof Error ? err.message : String(err),\n });\n }\n } else {\n logger.info('[telemetry] OTel SDK exporter disabled by env');\n }\n\n const shutdown = async (): Promise<void> => {\n try {\n if (otelSdk?.shutdown) await otelSdk.shutdown();\n } catch (err) {\n logger.warn('[telemetry] shutdown error (ignored)', {\n error: err instanceof Error ? err.message : String(err),\n });\n }\n };\n\n // Mirror defaultLogger so services that still use the singleton get trace-enriched output.\n defaultLogger.setLevel(logger.getLevel?.() ?? 'info');\n\n return {\n serviceName: cfg.serviceName,\n serviceVersion,\n env,\n logger: logger,\n instrumentation,\n shutdown,\n };\n}\n\n// Re-export what services typically import.\nexport { initializeInstrumentation, setupInstrumentation };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/be-sdk",
3
- "version": "2026.622.1",
3
+ "version": "2026.624.1",
4
4
  "description": "Backend SDK for Burdenoff products providing unified access to notifications, RBAC, activity tracking, usage monitoring, and more",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",