@usebetterdev/audit-cli 0.4.0-beta.1
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/dist/check.d.ts +17 -0
- package/dist/check.js +8 -0
- package/dist/check.js.map +1 -0
- package/dist/chunk-2G3BRX4J.js +12 -0
- package/dist/chunk-2G3BRX4J.js.map +1 -0
- package/dist/chunk-2LFMRHGS.js +12 -0
- package/dist/chunk-2LFMRHGS.js.map +1 -0
- package/dist/chunk-3MHCJHIZ.js +12 -0
- package/dist/chunk-3MHCJHIZ.js.map +1 -0
- package/dist/chunk-MG36ZYWA.js +16 -0
- package/dist/chunk-MG36ZYWA.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +39 -0
- package/dist/cli.js.map +1 -0
- package/dist/migrate.d.ts +19 -0
- package/dist/migrate.js +8 -0
- package/dist/migrate.js.map +1 -0
- package/dist/purge.d.ts +15 -0
- package/dist/purge.js +8 -0
- package/dist/purge.js.map +1 -0
- package/dist/stats.d.ts +19 -0
- package/dist/stats.js +8 -0
- package/dist/stats.js.map +1 -0
- package/package.json +39 -0
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `better-audit check` — Verify audit_logs table exists and the ORM adapter
|
|
3
|
+
* is correctly capturing mutations.
|
|
4
|
+
*
|
|
5
|
+
* Checks:
|
|
6
|
+
* 1. audit_logs table exists with all required columns
|
|
7
|
+
* 2. Indexes are present
|
|
8
|
+
* 3. ORM adapter is installed and responds to a test mutation
|
|
9
|
+
*
|
|
10
|
+
* TODO: Connect to DB and run checks.
|
|
11
|
+
*/
|
|
12
|
+
interface CheckOptions {
|
|
13
|
+
config?: string;
|
|
14
|
+
}
|
|
15
|
+
declare function check(options?: CheckOptions): Promise<void>;
|
|
16
|
+
|
|
17
|
+
export { type CheckOptions, check };
|
package/dist/check.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/migrate.ts"],"sourcesContent":["/**\n * `better-audit migrate` — Generate and apply the audit_logs table migration.\n *\n * Generates appropriate DDL for the configured database:\n * - Postgres: JSONB columns, TIMESTAMPTZ, INET, GIN indexes\n * - MySQL: JSON columns, DATETIME(6), standard indexes\n * - SQLite: TEXT columns for JSON, standard indexes\n *\n * TODO: Connect to DB via adapter config and run migration.\n */\n\nexport interface MigrateOptions {\n /** Config file path (default: better-audit.config.ts) */\n config?: string;\n /** Output SQL to stdout instead of applying it */\n dryRun?: boolean;\n}\n\nexport async function migrate(options: MigrateOptions = {}): Promise<void> {\n console.log(\"[better-audit] migrate — not yet implemented\");\n void options;\n}\n"],"mappings":";;;AAkBA,eAAsB,QAAQ,UAA0B,CAAC,GAAkB;AACzE,UAAQ,IAAI,mDAA8C;AAC1D,OAAK;AACP;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/check.ts"],"sourcesContent":["/**\n * `better-audit check` — Verify audit_logs table exists and the ORM adapter\n * is correctly capturing mutations.\n *\n * Checks:\n * 1. audit_logs table exists with all required columns\n * 2. Indexes are present\n * 3. ORM adapter is installed and responds to a test mutation\n *\n * TODO: Connect to DB and run checks.\n */\n\nexport interface CheckOptions {\n config?: string;\n}\n\nexport async function check(options: CheckOptions = {}): Promise<void> {\n console.log(\"[better-audit] check — not yet implemented\");\n void options;\n}\n"],"mappings":";;;AAgBA,eAAsB,MAAM,UAAwB,CAAC,GAAkB;AACrE,UAAQ,IAAI,iDAA4C;AACxD,OAAK;AACP;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stats.ts"],"sourcesContent":["/**\n * `better-audit stats` — Show audit log statistics.\n *\n * Outputs:\n * - Total log count\n * - Events per day (last 7 / 30 days)\n * - Top actors (by event count)\n * - Top tables (by event count)\n * - Severity distribution\n *\n * TODO: Connect to DB and run aggregation queries.\n */\n\nexport interface StatsOptions {\n config?: string;\n since?: string;\n}\n\nexport async function stats(options: StatsOptions = {}): Promise<void> {\n console.log(\"[better-audit] stats — not yet implemented\");\n void options;\n}\n"],"mappings":";;;AAkBA,eAAsB,MAAM,UAAwB,CAAC,GAAkB;AACrE,UAAQ,IAAI,iDAA4C;AACxD,OAAK;AACP;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/purge.ts
|
|
4
|
+
async function purge(options = {}) {
|
|
5
|
+
if (options.dryRun) {
|
|
6
|
+
console.log("[better-audit] purge --dry-run \u2014 not yet implemented");
|
|
7
|
+
} else {
|
|
8
|
+
console.log("[better-audit] purge \u2014 not yet implemented");
|
|
9
|
+
}
|
|
10
|
+
void options;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
purge
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-MG36ZYWA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/purge.ts"],"sourcesContent":["/**\n * `better-audit purge` — Delete audit logs older than the configured retention period.\n *\n * Always run with --dry-run first to preview what will be deleted.\n *\n * TODO: Connect to DB and run DELETE query with retention window.\n */\n\nexport interface PurgeOptions {\n config?: string;\n /** Preview rows to be deleted without deleting them. */\n dryRun?: boolean;\n}\n\nexport async function purge(options: PurgeOptions = {}): Promise<void> {\n if (options.dryRun) {\n console.log(\"[better-audit] purge --dry-run — not yet implemented\");\n } else {\n console.log(\"[better-audit] purge — not yet implemented\");\n }\n void options;\n}\n"],"mappings":";;;AAcA,eAAsB,MAAM,UAAwB,CAAC,GAAkB;AACrE,MAAI,QAAQ,QAAQ;AAClB,YAAQ,IAAI,2DAAsD;AAAA,EACpE,OAAO;AACL,YAAQ,IAAI,iDAA4C;AAAA,EAC1D;AACA,OAAK;AACP;","names":[]}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
import {
|
|
4
|
+
check
|
|
5
|
+
} from "./chunk-2LFMRHGS.js";
|
|
6
|
+
import {
|
|
7
|
+
migrate
|
|
8
|
+
} from "./chunk-2G3BRX4J.js";
|
|
9
|
+
import {
|
|
10
|
+
purge
|
|
11
|
+
} from "./chunk-MG36ZYWA.js";
|
|
12
|
+
import {
|
|
13
|
+
stats
|
|
14
|
+
} from "./chunk-3MHCJHIZ.js";
|
|
15
|
+
|
|
16
|
+
// src/cli.ts
|
|
17
|
+
import { Command } from "commander";
|
|
18
|
+
var program = new Command().name("better-audit").description("CLI for better-audit \u2014 compliance-ready audit logging").version("0.1.0");
|
|
19
|
+
program.command("migrate").description("Generate and apply the audit_logs table migration").option("-c, --config <path>", "Config file path", "better-audit.config.ts").option("--dry-run", "Print SQL without applying it").action(async (opts) => {
|
|
20
|
+
const migrateOpts = { config: opts.config };
|
|
21
|
+
if (opts.dryRun !== void 0) migrateOpts.dryRun = opts.dryRun;
|
|
22
|
+
await migrate(migrateOpts);
|
|
23
|
+
});
|
|
24
|
+
program.command("check").description("Verify the audit_logs table and ORM adapter are working").option("-c, --config <path>", "Config file path", "better-audit.config.ts").action(async (opts) => {
|
|
25
|
+
await check({ config: opts.config });
|
|
26
|
+
});
|
|
27
|
+
program.command("stats").description("Show audit log statistics").option("-c, --config <path>", "Config file path", "better-audit.config.ts").option("--since <period>", "Time window (e.g. 30d)", "30d").action(async (opts) => {
|
|
28
|
+
await stats({ config: opts.config, since: opts.since });
|
|
29
|
+
});
|
|
30
|
+
program.command("purge").description("Delete audit logs older than the retention period").option("-c, --config <path>", "Config file path", "better-audit.config.ts").option("--dry-run", "Preview rows to be deleted without deleting them").action(async (opts) => {
|
|
31
|
+
const purgeOpts = { config: opts.config };
|
|
32
|
+
if (opts.dryRun !== void 0) purgeOpts.dryRun = opts.dryRun;
|
|
33
|
+
await purge(purgeOpts);
|
|
34
|
+
});
|
|
35
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
36
|
+
console.error(err);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport { migrate } from \"./migrate.js\";\nimport { check } from \"./check.js\";\nimport { stats } from \"./stats.js\";\nimport { purge } from \"./purge.js\";\n\nconst program = new Command()\n .name(\"better-audit\")\n .description(\"CLI for better-audit — compliance-ready audit logging\")\n .version(\"0.1.0\");\n\nprogram\n .command(\"migrate\")\n .description(\"Generate and apply the audit_logs table migration\")\n .option(\"-c, --config <path>\", \"Config file path\", \"better-audit.config.ts\")\n .option(\"--dry-run\", \"Print SQL without applying it\")\n .action(async (opts: { config: string; dryRun?: boolean }) => {\n const migrateOpts: Parameters<typeof migrate>[0] = { config: opts.config };\n if (opts.dryRun !== undefined) migrateOpts.dryRun = opts.dryRun;\n await migrate(migrateOpts);\n });\n\nprogram\n .command(\"check\")\n .description(\"Verify the audit_logs table and ORM adapter are working\")\n .option(\"-c, --config <path>\", \"Config file path\", \"better-audit.config.ts\")\n .action(async (opts: { config: string }) => {\n await check({ config: opts.config });\n });\n\nprogram\n .command(\"stats\")\n .description(\"Show audit log statistics\")\n .option(\"-c, --config <path>\", \"Config file path\", \"better-audit.config.ts\")\n .option(\"--since <period>\", \"Time window (e.g. 30d)\", \"30d\")\n .action(async (opts: { config: string; since: string }) => {\n await stats({ config: opts.config, since: opts.since });\n });\n\nprogram\n .command(\"purge\")\n .description(\"Delete audit logs older than the retention period\")\n .option(\"-c, --config <path>\", \"Config file path\", \"better-audit.config.ts\")\n .option(\"--dry-run\", \"Preview rows to be deleted without deleting them\")\n .action(async (opts: { config: string; dryRun?: boolean }) => {\n const purgeOpts: Parameters<typeof purge>[0] = { config: opts.config };\n if (opts.dryRun !== undefined) purgeOpts.dryRun = opts.dryRun;\n await purge(purgeOpts);\n });\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n console.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;AACA,SAAS,eAAe;AAMxB,IAAM,UAAU,IAAI,QAAQ,EACzB,KAAK,cAAc,EACnB,YAAY,4DAAuD,EACnE,QAAQ,OAAO;AAElB,QACG,QAAQ,SAAS,EACjB,YAAY,mDAAmD,EAC/D,OAAO,uBAAuB,oBAAoB,wBAAwB,EAC1E,OAAO,aAAa,+BAA+B,EACnD,OAAO,OAAO,SAA+C;AAC5D,QAAM,cAA6C,EAAE,QAAQ,KAAK,OAAO;AACzE,MAAI,KAAK,WAAW,OAAW,aAAY,SAAS,KAAK;AACzD,QAAM,QAAQ,WAAW;AAC3B,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,yDAAyD,EACrE,OAAO,uBAAuB,oBAAoB,wBAAwB,EAC1E,OAAO,OAAO,SAA6B;AAC1C,QAAM,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC;AACrC,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,2BAA2B,EACvC,OAAO,uBAAuB,oBAAoB,wBAAwB,EAC1E,OAAO,oBAAoB,0BAA0B,KAAK,EAC1D,OAAO,OAAO,SAA4C;AACzD,QAAM,MAAM,EAAE,QAAQ,KAAK,QAAQ,OAAO,KAAK,MAAM,CAAC;AACxD,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,mDAAmD,EAC/D,OAAO,uBAAuB,oBAAoB,wBAAwB,EAC1E,OAAO,aAAa,kDAAkD,EACtE,OAAO,OAAO,SAA+C;AAC5D,QAAM,YAAyC,EAAE,QAAQ,KAAK,OAAO;AACrE,MAAI,KAAK,WAAW,OAAW,WAAU,SAAS,KAAK;AACvD,QAAM,MAAM,SAAS;AACvB,CAAC;AAEH,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACvD,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `better-audit migrate` — Generate and apply the audit_logs table migration.
|
|
3
|
+
*
|
|
4
|
+
* Generates appropriate DDL for the configured database:
|
|
5
|
+
* - Postgres: JSONB columns, TIMESTAMPTZ, INET, GIN indexes
|
|
6
|
+
* - MySQL: JSON columns, DATETIME(6), standard indexes
|
|
7
|
+
* - SQLite: TEXT columns for JSON, standard indexes
|
|
8
|
+
*
|
|
9
|
+
* TODO: Connect to DB via adapter config and run migration.
|
|
10
|
+
*/
|
|
11
|
+
interface MigrateOptions {
|
|
12
|
+
/** Config file path (default: better-audit.config.ts) */
|
|
13
|
+
config?: string;
|
|
14
|
+
/** Output SQL to stdout instead of applying it */
|
|
15
|
+
dryRun?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare function migrate(options?: MigrateOptions): Promise<void>;
|
|
18
|
+
|
|
19
|
+
export { type MigrateOptions, migrate };
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/purge.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `better-audit purge` — Delete audit logs older than the configured retention period.
|
|
3
|
+
*
|
|
4
|
+
* Always run with --dry-run first to preview what will be deleted.
|
|
5
|
+
*
|
|
6
|
+
* TODO: Connect to DB and run DELETE query with retention window.
|
|
7
|
+
*/
|
|
8
|
+
interface PurgeOptions {
|
|
9
|
+
config?: string;
|
|
10
|
+
/** Preview rows to be deleted without deleting them. */
|
|
11
|
+
dryRun?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function purge(options?: PurgeOptions): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { type PurgeOptions, purge };
|
package/dist/purge.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/stats.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `better-audit stats` — Show audit log statistics.
|
|
3
|
+
*
|
|
4
|
+
* Outputs:
|
|
5
|
+
* - Total log count
|
|
6
|
+
* - Events per day (last 7 / 30 days)
|
|
7
|
+
* - Top actors (by event count)
|
|
8
|
+
* - Top tables (by event count)
|
|
9
|
+
* - Severity distribution
|
|
10
|
+
*
|
|
11
|
+
* TODO: Connect to DB and run aggregation queries.
|
|
12
|
+
*/
|
|
13
|
+
interface StatsOptions {
|
|
14
|
+
config?: string;
|
|
15
|
+
since?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function stats(options?: StatsOptions): Promise<void>;
|
|
18
|
+
|
|
19
|
+
export { type StatsOptions, stats };
|
package/dist/stats.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@usebetterdev/audit-cli",
|
|
3
|
+
"version": "0.4.0-beta.1",
|
|
4
|
+
"repository": "github:usebetter-dev/usebetter",
|
|
5
|
+
"bugs": "https://github.com/usebetter-dev/usebetter/issues",
|
|
6
|
+
"homepage": "https://github.com/usebetter-dev/usebetter#readme",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/cli.js",
|
|
13
|
+
"bin": {
|
|
14
|
+
"better-audit": "./dist/cli.js",
|
|
15
|
+
"audit-cli": "./dist/cli.js"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prepare": "mkdir -p dist && test -f dist/cli.js || echo '#!/usr/bin/env node' > dist/cli.js",
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@clack/prompts": "^0.10.0",
|
|
26
|
+
"@usebetterdev/audit-core": "workspace:*",
|
|
27
|
+
"commander": "^12.1.0",
|
|
28
|
+
"picocolors": "^1.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^22.10.0",
|
|
32
|
+
"tsup": "^8.3.5",
|
|
33
|
+
"typescript": "~5.7.2",
|
|
34
|
+
"vitest": "^2.1.6"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=22"
|
|
38
|
+
}
|
|
39
|
+
}
|