ezlogs-nextjs 0.1.0 → 0.1.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/LICENSE +1 -1
- package/README.md +98 -688
- package/bin/install-triggers.cjs +1 -1
- package/dist/actors/index.d.cts +1 -1
- package/dist/actors/index.d.ts +1 -1
- package/dist/{configuration-D9x9Gvds.d.cts → configuration-aUYgA8-h.d.cts} +20 -3
- package/dist/{configuration-D9x9Gvds.d.ts → configuration-aUYgA8-h.d.ts} +20 -3
- package/dist/db/drizzle.cjs +17 -6
- package/dist/db/drizzle.js +17 -6
- package/dist/db/prisma.cjs +271 -76
- package/dist/db/prisma.d.cts +38 -1
- package/dist/db/prisma.d.ts +38 -1
- package/dist/db/prisma.js +270 -77
- package/dist/db/supabase.cjs +17 -6
- package/dist/db/supabase.js +17 -6
- package/dist/index.cjs +459 -222
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +459 -222
- package/dist/jobs/bullmq.cjs +6 -5
- package/dist/jobs/bullmq.d.cts +16 -8
- package/dist/jobs/bullmq.d.ts +16 -8
- package/dist/jobs/bullmq.js +6 -5
- package/dist/jobs/inngest.cjs +16 -6
- package/dist/jobs/inngest.js +16 -6
- package/dist/jobs/supabase-queues.cjs +16 -6
- package/dist/jobs/supabase-queues.js +16 -6
- package/dist/jobs/trigger.cjs +16 -6
- package/dist/jobs/trigger.js +16 -6
- package/dist/jobs/upstash-workflow.cjs +16 -6
- package/dist/jobs/upstash-workflow.js +16 -6
- package/dist/nextjs-plugin/index.cjs +18 -0
- package/dist/nextjs-plugin/index.js +18 -0
- package/dist/nextjs-plugin/loader.cjs +44 -34
- package/dist/nextjs-plugin/loader.d.cts +10 -0
- package/dist/nextjs-plugin/loader.d.ts +10 -0
- package/dist/nextjs-plugin/loader.js +44 -34
- package/dist/triggers/index.cjs +43 -8
- package/dist/triggers/index.d.cts +7 -0
- package/dist/triggers/index.d.ts +7 -0
- package/dist/triggers/index.js +43 -8
- package/package.json +3 -4
- package/sql/postgres/00_install.sql +1 -1
package/dist/triggers/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readFile } from 'fs/promises';
|
|
2
2
|
import { dirname, join } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
-
import 'crypto';
|
|
5
4
|
|
|
6
5
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
7
6
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -91,9 +90,8 @@ var DEFAULT_EXCLUDED_TABLES = Object.freeze([
|
|
|
91
90
|
]);
|
|
92
91
|
var DEFAULT_EXCLUDED_JOB_CLASSES = Object.freeze([]);
|
|
93
92
|
var DEFAULT_EXCLUDED_GRAPHQL_OPERATIONS = Object.freeze(["IntrospectionQuery", "__*"]);
|
|
94
|
-
var DEFAULT_SERVER_URL = "https://app.ezlogs.io";
|
|
95
93
|
var Configuration = class {
|
|
96
|
-
serverUrl =
|
|
94
|
+
serverUrl = null;
|
|
97
95
|
projectToken = null;
|
|
98
96
|
captureHttp = true;
|
|
99
97
|
captureDb = true;
|
|
@@ -105,6 +103,7 @@ var Configuration = class {
|
|
|
105
103
|
logLevel = "warn";
|
|
106
104
|
patchGlobalFetch = true;
|
|
107
105
|
actorFromSupabase = true;
|
|
106
|
+
allowInsecureTransport = false;
|
|
108
107
|
excludedPaths = [];
|
|
109
108
|
excludedTables = [];
|
|
110
109
|
excludedJobClasses = [];
|
|
@@ -132,7 +131,7 @@ var Configuration = class {
|
|
|
132
131
|
*/
|
|
133
132
|
triggerTrackedTables = null;
|
|
134
133
|
apply(options) {
|
|
135
|
-
|
|
134
|
+
this.serverUrl = options.serverUrl;
|
|
136
135
|
this.projectToken = options.projectToken;
|
|
137
136
|
if (options.captureHttp !== void 0) this.captureHttp = options.captureHttp;
|
|
138
137
|
if (options.captureDb !== void 0) this.captureDb = options.captureDb;
|
|
@@ -157,6 +156,9 @@ var Configuration = class {
|
|
|
157
156
|
if (options.patchGlobalFetch !== void 0) {
|
|
158
157
|
this.patchGlobalFetch = options.patchGlobalFetch;
|
|
159
158
|
}
|
|
159
|
+
if (options.allowInsecureTransport !== void 0) {
|
|
160
|
+
this.allowInsecureTransport = options.allowInsecureTransport;
|
|
161
|
+
}
|
|
160
162
|
if (options.actorFromSupabase !== void 0) {
|
|
161
163
|
this.actorFromSupabase = options.actorFromSupabase;
|
|
162
164
|
}
|
|
@@ -505,6 +507,8 @@ var storage = createScopedStorage(
|
|
|
505
507
|
function getCurrentActor() {
|
|
506
508
|
return storage.read();
|
|
507
509
|
}
|
|
510
|
+
|
|
511
|
+
// src/correlation.ts
|
|
508
512
|
var storage2 = createScopedStorage(
|
|
509
513
|
/* @__PURE__ */ Symbol.for("ezlogs-nextjs:correlation-storage")
|
|
510
514
|
);
|
|
@@ -792,7 +796,17 @@ var DB_SENSITIVE_PATTERNS = Object.freeze([
|
|
|
792
796
|
"credit_card",
|
|
793
797
|
"ssn",
|
|
794
798
|
"social_security",
|
|
795
|
-
"encrypted"
|
|
799
|
+
"encrypted",
|
|
800
|
+
"private_key",
|
|
801
|
+
"public_key",
|
|
802
|
+
"signing_key",
|
|
803
|
+
"pem",
|
|
804
|
+
"cipher",
|
|
805
|
+
"nonce",
|
|
806
|
+
"salt",
|
|
807
|
+
"digest",
|
|
808
|
+
"signature",
|
|
809
|
+
"hmac"
|
|
796
810
|
]);
|
|
797
811
|
function emitDbEvent(input) {
|
|
798
812
|
try {
|
|
@@ -964,13 +978,21 @@ function runWithAuditSnapshotScope(callback) {
|
|
|
964
978
|
return storage3.run(0n, callback);
|
|
965
979
|
}
|
|
966
980
|
|
|
981
|
+
// src/triggers/emit-dedup.ts
|
|
982
|
+
var storage4 = createScopedStorage(
|
|
983
|
+
/* @__PURE__ */ Symbol.for("ezlogs-nextjs:audit-emitted-ids-storage")
|
|
984
|
+
);
|
|
985
|
+
function currentEmittedAuditIds() {
|
|
986
|
+
return storage4.read();
|
|
987
|
+
}
|
|
988
|
+
|
|
967
989
|
// src/triggers/reader.ts
|
|
968
990
|
async function readAuditRows(exec, correlationId, snapshotMaxId = null) {
|
|
969
991
|
try {
|
|
970
|
-
const sql = snapshotMaxId === null ? `SELECT table_name, op, old_row, new_row, resource_id
|
|
992
|
+
const sql = snapshotMaxId === null ? `SELECT id, table_name, op, old_row, new_row, resource_id
|
|
971
993
|
FROM ezlogs_audit_log
|
|
972
994
|
WHERE correlation_id = $1
|
|
973
|
-
ORDER BY id ASC` : `SELECT table_name, op, old_row, new_row, resource_id
|
|
995
|
+
ORDER BY id ASC` : `SELECT id, table_name, op, old_row, new_row, resource_id
|
|
974
996
|
FROM ezlogs_audit_log
|
|
975
997
|
WHERE correlation_id = $1
|
|
976
998
|
OR (correlation_id IS NULL AND id > $2)
|
|
@@ -1041,7 +1063,19 @@ async function flushAuditLog(exec) {
|
|
|
1041
1063
|
const snapshot = currentAuditSnapshot();
|
|
1042
1064
|
const rows = await readAuditRows(exec, correlationId, snapshot);
|
|
1043
1065
|
if (rows.length === 0) return;
|
|
1044
|
-
|
|
1066
|
+
const emitted = currentEmittedAuditIds();
|
|
1067
|
+
if (emitted === null) {
|
|
1068
|
+
emitAuditRows(rows);
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
const fresh = [];
|
|
1072
|
+
for (const row of rows) {
|
|
1073
|
+
if (row.id === "" || emitted.has(row.id)) continue;
|
|
1074
|
+
emitted.add(row.id);
|
|
1075
|
+
fresh.push(row);
|
|
1076
|
+
}
|
|
1077
|
+
if (fresh.length === 0) return;
|
|
1078
|
+
emitAuditRows(fresh);
|
|
1045
1079
|
}
|
|
1046
1080
|
function emitOne(row) {
|
|
1047
1081
|
const op = mapOp(row.op);
|
|
@@ -1137,6 +1171,7 @@ function extractRows(result) {
|
|
|
1137
1171
|
function normalizeAuditRow(raw) {
|
|
1138
1172
|
const r = raw ?? {};
|
|
1139
1173
|
return {
|
|
1174
|
+
id: r.id == null ? "" : String(r.id),
|
|
1140
1175
|
table_name: String(r.table_name ?? ""),
|
|
1141
1176
|
op: r.op,
|
|
1142
1177
|
old_row: r.old_row ?? null,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ezlogs-nextjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "EZLogs agent for Next.js — capture HTTP, database, and background-job events as plain-English Action cards.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "EZLogs",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://github.com/dezsirazvan/ez_logs_agent_nextjs",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/dezsirazvan/ez_logs_agent_nextjs"
|
|
10
|
+
"url": "https://github.com/dezsirazvan/ez_logs_agent_nextjs.git"
|
|
11
11
|
},
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/dezsirazvan/ez_logs_agent_nextjs/issues"
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"dist",
|
|
22
22
|
"sql",
|
|
23
23
|
"bin",
|
|
24
|
-
"LICENSE",
|
|
25
24
|
"README.md"
|
|
26
25
|
],
|
|
27
26
|
"bin": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
-- ezlogs
|
|
1
|
+
-- @ezlogs/nextjs — Postgres trigger-based change-data-capture install.
|
|
2
2
|
--
|
|
3
3
|
-- Run once per database. Idempotent: safe to re-run after upgrades.
|
|
4
4
|
-- After this, attach the trigger to specific tables with:
|