@usebetterdev/audit-cli 0.4.0-beta.1 → 0.4.0-beta.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 usebetter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.js CHANGED
@@ -1,39 +1 @@
1
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usebetterdev/audit-cli",
3
- "version": "0.4.0-beta.1",
3
+ "version": "0.4.0-beta.3",
4
4
  "repository": "github:usebetter-dev/usebetter",
5
5
  "bugs": "https://github.com/usebetter-dev/usebetter/issues",
6
6
  "homepage": "https://github.com/usebetter-dev/usebetter#readme",
@@ -14,18 +14,14 @@
14
14
  "better-audit": "./dist/cli.js",
15
15
  "audit-cli": "./dist/cli.js"
16
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
- },
17
+ "files": [
18
+ "dist"
19
+ ],
24
20
  "dependencies": {
25
21
  "@clack/prompts": "^0.10.0",
26
- "@usebetterdev/audit-core": "workspace:*",
27
22
  "commander": "^12.1.0",
28
- "picocolors": "^1.1.0"
23
+ "picocolors": "^1.1.0",
24
+ "@usebetterdev/audit-core": "0.4.0-beta.3"
29
25
  },
30
26
  "devDependencies": {
31
27
  "@types/node": "^22.10.0",
@@ -35,5 +31,10 @@
35
31
  },
36
32
  "engines": {
37
33
  "node": ">=22"
34
+ },
35
+ "scripts": {
36
+ "build": "tsup",
37
+ "test": "vitest run",
38
+ "typecheck": "tsc --noEmit"
38
39
  }
39
- }
40
+ }
package/dist/check.d.ts DELETED
@@ -1,17 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- check
4
- } from "./chunk-2LFMRHGS.js";
5
- export {
6
- check
7
- };
8
- //# sourceMappingURL=check.js.map
package/dist/check.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/migrate.ts
4
- async function migrate(options = {}) {
5
- console.log("[better-audit] migrate \u2014 not yet implemented");
6
- void options;
7
- }
8
-
9
- export {
10
- migrate
11
- };
12
- //# sourceMappingURL=chunk-2G3BRX4J.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/check.ts
4
- async function check(options = {}) {
5
- console.log("[better-audit] check \u2014 not yet implemented");
6
- void options;
7
- }
8
-
9
- export {
10
- check
11
- };
12
- //# sourceMappingURL=chunk-2LFMRHGS.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/stats.ts
4
- async function stats(options = {}) {
5
- console.log("[better-audit] stats \u2014 not yet implemented");
6
- void options;
7
- }
8
-
9
- export {
10
- stats
11
- };
12
- //# sourceMappingURL=chunk-3MHCJHIZ.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,16 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
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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0 @@
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 DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- migrate
4
- } from "./chunk-2G3BRX4J.js";
5
- export {
6
- migrate
7
- };
8
- //# sourceMappingURL=migrate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/purge.d.ts DELETED
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- purge
4
- } from "./chunk-MG36ZYWA.js";
5
- export {
6
- purge
7
- };
8
- //# sourceMappingURL=purge.js.map
package/dist/purge.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/stats.d.ts DELETED
@@ -1,19 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- stats
4
- } from "./chunk-3MHCJHIZ.js";
5
- export {
6
- stats
7
- };
8
- //# sourceMappingURL=stats.js.map
package/dist/stats.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}