ezlogs-nextjs 0.4.1 → 0.4.2

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.
Files changed (42) hide show
  1. package/README.md +13 -8
  2. package/dist/actors/index.d.cts +1 -1
  3. package/dist/actors/index.d.ts +1 -1
  4. package/dist/{chunk-B7SH6V7M.js → chunk-GI6BM4MR.js} +2 -1
  5. package/dist/{chunk-VROC3BO3.cjs → chunk-GMHOUAKD.cjs} +12 -12
  6. package/dist/{chunk-2X6IZ2JX.js → chunk-MHBS5FEP.js} +2 -2
  7. package/dist/{chunk-ULFJOPQ2.cjs → chunk-MMLQXSSD.cjs} +2 -1
  8. package/dist/{chunk-SH5NGIX3.js → chunk-NINIAL7M.js} +1 -1
  9. package/dist/{chunk-LMG2SNTF.cjs → chunk-NX4EL7BY.cjs} +4 -4
  10. package/dist/{chunk-ZSFJ3UQV.cjs → chunk-PS4U2GFJ.cjs} +5 -5
  11. package/dist/{chunk-GILAKFP7.cjs → chunk-R6IWVTX3.cjs} +21 -21
  12. package/dist/{chunk-KCCKURJW.js → chunk-U22T7QYY.js} +3 -3
  13. package/dist/{chunk-DLUZRHHW.js → chunk-YMIGZYFH.js} +1 -1
  14. package/dist/{chunk-OJKWSUMK.cjs → chunk-YXZZNZG6.cjs} +9 -9
  15. package/dist/{chunk-H4K5QDXE.js → chunk-Z2TM3LGG.js} +1 -1
  16. package/dist/{configuration-Pshqvpkk.d.cts → configuration-CJ5yKVlP.d.cts} +2 -1
  17. package/dist/{configuration-Pshqvpkk.d.ts → configuration-CJ5yKVlP.d.ts} +2 -1
  18. package/dist/db/drizzle.cjs +3 -3
  19. package/dist/db/drizzle.js +2 -2
  20. package/dist/db/postgres-js.cjs +4 -4
  21. package/dist/db/postgres-js.js +2 -2
  22. package/dist/db/prisma.cjs +12 -12
  23. package/dist/db/prisma.js +2 -2
  24. package/dist/db/supabase.cjs +11 -11
  25. package/dist/db/supabase.js +2 -2
  26. package/dist/index.cjs +100 -101
  27. package/dist/index.d.cts +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +6 -7
  30. package/dist/jobs/bullmq.cjs +16 -16
  31. package/dist/jobs/bullmq.js +4 -4
  32. package/dist/jobs/inngest.cjs +17 -17
  33. package/dist/jobs/inngest.js +4 -4
  34. package/dist/jobs/supabase-queues.cjs +9 -9
  35. package/dist/jobs/supabase-queues.js +4 -4
  36. package/dist/jobs/trigger.cjs +7 -7
  37. package/dist/jobs/trigger.js +4 -4
  38. package/dist/jobs/upstash-workflow.cjs +15 -15
  39. package/dist/jobs/upstash-workflow.js +4 -4
  40. package/dist/triggers/index.cjs +16 -16
  41. package/dist/triggers/index.js +5 -5
  42. package/package.json +1 -1
package/README.md CHANGED
@@ -46,13 +46,15 @@ import { ezlogs } from "ezlogs-nextjs";
46
46
  export async function register() {
47
47
  if (process.env.NEXT_RUNTIME === "nodejs") {
48
48
  ezlogs.init({
49
- serverUrl: process.env.EZLOGS_SERVER_URL!,
50
49
  projectToken: process.env.EZLOGS_PROJECT_TOKEN!,
51
50
  });
52
51
  }
53
52
  }
54
53
  ```
55
54
 
55
+ `serverUrl` is optional: it defaults to `process.env.EZLOGS_SERVER_URL`
56
+ if set, otherwise `https://app.ezlogs.io`. Set it only if you self-host.
57
+
56
58
  ### 2. Wrap your Next config
57
59
 
