ezlogs-nextjs 0.4.4 → 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 +73 -13
- package/dist/actors/index.d.cts +1 -1
- package/dist/actors/index.d.ts +1 -1
- package/dist/{chunk-MMLQXSSD.cjs → chunk-2YCQFLXW.cjs} +21 -11
- package/dist/{chunk-YMIGZYFH.js → chunk-343ZGTMH.js} +1 -1
- package/dist/{chunk-Z2TM3LGG.js → chunk-5ZMOWEBY.js} +1 -1
- package/dist/{chunk-GI6BM4MR.js → chunk-7MFKEYDN.js} +21 -12
- package/dist/{chunk-NINIAL7M.js → chunk-AXIQTU52.js} +1 -1
- package/dist/chunk-BE3RCFNP.js +13 -0
- package/dist/chunk-CHVJ4WPM.cjs +16 -0
- package/dist/{chunk-MHBS5FEP.js → chunk-CYAFYBKF.js} +27 -4
- package/dist/chunk-DRE2VXFX.js +19 -0
- package/dist/{chunk-GMHOUAKD.cjs → chunk-EXGEA4KE.cjs} +37 -13
- package/dist/{chunk-PS4U2GFJ.cjs → chunk-JB4UYCZI.cjs} +5 -5
- package/dist/chunk-JWJKFZBW.js +52 -0
- package/dist/{chunk-R6IWVTX3.cjs → chunk-KOFR5OC3.cjs} +31 -21
- package/dist/chunk-NFZ5OKF3.cjs +22 -0
- package/dist/{chunk-U22T7QYY.js → chunk-Q3HRVWCS.js} +13 -3
- package/dist/{chunk-YXZZNZG6.cjs → chunk-UC2KS5EG.cjs} +9 -9
- package/dist/chunk-VJR4VB4B.cjs +56 -0
- package/dist/{chunk-NX4EL7BY.cjs → chunk-XWEBKN65.cjs} +4 -4
- package/dist/{configuration-CJ5yKVlP.d.cts → configuration-b9pImwFB.d.cts} +2 -2
- package/dist/{configuration-CJ5yKVlP.d.ts → configuration-b9pImwFB.d.ts} +2 -2
- 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 +42 -17
- package/dist/db/supabase.d.cts +11 -5
- package/dist/db/supabase.d.ts +11 -5
- package/dist/db/supabase.js +33 -9
- package/dist/index.cjs +303 -142
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +213 -52
- package/dist/jobs/bullmq.cjs +44 -16
- package/dist/jobs/bullmq.d.cts +7 -1
- package/dist/jobs/bullmq.d.ts +7 -1
- package/dist/jobs/bullmq.js +33 -6
- package/dist/jobs/inngest.cjs +171 -48
- package/dist/jobs/inngest.d.cts +13 -7
- package/dist/jobs/inngest.d.ts +13 -7
- package/dist/jobs/inngest.js +162 -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 +139 -23
- package/dist/jobs/upstash-workflow.d.cts +20 -2
- package/dist/jobs/upstash-workflow.d.ts +20 -2
- package/dist/jobs/upstash-workflow.js +129 -14
- package/dist/nextjs-plugin/index.cjs +46 -29
- package/dist/nextjs-plugin/index.js +46 -29
- package/dist/nextjs-plugin/loader.cjs +104 -65
- package/dist/nextjs-plugin/loader.d.cts +18 -1
- package/dist/nextjs-plugin/loader.d.ts +18 -1
- package/dist/nextjs-plugin/loader.js +104 -66
- package/dist/triggers/index.cjs +22 -16
- package/dist/triggers/index.d.cts +0 -10
- package/dist/triggers/index.d.ts +0 -10
- package/dist/triggers/index.js +11 -5
- package/package.json +1 -1
- package/sql/postgres/00_install.sql +20 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { INSTRUMENTED_IMPORTS } from '../chunk-DRE2VXFX.js';
|
|
1
2
|
import { __commonJS } from '../chunk-SIAA4J6H.js';
|
|
2
3
|
import { relative, sep } from 'path';
|
|
3
4
|
|
|
@@ -15756,6 +15757,10 @@ function loaderImpl(source) {
|
|
|
15756
15757
|
const options = readOptions(this);
|
|
15757
15758
|
const kind = options.kind ?? "app-route-handler";
|
|
15758
15759
|
const routeModulePath = computeRouteModulePath(this.resourcePath, kind);
|
|
15760
|
+
const root = options.projectDir ?? this.rootContext ?? process.cwd();
|
|
15761
|
+
const rootEntry = isRootEntryFile(this.resourcePath, root, "middleware") || isRootEntryFile(this.resourcePath, root, "proxy");
|
|
15762
|
+
if (!rootEntry) source = rewriteInstrumentedImports(source, this.resourcePath);
|
|
15763
|
+
if (kind === "instrumented-imports") return source;
|
|
15759
15764
|
if (kind === "pages-api") {
|
|
15760
15765
|
return rewritePagesApi(source, routeModulePath);
|
|
15761
15766
|
}
|
|
@@ -15763,15 +15768,10 @@ function loaderImpl(source) {
|
|
|
15763
15768
|
return rewriteMiddleware(source);
|
|
15764
15769
|
}
|
|
15765
15770
|
if (kind === "proxy") {
|
|
15766
|
-
|
|
15767
|
-
return isRootProxyFile(this.resourcePath, root) ? rewriteMiddleware(source, "proxy") : source;
|
|
15771
|
+
return rootEntry ? rewriteMiddleware(source, "proxy") : source;
|
|
15768
15772
|
}
|
|
15769
15773
|
if (kind === "server-action") {
|
|
15770
|
-
|
|
15771
|
-
return rewriteServerActionFile(withSupabase);
|
|
15772
|
-
}
|
|
15773
|
-
if (kind === "supabase-factory") {
|
|
15774
|
-
return rewriteSupabaseFactoryImports(source);
|
|
15774
|
+
return rewriteServerActionFile(source);
|
|
15775
15775
|
}
|
|
15776
15776
|
if (kind === "inline-server-action") {
|
|
15777
15777
|
return rewriteInlineServerActions(source, this.resourcePath);
|
|
@@ -15857,70 +15857,75 @@ function rewriteLocalAliasedRouteExports(source, routeModulePath) {
|
|
|
15857
15857
|
}
|
|
15858
15858
|
function renameDestructuredExports(source) {
|
|
15859
15859
|
const methodSet = new Set(HTTP_METHOD_NAMES);
|
|
15860
|
-
const workflowServe = upstashWorkflowServeNames(source);
|
|
15861
15860
|
const methods = [];
|
|
15862
15861
|
const out = source.replace(
|
|
15863
15862
|
/(^|\n)([ \t]*)export\s+const\s*\{([^}]+)\}\s*=/g,
|
|
15864
15863
|
(full, lead, indent, list, offset) => {
|
|
15865
15864
|
const names = list.split(",").map((n) => n.trim()).filter(Boolean);
|
|
15866
15865
|
if (names.length === 0 || !names.every((n) => methodSet.has(n))) return full;
|
|
15867
|
-
const callee = /^\s*([A-Za-z_$][\w$]*)\s*[<(]/.exec(source.slice(offset + full.length))?.[1];
|
|
15868
|
-
if (callee && workflowServe.has(callee)) return full;
|
|
15869
15866
|
methods.push(...names);
|
|
15870
15867
|
return `${lead}${indent}const { ${names.map((n) => `${n}: ${ALREADY_WRAPPED_MARKER}${n}`).join(", ")} } =`;
|
|
15871
15868
|
}
|
|
15872
15869
|
);
|
|
15873
15870
|
return { source: out, methods };
|
|
15874
15871
|
}
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
|
|
15880
|
-
|
|
15872
|
+
var NEVER_WRAP_EXPORTS = /* @__PURE__ */ new Set(["config", "metadata", "generateMetadata"]);
|
|
15873
|
+
var IMPORT_MARKER = "__ezlogs_import_";
|
|
15874
|
+
var NAMED_IMPORT = /^(\uFEFF?[ \t]*)import\s+(?!type\b)((?:[A-Za-z_$][\w$]*\s*,\s*)?)\{([^}]*)\}(\s*from\s*)(["'])([^"'\n]+)\5([ \t]*;?)/gm;
|
|
15875
|
+
function rewriteInstrumentedImports(source, filename = "file.ts") {
|
|
15876
|
+
if (!INSTRUMENTED_IMPORTS.some((entry) => source.includes(entry.module))) return source;
|
|
15877
|
+
if (hasFileLevelDirective(source, "use client")) return source;
|
|
15878
|
+
const tokens = tokenize(source, filename);
|
|
15879
|
+
if (!tokens) return source;
|
|
15880
|
+
const importStarts = new Set(tokens.filter((t) => t.type === TT_IMPORT).map((t) => t.start));
|
|
15881
|
+
const valueUses = (local, from, to) => tokens.some(
|
|
15882
|
+
(t) => t.type === TT_NAME && !t.isType && (t.start < from || t.start >= to) && source.slice(t.start, t.end) === local
|
|
15883
|
+
);
|
|
15884
|
+
const imported = /* @__PURE__ */ new Set();
|
|
15885
|
+
return source.replace(
|
|
15886
|
+
NAMED_IMPORT,
|
|
15887
|
+
(full, indent, defaultPart, list, from, quote, module, end, offset) => {
|
|
15888
|
+
const entry = INSTRUMENTED_IMPORTS.find((e) => e.module === module);
|
|
15889
|
+
if (!entry || !importStarts.has(offset + indent.length)) return full;
|
|
15890
|
+
if (/^\s*(?:with|assert)\s*\{/.test(source.slice(offset + full.length))) return full;
|
|
15891
|
+
const replaced = [];
|
|
15892
|
+
const specifiers = list.split(",").map((piece) => {
|
|
15893
|
+
const spec = piece.trim();
|
|
15894
|
+
const match = /^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/.exec(spec);
|
|
15895
|
+
if (!match) return piece;
|
|
15896
|
+
const name = match[1];
|
|
15897
|
+
const local = match[2] ?? name;
|
|
15898
|
+
if (!entry.names.includes(name) || local.startsWith(IMPORT_MARKER)) return piece;
|
|
15899
|
+
if (!valueUses(local, offset, offset + full.length)) return piece;
|
|
15900
|
+
replaced.push({ local, name });
|
|
15901
|
+
return piece.replace(spec, `${name} as ${IMPORT_MARKER}${local}`);
|
|
15902
|
+
});
|
|
15903
|
+
if (replaced.length === 0) return full;
|
|
15904
|
+
const instrument = `__ezlogs_instrument_${entry.via.replace(/[^A-Za-z0-9]/g, "_")}`;
|
|
15905
|
+
const added = [];
|
|
15906
|
+
if (!imported.has(instrument)) {
|
|
15907
|
+
imported.add(instrument);
|
|
15908
|
+
added.push(`import { __ezlogsInstrument as ${instrument} } from "${PACKAGE_NAME}/${entry.via}";`);
|
|
15909
|
+
}
|
|
15910
|
+
for (const { local, name } of replaced) {
|
|
15911
|
+
added.push(`const ${local} = ${instrument}("${module}#${name}", ${IMPORT_MARKER}${local});`);
|
|
15912
|
+
}
|
|
15913
|
+
const statement = `${indent}import ${defaultPart}{${specifiers.join(",")}}${from}${quote}${module}${quote}${end}`;
|
|
15914
|
+
return `${statement}${end.trim().endsWith(";") ? "" : ";"} ${added.join(" ")}`;
|
|
15881
15915
|
}
|
|
15882
|
-
|
|
15883
|
-
return names;
|
|
15916
|
+
);
|
|
15884
15917
|
}
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
{
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
let changed = false;
|
|
15894
|
-
let needsWrapImport = false;
|
|
15895
|
-
for (const { module, exportName } of SUPABASE_FACTORY_IMPORTS) {
|
|
15896
|
-
const importPattern = new RegExp(
|
|
15897
|
-
`(import\\s*\\{[^}]*?)\\b(${exportName})\\b(\\s*(?:,[^}]*)?\\}\\s*from\\s*['"]${escapeRegexLiteral(module)}['"])`,
|
|
15898
|
-
"m"
|
|
15918
|
+
function tokenize(source, filename) {
|
|
15919
|
+
const sucraseParse = getSucraseParse();
|
|
15920
|
+
if (sucraseParse === null) return null;
|
|
15921
|
+
try {
|
|
15922
|
+
return sucraseParse(source, /\.(jsx|tsx|js|mjs|cjs)$/i.test(filename), /\.([cm]?ts|tsx)$/i.test(filename), false).tokens;
|
|
15923
|
+
} catch (e) {
|
|
15924
|
+
console.warn(
|
|
15925
|
+
`[ezlogs] sucrase parse failed for ${filename}; its library imports are not instrumented. ${e instanceof Error ? e.message : String(e)}`
|
|
15899
15926
|
);
|
|
15900
|
-
|
|
15901
|
-
if (!match) continue;
|
|
15902
|
-
const insertPoint = match.index + match[1].length + match[2].length;
|
|
15903
|
-
const after = rewritten.slice(insertPoint, insertPoint + 6);
|
|
15904
|
-
if (/^\s+as\b/.test(after)) continue;
|
|
15905
|
-
rewritten = rewritten.replace(importPattern, (_full, lead, name, tail) => {
|
|
15906
|
-
return `${lead}${name} as ${ALREADY_WRAPPED_MARKER}${name}${tail}`;
|
|
15907
|
-
});
|
|
15908
|
-
const wrapper = `const ${exportName} = (...__ezlogs_args) => ${ALREADY_WRAPPED_MARKER}wrap(${ALREADY_WRAPPED_MARKER}${exportName}(...__ezlogs_args));`;
|
|
15909
|
-
rewritten = `${rewritten}
|
|
15910
|
-
${wrapper}
|
|
15911
|
-
`;
|
|
15912
|
-
changed = true;
|
|
15913
|
-
needsWrapImport = true;
|
|
15914
|
-
}
|
|
15915
|
-
if (!changed) return source;
|
|
15916
|
-
if (needsWrapImport) {
|
|
15917
|
-
rewritten = `import { wrapSupabase as ${ALREADY_WRAPPED_MARKER}wrap } from "${PACKAGE_NAME}/supabase";
|
|
15918
|
-
${rewritten}`;
|
|
15927
|
+
return null;
|
|
15919
15928
|
}
|
|
15920
|
-
return rewritten;
|
|
15921
|
-
}
|
|
15922
|
-
function escapeRegexLiteral(input) {
|
|
15923
|
-
return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15924
15929
|
}
|
|
15925
15930
|
function rewriteServerActionFile(source) {
|
|
15926
15931
|
if (!hasFileLevelUseServer(source)) return source;
|
|
@@ -15968,6 +15973,7 @@ var TT_ARROW = 22528;
|
|
|
15968
15973
|
var TT_CONST = 80912;
|
|
15969
15974
|
var TT_LET = 79888;
|
|
15970
15975
|
var TT_VAR = 78864;
|
|
15976
|
+
var TT_IMPORT = 90640;
|
|
15971
15977
|
var INLINE_HELPER_NAME = "__ezlogs_run_inline_server_action";
|
|
15972
15978
|
function rewriteInlineServerActions(source, filename) {
|
|
15973
15979
|
if (!source.includes("use server")) return source;
|
|
@@ -16123,11 +16129,14 @@ function skipMatchingParens(tokens, idx) {
|
|
|
16123
16129
|
return -1;
|
|
16124
16130
|
}
|
|
16125
16131
|
function hasFileLevelUseServer(source) {
|
|
16132
|
+
return hasFileLevelDirective(source, "use server");
|
|
16133
|
+
}
|
|
16134
|
+
function hasFileLevelDirective(source, directive) {
|
|
16126
16135
|
let i = 0;
|
|
16127
16136
|
const n = source.length;
|
|
16128
16137
|
while (i < n) {
|
|
16129
16138
|
const ch = source.charCodeAt(i);
|
|
16130
|
-
if (ch === 32 || ch === 9 || ch === 10 || ch === 13) {
|
|
16139
|
+
if (ch === 32 || ch === 9 || ch === 10 || ch === 13 || ch === 65279) {
|
|
16131
16140
|
i += 1;
|
|
16132
16141
|
continue;
|
|
16133
16142
|
}
|
|
@@ -16145,8 +16154,8 @@ function hasFileLevelUseServer(source) {
|
|
|
16145
16154
|
}
|
|
16146
16155
|
break;
|
|
16147
16156
|
}
|
|
16148
|
-
const head = source.slice(i, i +
|
|
16149
|
-
return
|
|
16157
|
+
const head = source.slice(i, i + directive.length + 2);
|
|
16158
|
+
return head === `"${directive}"` || head === `'${directive}'`;
|
|
16150
16159
|
}
|
|
16151
16160
|
function rewriteMiddleware(source, name = "middleware") {
|
|
16152
16161
|
const namedRenamed = renameExport(source, name);
|
|
@@ -16175,9 +16184,9 @@ function rewriteMiddleware(source, name = "middleware") {
|
|
|
16175
16184
|
}
|
|
16176
16185
|
return source;
|
|
16177
16186
|
}
|
|
16178
|
-
function
|
|
16187
|
+
function isRootEntryFile(resourcePath, root, name) {
|
|
16179
16188
|
const rel = relative(root, resourcePath).split(sep).join("/");
|
|
16180
|
-
return
|
|
16189
|
+
return new RegExp(`^(?:src/)?${name}\\.[cm]?[jt]sx?$`).test(rel);
|
|
16181
16190
|
}
|
|
16182
16191
|
function rewritePagesApi(source, routeModulePath) {
|
|
16183
16192
|
const renamed = renameDefaultExport(source);
|
|
@@ -16199,19 +16208,23 @@ function rewritePagesApi(source, routeModulePath) {
|
|
|
16199
16208
|
return renamed.source + wrapperBlock;
|
|
16200
16209
|
}
|
|
16201
16210
|
function renameExport(source, name) {
|
|
16211
|
+
const end = "(?![\\p{L}\\p{N}_$\\u200C\\u200D])";
|
|
16202
16212
|
const patterns = [
|
|
16203
|
-
// `export async function NAME(`
|
|
16204
|
-
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"),
|
|
16205
16215
|
// `export function NAME(`
|
|
16206
|
-
new RegExp(`(^|\\s)export\\s+function\\s
|
|
16216
|
+
new RegExp(`(^|\\s)export\\s+function\\s*\\*?\\s*${name}${end}`, "mu"),
|
|
16207
16217
|
// `export const NAME =` / `export let NAME =` / `export var NAME =`
|
|
16208
|
-
new RegExp(`(^|\\s)export\\s+(const|let|var)\\s+${name}
|
|
16218
|
+
new RegExp(`(^|\\s)export\\s+(const|let|var)\\s+${name}${end}`, "mu")
|
|
16209
16219
|
];
|
|
16210
16220
|
for (const pattern of patterns) {
|
|
16211
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
|
+
}
|
|
16212
16225
|
if (match) {
|
|
16213
16226
|
const replaced = source.replace(pattern, (full, lead) => {
|
|
16214
|
-
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}`);
|
|
16215
16228
|
return `${lead}${rest}`;
|
|
16216
16229
|
});
|
|
16217
16230
|
return { source: replaced, changed: true };
|
|
@@ -16219,6 +16232,31 @@ function renameExport(source, name) {
|
|
|
16219
16232
|
}
|
|
16220
16233
|
return { source, changed: false };
|
|
16221
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
|
+
}
|
|
16222
16260
|
function renameDefaultExport(source) {
|
|
16223
16261
|
const fnDefault = source.match(
|
|
16224
16262
|
/(^|\n)\s*export\s+default\s+(async\s+)?function\s*([A-Za-z_$][A-Za-z0-9_$]*)?\s*\(/
|
|
@@ -16283,4 +16321,4 @@ function basename(p) {
|
|
|
16283
16321
|
return idx >= 0 ? p.slice(idx + 1) : p;
|
|
16284
16322
|
}
|
|
16285
16323
|
|
|
16286
|
-
export { loader as default, pitch, rewriteInlineServerActions };
|
|
16324
|
+
export { loader as default, pitch, rewriteInlineServerActions, rewriteInstrumentedImports };
|
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;
|
|
@@ -145,6 +145,12 @@ SELECT t.table_name,
|
|
|
145
145
|
FROM information_schema.tables t
|
|
146
146
|
WHERE t.table_schema = 'public'
|
|
147
147
|
AND t.table_type = 'BASE TABLE'
|
|
148
|
+
-- A partition gets its parent's trigger cloned onto it; track the parent only.
|
|
149
|
+
AND NOT EXISTS (
|
|
150
|
+
SELECT 1 FROM pg_class pc
|
|
151
|
+
JOIN pg_namespace pn ON pn.oid = pc.relnamespace
|
|
152
|
+
WHERE pn.nspname = t.table_schema AND pc.relname = t.table_name AND pc.relispartition
|
|
153
|
+
)
|
|
148
154
|
ORDER BY t.table_name
|
|
149
155
|
`.trim();
|
|
150
156
|
async function runInstall(args, options = {}) {
|
|
@@ -332,43 +338,43 @@ function parseEnvEntries(text) {
|
|
|
332
338
|
|
|
333
339
|
Object.defineProperty(exports, "patchPgClient", {
|
|
334
340
|
enumerable: true,
|
|
335
|
-
get: function () { return
|
|
341
|
+
get: function () { return chunkXWEBKN65_cjs.patchPgClient; }
|
|
336
342
|
});
|
|
337
343
|
Object.defineProperty(exports, "applyDatabaseContext", {
|
|
338
344
|
enumerable: true,
|
|
339
|
-
get: function () { return
|
|
345
|
+
get: function () { return chunkJB4UYCZI_cjs.applyDatabaseContext; }
|
|
340
346
|
});
|
|
341
347
|
Object.defineProperty(exports, "getDatabaseContext", {
|
|
342
348
|
enumerable: true,
|
|
343
|
-
get: function () { return
|
|
349
|
+
get: function () { return chunkJB4UYCZI_cjs.getDatabaseContext; }
|
|
344
350
|
});
|
|
345
351
|
Object.defineProperty(exports, "withDatabaseContext", {
|
|
346
352
|
enumerable: true,
|
|
347
|
-
get: function () { return
|
|
353
|
+
get: function () { return chunkJB4UYCZI_cjs.withDatabaseContext; }
|
|
348
354
|
});
|
|
349
355
|
Object.defineProperty(exports, "detectTriggerTrackedTables", {
|
|
350
356
|
enumerable: true,
|
|
351
|
-
get: function () { return
|
|
357
|
+
get: function () { return chunkEXGEA4KE_cjs.detectTriggerTrackedTables; }
|
|
352
358
|
});
|
|
353
359
|
Object.defineProperty(exports, "emitAuditRows", {
|
|
354
360
|
enumerable: true,
|
|
355
|
-
get: function () { return
|
|
361
|
+
get: function () { return chunkEXGEA4KE_cjs.emitAuditRows; }
|
|
356
362
|
});
|
|
357
363
|
Object.defineProperty(exports, "flushAuditLog", {
|
|
358
364
|
enumerable: true,
|
|
359
|
-
get: function () { return
|
|
365
|
+
get: function () { return chunkEXGEA4KE_cjs.flushAuditLog; }
|
|
360
366
|
});
|
|
361
367
|
Object.defineProperty(exports, "pruneAuditLog", {
|
|
362
368
|
enumerable: true,
|
|
363
|
-
get: function () { return
|
|
369
|
+
get: function () { return chunkEXGEA4KE_cjs.pruneAuditLog; }
|
|
364
370
|
});
|
|
365
371
|
Object.defineProperty(exports, "readAuditRows", {
|
|
366
372
|
enumerable: true,
|
|
367
|
-
get: function () { return
|
|
373
|
+
get: function () { return chunkEXGEA4KE_cjs.readAuditRows; }
|
|
368
374
|
});
|
|
369
375
|
Object.defineProperty(exports, "sweepAuditLog", {
|
|
370
376
|
enumerable: true,
|
|
371
|
-
get: function () { return
|
|
377
|
+
get: function () { return chunkEXGEA4KE_cjs.sweepAuditLog; }
|
|
372
378
|
});
|
|
373
379
|
exports.buildTrackingSql = buildTrackingSql;
|
|
374
380
|
exports.detectEngine = detectEngine;
|
|
@@ -200,16 +200,6 @@ declare function detectTriggerTrackedTables(exec: SqlExecutor): Promise<Set<stri
|
|
|
200
200
|
* Public so tests and advanced customers can call it directly.
|
|
201
201
|
*/
|
|
202
202
|
declare function emitAuditRows(rows: ReadonlyArray<AuditRow>): void;
|
|
203
|
-
/**
|
|
204
|
-
* End-of-request entry point. Claims rows for the current correlation
|
|
205
|
-
* id and emits each one, then runs the throttled sweep (untagged /
|
|
206
|
-
* orphaned rows, as their own actions) and prune. Skips when no
|
|
207
|
-
* correlation is in scope or no exec is supplied.
|
|
208
|
-
*
|
|
209
|
-
* The HTTP capturers call this after the user's handler returns,
|
|
210
|
-
* before they push the HTTP event itself, so DB events arrive
|
|
211
|
-
* grouped under the same correlation as the HTTP card.
|
|
212
|
-
*/
|
|
213
203
|
declare function flushAuditLog(exec: SqlExecutor | null | undefined, options?: {
|
|
214
204
|
since?: Date | null;
|
|
215
205
|
}): Promise<void>;
|
package/dist/triggers/index.d.ts
CHANGED
|
@@ -200,16 +200,6 @@ declare function detectTriggerTrackedTables(exec: SqlExecutor): Promise<Set<stri
|
|
|
200
200
|
* Public so tests and advanced customers can call it directly.
|
|
201
201
|
*/
|
|
202
202
|
declare function emitAuditRows(rows: ReadonlyArray<AuditRow>): void;
|
|
203
|
-
/**
|
|
204
|
-
* End-of-request entry point. Claims rows for the current correlation
|
|
205
|
-
* id and emits each one, then runs the throttled sweep (untagged /
|
|
206
|
-
* orphaned rows, as their own actions) and prune. Skips when no
|
|
207
|
-
* correlation is in scope or no exec is supplied.
|
|
208
|
-
*
|
|
209
|
-
* The HTTP capturers call this after the user's handler returns,
|
|
210
|
-
* before they push the HTTP event itself, so DB events arrive
|
|
211
|
-
* grouped under the same correlation as the HTTP card.
|
|
212
|
-
*/
|
|
213
203
|
declare function flushAuditLog(exec: SqlExecutor | null | undefined, options?: {
|
|
214
204
|
since?: Date | null;
|
|
215
205
|
}): Promise<void>;
|
package/dist/triggers/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { patchPgClient } from '../chunk-
|
|
2
|
-
export { applyDatabaseContext, getDatabaseContext, withDatabaseContext } from '../chunk-
|
|
3
|
-
export { detectTriggerTrackedTables, emitAuditRows, flushAuditLog, pruneAuditLog, readAuditRows, sweepAuditLog } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import { AUTH_SESSION_TABLE_NAMES } from '../chunk-
|
|
1
|
+
export { patchPgClient } from '../chunk-5ZMOWEBY.js';
|
|
2
|
+
export { applyDatabaseContext, getDatabaseContext, withDatabaseContext } from '../chunk-343ZGTMH.js';
|
|
3
|
+
export { detectTriggerTrackedTables, emitAuditRows, flushAuditLog, pruneAuditLog, readAuditRows, sweepAuditLog } from '../chunk-CYAFYBKF.js';
|
|
4
|
+
import '../chunk-AXIQTU52.js';
|
|
5
|
+
import { AUTH_SESSION_TABLE_NAMES } from '../chunk-7MFKEYDN.js';
|
|
6
6
|
import { logger } from '../chunk-FCFVIRQF.js';
|
|
7
7
|
import '../chunk-SIAA4J6H.js';
|
|
8
8
|
import { readFile } from 'fs/promises';
|
|
@@ -142,6 +142,12 @@ SELECT t.table_name,
|
|
|
142
142
|
FROM information_schema.tables t
|
|
143
143
|
WHERE t.table_schema = 'public'
|
|
144
144
|
AND t.table_type = 'BASE TABLE'
|
|
145
|
+
-- A partition gets its parent's trigger cloned onto it; track the parent only.
|
|
146
|
+
AND NOT EXISTS (
|
|
147
|
+
SELECT 1 FROM pg_class pc
|
|
148
|
+
JOIN pg_namespace pn ON pn.oid = pc.relnamespace
|
|
149
|
+
WHERE pn.nspname = t.table_schema AND pc.relname = t.table_name AND pc.relispartition
|
|
150
|
+
)
|
|
145
151
|
ORDER BY t.table_name
|
|
146
152
|
`.trim();
|
|
147
153
|
async function runInstall(args, options = {}) {
|
package/package.json
CHANGED
|
@@ -235,7 +235,10 @@ BEGIN
|
|
|
235
235
|
resource_id,
|
|
236
236
|
actor_id, correlation_id
|
|
237
237
|
) VALUES (
|
|
238
|
-
|
|
238
|
+
-- The tracked table's name (TG_ARGV[4]), so a partition's rows
|
|
239
|
+
-- show under their parent; triggers attached before 0.4.5 have
|
|
240
|
+
-- no 5th argument.
|
|
241
|
+
COALESCE(NULLIF(TG_ARGV[4], ''), TG_TABLE_NAME), TG_OP,
|
|
239
242
|
old_json,
|
|
240
243
|
new_json,
|
|
241
244
|
resource_id_value,
|
|
@@ -295,6 +298,15 @@ DECLARE
|
|
|
295
298
|
all_columns text[];
|
|
296
299
|
trigger_args text;
|
|
297
300
|
BEGIN
|
|
301
|
+
-- A partition carries the trigger cloned from its parent (which records
|
|
302
|
+
-- rows under the parent's name); that clone can't be replaced here.
|
|
303
|
+
IF EXISTS (
|
|
304
|
+
SELECT 1 FROM pg_class c
|
|
305
|
+
WHERE c.oid = format('public.%I', target_table)::regclass AND c.relispartition
|
|
306
|
+
) THEN
|
|
307
|
+
RETURN;
|
|
308
|
+
END IF;
|
|
309
|
+
|
|
298
310
|
-- Detect the table's single-column primary key so the trigger can
|
|
299
311
|
-- populate `resource_id` correctly regardless of how the customer
|
|
300
312
|
-- named their PK column. Tables whose PK isn't `id` are a normal
|
|
@@ -327,12 +339,17 @@ BEGIN
|
|
|
327
339
|
AND a.attnum > 0
|
|
328
340
|
AND NOT a.attisdropped;
|
|
329
341
|
|
|
342
|
+
-- The 5th argument is the table's own name. Postgres clones a
|
|
343
|
+
-- partitioned table's trigger, arguments included, onto every
|
|
344
|
+
-- partition, where TG_TABLE_NAME is the partition
|
|
345
|
+
-- (`events_2026_11`); the argument keeps the parent's name.
|
|
330
346
|
trigger_args := format(
|
|
331
|
-
'%L, %L, %L, %L',
|
|
347
|
+
'%L, %L, %L, %L, %L',
|
|
332
348
|
COALESCE(pk_column_name, ''),
|
|
333
349
|
sensitive_columns::text,
|
|
334
350
|
all_columns::text,
|
|
335
|
-
public.ezlogs_patterns_version()
|
|
351
|
+
public.ezlogs_patterns_version(),
|
|
352
|
+
target_table
|
|
336
353
|
);
|
|
337
354
|
|
|
338
355
|
-- Already attached with exactly these arguments (same PK, columns and
|