ezlogs-nextjs 0.3.0 → 0.3.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/README.md +15 -2
- package/bin/install-triggers.cjs +33 -5
- package/dist/actors/index.cjs +5 -37
- package/dist/actors/index.js +2 -34
- package/dist/chunk-C5OSM557.js +39 -0
- package/dist/chunk-CE3R7DVB.js +1127 -0
- package/dist/chunk-CU45I2WR.js +498 -0
- package/dist/chunk-DKRNNI4I.js +180 -0
- package/dist/chunk-SIAA4J6H.js +17 -0
- package/dist/chunk-UQHEW6ER.js +119 -0
- package/dist/chunk-UWHYJH4M.cjs +126 -0
- package/dist/chunk-V5YNKKTG.cjs +42 -0
- package/dist/chunk-WASXTDLW.cjs +1151 -0
- package/dist/chunk-Y5NSHKWQ.cjs +182 -0
- package/dist/chunk-YX2XPLOA.cjs +508 -0
- package/dist/chunk-ZDSQYCYV.cjs +21 -0
- package/dist/db/drizzle.cjs +6 -821
- package/dist/db/drizzle.js +5 -820
- package/dist/db/prisma.cjs +28 -853
- package/dist/db/prisma.js +14 -839
- package/dist/db/supabase.cjs +21 -836
- package/dist/db/supabase.js +14 -829
- package/dist/index.cjs +132 -2362
- package/dist/index.js +34 -2270
- package/dist/jobs/bullmq.cjs +13 -1465
- package/dist/jobs/bullmq.js +7 -1459
- package/dist/jobs/inngest.cjs +14 -1422
- package/dist/jobs/inngest.js +8 -1416
- package/dist/jobs/supabase-queues.cjs +15 -1467
- package/dist/jobs/supabase-queues.js +10 -1462
- package/dist/jobs/trigger.cjs +9 -1454
- package/dist/jobs/trigger.js +5 -1450
- package/dist/jobs/upstash-workflow.cjs +30 -1456
- package/dist/jobs/upstash-workflow.d.cts +2 -1
- package/dist/jobs/upstash-workflow.d.ts +2 -1
- package/dist/jobs/upstash-workflow.js +27 -1453
- package/dist/nextjs-plugin/index.cjs +1 -1
- package/dist/nextjs-plugin/index.js +1 -1
- package/dist/nextjs-plugin/loader.cjs +21 -25
- package/dist/nextjs-plugin/loader.js +1 -5
- package/dist/triggers/index.cjs +40 -1434
- package/dist/triggers/index.js +6 -1421
- package/package.json +2 -1
package/dist/db/drizzle.js
CHANGED
|
@@ -1,821 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/logger.ts
|
|
9
|
-
var LEVEL_RANK = {
|
|
10
|
-
debug: 10,
|
|
11
|
-
info: 20,
|
|
12
|
-
warn: 30,
|
|
13
|
-
error: 40,
|
|
14
|
-
silent: 100
|
|
15
|
-
};
|
|
16
|
-
var LEVEL_KEY = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:log-level");
|
|
17
|
-
function readLevel() {
|
|
18
|
-
const g = globalThis;
|
|
19
|
-
return g[LEVEL_KEY] ?? "warn";
|
|
20
|
-
}
|
|
21
|
-
function shouldLog(level) {
|
|
22
|
-
return LEVEL_RANK[level] >= LEVEL_RANK[readLevel()];
|
|
23
|
-
}
|
|
24
|
-
function safeWrite(level, message) {
|
|
25
|
-
try {
|
|
26
|
-
if (!shouldLog(level)) return;
|
|
27
|
-
const line = `[ezlogs] ${message}`;
|
|
28
|
-
if (level === "error" || level === "warn") {
|
|
29
|
-
console.error(line);
|
|
30
|
-
} else {
|
|
31
|
-
console.log(line);
|
|
32
|
-
}
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
var logger = {
|
|
37
|
-
debug: (message) => safeWrite("debug", message),
|
|
38
|
-
info: (message) => safeWrite("info", message),
|
|
39
|
-
warn: (message) => safeWrite("warn", message),
|
|
40
|
-
error: (message) => safeWrite("error", message)
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/configuration.ts
|
|
44
|
-
var DEFAULT_EXCLUDED_PATHS = Object.freeze([
|
|
45
|
-
// Next.js / Vercel infrastructure noise
|
|
46
|
-
"/_next/*",
|
|
47
|
-
"/_vercel/*",
|
|
48
|
-
"/__nextjs_*",
|
|
49
|
-
// NextAuth.js / Auth.js — skip session-refresh polls and CSRF/provider
|
|
50
|
-
// metadata GETs (high-frequency, no business meaning), but CAPTURE
|
|
51
|
-
// POSTs (callbacks, signin, signout, register). The POSTs are the
|
|
52
|
-
// actual auth events users care about; the GETs are pure plumbing.
|
|
53
|
-
Object.freeze({ path: "/api/auth/*", methods: ["GET", "HEAD"] }),
|
|
54
|
-
// Generic infrastructure
|
|
55
|
-
"/health*",
|
|
56
|
-
"/api/health",
|
|
57
|
-
"/up",
|
|
58
|
-
"/alive",
|
|
59
|
-
"/ready",
|
|
60
|
-
"/metrics",
|
|
61
|
-
"/favicon.ico",
|
|
62
|
-
"/.well-known*",
|
|
63
|
-
"/robots.txt",
|
|
64
|
-
"/sitemap.xml",
|
|
65
|
-
"/*.hot-update.*",
|
|
66
|
-
// Auth routes (common patterns across Clerk, NextAuth, custom auth)
|
|
67
|
-
"*/login*",
|
|
68
|
-
"*/logout*",
|
|
69
|
-
"*/sign-in*",
|
|
70
|
-
"*/sign-out*",
|
|
71
|
-
"*/signin*",
|
|
72
|
-
"*/signout*",
|
|
73
|
-
"/session*"
|
|
74
|
-
]);
|
|
75
|
-
var DEFAULT_EXCLUDED_TABLES = Object.freeze([
|
|
76
|
-
// Prisma migration ledger
|
|
77
|
-
"_prisma_migrations",
|
|
78
|
-
// Auth.js / NextAuth Prisma adapter — session/verification-token churn
|
|
79
|
-
// is auth machinery, not business activity. Account/User stay captured.
|
|
80
|
-
"Session",
|
|
81
|
-
"VerificationToken",
|
|
82
|
-
// Common cross-stack convention names for the same things
|
|
83
|
-
"sessions",
|
|
84
|
-
"session",
|
|
85
|
-
"verification_tokens"
|
|
86
|
-
]);
|
|
87
|
-
var DEFAULT_EXCLUDED_JOB_CLASSES = Object.freeze([]);
|
|
88
|
-
var DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS = Object.freeze(["IntrospectionQuery", "__*"]);
|
|
89
|
-
var Configuration = class {
|
|
90
|
-
serverUrl = null;
|
|
91
|
-
projectToken = null;
|
|
92
|
-
captureHttp = true;
|
|
93
|
-
captureDb = true;
|
|
94
|
-
captureJobs = true;
|
|
95
|
-
bufferSize = 1e4;
|
|
96
|
-
/** Default 3000 ms — equivalent to Ruby's 3 seconds. */
|
|
97
|
-
sendInterval = 3e3;
|
|
98
|
-
retryAttempts = 3;
|
|
99
|
-
logLevel = "warn";
|
|
100
|
-
patchGlobalFetch = true;
|
|
101
|
-
actorFromSupabase = true;
|
|
102
|
-
allowInsecureTransport = false;
|
|
103
|
-
excludedPaths = [];
|
|
104
|
-
excludedTables = [];
|
|
105
|
-
excludedJobClasses = [];
|
|
106
|
-
excludedGraphqlOperations = [];
|
|
107
|
-
excludedGraphqlVariableKeys = [];
|
|
108
|
-
actorFromRequest = null;
|
|
109
|
-
displayNameFor = {};
|
|
110
|
-
isServerActionError = null;
|
|
111
|
-
databaseReader = null;
|
|
112
|
-
databaseUrl = null;
|
|
113
|
-
/**
|
|
114
|
-
* Tables that have the `ezlogs_audit` trigger attached. Detected once
|
|
115
|
-
* at agent startup by reading `information_schema.triggers`. The
|
|
116
|
-
* supabase / drizzle / prisma adapters use this to decide whether
|
|
117
|
-
* their per-mutation emit is redundant: if the table is trigger-
|
|
118
|
-
* tracked the audit-log reader will surface the same write with full
|
|
119
|
-
* old/new state, so the adapter's emit is suppressed. Tables NOT in
|
|
120
|
-
* this set fall through to the adapter so they're still captured.
|
|
121
|
-
*
|
|
122
|
-
* `null` means "detection hasn't run yet or failed" — in that state
|
|
123
|
-
* `databaseReader`-wired apps suppress every adapter emit (the
|
|
124
|
-
* original Phase 5 behavior). After detection completes the agent
|
|
125
|
-
* gives the more accurate per-table answer.
|
|
126
|
-
*/
|
|
127
|
-
triggerTrackedTables = null;
|
|
128
|
-
apply(options) {
|
|
129
|
-
this.serverUrl = options.serverUrl;
|
|
130
|
-
this.projectToken = options.projectToken;
|
|
131
|
-
if (options.captureHttp !== void 0) this.captureHttp = options.captureHttp;
|
|
132
|
-
if (options.captureDb !== void 0) this.captureDb = options.captureDb;
|
|
133
|
-
if (options.captureJobs !== void 0) this.captureJobs = options.captureJobs;
|
|
134
|
-
if (options.bufferSize !== void 0) this.bufferSize = options.bufferSize;
|
|
135
|
-
if (options.sendInterval !== void 0) this.sendInterval = options.sendInterval;
|
|
136
|
-
if (options.retryAttempts !== void 0) this.retryAttempts = options.retryAttempts;
|
|
137
|
-
if (options.excludedPaths) this.excludedPaths = [...options.excludedPaths];
|
|
138
|
-
if (options.excludedTables) this.excludedTables = [...options.excludedTables];
|
|
139
|
-
if (options.excludedJobClasses) {
|
|
140
|
-
this.excludedJobClasses = [...options.excludedJobClasses];
|
|
141
|
-
}
|
|
142
|
-
if (options.excludedGraphqlOperations) {
|
|
143
|
-
this.excludedGraphqlOperations = [...options.excludedGraphqlOperations];
|
|
144
|
-
}
|
|
145
|
-
if (options.excludedGraphqlVariableKeys) {
|
|
146
|
-
this.excludedGraphqlVariableKeys = [...options.excludedGraphqlVariableKeys];
|
|
147
|
-
}
|
|
148
|
-
if (options.actorFromRequest) this.actorFromRequest = options.actorFromRequest;
|
|
149
|
-
if (options.displayNameFor) this.displayNameFor = { ...options.displayNameFor };
|
|
150
|
-
if (options.isServerActionError) this.isServerActionError = options.isServerActionError;
|
|
151
|
-
if (options.patchGlobalFetch !== void 0) {
|
|
152
|
-
this.patchGlobalFetch = options.patchGlobalFetch;
|
|
153
|
-
}
|
|
154
|
-
if (options.allowInsecureTransport !== void 0) {
|
|
155
|
-
this.allowInsecureTransport = options.allowInsecureTransport;
|
|
156
|
-
}
|
|
157
|
-
if (options.actorFromSupabase !== void 0) {
|
|
158
|
-
this.actorFromSupabase = options.actorFromSupabase;
|
|
159
|
-
}
|
|
160
|
-
if (options.databaseReader !== void 0) {
|
|
161
|
-
this.databaseReader = options.databaseReader;
|
|
162
|
-
}
|
|
163
|
-
if (options.databaseUrl !== void 0) {
|
|
164
|
-
this.databaseUrl = options.databaseUrl;
|
|
165
|
-
}
|
|
166
|
-
if (options.logLevel) this.logLevel = options.logLevel;
|
|
167
|
-
}
|
|
168
|
-
allExcludedPaths() {
|
|
169
|
-
return [...DEFAULT_EXCLUDED_PATHS, ...this.excludedPaths];
|
|
170
|
-
}
|
|
171
|
-
allExcludedTables() {
|
|
172
|
-
return [...DEFAULT_EXCLUDED_TABLES, ...this.excludedTables];
|
|
173
|
-
}
|
|
174
|
-
allExcludedJobClasses() {
|
|
175
|
-
return [...DEFAULT_EXCLUDED_JOB_CLASSES, ...this.excludedJobClasses];
|
|
176
|
-
}
|
|
177
|
-
allExcludedGraphqlOperations() {
|
|
178
|
-
return [...DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS, ...this.excludedGraphqlOperations];
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var GLOBAL_CONFIG_KEY = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:configuration");
|
|
182
|
-
function configuration() {
|
|
183
|
-
const g = globalThis;
|
|
184
|
-
if (!g[GLOBAL_CONFIG_KEY]) {
|
|
185
|
-
g[GLOBAL_CONFIG_KEY] = new Configuration();
|
|
186
|
-
}
|
|
187
|
-
return g[GLOBAL_CONFIG_KEY];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// src/event-builder.ts
|
|
191
|
-
var SENSITIVE_KEYS = Object.freeze([
|
|
192
|
-
"password",
|
|
193
|
-
"token",
|
|
194
|
-
"secret",
|
|
195
|
-
"api_key",
|
|
196
|
-
"credit_card"
|
|
197
|
-
]);
|
|
198
|
-
var VALID_SOURCE_TYPES = [
|
|
199
|
-
"http_request",
|
|
200
|
-
"background_job",
|
|
201
|
-
"database_callback"
|
|
202
|
-
];
|
|
203
|
-
var VALID_OUTCOMES = ["success", "failure"];
|
|
204
|
-
function build(input) {
|
|
205
|
-
const source_type = validateSourceType(input.source_type);
|
|
206
|
-
const source_data_raw = validateSourceData(input.source_data);
|
|
207
|
-
const outcome = validateOutcome(input.outcome);
|
|
208
|
-
const timestamp = validateTimestamp(input.timestamp ?? null);
|
|
209
|
-
const resource_ids = validateResourceIds(input.resource_ids ?? []);
|
|
210
|
-
const context_raw = validateContext(input.context ?? null);
|
|
211
|
-
const duration_ms = validateDurationMs();
|
|
212
|
-
const error_message = input.error_message ?? null;
|
|
213
|
-
validateOutcomeErrorConsistency(outcome, error_message);
|
|
214
|
-
const source_data = sanitizeRecord(source_data_raw);
|
|
215
|
-
const context = context_raw === null ? null : sanitizeRecord(context_raw);
|
|
216
|
-
const correlation_id = input.correlation_id ?? null;
|
|
217
|
-
const event = {
|
|
218
|
-
timestamp,
|
|
219
|
-
source_type,
|
|
220
|
-
source_data,
|
|
221
|
-
outcome,
|
|
222
|
-
correlation_id,
|
|
223
|
-
resource_ids,
|
|
224
|
-
context,
|
|
225
|
-
duration_ms,
|
|
226
|
-
error_message
|
|
227
|
-
};
|
|
228
|
-
return event;
|
|
229
|
-
}
|
|
230
|
-
function validateSourceType(value) {
|
|
231
|
-
const normalized = String(value);
|
|
232
|
-
if (!VALID_SOURCE_TYPES.includes(normalized)) {
|
|
233
|
-
throw new ArgError(
|
|
234
|
-
`source_type must be one of ${VALID_SOURCE_TYPES.join(", ")}, got: ${normalized}`
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
return normalized;
|
|
238
|
-
}
|
|
239
|
-
function validateSourceData(value) {
|
|
240
|
-
if (value === null || value === void 0) {
|
|
241
|
-
throw new ArgError("source_data is required");
|
|
242
|
-
}
|
|
243
|
-
if (!isPlainObject(value)) {
|
|
244
|
-
throw new ArgError(
|
|
245
|
-
`source_data must be an object, got: ${describe(value)}`
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
return value;
|
|
249
|
-
}
|
|
250
|
-
function validateOutcome(value) {
|
|
251
|
-
const normalized = String(value);
|
|
252
|
-
if (!VALID_OUTCOMES.includes(normalized)) {
|
|
253
|
-
throw new ArgError(
|
|
254
|
-
`outcome must be one of ${VALID_OUTCOMES.join(", ")}, got: ${normalized}`
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
return normalized;
|
|
258
|
-
}
|
|
259
|
-
function validateTimestamp(value) {
|
|
260
|
-
if (value === null) {
|
|
261
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
262
|
-
}
|
|
263
|
-
if (typeof value === "string") {
|
|
264
|
-
const parsed = new Date(value);
|
|
265
|
-
if (Number.isNaN(parsed.getTime())) {
|
|
266
|
-
throw new ArgError(
|
|
267
|
-
`timestamp must be valid ISO 8601 format, got: ${value}`
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
return value;
|
|
271
|
-
}
|
|
272
|
-
if (value instanceof Date) {
|
|
273
|
-
if (Number.isNaN(value.getTime())) {
|
|
274
|
-
throw new ArgError("timestamp must be a valid Date");
|
|
275
|
-
}
|
|
276
|
-
return value.toISOString();
|
|
277
|
-
}
|
|
278
|
-
throw new ArgError(
|
|
279
|
-
`timestamp must be a string or Date, got: ${describe(value)}`
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
function validateResourceIds(value) {
|
|
283
|
-
if (!Array.isArray(value)) {
|
|
284
|
-
throw new ArgError(`resource_ids must be an array, got: ${describe(value)}`);
|
|
285
|
-
}
|
|
286
|
-
value.forEach((entry, index) => {
|
|
287
|
-
if (!isPlainObject(entry)) {
|
|
288
|
-
throw new ArgError(
|
|
289
|
-
`resource_ids[${index}] must be an object, got: ${describe(entry)}`
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
const e = entry;
|
|
293
|
-
if (!("resource_type" in e) || !("resource_id" in e)) {
|
|
294
|
-
throw new ArgError(
|
|
295
|
-
`resource_ids[${index}] must have resource_type and resource_id keys, got: ${Object.keys(e).join(", ")}`
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
if (typeof e.resource_type !== "string") {
|
|
299
|
-
throw new ArgError(
|
|
300
|
-
`resource_ids[${index}].resource_type must be a string, got: ${describe(e.resource_type)}`
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
if (typeof e.resource_id !== "string") {
|
|
304
|
-
throw new ArgError(
|
|
305
|
-
`resource_ids[${index}].resource_id must be a string, got: ${describe(e.resource_id)}`
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
return value;
|
|
310
|
-
}
|
|
311
|
-
function validateContext(value) {
|
|
312
|
-
if (value === null) return null;
|
|
313
|
-
if (!isPlainObject(value)) {
|
|
314
|
-
throw new ArgError(
|
|
315
|
-
`context must be an object or null, got: ${describe(value)}`
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
return value;
|
|
319
|
-
}
|
|
320
|
-
function validateDurationMs(value) {
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
function validateOutcomeErrorConsistency(outcome, error_message) {
|
|
324
|
-
if (outcome === "failure") {
|
|
325
|
-
if (error_message === null || error_message === "") {
|
|
326
|
-
throw new ArgError("error_message is required when outcome is 'failure'");
|
|
327
|
-
}
|
|
328
|
-
} else if (outcome === "success") {
|
|
329
|
-
if (error_message !== null) {
|
|
330
|
-
throw new ArgError("error_message must be null when outcome is 'success'");
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
function sanitizeRecord(input) {
|
|
335
|
-
const result = {};
|
|
336
|
-
for (const key of Object.keys(input)) {
|
|
337
|
-
const value = input[key];
|
|
338
|
-
if (isSensitiveKey(key)) {
|
|
339
|
-
result[key] = "[FILTERED]";
|
|
340
|
-
} else if (isPlainObject(value)) {
|
|
341
|
-
result[key] = sanitizeRecord(value);
|
|
342
|
-
} else if (Array.isArray(value)) {
|
|
343
|
-
result[key] = value.map(
|
|
344
|
-
(item) => isPlainObject(item) ? sanitizeRecord(item) : item
|
|
345
|
-
);
|
|
346
|
-
} else {
|
|
347
|
-
result[key] = value;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return result;
|
|
351
|
-
}
|
|
352
|
-
function isSensitiveKey(key) {
|
|
353
|
-
const lower = key.toLowerCase();
|
|
354
|
-
return SENSITIVE_KEYS.some((p) => lower.includes(p));
|
|
355
|
-
}
|
|
356
|
-
function isPlainObject(value) {
|
|
357
|
-
if (value === null || typeof value !== "object") return false;
|
|
358
|
-
const proto = Object.getPrototypeOf(value);
|
|
359
|
-
return proto === Object.prototype || proto === null;
|
|
360
|
-
}
|
|
361
|
-
function describe(value) {
|
|
362
|
-
if (value === null) return "null";
|
|
363
|
-
if (Array.isArray(value)) return "Array";
|
|
364
|
-
return typeof value;
|
|
365
|
-
}
|
|
366
|
-
var ArgError = class extends Error {
|
|
367
|
-
constructor(message) {
|
|
368
|
-
super(message);
|
|
369
|
-
this.name = "ArgError";
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
// src/pipeline/buffer.ts
|
|
374
|
-
var GLOBAL_QUEUE_KEY = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:buffer-queue");
|
|
375
|
-
function getQueue() {
|
|
376
|
-
const g = globalThis;
|
|
377
|
-
if (!g[GLOBAL_QUEUE_KEY]) g[GLOBAL_QUEUE_KEY] = [];
|
|
378
|
-
return g[GLOBAL_QUEUE_KEY];
|
|
379
|
-
}
|
|
380
|
-
function pushEvent(event) {
|
|
381
|
-
try {
|
|
382
|
-
const queue = getQueue();
|
|
383
|
-
const max = maxSize();
|
|
384
|
-
if (queue.length >= max) {
|
|
385
|
-
queue.shift();
|
|
386
|
-
logger.warn(`Buffer full (${max}), dropped oldest event`);
|
|
387
|
-
}
|
|
388
|
-
queue.push(event);
|
|
389
|
-
} catch (error) {
|
|
390
|
-
logger.error(`pushEvent failed: ${describe2(error)}`);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
function maxSize() {
|
|
394
|
-
try {
|
|
395
|
-
return configuration().bufferSize;
|
|
396
|
-
} catch {
|
|
397
|
-
return 1e4;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
function describe2(error) {
|
|
401
|
-
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
402
|
-
return String(error);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// src/edge-fallback.ts
|
|
406
|
-
var ALS_CTOR = loadAsyncLocalStorage();
|
|
407
|
-
function loadAsyncLocalStorage() {
|
|
408
|
-
const fromGlobal = globalThis.AsyncLocalStorage;
|
|
409
|
-
if (typeof fromGlobal === "function") return fromGlobal;
|
|
410
|
-
try {
|
|
411
|
-
const req = typeof __require !== "undefined" ? __require : (
|
|
412
|
-
// In ESM, `createRequire` is the official escape hatch.
|
|
413
|
-
// We pull it via globalThis to avoid a static `import`
|
|
414
|
-
// that would itself be browser-bundled.
|
|
415
|
-
void 0
|
|
416
|
-
);
|
|
417
|
-
if (typeof req === "function") {
|
|
418
|
-
const moduleName = ["async", "hooks"].join("_");
|
|
419
|
-
const mod = req("node:" + moduleName);
|
|
420
|
-
if (typeof mod.AsyncLocalStorage === "function") return mod.AsyncLocalStorage;
|
|
421
|
-
}
|
|
422
|
-
} catch {
|
|
423
|
-
}
|
|
424
|
-
return null;
|
|
425
|
-
}
|
|
426
|
-
function createScopedStorage(key = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:default-scoped-storage")) {
|
|
427
|
-
const globalStore = globalThis;
|
|
428
|
-
let entry = globalStore[key];
|
|
429
|
-
if (!entry) {
|
|
430
|
-
const als2 = (() => {
|
|
431
|
-
if (!ALS_CTOR) return null;
|
|
432
|
-
try {
|
|
433
|
-
return new ALS_CTOR();
|
|
434
|
-
} catch {
|
|
435
|
-
return null;
|
|
436
|
-
}
|
|
437
|
-
})();
|
|
438
|
-
entry = { als: als2, edgeFallback: null };
|
|
439
|
-
globalStore[key] = entry;
|
|
440
|
-
}
|
|
441
|
-
const als = entry.als;
|
|
442
|
-
const stateRef = entry;
|
|
443
|
-
return {
|
|
444
|
-
read() {
|
|
445
|
-
if (als) return als.getStore()?.value ?? null;
|
|
446
|
-
return stateRef.edgeFallback?.value ?? null;
|
|
447
|
-
},
|
|
448
|
-
run(value, callback) {
|
|
449
|
-
if (als) return als.run({ value }, callback);
|
|
450
|
-
const previous = stateRef.edgeFallback;
|
|
451
|
-
stateRef.edgeFallback = { value };
|
|
452
|
-
try {
|
|
453
|
-
return callback();
|
|
454
|
-
} finally {
|
|
455
|
-
stateRef.edgeFallback = previous;
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
update(value) {
|
|
459
|
-
if (als) {
|
|
460
|
-
const store = als.getStore();
|
|
461
|
-
if (store) store.value = value;
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
stateRef.edgeFallback = { value };
|
|
465
|
-
},
|
|
466
|
-
_resetForTests() {
|
|
467
|
-
stateRef.edgeFallback = null;
|
|
468
|
-
},
|
|
469
|
-
_isAsyncLocalStorage() {
|
|
470
|
-
return als !== null;
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// src/correlation.ts
|
|
476
|
-
var storage = createScopedStorage(
|
|
477
|
-
/* @__PURE__ */ Symbol.for("ezlogs-nextjs:correlation-storage")
|
|
478
|
-
);
|
|
479
|
-
function current() {
|
|
480
|
-
return storage.read();
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// src/actor.ts
|
|
484
|
-
var storage2 = createScopedStorage(
|
|
485
|
-
/* @__PURE__ */ Symbol.for("ezlogs-nextjs:actor-storage")
|
|
486
|
-
);
|
|
487
|
-
function getCurrentActor() {
|
|
488
|
-
return storage2.read();
|
|
489
|
-
}
|
|
490
|
-
var SENSITIVE_WORD_PATTERNS = Object.freeze([
|
|
491
|
-
"pin",
|
|
492
|
-
"otp",
|
|
493
|
-
"totp",
|
|
494
|
-
"iban",
|
|
495
|
-
"mfa",
|
|
496
|
-
"passphrase"
|
|
497
|
-
]);
|
|
498
|
-
function snakeLower(key) {
|
|
499
|
-
return key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
|
|
500
|
-
}
|
|
501
|
-
function matchesSensitiveKey(key, substringPatterns) {
|
|
502
|
-
const lower = key.toLowerCase();
|
|
503
|
-
const snake = snakeLower(key);
|
|
504
|
-
if (substringPatterns.some((p) => lower.includes(p) || snake.includes(p))) {
|
|
505
|
-
return true;
|
|
506
|
-
}
|
|
507
|
-
const words = snake.split(/[^a-z0-9]+/);
|
|
508
|
-
return SENSITIVE_WORD_PATTERNS.some((w) => words.includes(w));
|
|
509
|
-
}
|
|
510
|
-
function passesLuhn(digits) {
|
|
511
|
-
let sum = 0;
|
|
512
|
-
for (let i = 0; i < digits.length; i += 1) {
|
|
513
|
-
let d = Number(digits[digits.length - 1 - i]);
|
|
514
|
-
if (i % 2 === 1) {
|
|
515
|
-
d *= 2;
|
|
516
|
-
if (d > 9) d -= 9;
|
|
517
|
-
}
|
|
518
|
-
sum += d;
|
|
519
|
-
}
|
|
520
|
-
return sum % 10 === 0;
|
|
521
|
-
}
|
|
522
|
-
var SECRET_TEXT_PATTERNS = [
|
|
523
|
-
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,
|
|
524
|
-
/\beyJ[\w-]+\.[\w-]+\.[\w-]+/g,
|
|
525
|
-
/\b(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]+/g,
|
|
526
|
-
/\bsk-[A-Za-z0-9_-]{16,}/g,
|
|
527
|
-
/\bgh[pousr]_[A-Za-z0-9]{20,}/g,
|
|
528
|
-
/\bxox[abposr]-[A-Za-z0-9-]+/g,
|
|
529
|
-
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g
|
|
530
|
-
];
|
|
531
|
-
var EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
|
|
532
|
-
function scrubSecretsInText(text, options = {}) {
|
|
533
|
-
let out = text;
|
|
534
|
-
for (const pattern of SECRET_TEXT_PATTERNS) out = out.replace(pattern, "[FILTERED]");
|
|
535
|
-
out = out.replace(/\b(Bearer|Basic)\s+[\w.~+/=-]+/gi, "$1 [FILTERED]").replace(/\b\d(?:[ -]?\d){12,18}\b/g, (match) => {
|
|
536
|
-
const digits = match.replace(/[ -]/g, "");
|
|
537
|
-
return (digits.length === 15 || digits.length === 16) && passesLuhn(digits) ? "[FILTERED]" : match;
|
|
538
|
-
});
|
|
539
|
-
return options.emails ? out.replace(EMAIL, "[FILTERED]") : out;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
// src/db/shared.ts
|
|
543
|
-
var IGNORED_ATTRIBUTES = Object.freeze([
|
|
544
|
-
"id",
|
|
545
|
-
"createdAt",
|
|
546
|
-
"created_at",
|
|
547
|
-
"updatedAt",
|
|
548
|
-
"updated_at",
|
|
549
|
-
// Auth.js / NextAuth standard columns
|
|
550
|
-
"emailVerified",
|
|
551
|
-
"expires"
|
|
552
|
-
]);
|
|
553
|
-
var DB_SENSITIVE_PATTERNS = Object.freeze([
|
|
554
|
-
"password",
|
|
555
|
-
"token",
|
|
556
|
-
"secret",
|
|
557
|
-
"api_key",
|
|
558
|
-
"credit_card",
|
|
559
|
-
"ssn",
|
|
560
|
-
"social_security",
|
|
561
|
-
"encrypted",
|
|
562
|
-
"private_key",
|
|
563
|
-
"public_key",
|
|
564
|
-
"signing_key",
|
|
565
|
-
"pem",
|
|
566
|
-
"cipher",
|
|
567
|
-
"nonce",
|
|
568
|
-
"salt",
|
|
569
|
-
"digest",
|
|
570
|
-
"signature",
|
|
571
|
-
"hmac",
|
|
572
|
-
// 0.2.0 additions. `credential` / `passwd` / `apikey` were already in
|
|
573
|
-
// the HTTP list; `passcode` / `card_number` / `cardnumber` / `cvv` /
|
|
574
|
-
// `cvc` are new. Whole-word `pin` / `otp` / `totp` / `iban` come from
|
|
575
|
-
// SENSITIVE_WORD_PATTERNS. The SQL trigger mirrors this list.
|
|
576
|
-
"credential",
|
|
577
|
-
"passwd",
|
|
578
|
-
"passcode",
|
|
579
|
-
"apikey",
|
|
580
|
-
"card_number",
|
|
581
|
-
"cardnumber",
|
|
582
|
-
"cvv",
|
|
583
|
-
"cvc"
|
|
584
|
-
]);
|
|
585
|
-
function emitDbEvent(input) {
|
|
586
|
-
try {
|
|
587
|
-
const config = configuration();
|
|
588
|
-
if (!config.captureDb) return;
|
|
589
|
-
if (config.allExcludedTables().includes(input.modelClass)) return;
|
|
590
|
-
if (config.databaseReader && !input._fromTrigger) {
|
|
591
|
-
const tracked = config.triggerTrackedTables;
|
|
592
|
-
if (tracked === null || tracked.has(input.table ?? input.modelClass)) return;
|
|
593
|
-
}
|
|
594
|
-
if (input.operation === "update") {
|
|
595
|
-
const meaningful = input.changes ? filterMeaningfulChanges(input.changes) : [];
|
|
596
|
-
if (meaningful.length === 0) return;
|
|
597
|
-
}
|
|
598
|
-
const resourceIdStr = input.resourceId === null || input.resourceId === void 0 ? null : String(input.resourceId);
|
|
599
|
-
const related = resourceIdStr === null ? input.relatedResourceIds ?? [] : [];
|
|
600
|
-
const context = buildContext(
|
|
601
|
-
related.length > 0 ? { ...input, displayName: null, modelInstance: null } : input
|
|
602
|
-
);
|
|
603
|
-
const event = build({
|
|
604
|
-
source_type: "database_callback",
|
|
605
|
-
source_data: {
|
|
606
|
-
model_class: input.modelClass,
|
|
607
|
-
operation: input.operation
|
|
608
|
-
},
|
|
609
|
-
outcome: "success",
|
|
610
|
-
correlation_id: current(),
|
|
611
|
-
resource_ids: resourceIdStr === null ? [...related] : [{ resource_type: input.modelClass, resource_id: resourceIdStr }],
|
|
612
|
-
context,
|
|
613
|
-
duration_ms: null,
|
|
614
|
-
timestamp: input.timestamp ?? null
|
|
615
|
-
});
|
|
616
|
-
pushEvent(event);
|
|
617
|
-
} catch (error) {
|
|
618
|
-
logger.debug(`db emit failed: ${describeError(error)}`);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
function buildContext(input) {
|
|
622
|
-
const context = {};
|
|
623
|
-
const actor = getCurrentActor();
|
|
624
|
-
if (actor) context.actor = actor;
|
|
625
|
-
if ((input.operation === "create" || input.operation === "destroy") && input.initialAttributes) {
|
|
626
|
-
const filtered = filterMeaningfulAttributes(input.initialAttributes);
|
|
627
|
-
if (filtered !== null) context.initial_attributes = filtered;
|
|
628
|
-
}
|
|
629
|
-
if (input.operation === "update" && input.changes) {
|
|
630
|
-
const filtered = filterMeaningfulChanges(input.changes);
|
|
631
|
-
if (filtered.length > 0) {
|
|
632
|
-
context.changes = filtered.map((c) => {
|
|
633
|
-
const out = {
|
|
634
|
-
attribute: c.attribute,
|
|
635
|
-
to: formatForJson(c.to)
|
|
636
|
-
};
|
|
637
|
-
if (c.from !== void 0) out.from = formatForJson(c.from);
|
|
638
|
-
return out;
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
const displayName = input.displayName ?? (input.modelInstance ? resolveDisplayName(input.modelClass, input.modelInstance) : null);
|
|
643
|
-
if (displayName !== null) context.display_name = displayName;
|
|
644
|
-
return Object.keys(context).length === 0 ? null : context;
|
|
645
|
-
}
|
|
646
|
-
function filterMeaningfulAttributes(attrs) {
|
|
647
|
-
const out = {};
|
|
648
|
-
for (const key of Object.keys(attrs)) {
|
|
649
|
-
if (!isMeaningfulAttribute(key)) continue;
|
|
650
|
-
const value = attrs[key];
|
|
651
|
-
if (value === null || value === void 0) continue;
|
|
652
|
-
if (!isScalar(value)) continue;
|
|
653
|
-
out[key] = formatForJson(value);
|
|
654
|
-
}
|
|
655
|
-
return Object.keys(out).length === 0 ? null : out;
|
|
656
|
-
}
|
|
657
|
-
function filterMeaningfulChanges(changes) {
|
|
658
|
-
return flattenNestedChanges(changes).filter((c) => {
|
|
659
|
-
if (!isMeaningfulAttribute(c.attribute)) return false;
|
|
660
|
-
if (!isScalar(c.to)) return false;
|
|
661
|
-
if (c.from === void 0) return true;
|
|
662
|
-
if (!isScalar(c.from)) return false;
|
|
663
|
-
return valuesActuallyChanged(c.from, c.to);
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
var MAX_NESTED_DEPTH = 3;
|
|
667
|
-
var MAX_NESTED_LEAVES = 20;
|
|
668
|
-
var MAX_UNKNOWN_FROM_LEAVES = 5;
|
|
669
|
-
function flattenNestedChanges(changes) {
|
|
670
|
-
if (!changes.some((c) => isPlainRecord(c.to) || isPlainRecord(c.from))) return changes;
|
|
671
|
-
const out = [];
|
|
672
|
-
for (const c of changes) {
|
|
673
|
-
if (!isPlainRecord(c.to) && !isPlainRecord(c.from)) {
|
|
674
|
-
out.push(c);
|
|
675
|
-
continue;
|
|
676
|
-
}
|
|
677
|
-
if (!isMeaningfulAttribute(c.attribute)) continue;
|
|
678
|
-
const leaves = [];
|
|
679
|
-
collectLeafChanges(c.attribute, c.from, c.to, 1, leaves);
|
|
680
|
-
const cap = c.from === void 0 ? MAX_UNKNOWN_FROM_LEAVES : MAX_NESTED_LEAVES;
|
|
681
|
-
out.push(...leaves.slice(0, cap).map(scrubLeaf));
|
|
682
|
-
}
|
|
683
|
-
return out;
|
|
684
|
-
}
|
|
685
|
-
function collectLeafChanges(path, from, to, depth, out) {
|
|
686
|
-
if (out.length > MAX_NESTED_LEAVES) return;
|
|
687
|
-
const fromObj = isPlainRecord(from);
|
|
688
|
-
const toObj = isPlainRecord(to);
|
|
689
|
-
if ((fromObj || toObj) && depth <= MAX_NESTED_DEPTH && (fromObj || from == null) && (toObj || to == null)) {
|
|
690
|
-
const f = fromObj ? from : {};
|
|
691
|
-
const t = toObj ? to : {};
|
|
692
|
-
for (const key of /* @__PURE__ */ new Set([...Object.keys(f), ...Object.keys(t)])) {
|
|
693
|
-
const before = from === void 0 ? void 0 : f[key] ?? null;
|
|
694
|
-
collectLeafChanges(`${path}.${key}`, before, t[key] ?? null, depth + 1, out);
|
|
695
|
-
}
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
if (from !== void 0 && sameJson(from, to)) return;
|
|
699
|
-
out.push(from === void 0 ? { attribute: path, to } : { attribute: path, from, to });
|
|
700
|
-
}
|
|
701
|
-
function scrubLeaf(change) {
|
|
702
|
-
const scrub = (v) => typeof v === "string" ? scrubSecretsInText(v) : v;
|
|
703
|
-
const out = { attribute: change.attribute, to: scrub(change.to) };
|
|
704
|
-
if (change.from !== void 0) out.from = scrub(change.from);
|
|
705
|
-
return out;
|
|
706
|
-
}
|
|
707
|
-
function isPlainRecord(value) {
|
|
708
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
709
|
-
const proto = Object.getPrototypeOf(value);
|
|
710
|
-
return proto === Object.prototype || proto === null;
|
|
711
|
-
}
|
|
712
|
-
function sameJson(a, b) {
|
|
713
|
-
if (a === b) return true;
|
|
714
|
-
try {
|
|
715
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
716
|
-
} catch {
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
function isMeaningfulAttribute(name) {
|
|
721
|
-
if (IGNORED_ATTRIBUTES.includes(name)) return false;
|
|
722
|
-
if (isDbSensitive(name)) return false;
|
|
723
|
-
return true;
|
|
724
|
-
}
|
|
725
|
-
function isDbSensitive(name) {
|
|
726
|
-
return matchesSensitiveKey(name, DB_SENSITIVE_PATTERNS);
|
|
727
|
-
}
|
|
728
|
-
function isScalar(value) {
|
|
729
|
-
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint" || value instanceof Date) {
|
|
730
|
-
return true;
|
|
731
|
-
}
|
|
732
|
-
if (isPrismaDecimal(value)) return true;
|
|
733
|
-
if (Buffer.isBuffer?.(value)) return false;
|
|
734
|
-
if (Array.isArray(value)) return value.every((v) => isScalar(v));
|
|
735
|
-
return false;
|
|
736
|
-
}
|
|
737
|
-
function valuesActuallyChanged(from, to) {
|
|
738
|
-
if (from === null && to === null) return false;
|
|
739
|
-
if (from instanceof Date && to instanceof Date) {
|
|
740
|
-
return from.getTime() !== to.getTime();
|
|
741
|
-
}
|
|
742
|
-
return from !== to;
|
|
743
|
-
}
|
|
744
|
-
function formatForJson(value) {
|
|
745
|
-
if (value === null || value === void 0) return value;
|
|
746
|
-
if (value instanceof Date) return value.toISOString();
|
|
747
|
-
if (typeof value === "bigint") return value.toString();
|
|
748
|
-
if (isPrismaDecimal(value)) return Number(value.toString());
|
|
749
|
-
if (Array.isArray(value)) return value.map(formatForJson);
|
|
750
|
-
return value;
|
|
751
|
-
}
|
|
752
|
-
function isPrismaDecimal(value) {
|
|
753
|
-
if (value === null || typeof value !== "object") return false;
|
|
754
|
-
const obj = value;
|
|
755
|
-
return typeof obj.toString === "function" && typeof obj.toFixed === "function" && "d" in obj && "e" in obj && "s" in obj;
|
|
756
|
-
}
|
|
757
|
-
var DISPLAY_NAME_COLUMNS = ["name", "title", "number", "label"];
|
|
758
|
-
var MAX_DISPLAY_NAME_LENGTH = 120;
|
|
759
|
-
function resolveDisplayName(modelClass, instance) {
|
|
760
|
-
try {
|
|
761
|
-
const config = configuration();
|
|
762
|
-
const resolver = config.displayNameFor[modelClass];
|
|
763
|
-
const resolved = applyResolver(resolver, instance);
|
|
764
|
-
if (resolved !== null) return resolved;
|
|
765
|
-
const columns = /* @__PURE__ */ new Map();
|
|
766
|
-
for (const key of Object.keys(instance)) {
|
|
767
|
-
if (isDbSensitive(key)) continue;
|
|
768
|
-
const norm = key.toLowerCase().replace(/_/g, "");
|
|
769
|
-
if (!columns.has(norm)) columns.set(norm, instance[key]);
|
|
770
|
-
}
|
|
771
|
-
const text = (norm) => {
|
|
772
|
-
const value = columns.get(norm);
|
|
773
|
-
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "bigint") {
|
|
774
|
-
return null;
|
|
775
|
-
}
|
|
776
|
-
const str = String(value).trim();
|
|
777
|
-
return str.length > 0 ? str.slice(0, MAX_DISPLAY_NAME_LENGTH) : null;
|
|
778
|
-
};
|
|
779
|
-
for (const column of DISPLAY_NAME_COLUMNS) {
|
|
780
|
-
const value = text(column);
|
|
781
|
-
if (value !== null) return value;
|
|
782
|
-
}
|
|
783
|
-
return text(`${singularNorm(modelClass)}number`);
|
|
784
|
-
} catch {
|
|
785
|
-
}
|
|
786
|
-
return null;
|
|
787
|
-
}
|
|
788
|
-
function singularNorm(modelClass) {
|
|
789
|
-
const norm = modelClass.toLowerCase().replace(/_/g, "");
|
|
790
|
-
if (norm.endsWith("ies")) return norm.slice(0, -3) + "y";
|
|
791
|
-
if (/(ss|us|is)$/.test(norm)) return norm;
|
|
792
|
-
if (/(xes|ches|shes|sses)$/.test(norm)) return norm.slice(0, -2);
|
|
793
|
-
return norm.endsWith("s") ? norm.slice(0, -1) : norm;
|
|
794
|
-
}
|
|
795
|
-
function applyResolver(resolver, instance) {
|
|
796
|
-
if (typeof resolver === "string") {
|
|
797
|
-
const value = instance[resolver];
|
|
798
|
-
if (value !== null && value !== void 0 && String(value).length > 0) {
|
|
799
|
-
return String(value);
|
|
800
|
-
}
|
|
801
|
-
return null;
|
|
802
|
-
}
|
|
803
|
-
if (typeof resolver === "function") {
|
|
804
|
-
try {
|
|
805
|
-
const value = resolver(instance);
|
|
806
|
-
if (typeof value === "string" && value.length > 0) return value;
|
|
807
|
-
if (value !== null && value !== void 0 && String(value).length > 0) {
|
|
808
|
-
return String(value);
|
|
809
|
-
}
|
|
810
|
-
} catch {
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
815
|
-
function describeError(error) {
|
|
816
|
-
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
817
|
-
return String(error);
|
|
818
|
-
}
|
|
1
|
+
import { emitDbEvent } from '../chunk-CE3R7DVB.js';
|
|
2
|
+
import { logger } from '../chunk-C5OSM557.js';
|
|
3
|
+
import '../chunk-SIAA4J6H.js';
|
|
819
4
|
|
|
820
5
|
// src/db/drizzle.ts
|
|
821
6
|
function ezlogsDrizzleLogger(options = {}) {
|
|
@@ -834,7 +19,7 @@ function ezlogsDrizzleLogger(options = {}) {
|
|
|
834
19
|
});
|
|
835
20
|
}
|
|
836
21
|
} catch (error) {
|
|
837
|
-
logger.debug(`drizzle capture failed: ${
|
|
22
|
+
logger.debug(`drizzle capture failed: ${describeError(error)}`);
|
|
838
23
|
} finally {
|
|
839
24
|
if (options.next) {
|
|
840
25
|
try {
|
|
@@ -1032,7 +217,7 @@ function unquote(token) {
|
|
|
1032
217
|
}
|
|
1033
218
|
return token;
|
|
1034
219
|
}
|
|
1035
|
-
function
|
|
220
|
+
function describeError(error) {
|
|
1036
221
|
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
1037
222
|
return String(error);
|
|
1038
223
|
}
|