58
60
  `withEzlogsConfig(...)` is a transparent wrapper around your existing
@@ -110,7 +112,6 @@ yours and add to it:
110
112
 
111
113
  ```bash
112
114
  # .env.local
113
- EZLOGS_SERVER_URL=https://app.ezlogs.io
114
115
  EZLOGS_PROJECT_TOKEN=ezl_your_api_key_here
115
116
  ```
116
117
 
@@ -121,12 +122,16 @@ per server process, at the default log level):
121
122
  [ezlogs] capturing → app.ezlogs.io (key ezl_a1b2c3d4…)
122
123
  ```
123
124
 
124
- If `serverUrl` or `projectToken` is missing you get
125
- `[ezlogs] not capturing: … missing` instead. Call an API route or
126
- submit a Server Action; events appear in your EZLogs dashboard within a
127
- few seconds. Page views are only recorded when the app has a
128
- `middleware.ts` (or `proxy.ts` on Next 16), so opening a page is not a
129
- reliable check.
125
+ If `projectToken` is missing you get this instead:
126
+
127
+ ```
128
+ [ezlogs] not capturing: projectToken missing in ezlogs.init() (check EZLOGS_PROJECT_TOKEN)
129
+ ```
130
+
131
+ Call an API route or submit a Server Action; events appear in your
132
+ EZLogs dashboard within a few seconds. Page views are only recorded when
133
+ the app has a `middleware.ts` (or `proxy.ts` on Next 16), so opening a
134
+ page is not a reliable check.
130
135
 
131
136
  Sending to a local EZLogs server over plain `http://` (development)?
132
137
  Events are still sent, but the agent warns on every start; pass
@@ -1,4 +1,4 @@
1
- import { a as ActorFromRequest } from '../configuration-Pshqvpkk.cjs';
1
+ import { a as ActorFromRequest } from '../configuration-CJ5yKVlP.cjs';
2
2
 
3
3
  /**
4
4
  * Returns an `ActorFromRequest` that pulls the current user from
@@ -1,4 +1,4 @@
1
- import { a as ActorFromRequest } from '../configuration-Pshqvpkk.js';
1
+ import { a as ActorFromRequest } from '../configuration-CJ5yKVlP.js';
2
2
 
3
3
  /**
4
4
  * Returns an `ActorFromRequest` that pulls the current user from
@@ -76,6 +76,7 @@ function isSessionStoreColumn(column) {
76
76
  }
77
77
  var DEFAULT_EXCLUDED_JOB_CLASSES = Object.freeze([]);
78
78
  var DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS = Object.freeze(["IntrospectionQuery", "__*"]);
79
+ var DEFAULT_SERVER_URL = "https://app.ezlogs.io";
79
80
  var Configuration = class {
80
81
  serverUrl = null;
81
82
  projectToken = null;
@@ -116,7 +117,7 @@ var Configuration = class {
116
117
  */
117
118
  triggerTrackedTables = null;
