ezlogs-nextjs 0.4.4 → 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.
Files changed (65) hide show
  1. package/README.md +73 -13
  2. package/dist/actors/index.d.cts +1 -1
  3. package/dist/actors/index.d.ts +1 -1
  4. package/dist/{chunk-MMLQXSSD.cjs → chunk-2YCQFLXW.cjs} +21 -11
  5. package/dist/{chunk-YMIGZYFH.js → chunk-343ZGTMH.js} +1 -1
  6. package/dist/{chunk-Z2TM3LGG.js → chunk-5ZMOWEBY.js} +1 -1
  7. package/dist/{chunk-GI6BM4MR.js → chunk-7MFKEYDN.js} +21 -12
  8. package/dist/{chunk-NINIAL7M.js → chunk-AXIQTU52.js} +1 -1
  9. package/dist/chunk-BE3RCFNP.js +13 -0
  10. package/dist/chunk-CHVJ4WPM.cjs +16 -0
  11. package/dist/{chunk-MHBS5FEP.js → chunk-CYAFYBKF.js} +27 -4
  12. package/dist/chunk-DRE2VXFX.js +19 -0
  13. package/dist/{chunk-GMHOUAKD.cjs → chunk-EXGEA4KE.cjs} +37 -13
  14. package/dist/{chunk-PS4U2GFJ.cjs → chunk-JB4UYCZI.cjs} +5 -5
  15. package/dist/chunk-JWJKFZBW.js +52 -0
  16. package/dist/{chunk-R6IWVTX3.cjs → chunk-KOFR5OC3.cjs} +31 -21
  17. package/dist/chunk-NFZ5OKF3.cjs +22 -0
  18. package/dist/{chunk-U22T7QYY.js → chunk-Q3HRVWCS.js} +13 -3
  19. package/dist/{chunk-YXZZNZG6.cjs → chunk-UC2KS5EG.cjs} +9 -9
  20. package/dist/chunk-VJR4VB4B.cjs +56 -0
  21. package/dist/{chunk-NX4EL7BY.cjs → chunk-XWEBKN65.cjs} +4 -4
  22. package/dist/{configuration-CJ5yKVlP.d.cts → configuration-b9pImwFB.d.cts} +2 -2
  23. package/dist/{configuration-CJ5yKVlP.d.ts → configuration-b9pImwFB.d.ts} +2 -2
  24. package/dist/db/drizzle.cjs +3 -3
  25. package/dist/db/drizzle.js +2 -2
  26. package/dist/db/postgres-js.cjs +4 -4
  27. package/dist/db/postgres-js.js +2 -2
  28. package/dist/db/prisma.cjs +12 -12
  29. package/dist/db/prisma.js +2 -2
  30. package/dist/db/supabase.cjs +42 -17
  31. package/dist/db/supabase.d.cts +11 -5
  32. package/dist/db/supabase.d.ts +11 -5
  33. package/dist/db/supabase.js +33 -9
  34. package/dist/index.cjs +303 -142
  35. package/dist/index.d.cts +2 -2
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.js +213 -52
  38. package/dist/jobs/bullmq.cjs +44 -16
  39. package/dist/jobs/bullmq.d.cts +7 -1
  40. package/dist/jobs/bullmq.d.ts +7 -1
  41. package/dist/jobs/bullmq.js +33 -6
  42. package/dist/jobs/inngest.cjs +171 -48
  43. package/dist/jobs/inngest.d.cts +13 -7
  44. package/dist/jobs/inngest.d.ts +13 -7
  45. package/dist/jobs/inngest.js +162 -40
  46. package/dist/jobs/supabase-queues.cjs +9 -9
  47. package/dist/jobs/supabase-queues.js +4 -4
  48. package/dist/jobs/trigger.cjs +7 -7
  49. package/dist/jobs/trigger.js +4 -4
  50. package/dist/jobs/upstash-workflow.cjs +139 -23
  51. package/dist/jobs/upstash-workflow.d.cts +20 -2
  52. package/dist/jobs/upstash-workflow.d.ts +20 -2
  53. package/dist/jobs/upstash-workflow.js +129 -14
  54. package/dist/nextjs-plugin/index.cjs +46 -29
  55. package/dist/nextjs-plugin/index.js +46 -29
  56. package/dist/nextjs-plugin/loader.cjs +104 -65
  57. package/dist/nextjs-plugin/loader.d.cts +18 -1
  58. package/dist/nextjs-plugin/loader.d.ts +18 -1
  59. package/dist/nextjs-plugin/loader.js +104 -66
  60. package/dist/triggers/index.cjs +22 -16
  61. package/dist/triggers/index.d.cts +0 -10
  62. package/dist/triggers/index.d.ts +0 -10
  63. package/dist/triggers/index.js +11 -5
  64. package/package.json +1 -1
  65. package/sql/postgres/00_install.sql +20 -3
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkGMHOUAKD_cjs = require('./chunk-GMHOUAKD.cjs');
4
- var chunkYXZZNZG6_cjs = require('./chunk-YXZZNZG6.cjs');
5
- var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.cjs');
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 = chunkMMLQXSSD_cjs.configuration();
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({
@@ -20,33 +20,39 @@ function emitJobEvent(input) {
20
20
  job_id: input.jobId ?? null,
21
21
  queue: input.queue ?? null,
22
22
  retry_count: input.retryCount ?? null,
23
+ step: input.step ?? null,
23
24
  arguments: jobArguments(input.payload)
24
25
  });
25
- const event = chunkYXZZNZG6_cjs.build({
26
+ const event = chunkUC2KS5EG_cjs.build({
26
27
  source_type: "background_job",
27
28
  source_data: sourceData,
28
29
  outcome: input.outcome,
29
- correlation_id: input.correlationId ?? chunkMMLQXSSD_cjs.current(),
30
+ correlation_id: input.correlationId ?? chunk2YCQFLXW_cjs.current(),
30
31
  resource_ids: [],
31
32
  context: null,
32
33
  duration_ms: input.durationMs ?? null,
33
34
  error_message: input.errorMessage ?? null,
34
35
  timestamp: input.startedAt
35
36
  });
36
- chunkYXZZNZG6_cjs.pushEvent(event);
37
+ chunkUC2KS5EG_cjs.pushEvent(event);
37
38
  } catch (error) {
38
39
  chunkTWTG5ILJ_cjs.logger.debug(`job emit failed: ${describeError(error)}`);
39
40
  }
40
41
  }
41
42
  async function runJobWithCapture(meta, work) {
42
- const correlationId = meta.correlationId ?? chunkMMLQXSSD_cjs.generate();
43
+ const correlationId = meta.correlationId ?? chunk2YCQFLXW_cjs.generate();
43
44
  const body = async () => {
44
45
  const startedAt = /* @__PURE__ */ new Date();
45
46
  const startMs = startedAt.getTime();
47
+ const step = meta.step;
46
48
  const baseMeta = {
47
49
  jobClass: meta.jobClass,
48
50
  jobId: meta.jobId ?? null,
49
51
  queue: meta.queue ?? null,
52
+ // Read when the event is built (after the run): the step it executed.
53
+ get step() {
54
+ return (typeof step === "function" ? step() : step) ?? null;
55
+ },
50
56
  retryCount: meta.retryCount ?? null,
51
57
  correlationId,
52
58
  startedAt,
@@ -65,6 +71,10 @@ async function runJobWithCapture(meta, work) {
65
71
  const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
66
72
  await flushJobAuditLog(startedAt);
67
73
  if (meta.isControlFlow?.(error)) throw error;
74
+ if (meta.isSuccessfulExit?.(error)) {
75
+ emitJobEvent({ ...baseMeta, outcome: "success", durationMs: Date.now() - startMs });
76
+ throw error;
77
+ }
68
78
  emitJobEvent({
69
79
  ...baseMeta,
70
80
  outcome: "failure",
@@ -74,13 +84,13 @@ async function runJobWithCapture(meta, work) {
74
84
  throw error;
75
85
  }
76
86
  };
77
- const scoped = () => body().finally(chunkMMLQXSSD_cjs.endCorrelationScope);
78
- return chunkMMLQXSSD_cjs.runWithCorrelation(correlationId, () => chunkMMLQXSSD_cjs.runWithActorScope(scoped, meta.actor ?? null));
87
+ const scoped = () => body().finally(chunk2YCQFLXW_cjs.endCorrelationScope);
88
+ return chunk2YCQFLXW_cjs.runWithCorrelation(correlationId, () => chunk2YCQFLXW_cjs.runWithActorScope(scoped, meta.actor ?? null));
79
89
  }
80
90
  var JOB_FLUSH_SKEW_MS = 500;
81
91
  async function flushJobAuditLog(startedAt) {
82
92
  try {
83
- await chunkGMHOUAKD_cjs.flushAuditLog(chunkMMLQXSSD_cjs.configuration().databaseReader, {
93
+ await chunkEXGEA4KE_cjs.flushAuditLog(chunk2YCQFLXW_cjs.configuration().databaseReader, {
84
94
  since: new Date(startedAt.getTime() - JOB_FLUSH_SKEW_MS)
85
95
  });
86
96
  } catch (error) {
@@ -89,16 +99,16 @@ async function flushJobAuditLog(startedAt) {
89
99
  }
90
100
  function jobArguments(payload) {
91
101
  if (payload === null || payload === void 0) return null;
92
- const patterns = chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys;
93
- if (Array.isArray(payload)) return payload.length === 0 ? null : chunkYXZZNZG6_cjs.sanitizeArgs(payload, patterns);
102
+ const patterns = chunk2YCQFLXW_cjs.configuration().excludedGraphqlVariableKeys;
103
+ if (Array.isArray(payload)) return payload.length === 0 ? null : chunkUC2KS5EG_cjs.sanitizeArgs(payload, patterns);
94
104
  if (typeof payload === "object" && Object.getPrototypeOf(payload) === Object.prototype) {
95
105
  const rest = { ...payload };
96
106
  delete rest[CORRELATION_PAYLOAD_KEY];
97
107
  delete rest[ACTOR_PAYLOAD_KEY];
98
108
  if (Object.keys(rest).length === 0) return null;
99
- return chunkYXZZNZG6_cjs.sanitizeArgs([rest], patterns)[0];
109
+ return chunkUC2KS5EG_cjs.sanitizeArgs([rest], patterns)[0];
100
110
  }
101
- return chunkYXZZNZG6_cjs.sanitizeArgs([payload], patterns);
111
+ return chunkUC2KS5EG_cjs.sanitizeArgs([payload], patterns);
102
112
  }
103
113
  function extractCorrelationFromPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
104
114
  if (payload === null || typeof payload !== "object") return null;
@@ -108,7 +118,7 @@ function extractCorrelationFromPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
108
118
  function stampCorrelationOnPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
109
119
  if (!payload || typeof payload !== "object") return payload;
110
120
  if (typeof payload[key] === "string" && payload[key]) return payload;
111
- const id = chunkMMLQXSSD_cjs.current();
121
+ const id = chunk2YCQFLXW_cjs.current();
112
122
  if (!id) return payload;
113
123
  return { ...payload, [key]: id };
114
124
  }
@@ -126,10 +136,10 @@ function describeError(error) {
126
136
  }
127
137
  function pendingActorToken(correlationId) {
128
138
  try {
129
- const actor = chunkMMLQXSSD_cjs.getCurrentActor();
139
+ const actor = chunk2YCQFLXW_cjs.getCurrentActor();
130
140
  if (!actor || actor.kind && actor.kind !== "human" || actor.principal) return null;
131
141
  const actorId = actor.id;
132
- const key = chunkMMLQXSSD_cjs.configuration().projectToken;
142
+ const key = chunk2YCQFLXW_cjs.configuration().projectToken;
133
143
  if (!actorId || !key) return null;
134
144
  const bytes = new TextEncoder().encode(actorId);
135
145
  if (bytes.length > ACTOR_ID_MAX_BYTES) return null;
@@ -157,8 +167,8 @@ ${actorId}`;
157
167
  var tokenMemo = /* @__PURE__ */ new Map();
158
168
  function signedActorToken(correlationId) {
159
169
  const now = pendingActorToken(correlationId);
160
- if (now || chunkMMLQXSSD_cjs.getCurrentActor() || !chunkMMLQXSSD_cjs.configuration().actorFromSupabase) return now;
161
- return chunkMMLQXSSD_cjs.maybeExtractSupabaseActor().then(
170
+ if (now || chunk2YCQFLXW_cjs.getCurrentActor() || !chunk2YCQFLXW_cjs.configuration().actorFromSupabase) return now;
171
+ return chunk2YCQFLXW_cjs.maybeExtractSupabaseActor().then(
162
172
  () => pendingActorToken(correlationId),
163
173
  () => null
164
174
  );
@@ -169,7 +179,7 @@ async function actorToken(correlationId) {
169
179
  async function readActorToken(token, correlationId) {
170
180
  try {
171
181
  const match = typeof token === "string" ? ACTOR_TOKEN.exec(token) : null;
172
- const key = chunkMMLQXSSD_cjs.configuration().projectToken;
182
+ const key = chunk2YCQFLXW_cjs.configuration().projectToken;
173
183
  if (!match || !key || match[1].length % 2 !== 0) return null;
174
184
  const bytes = new Uint8Array(match[1].match(/../g).map((h) => parseInt(h, 16)));
175
185
  const actorId = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ // src/nextjs-plugin/instrumented-imports.ts
4
+ var INSTRUMENTED_IMPORTS = [
5
+ {
6
+ module: "@upstash/workflow/nextjs",
7
+ names: ["serve", "servePagesRouter", "createWorkflow", "createWorkflowPagesRouter", "serveMany", "serveManyPagesRouter"],
8
+ via: "upstash-workflow"
9
+ },
10
+ { module: "@upstash/workflow", names: ["serve", "Client"], via: "upstash-workflow" },
11
+ { module: "@upstash/qstash", names: ["Client"], via: "upstash-workflow" },
12
+ { module: "bullmq", names: ["Queue", "Worker"], via: "bullmq" },
13
+ { module: "inngest", names: ["Inngest"], via: "inngest" },
14
+ { module: "@supabase/supabase-js", names: ["createClient"], via: "supabase" },
15
+ { module: "@supabase/ssr", names: ["createServerClient"], via: "supabase" }
16
+ ];
17
+ var INSTRUMENTED_IMPORT_CONTENT = new RegExp(
18
+ `from\\s*["'](?:${[...new Set(INSTRUMENTED_IMPORTS.map((e) => e.module))].map((m) => m.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")).join("|")})["']`
19
+ );
20
+
21
+ exports.INSTRUMENTED_IMPORTS = INSTRUMENTED_IMPORTS;
22
+ exports.INSTRUMENTED_IMPORT_CONTENT = INSTRUMENTED_IMPORT_CONTENT;
@@ -1,6 +1,6 @@
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';
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
@@ -18,6 +18,7 @@ function emitJobEvent(input) {
18
18
  job_id: input.jobId ?? null,
19
19
  queue: input.queue ?? null,
20
20
  retry_count: input.retryCount ?? null,
21
+ step: input.step ?? null,
21
22
  arguments: jobArguments(input.payload)
22
23
  });
23
24
  const event = build({
@@ -41,10 +42,15 @@ async function runJobWithCapture(meta, work) {
41
42
  const body = async () => {
42
43
  const startedAt = /* @__PURE__ */ new Date();
43
44
  const startMs = startedAt.getTime();
45
+ const step = meta.step;
44
46
  const baseMeta = {
45
47
  jobClass: meta.jobClass,
46
48
  jobId: meta.jobId ?? null,
47
49
  queue: meta.queue ?? null,
50
+ // Read when the event is built (after the run): the step it executed.
51
+ get step() {
52
+ return (typeof step === "function" ? step() : step) ?? null;
53
+ },
48
54
  retryCount: meta.retryCount ?? null,
49
55
  correlationId,
50
56
  startedAt,
@@ -63,6 +69,10 @@ async function runJobWithCapture(meta, work) {
63
69
  const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
64
70
  await flushJobAuditLog(startedAt);
65
71
  if (meta.isControlFlow?.(error)) throw error;
72
+ if (meta.isSuccessfulExit?.(error)) {
73
+ emitJobEvent({ ...baseMeta, outcome: "success", durationMs: Date.now() - startMs });
74
+ throw error;
75
+ }
66
76
  emitJobEvent({
67
77
  ...baseMeta,
68
78
  outcome: "failure",
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.cjs');
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 chunkMMLQXSSD_cjs.configuration().bufferSize;
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 = chunkMMLQXSSD_cjs.configuration();
544
+ const config = chunk2YCQFLXW_cjs.configuration();
545
545
  if (!config.captureDb) return;
546
546
  if (config.excludedTables.includes(input.modelClass)) return;
547
- if (chunkMMLQXSSD_cjs.DEFAULT_EXCLUDED_TABLES.includes(input.modelClass) && !(input._fromTrigger && isBusinessSessionRow(input.modelClass, input.modelInstance))) {
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: chunkMMLQXSSD_cjs.current(),
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 = chunkMMLQXSSD_cjs.getCurrentActor();
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 (!chunkMMLQXSSD_cjs.AUTH_SESSION_TABLE_NAMES.test(table) || /verif/i.test(table) || !row) return false;
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(chunkMMLQXSSD_cjs.isSessionStoreColumn);
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 = chunkMMLQXSSD_cjs.configuration();
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;
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
4
+
5
+ // src/instrument.ts
6
+ function instrumentFrom(replacements) {
7
+ return (key, original) => {
8
+ const replace = Object.prototype.hasOwnProperty.call(replacements, key) ? replacements[key] : void 0;
9
+ if (!replace) return original;
10
+ try {
11
+ return replace(original) ?? original;
12
+ } catch (error) {
13
+ chunkTWTG5ILJ_cjs.logger.debug(`instrument ${key} failed (${error instanceof Error ? error.message : String(error)}); using the original`);
14
+ return original;
15
+ }
16
+ };
17
+ }
18
+ function instrumentClass(original, wrapInstance, mapArgs) {
19
+ if (typeof original !== "function") return original;
20
+ return new Proxy(original, {
21
+ construct(target, args, newTarget) {
22
+ let callArgs = args;
23
+ if (mapArgs) {
24
+ try {
25
+ callArgs = mapArgs(args);
26
+ } catch {
27
+ callArgs = args;
28
+ }
29
+ }
30
+ const instance = Reflect.construct(target, callArgs, newTarget);
31
+ try {
32
+ return wrapInstance(instance) ?? instance;
33
+ } catch {
34
+ return instance;
35
+ }
36
+ }
37
+ });
38
+ }
39
+ function instrumentFactory(original, wrapResult) {
40
+ if (typeof original !== "function") return original;
41
+ const factory = original;
42
+ return new Proxy(factory, {
43
+ apply(target, thisArg, args) {
44
+ const value = Reflect.apply(target, thisArg, args);
45
+ try {
46
+ return wrapResult(value) ?? value;
47
+ } catch {
48
+ return value;
49
+ }
50
+ }
51
+ });
52
+ }
53
+
54
+ exports.instrumentClass = instrumentClass;
55
+ exports.instrumentFactory = instrumentFactory;
56
+ exports.instrumentFrom = instrumentFrom;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.cjs');
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 = chunkMMLQXSSD_cjs.makeAsyncContextCapture();
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 = chunkMMLQXSSD_cjs.getCurrentActor();
98
+ const actor = chunk2YCQFLXW_cjs.getCurrentActor();
99
99
  return {
100
100
  actorId: actor && actor.id ? actor.id : null,
101
- correlationId: chunkMMLQXSSD_cjs.current()
101
+ correlationId: chunk2YCQFLXW_cjs.current()
102
102
  };
103
103
  }
104
104
  async function injectAndRun(client, original, config, values, callback, ctx) {
@@ -83,7 +83,7 @@ type DisplayNameMap = Record<string, DisplayNameResolver>;
83
83
  /**
84
84
  * Classifier for Server Action failure return values.
85
85
  *
86
- * Many Next.js codebases (Velory, next-safe-action templates, the
86
+ * Many Next.js codebases (in-house action wrappers, next-safe-action templates, the
87
87
  * Vercel App Router examples, tRPC) catch errors inside the action and
88
88
  * return `{ success: false, error: "..." }` instead of throwing. The
89
89
  * HTTP response is 200, so the agent can't tell the action failed
@@ -218,4 +218,4 @@ interface InitOptions {
218
218
  */
219
219
  type DatabaseReader = (sql: string, params: ReadonlyArray<unknown>) => Promise<unknown>;
220
220
 
221
- export type { ActorContext as A, DisplayNameMap as D, InitOptions as I, ActorFromRequest as a, ActorPrincipal as b };
221
+ export type { ActorFromRequest as A, DisplayNameMap as D, InitOptions as I, ActorContext as a, ActorPrincipal as b };
@@ -83,7 +83,7 @@ type DisplayNameMap = Record<string, DisplayNameResolver>;
83
83
  /**
84
84
  * Classifier for Server Action failure return values.
85
85
  *
86
- * Many Next.js codebases (Velory, next-safe-action templates, the
86
+ * Many Next.js codebases (in-house action wrappers, next-safe-action templates, the
87
87
  * Vercel App Router examples, tRPC) catch errors inside the action and
88
88
  * return `{ success: false, error: "..." }` instead of throwing. The
89
89
  * HTTP response is 200, so the agent can't tell the action failed
@@ -218,4 +218,4 @@ interface InitOptions {
218
218
  */
219
219
  type DatabaseReader = (sql: string, params: ReadonlyArray<unknown>) => Promise<unknown>;
220
220
 
221
- export type { ActorContext as A, DisplayNameMap as D, InitOptions as I, ActorFromRequest as a, ActorPrincipal as b };
221
+ export type { ActorFromRequest as A, DisplayNameMap as D, InitOptions as I, ActorContext as a, ActorPrincipal as b };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkYXZZNZG6_cjs = require('../chunk-YXZZNZG6.cjs');
4
- require('../chunk-MMLQXSSD.cjs');
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
- chunkYXZZNZG6_cjs.emitDbEvent({
17
+ chunkUC2KS5EG_cjs.emitDbEvent({
18
18
  modelClass: parsed.table,
19
19
  operation: parsed.operation,
20
20
  resourceId,
@@ -1,5 +1,5 @@
1
- import { emitDbEvent } from '../chunk-NINIAL7M.js';
2
- import '../chunk-GI6BM4MR.js';
1
+ import { emitDbEvent } from '../chunk-AXIQTU52.js';
2
+ import '../chunk-7MFKEYDN.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 chunkPS4U2GFJ_cjs = require('../chunk-PS4U2GFJ.cjs');
4
- var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.cjs');
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 (chunkMMLQXSSD_cjs.configuration().databaseReader == null) return null;
26
- const ctx = chunkPS4U2GFJ_cjs.getDatabaseContext();
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) {
@@ -1,5 +1,5 @@
1
- import { getDatabaseContext } from '../chunk-YMIGZYFH.js';
2
- import { configuration } from '../chunk-GI6BM4MR.js';
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
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkYXZZNZG6_cjs = require('../chunk-YXZZNZG6.cjs');
4
- var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.cjs');
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, chunkMMLQXSSD_cjs.current(), chunkMMLQXSSD_cjs.getCurrentActor()?.id ?? ""),
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 (chunkMMLQXSSD_cjs.configuration().databaseReader == null) return false;
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 (!chunkMMLQXSSD_cjs.current()) return false;
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
- chunkYXZZNZG6_cjs.emitDbEvent({
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
- chunkYXZZNZG6_cjs.emitDbEvent({
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 = chunkYXZZNZG6_cjs.resolveDisplayName(ctx.model, rowObj);
152
+ const displayName = chunkUC2KS5EG_cjs.resolveDisplayName(ctx.model, rowObj);
153
153
  if (dbOperation === "create") {
154
- chunkYXZZNZG6_cjs.emitDbEvent({
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
- chunkYXZZNZG6_cjs.emitDbEvent({
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
- chunkYXZZNZG6_cjs.emitDbEvent({
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 = chunkMMLQXSSD_cjs.makeAsyncContextCapture();
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-NINIAL7M.js';
2
- import { current, getCurrentActor, configuration, makeAsyncContextCapture } from '../chunk-GI6BM4MR.js';
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