ezlogs-nextjs 0.4.6 → 0.4.7
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 +23 -3
- package/dist/{chunk-B5ZUQULZ.cjs → chunk-2YCQFLXW.cjs} +3 -0
- package/dist/{chunk-RD47JECJ.js → chunk-343ZGTMH.js} +1 -1
- package/dist/{chunk-2NFJOT6Q.js → chunk-5ZMOWEBY.js} +1 -1
- package/dist/{chunk-IBSNHBUC.js → chunk-7MFKEYDN.js} +3 -0
- package/dist/{chunk-U3IJV5EJ.js → chunk-AXIQTU52.js} +1 -1
- package/dist/{chunk-RMKGMIV2.js → chunk-BE3RCFNP.js} +1 -1
- package/dist/{chunk-H3FC5HMW.cjs → chunk-CHVJ4WPM.cjs} +2 -2
- package/dist/{chunk-M3VBQ5KT.js → chunk-CYAFYBKF.js} +2 -2
- package/dist/{chunk-O7SFYXJC.cjs → chunk-EXGEA4KE.cjs} +12 -12
- package/dist/{chunk-YO6E763S.cjs → chunk-JB4UYCZI.cjs} +5 -5
- package/dist/{chunk-65HRY3PW.cjs → chunk-KOFR5OC3.cjs} +21 -21
- package/dist/{chunk-PK2Z2ABL.js → chunk-Q3HRVWCS.js} +3 -3
- package/dist/{chunk-B3WST6ES.cjs → chunk-UC2KS5EG.cjs} +9 -9
- package/dist/{chunk-DM2EAOSF.cjs → chunk-XWEBKN65.cjs} +4 -4
- package/dist/db/drizzle.cjs +3 -3
- package/dist/db/drizzle.js +2 -2
- package/dist/db/postgres-js.cjs +4 -4
- package/dist/db/postgres-js.js +2 -2
- package/dist/db/prisma.cjs +12 -12
- package/dist/db/prisma.js +2 -2
- package/dist/db/supabase.cjs +11 -11
- package/dist/db/supabase.js +2 -2
- package/dist/index.cjs +121 -106
- package/dist/index.js +21 -6
- package/dist/jobs/bullmq.cjs +17 -17
- package/dist/jobs/bullmq.js +4 -4
- package/dist/jobs/inngest.cjs +154 -50
- package/dist/jobs/inngest.d.cts +6 -6
- package/dist/jobs/inngest.d.ts +6 -6
- package/dist/jobs/inngest.js +144 -40
- package/dist/jobs/supabase-queues.cjs +9 -9
- package/dist/jobs/supabase-queues.js +4 -4
- package/dist/jobs/trigger.cjs +7 -7
- package/dist/jobs/trigger.js +4 -4
- package/dist/jobs/upstash-workflow.cjs +19 -19
- package/dist/jobs/upstash-workflow.js +5 -5
- package/dist/nextjs-plugin/loader.cjs +34 -5
- package/dist/nextjs-plugin/loader.js +34 -5
- package/dist/triggers/index.cjs +16 -16
- package/dist/triggers/index.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,10 @@ npm install ezlogs-nextjs
|
|
|
53
53
|
# or: pnpm add ezlogs-nextjs / bun add ezlogs-nextjs
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
On a Next.js canary or release candidate, npm stops with `ERESOLVE`
|
|
57
|
+
(npm never counts a pre-release as matching the `next >=14` peer range).
|
|
58
|
+
Add `--legacy-peer-deps` to that install; pnpm and bun only warn.
|
|
59
|
+
|
|
56
60
|
### 2. Add `instrumentation.ts`
|
|
57
61
|
|
|
58
62
|
Starts the agent when your server boots. Put it at the project root
|
|
@@ -87,6 +91,21 @@ Auth there is nothing to add. Otherwise add one line to `ezlogs.init`:
|
|
|
87
91
|
import { authJsActor } from "ezlogs-nextjs/actors"; // or nextAuthActor / clerkActor
|
|
88
92
|
```
|
|
89
93
|
|
|
94
|
+
Import your own `auth` / `authOptions` inside the `nodejs` branch, with
|
|
95
|
+
`await import`: `instrumentation.ts` is also built for the Edge runtime,
|
|
96
|
+
and an auth module that loads your database client (Prisma, `pg`) breaks
|
|
97
|
+
that build when imported at the top of the file.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
101
|
+
const { auth } = await import("@/auth"); // or: const { authOptions } = await import("@/lib/auth");
|
|
102
|
+
ezlogs.init({
|
|
103
|
+
projectToken: process.env.EZLOGS_PROJECT_TOKEN!,
|
|
104
|
+
actorFromRequest: authJsActor({ auth }),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
90
109
|
### 3. Wrap your Next config
|
|
91
110
|
|
|
92
111
|
Registers the build-time loaders that auto-wrap your routes and Server
|
|
@@ -340,7 +359,7 @@ made:
|
|
|
340
359
|
| Upstash Workflow | `serve`, `servePagesRouter`, `createWorkflow`, `serveMany` from `@upstash/workflow/nextjs`; `Client` from `@upstash/workflow` |
|
|
341
360
|
| QStash | `Client` from `@upstash/qstash` |
|
|
342
361
|
| BullMQ | `Queue`, `Worker` from `bullmq` |
|
|
343
|
-
| Inngest (v3) | `Inngest` from `inngest` (gets `ezlogsInngestMiddleware()`); wrap a function body in `runInsideInngestCorrelation` to link its writes |
|
|
362
|
+
| Inngest (v3, v4) | `Inngest` from `inngest` (gets `ezlogsInngestMiddleware()`); on v3, wrap a function body in `runInsideInngestCorrelation` to link its writes |
|
|
344
363
|
|
|
345
364
|
A workflow step or QStash delivery is one job event: the agent does not
|
|
346
365
|
also record the POST that delivered it.
|
|
@@ -388,8 +407,9 @@ ezlogs.init({
|
|
|
388
407
|
});
|
|
389
408
|
```
|
|
390
409
|
|
|
391
|
-
The key is the table name
|
|
392
|
-
|
|
410
|
+
The key is the database table name (`users`) and the row has the
|
|
411
|
+
database column names; only the Prisma adapter used without triggers
|
|
412
|
+
keys by the model name (`User`). Without it, the
|
|
393
413
|
record shows by its id.
|
|
394
414
|
|
|
395
415
|
---
|
|
@@ -282,6 +282,7 @@ function createScopedStorage(key = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:def
|
|
|
282
282
|
|
|
283
283
|
// src/correlation.ts
|
|
284
284
|
var CORRELATION_HEADER = "x-ezlogs-correlation-id";
|
|
285
|
+
var CROSS_SERVICE_HEADER = "x-correlation-id";
|
|
285
286
|
var PLATFORM_REQUEST_ID_HEADERS = [
|
|
286
287
|
"x-vercel-id",
|
|
287
288
|
"cf-ray",
|
|
@@ -310,6 +311,8 @@ function resolveCorrelation(headers) {
|
|
|
310
311
|
if (!headers) return generate();
|
|
311
312
|
const ezlogs = safeRead(headers, CORRELATION_HEADER);
|
|
312
313
|
if (ezlogs && isTrustedInboundId(ezlogs)) return ezlogs;
|
|
314
|
+
const crossService = safeRead(headers, CROSS_SERVICE_HEADER);
|
|
315
|
+
if (crossService && isTrustedInboundId(crossService)) return crossService;
|
|
313
316
|
for (const name of PLATFORM_REQUEST_ID_HEADERS) {
|
|
314
317
|
const platformId = safeRead(headers, name);
|
|
315
318
|
if (platformId) return wrapPlatformId(platformId);
|
|
@@ -280,6 +280,7 @@ function createScopedStorage(key = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:def
|
|
|
280
280
|
|
|
281
281
|
// src/correlation.ts
|
|
282
282
|
var CORRELATION_HEADER = "x-ezlogs-correlation-id";
|
|
283
|
+
var CROSS_SERVICE_HEADER = "x-correlation-id";
|
|
283
284
|
var PLATFORM_REQUEST_ID_HEADERS = [
|
|
284
285
|
"x-vercel-id",
|
|
285
286
|
"cf-ray",
|
|
@@ -308,6 +309,8 @@ function resolveCorrelation(headers) {
|
|
|
308
309
|
if (!headers) return generate();
|
|
309
310
|
const ezlogs = safeRead(headers, CORRELATION_HEADER);
|
|
310
311
|
if (ezlogs && isTrustedInboundId(ezlogs)) return ezlogs;
|
|
312
|
+
const crossService = safeRead(headers, CROSS_SERVICE_HEADER);
|
|
313
|
+
if (crossService && isTrustedInboundId(crossService)) return crossService;
|
|
311
314
|
for (const name of PLATFORM_REQUEST_ID_HEADERS) {
|
|
312
315
|
const platformId = safeRead(headers, name);
|
|
313
316
|
if (platformId) return wrapPlatformId(platformId);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { configuration, DEFAULT_EXCLUDED_TABLES, current, getCurrentActor, AUTH_SESSION_TABLE_NAMES, isSessionStoreColumn } from './chunk-
|
|
1
|
+
import { configuration, DEFAULT_EXCLUDED_TABLES, current, getCurrentActor, AUTH_SESSION_TABLE_NAMES, isSessionStoreColumn } from './chunk-7MFKEYDN.js';
|
|
2
2
|
import { logger } from './chunk-FCFVIRQF.js';
|
|
3
3
|
import { __export } from './chunk-SIAA4J6H.js';
|
|
4
4
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2YCQFLXW_cjs = require('./chunk-2YCQFLXW.cjs');
|
|
4
4
|
|
|
5
5
|
// src/job-delivery.ts
|
|
6
|
-
var storage =
|
|
6
|
+
var storage = chunk2YCQFLXW_cjs.createScopedStorage(/* @__PURE__ */ Symbol.for("ezlogs-nextjs:job-delivery"));
|
|
7
7
|
function runWithDeliverySlot(slot, callback) {
|
|
8
8
|
return storage.run(slot, callback);
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { emitDbEvent } from './chunk-
|
|
2
|
-
import { createScopedStorage, runWithCorrelation, getCurrentActor, runWithActorScope, current, generate } from './chunk-
|
|
1
|
+
import { emitDbEvent } from './chunk-AXIQTU52.js';
|
|
2
|
+
import { createScopedStorage, runWithCorrelation, getCurrentActor, runWithActorScope, current, generate } from './chunk-7MFKEYDN.js';
|
|
3
3
|
import { logger } from './chunk-FCFVIRQF.js';
|
|
4
4
|
|
|
5
5
|
// src/triggers/emit-dedup.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkUC2KS5EG_cjs = require('./chunk-UC2KS5EG.cjs');
|
|
4
|
+
var chunk2YCQFLXW_cjs = require('./chunk-2YCQFLXW.cjs');
|
|
5
5
|
var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
|
|
6
6
|
|
|
7
7
|
// src/triggers/emit-dedup.ts
|
|
8
|
-
var storage =
|
|
8
|
+
var storage = chunk2YCQFLXW_cjs.createScopedStorage(
|
|
9
9
|
/* @__PURE__ */ Symbol.for("ezlogs-nextjs:audit-emitted-ids-storage")
|
|
10
10
|
);
|
|
11
11
|
function currentEmittedAuditIds() {
|
|
@@ -103,7 +103,7 @@ async function sweepAuditLog(exec) {
|
|
|
103
103
|
await loadTableMeta(exec, rows);
|
|
104
104
|
for (const row of rows) {
|
|
105
105
|
const correlationId = row.correlation_id ?? correlationForTx(row.txid);
|
|
106
|
-
|
|
106
|
+
chunk2YCQFLXW_cjs.runWithCorrelation(correlationId, () => emitWithRowActor(row));
|
|
107
107
|
}
|
|
108
108
|
return rows.length;
|
|
109
109
|
} catch (err) {
|
|
@@ -216,9 +216,9 @@ function emitAuditRows(rows) {
|
|
|
216
216
|
}
|
|
217
217
|
function emitWithRowActor(row) {
|
|
218
218
|
const stored = row.actor_id || null;
|
|
219
|
-
const claimer =
|
|
219
|
+
const claimer = chunk2YCQFLXW_cjs.getCurrentActor();
|
|
220
220
|
const actor = stored ? claimer?.id === stored ? claimer : { id: stored } : null;
|
|
221
|
-
|
|
221
|
+
chunk2YCQFLXW_cjs.runWithActorScope(() => emitOne(row), actor);
|
|
222
222
|
}
|
|
223
223
|
var inFlightFlushes = /* @__PURE__ */ new Set();
|
|
224
224
|
var IN_FLIGHT_MAX_MS = 5e3;
|
|
@@ -245,7 +245,7 @@ function flushAuditLog(exec, options = {}) {
|
|
|
245
245
|
}
|
|
246
246
|
async function readAndEmit(exec, options) {
|
|
247
247
|
if (!exec) return;
|
|
248
|
-
const correlationId =
|
|
248
|
+
const correlationId = chunk2YCQFLXW_cjs.current();
|
|
249
249
|
if (!correlationId) return;
|
|
250
250
|
lastRequestFlushAt = Date.now();
|
|
251
251
|
const rows = await readAuditRows(exec, correlationId, options.since ?? null);
|
|
@@ -388,11 +388,11 @@ function emitFresh(rows) {
|
|
|
388
388
|
emitAuditRows(fresh);
|
|
389
389
|
}
|
|
390
390
|
function correlationForTx(txid) {
|
|
391
|
-
if (!txid) return
|
|
391
|
+
if (!txid) return chunk2YCQFLXW_cjs.generate();
|
|
392
392
|
let id = txCorrelation.get(txid);
|
|
393
393
|
if (!id) {
|
|
394
394
|
if (txCorrelation.size >= 1e3) txCorrelation.clear();
|
|
395
|
-
id =
|
|
395
|
+
id = chunk2YCQFLXW_cjs.generate();
|
|
396
396
|
txCorrelation.set(txid, id);
|
|
397
397
|
}
|
|
398
398
|
return id;
|
|
@@ -413,7 +413,7 @@ function emitOne(row) {
|
|
|
413
413
|
const newRow = withUtcTimestamps(coerceJsonb(row.new_row), naive);
|
|
414
414
|
const related = row.resource_id === null ? relatedResourceIds(row.table_name, newRow ?? oldRow ?? {}) : null;
|
|
415
415
|
if (op === "create" && newRow) {
|
|
416
|
-
|
|
416
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
417
417
|
modelClass: row.table_name,
|
|
418
418
|
operation: "create",
|
|
419
419
|
resourceId: row.resource_id,
|
|
@@ -431,7 +431,7 @@ function emitOne(row) {
|
|
|
431
431
|
if (changes.length === 0) {
|
|
432
432
|
return;
|
|
433
433
|
}
|
|
434
|
-
|
|
434
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
435
435
|
modelClass: row.table_name,
|
|
436
436
|
operation: "update",
|
|
437
437
|
resourceId: row.resource_id,
|
|
@@ -447,7 +447,7 @@ function emitOne(row) {
|
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
449
449
|
if (op === "destroy" && oldRow) {
|
|
450
|
-
|
|
450
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
451
451
|
modelClass: row.table_name,
|
|
452
452
|
operation: "destroy",
|
|
453
453
|
resourceId: row.resource_id,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2YCQFLXW_cjs = require('./chunk-2YCQFLXW.cjs');
|
|
4
4
|
var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
|
|
5
5
|
|
|
6
6
|
// src/triggers/context.ts
|
|
7
7
|
function getDatabaseContext() {
|
|
8
|
-
const actor =
|
|
8
|
+
const actor = chunk2YCQFLXW_cjs.getCurrentActor();
|
|
9
9
|
return {
|
|
10
10
|
actorId: actor && actor.id ? actor.id : null,
|
|
11
|
-
correlationId:
|
|
11
|
+
correlationId: chunk2YCQFLXW_cjs.current()
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
async function applyDatabaseContext(exec) {
|
|
15
|
-
const actor =
|
|
16
|
-
const correlationId =
|
|
15
|
+
const actor = chunk2YCQFLXW_cjs.getCurrentActor();
|
|
16
|
+
const correlationId = chunk2YCQFLXW_cjs.current();
|
|
17
17
|
if (!actor && !correlationId) return;
|
|
18
18
|
try {
|
|
19
19
|
if (actor && actor.id) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkEXGEA4KE_cjs = require('./chunk-EXGEA4KE.cjs');
|
|
4
|
+
var chunkUC2KS5EG_cjs = require('./chunk-UC2KS5EG.cjs');
|
|
5
|
+
var chunk2YCQFLXW_cjs = require('./chunk-2YCQFLXW.cjs');
|
|
6
6
|
var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
|
|
7
7
|
|
|
8
8
|
// src/jobs/shared.ts
|
|
@@ -12,7 +12,7 @@ var ACTOR_TOKEN = /^a([0-9a-f]{2,128})_([0-9a-f]{16})$/;
|
|
|
12
12
|
var ACTOR_ID_MAX_BYTES = 64;
|
|
13
13
|
function emitJobEvent(input) {
|
|
14
14
|
try {
|
|
15
|
-
const config =
|
|
15
|
+
const config = chunk2YCQFLXW_cjs.configuration();
|
|
16
16
|
if (!config.captureJobs) return;
|
|
17
17
|
if (config.allExcludedJobClasses().includes(input.jobClass)) return;
|
|
18
18
|
const sourceData = compactJobSourceData({
|
|
@@ -23,24 +23,24 @@ function emitJobEvent(input) {
|
|
|
23
23
|
step: input.step ?? null,
|
|
24
24
|
arguments: jobArguments(input.payload)
|
|
25
25
|
});
|
|
26
|
-
const event =
|
|
26
|
+
const event = chunkUC2KS5EG_cjs.build({
|
|
27
27
|
source_type: "background_job",
|
|
28
28
|
source_data: sourceData,
|
|
29
29
|
outcome: input.outcome,
|
|
30
|
-
correlation_id: input.correlationId ??
|
|
30
|
+
correlation_id: input.correlationId ?? chunk2YCQFLXW_cjs.current(),
|
|
31
31
|
resource_ids: [],
|
|
32
32
|
context: null,
|
|
33
33
|
duration_ms: input.durationMs ?? null,
|
|
34
34
|
error_message: input.errorMessage ?? null,
|
|
35
35
|
timestamp: input.startedAt
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
chunkUC2KS5EG_cjs.pushEvent(event);
|
|
38
38
|
} catch (error) {
|
|
39
39
|
chunkTWTG5ILJ_cjs.logger.debug(`job emit failed: ${describeError(error)}`);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
async function runJobWithCapture(meta, work) {
|
|
43
|
-
const correlationId = meta.correlationId ??
|
|
43
|
+
const correlationId = meta.correlationId ?? chunk2YCQFLXW_cjs.generate();
|
|
44
44
|
const body = async () => {
|
|
45
45
|
const startedAt = /* @__PURE__ */ new Date();
|
|
46
46
|
const startMs = startedAt.getTime();
|
|
@@ -84,13 +84,13 @@ async function runJobWithCapture(meta, work) {
|
|
|
84
84
|
throw error;
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
const scoped = () => body().finally(
|
|
88
|
-
return
|
|
87
|
+
const scoped = () => body().finally(chunk2YCQFLXW_cjs.endCorrelationScope);
|
|
88
|
+
return chunk2YCQFLXW_cjs.runWithCorrelation(correlationId, () => chunk2YCQFLXW_cjs.runWithActorScope(scoped, meta.actor ?? null));
|
|
89
89
|
}
|
|
90
90
|
var JOB_FLUSH_SKEW_MS = 500;
|
|
91
91
|
async function flushJobAuditLog(startedAt) {
|
|
92
92
|
try {
|
|
93
|
-
await
|
|
93
|
+
await chunkEXGEA4KE_cjs.flushAuditLog(chunk2YCQFLXW_cjs.configuration().databaseReader, {
|
|
94
94
|
since: new Date(startedAt.getTime() - JOB_FLUSH_SKEW_MS)
|
|
95
95
|
});
|
|
96
96
|
} catch (error) {
|
|
@@ -99,16 +99,16 @@ async function flushJobAuditLog(startedAt) {
|
|
|
99
99
|
}
|
|
100
100
|
function jobArguments(payload) {
|
|
101
101
|
if (payload === null || payload === void 0) return null;
|
|
102
|
-
const patterns =
|
|
103
|
-
if (Array.isArray(payload)) return payload.length === 0 ? null :
|
|
102
|
+
const patterns = chunk2YCQFLXW_cjs.configuration().excludedGraphqlVariableKeys;
|
|
103
|
+
if (Array.isArray(payload)) return payload.length === 0 ? null : chunkUC2KS5EG_cjs.sanitizeArgs(payload, patterns);
|
|
104
104
|
if (typeof payload === "object" && Object.getPrototypeOf(payload) === Object.prototype) {
|
|
105
105
|
const rest = { ...payload };
|
|
106
106
|
delete rest[CORRELATION_PAYLOAD_KEY];
|
|
107
107
|
delete rest[ACTOR_PAYLOAD_KEY];
|
|
108
108
|
if (Object.keys(rest).length === 0) return null;
|
|
109
|
-
return
|
|
109
|
+
return chunkUC2KS5EG_cjs.sanitizeArgs([rest], patterns)[0];
|
|
110
110
|
}
|
|
111
|
-
return
|
|
111
|
+
return chunkUC2KS5EG_cjs.sanitizeArgs([payload], patterns);
|
|
112
112
|
}
|
|
113
113
|
function extractCorrelationFromPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
|
|
114
114
|
if (payload === null || typeof payload !== "object") return null;
|
|
@@ -118,7 +118,7 @@ function extractCorrelationFromPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
|
|
|
118
118
|
function stampCorrelationOnPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
|
|
119
119
|
if (!payload || typeof payload !== "object") return payload;
|
|
120
120
|
if (typeof payload[key] === "string" && payload[key]) return payload;
|
|
121
|
-
const id =
|
|
121
|
+
const id = chunk2YCQFLXW_cjs.current();
|
|
122
122
|
if (!id) return payload;
|
|
123
123
|
return { ...payload, [key]: id };
|
|
124
124
|
}
|
|
@@ -136,10 +136,10 @@ function describeError(error) {
|
|
|
136
136
|
}
|
|
137
137
|
function pendingActorToken(correlationId) {
|
|
138
138
|
try {
|
|
139
|
-
const actor =
|
|
139
|
+
const actor = chunk2YCQFLXW_cjs.getCurrentActor();
|
|
140
140
|
if (!actor || actor.kind && actor.kind !== "human" || actor.principal) return null;
|
|
141
141
|
const actorId = actor.id;
|
|
142
|
-
const key =
|
|
142
|
+
const key = chunk2YCQFLXW_cjs.configuration().projectToken;
|
|
143
143
|
if (!actorId || !key) return null;
|
|
144
144
|
const bytes = new TextEncoder().encode(actorId);
|
|
145
145
|
if (bytes.length > ACTOR_ID_MAX_BYTES) return null;
|
|
@@ -167,8 +167,8 @@ ${actorId}`;
|
|
|
167
167
|
var tokenMemo = /* @__PURE__ */ new Map();
|
|
168
168
|
function signedActorToken(correlationId) {
|
|
169
169
|
const now = pendingActorToken(correlationId);
|
|
170
|
-
if (now ||
|
|
171
|
-
return
|
|
170
|
+
if (now || chunk2YCQFLXW_cjs.getCurrentActor() || !chunk2YCQFLXW_cjs.configuration().actorFromSupabase) return now;
|
|
171
|
+
return chunk2YCQFLXW_cjs.maybeExtractSupabaseActor().then(
|
|
172
172
|
() => pendingActorToken(correlationId),
|
|
173
173
|
() => null
|
|
174
174
|
);
|
|
@@ -179,7 +179,7 @@ async function actorToken(correlationId) {
|
|
|
179
179
|
async function readActorToken(token, correlationId) {
|
|
180
180
|
try {
|
|
181
181
|
const match = typeof token === "string" ? ACTOR_TOKEN.exec(token) : null;
|
|
182
|
-
const key =
|
|
182
|
+
const key = chunk2YCQFLXW_cjs.configuration().projectToken;
|
|
183
183
|
if (!match || !key || match[1].length % 2 !== 0) return null;
|
|
184
184
|
const bytes = new Uint8Array(match[1].match(/../g).map((h) => parseInt(h, 16)));
|
|
185
185
|
const actorId = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { flushAuditLog } from './chunk-
|
|
2
|
-
import { build, pushEvent, sanitizeArgs } from './chunk-
|
|
3
|
-
import { configuration, current, generate, runWithCorrelation, runWithActorScope, getCurrentActor, maybeExtractSupabaseActor, endCorrelationScope } from './chunk-
|
|
1
|
+
import { flushAuditLog } from './chunk-CYAFYBKF.js';
|
|
2
|
+
import { build, pushEvent, sanitizeArgs } from './chunk-AXIQTU52.js';
|
|
3
|
+
import { configuration, current, generate, runWithCorrelation, runWithActorScope, getCurrentActor, maybeExtractSupabaseActor, endCorrelationScope } from './chunk-7MFKEYDN.js';
|
|
4
4
|
import { logger } from './chunk-FCFVIRQF.js';
|
|
5
5
|
|
|
6
6
|
// src/jobs/shared.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2YCQFLXW_cjs = require('./chunk-2YCQFLXW.cjs');
|
|
4
4
|
var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
|
|
5
5
|
var chunkZDSQYCYV_cjs = require('./chunk-ZDSQYCYV.cjs');
|
|
6
6
|
|
|
@@ -50,7 +50,7 @@ function clearBuffer() {
|
|
|
50
50
|
}
|
|
51
51
|
function maxSize() {
|
|
52
52
|
try {
|
|
53
|
-
return
|
|
53
|
+
return chunk2YCQFLXW_cjs.configuration().bufferSize;
|
|
54
54
|
} catch {
|
|
55
55
|
return 1e4;
|
|
56
56
|
}
|
|
@@ -541,10 +541,10 @@ var DB_SENSITIVE_PATTERNS = Object.freeze([
|
|
|
541
541
|
]);
|
|
542
542
|
function emitDbEvent(input) {
|
|
543
543
|
try {
|
|
544
|
-
const config =
|
|
544
|
+
const config = chunk2YCQFLXW_cjs.configuration();
|
|
545
545
|
if (!config.captureDb) return;
|
|
546
546
|
if (config.excludedTables.includes(input.modelClass)) return;
|
|
547
|
-
if (
|
|
547
|
+
if (chunk2YCQFLXW_cjs.DEFAULT_EXCLUDED_TABLES.includes(input.modelClass) && !(input._fromTrigger && isBusinessSessionRow(input.modelClass, input.modelInstance))) {
|
|
548
548
|
return;
|
|
549
549
|
}
|
|
550
550
|
if (config.databaseReader && !input._fromTrigger) {
|
|
@@ -567,7 +567,7 @@ function emitDbEvent(input) {
|
|
|
567
567
|
operation: input.operation
|
|
568
568
|
},
|
|
569
569
|
outcome: "success",
|
|
570
|
-
correlation_id:
|
|
570
|
+
correlation_id: chunk2YCQFLXW_cjs.current(),
|
|
571
571
|
resource_ids: resourceIdStr === null ? [...related] : [{ resource_type: input.modelClass, resource_id: resourceIdStr }],
|
|
572
572
|
context,
|
|
573
573
|
duration_ms: null,
|
|
@@ -580,7 +580,7 @@ function emitDbEvent(input) {
|
|
|
580
580
|
}
|
|
581
581
|
function buildContext(input) {
|
|
582
582
|
const context = {};
|
|
583
|
-
const actor =
|
|
583
|
+
const actor = chunk2YCQFLXW_cjs.getCurrentActor();
|
|
584
584
|
if (actor) context.actor = actor;
|
|
585
585
|
if ((input.operation === "create" || input.operation === "destroy") && input.initialAttributes) {
|
|
586
586
|
const filtered = filterMeaningfulAttributes(input.initialAttributes);
|
|
@@ -735,15 +735,15 @@ function isPrismaDecimal(value) {
|
|
|
735
735
|
return typeof obj.toString === "function" && typeof obj.toFixed === "function" && "d" in obj && "e" in obj && "s" in obj;
|
|
736
736
|
}
|
|
737
737
|
function isBusinessSessionRow(table, row) {
|
|
738
|
-
if (!
|
|
738
|
+
if (!chunk2YCQFLXW_cjs.AUTH_SESSION_TABLE_NAMES.test(table) || /verif/i.test(table) || !row) return false;
|
|
739
739
|
const columns = Object.keys(row);
|
|
740
|
-
return columns.length > 0 && !columns.some(
|
|
740
|
+
return columns.length > 0 && !columns.some(chunk2YCQFLXW_cjs.isSessionStoreColumn);
|
|
741
741
|
}
|
|
742
742
|
var DISPLAY_NAME_COLUMNS = ["name", "title", "number", "label"];
|
|
743
743
|
var MAX_DISPLAY_NAME_LENGTH = 120;
|
|
744
744
|
function resolveDisplayName(modelClass, instance) {
|
|
745
745
|
try {
|
|
746
|
-
const config =
|
|
746
|
+
const config = chunk2YCQFLXW_cjs.configuration();
|
|
747
747
|
const resolver = config.displayNameFor[modelClass];
|
|
748
748
|
const resolved = applyResolver(resolver, instance);
|
|
749
749
|
if (resolved !== null) return resolved;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2YCQFLXW_cjs = require('./chunk-2YCQFLXW.cjs');
|
|
4
4
|
var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
|
|
5
5
|
|
|
6
6
|
// src/triggers/patch-pg.ts
|
|
@@ -28,7 +28,7 @@ function patchPgClient(pgModule) {
|
|
|
28
28
|
function patchPgPool(Pool) {
|
|
29
29
|
const proto = Pool?.prototype;
|
|
30
30
|
if (!proto || typeof proto.connect !== "function" || proto._ezlogsPoolPatched) return;
|
|
31
|
-
const captureAndRun =
|
|
31
|
+
const captureAndRun = chunk2YCQFLXW_cjs.makeAsyncContextCapture();
|
|
32
32
|
if (!captureAndRun) return;
|
|
33
33
|
const originalConnect = proto.connect;
|
|
34
34
|
proto.connect = function patchedConnect(...args) {
|
|
@@ -95,10 +95,10 @@ function runPatchedQuery(client, original, config, values, callback) {
|
|
|
95
95
|
return wrapInTx(client, original, config, values, callback, ctx);
|
|
96
96
|
}
|
|
97
97
|
function snapshotContext() {
|
|
98
|
-
const actor =
|
|
98
|
+
const actor = chunk2YCQFLXW_cjs.getCurrentActor();
|
|
99
99
|
return {
|
|
100
100
|
actorId: actor && actor.id ? actor.id : null,
|
|
101
|
-
correlationId:
|
|
101
|
+
correlationId: chunk2YCQFLXW_cjs.current()
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
async function injectAndRun(client, original, config, values, callback, ctx) {
|
package/dist/db/drizzle.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkUC2KS5EG_cjs = require('../chunk-UC2KS5EG.cjs');
|
|
4
|
+
require('../chunk-2YCQFLXW.cjs');
|
|
5
5
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
6
6
|
require('../chunk-ZDSQYCYV.cjs');
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ function ezlogsDrizzleLogger(options = {}) {
|
|
|
14
14
|
if (parsed) {
|
|
15
15
|
const resourceId = parsed.operation === "create" ? null : extractResourceIdFromSimpleWhere(query, params);
|
|
16
16
|
const changes = parsed.operation === "update" ? extractSetChangesFromUpdate(query, params) : null;
|
|
17
|
-
|
|
17
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
18
18
|
modelClass: parsed.table,
|
|
19
19
|
operation: parsed.operation,
|
|
20
20
|
resourceId,
|
package/dist/db/drizzle.js
CHANGED
package/dist/db/postgres-js.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkJB4UYCZI_cjs = require('../chunk-JB4UYCZI.cjs');
|
|
4
|
+
var chunk2YCQFLXW_cjs = require('../chunk-2YCQFLXW.cjs');
|
|
5
5
|
require('../chunk-TWTG5ILJ.cjs');
|
|
6
6
|
require('../chunk-ZDSQYCYV.cjs');
|
|
7
7
|
|
|
@@ -22,8 +22,8 @@ function wrapPostgresJs(sql) {
|
|
|
22
22
|
return proxy;
|
|
23
23
|
}
|
|
24
24
|
function tagContext() {
|
|
25
|
-
if (
|
|
26
|
-
const ctx =
|
|
25
|
+
if (chunk2YCQFLXW_cjs.configuration().databaseReader == null) return null;
|
|
26
|
+
const ctx = chunkJB4UYCZI_cjs.getDatabaseContext();
|
|
27
27
|
return ctx.correlationId ? ctx : null;
|
|
28
28
|
}
|
|
29
29
|
function setContext(tx, ctx) {
|
package/dist/db/postgres-js.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getDatabaseContext } from '../chunk-
|
|
2
|
-
import { configuration } from '../chunk-
|
|
1
|
+
import { getDatabaseContext } from '../chunk-343ZGTMH.js';
|
|
2
|
+
import { configuration } from '../chunk-7MFKEYDN.js';
|
|
3
3
|
import '../chunk-FCFVIRQF.js';
|
|
4
4
|
import '../chunk-SIAA4J6H.js';
|
|
5
5
|
|
package/dist/db/prisma.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkUC2KS5EG_cjs = require('../chunk-UC2KS5EG.cjs');
|
|
4
|
+
var chunk2YCQFLXW_cjs = require('../chunk-2YCQFLXW.cjs');
|
|
5
5
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
6
6
|
require('../chunk-ZDSQYCYV.cjs');
|
|
7
7
|
|
|
@@ -62,7 +62,7 @@ async function runTagged(client, ctx) {
|
|
|
62
62
|
if (!shouldTag(client, ctx)) return ctx.query(ctx.args);
|
|
63
63
|
try {
|
|
64
64
|
const results = await client.$transaction([
|
|
65
|
-
client.$executeRawUnsafe(SET_CONTEXT_SQL,
|
|
65
|
+
client.$executeRawUnsafe(SET_CONTEXT_SQL, chunk2YCQFLXW_cjs.current(), chunk2YCQFLXW_cjs.getCurrentActor()?.id ?? ""),
|
|
66
66
|
ctx.query(ctx.args)
|
|
67
67
|
]);
|
|
68
68
|
return results[1];
|
|
@@ -81,12 +81,12 @@ function _resetPrismaTaggingForTests() {
|
|
|
81
81
|
}
|
|
82
82
|
function shouldTag(client, ctx) {
|
|
83
83
|
if (!client || taggingDisabled.has(client)) return false;
|
|
84
|
-
if (
|
|
84
|
+
if (chunk2YCQFLXW_cjs.configuration().databaseReader == null) return false;
|
|
85
85
|
if (!isPostgresClient(client)) return false;
|
|
86
86
|
if (typeof client.$transaction !== "function" || typeof client.$executeRawUnsafe !== "function") {
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
89
|
-
if (!
|
|
89
|
+
if (!chunk2YCQFLXW_cjs.current()) return false;
|
|
90
90
|
const params = ctx.__internalParams;
|
|
91
91
|
return params != null && !params.transaction;
|
|
92
92
|
}
|
|
@@ -112,7 +112,7 @@ function recordPrismaOperation(ctx, result, table) {
|
|
|
112
112
|
const dbOperation = OPERATION_TO_DB_OPERATION[ctx.operation];
|
|
113
113
|
if (!dbOperation) return;
|
|
114
114
|
if (isBatchResult(result)) {
|
|
115
|
-
|
|
115
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
116
116
|
modelClass: ctx.model,
|
|
117
117
|
table,
|
|
118
118
|
operation: dbOperation,
|
|
@@ -139,7 +139,7 @@ function recordPrismaOperation(ctx, result, table) {
|
|
|
139
139
|
}
|
|
140
140
|
function emitSingleRowEvent(ctx, dbOperation, row, table) {
|
|
141
141
|
if (!isPlainObject(row)) {
|
|
142
|
-
|
|
142
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
143
143
|
modelClass: ctx.model,
|
|
144
144
|
table,
|
|
145
145
|
operation: dbOperation,
|
|
@@ -149,9 +149,9 @@ function emitSingleRowEvent(ctx, dbOperation, row, table) {
|
|
|
149
149
|
}
|
|
150
150
|
const rowObj = row;
|
|
151
151
|
const resourceId = rowObj.id ?? null;
|
|
152
|
-
const displayName =
|
|
152
|
+
const displayName = chunkUC2KS5EG_cjs.resolveDisplayName(ctx.model, rowObj);
|
|
153
153
|
if (dbOperation === "create") {
|
|
154
|
-
|
|
154
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
155
155
|
modelClass: ctx.model,
|
|
156
156
|
table,
|
|
157
157
|
operation: "create",
|
|
@@ -166,7 +166,7 @@ function emitSingleRowEvent(ctx, dbOperation, row, table) {
|
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
if (dbOperation === "update") {
|
|
169
|
-
|
|
169
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
170
170
|
modelClass: ctx.model,
|
|
171
171
|
table,
|
|
172
172
|
operation: "update",
|
|
@@ -177,7 +177,7 @@ function emitSingleRowEvent(ctx, dbOperation, row, table) {
|
|
|
177
177
|
});
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
chunkUC2KS5EG_cjs.emitDbEvent({
|
|
181
181
|
modelClass: ctx.model,
|
|
182
182
|
table,
|
|
183
183
|
operation: "destroy",
|
|
@@ -268,7 +268,7 @@ function patchPrismaClient(prisma, adapter) {
|
|
|
268
268
|
if (prisma[EZLOGS_PRISMA_BRAND] === true) {
|
|
269
269
|
return prisma;
|
|
270
270
|
}
|
|
271
|
-
const captureAndRun =
|
|
271
|
+
const captureAndRun = chunk2YCQFLXW_cjs.makeAsyncContextCapture();
|
|
272
272
|
if (!captureAndRun) {
|
|
273
273
|
chunkTWTG5ILJ_cjs.logger.debug(
|
|
274
274
|
"patchPrismaClient: AsyncLocalStorage.snapshot() unavailable; skipping ALS bind, applying ezlogsPrisma() only."
|
package/dist/db/prisma.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { emitDbEvent, resolveDisplayName } from '../chunk-
|
|
2
|
-
import { current, getCurrentActor, configuration, makeAsyncContextCapture } from '../chunk-
|
|
1
|
+
import { emitDbEvent, resolveDisplayName } from '../chunk-AXIQTU52.js';
|
|
2
|
+
import { current, getCurrentActor, configuration, makeAsyncContextCapture } from '../chunk-7MFKEYDN.js';
|
|
3
3
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
4
4
|
import '../chunk-SIAA4J6H.js';
|
|
5
5
|
|