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.
- package/README.md +149 -30
- package/bin/install-triggers.cjs +7 -2
- package/dist/actors/index.cjs +4 -4
- package/dist/actors/index.d.cts +1 -1
- package/dist/actors/index.d.ts +1 -1
- package/dist/actors/index.js +1 -1
- package/dist/{chunk-C5OSM557.js → chunk-FCFVIRQF.js} +7 -0
- package/dist/chunk-GI6BM4MR.js +443 -0
- package/dist/{chunk-YX2XPLOA.cjs → chunk-GMHOUAKD.cjs} +63 -34
- package/dist/{chunk-CU45I2WR.js → chunk-MHBS5FEP.js} +48 -20
- package/dist/chunk-MMLQXSSD.cjs +461 -0
- package/dist/{chunk-CE3R7DVB.js → chunk-NINIAL7M.js} +60 -384
- package/dist/{chunk-Y5NSHKWQ.cjs → chunk-NX4EL7BY.cjs} +57 -7
- package/dist/chunk-PS4U2GFJ.cjs +52 -0
- package/dist/chunk-R6IWVTX3.cjs +212 -0
- package/dist/{chunk-V5YNKKTG.cjs → chunk-TWTG5ILJ.cjs} +7 -0
- package/dist/chunk-U22T7QYY.js +200 -0
- package/dist/chunk-YMIGZYFH.js +48 -0
- package/dist/{chunk-WASXTDLW.cjs → chunk-YXZZNZG6.cjs} +71 -403
- package/dist/{chunk-DKRNNI4I.js → chunk-Z2TM3LGG.js} +53 -3
- package/dist/{configuration-OHLNivON.d.ts → configuration-CJ5yKVlP.d.cts} +14 -8
- package/dist/{configuration-OHLNivON.d.cts → configuration-CJ5yKVlP.d.ts} +14 -8
- package/dist/db/drizzle.cjs +5 -4
- package/dist/db/drizzle.js +3 -2
- package/dist/db/postgres-js.cjs +98 -0
- package/dist/db/postgres-js.d.cts +11 -0
- package/dist/db/postgres-js.d.ts +11 -0
- package/dist/db/postgres-js.js +95 -0
- package/dist/db/prisma.cjs +21 -20
- package/dist/db/prisma.d.cts +19 -2
- package/dist/db/prisma.d.ts +19 -2
- package/dist/db/prisma.js +6 -5
- package/dist/db/supabase.cjs +19 -12
- package/dist/db/supabase.d.cts +3 -2
- package/dist/db/supabase.d.ts +3 -2
- package/dist/db/supabase.js +11 -4
- package/dist/index.cjs +596 -165
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +492 -62
- package/dist/jobs/bullmq.cjs +63 -18
- package/dist/jobs/bullmq.d.cts +0 -4
- package/dist/jobs/bullmq.d.ts +0 -4
- package/dist/jobs/bullmq.js +59 -14
- package/dist/jobs/inngest.cjs +61 -24
- package/dist/jobs/inngest.d.cts +5 -1
- package/dist/jobs/inngest.d.ts +5 -1
- package/dist/jobs/inngest.js +55 -18
- package/dist/jobs/supabase-queues.cjs +17 -15
- package/dist/jobs/supabase-queues.d.cts +1 -1
- package/dist/jobs/supabase-queues.d.ts +1 -1
- package/dist/jobs/supabase-queues.js +15 -13
- package/dist/jobs/trigger.cjs +11 -12
- package/dist/jobs/trigger.d.cts +4 -3
- package/dist/jobs/trigger.d.ts +4 -3
- package/dist/jobs/trigger.js +7 -8
- package/dist/jobs/upstash-workflow.cjs +43 -35
- package/dist/jobs/upstash-workflow.d.cts +2 -8
- package/dist/jobs/upstash-workflow.d.ts +2 -8
- package/dist/jobs/upstash-workflow.js +38 -30
- package/dist/nextjs-plugin/index.cjs +39 -3
- package/dist/nextjs-plugin/index.d.cts +8 -1
- package/dist/nextjs-plugin/index.d.ts +8 -1
- package/dist/nextjs-plugin/index.js +39 -3
- package/dist/nextjs-plugin/loader.cjs +41 -3
- package/dist/nextjs-plugin/loader.d.cts +1 -0
- package/dist/nextjs-plugin/loader.d.ts +1 -0
- package/dist/nextjs-plugin/loader.js +42 -4
- package/dist/triggers/index.cjs +145 -92
- package/dist/triggers/index.d.cts +20 -5
- package/dist/triggers/index.d.ts +20 -5
- package/dist/triggers/index.js +125 -82
- package/package.json +11 -1
- package/sql/postgres/00_install.sql +1 -1
- package/dist/chunk-UQHEW6ER.js +0 -119
- package/dist/chunk-UWHYJH4M.cjs +0 -126
package/dist/db/supabase.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkYXZZNZG6_cjs = require('../chunk-YXZZNZG6.cjs');
|
|
4
|
+
var chunkMMLQXSSD_cjs = require('../chunk-MMLQXSSD.cjs');
|
|
5
|
+
var chunkTWTG5ILJ_cjs = require('../chunk-TWTG5ILJ.cjs');
|
|
5
6
|
require('../chunk-ZDSQYCYV.cjs');
|
|
6
7
|
|
|
7
8
|
// src/db/supabase.ts
|
|
8
9
|
function triggerPathWillCapture(table) {
|
|
9
|
-
const config =
|
|
10
|
+
const config = chunkMMLQXSSD_cjs.configuration();
|
|
10
11
|
if (!config.databaseReader) return false;
|
|
11
12
|
const tracked = config.triggerTrackedTables;
|
|
12
13
|
if (tracked === null) return false;
|
|
@@ -63,14 +64,20 @@ function wrapSupabase(client) {
|
|
|
63
64
|
var GLOBAL_CLIENT_KEY = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:supabase-current-client");
|
|
64
65
|
function registerActorSource(client) {
|
|
65
66
|
try {
|
|
67
|
+
const slot = chunkMMLQXSSD_cjs.currentActorSource();
|
|
68
|
+
if (slot) {
|
|
69
|
+
slot.client = client;
|
|
70
|
+
slot.tried = false;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
66
73
|
const g = globalThis;
|
|
67
74
|
g[GLOBAL_CLIENT_KEY] = client;
|
|
68
75
|
} catch {
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
async function tryExtractSupabaseActor() {
|
|
72
|
-
const
|
|
73
|
-
const client =
|
|
79
|
+
const slot = chunkMMLQXSSD_cjs.currentActorSource();
|
|
80
|
+
const client = slot ? slot.client : globalThis[GLOBAL_CLIENT_KEY];
|
|
74
81
|
if (!client || typeof client.auth?.getUser !== "function") return null;
|
|
75
82
|
try {
|
|
76
83
|
const { data } = await client.auth.getUser();
|
|
@@ -209,7 +216,7 @@ function instrumentFilterBuilder(builder, onResolved, beforeFire) {
|
|
|
209
216
|
try {
|
|
210
217
|
if (!result?.error) onResolved(result);
|
|
211
218
|
} catch (error) {
|
|
212
|
-
|
|
219
|
+
chunkTWTG5ILJ_cjs.logger.debug(`supabase capture failed: ${describeError(error)}`);
|
|
213
220
|
}
|
|
214
221
|
try {
|
|
215
222
|
const passthrough = onfulfilled ? onfulfilled(raw) : raw;
|
|
@@ -248,7 +255,7 @@ function emitFromMutation(ctx, values, result, filters, beforeRow) {
|
|
|
248
255
|
return;
|
|
249
256
|
}
|
|
250
257
|
if (!isPlainObject(values)) {
|
|
251
|
-
|
|
258
|
+
chunkYXZZNZG6_cjs.emitDbEvent({
|
|
252
259
|
modelClass: ctx.table,
|
|
253
260
|
operation: ctx.operation,
|
|
254
261
|
resourceId: idFromFilters(filters)
|
|
@@ -262,9 +269,9 @@ function emitFromMutation(ctx, values, result, filters, beforeRow) {
|
|
|
262
269
|
function emitOneRow(ctx, values, resultRow, filters, beforeRow) {
|
|
263
270
|
const resourceId = resultRow?.id ?? values.id ?? idFromFilters(filters) ?? null;
|
|
264
271
|
const merged = beforeRow ?? resultRow ?? values;
|
|
265
|
-
const displayName =
|
|
272
|
+
const displayName = chunkYXZZNZG6_cjs.resolveDisplayName(ctx.table, merged);
|
|
266
273
|
if (ctx.operation === "create") {
|
|
267
|
-
|
|
274
|
+
chunkYXZZNZG6_cjs.emitDbEvent({
|
|
268
275
|
modelClass: ctx.table,
|
|
269
276
|
operation: "create",
|
|
270
277
|
resourceId,
|
|
@@ -276,7 +283,7 @@ function emitOneRow(ctx, values, resultRow, filters, beforeRow) {
|
|
|
276
283
|
}
|
|
277
284
|
if (ctx.operation === "update") {
|
|
278
285
|
const changes = buildUpdateChanges(values, beforeRow);
|
|
279
|
-
|
|
286
|
+
chunkYXZZNZG6_cjs.emitDbEvent({
|
|
280
287
|
modelClass: ctx.table,
|
|
281
288
|
operation: "update",
|
|
282
289
|
resourceId,
|
|
@@ -290,8 +297,8 @@ function emitFromDelete(table, result, filters, beforeRow) {
|
|
|
290
297
|
const resultRow = pickFirstResultRow(result);
|
|
291
298
|
const resourceId = resultRow?.id ?? beforeRow?.id ?? idFromFilters(filters) ?? null;
|
|
292
299
|
const richestRow = resultRow ?? beforeRow;
|
|
293
|
-
const displayName = richestRow ?
|
|
294
|
-
|
|
300
|
+
const displayName = richestRow ? chunkYXZZNZG6_cjs.resolveDisplayName(table, richestRow) : null;
|
|
301
|
+
chunkYXZZNZG6_cjs.emitDbEvent({
|
|
295
302
|
modelClass: table,
|
|
296
303
|
operation: "destroy",
|
|
297
304
|
resourceId,
|
package/dist/db/supabase.d.cts
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
declare function wrapSupabase<T>(client: T): T;
|
|
18
18
|
/**
|
|
19
|
-
* Returns the current actor (if any) by asking the
|
|
20
|
-
* registered
|
|
19
|
+
* Returns the current actor (if any) by asking the Supabase client
|
|
20
|
+
* registered in this scope (outside any scope: the most recent one)
|
|
21
|
+
* for its authenticated user. Returns null
|
|
21
22
|
* when no client is registered or the call fails. Used by the HTTP
|
|
22
23
|
* capturer's default `actorFromSupabase` path.
|
|
23
24
|
*
|
package/dist/db/supabase.d.ts
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
declare function wrapSupabase<T>(client: T): T;
|
|
18
18
|
/**
|
|
19
|
-
* Returns the current actor (if any) by asking the
|
|
20
|
-
* registered
|
|
19
|
+
* Returns the current actor (if any) by asking the Supabase client
|
|
20
|
+
* registered in this scope (outside any scope: the most recent one)
|
|
21
|
+
* for its authenticated user. Returns null
|
|
21
22
|
* when no client is registered or the call fails. Used by the HTTP
|
|
22
23
|
* capturer's default `actorFromSupabase` path.
|
|
23
24
|
*
|
package/dist/db/supabase.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { emitDbEvent, resolveDisplayName
|
|
2
|
-
import {
|
|
1
|
+
import { emitDbEvent, resolveDisplayName } from '../chunk-NINIAL7M.js';
|
|
2
|
+
import { currentActorSource, configuration } from '../chunk-GI6BM4MR.js';
|
|
3
|
+
import { logger } from '../chunk-FCFVIRQF.js';
|
|
3
4
|
import '../chunk-SIAA4J6H.js';
|
|
4
5
|
|
|
5
6
|
// src/db/supabase.ts
|
|
@@ -61,14 +62,20 @@ function wrapSupabase(client) {
|
|
|
61
62
|
var GLOBAL_CLIENT_KEY = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:supabase-current-client");
|
|
62
63
|
function registerActorSource(client) {
|
|
63
64
|
try {
|
|
65
|
+
const slot = currentActorSource();
|
|
66
|
+
if (slot) {
|
|
67
|
+
slot.client = client;
|
|
68
|
+
slot.tried = false;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
64
71
|
const g = globalThis;
|
|
65
72
|
g[GLOBAL_CLIENT_KEY] = client;
|
|
66
73
|
} catch {
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
76
|
async function tryExtractSupabaseActor() {
|
|
70
|
-
const
|
|
71
|
-
const client =
|
|
77
|
+
const slot = currentActorSource();
|
|
78
|
+
const client = slot ? slot.client : globalThis[GLOBAL_CLIENT_KEY];
|
|
72
79
|
if (!client || typeof client.auth?.getUser !== "function") return null;
|
|
73
80
|
try {
|
|
74
81
|
const { data } = await client.auth.getUser();
|