ezlogs-nextjs 0.4.1 → 0.4.3
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 +21 -10
- package/dist/actors/index.d.cts +1 -1
- package/dist/actors/index.d.ts +1 -1
- package/dist/{chunk-B7SH6V7M.js → chunk-GI6BM4MR.js} +2 -1
- package/dist/{chunk-VROC3BO3.cjs → chunk-GMHOUAKD.cjs} +12 -12
- package/dist/{chunk-2X6IZ2JX.js → chunk-MHBS5FEP.js} +2 -2
- package/dist/{chunk-ULFJOPQ2.cjs → chunk-MMLQXSSD.cjs} +2 -1
- package/dist/{chunk-SH5NGIX3.js → chunk-NINIAL7M.js} +1 -1
- package/dist/{chunk-LMG2SNTF.cjs → chunk-NX4EL7BY.cjs} +4 -4
- package/dist/{chunk-ZSFJ3UQV.cjs → chunk-PS4U2GFJ.cjs} +5 -5
- package/dist/{chunk-GILAKFP7.cjs → chunk-R6IWVTX3.cjs} +21 -21
- package/dist/{chunk-KCCKURJW.js → chunk-U22T7QYY.js} +3 -3
- package/dist/{chunk-DLUZRHHW.js → chunk-YMIGZYFH.js} +1 -1
- package/dist/{chunk-OJKWSUMK.cjs → chunk-YXZZNZG6.cjs} +9 -9
- package/dist/{chunk-H4K5QDXE.js → chunk-Z2TM3LGG.js} +1 -1
- package/dist/{configuration-Pshqvpkk.d.cts → configuration-CJ5yKVlP.d.cts} +2 -1
- package/dist/{configuration-Pshqvpkk.d.ts → configuration-CJ5yKVlP.d.ts} +2 -1
- 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 +156 -119
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +62 -25
- package/dist/jobs/bullmq.cjs +16 -16
- package/dist/jobs/bullmq.js +4 -4
- package/dist/jobs/inngest.cjs +17 -17
- package/dist/jobs/inngest.js +4 -4
- 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 +15 -15
- package/dist/jobs/upstash-workflow.js +4 -4
- package/dist/triggers/index.cjs +16 -16
- package/dist/triggers/index.js +5 -5
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InitOptions } from './configuration-
|
|
2
|
-
export { A as ActorContext, a as ActorFromRequest, b as ActorPrincipal, D as DisplayNameMap } from './configuration-
|
|
1
|
+
import { I as InitOptions } from './configuration-CJ5yKVlP.cjs';
|
|
2
|
+
export { A as ActorContext, a as ActorFromRequest, b as ActorPrincipal, D as DisplayNameMap } from './configuration-CJ5yKVlP.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* EventBuilder — port of ez_logs_agent/lib/ez_logs_agent/event_builder.rb.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InitOptions } from './configuration-
|
|
2
|
-
export { A as ActorContext, a as ActorFromRequest, b as ActorPrincipal, D as DisplayNameMap } from './configuration-
|
|
1
|
+
import { I as InitOptions } from './configuration-CJ5yKVlP.js';
|
|
2
|
+
export { A as ActorContext, a as ActorFromRequest, b as ActorPrincipal, D as DisplayNameMap } from './configuration-CJ5yKVlP.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* EventBuilder — port of ez_logs_agent/lib/ez_logs_agent/event_builder.rb.
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { patchPgClient } from './chunk-
|
|
2
|
-
import { flushAuditLog, runWithEmittedAuditIdsScope, auditLogInstalled, checkAuditLogAccess, detectTriggerTrackedTables, maintainAuditLogAfterRequests } from './chunk-
|
|
3
|
-
import { build, pushEvent, maskAuthParams, isAuthActionName, isAuthPath, scrubSecretsInText, buffer_exports, sanitizeRequestParams, passesLuhn,
|
|
4
|
-
export { ArgError, build as buildEvent } from './chunk-
|
|
5
|
-
import { configuration, resolveCorrelation, runWithCorrelation, maybeExtractSupabaseActor, endCorrelationScope, getCurrentActor, current, makeAsyncContextCapture, runWithActorScope, setActor, DEFAULT_EXCLUDED_EXTENSIONS } from './chunk-
|
|
1
|
+
import { patchPgClient } from './chunk-Z2TM3LGG.js';
|
|
2
|
+
import { flushAuditLog, runWithEmittedAuditIdsScope, auditLogInstalled, checkAuditLogAccess, detectTriggerTrackedTables, maintainAuditLogAfterRequests } from './chunk-MHBS5FEP.js';
|
|
3
|
+
import { build, pushEvent, maskAuthParams, isAuthActionName, isAuthPath, scrubSecretsInText, buffer_exports, sanitizeRequestParams, passesLuhn, isSensitiveKey, drainEvents } from './chunk-NINIAL7M.js';
|
|
4
|
+
export { ArgError, build as buildEvent } from './chunk-NINIAL7M.js';
|
|
5
|
+
import { configuration, resolveCorrelation, runWithCorrelation, maybeExtractSupabaseActor, endCorrelationScope, getCurrentActor, current, makeAsyncContextCapture, runWithActorScope, setActor, DEFAULT_EXCLUDED_EXTENSIONS } from './chunk-GI6BM4MR.js';
|
|
6
6
|
import { logger, setLogLevel } from './chunk-FCFVIRQF.js';
|
|
7
7
|
import './chunk-SIAA4J6H.js';
|
|
8
8
|
|
|
@@ -122,7 +122,7 @@ var GLOBAL_KEY = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:flush-scheduler-state
|
|
|
122
122
|
function state() {
|
|
123
123
|
const g = globalThis;
|
|
124
124
|
if (!g[GLOBAL_KEY]) {
|
|
125
|
-
g[GLOBAL_KEY] = { timer: null, inFlight: false };
|
|
125
|
+
g[GLOBAL_KEY] = { timer: null, inFlight: false, current: null, followUp: null };
|
|
126
126
|
}
|
|
127
127
|
return g[GLOBAL_KEY];
|
|
128
128
|
}
|
|
@@ -150,15 +150,37 @@ var flushScheduler = {
|
|
|
150
150
|
isRunning() {
|
|
151
151
|
return state().timer !== null;
|
|
152
152
|
},
|
|
153
|
-
/**
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Drain and send now; resolves once this caller's events are sent (or
|
|
155
|
+
* dropped). If a send is already running, one more drain is queued after
|
|
156
|
+
* it, so events buffered since that send started are covered too: on
|
|
157
|
+
* serverless, overlapping requests each hand this promise to waitUntil.
|
|
158
|
+
* Concurrent callers share that single follow-up, so a slow server never
|
|
159
|
+
* builds a queue.
|
|
160
|
+
*/
|
|
161
|
+
flushNow() {
|
|
162
|
+
const s = state();
|
|
163
|
+
if (!s.inFlight || !s.current) return tick();
|
|
164
|
+
if (!s.followUp) {
|
|
165
|
+
s.followUp = s.current.then(() => {
|
|
166
|
+
s.followUp = null;
|
|
167
|
+
return tick();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return s.followUp;
|
|
156
171
|
}
|
|
157
172
|
};
|
|
158
|
-
|
|
173
|
+
function tick() {
|
|
159
174
|
const s = state();
|
|
160
|
-
if (s.inFlight) return;
|
|
175
|
+
if (s.inFlight && s.current) return s.current;
|
|
161
176
|
s.inFlight = true;
|
|
177
|
+
s.current = runTick().finally(() => {
|
|
178
|
+
s.inFlight = false;
|
|
179
|
+
s.current = null;
|
|
180
|
+
});
|
|
181
|
+
return s.current;
|
|
182
|
+
}
|
|
183
|
+
async function runTick() {
|
|
162
184
|
try {
|
|
163
185
|
const events = drainEvents();
|
|
164
186
|
if (events.length > 0) await retrySender.send(events);
|
|
@@ -169,8 +191,6 @@ async function tick() {
|
|
|
169
191
|
if (swept.length > 0) await retrySender.send(swept);
|
|
170
192
|
} catch (error) {
|
|
171
193
|
logger.error(`FlushScheduler tick failed: ${describeError3(error)}`);
|
|
172
|
-
} finally {
|
|
173
|
-
s.inFlight = false;
|
|
174
194
|
}
|
|
175
195
|
}
|
|
176
196
|
function sendInterval() {
|
|
@@ -798,10 +818,7 @@ function captureRoute(handler, context = {}) {
|
|
|
798
818
|
durationMs: handlerMs ?? Date.now() - startMs,
|
|
799
819
|
startedAt: new Date(startMs)
|
|
800
820
|
});
|
|
801
|
-
|
|
802
|
-
await flushScheduler.flushNow().catch(() => {
|
|
803
|
-
});
|
|
804
|
-
}
|
|
821
|
+
await flushOnServerless();
|
|
805
822
|
endCorrelationScope();
|
|
806
823
|
};
|
|
807
824
|
try {
|
|
@@ -1031,9 +1048,7 @@ function capturePagesApi(handler, context = {}) {
|
|
|
1031
1048
|
durationMs: Date.now() - startMs,
|
|
1032
1049
|
startedAt: new Date(startMs)
|
|
1033
1050
|
});
|
|
1034
|
-
|
|
1035
|
-
await flushScheduler.flushNow().catch(() => void 0);
|
|
1036
|
-
}
|
|
1051
|
+
await flushOnServerless();
|
|
1037
1052
|
endCorrelationScope();
|
|
1038
1053
|
}
|
|
1039
1054
|
})
|
|
@@ -1112,9 +1127,7 @@ function captureServerAction(action, actionName) {
|
|
|
1112
1127
|
});
|
|
1113
1128
|
throw e;
|
|
1114
1129
|
} finally {
|
|
1115
|
-
|
|
1116
|
-
await flushScheduler.flushNow().catch(() => void 0);
|
|
1117
|
-
}
|
|
1130
|
+
await flushOnServerless();
|
|
1118
1131
|
endCorrelationScope();
|
|
1119
1132
|
}
|
|
1120
1133
|
})
|
|
@@ -1928,6 +1941,31 @@ function followBody(response, method, onDone, onChunk) {
|
|
|
1928
1941
|
return null;
|
|
1929
1942
|
}
|
|
1930
1943
|
}
|
|
1944
|
+
var SERVERLESS_INLINE_FLUSH_MS = 2e3;
|
|
1945
|
+
async function flushOnServerless() {
|
|
1946
|
+
if (!isServerless()) return;
|
|
1947
|
+
try {
|
|
1948
|
+
const waitUntil = platformWaitUntil();
|
|
1949
|
+
if (waitUntil) {
|
|
1950
|
+
waitUntil(flushScheduler.flushNow());
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
} catch (e) {
|
|
1954
|
+
logger.debug(`waitUntil unavailable, flushing inline: ${describeError5(e)}`);
|
|
1955
|
+
}
|
|
1956
|
+
let timer;
|
|
1957
|
+
try {
|
|
1958
|
+
await Promise.race([
|
|
1959
|
+
flushScheduler.flushNow(),
|
|
1960
|
+
new Promise((resolve) => {
|
|
1961
|
+
timer = setTimeout(resolve, SERVERLESS_INLINE_FLUSH_MS);
|
|
1962
|
+
})
|
|
1963
|
+
]);
|
|
1964
|
+
} catch {
|
|
1965
|
+
} finally {
|
|
1966
|
+
clearTimeout(timer);
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1931
1969
|
function platformWaitUntil() {
|
|
1932
1970
|
for (const key of ["@next/request-context", "@vercel/request-context"]) {
|
|
1933
1971
|
try {
|
|
@@ -2097,8 +2135,7 @@ function announceStartup(serverUrl, projectToken) {
|
|
|
2097
2135
|
if (g[STARTUP_ANNOUNCED_KEY]) return;
|
|
2098
2136
|
g[STARTUP_ANNOUNCED_KEY] = true;
|
|
2099
2137
|
if (!serverUrl || !projectToken) {
|
|
2100
|
-
|
|
2101
|
-
logger.warn(`not capturing: ${missing} missing in ezlogs.init() (check EZLOGS_SERVER_URL / EZLOGS_PROJECT_TOKEN)`);
|
|
2138
|
+
logger.warn("not capturing: projectToken missing in ezlogs.init() (check EZLOGS_PROJECT_TOKEN)");
|
|
2102
2139
|
return;
|
|
2103
2140
|
}
|
|
2104
2141
|
let host = serverUrl;
|
package/dist/jobs/bullmq.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
var
|
|
3
|
+
var chunkR6IWVTX3_cjs = require('../chunk-R6IWVTX3.cjs');
|
|
4
|
+
require('../chunk-GMHOUAKD.cjs');
|
|
5
|
+
require('../chunk-YXZZNZG6.cjs');
|
|
6
|
+
var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.cjs');
|
|
7
7
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
8
8
|
require('../chunk-ZDSQYCYV.cjs');
|
|
9
9
|
|
|
@@ -39,7 +39,7 @@ function wrapBullQueue(queue) {
|
|
|
39
39
|
const wrappedAddBulk = (jobs) => {
|
|
40
40
|
const stamped = jobs.map((j) => ({ ...j, data: stampPayload(j.data) }));
|
|
41
41
|
const ours = stamped.map((j) => isOurs(j.data));
|
|
42
|
-
const token = ours.includes(true) ?
|
|
42
|
+
const token = ours.includes(true) ? chunkR6IWVTX3_cjs.signedActorToken(chunkMMLQXSSD_cjs.current()) : null;
|
|
43
43
|
return inOrder(
|
|
44
44
|
token,
|
|
45
45
|
(t) => originalAddBulk(stamped.map((j, i) => ours[i] ? { ...j, data: withActor(j.data, t) } : j))
|
|
@@ -70,8 +70,8 @@ function wrapBullWorker(worker) {
|
|
|
70
70
|
internals.processFn = function ezlogsProcess(...args) {
|
|
71
71
|
const job = args[0] ?? {};
|
|
72
72
|
if (typeof args[0] === "object" && args[0] !== null) reported.add(args[0]);
|
|
73
|
-
const correlationId =
|
|
74
|
-
const run = (actor) =>
|
|
73
|
+
const correlationId = chunkR6IWVTX3_cjs.extractCorrelationFromPayload(job.data);
|
|
74
|
+
const run = (actor) => chunkR6IWVTX3_cjs.runJobWithCapture(
|
|
75
75
|
{
|
|
76
76
|
jobClass: job.name ?? worker.name ?? "BullMQJob",
|
|
77
77
|
jobId: job.id !== void 0 && job.id !== null ? String(job.id) : null,
|
|
@@ -86,9 +86,9 @@ function wrapBullWorker(worker) {
|
|
|
86
86
|
},
|
|
87
87
|
() => Promise.resolve(original.apply(this, args))
|
|
88
88
|
);
|
|
89
|
-
const token = job.data?.[
|
|
89
|
+
const token = job.data?.[chunkR6IWVTX3_cjs.ACTOR_PAYLOAD_KEY];
|
|
90
90
|
if (!correlationId || token === void 0) return run(null);
|
|
91
|
-
return
|
|
91
|
+
return chunkR6IWVTX3_cjs.readActorToken(token, correlationId).then(run);
|
|
92
92
|
};
|
|
93
93
|
worker.on("failed", (...args) => {
|
|
94
94
|
const job = args[0];
|
|
@@ -129,10 +129,10 @@ function markWrapped(worker) {
|
|
|
129
129
|
}
|
|
130
130
|
function captureJob(job, worker, outcome, errorMessage) {
|
|
131
131
|
try {
|
|
132
|
-
const correlationId =
|
|
132
|
+
const correlationId = chunkR6IWVTX3_cjs.extractCorrelationFromPayload(job.data);
|
|
133
133
|
const startedAt = typeof job.timestamp === "number" ? new Date(job.timestamp) : /* @__PURE__ */ new Date();
|
|
134
134
|
const durationMs = job.timestamp ? Date.now() - job.timestamp : null;
|
|
135
|
-
|
|
135
|
+
chunkR6IWVTX3_cjs.emitJobEvent({
|
|
136
136
|
jobClass: job.name ?? worker.name ?? "BullMQJob",
|
|
137
137
|
jobId: job.id !== void 0 && job.id !== null ? String(job.id) : null,
|
|
138
138
|
queue: job.queueName ?? worker.name ?? null,
|
|
@@ -149,22 +149,22 @@ function captureJob(job, worker, outcome, errorMessage) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
function pendingActorTokenFor(data) {
|
|
152
|
-
return isOurs(data) ?
|
|
152
|
+
return isOurs(data) ? chunkR6IWVTX3_cjs.signedActorToken(chunkMMLQXSSD_cjs.current()) : null;
|
|
153
153
|
}
|
|
154
154
|
function isOurs(data) {
|
|
155
155
|
if (data === null || typeof data !== "object" || Array.isArray(data)) return false;
|
|
156
156
|
const obj = data;
|
|
157
|
-
const id =
|
|
158
|
-
return Boolean(id) && obj[
|
|
157
|
+
const id = chunkMMLQXSSD_cjs.current();
|
|
158
|
+
return Boolean(id) && obj[chunkR6IWVTX3_cjs.CORRELATION_PAYLOAD_KEY] === id && !(chunkR6IWVTX3_cjs.ACTOR_PAYLOAD_KEY in obj);
|
|
159
159
|
}
|
|
160
160
|
function withActor(data, token) {
|
|
161
|
-
return token ? { ...data, [
|
|
161
|
+
return token ? { ...data, [chunkR6IWVTX3_cjs.ACTOR_PAYLOAD_KEY]: token } : data;
|
|
162
162
|
}
|
|
163
163
|
function stampPayload(data) {
|
|
164
164
|
if (data === null || typeof data !== "object" || Array.isArray(data)) {
|
|
165
165
|
return data;
|
|
166
166
|
}
|
|
167
|
-
return
|
|
167
|
+
return chunkR6IWVTX3_cjs.stampCorrelationOnPayload(data, chunkR6IWVTX3_cjs.CORRELATION_PAYLOAD_KEY);
|
|
168
168
|
}
|
|
169
169
|
function describeError(error) {
|
|
170
170
|
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
package/dist/jobs/bullmq.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { extractCorrelationFromPayload, ACTOR_PAYLOAD_KEY, readActorToken, emitJobEvent, signedActorToken, CORRELATION_PAYLOAD_KEY, stampCorrelationOnPayload, runJobWithCapture } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import { current } from '../chunk-
|
|
1
|
+
import { extractCorrelationFromPayload, ACTOR_PAYLOAD_KEY, readActorToken, emitJobEvent, signedActorToken, CORRELATION_PAYLOAD_KEY, stampCorrelationOnPayload, runJobWithCapture } from '../chunk-U22T7QYY.js';
|
|
2
|
+
import '../chunk-MHBS5FEP.js';
|
|
3
|
+
import '../chunk-NINIAL7M.js';
|
|
4
|
+
import { current } from '../chunk-GI6BM4MR.js';
|
|
5
5
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
6
6
|
import '../chunk-SIAA4J6H.js';
|
|
7
7
|
|
package/dist/jobs/inngest.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
var
|
|
3
|
+
var chunkR6IWVTX3_cjs = require('../chunk-R6IWVTX3.cjs');
|
|
4
|
+
require('../chunk-GMHOUAKD.cjs');
|
|
5
|
+
require('../chunk-YXZZNZG6.cjs');
|
|
6
|
+
var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.cjs');
|
|
7
7
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
8
8
|
require('../chunk-ZDSQYCYV.cjs');
|
|
9
9
|
|
|
@@ -32,7 +32,7 @@ function ezlogsInngestMiddleware() {
|
|
|
32
32
|
const attempt = typeof args.ctx?.attempt === "number" ? args.ctx.attempt : 0;
|
|
33
33
|
const eventName = args.ctx?.event?.name ?? null;
|
|
34
34
|
const eventData = args.ctx?.event?.data;
|
|
35
|
-
const correlationId =
|
|
35
|
+
const correlationId = chunkR6IWVTX3_cjs.extractCorrelationFromPayload(args.ctx?.event?.data) ?? chunkMMLQXSSD_cjs.generate();
|
|
36
36
|
const startedAt = /* @__PURE__ */ new Date();
|
|
37
37
|
const startMs = startedAt.getTime();
|
|
38
38
|
return {
|
|
@@ -44,7 +44,7 @@ function ezlogsInngestMiddleware() {
|
|
|
44
44
|
const error = result?.error;
|
|
45
45
|
const outcome = error ? "failure" : "success";
|
|
46
46
|
const errorMessage = error ? formatError(error) : null;
|
|
47
|
-
|
|
47
|
+
chunkR6IWVTX3_cjs.emitJobEvent({
|
|
48
48
|
jobClass: fnId,
|
|
49
49
|
jobId: runId,
|
|
50
50
|
queue: eventName,
|
|
@@ -73,7 +73,7 @@ function ezlogsInngestMiddleware() {
|
|
|
73
73
|
// would carry the first request's id and actor).
|
|
74
74
|
transformInput(args) {
|
|
75
75
|
try {
|
|
76
|
-
const id =
|
|
76
|
+
const id = chunkMMLQXSSD_cjs.current();
|
|
77
77
|
if (!id) return;
|
|
78
78
|
if (!Array.isArray(args.payloads)) return;
|
|
79
79
|
const stamped = [];
|
|
@@ -87,13 +87,13 @@ function ezlogsInngestMiddleware() {
|
|
|
87
87
|
return payload;
|
|
88
88
|
}
|
|
89
89
|
const copy = { ...data, ezlogs_correlation_id: id };
|
|
90
|
-
if (!(
|
|
90
|
+
if (!(chunkR6IWVTX3_cjs.ACTOR_PAYLOAD_KEY in copy)) stamped.push(copy);
|
|
91
91
|
return { ...payload, data: copy };
|
|
92
92
|
});
|
|
93
|
-
const pending = stamped.length > 0 ?
|
|
93
|
+
const pending = stamped.length > 0 ? chunkR6IWVTX3_cjs.signedActorToken(id) : null;
|
|
94
94
|
if (!pending) return { payloads };
|
|
95
95
|
return pending.then((token) => {
|
|
96
|
-
if (token) for (const data of stamped) data[
|
|
96
|
+
if (token) for (const data of stamped) data[chunkR6IWVTX3_cjs.ACTOR_PAYLOAD_KEY] = token;
|
|
97
97
|
return { payloads };
|
|
98
98
|
});
|
|
99
99
|
} catch (error) {
|
|
@@ -107,20 +107,20 @@ function ezlogsInngestMiddleware() {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
async function runInsideInngestCorrelation(event, callback) {
|
|
110
|
-
const carried =
|
|
111
|
-
const id = carried ??
|
|
112
|
-
const token = event?.data?.[
|
|
113
|
-
const actor = carried && token !== void 0 ? await
|
|
110
|
+
const carried = chunkR6IWVTX3_cjs.extractCorrelationFromPayload(event?.data);
|
|
111
|
+
const id = carried ?? chunkMMLQXSSD_cjs.generate();
|
|
112
|
+
const token = event?.data?.[chunkR6IWVTX3_cjs.ACTOR_PAYLOAD_KEY];
|
|
113
|
+
const actor = carried && token !== void 0 ? await chunkR6IWVTX3_cjs.readActorToken(token, carried) : null;
|
|
114
114
|
const startedAt = /* @__PURE__ */ new Date();
|
|
115
115
|
const body = async () => {
|
|
116
116
|
try {
|
|
117
117
|
return await callback();
|
|
118
118
|
} finally {
|
|
119
|
-
await
|
|
119
|
+
await chunkR6IWVTX3_cjs.flushJobAuditLog(startedAt);
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
const scoped = () => body().finally(
|
|
123
|
-
return
|
|
122
|
+
const scoped = () => body().finally(chunkMMLQXSSD_cjs.endCorrelationScope);
|
|
123
|
+
return chunkMMLQXSSD_cjs.runWithCorrelation(id, () => chunkMMLQXSSD_cjs.runWithActorScope(scoped, actor));
|
|
124
124
|
}
|
|
125
125
|
function functionId(fn) {
|
|
126
126
|
try {
|
package/dist/jobs/inngest.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ACTOR_PAYLOAD_KEY, signedActorToken, extractCorrelationFromPayload, emitJobEvent, readActorToken, flushJobAuditLog } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import { current, generate, runWithCorrelation, runWithActorScope, endCorrelationScope } from '../chunk-
|
|
1
|
+
import { ACTOR_PAYLOAD_KEY, signedActorToken, extractCorrelationFromPayload, emitJobEvent, readActorToken, flushJobAuditLog } from '../chunk-U22T7QYY.js';
|
|
2
|
+
import '../chunk-MHBS5FEP.js';
|
|
3
|
+
import '../chunk-NINIAL7M.js';
|
|
4
|
+
import { current, generate, runWithCorrelation, runWithActorScope, endCorrelationScope } from '../chunk-GI6BM4MR.js';
|
|
5
5
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
6
6
|
import '../chunk-SIAA4J6H.js';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
3
|
+
var chunkR6IWVTX3_cjs = require('../chunk-R6IWVTX3.cjs');
|
|
4
|
+
require('../chunk-GMHOUAKD.cjs');
|
|
5
|
+
require('../chunk-YXZZNZG6.cjs');
|
|
6
|
+
require('../chunk-MMLQXSSD.cjs');
|
|
7
7
|
require('../chunk-TWTG5ILJ.cjs');
|
|
8
8
|
require('../chunk-ZDSQYCYV.cjs');
|
|
9
9
|
|
|
@@ -41,21 +41,21 @@ function wrapPgmqSchema(schema) {
|
|
|
41
41
|
}
|
|
42
42
|
function stampPgmqMessage(args) {
|
|
43
43
|
if ("message" in args && isPlainObject(args.message)) {
|
|
44
|
-
return { ...args, message:
|
|
44
|
+
return { ...args, message: chunkR6IWVTX3_cjs.stampCorrelationOnPayload(args.message) };
|
|
45
45
|
}
|
|
46
46
|
if (Array.isArray(args.messages)) {
|
|
47
47
|
return {
|
|
48
48
|
...args,
|
|
49
49
|
messages: args.messages.map(
|
|
50
|
-
(msg) => isPlainObject(msg) ?
|
|
50
|
+
(msg) => isPlainObject(msg) ? chunkR6IWVTX3_cjs.stampCorrelationOnPayload(msg) : msg
|
|
51
51
|
)
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
return args;
|
|
55
55
|
}
|
|
56
56
|
async function captureQueueMessage(meta, work) {
|
|
57
|
-
const correlationId =
|
|
58
|
-
return
|
|
57
|
+
const correlationId = chunkR6IWVTX3_cjs.extractCorrelationFromPayload(meta.message);
|
|
58
|
+
return chunkR6IWVTX3_cjs.runJobWithCapture(
|
|
59
59
|
{
|
|
60
60
|
jobClass: meta.queueName,
|
|
61
61
|
jobId: meta.messageId !== void 0 && meta.messageId !== null ? String(meta.messageId) : null,
|
|
@@ -69,7 +69,7 @@ async function captureQueueMessage(meta, work) {
|
|
|
69
69
|
}
|
|
70
70
|
function stampPgmqPayload(message) {
|
|
71
71
|
if (!isPlainObject(message)) return message;
|
|
72
|
-
return
|
|
72
|
+
return chunkR6IWVTX3_cjs.stampCorrelationOnPayload(message);
|
|
73
73
|
}
|
|
74
74
|
function isPlainObject(value) {
|
|
75
75
|
if (value === null || typeof value !== "object") return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { extractCorrelationFromPayload, runJobWithCapture, stampCorrelationOnPayload } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
import { extractCorrelationFromPayload, runJobWithCapture, stampCorrelationOnPayload } from '../chunk-U22T7QYY.js';
|
|
2
|
+
import '../chunk-MHBS5FEP.js';
|
|
3
|
+
import '../chunk-NINIAL7M.js';
|
|
4
|
+
import '../chunk-GI6BM4MR.js';
|
|
5
5
|
import '../chunk-FCFVIRQF.js';
|
|
6
6
|
import '../chunk-SIAA4J6H.js';
|
|
7
7
|
|
package/dist/jobs/trigger.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
var
|
|
3
|
+
var chunkR6IWVTX3_cjs = require('../chunk-R6IWVTX3.cjs');
|
|
4
|
+
require('../chunk-GMHOUAKD.cjs');
|
|
5
|
+
require('../chunk-YXZZNZG6.cjs');
|
|
6
|
+
var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.cjs');
|
|
7
7
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
8
8
|
require('../chunk-ZDSQYCYV.cjs');
|
|
9
9
|
|
|
@@ -31,20 +31,20 @@ async function runWithEzlogsCapture(params) {
|
|
|
31
31
|
const queueName = ctx.run?.queue?.name ?? null;
|
|
32
32
|
const attemptNumber = ctx.attempt?.number ?? 1;
|
|
33
33
|
const retryCount = Math.max(0, attemptNumber - 1);
|
|
34
|
-
return
|
|
34
|
+
return chunkR6IWVTX3_cjs.runJobWithCapture(
|
|
35
35
|
{
|
|
36
36
|
jobClass: taskId,
|
|
37
37
|
jobId: runId,
|
|
38
38
|
queue: queueName,
|
|
39
39
|
retryCount,
|
|
40
|
-
correlationId:
|
|
40
|
+
correlationId: chunkR6IWVTX3_cjs.extractCorrelationFromPayload(params.payload),
|
|
41
41
|
payload: params.payload
|
|
42
42
|
},
|
|
43
43
|
() => params.next()
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
function stampPayloadForTrigger(payload) {
|
|
47
|
-
const id =
|
|
47
|
+
const id = chunkMMLQXSSD_cjs.current();
|
|
48
48
|
if (!id) return payload;
|
|
49
49
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
50
50
|
return payload;
|
package/dist/jobs/trigger.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { runJobWithCapture, extractCorrelationFromPayload } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import { current } from '../chunk-
|
|
1
|
+
import { runJobWithCapture, extractCorrelationFromPayload } from '../chunk-U22T7QYY.js';
|
|
2
|
+
import '../chunk-MHBS5FEP.js';
|
|
3
|
+
import '../chunk-NINIAL7M.js';
|
|
4
|
+
import { current } from '../chunk-GI6BM4MR.js';
|
|
5
5
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
6
6
|
import '../chunk-SIAA4J6H.js';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
var
|
|
3
|
+
var chunkR6IWVTX3_cjs = require('../chunk-R6IWVTX3.cjs');
|
|
4
|
+
require('../chunk-GMHOUAKD.cjs');
|
|
5
|
+
require('../chunk-YXZZNZG6.cjs');
|
|
6
|
+
var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.cjs');
|
|
7
7
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
8
8
|
require('../chunk-ZDSQYCYV.cjs');
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ function wrapWorkflowClient(client) {
|
|
|
29
29
|
if (typeof client.trigger === "function") {
|
|
30
30
|
const original = client.trigger.bind(client);
|
|
31
31
|
client.trigger = async (params) => {
|
|
32
|
-
if (
|
|
32
|
+
if (chunkMMLQXSSD_cjs.current()) await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
|
|
33
33
|
return original(
|
|
34
34
|
Array.isArray(params) ? await Promise.all(params.map(stampTriggerOptions)) : await stampTriggerOptions(params)
|
|
35
35
|
);
|
|
@@ -43,14 +43,14 @@ function wrapWorkflowClient(client) {
|
|
|
43
43
|
return client;
|
|
44
44
|
}
|
|
45
45
|
async function stampTriggerOptions(options) {
|
|
46
|
-
const current2 =
|
|
46
|
+
const current2 = chunkMMLQXSSD_cjs.current();
|
|
47
47
|
if (!current2 || !options || typeof options !== "object") return options;
|
|
48
48
|
const opts = options;
|
|
49
49
|
const headers = { ...opts.headers ?? {} };
|
|
50
50
|
const supplied = Object.keys(headers).find((k) => k.toLowerCase() === CORRELATION_HEADER);
|
|
51
51
|
const id = supplied ? headers[supplied] : current2;
|
|
52
52
|
if (!supplied) headers[CORRELATION_HEADER] = id;
|
|
53
|
-
const token = AGENT_CORRELATION_ID.test(id) ? await
|
|
53
|
+
const token = AGENT_CORRELATION_ID.test(id) ? await chunkR6IWVTX3_cjs.actorToken(id) : null;
|
|
54
54
|
if (token && !Object.keys(headers).some((k) => k.toLowerCase() === ACTOR_HEADER)) {
|
|
55
55
|
headers[ACTOR_HEADER] = token;
|
|
56
56
|
}
|
|
@@ -75,15 +75,15 @@ function wrapQStashClient(client) {
|
|
|
75
75
|
return client;
|
|
76
76
|
}
|
|
77
77
|
async function stampPublishRequest(request) {
|
|
78
|
-
const id =
|
|
78
|
+
const id = chunkMMLQXSSD_cjs.current();
|
|
79
79
|
if (!id || !request || typeof request !== "object") return request;
|
|
80
80
|
const headerKey = `${FORWARD_PREFIX}${CORRELATION_HEADER}`;
|
|
81
81
|
const raw = request.headers;
|
|
82
82
|
const headers = raw instanceof Headers || Array.isArray(raw) ? Object.fromEntries(new Headers(raw)) : { ...raw ?? {} };
|
|
83
83
|
if (Object.keys(headers).some((key) => key.toLowerCase() === headerKey)) return request;
|
|
84
84
|
headers[headerKey] = id;
|
|
85
|
-
await
|
|
86
|
-
const token = await
|
|
85
|
+
await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
|
|
86
|
+
const token = await chunkR6IWVTX3_cjs.actorToken(id);
|
|
87
87
|
if (token) headers[`${FORWARD_PREFIX}${ACTOR_HEADER}`] = token;
|
|
88
88
|
return { ...request, headers };
|
|
89
89
|
}
|
|
@@ -92,11 +92,11 @@ async function captureWorkflowRequest(meta, work) {
|
|
|
92
92
|
const correlationId = readCorrelationFromHeaders(headers);
|
|
93
93
|
const runId = readHeader(headers, "upstash-workflow-runid");
|
|
94
94
|
const retried = parseRetried(readHeader(headers, "upstash-retried"));
|
|
95
|
-
const actor = correlationId ? await
|
|
95
|
+
const actor = correlationId ? await chunkR6IWVTX3_cjs.readActorToken(
|
|
96
96
|
readHeader(headers, ACTOR_HEADER) ?? readHeader(headers, `${FORWARD_PREFIX}${ACTOR_HEADER}`),
|
|
97
97
|
correlationId
|
|
98
|
-
) ?? await
|
|
99
|
-
return
|
|
98
|
+
) ?? await chunkR6IWVTX3_cjs.readActorToken(runId ? AGENT_RUN_ID.exec(runId)?.[2] : null, correlationId) : null;
|
|
99
|
+
return chunkR6IWVTX3_cjs.runJobWithCapture(
|
|
100
100
|
{
|
|
101
101
|
jobClass: meta.workflowName,
|
|
102
102
|
jobId: runId,
|
|
@@ -111,7 +111,7 @@ async function captureWorkflowRequest(meta, work) {
|
|
|
111
111
|
function emitUpstashWorkflowEvent(input) {
|
|
112
112
|
try {
|
|
113
113
|
const headers = input.request.headers;
|
|
114
|
-
|
|
114
|
+
chunkR6IWVTX3_cjs.emitJobEvent({
|
|
115
115
|
jobClass: input.workflowName,
|
|
116
116
|
jobId: readHeader(headers, "upstash-workflow-runid"),
|
|
117
117
|
queue: input.workflowName,
|
|
@@ -129,7 +129,7 @@ function emitUpstashWorkflowEvent(input) {
|
|
|
129
129
|
function randomHex(bytes) {
|
|
130
130
|
const buf = new Uint8Array(bytes);
|
|
131
131
|
globalThis.crypto.getRandomValues(buf);
|
|
132
|
-
return
|
|
132
|
+
return chunkR6IWVTX3_cjs.toHex(buf);
|
|
133
133
|
}
|
|
134
134
|
function readHeader(headers, name) {
|
|
135
135
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { actorToken, readActorToken, runJobWithCapture, emitJobEvent, toHex } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import { current, maybeExtractSupabaseActor } from '../chunk-
|
|
1
|
+
import { actorToken, readActorToken, runJobWithCapture, emitJobEvent, toHex } from '../chunk-U22T7QYY.js';
|
|
2
|
+
import '../chunk-MHBS5FEP.js';
|
|
3
|
+
import '../chunk-NINIAL7M.js';
|
|
4
|
+
import { current, maybeExtractSupabaseActor } from '../chunk-GI6BM4MR.js';
|
|
5
5
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
6
6
|
import '../chunk-SIAA4J6H.js';
|
|
7
7
|
|