ezlogs-nextjs 0.3.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 (76) hide show
  1. package/README.md +149 -30
  2. package/bin/install-triggers.cjs +7 -2
  3. package/dist/actors/index.cjs +4 -4
  4. package/dist/actors/index.d.cts +1 -1
  5. package/dist/actors/index.d.ts +1 -1
  6. package/dist/actors/index.js +1 -1
  7. package/dist/{chunk-C5OSM557.js → chunk-FCFVIRQF.js} +7 -0
  8. package/dist/chunk-GI6BM4MR.js +443 -0
  9. package/dist/{chunk-YX2XPLOA.cjs → chunk-GMHOUAKD.cjs} +63 -34
  10. package/dist/{chunk-CU45I2WR.js → chunk-MHBS5FEP.js} +48 -20
  11. package/dist/chunk-MMLQXSSD.cjs +461 -0
  12. package/dist/{chunk-CE3R7DVB.js → chunk-NINIAL7M.js} +60 -384
  13. package/dist/{chunk-Y5NSHKWQ.cjs → chunk-NX4EL7BY.cjs} +57 -7
  14. package/dist/chunk-PS4U2GFJ.cjs +52 -0
  15. package/dist/chunk-R6IWVTX3.cjs +212 -0
  16. package/dist/{chunk-V5YNKKTG.cjs → chunk-TWTG5ILJ.cjs} +7 -0
  17. package/dist/chunk-U22T7QYY.js +200 -0
  18. package/dist/chunk-YMIGZYFH.js +48 -0
  19. package/dist/{chunk-WASXTDLW.cjs → chunk-YXZZNZG6.cjs} +71 -403
  20. package/dist/{chunk-DKRNNI4I.js → chunk-Z2TM3LGG.js} +53 -3
  21. package/dist/{configuration-OHLNivON.d.ts → configuration-CJ5yKVlP.d.cts} +14 -8
  22. package/dist/{configuration-OHLNivON.d.cts → configuration-CJ5yKVlP.d.ts} +14 -8
  23. package/dist/db/drizzle.cjs +5 -4
  24. package/dist/db/drizzle.js +3 -2
  25. package/dist/db/postgres-js.cjs +98 -0
  26. package/dist/db/postgres-js.d.cts +11 -0
  27. package/dist/db/postgres-js.d.ts +11 -0
  28. package/dist/db/postgres-js.js +95 -0
  29. package/dist/db/prisma.cjs +21 -20
  30. package/dist/db/prisma.d.cts +19 -2
  31. package/dist/db/prisma.d.ts +19 -2
  32. package/dist/db/prisma.js +6 -5
  33. package/dist/db/supabase.cjs +19 -12
  34. package/dist/db/supabase.d.cts +3 -2
  35. package/dist/db/supabase.d.ts +3 -2
  36. package/dist/db/supabase.js +11 -4
  37. package/dist/index.cjs +596 -165
  38. package/dist/index.d.cts +5 -3
  39. package/dist/index.d.ts +5 -3
  40. package/dist/index.js +492 -62
  41. package/dist/jobs/bullmq.cjs +63 -18
  42. package/dist/jobs/bullmq.d.cts +0 -4
  43. package/dist/jobs/bullmq.d.ts +0 -4
  44. package/dist/jobs/bullmq.js +59 -14
  45. package/dist/jobs/inngest.cjs +61 -24
  46. package/dist/jobs/inngest.d.cts +5 -1
  47. package/dist/jobs/inngest.d.ts +5 -1
  48. package/dist/jobs/inngest.js +55 -18
  49. package/dist/jobs/supabase-queues.cjs +17 -15
  50. package/dist/jobs/supabase-queues.d.cts +1 -1
  51. package/dist/jobs/supabase-queues.d.ts +1 -1
  52. package/dist/jobs/supabase-queues.js +15 -13
  53. package/dist/jobs/trigger.cjs +11 -12
  54. package/dist/jobs/trigger.d.cts +4 -3
  55. package/dist/jobs/trigger.d.ts +4 -3
  56. package/dist/jobs/trigger.js +7 -8
  57. package/dist/jobs/upstash-workflow.cjs +43 -35
  58. package/dist/jobs/upstash-workflow.d.cts +2 -8
  59. package/dist/jobs/upstash-workflow.d.ts +2 -8
  60. package/dist/jobs/upstash-workflow.js +38 -30
  61. package/dist/nextjs-plugin/index.cjs +39 -3
  62. package/dist/nextjs-plugin/index.d.cts +8 -1
  63. package/dist/nextjs-plugin/index.d.ts +8 -1
  64. package/dist/nextjs-plugin/index.js +39 -3
  65. package/dist/nextjs-plugin/loader.cjs +41 -3
  66. package/dist/nextjs-plugin/loader.d.cts +1 -0
  67. package/dist/nextjs-plugin/loader.d.ts +1 -0
  68. package/dist/nextjs-plugin/loader.js +42 -4
  69. package/dist/triggers/index.cjs +145 -92
  70. package/dist/triggers/index.d.cts +20 -5
  71. package/dist/triggers/index.d.ts +20 -5
  72. package/dist/triggers/index.js +125 -82
  73. package/package.json +11 -1
  74. package/sql/postgres/00_install.sql +1 -1
  75. package/dist/chunk-UQHEW6ER.js +0 -119
  76. package/dist/chunk-UWHYJH4M.cjs +0 -126
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkYX2XPLOA_cjs = require('./chunk-YX2XPLOA.cjs');
4
- var chunkWASXTDLW_cjs = require('./chunk-WASXTDLW.cjs');
5
- var chunkV5YNKKTG_cjs = require('./chunk-V5YNKKTG.cjs');
6
-
7
- // src/jobs/shared.ts
8
- var CORRELATION_PAYLOAD_KEY = "ezlogs_correlation_id";
9
- function emitJobEvent(input) {
10
- try {
11
- const config = chunkWASXTDLW_cjs.configuration();
12
- if (!config.captureJobs) return;
13
- if (config.allExcludedJobClasses().includes(input.jobClass)) return;
14
- const sourceData = compactJobSourceData({
15
- job_class: input.jobClass,
16
- job_id: input.jobId ?? null,
17
- queue: input.queue ?? null,
18
- retry_count: input.retryCount ?? null,
19
- arguments: jobArguments(input.payload)
20
- });
21
- const event = chunkWASXTDLW_cjs.build({
22
- source_type: "background_job",
23
- source_data: sourceData,
24
- outcome: input.outcome,
25
- correlation_id: input.correlationId ?? chunkWASXTDLW_cjs.current(),
26
- resource_ids: [],
27
- context: null,
28
- duration_ms: input.durationMs ?? null,
29
- error_message: input.errorMessage ?? null,
30
- timestamp: input.startedAt
31
- });
32
- chunkWASXTDLW_cjs.pushEvent(event);
33
- } catch (error) {
34
- chunkV5YNKKTG_cjs.logger.debug(`job emit failed: ${describeError(error)}`);
35
- }
36
- }
37
- async function runJobWithCapture(meta, work) {
38
- const correlationId = meta.correlationId ?? chunkWASXTDLW_cjs.generate();
39
- return chunkWASXTDLW_cjs.runWithCorrelation(correlationId, async () => {
40
- const startedAt = /* @__PURE__ */ new Date();
41
- const startMs = startedAt.getTime();
42
- const baseMeta = {
43
- jobClass: meta.jobClass,
44
- jobId: meta.jobId ?? null,
45
- queue: meta.queue ?? null,
46
- retryCount: meta.retryCount ?? null,
47
- correlationId,
48
- startedAt,
49
- payload: meta.payload
50
- };
51
- try {
52
- const result = await work();
53
- await flushJobAuditLog(startedAt);
54
- emitJobEvent({
55
- ...baseMeta,
56
- outcome: "success",
57
- durationMs: Date.now() - startMs
58
- });
59
- return result;
60
- } catch (error) {
61
- const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
62
- await flushJobAuditLog(startedAt);
63
- if (meta.isControlFlow?.(error)) throw error;
64
- emitJobEvent({
65
- ...baseMeta,
66
- outcome: "failure",
67
- errorMessage: message,
68
- durationMs: Date.now() - startMs
69
- });
70
- throw error;
71
- }
72
- });
73
- }
74
- var JOB_FLUSH_SKEW_MS = 500;
75
- async function flushJobAuditLog(startedAt) {
76
- try {
77
- await chunkYX2XPLOA_cjs.flushAuditLog(chunkWASXTDLW_cjs.configuration().databaseReader, {
78
- since: new Date(startedAt.getTime() - JOB_FLUSH_SKEW_MS)
79
- });
80
- } catch (error) {
81
- chunkV5YNKKTG_cjs.logger.debug(`job audit flush failed: ${describeError(error)}`);
82
- }
83
- }
84
- function jobArguments(payload) {
85
- if (payload === null || payload === void 0) return null;
86
- const patterns = chunkWASXTDLW_cjs.configuration().excludedGraphqlVariableKeys;
87
- if (Array.isArray(payload)) return payload.length === 0 ? null : chunkWASXTDLW_cjs.sanitizeArgs(payload, patterns);
88
- if (typeof payload === "object" && Object.getPrototypeOf(payload) === Object.prototype) {
89
- const rest = { ...payload };
90
- delete rest[CORRELATION_PAYLOAD_KEY];
91
- if (Object.keys(rest).length === 0) return null;
92
- return chunkWASXTDLW_cjs.sanitizeArgs([rest], patterns)[0];
93
- }
94
- return chunkWASXTDLW_cjs.sanitizeArgs([payload], patterns);
95
- }
96
- function extractCorrelationFromPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
97
- if (payload === null || typeof payload !== "object") return null;
98
- const value = payload[key];
99
- return typeof value === "string" && value.length > 0 ? value : null;
100
- }
101
- function stampCorrelationOnPayload(payload, key = CORRELATION_PAYLOAD_KEY) {
102
- if (!payload || typeof payload !== "object") return;
103
- if (typeof payload[key] === "string" && payload[key]) return;
104
- const id = chunkWASXTDLW_cjs.current();
105
- if (!id) return;
106
- payload[key] = id;
107
- }
108
- function compactJobSourceData(data) {
109
- const out = {};
110
- for (const key of Object.keys(data)) {
111
- const value = data[key];
112
- if (value !== null && value !== void 0) out[key] = value;
113
- }
114
- return out;
115
- }
116
- function describeError(error) {
117
- if (error instanceof Error) return `${error.name}: ${error.message}`;
118
- return String(error);
119
- }
120
-
121
- exports.CORRELATION_PAYLOAD_KEY = CORRELATION_PAYLOAD_KEY;
122
- exports.emitJobEvent = emitJobEvent;
123
- exports.extractCorrelationFromPayload = extractCorrelationFromPayload;
124
- exports.flushJobAuditLog = flushJobAuditLog;
125
- exports.runJobWithCapture = runJobWithCapture;
126
- exports.stampCorrelationOnPayload = stampCorrelationOnPayload;