118
119
  apply(options) {
119
- this.serverUrl = options.serverUrl;
120
+ this.serverUrl = options.serverUrl || (typeof process !== "undefined" ? process.env?.EZLOGS_SERVER_URL : void 0) || DEFAULT_SERVER_URL;
120
121
  this.projectToken = options.projectToken;
121
122
  if (options.captureHttp !== void 0) this.captureHttp = options.captureHttp;
122
123
  if (options.captureDb !== void 0) this.captureDb = options.captureDb;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkOJKWSUMK_cjs = require('./chunk-OJKWSUMK.cjs');
4
- var chunkULFJOPQ2_cjs = require('./chunk-ULFJOPQ2.cjs');
3
+ var chunkYXZZNZG6_cjs = require('./chunk-YXZZNZG6.cjs');
4
+ var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.cjs');
5
5
  var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
6
6
 
7
7
  // src/triggers/emit-dedup.ts
8
- var storage = chunkULFJOPQ2_cjs.createScopedStorage(
8
+ var storage = chunkMMLQXSSD_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
- chunkULFJOPQ2_cjs.runWithCorrelation(correlationId, () => emitWithRowActor(row));
106
+ chunkMMLQXSSD_cjs.runWithCorrelation(correlationId, () => emitWithRowActor(row));
107
107
  }
108
108
  return rows.length;
109
109
  } catch (err) {
@@ -216,13 +216,13 @@ function emitAuditRows(rows) {
216
216
  }
217
217
  function emitWithRowActor(row) {
218
218
  const stored = row.actor_id || null;
219
- const claimer = chunkULFJOPQ2_cjs.getCurrentActor();
219
+ const claimer = chunkMMLQXSSD_cjs.getCurrentActor();
220
220
  const actor = stored ? claimer?.id === stored ? claimer : { id: stored } : null;
221
- chunkULFJOPQ2_cjs.runWithActorScope(() => emitOne(row), actor);
221
+ chunkMMLQXSSD_cjs.runWithActorScope(() => emitOne(row), actor);
222
222
  }
223
223
  async function flushAuditLog(exec, options = {}) {
224
224
  if (!exec) return;
225
- const correlationId = chunkULFJOPQ2_cjs.current();
225
+ const correlationId = chunkMMLQXSSD_cjs.current();
226
226
  if (!correlationId) return;
227
227
  lastRequestFlushAt = Date.now();
228
228
  const rows = await readAuditRows(exec, correlationId, options.since ?? null);
@@ -365,11 +365,11 @@ function emitFresh(rows) {
365
365
  emitAuditRows(fresh);
366
366
  }
367
367
  function correlationForTx(txid) {
368
- if (!txid) return chunkULFJOPQ2_cjs.generate();
368
+ if (!txid) return chunkMMLQXSSD_cjs.generate();
369
369
  let id = txCorrelation.get(txid);
370
370
  if (!id) {
371
371
  if (txCorrelation.size >= 1e3) txCorrelation.clear();
372
- id = chunkULFJOPQ2_cjs.generate();
372
+ id = chunkMMLQXSSD_cjs.generate();
373
373
  txCorrelation.set(txid, id);
374
374
  }
375
375
  return id;
@@ -390,7 +390,7 @@ function emitOne(row) {
390
390
  const newRow = withUtcTimestamps(coerceJsonb(row.new_row), naive);
391
391
  const related = row.resource_id === null ? relatedResourceIds(row.table_name, newRow ?? oldRow ?? {}) : null;
392
392
  if (op === "create" && newRow) {
393
- chunkOJKWSUMK_cjs.emitDbEvent({
393
+ chunkYXZZNZG6_cjs.emitDbEvent({
394
394
  modelClass: row.table_name,
395
395
  operation: "create",
396
396
  resourceId: row.resource_id,
@@ -408,7 +408,7 @@ function emitOne(row) {
408
408
  if (changes.length === 0) {
409
409
  return;
410
410
  }
411
- chunkOJKWSUMK_cjs.emitDbEvent({
411
+ chunkYXZZNZG6_cjs.emitDbEvent({
412
412
  modelClass: row.table_name,
413
413
  operation: "update",
414
414
  resourceId: row.resource_id,
@@ -424,7 +424,7 @@ function emitOne(row) {
424
424
  return;
425
425
  }
426
426
  if (op === "destroy" && oldRow) {
427
- chunkOJKWSUMK_cjs.emitDbEvent({
427
+ chunkYXZZNZG6_cjs.emitDbEvent({
428
428
  modelClass: row.table_name,
429
429
  operation: "destroy",
430
430
  resourceId: row.resource_id,
@@ -1,5 +1,5 @@
1
- import { emitDbEvent } from './chunk-SH5NGIX3.js';
2
- import { createScopedStorage, runWithCorrelation, getCurrentActor, runWithActorScope, current, generate } from './chunk-B7SH6V7M.js';
1
+ import { emitDbEvent } from './chunk-NINIAL7M.js';
2
+ import { createScopedStorage, runWithCorrelation, getCurrentActor, runWithActorScope, current, generate } from './chunk-GI6BM4MR.js';
3
3
  import { logger } from './chunk-FCFVIRQF.js';
4
4
 
5
5
  // src/triggers/emit-dedup.ts
@@ -78,6 +78,7 @@ function isSessionStoreColumn(column) {
78
78
  }
79
79
  var DEFAULT_EXCLUDED_JOB_CLASSES = Object.freeze([]);
80
80
  var DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS = Object.freeze(["IntrospectionQuery", "__*"]);
81
+ var DEFAULT_SERVER_URL = "https://app.ezlogs.io";
81
82
  var Configuration = class {
82
83
  serverUrl = null;
83
84
  projectToken = null;
@@ -118,7 +119,7 @@ var Configuration = class {
118
119
  */
119
120
  triggerTrackedTables = null;
120
121
  apply(options) {
121
- this.serverUrl = options.serverUrl;
122
+ this.serverUrl = options.serverUrl || (typeof process !== "undefined" ? process.env?.EZLOGS_SERVER_URL : void 0) || DEFAULT_SERVER_URL;
122
123
  this.projectToken = options.projectToken;
123
124
  if (options.captureHttp !== void 0) this.captureHttp = options.captureHttp;
124
125
  if (options.captureDb !== void 0) this.captureDb = options.captureDb;
@@ -1,4 +1,4 @@
1
- import { configuration, DEFAULT_EXCLUDED_TABLES, current, getCurrentActor, AUTH_SESSION_TABLE_NAMES, isSessionStoreColumn } from './chunk-B7SH6V7M.js';
1
+ import { configuration, DEFAULT_EXCLUDED_TABLES, current, getCurrentActor, AUTH_SESSION_TABLE_NAMES, isSessionStoreColumn } from './chunk-GI6BM4MR.js';
2
2
  import { logger } from './chunk-FCFVIRQF.js';
3
3
  import { __export } from './chunk-SIAA4J6H.js';
4
4
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkULFJOPQ2_cjs = require('./chunk-ULFJOPQ2.cjs');
3
+ var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.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 = chunkULFJOPQ2_cjs.makeAsyncContextCapture();
31
+ const captureAndRun = chunkMMLQXSSD_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 = chunkULFJOPQ2_cjs.getCurrentActor();
98
+ const actor = chunkMMLQXSSD_cjs.getCurrentActor();
99
99
  return {
100
100
  actorId: actor && actor.id ? actor.id : null,
101
- correlationId: chunkULFJOPQ2_cjs.current()
101
+ correlationId: chunkMMLQXSSD_cjs.current()
102
102
  };
103
103
  }
104
104
  async function injectAndRun(client, original, config, values, callback, ctx) {
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkULFJOPQ2_cjs = require('./chunk-ULFJOPQ2.cjs');
3
+ var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.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 = chunkULFJOPQ2_cjs.getCurrentActor();
8
+ const actor = chunkMMLQXSSD_cjs.getCurrentActor();
9
9
  return {
10
10
  actorId: actor && actor.id ? actor.id : null,
11
- correlationId: chunkULFJOPQ2_cjs.current()
11
+ correlationId: chunkMMLQXSSD_cjs.current()
12
12
  };
13
13
  }
14
14
  async function applyDatabaseContext(exec) {
15
- const actor = chunkULFJOPQ2_cjs.getCurrentActor();
16
- const correlationId = chunkULFJOPQ2_cjs.current();
15
+ const actor = chunkMMLQXSSD_cjs.getCurrentActor();
16
+ const correlationId = chunkMMLQXSSD_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 chunkVROC3BO3_cjs = require('./chunk-VROC3BO3.cjs');
4
- var chunkOJKWSUMK_cjs = require('./chunk-OJKWSUMK.cjs');
5
- var chunkULFJOPQ2_cjs = require('./chunk-ULFJOPQ2.cjs');
3
+ var chunkGMHOUAKD_cjs = require('./chunk-GMHOUAKD.cjs');
4
+ var chunkYXZZNZG6_cjs = require('./chunk-YXZZNZG6.cjs');
5
+ var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.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 = chunkULFJOPQ2_cjs.configuration();
15
+ const config = chunkMMLQXSSD_cjs.configuration();
16
16
  if (!config.captureJobs) return;
17
17
  if (config.allExcludedJobClasses().includes(input.jobClass)) return;
18
18
  const sourceData = compactJobSourceData({
@@ -22,24 +22,24 @@ function emitJobEvent(input) {
22
22
  retry_count: input.retryCount ?? null,
23
23
  arguments: jobArguments(input.payload)
24
24
  });
25
- const event = chunkOJKWSUMK_cjs.build({
25
+ const event = chunkYXZZNZG6_cjs.build({
26
26
  source_type: "background_job",
27
27
  source_data: sourceData,
28
28
  outcome: input.outcome,
29
- correlation_id: input.correlationId ?? chunkULFJOPQ2_cjs.current(),
29
+ correlation_id: input.correlationId ?? chunkMMLQXSSD_cjs.current(),
30
30
  resource_ids: [],
31
31
  context: null,
32
32
  duration_ms: input.durationMs ?? null,
33
33
  error_message: input.errorMessage ?? null,
34
34
  timestamp: input.startedAt
35
35
  });
36
- chunkOJKWSUMK_cjs.pushEvent(event);
36
+ chunkYXZZNZG6_cjs.pushEvent(event);
37
37
  } catch (error) {
38
38
  chunkTWTG5ILJ_cjs.logger.debug(`job emit failed: ${describeError(error)}`);
39
39
  }
40
40
  }
41
41
  async function runJobWithCapture(meta, work) {
42
- const correlationId = meta.correlationId ?? chunkULFJOPQ2_cjs.generate();
42
+ const correlationId = meta.correlationId ?? chunkMMLQXSSD_cjs.generate();
43
43
  const body = async () => {
44
44
  const startedAt = /* @__PURE__ */ new Date();
45
45
  const startMs = startedAt.getTime();
@@ -74,13 +74,13 @@ async function runJobWithCapture(meta, work) {
74
74
  throw error;
75
75
  }
76
76
  };
77
- const scoped = () => body().finally(chunkULFJOPQ2_cjs.endCorrelationScope);
78
- return chunkULFJOPQ2_cjs.runWithCorrelation(correlationId, () => chunkULFJOPQ2_cjs.runWithActorScope(scoped, meta.actor ?? null));
77
+ const scoped = () => body().finally(chunkMMLQXSSD_cjs.endCorrelationScope);
78
+ return chunkMMLQXSSD_cjs.runWithCorrelation(correlationId, () => chunkMMLQXSSD_cjs.runWithActorScope(scoped, meta.actor ?? null));
79
79
  }
80
80
  var JOB_FLUSH_SKEW_MS = 500;
81
81
  async function flushJobAuditLog(startedAt) {
82
82
  try {
83
- await chunkVROC3BO3_cjs.flushAuditLog(chunkULFJOPQ2_cjs.configuration().databaseReader, {
83
+ await chunkGMHOUAKD_cjs.flushAuditLog(chunkMMLQXSSD_cjs.configuration().databaseReader, {
84
84
  since: new Date(startedAt.getTime() - JOB_FLUSH_SKEW_MS)
85
85
  });
86
86
  } catch (error) {
@@ -89,16 +89,16 @@ async function flushJobAuditLog(startedAt) {
89
89
  }
90
90
  function jobArguments(payload) {
91
91
  if (payload === null || payload === void 0) return null;
92
- const patterns = chunkULFJOPQ2_cjs.configuration().excludedGraphqlVariableKeys;
93
- if (Array.isArray(payload)) return payload.length === 0 ? null : chunkOJKWSUMK_cjs.sanitizeArgs(payload, patterns);
92
+ const patterns = chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys;
93
+ if (Array.isArray(payload)) return payload.length === 0 ? null : chunkYXZZNZG6_cjs.sanitizeArgs(payload, patterns);
94
94
  if (typeof payload === "object" && Object.getPrototypeOf(payload) === Object.prototype) {
95
95
  const rest = { ...payload };
96
96
  delete rest[CORRELATION_PAYLOAD_KEY];
97
97
  delete rest[ACTOR_PAYLOAD_KEY];
98
98
  if (Object.keys(rest).length === 0) return null;
99
- return chunkOJKWSUMK_cjs.sanitizeArgs([rest], patterns)[0];
99
+ return chunkYXZZNZG6_cjs.sanitizeArgs([rest], patterns)[0];
100
100
  }
101
- return chunkOJKWSUMK_cjs.sanitizeArgs([payload], patterns);
101
+ return chunkYXZZNZG6_cjs.sanitizeArgs([payload], patterns);
102
102
  }
103
103
  function extractCorrelationFromPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
104
104
  if (payload === null || typeof payload !== "object") return null;
@@ -108,7 +108,7 @@ function extractCorrelationFromPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
108
108
  function stampCorrelationOnPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
109
109
  if (!payload || typeof payload !== "object") return payload;
110
110
  if (typeof payload[key] === "string" && payload[key]) return payload;
111
- const id = chunkULFJOPQ2_cjs.current();
111
+ const id = chunkMMLQXSSD_cjs.current();
112
112
  if (!id) return payload;
113
113
  return { ...payload, [key]: id };
114
114
  }
@@ -126,10 +126,10 @@ function describeError(error) {
126
126
  }
127
127
  function pendingActorToken(correlationId) {
128
128
  try {
129
- const actor = chunkULFJOPQ2_cjs.getCurrentActor();
129
+ const actor = chunkMMLQXSSD_cjs.getCurrentActor();
130
130
  if (!actor || actor.kind && actor.kind !== "human" || actor.principal) return null;
131
131
  const actorId = actor.id;
132
- const key = chunkULFJOPQ2_cjs.configuration().projectToken;
132
+ const key = chunkMMLQXSSD_cjs.configuration().projectToken;
133
133
  if (!actorId || !key) return null;
134
134
  const bytes = new TextEncoder().encode(actorId);
135
135
  if (bytes.length > ACTOR_ID_MAX_BYTES) return null;
@@ -157,8 +157,8 @@ ${actorId}`;
157
157
  var tokenMemo = /* @__PURE__ */ new Map();
158
158
  function signedActorToken(correlationId) {
159
159
  const now = pendingActorToken(correlationId);
160
- if (now || chunkULFJOPQ2_cjs.getCurrentActor() || !chunkULFJOPQ2_cjs.configuration().actorFromSupabase) return now;
161
- return chunkULFJOPQ2_cjs.maybeExtractSupabaseActor().then(
160
+ if (now || chunkMMLQXSSD_cjs.getCurrentActor() || !chunkMMLQXSSD_cjs.configuration().actorFromSupabase) return now;
161
+ return chunkMMLQXSSD_cjs.maybeExtractSupabaseActor().then(
162
162
  () => pendingActorToken(correlationId),
163
163
  () => null
164
164
  );
@@ -169,7 +169,7 @@ async function actorToken(correlationId) {
169
169
  async function readActorToken(token, correlationId) {
170
170
  try {
171
171
  const match = typeof token === "string" ? ACTOR_TOKEN.exec(token) : null;
172
- const key = chunkULFJOPQ2_cjs.configuration().projectToken;
172
+ const key = chunkMMLQXSSD_cjs.configuration().projectToken;
173
173
  if (!match || !key || match[1].length % 2 !== 0) return null;
174
174
  const bytes = new Uint8Array(match[1].match(/../g).map((h) => parseInt(h, 16)));
175
175
  const actorId = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
@@ -1,6 +1,6 @@
1
- import { flushAuditLog } from './chunk-2X6IZ2JX.js';
2
- import { build, pushEvent, sanitizeArgs } from './chunk-SH5NGIX3.js';
3
- import { configuration, current, generate, runWithCorrelation, runWithActorScope, getCurrentActor, maybeExtractSupabaseActor, endCorrelationScope } from './chunk-B7SH6V7M.js';
1
+ import { flushAuditLog } from './chunk-MHBS5FEP.js';
2
+ import { build, pushEvent, sanitizeArgs } from './chunk-NINIAL7M.js';
3
+ import { configuration, current, generate, runWithCorrelation, runWithActorScope, getCurrentActor, maybeExtractSupabaseActor, endCorrelationScope } from './chunk-GI6BM4MR.js';
4
4
  import { logger } from './chunk-FCFVIRQF.js';
5
5
 
6
6
  // src/jobs/shared.ts
@@ -1,4 +1,4 @@
1
- import { getCurrentActor, current } from './chunk-B7SH6V7M.js';
1
+ import { getCurrentActor, current } from './chunk-GI6BM4MR.js';
2
2
  import { logger } from './chunk-FCFVIRQF.js';
3
3
 
4
4
  // src/triggers/context.ts
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkULFJOPQ2_cjs = require('./chunk-ULFJOPQ2.cjs');
3
+ var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.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 chunkULFJOPQ2_cjs.configuration().bufferSize;
53
+ return chunkMMLQXSSD_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 = chunkULFJOPQ2_cjs.configuration();
544
+ const config = chunkMMLQXSSD_cjs.configuration();
545
545
  if (!config.captureDb) return;
546
546
  if (config.excludedTables.includes(input.modelClass)) return;
547
- if (chunkULFJOPQ2_cjs.DEFAULT_EXCLUDED_TABLES.includes(input.modelClass) && !(input._fromTrigger && isBusinessSessionRow(input.modelClass, input.modelInstance))) {
547
+ if (chunkMMLQXSSD_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: chunkULFJOPQ2_cjs.current(),
570
+ correlation_id: chunkMMLQXSSD_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 = chunkULFJOPQ2_cjs.getCurrentActor();
583
+ const actor = chunkMMLQXSSD_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 (!chunkULFJOPQ2_cjs.AUTH_SESSION_TABLE_NAMES.test(table) || /verif/i.test(table) || !row) return false;
738
+ if (!chunkMMLQXSSD_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(chunkULFJOPQ2_cjs.isSessionStoreColumn);
740
+ return columns.length > 0 && !columns.some(chunkMMLQXSSD_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 = chunkULFJOPQ2_cjs.configuration();
746
+ const config = chunkMMLQXSSD_cjs.configuration();
747
747
  const resolver = config.displayNameFor[modelClass];
748
748
  const resolved = applyResolver(resolver, instance);
749
749
  if (resolved !== null) return resolved;
@@ -1,4 +1,4 @@
1
- import { makeAsyncContextCapture, getCurrentActor, current } from './chunk-B7SH6V7M.js';
1
+ import { makeAsyncContextCapture, getCurrentActor, current } from './chunk-GI6BM4MR.js';
2
2
  import { logger } from './chunk-FCFVIRQF.js';
3
3
 
4
4
  // src/triggers/patch-pg.ts
@@ -102,7 +102,8 @@ type ServerActionErrorClassifier = (result: unknown) => boolean | {
102
102
  errorMessage: string;
103
103
  } | null | undefined;
104
104
  interface InitOptions {
105
- serverUrl: string;
105
+ /** Default: `process.env.EZLOGS_SERVER_URL`, else `"https://app.ezlogs.io"`. Set only if you self-host. */
106
+ serverUrl?: string;
106
107
  projectToken: string;
107
108
  captureHttp?: boolean;
108
109
  captureDb?: boolean;
@@ -102,7 +102,8 @@ type ServerActionErrorClassifier = (result: unknown) => boolean | {
102
102
  errorMessage: string;
103
103
  } | null | undefined;
104
104
  interface InitOptions {
105
- serverUrl: string;
105
+ /** Default: `process.env.EZLOGS_SERVER_URL`, else `"https://app.ezlogs.io"`. Set only if you self-host. */
106
+ serverUrl?: string;
106
107
  projectToken: string;
107
108
  captureHttp?: boolean;
108
109
  captureDb?: boolean;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkOJKWSUMK_cjs = require('../chunk-OJKWSUMK.cjs');
4
- require('../chunk-ULFJOPQ2.cjs');
3
+ var chunkYXZZNZG6_cjs = require('../chunk-YXZZNZG6.cjs');
4
+ require('../chunk-MMLQXSSD.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
- chunkOJKWSUMK_cjs.emitDbEvent({
17
+ chunkYXZZNZG6_cjs.emitDbEvent({
18
18
  modelClass: parsed.table,
19
19
  operation: parsed.operation,
20
20
  resourceId,
@@ -1,5 +1,5 @@
1
- import { emitDbEvent } from '../chunk-SH5NGIX3.js';
2
- import '../chunk-B7SH6V7M.js';
1
+ import { emitDbEvent } from '../chunk-NINIAL7M.js';
2
+ import '../chunk-GI6BM4MR.js';
3
3
  import { logger } from '../chunk-FCFVIRQF.js';
4
4
  import '../chunk-SIAA4J6H.js';
5
5
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkZSFJ3UQV_cjs = require('../chunk-ZSFJ3UQV.cjs');
4
- var chunkULFJOPQ2_cjs = require('../chunk-ULFJOPQ2.cjs');
3
+ var chunkPS4U2GFJ_cjs = require('../chunk-PS4U2GFJ.cjs');
4
+ var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.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 (chunkULFJOPQ2_cjs.configuration().databaseReader == null) return null;
26
- const ctx = chunkZSFJ3UQV_cjs.getDatabaseContext();
25
+ if (chunkMMLQXSSD_cjs.configuration().databaseReader == null) return null;
26
+ const ctx = chunkPS4U2GFJ_cjs.getDatabaseContext();
27
27
  return ctx.correlationId ? ctx : null;
28
28
  }
29
29
  function setContext(tx, ctx) {
@@ -1,5 +1,5 @@
1
- import { getDatabaseContext } from '../chunk-DLUZRHHW.js';
2
- import { configuration } from '../chunk-B7SH6V7M.js';
1
+ import { getDatabaseContext } from '../chunk-YMIGZYFH.js';
2
+ import { configuration } from '../chunk-GI6BM4MR.js';
3
3
  import '../chunk-FCFVIRQF.js';
4
4
  import '../chunk-SIAA4J6H.js';
5
5
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkOJKWSUMK_cjs = require('../chunk-OJKWSUMK.cjs');
4
- var chunkULFJOPQ2_cjs = require('../chunk-ULFJOPQ2.cjs');
3
+ var chunkYXZZNZG6_cjs = require('../chunk-YXZZNZG6.cjs');
4
+ var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.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, chunkULFJOPQ2_cjs.current(), chunkULFJOPQ2_cjs.getCurrentActor()?.id ?? ""),
65
+ client.$executeRawUnsafe(SET_CONTEXT_SQL, chunkMMLQXSSD_cjs.current(), chunkMMLQXSSD_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 (chunkULFJOPQ2_cjs.configuration().databaseReader == null) return false;
84
+ if (chunkMMLQXSSD_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 (!chunkULFJOPQ2_cjs.current()) return false;
89
+ if (!chunkMMLQXSSD_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
- chunkOJKWSUMK_cjs.emitDbEvent({
115
+ chunkYXZZNZG6_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
- chunkOJKWSUMK_cjs.emitDbEvent({
142
+ chunkYXZZNZG6_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 = chunkOJKWSUMK_cjs.resolveDisplayName(ctx.model, rowObj);
152
+ const displayName = chunkYXZZNZG6_cjs.resolveDisplayName(ctx.model, rowObj);
153
153
  if (dbOperation === "create") {
154
- chunkOJKWSUMK_cjs.emitDbEvent({
154
+ chunkYXZZNZG6_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
- chunkOJKWSUMK_cjs.emitDbEvent({
169
+ chunkYXZZNZG6_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
- chunkOJKWSUMK_cjs.emitDbEvent({
180
+ chunkYXZZNZG6_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 = chunkULFJOPQ2_cjs.makeAsyncContextCapture();
271
+ const captureAndRun = chunkMMLQXSSD_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-SH5NGIX3.js';
2
- import { current, getCurrentActor, configuration, makeAsyncContextCapture } from '../chunk-B7SH6V7M.js';
1
+ import { emitDbEvent, resolveDisplayName } from '../chunk-NINIAL7M.js';
2
+ import { current, getCurrentActor, configuration, makeAsyncContextCapture } from '../chunk-GI6BM4MR.js';
3
3
  import { logger } from '../chunk-FCFVIRQF.js';
4
4
  import '../chunk-SIAA4J6H.js';
5
5