ezlogs-nextjs 0.1.0

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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +779 -0
  3. package/bin/install-triggers.cjs +75 -0
  4. package/dist/actors/index.cjs +111 -0
  5. package/dist/actors/index.d.cts +52 -0
  6. package/dist/actors/index.d.ts +52 -0
  7. package/dist/actors/index.js +107 -0
  8. package/dist/configuration-D9x9Gvds.d.cts +190 -0
  9. package/dist/configuration-D9x9Gvds.d.ts +190 -0
  10. package/dist/db/drizzle.cjs +898 -0
  11. package/dist/db/drizzle.d.cts +68 -0
  12. package/dist/db/drizzle.d.ts +68 -0
  13. package/dist/db/drizzle.js +893 -0
  14. package/dist/db/prisma.cjs +826 -0
  15. package/dist/db/prisma.d.cts +3 -0
  16. package/dist/db/prisma.d.ts +3 -0
  17. package/dist/db/prisma.js +824 -0
  18. package/dist/db/supabase.cjs +1027 -0
  19. package/dist/db/supabase.d.cts +32 -0
  20. package/dist/db/supabase.d.ts +32 -0
  21. package/dist/db/supabase.js +1024 -0
  22. package/dist/index.cjs +3329 -0
  23. package/dist/index.d.cts +305 -0
  24. package/dist/index.d.ts +305 -0
  25. package/dist/index.js +3317 -0
  26. package/dist/jobs/bullmq.cjs +624 -0
  27. package/dist/jobs/bullmq.d.cts +33 -0
  28. package/dist/jobs/bullmq.d.ts +33 -0
  29. package/dist/jobs/bullmq.js +621 -0
  30. package/dist/jobs/inngest.cjs +645 -0
  31. package/dist/jobs/inngest.d.cts +21 -0
  32. package/dist/jobs/inngest.d.ts +21 -0
  33. package/dist/jobs/inngest.js +642 -0
  34. package/dist/jobs/supabase-queues.cjs +661 -0
  35. package/dist/jobs/supabase-queues.d.cts +37 -0
  36. package/dist/jobs/supabase-queues.d.ts +37 -0
  37. package/dist/jobs/supabase-queues.js +657 -0
  38. package/dist/jobs/trigger.cjs +622 -0
  39. package/dist/jobs/trigger.d.cts +46 -0
  40. package/dist/jobs/trigger.d.ts +46 -0
  41. package/dist/jobs/trigger.js +619 -0
  42. package/dist/jobs/upstash-workflow.cjs +673 -0
  43. package/dist/jobs/upstash-workflow.d.cts +57 -0
  44. package/dist/jobs/upstash-workflow.d.ts +57 -0
  45. package/dist/jobs/upstash-workflow.js +669 -0
  46. package/dist/nextjs-plugin/index.cjs +232 -0
  47. package/dist/nextjs-plugin/index.d.cts +68 -0
  48. package/dist/nextjs-plugin/index.d.ts +68 -0
  49. package/dist/nextjs-plugin/index.js +229 -0
  50. package/dist/nextjs-plugin/loader.cjs +16248 -0
  51. package/dist/nextjs-plugin/loader.d.cts +61 -0
  52. package/dist/nextjs-plugin/loader.d.ts +61 -0
  53. package/dist/nextjs-plugin/loader.js +16242 -0
  54. package/dist/triggers/index.cjs +1354 -0
  55. package/dist/triggers/index.d.cts +243 -0
  56. package/dist/triggers/index.d.ts +243 -0
  57. package/dist/triggers/index.js +1337 -0
  58. package/package.json +150 -0
  59. package/sql/postgres/00_install.sql +205 -0
