@parsrun/core 0.1.0
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/README.md +113 -0
- package/dist/decimal.d.ts +190 -0
- package/dist/decimal.js +347 -0
- package/dist/decimal.js.map +1 -0
- package/dist/env.d.ts +101 -0
- package/dist/env.js +172 -0
- package/dist/env.js.map +1 -0
- package/dist/error-codes.d.ts +257 -0
- package/dist/error-codes.js +261 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +161 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.js +1987 -0
- package/dist/index.js.map +1 -0
- package/dist/logger-aEibH9Mv.d.ts +262 -0
- package/dist/logger.d.ts +1 -0
- package/dist/logger.js +327 -0
- package/dist/logger.js.map +1 -0
- package/dist/runtime.d.ts +62 -0
- package/dist/runtime.js +88 -0
- package/dist/runtime.js.map +1 -0
- package/dist/transports/index.d.ts +347 -0
- package/dist/transports/index.js +657 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { h as LogTransport, p as BatchTransportOptions, g as LogEntry, E as ErrorTransport, o as BaseTransportOptions, k as ErrorContext, n as ErrorUser, B as Breadcrumb } from '../logger-aEibH9Mv.js';
|
|
2
|
+
export { j as CombinedTransport, C as ConsoleTransport, q as ConsoleTransportOptions } from '../logger-aEibH9Mv.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @parsrun/core - Axiom Transport
|
|
6
|
+
* Log ingestion transport for Axiom (axiom.co)
|
|
7
|
+
* Uses native fetch - works on all runtimes (Node, Deno, Bun, Workers)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Axiom transport options
|
|
12
|
+
*/
|
|
13
|
+
interface AxiomTransportOptions extends BatchTransportOptions {
|
|
14
|
+
/** Axiom API token */
|
|
15
|
+
token: string;
|
|
16
|
+
/** Dataset name to ingest logs into */
|
|
17
|
+
dataset: string;
|
|
18
|
+
/** Organization ID (optional, for personal tokens) */
|
|
19
|
+
orgId?: string;
|
|
20
|
+
/** Custom Axiom API URL (default: https://api.axiom.co) */
|
|
21
|
+
apiUrl?: string;
|
|
22
|
+
/** Callback for errors during ingestion */
|
|
23
|
+
onError?: (error: Error, droppedCount: number) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Axiom Transport
|
|
27
|
+
* Batches logs and sends them to Axiom's ingest API
|
|
28
|
+
*/
|
|
29
|
+
declare class AxiomTransport implements LogTransport {
|
|
30
|
+
readonly name = "axiom";
|
|
31
|
+
private buffer;
|
|
32
|
+
private flushTimer;
|
|
33
|
+
private isFlushing;
|
|
34
|
+
private readonly options;
|
|
35
|
+
constructor(options: AxiomTransportOptions);
|
|
36
|
+
log(entry: LogEntry): void;
|
|
37
|
+
flush(): Promise<void>;
|
|
38
|
+
close(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create Axiom transport
|
|
42
|
+
*/
|
|
43
|
+
declare function createAxiomTransport(options: AxiomTransportOptions): AxiomTransport;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @parsrun/core - Sentry Transport
|
|
47
|
+
* Error tracking transport for Sentry
|
|
48
|
+
*
|
|
49
|
+
* Supports two modes:
|
|
50
|
+
* 1. HTTP API mode (default) - Zero dependency, works on all runtimes
|
|
51
|
+
* 2. SDK mode (BYOS) - Full features with user-provided Sentry SDK
|
|
52
|
+
*
|
|
53
|
+
* @example HTTP API mode (simple, universal)
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const sentry = new SentryTransport({
|
|
56
|
+
* dsn: 'https://xxx@sentry.io/123',
|
|
57
|
+
* environment: 'production',
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example SDK mode (full features)
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import * as Sentry from '@sentry/cloudflare'; // or @sentry/node
|
|
64
|
+
*
|
|
65
|
+
* Sentry.init({ dsn: '...' });
|
|
66
|
+
*
|
|
67
|
+
* const sentry = new SentryTransport({
|
|
68
|
+
* client: Sentry,
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sentry SDK interface (minimal interface for BYOS)
|
|
75
|
+
* Compatible with @sentry/node, @sentry/cloudflare, @sentry/browser, etc.
|
|
76
|
+
*/
|
|
77
|
+
interface SentryClient {
|
|
78
|
+
captureException(error: Error, hint?: unknown): string;
|
|
79
|
+
captureMessage(message: string, level?: string): string;
|
|
80
|
+
withScope(callback: (scope: SentryScope) => void): void;
|
|
81
|
+
flush?(timeout?: number): Promise<boolean>;
|
|
82
|
+
}
|
|
83
|
+
interface SentryScope {
|
|
84
|
+
setTag(key: string, value: string): void;
|
|
85
|
+
setUser(user: {
|
|
86
|
+
id: string;
|
|
87
|
+
email?: string;
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
} | null): void;
|
|
90
|
+
setExtra(key: string, value: unknown): void;
|
|
91
|
+
setExtras(extras: Record<string, unknown>): void;
|
|
92
|
+
setLevel(level: string): void;
|
|
93
|
+
addBreadcrumb(breadcrumb: unknown): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Sentry transport options
|
|
97
|
+
*/
|
|
98
|
+
interface SentryTransportOptions extends BaseTransportOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Sentry DSN (required for HTTP mode)
|
|
101
|
+
* Format: https://{publicKey}@{host}/{projectId}
|
|
102
|
+
*/
|
|
103
|
+
dsn?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Sentry SDK client (for BYOS mode)
|
|
106
|
+
* Pass your initialized Sentry client for full SDK features
|
|
107
|
+
*/
|
|
108
|
+
client?: SentryClient;
|
|
109
|
+
/** Environment name (e.g., 'production', 'staging') */
|
|
110
|
+
environment?: string;
|
|
111
|
+
/** Release version */
|
|
112
|
+
release?: string;
|
|
113
|
+
/** Server name */
|
|
114
|
+
serverName?: string;
|
|
115
|
+
/** Sample rate for error events (0.0 to 1.0) */
|
|
116
|
+
sampleRate?: number;
|
|
117
|
+
/** Additional tags to add to all events */
|
|
118
|
+
tags?: Record<string, string>;
|
|
119
|
+
/** Callback before sending (return null to drop event) */
|
|
120
|
+
beforeSend?: (event: SentryEvent) => SentryEvent | null;
|
|
121
|
+
/** Callback for transport errors */
|
|
122
|
+
onError?: (error: Error) => void;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Sentry event structure (simplified)
|
|
126
|
+
*/
|
|
127
|
+
interface SentryEvent {
|
|
128
|
+
event_id: string;
|
|
129
|
+
timestamp: string;
|
|
130
|
+
platform: string;
|
|
131
|
+
level: "fatal" | "error" | "warning" | "info" | "debug";
|
|
132
|
+
logger?: string;
|
|
133
|
+
transaction?: string;
|
|
134
|
+
server_name?: string;
|
|
135
|
+
release?: string;
|
|
136
|
+
environment?: string;
|
|
137
|
+
message?: {
|
|
138
|
+
formatted: string;
|
|
139
|
+
};
|
|
140
|
+
exception?: {
|
|
141
|
+
values: Array<{
|
|
142
|
+
type: string;
|
|
143
|
+
value: string;
|
|
144
|
+
stacktrace?: {
|
|
145
|
+
frames: Array<{
|
|
146
|
+
filename?: string;
|
|
147
|
+
function?: string;
|
|
148
|
+
lineno?: number;
|
|
149
|
+
colno?: number;
|
|
150
|
+
in_app?: boolean;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
}>;
|
|
154
|
+
};
|
|
155
|
+
tags?: Record<string, string>;
|
|
156
|
+
extra?: Record<string, unknown>;
|
|
157
|
+
user?: {
|
|
158
|
+
id?: string;
|
|
159
|
+
email?: string;
|
|
160
|
+
username?: string;
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
};
|
|
163
|
+
breadcrumbs?: Array<{
|
|
164
|
+
type?: string;
|
|
165
|
+
category?: string;
|
|
166
|
+
message?: string;
|
|
167
|
+
data?: Record<string, unknown>;
|
|
168
|
+
level?: string;
|
|
169
|
+
timestamp?: number;
|
|
170
|
+
}>;
|
|
171
|
+
contexts?: Record<string, Record<string, unknown>>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Sentry Transport
|
|
175
|
+
* Implements both LogTransport and ErrorTransport
|
|
176
|
+
*/
|
|
177
|
+
declare class SentryTransport implements LogTransport, ErrorTransport {
|
|
178
|
+
readonly name = "sentry";
|
|
179
|
+
private readonly client?;
|
|
180
|
+
private readonly dsn?;
|
|
181
|
+
private readonly options;
|
|
182
|
+
private user;
|
|
183
|
+
private contexts;
|
|
184
|
+
private breadcrumbs;
|
|
185
|
+
private readonly maxBreadcrumbs;
|
|
186
|
+
constructor(options: SentryTransportOptions);
|
|
187
|
+
/**
|
|
188
|
+
* Parse Sentry DSN
|
|
189
|
+
*/
|
|
190
|
+
private parseDSN;
|
|
191
|
+
/**
|
|
192
|
+
* LogTransport implementation
|
|
193
|
+
* Only sends ERROR and FATAL level logs
|
|
194
|
+
*/
|
|
195
|
+
log(entry: LogEntry): void;
|
|
196
|
+
/**
|
|
197
|
+
* Capture an exception
|
|
198
|
+
*/
|
|
199
|
+
captureException(error: Error, context?: ErrorContext): void;
|
|
200
|
+
/**
|
|
201
|
+
* Capture a message
|
|
202
|
+
*/
|
|
203
|
+
captureMessage(message: string, level: "info" | "warning" | "error", context?: ErrorContext): void;
|
|
204
|
+
/**
|
|
205
|
+
* Set user context
|
|
206
|
+
*/
|
|
207
|
+
setUser(user: ErrorUser | null): void;
|
|
208
|
+
/**
|
|
209
|
+
* Set custom context
|
|
210
|
+
*/
|
|
211
|
+
setContext(name: string, context: Record<string, unknown>): void;
|
|
212
|
+
/**
|
|
213
|
+
* Add breadcrumb
|
|
214
|
+
*/
|
|
215
|
+
addBreadcrumb(breadcrumb: Breadcrumb): void;
|
|
216
|
+
/**
|
|
217
|
+
* Flush pending events
|
|
218
|
+
*/
|
|
219
|
+
flush(): Promise<void>;
|
|
220
|
+
private shouldSample;
|
|
221
|
+
/**
|
|
222
|
+
* Capture with SDK (BYOS mode)
|
|
223
|
+
*/
|
|
224
|
+
private captureWithSdk;
|
|
225
|
+
/**
|
|
226
|
+
* Apply context to SDK scope
|
|
227
|
+
*/
|
|
228
|
+
private applyContext;
|
|
229
|
+
/**
|
|
230
|
+
* Capture with HTTP API (default mode)
|
|
231
|
+
*/
|
|
232
|
+
private captureWithHttp;
|
|
233
|
+
/**
|
|
234
|
+
* Build event context for HTTP API
|
|
235
|
+
*/
|
|
236
|
+
private buildEventContext;
|
|
237
|
+
/**
|
|
238
|
+
* Parse error stack trace into Sentry format
|
|
239
|
+
*/
|
|
240
|
+
private parseStackTrace;
|
|
241
|
+
/**
|
|
242
|
+
* Generate event ID
|
|
243
|
+
*/
|
|
244
|
+
private generateEventId;
|
|
245
|
+
/**
|
|
246
|
+
* Send event via HTTP API
|
|
247
|
+
*/
|
|
248
|
+
private sendHttpEvent;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Create Sentry transport
|
|
252
|
+
*/
|
|
253
|
+
declare function createSentryTransport(options: SentryTransportOptions): SentryTransport;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @parsrun/core - Logtape Transport
|
|
257
|
+
* Structured logging transport for Logtape (@logtape/logtape)
|
|
258
|
+
*
|
|
259
|
+
* Logtape is a TypeScript-first structured logging library.
|
|
260
|
+
* This transport bridges Pars Logger to Logtape for advanced logging scenarios.
|
|
261
|
+
*
|
|
262
|
+
* @example BYOS (Bring Your Own SDK)
|
|
263
|
+
* ```typescript
|
|
264
|
+
* import { getLogger, configure } from '@logtape/logtape';
|
|
265
|
+
*
|
|
266
|
+
* // Configure Logtape
|
|
267
|
+
* await configure({
|
|
268
|
+
* sinks: { console: consoleSink() },
|
|
269
|
+
* loggers: [{ category: 'pars', sinks: ['console'], level: 'info' }],
|
|
270
|
+
* });
|
|
271
|
+
*
|
|
272
|
+
* const logtapeLogger = getLogger('pars');
|
|
273
|
+
* const transport = new LogtapeTransport({ logger: logtapeLogger });
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @example Simple mode (creates internal logger)
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const transport = new LogtapeTransport({
|
|
279
|
+
* category: 'my-app',
|
|
280
|
+
* });
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Logtape Logger interface (minimal interface for BYOS)
|
|
286
|
+
* Compatible with @logtape/logtape getLogger() return type
|
|
287
|
+
*/
|
|
288
|
+
interface LogtapeLogger {
|
|
289
|
+
debug(message: string, properties?: Record<string, unknown>): void;
|
|
290
|
+
info(message: string, properties?: Record<string, unknown>): void;
|
|
291
|
+
warn(message: string, properties?: Record<string, unknown>): void;
|
|
292
|
+
warning(message: string, properties?: Record<string, unknown>): void;
|
|
293
|
+
error(message: string, properties?: Record<string, unknown>): void;
|
|
294
|
+
fatal(message: string, properties?: Record<string, unknown>): void;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Logtape transport options
|
|
298
|
+
*/
|
|
299
|
+
interface LogtapeTransportOptions extends BaseTransportOptions {
|
|
300
|
+
/**
|
|
301
|
+
* Logtape logger instance (for BYOS mode)
|
|
302
|
+
* Get this from @logtape/logtape's getLogger()
|
|
303
|
+
*/
|
|
304
|
+
logger?: LogtapeLogger;
|
|
305
|
+
/**
|
|
306
|
+
* Category name for the logger
|
|
307
|
+
* Only used if logger is not provided (creates a simple fallback logger)
|
|
308
|
+
*/
|
|
309
|
+
category?: string;
|
|
310
|
+
/**
|
|
311
|
+
* Include timestamp in properties
|
|
312
|
+
* @default true
|
|
313
|
+
*/
|
|
314
|
+
includeTimestamp?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Include level value in properties
|
|
317
|
+
* @default false
|
|
318
|
+
*/
|
|
319
|
+
includeLevelValue?: boolean;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Logtape Transport
|
|
323
|
+
* Bridges Pars Logger to Logtape
|
|
324
|
+
*/
|
|
325
|
+
declare class LogtapeTransport implements LogTransport {
|
|
326
|
+
readonly name = "logtape";
|
|
327
|
+
private readonly logger;
|
|
328
|
+
private readonly includeTimestamp;
|
|
329
|
+
private readonly includeLevelValue;
|
|
330
|
+
private readonly enabled;
|
|
331
|
+
constructor(options?: LogtapeTransportOptions);
|
|
332
|
+
log(entry: LogEntry): void;
|
|
333
|
+
/**
|
|
334
|
+
* Map Pars log level to Logtape level
|
|
335
|
+
*/
|
|
336
|
+
private mapLevel;
|
|
337
|
+
/**
|
|
338
|
+
* Build properties object for Logtape
|
|
339
|
+
*/
|
|
340
|
+
private buildProperties;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Create Logtape transport
|
|
344
|
+
*/
|
|
345
|
+
declare function createLogtapeTransport(options?: LogtapeTransportOptions): LogtapeTransport;
|
|
346
|
+
|
|
347
|
+
export { AxiomTransport, type AxiomTransportOptions, BaseTransportOptions, BatchTransportOptions, Breadcrumb, ErrorContext, ErrorTransport, ErrorUser, LogTransport, type LogtapeLogger, LogtapeTransport, type LogtapeTransportOptions, type SentryClient, type SentryEvent, type SentryScope, SentryTransport, type SentryTransportOptions, createAxiomTransport, createLogtapeTransport, createSentryTransport };
|