ezlogs-nextjs 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist/{chunk-B5ZUQULZ.cjs → chunk-2YCQFLXW.cjs} +3 -0
- package/dist/{chunk-RD47JECJ.js → chunk-343ZGTMH.js} +1 -1
- package/dist/{chunk-2NFJOT6Q.js → chunk-5ZMOWEBY.js} +1 -1
- package/dist/{chunk-IBSNHBUC.js → chunk-7MFKEYDN.js} +3 -0
- package/dist/{chunk-U3IJV5EJ.js → chunk-AXIQTU52.js} +1 -1
- package/dist/{chunk-RMKGMIV2.js → chunk-BE3RCFNP.js} +1 -1
- package/dist/{chunk-H3FC5HMW.cjs → chunk-CHVJ4WPM.cjs} +2 -2
- package/dist/{chunk-M3VBQ5KT.js → chunk-CYAFYBKF.js} +2 -2
- package/dist/{chunk-O7SFYXJC.cjs → chunk-EXGEA4KE.cjs} +12 -12
- package/dist/{chunk-YO6E763S.cjs → chunk-JB4UYCZI.cjs} +5 -5
- package/dist/{chunk-65HRY3PW.cjs → chunk-KOFR5OC3.cjs} +21 -21
- package/dist/{chunk-PK2Z2ABL.js → chunk-Q3HRVWCS.js} +3 -3
- package/dist/{chunk-B3WST6ES.cjs → chunk-UC2KS5EG.cjs} +9 -9
- package/dist/{chunk-DM2EAOSF.cjs → chunk-XWEBKN65.cjs} +4 -4
- package/dist/db/drizzle.cjs +3 -3
- package/dist/db/drizzle.js +2 -2
- package/dist/db/postgres-js.cjs +4 -4
- package/dist/db/postgres-js.js +2 -2
- package/dist/db/prisma.cjs +12 -12
- package/dist/db/prisma.js +2 -2
- package/dist/db/supabase.cjs +11 -11
- package/dist/db/supabase.js +2 -2
- package/dist/index.cjs +121 -106
- package/dist/index.js +21 -6
- package/dist/jobs/bullmq.cjs +17 -17
- package/dist/jobs/bullmq.js +4 -4
- package/dist/jobs/inngest.cjs +154 -50
- package/dist/jobs/inngest.d.cts +6 -6
- package/dist/jobs/inngest.d.ts +6 -6
- package/dist/jobs/inngest.js +144 -40
- package/dist/jobs/supabase-queues.cjs +9 -9
- package/dist/jobs/supabase-queues.js +4 -4
- package/dist/jobs/trigger.cjs +7 -7
- package/dist/jobs/trigger.js +4 -4
- package/dist/jobs/upstash-workflow.cjs +19 -19
- package/dist/jobs/upstash-workflow.js +5 -5
- package/dist/nextjs-plugin/loader.cjs +34 -5
- package/dist/nextjs-plugin/loader.js +34 -5
- package/dist/triggers/index.cjs +16 -16
- package/dist/triggers/index.js +5 -5
- package/package.json +1 -1
package/dist/jobs/inngest.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import { markJobDelivery } from '../chunk-
|
|
1
|
+
import { markJobDelivery } from '../chunk-BE3RCFNP.js';
|
|
2
2
|
import { instrumentFrom, instrumentClass } from '../chunk-JWJKFZBW.js';
|
|
3
|
-
import {
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import {
|
|
3
|
+
import { extractCorrelationFromPayload, emitJobEvent, ACTOR_PAYLOAD_KEY, signedActorToken, readActorToken, flushJobAuditLog, CORRELATION_PAYLOAD_KEY } from '../chunk-Q3HRVWCS.js';
|
|
4
|
+
import '../chunk-CYAFYBKF.js';
|
|
5
|
+
import '../chunk-AXIQTU52.js';
|
|
6
|
+
import { createScopedStorage, generate, current, runWithCorrelation, runWithActorScope, endCorrelationScope } from '../chunk-7MFKEYDN.js';
|
|
7
7
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
8
8
|
import '../chunk-SIAA4J6H.js';
|
|
9
9
|
|
|
10
10
|
// src/jobs/inngest.ts
|
|
11
|
-
var
|
|
11
|
+
var insideV4Run = createScopedStorage(/* @__PURE__ */ Symbol.for("ezlogs-nextjs:inngest-v4-run"));
|
|
12
12
|
function ezlogsInngestMiddleware() {
|
|
13
13
|
const middleware = function ezlogsInngestV4() {
|
|
14
|
-
|
|
15
|
-
warnedUnsupported = true;
|
|
16
|
-
logger.warn(
|
|
17
|
-
"ezlogsInngestMiddleware supports Inngest v3 only; on this Inngest version it does nothing (jobs are not captured)"
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
return {};
|
|
14
|
+
return inngestV4Hooks();
|
|
21
15
|
};
|
|
22
16
|
Object.defineProperty(middleware, "name", { value: "ezlogs-nextjs" });
|
|
23
17
|
return Object.assign(middleware, {
|
|
@@ -76,33 +70,7 @@ function ezlogsInngestMiddleware() {
|
|
|
76
70
|
// objects are never written (one reused across requests
|
|
77
71
|
// would carry the first request's id and actor).
|
|
78
72
|
transformInput(args) {
|
|
79
|
-
|
|
80
|
-
const id = current();
|
|
81
|
-
if (!id) return;
|
|
82
|
-
if (!Array.isArray(args.payloads)) return;
|
|
83
|
-
const stamped = [];
|
|
84
|
-
const payloads = args.payloads.map((payload) => {
|
|
85
|
-
if (!payload || typeof payload !== "object") return payload;
|
|
86
|
-
const data = payload.data ?? {};
|
|
87
|
-
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
88
|
-
return payload;
|
|
89
|
-
}
|
|
90
|
-
if (typeof data.ezlogs_correlation_id === "string") {
|
|
91
|
-
return payload;
|
|
92
|
-
}
|
|
93
|
-
const copy = { ...data, ezlogs_correlation_id: id };
|
|
94
|
-
if (!(ACTOR_PAYLOAD_KEY in copy)) stamped.push(copy);
|
|
95
|
-
return { ...payload, data: copy };
|
|
96
|
-
});
|
|
97
|
-
const pending = stamped.length > 0 ? signedActorToken(id) : null;
|
|
98
|
-
if (!pending) return { payloads };
|
|
99
|
-
return pending.then((token) => {
|
|
100
|
-
if (token) for (const data of stamped) data[ACTOR_PAYLOAD_KEY] = token;
|
|
101
|
-
return { payloads };
|
|
102
|
-
});
|
|
103
|
-
} catch (error) {
|
|
104
|
-
logger.debug(`inngest send-stamp failed: ${describeError(error)}`);
|
|
105
|
-
}
|
|
73
|
+
return stampSendEvents(args.payloads, (payloads) => ({ payloads }));
|
|
106
74
|
}
|
|
107
75
|
};
|
|
108
76
|
}
|
|
@@ -110,7 +78,143 @@ function ezlogsInngestMiddleware() {
|
|
|
110
78
|
}
|
|
111
79
|
});
|
|
112
80
|
}
|
|
81
|
+
function inngestV4Hooks() {
|
|
82
|
+
let runError = null;
|
|
83
|
+
let ranStep = null;
|
|
84
|
+
let executed = false;
|
|
85
|
+
return {
|
|
86
|
+
id: "ezlogs-nextjs",
|
|
87
|
+
// Before the function sees (and Inngest validates) its events: our keys
|
|
88
|
+
// are removed, so a trigger or `waitForEvent` with a strict schema
|
|
89
|
+
// still accepts them. The scope was opened from the request body.
|
|
90
|
+
transformFunctionInput(arg) {
|
|
91
|
+
executed = true;
|
|
92
|
+
try {
|
|
93
|
+
return withoutCarriedKeysInInput(arg);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
logger.debug(`inngest input strip failed: ${describeError(error)}`);
|
|
96
|
+
return arg;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
// Called for `inngest.send` and `step.sendEvent`; returns the arg with stamped copies.
|
|
100
|
+
transformSendEvent(args) {
|
|
101
|
+
return stampSendEvents(args?.events, (events) => ({ ...args, events })) ?? args;
|
|
102
|
+
},
|
|
103
|
+
// Only for steps that run in this request (`step.run`, `step.sendEvent`), not memoized ones.
|
|
104
|
+
onStepStart(args) {
|
|
105
|
+
const options = args?.stepInfo?.options;
|
|
106
|
+
const name = options?.name ?? options?.id;
|
|
107
|
+
ranStep = typeof name === "string" && name ? name : null;
|
|
108
|
+
},
|
|
109
|
+
onStepError(args) {
|
|
110
|
+
runError = args?.error ?? runError;
|
|
111
|
+
},
|
|
112
|
+
onRunError(args) {
|
|
113
|
+
runError = args?.error ?? runError;
|
|
114
|
+
},
|
|
115
|
+
async wrapRequest(args) {
|
|
116
|
+
let nextCalled = false;
|
|
117
|
+
const next = () => {
|
|
118
|
+
nextCalled = true;
|
|
119
|
+
return args.next();
|
|
120
|
+
};
|
|
121
|
+
try {
|
|
122
|
+
const body = args.fn ? await args.requestInfo?.body?.() : null;
|
|
123
|
+
if (!body || typeof body !== "object") return await next();
|
|
124
|
+
const fnId = functionId(args.fn) ?? "inngest-function";
|
|
125
|
+
const event = body.event;
|
|
126
|
+
const attempt = typeof body.ctx?.attempt === "number" ? body.ctx.attempt : 0;
|
|
127
|
+
const runId = args.runId || body.ctx?.run_id || null;
|
|
128
|
+
return await runInsideInngestCorrelation(event, () => insideV4Run.run(true, async () => {
|
|
129
|
+
const startedAt = /* @__PURE__ */ new Date();
|
|
130
|
+
try {
|
|
131
|
+
return await next();
|
|
132
|
+
} catch (error) {
|
|
133
|
+
runError = error;
|
|
134
|
+
throw error;
|
|
135
|
+
} finally {
|
|
136
|
+
if (executed) {
|
|
137
|
+
markJobDelivery();
|
|
138
|
+
emitJobEvent({
|
|
139
|
+
jobClass: fnId,
|
|
140
|
+
jobId: runId,
|
|
141
|
+
queue: event?.name ?? null,
|
|
142
|
+
step: ranStep,
|
|
143
|
+
retryCount: attempt,
|
|
144
|
+
outcome: runError ? "failure" : "success",
|
|
145
|
+
errorMessage: runError ? formatError(runError) : null,
|
|
146
|
+
durationMs: Date.now() - startedAt.getTime(),
|
|
147
|
+
startedAt,
|
|
148
|
+
payload: event?.data
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}));
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (nextCalled) throw error;
|
|
155
|
+
logger.debug(`inngest capture failed: ${describeError(error)}`);
|
|
156
|
+
return args.next();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function withoutCarriedKeysInInput(arg) {
|
|
162
|
+
const ctx = arg?.ctx;
|
|
163
|
+
if (!ctx) return arg;
|
|
164
|
+
let changed = false;
|
|
165
|
+
const strip = (value) => {
|
|
166
|
+
const out = withoutCarriedKeys(value);
|
|
167
|
+
if (out !== value) changed = true;
|
|
168
|
+
return out;
|
|
169
|
+
};
|
|
170
|
+
const event = strip(ctx.event);
|
|
171
|
+
const events = Array.isArray(ctx.events) ? ctx.events.map(strip) : ctx.events;
|
|
172
|
+
const steps = {};
|
|
173
|
+
for (const [id, step] of Object.entries(arg.steps ?? {})) {
|
|
174
|
+
steps[id] = step?.type === "data" ? { ...step, data: strip(step.data) } : step;
|
|
175
|
+
}
|
|
176
|
+
return changed ? { ...arg, ctx: { ...ctx, event, events }, steps } : arg;
|
|
177
|
+
}
|
|
178
|
+
function withoutCarriedKeys(event) {
|
|
179
|
+
const data = event?.data;
|
|
180
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return event;
|
|
181
|
+
if (!(CORRELATION_PAYLOAD_KEY in data) && !(ACTOR_PAYLOAD_KEY in data)) return event;
|
|
182
|
+
const rest = { ...data };
|
|
183
|
+
delete rest[CORRELATION_PAYLOAD_KEY];
|
|
184
|
+
delete rest[ACTOR_PAYLOAD_KEY];
|
|
185
|
+
return { ...event, data: rest };
|
|
186
|
+
}
|
|
187
|
+
function stampSendEvents(events, wrap) {
|
|
188
|
+
try {
|
|
189
|
+
const id = current();
|
|
190
|
+
if (!id) return;
|
|
191
|
+
if (!Array.isArray(events)) return;
|
|
192
|
+
const stamped = [];
|
|
193
|
+
const payloads = events.map((payload) => {
|
|
194
|
+
if (!payload || typeof payload !== "object") return payload;
|
|
195
|
+
const data = payload.data ?? {};
|
|
196
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
197
|
+
return payload;
|
|
198
|
+
}
|
|
199
|
+
if (typeof data.ezlogs_correlation_id === "string") {
|
|
200
|
+
return payload;
|
|
201
|
+
}
|
|
202
|
+
const copy = { ...data, ezlogs_correlation_id: id };
|
|
203
|
+
if (!(ACTOR_PAYLOAD_KEY in copy)) stamped.push(copy);
|
|
204
|
+
return { ...payload, data: copy };
|
|
205
|
+
});
|
|
206
|
+
const pending = stamped.length > 0 ? signedActorToken(id) : null;
|
|
207
|
+
if (!pending) return wrap(payloads);
|
|
208
|
+
return pending.then((token) => {
|
|
209
|
+
if (token) for (const data of stamped) data[ACTOR_PAYLOAD_KEY] = token;
|
|
210
|
+
return wrap(payloads);
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
logger.debug(`inngest send-stamp failed: ${describeError(error)}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
113
216
|
async function runInsideInngestCorrelation(event, callback) {
|
|
217
|
+
if (insideV4Run.read()) return callback();
|
|
114
218
|
const carried = extractCorrelationFromPayload(event?.data);
|
|
115
219
|
const id = carried ?? generate();
|
|
116
220
|
const token = event?.data?.[ACTOR_PAYLOAD_KEY];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
3
|
+
var chunkKOFR5OC3_cjs = require('../chunk-KOFR5OC3.cjs');
|
|
4
|
+
require('../chunk-EXGEA4KE.cjs');
|
|
5
|
+
require('../chunk-UC2KS5EG.cjs');
|
|
6
|
+
require('../chunk-2YCQFLXW.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: chunkKOFR5OC3_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) ? chunkKOFR5OC3_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 = chunkKOFR5OC3_cjs.extractCorrelationFromPayload(meta.message);
|
|
58
|
+
return chunkKOFR5OC3_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 chunkKOFR5OC3_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-Q3HRVWCS.js';
|
|
2
|
+
import '../chunk-CYAFYBKF.js';
|
|
3
|
+
import '../chunk-AXIQTU52.js';
|
|
4
|
+
import '../chunk-7MFKEYDN.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 chunkKOFR5OC3_cjs = require('../chunk-KOFR5OC3.cjs');
|
|
4
|
+
require('../chunk-EXGEA4KE.cjs');
|
|
5
|
+
require('../chunk-UC2KS5EG.cjs');
|
|
6
|
+
var chunk2YCQFLXW_cjs = require('../chunk-2YCQFLXW.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 chunkKOFR5OC3_cjs.runJobWithCapture(
|
|
35
35
|
{
|
|
36
36
|
jobClass: taskId,
|
|
37
37
|
jobId: runId,
|
|
38
38
|
queue: queueName,
|
|
39
39
|
retryCount,
|
|
40
|
-
correlationId:
|
|
40
|
+
correlationId: chunkKOFR5OC3_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 = chunk2YCQFLXW_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-Q3HRVWCS.js';
|
|
2
|
+
import '../chunk-CYAFYBKF.js';
|
|
3
|
+
import '../chunk-AXIQTU52.js';
|
|
4
|
+
import { current } from '../chunk-7MFKEYDN.js';
|
|
5
5
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
6
6
|
import '../chunk-SIAA4J6H.js';
|
|
7
7
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCHVJ4WPM_cjs = require('../chunk-CHVJ4WPM.cjs');
|
|
4
4
|
var chunkVJR4VB4B_cjs = require('../chunk-VJR4VB4B.cjs');
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
8
|
-
var
|
|
5
|
+
var chunkKOFR5OC3_cjs = require('../chunk-KOFR5OC3.cjs');
|
|
6
|
+
require('../chunk-EXGEA4KE.cjs');
|
|
7
|
+
require('../chunk-UC2KS5EG.cjs');
|
|
8
|
+
var chunk2YCQFLXW_cjs = require('../chunk-2YCQFLXW.cjs');
|
|
9
9
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
10
10
|
require('../chunk-ZDSQYCYV.cjs');
|
|
11
11
|
|
|
@@ -31,7 +31,7 @@ function wrapWorkflowClient(client) {
|
|
|
31
31
|
if (typeof client.trigger === "function") {
|
|
32
32
|
const original = client.trigger.bind(client);
|
|
33
33
|
client.trigger = async (params) => {
|
|
34
|
-
if (
|
|
34
|
+
if (chunk2YCQFLXW_cjs.current()) await chunk2YCQFLXW_cjs.maybeExtractSupabaseActor();
|
|
35
35
|
return original(
|
|
36
36
|
Array.isArray(params) ? await Promise.all(params.map(stampTriggerOptions)) : await stampTriggerOptions(params)
|
|
37
37
|
);
|
|
@@ -45,14 +45,14 @@ function wrapWorkflowClient(client) {
|
|
|
45
45
|
return client;
|
|
46
46
|
}
|
|
47
47
|
async function stampTriggerOptions(options) {
|
|
48
|
-
const current2 =
|
|
48
|
+
const current2 = chunk2YCQFLXW_cjs.current();
|
|
49
49
|
if (!current2 || !options || typeof options !== "object") return options;
|
|
50
50
|
const opts = options;
|
|
51
51
|
const headers = { ...opts.headers ?? {} };
|
|
52
52
|
const supplied = Object.keys(headers).find((k) => k.toLowerCase() === CORRELATION_HEADER);
|
|
53
53
|
const id = supplied ? headers[supplied] : current2;
|
|
54
54
|
if (!supplied) headers[CORRELATION_HEADER] = id;
|
|
55
|
-
const token = AGENT_CORRELATION_ID.test(id) ? await
|
|
55
|
+
const token = AGENT_CORRELATION_ID.test(id) ? await chunkKOFR5OC3_cjs.actorToken(id) : null;
|
|
56
56
|
if (token && !Object.keys(headers).some((k) => k.toLowerCase() === ACTOR_HEADER)) {
|
|
57
57
|
headers[ACTOR_HEADER] = token;
|
|
58
58
|
}
|
|
@@ -77,22 +77,22 @@ function wrapQStashClient(client) {
|
|
|
77
77
|
return client;
|
|
78
78
|
}
|
|
79
79
|
async function stampPublishRequest(request) {
|
|
80
|
-
const id =
|
|
80
|
+
const id = chunk2YCQFLXW_cjs.current();
|
|
81
81
|
if (!id || !request || typeof request !== "object") return request;
|
|
82
82
|
const headerKey = `${FORWARD_PREFIX}${CORRELATION_HEADER}`;
|
|
83
83
|
const raw = request.headers;
|
|
84
84
|
const headers = raw instanceof Headers || Array.isArray(raw) ? Object.fromEntries(new Headers(raw)) : { ...raw ?? {} };
|
|
85
85
|
if (Object.keys(headers).some((key) => key.toLowerCase() === headerKey)) return request;
|
|
86
86
|
headers[headerKey] = id;
|
|
87
|
-
await
|
|
88
|
-
const token = await
|
|
87
|
+
await chunk2YCQFLXW_cjs.maybeExtractSupabaseActor();
|
|
88
|
+
const token = await chunkKOFR5OC3_cjs.actorToken(id);
|
|
89
89
|
if (token) headers[`${FORWARD_PREFIX}${ACTOR_HEADER}`] = token;
|
|
90
90
|
return { ...request, headers };
|
|
91
91
|
}
|
|
92
92
|
var warnedNoHeaders = false;
|
|
93
93
|
async function captureWorkflowRequest(meta, work) {
|
|
94
94
|
if (meta.context?.disabled === true) return work();
|
|
95
|
-
|
|
95
|
+
chunkCHVJ4WPM_cjs.markJobDelivery();
|
|
96
96
|
if (insideStepCapture.read()) return work();
|
|
97
97
|
const headers = meta.request?.headers ?? meta.context?.headers;
|
|
98
98
|
if (!headers) {
|
|
@@ -107,11 +107,11 @@ async function captureWorkflowRequest(meta, work) {
|
|
|
107
107
|
const runId = readHeader(headers, "upstash-workflow-runid") ?? meta.context?.workflowRunId ?? null;
|
|
108
108
|
const correlationId = readCorrelationFromHeaders(headers) ?? correlationFromRunId(runId);
|
|
109
109
|
const retried = parseRetried(readHeader(headers, "upstash-retried"));
|
|
110
|
-
const actor = correlationId ? await
|
|
110
|
+
const actor = correlationId ? await chunkKOFR5OC3_cjs.readActorToken(
|
|
111
111
|
readHeader(headers, ACTOR_HEADER) ?? readHeader(headers, `${FORWARD_PREFIX}${ACTOR_HEADER}`),
|
|
112
112
|
correlationId
|
|
113
|
-
) ?? await
|
|
114
|
-
return insideStepCapture.run(true, () =>
|
|
113
|
+
) ?? await chunkKOFR5OC3_cjs.readActorToken(runId ? AGENT_RUN_ID.exec(runId)?.[2] : null, correlationId) : null;
|
|
114
|
+
return insideStepCapture.run(true, () => chunkKOFR5OC3_cjs.runJobWithCapture(
|
|
115
115
|
{
|
|
116
116
|
jobClass: meta.workflowName,
|
|
117
117
|
jobId: runId,
|
|
@@ -130,7 +130,7 @@ async function captureWorkflowRequest(meta, work) {
|
|
|
130
130
|
work
|
|
131
131
|
));
|
|
132
132
|
}
|
|
133
|
-
var insideStepCapture =
|
|
133
|
+
var insideStepCapture = chunk2YCQFLXW_cjs.createScopedStorage(/* @__PURE__ */ Symbol.for("ezlogs-nextjs:upstash-step-capture"));
|
|
134
134
|
function workflowNameOf(context) {
|
|
135
135
|
try {
|
|
136
136
|
if (typeof context.url === "string") return new URL(context.url).pathname;
|
|
@@ -185,7 +185,7 @@ function instrumentServe(original) {
|
|
|
185
185
|
if (typeof handler !== "function") continue;
|
|
186
186
|
const deliver = handler;
|
|
187
187
|
handlers[name] = function ezlogsDelivery(...args) {
|
|
188
|
-
if (signedByQStash(args[0]))
|
|
188
|
+
if (signedByQStash(args[0])) chunkCHVJ4WPM_cjs.markJobDelivery();
|
|
189
189
|
return deliver.apply(this, args);
|
|
190
190
|
};
|
|
191
191
|
}
|
|
@@ -220,7 +220,7 @@ var __ezlogsInstrument = chunkVJR4VB4B_cjs.instrumentFrom({
|
|
|
220
220
|
function emitUpstashWorkflowEvent(input) {
|
|
221
221
|
try {
|
|
222
222
|
const headers = input.request.headers;
|
|
223
|
-
|
|
223
|
+
chunkKOFR5OC3_cjs.emitJobEvent({
|
|
224
224
|
jobClass: input.workflowName,
|
|
225
225
|
jobId: readHeader(headers, "upstash-workflow-runid"),
|
|
226
226
|
queue: input.workflowName,
|
|
@@ -238,7 +238,7 @@ function emitUpstashWorkflowEvent(input) {
|
|
|
238
238
|
function randomHex(bytes) {
|
|
239
239
|
const buf = new Uint8Array(bytes);
|
|
240
240
|
globalThis.crypto.getRandomValues(buf);
|
|
241
|
-
return
|
|
241
|
+
return chunkKOFR5OC3_cjs.toHex(buf);
|
|
242
242
|
}
|
|
243
243
|
function readHeader(headers, name) {
|
|
244
244
|
try {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { markJobDelivery } from '../chunk-
|
|
1
|
+
import { markJobDelivery } from '../chunk-BE3RCFNP.js';
|
|
2
2
|
import { instrumentFrom, instrumentClass } from '../chunk-JWJKFZBW.js';
|
|
3
|
-
import { actorToken, readActorToken, runJobWithCapture, toHex, emitJobEvent } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import { createScopedStorage, current, maybeExtractSupabaseActor } from '../chunk-
|
|
3
|
+
import { actorToken, readActorToken, runJobWithCapture, toHex, emitJobEvent } from '../chunk-Q3HRVWCS.js';
|
|
4
|
+
import '../chunk-CYAFYBKF.js';
|
|
5
|
+
import '../chunk-AXIQTU52.js';
|
|
6
|
+
import { createScopedStorage, current, maybeExtractSupabaseActor } from '../chunk-7MFKEYDN.js';
|
|
7
7
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
8
8
|
import '../chunk-SIAA4J6H.js';
|
|
9
9
|
|
|
@@ -16212,19 +16212,23 @@ function rewritePagesApi(source, routeModulePath) {
|
|
|
16212
16212
|
return renamed.source + wrapperBlock;
|
|
16213
16213
|
}
|
|
16214
16214
|
function renameExport(source, name) {
|
|
16215
|
+
const end = "(?![\\p{L}\\p{N}_$\\u200C\\u200D])";
|
|
16215
16216
|
const patterns = [
|
|
16216
|
-
// `export async function NAME(`
|
|
16217
|
-
new RegExp(`(^|\\s)export\\s+async\\s+function\\s
|
|
16217
|
+
// `export async function NAME(` / `export async function* NAME(`
|
|
16218
|
+
new RegExp(`(^|\\s)export\\s+async\\s+function\\s*\\*?\\s*${name}${end}`, "mu"),
|
|
16218
16219
|
// `export function NAME(`
|
|
16219
|
-
new RegExp(`(^|\\s)export\\s+function\\s
|
|
16220
|
+
new RegExp(`(^|\\s)export\\s+function\\s*\\*?\\s*${name}${end}`, "mu"),
|
|
16220
16221
|
// `export const NAME =` / `export let NAME =` / `export var NAME =`
|
|
16221
|
-
new RegExp(`(^|\\s)export\\s+(const|let|var)\\s+${name}
|
|
16222
|
+
new RegExp(`(^|\\s)export\\s+(const|let|var)\\s+${name}${end}`, "mu")
|
|
16222
16223
|
];
|
|
16223
16224
|
for (const pattern of patterns) {
|
|
16224
16225
|
const match = source.match(pattern);
|
|
16226
|
+
if (match && pattern === patterns[2] && declaresMoreThanOne(source, match.index + match[0].length)) {
|
|
16227
|
+
return { source, changed: false };
|
|
16228
|
+
}
|
|
16225
16229
|
if (match) {
|
|
16226
16230
|
const replaced = source.replace(pattern, (full, lead) => {
|
|
16227
|
-
const rest = full.replace(/^\s*export\s+/, "").replace(new RegExp(
|
|
16231
|
+
const rest = full.replace(/^\s*export\s+/, "").replace(new RegExp(`(?<![\\p{L}\\p{N}_$])${name}${end}`, "u"), `${ALREADY_WRAPPED_MARKER}${name}`);
|
|
16228
16232
|
return `${lead}${rest}`;
|
|
16229
16233
|
});
|
|
16230
16234
|
return { source: replaced, changed: true };
|
|
@@ -16232,6 +16236,31 @@ function renameExport(source, name) {
|
|
|
16232
16236
|
}
|
|
16233
16237
|
return { source, changed: false };
|
|
16234
16238
|
}
|
|
16239
|
+
var TT_JSX_TEXT = 56320;
|
|
16240
|
+
function declaresMoreThanOne(source, from) {
|
|
16241
|
+
const sucraseParse = getSucraseParse();
|
|
16242
|
+
if (sucraseParse === null) return true;
|
|
16243
|
+
let tokens;
|
|
16244
|
+
try {
|
|
16245
|
+
tokens = sucraseParse(source, false, true, false).tokens;
|
|
16246
|
+
} catch {
|
|
16247
|
+
try {
|
|
16248
|
+
tokens = sucraseParse(source, true, true, false).tokens;
|
|
16249
|
+
} catch {
|
|
16250
|
+
return true;
|
|
16251
|
+
}
|
|
16252
|
+
}
|
|
16253
|
+
let depth = 0;
|
|
16254
|
+
for (const t of tokens) {
|
|
16255
|
+
if (t.start < from || t.isType || t.type === TT_JSX_TEXT) continue;
|
|
16256
|
+
const text = source.slice(t.start, t.end);
|
|
16257
|
+
if (text === "(" || text === "[" || text === "{" || text === "${") depth++;
|
|
16258
|
+
else if (text === ")" || text === "]" || text === "}") depth--;
|
|
16259
|
+
else if (depth === 0 && text === ",") return true;
|
|
16260
|
+
else if (depth === 0 && text === ";") return false;
|
|
16261
|
+
}
|
|
16262
|
+
return false;
|
|
16263
|
+
}
|
|
16235
16264
|
function renameDefaultExport(source) {
|
|
16236
16265
|
const fnDefault = source.match(
|
|
16237
16266
|
/(^|\n)\s*export\s+default\s+(async\s+)?function\s*([A-Za-z_$][A-Za-z0-9_$]*)?\s*\(/
|
|
@@ -16208,19 +16208,23 @@ function rewritePagesApi(source, routeModulePath) {
|
|
|
16208
16208
|
return renamed.source + wrapperBlock;
|
|
16209
16209
|
}
|
|
16210
16210
|
function renameExport(source, name) {
|
|
16211
|
+
const end = "(?![\\p{L}\\p{N}_$\\u200C\\u200D])";
|
|
16211
16212
|
const patterns = [
|
|
16212
|
-
// `export async function NAME(`
|
|
16213
|
-
new RegExp(`(^|\\s)export\\s+async\\s+function\\s
|
|
16213
|
+
// `export async function NAME(` / `export async function* NAME(`
|
|
16214
|
+
new RegExp(`(^|\\s)export\\s+async\\s+function\\s*\\*?\\s*${name}${end}`, "mu"),
|
|
16214
16215
|
// `export function NAME(`
|
|
16215
|
-
new RegExp(`(^|\\s)export\\s+function\\s
|
|
16216
|
+
new RegExp(`(^|\\s)export\\s+function\\s*\\*?\\s*${name}${end}`, "mu"),
|
|
16216
16217
|
// `export const NAME =` / `export let NAME =` / `export var NAME =`
|
|
16217
|
-
new RegExp(`(^|\\s)export\\s+(const|let|var)\\s+${name}
|
|
16218
|
+
new RegExp(`(^|\\s)export\\s+(const|let|var)\\s+${name}${end}`, "mu")
|
|
16218
16219
|
];
|
|
16219
16220
|
for (const pattern of patterns) {
|
|
16220
16221
|
const match = source.match(pattern);
|
|
16222
|
+
if (match && pattern === patterns[2] && declaresMoreThanOne(source, match.index + match[0].length)) {
|
|
16223
|
+
return { source, changed: false };
|
|
16224
|
+
}
|
|
16221
16225
|
if (match) {
|
|
16222
16226
|
const replaced = source.replace(pattern, (full, lead) => {
|
|
16223
|
-
const rest = full.replace(/^\s*export\s+/, "").replace(new RegExp(
|
|
16227
|
+
const rest = full.replace(/^\s*export\s+/, "").replace(new RegExp(`(?<![\\p{L}\\p{N}_$])${name}${end}`, "u"), `${ALREADY_WRAPPED_MARKER}${name}`);
|
|
16224
16228
|
return `${lead}${rest}`;
|
|
16225
16229
|
});
|
|
16226
16230
|
return { source: replaced, changed: true };
|
|
@@ -16228,6 +16232,31 @@ function renameExport(source, name) {
|
|
|
16228
16232
|
}
|
|
16229
16233
|
return { source, changed: false };
|
|
16230
16234
|
}
|
|
16235
|
+
var TT_JSX_TEXT = 56320;
|
|
16236
|
+
function declaresMoreThanOne(source, from) {
|
|
16237
|
+
const sucraseParse = getSucraseParse();
|
|
16238
|
+
if (sucraseParse === null) return true;
|
|
16239
|
+
let tokens;
|
|
16240
|
+
try {
|
|
16241
|
+
tokens = sucraseParse(source, false, true, false).tokens;
|
|
16242
|
+
} catch {
|
|
16243
|
+
try {
|
|
16244
|
+
tokens = sucraseParse(source, true, true, false).tokens;
|
|
16245
|
+
} catch {
|
|
16246
|
+
return true;
|
|
16247
|
+
}
|
|
16248
|
+
}
|
|
16249
|
+
let depth = 0;
|
|
16250
|
+
for (const t of tokens) {
|
|
16251
|
+
if (t.start < from || t.isType || t.type === TT_JSX_TEXT) continue;
|
|
16252
|
+
const text = source.slice(t.start, t.end);
|
|
16253
|
+
if (text === "(" || text === "[" || text === "{" || text === "${") depth++;
|
|
16254
|
+
else if (text === ")" || text === "]" || text === "}") depth--;
|
|
16255
|
+
else if (depth === 0 && text === ",") return true;
|
|
16256
|
+
else if (depth === 0 && text === ";") return false;
|
|
16257
|
+
}
|
|
16258
|
+
return false;
|
|
16259
|
+
}
|
|
16231
16260
|
function renameDefaultExport(source) {
|
|
16232
16261
|
const fnDefault = source.match(
|
|
16233
16262
|
/(^|\n)\s*export\s+default\s+(async\s+)?function\s*([A-Za-z_$][A-Za-z0-9_$]*)?\s*\(/
|
package/dist/triggers/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
7
|
-
var
|
|
3
|
+
var chunkXWEBKN65_cjs = require('../chunk-XWEBKN65.cjs');
|
|
4
|
+
var chunkJB4UYCZI_cjs = require('../chunk-JB4UYCZI.cjs');
|
|
5
|
+
var chunkEXGEA4KE_cjs = require('../chunk-EXGEA4KE.cjs');
|
|
6
|
+
require('../chunk-UC2KS5EG.cjs');
|
|
7
|
+
var chunk2YCQFLXW_cjs = require('../chunk-2YCQFLXW.cjs');
|
|
8
8
|
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
9
9
|
require('../chunk-ZDSQYCYV.cjs');
|
|
10
10
|
var promises = require('fs/promises');
|
|
@@ -125,7 +125,7 @@ function skipReason(tableName, hasAuthColumns) {
|
|
|
125
125
|
for (const [pattern, reason] of NAMED_SKIPS) {
|
|
126
126
|
if (typeof pattern === "string" ? tableName === pattern : pattern.test(tableName)) return reason;
|
|
127
127
|
}
|
|
128
|
-
if (
|
|
128
|
+
if (chunk2YCQFLXW_cjs.AUTH_SESSION_TABLE_NAMES.test(tableName) && (hasAuthColumns !== false || /verif/i.test(tableName))) {
|
|
129
129
|
return "auth / session store (has token, expiry or session-data columns)";
|
|
130
130
|
}
|
|
131
131
|
return null;
|
|
@@ -338,43 +338,43 @@ function parseEnvEntries(text) {
|
|
|
338
338
|
|
|
339
339
|
Object.defineProperty(exports, "patchPgClient", {
|
|
340
340
|
enumerable: true,
|
|
341
|
-
get: function () { return
|
|
341
|
+
get: function () { return chunkXWEBKN65_cjs.patchPgClient; }
|
|
342
342
|
});
|
|
343
343
|
Object.defineProperty(exports, "applyDatabaseContext", {
|
|
344
344
|
enumerable: true,
|
|
345
|
-
get: function () { return
|
|
345
|
+
get: function () { return chunkJB4UYCZI_cjs.applyDatabaseContext; }
|
|
346
346
|
});
|
|
347
347
|
Object.defineProperty(exports, "getDatabaseContext", {
|
|
348
348
|
enumerable: true,
|
|
349
|
-
get: function () { return
|
|
349
|
+
get: function () { return chunkJB4UYCZI_cjs.getDatabaseContext; }
|
|
350
350
|
});
|
|
351
351
|
Object.defineProperty(exports, "withDatabaseContext", {
|
|
352
352
|
enumerable: true,
|
|
353
|
-
get: function () { return
|
|
353
|
+
get: function () { return chunkJB4UYCZI_cjs.withDatabaseContext; }
|
|
354
354
|
});
|
|
355
355
|
Object.defineProperty(exports, "detectTriggerTrackedTables", {
|
|
356
356
|
enumerable: true,
|
|
357
|
-
get: function () { return
|
|
357
|
+
get: function () { return chunkEXGEA4KE_cjs.detectTriggerTrackedTables; }
|
|
358
358
|
});
|
|
359
359
|
Object.defineProperty(exports, "emitAuditRows", {
|
|
360
360
|
enumerable: true,
|
|
361
|
-
get: function () { return
|
|
361
|
+
get: function () { return chunkEXGEA4KE_cjs.emitAuditRows; }
|
|
362
362
|
});
|
|
363
363
|
Object.defineProperty(exports, "flushAuditLog", {
|
|
364
364
|
enumerable: true,
|
|
365
|
-
get: function () { return
|
|
365
|
+
get: function () { return chunkEXGEA4KE_cjs.flushAuditLog; }
|
|
366
366
|
});
|
|
367
367
|
Object.defineProperty(exports, "pruneAuditLog", {
|
|
368
368
|
enumerable: true,
|
|
369
|
-
get: function () { return
|
|
369
|
+
get: function () { return chunkEXGEA4KE_cjs.pruneAuditLog; }
|
|
370
370
|
});
|
|
371
371
|
Object.defineProperty(exports, "readAuditRows", {
|
|
372
372
|
enumerable: true,
|
|
373
|
-
get: function () { return
|
|
373
|
+
get: function () { return chunkEXGEA4KE_cjs.readAuditRows; }
|
|
374
374
|
});
|
|
375
375
|
Object.defineProperty(exports, "sweepAuditLog", {
|
|
376
376
|
enumerable: true,
|
|
377
|
-
get: function () { return
|
|
377
|
+
get: function () { return chunkEXGEA4KE_cjs.sweepAuditLog; }
|
|
378
378
|
});
|
|
379
379
|
exports.buildTrackingSql = buildTrackingSql;
|
|
380
380
|
exports.detectEngine = detectEngine;
|