@@ -0,0 +1,68 @@
1
+ type DbOperation = "create" | "update" | "destroy";
2
+
3
+ interface DrizzleLogger {
4
+ logQuery(query: string, params: unknown[]): void;
5
+ }
6
+ interface Options {
7
+ /** Chain to a user's existing logger after capture. */
8
+ next?: DrizzleLogger;
9
+ }
10
+ declare function ezlogsDrizzleLogger(options?: Options): DrizzleLogger;
11
+ /**
12
+ * Extract a resource id from a simple `WHERE id = $N` (Postgres) or
13
+ * `WHERE id = ?` (MySQL / SQLite) clause. Returns null on any
14
+ * uncertainty — the parser is intentionally narrow.
15
+ *
16
+ * Accepted shapes (case-insensitive, optional double-quotes around `id`):
17
+ *
18
+ * UPDATE "t" SET ... WHERE id = $1
19
+ * DELETE FROM "t" WHERE "id" = $2
20
+ * UPDATE t SET ... WHERE id = ?
21
+ *
22
+ * Rejected (return null) — Phase 4 leaves these for later:
23
+ *
24
+ * WHERE id = $1 AND user_id = $2 (paranoid filter; ambiguous which placeholder to use)
25
+ * WHERE asset_id = $1 (non-`id` column; unique-per-row signal we don't have)
26
+ * WHERE id IN ($1, $2) (multi-row)
27
+ * WHERE upper(id) = $1 (function call; can't index back to params)
28
+ * anything with `OR`, parens, sub-queries
29
+ */
30
+ declare function extractResourceIdFromSimpleWhere(query: string, params: unknown[]): string | number | null;
31
+ /**
32
+ * Extract `{column: newValue, ...}` from an UPDATE's `SET` clause.
33
+ *
34
+ * Drizzle's logger gives us `(query, params)` only — there's no
35
+ * before-state. But the SET clause itself encodes what's being
36
+ * written, with parameter placeholders pointing into `params`. So
37
+ * we can at least surface the new values; without this, every
38
+ * Drizzle UPDATE renders "No tracked changes" in the dashboard.
39
+ *
40
+ * Accepted shapes (case-insensitive):
41
+ *
42
+ * UPDATE "t" SET "name" = $1
43
+ * UPDATE t SET name = $1, email = $2 WHERE id = $3
44
+ * update "users" set "name" = $1, "email" = $2 where ...
45
+ *
46
+ * Rejected — return null:
47
+ *
48
+ * SET expressions involving function calls (`now()`, `upper(...)`)
49
+ * SET expressions referencing other columns (`count = count + 1`)
50
+ * SET CASE WHEN ... THEN ...
51
+ * Any sub-query in the SET
52
+ *
53
+ * Drizzle's typed builders only generate the simple `col = $N` shape
54
+ * for `.set({col: val})`. The rejected shapes appear when users drop
55
+ * to raw SQL via `sql\`\`` template tags, which we (correctly) leave
56
+ * as "no changes captured" rather than guess.
57
+ */
58
+ declare function extractSetChangesFromUpdate(query: string, params: unknown[]): {
59
+ attribute: string;
60
+ to: unknown;
61
+ }[] | null;
62
+ interface ParsedMutation {
63
+ operation: DbOperation;
64
+ table: string;
65
+ }
66
+ declare function parseMutation(query: string): ParsedMutation | null;
67
+
68
+ export { extractResourceIdFromSimpleWhere, extractSetChangesFromUpdate, ezlogsDrizzleLogger, parseMutation };
@@ -0,0 +1,68 @@
1
+ type DbOperation = "create" | "update" | "destroy";
2
+
3
+ interface DrizzleLogger {
4
+ logQuery(query: string, params: unknown[]): void;
5
+ }
6
+ interface Options {
7
+ /** Chain to a user's existing logger after capture. */
8
+ next?: DrizzleLogger;
9
+ }
10
+ declare function ezlogsDrizzleLogger(options?: Options): DrizzleLogger;
11
+ /**
12
+ * Extract a resource id from a simple `WHERE id = $N` (Postgres) or
13
+ * `WHERE id = ?` (MySQL / SQLite) clause. Returns null on any
14
+ * uncertainty — the parser is intentionally narrow.
15
+ *
16
+ * Accepted shapes (case-insensitive, optional double-quotes around `id`):
17
+ *
18
+ * UPDATE "t" SET ... WHERE id = $1
19
+ * DELETE FROM "t" WHERE "id" = $2
20
+ * UPDATE t SET ... WHERE id = ?
21
+ *
22
+ * Rejected (return null) — Phase 4 leaves these for later:
23
+ *
24
+ * WHERE id = $1 AND user_id = $2 (paranoid filter; ambiguous which placeholder to use)
25
+ * WHERE asset_id = $1 (non-`id` column; unique-per-row signal we don't have)
26
+ * WHERE id IN ($1, $2) (multi-row)
27
+ * WHERE upper(id) = $1 (function call; can't index back to params)
28
+ * anything with `OR`, parens, sub-queries
29
+ */
30
+ declare function extractResourceIdFromSimpleWhere(query: string, params: unknown[]): string | number | null;
31
+ /**
32
+ * Extract `{column: newValue, ...}` from an UPDATE's `SET` clause.
33
+ *
34
+ * Drizzle's logger gives us `(query, params)` only — there's no
35
+ * before-state. But the SET clause itself encodes what's being
36
+ * written, with parameter placeholders pointing into `params`. So
37
+ * we can at least surface the new values; without this, every
38
+ * Drizzle UPDATE renders "No tracked changes" in the dashboard.
39
+ *
40
+ * Accepted shapes (case-insensitive):
41
+ *
42
+ * UPDATE "t" SET "name" = $1
43
+ * UPDATE t SET name = $1, email = $2 WHERE id = $3
44
+ * update "users" set "name" = $1, "email" = $2 where ...
45
+ *
46
+ * Rejected — return null:
47
+ *
48
+ * SET expressions involving function calls (`now()`, `upper(...)`)
49
+ * SET expressions referencing other columns (`count = count + 1`)
50
+ * SET CASE WHEN ... THEN ...
51
+ * Any sub-query in the SET
52
+ *
53
+ * Drizzle's typed builders only generate the simple `col = $N` shape
54
+ * for `.set({col: val})`. The rejected shapes appear when users drop
55
+ * to raw SQL via `sql\`\`` template tags, which we (correctly) leave
56
+ * as "no changes captured" rather than guess.
57
+ */
58
+ declare function extractSetChangesFromUpdate(query: string, params: unknown[]): {
59
+ attribute: string;
60
+ to: unknown;
61
+ }[] | null;
62
+ interface ParsedMutation {
63
+ operation: DbOperation;
64
+ table: string;
65
+ }
66
+ declare function parseMutation(query: string): ParsedMutation | null;
67
+
68
+ export { extractResourceIdFromSimpleWhere, extractSetChangesFromUpdate, ezlogsDrizzleLogger, parseMutation };