convex-audit-log 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 (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +408 -0
  3. package/dist/client/_generated/_ignore.d.ts +1 -0
  4. package/dist/client/_generated/_ignore.d.ts.map +1 -0
  5. package/dist/client/_generated/_ignore.js +3 -0
  6. package/dist/client/_generated/_ignore.js.map +1 -0
  7. package/dist/client/index.d.ts +336 -0
  8. package/dist/client/index.d.ts.map +1 -0
  9. package/dist/client/index.js +297 -0
  10. package/dist/client/index.js.map +1 -0
  11. package/dist/component/_generated/api.d.ts +36 -0
  12. package/dist/component/_generated/api.d.ts.map +1 -0
  13. package/dist/component/_generated/api.js +31 -0
  14. package/dist/component/_generated/api.js.map +1 -0
  15. package/dist/component/_generated/component.d.ts +317 -0
  16. package/dist/component/_generated/component.d.ts.map +1 -0
  17. package/dist/component/_generated/component.js +11 -0
  18. package/dist/component/_generated/component.js.map +1 -0
  19. package/dist/component/_generated/dataModel.d.ts +46 -0
  20. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  21. package/dist/component/_generated/dataModel.js +11 -0
  22. package/dist/component/_generated/dataModel.js.map +1 -0
  23. package/dist/component/_generated/server.d.ts +121 -0
  24. package/dist/component/_generated/server.d.ts.map +1 -0
  25. package/dist/component/_generated/server.js +78 -0
  26. package/dist/component/_generated/server.js.map +1 -0
  27. package/dist/component/convex.config.d.ts +3 -0
  28. package/dist/component/convex.config.d.ts.map +1 -0
  29. package/dist/component/convex.config.js +3 -0
  30. package/dist/component/convex.config.js.map +1 -0
  31. package/dist/component/lib.d.ts +341 -0
  32. package/dist/component/lib.d.ts.map +1 -0
  33. package/dist/component/lib.js +598 -0
  34. package/dist/component/lib.js.map +1 -0
  35. package/dist/component/schema.d.ts +87 -0
  36. package/dist/component/schema.d.ts.map +1 -0
  37. package/dist/component/schema.js +71 -0
  38. package/dist/component/schema.js.map +1 -0
  39. package/dist/component/shared.d.ts +203 -0
  40. package/dist/component/shared.d.ts.map +1 -0
  41. package/dist/component/shared.js +94 -0
  42. package/dist/component/shared.js.map +1 -0
  43. package/dist/react/index.d.ts +247 -0
  44. package/dist/react/index.d.ts.map +1 -0
  45. package/dist/react/index.js +196 -0
  46. package/dist/react/index.js.map +1 -0
  47. package/package.json +115 -0
  48. package/src/client/_generated/_ignore.ts +1 -0
  49. package/src/client/index.test.ts +61 -0
  50. package/src/client/index.ts +525 -0
  51. package/src/client/setup.test.ts +26 -0
  52. package/src/component/_generated/api.ts +52 -0
  53. package/src/component/_generated/component.ts +392 -0
  54. package/src/component/_generated/dataModel.ts +60 -0
  55. package/src/component/_generated/server.ts +161 -0
  56. package/src/component/convex.config.ts +3 -0
  57. package/src/component/lib.test.ts +171 -0
  58. package/src/component/lib.ts +722 -0
  59. package/src/component/schema.ts +93 -0
  60. package/src/component/setup.test.ts +11 -0
  61. package/src/component/shared.ts +167 -0
  62. package/src/react/index.ts +305 -0
  63. package/src/test.ts +18 -0
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Severity levels for audit events.
3
+ * - info: Regular operations (login, profile update)
4
+ * - warning: Potentially concerning actions (password change, permission change)
5
+ * - error: Failed operations or errors
6
+ * - critical: Security-sensitive events (unauthorized access attempts, data breaches)
7
+ */
8
+ export declare const vSeverity: import("convex/values").VUnion<"info" | "warning" | "error" | "critical", [import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warning", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"critical", "required">], "required", never>;
9
+ export type Severity = "info" | "warning" | "error" | "critical";
10
+ declare const _default: import("convex/server").SchemaDefinition<{
11
+ /**
12
+ * Main audit log table storing all audit events.
13
+ */
14
+ auditLogs: import("convex/server").TableDefinition<import("convex/values").VObject<{
15
+ resourceType?: string | undefined;
16
+ actorId?: string | undefined;
17
+ resourceId?: string | undefined;
18
+ before?: any;
19
+ metadata?: any;
20
+ ipAddress?: string | undefined;
21
+ userAgent?: string | undefined;
22
+ sessionId?: string | undefined;
23
+ tags?: string[] | undefined;
24
+ retentionCategory?: string | undefined;
25
+ after?: any;
26
+ diff?: string | undefined;
27
+ severity: "info" | "warning" | "error" | "critical";
28
+ action: string;
29
+ timestamp: number;
30
+ }, {
31
+ action: import("convex/values").VString<string, "required">;
32
+ actorId: import("convex/values").VString<string | undefined, "optional">;
33
+ timestamp: import("convex/values").VFloat64<number, "required">;
34
+ resourceType: import("convex/values").VString<string | undefined, "optional">;
35
+ resourceId: import("convex/values").VString<string | undefined, "optional">;
36
+ metadata: import("convex/values").VAny<any, "optional", string>;
37
+ severity: import("convex/values").VUnion<"info" | "warning" | "error" | "critical", [import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warning", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"critical", "required">], "required", never>;
38
+ ipAddress: import("convex/values").VString<string | undefined, "optional">;
39
+ userAgent: import("convex/values").VString<string | undefined, "optional">;
40
+ sessionId: import("convex/values").VString<string | undefined, "optional">;
41
+ tags: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
42
+ before: import("convex/values").VAny<any, "optional", string>;
43
+ after: import("convex/values").VAny<any, "optional", string>;
44
+ diff: import("convex/values").VString<string | undefined, "optional">;
45
+ retentionCategory: import("convex/values").VString<string | undefined, "optional">;
46
+ }, "required", "resourceType" | "actorId" | "severity" | "action" | "resourceId" | "before" | "metadata" | "ipAddress" | "userAgent" | "sessionId" | "tags" | "retentionCategory" | `metadata.${string}` | "after" | `before.${string}` | `after.${string}` | "timestamp" | "diff">, {
47
+ by_action_timestamp: ["action", "timestamp", "_creationTime"];
48
+ by_actor_timestamp: ["actorId", "timestamp", "_creationTime"];
49
+ by_resource: ["resourceType", "resourceId", "timestamp", "_creationTime"];
50
+ by_severity_timestamp: ["severity", "timestamp", "_creationTime"];
51
+ by_timestamp: ["timestamp", "_creationTime"];
52
+ by_retention_timestamp: ["retentionCategory", "timestamp", "_creationTime"];
53
+ }, {}, {}>;
54
+ /**
55
+ * Configuration table for component settings.
56
+ * Contains a single document with global configuration.
57
+ */
58
+ config: import("convex/server").TableDefinition<import("convex/values").VObject<{
59
+ customRetention?: {
60
+ category: string;
61
+ retentionDays: number;
62
+ }[] | undefined;
63
+ defaultRetentionDays: number;
64
+ criticalRetentionDays: number;
65
+ piiFieldsToRedact: string[];
66
+ samplingEnabled: boolean;
67
+ samplingRate: number;
68
+ }, {
69
+ defaultRetentionDays: import("convex/values").VFloat64<number, "required">;
70
+ criticalRetentionDays: import("convex/values").VFloat64<number, "required">;
71
+ piiFieldsToRedact: import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">;
72
+ samplingEnabled: import("convex/values").VBoolean<boolean, "required">;
73
+ samplingRate: import("convex/values").VFloat64<number, "required">;
74
+ customRetention: import("convex/values").VArray<{
75
+ category: string;
76
+ retentionDays: number;
77
+ }[] | undefined, import("convex/values").VObject<{
78
+ category: string;
79
+ retentionDays: number;
80
+ }, {
81
+ category: import("convex/values").VString<string, "required">;
82
+ retentionDays: import("convex/values").VFloat64<number, "required">;
83
+ }, "required", "category" | "retentionDays">, "optional">;
84
+ }, "required", "defaultRetentionDays" | "criticalRetentionDays" | "piiFieldsToRedact" | "samplingEnabled" | "samplingRate" | "customRetention">, {}, {}, {}>;
85
+ }, true>;
86
+ export default _default;
87
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,gUAKrB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;;IAG/D;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4CH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlDL,wBAyEG"}
@@ -0,0 +1,71 @@
1
+ import { defineSchema, defineTable } from "convex/server";
2
+ import { v } from "convex/values";
3
+ /**
4
+ * Severity levels for audit events.
5
+ * - info: Regular operations (login, profile update)
6
+ * - warning: Potentially concerning actions (password change, permission change)
7
+ * - error: Failed operations or errors
8
+ * - critical: Security-sensitive events (unauthorized access attempts, data breaches)
9
+ */
10
+ export const vSeverity = v.union(v.literal("info"), v.literal("warning"), v.literal("error"), v.literal("critical"));
11
+ export default defineSchema({
12
+ /**
13
+ * Main audit log table storing all audit events.
14
+ */
15
+ auditLogs: defineTable({
16
+ // Core event data
17
+ action: v.string(),
18
+ actorId: v.optional(v.string()),
19
+ timestamp: v.number(),
20
+ // Resource tracking
21
+ resourceType: v.optional(v.string()),
22
+ resourceId: v.optional(v.string()),
23
+ // Event metadata
24
+ metadata: v.optional(v.any()),
25
+ severity: vSeverity,
26
+ // Context information
27
+ ipAddress: v.optional(v.string()),
28
+ userAgent: v.optional(v.string()),
29
+ sessionId: v.optional(v.string()),
30
+ // Compliance tags
31
+ tags: v.optional(v.array(v.string())),
32
+ // Change tracking
33
+ before: v.optional(v.any()),
34
+ after: v.optional(v.any()),
35
+ diff: v.optional(v.string()),
36
+ // Retention category for cleanup policies
37
+ retentionCategory: v.optional(v.string()),
38
+ })
39
+ // Query by action type with time ordering
40
+ .index("by_action_timestamp", ["action", "timestamp"])
41
+ // Query by actor (user) with time ordering
42
+ .index("by_actor_timestamp", ["actorId", "timestamp"])
43
+ // Query by resource with time ordering
44
+ .index("by_resource", ["resourceType", "resourceId", "timestamp"])
45
+ // Query by severity level with time ordering
46
+ .index("by_severity_timestamp", ["severity", "timestamp"])
47
+ // Query by timestamp for time-range queries
48
+ .index("by_timestamp", ["timestamp"])
49
+ // Query by retention category for cleanup
50
+ .index("by_retention_timestamp", ["retentionCategory", "timestamp"]),
51
+ /**
52
+ * Configuration table for component settings.
53
+ * Contains a single document with global configuration.
54
+ */
55
+ config: defineTable({
56
+ // Retention settings
57
+ defaultRetentionDays: v.number(),
58
+ criticalRetentionDays: v.number(),
59
+ // PII redaction settings
60
+ piiFieldsToRedact: v.array(v.string()),
61
+ // Sampling settings (for high-volume apps)
62
+ samplingEnabled: v.boolean(),
63
+ samplingRate: v.number(), // 0.0 to 1.0
64
+ // Custom retention categories
65
+ customRetention: v.optional(v.array(v.object({
66
+ category: v.string(),
67
+ retentionDays: v.number(),
68
+ }))),
69
+ }),
70
+ });
71
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAC9B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EACjB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAClB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CACtB,CAAC;AAIF,eAAe,YAAY,CAAC;IAC1B;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC;QACrB,kBAAkB;QAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QAErB,oBAAoB;QACpB,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACpC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAElC,iBAAiB;QACjB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CA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tE;;;OAGG;IACH,MAAM,EAAE,WAAW,CAAC;QAClB,qBAAqB;QACrB,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;QAChC,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE;QAEjC,yBAAyB;QACzB,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAEtC,2CAA2C;QAC3C,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE;QAC5B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,aAAa;QAEvC,8BAA8B;QAC9B,eAAe,EAAE,CAAC,CAAC,QAAQ,CACzB,CAAC,CAAC,KAAK,CACL,CAAC,CAAC,MAAM,CAAC;YACP,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;YACpB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;SAC1B,CAAC,CACH,CACF;KACF,CAAC;CACH,CAAC,CAAC"}
@@ -0,0 +1,203 @@
1
+ import type { Infer } from "convex/values";
2
+ /**
3
+ * Severity levels for audit events.
4
+ */
5
+ export declare const vSeverity: import("convex/values").VUnion<"info" | "warning" | "error" | "critical", [import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warning", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"critical", "required">], "required", never>;
6
+ /**
7
+ * Base audit event validator (without timestamp - added automatically).
8
+ */
9
+ export declare const vAuditEventInput: import("convex/values").VObject<{
10
+ actorId?: string | undefined;
11
+ resourceType?: string | undefined;
12
+ resourceId?: string | undefined;
13
+ metadata?: any;
14
+ ipAddress?: string | undefined;
15
+ userAgent?: string | undefined;
16
+ sessionId?: string | undefined;
17
+ tags?: string[] | undefined;
18
+ retentionCategory?: string | undefined;
19
+ action: string;
20
+ severity: "info" | "warning" | "error" | "critical";
21
+ }, {
22
+ action: import("convex/values").VString<string, "required">;
23
+ actorId: import("convex/values").VString<string | undefined, "optional">;
24
+ resourceType: import("convex/values").VString<string | undefined, "optional">;
25
+ resourceId: import("convex/values").VString<string | undefined, "optional">;
26
+ metadata: import("convex/values").VAny<any, "optional", string>;
27
+ severity: import("convex/values").VUnion<"info" | "warning" | "error" | "critical", [import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warning", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"critical", "required">], "required", never>;
28
+ ipAddress: import("convex/values").VString<string | undefined, "optional">;
29
+ userAgent: import("convex/values").VString<string | undefined, "optional">;
30
+ sessionId: import("convex/values").VString<string | undefined, "optional">;
31
+ tags: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
32
+ retentionCategory: import("convex/values").VString<string | undefined, "optional">;
33
+ }, "required", "action" | "actorId" | "resourceType" | "resourceId" | "metadata" | "severity" | "ipAddress" | "userAgent" | "sessionId" | "tags" | "retentionCategory" | `metadata.${string}`>;
34
+ /**
35
+ * Change tracking event validator.
36
+ */
37
+ export declare const vChangeEventInput: import("convex/values").VObject<{
38
+ actorId?: string | undefined;
39
+ severity?: "info" | "warning" | "error" | "critical" | undefined;
40
+ ipAddress?: string | undefined;
41
+ userAgent?: string | undefined;
42
+ sessionId?: string | undefined;
43
+ tags?: string[] | undefined;
44
+ retentionCategory?: string | undefined;
45
+ before?: any;
46
+ after?: any;
47
+ generateDiff?: boolean | undefined;
48
+ action: string;
49
+ resourceType: string;
50
+ resourceId: string;
51
+ }, {
52
+ action: import("convex/values").VString<string, "required">;
53
+ actorId: import("convex/values").VString<string | undefined, "optional">;
54
+ resourceType: import("convex/values").VString<string, "required">;
55
+ resourceId: import("convex/values").VString<string, "required">;
56
+ before: import("convex/values").VAny<any, "optional", string>;
57
+ after: import("convex/values").VAny<any, "optional", string>;
58
+ generateDiff: import("convex/values").VBoolean<boolean | undefined, "optional">;
59
+ severity: import("convex/values").VUnion<"info" | "warning" | "error" | "critical" | undefined, [import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warning", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"critical", "required">], "optional", never>;
60
+ ipAddress: import("convex/values").VString<string | undefined, "optional">;
61
+ userAgent: import("convex/values").VString<string | undefined, "optional">;
62
+ sessionId: import("convex/values").VString<string | undefined, "optional">;
63
+ tags: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
64
+ retentionCategory: import("convex/values").VString<string | undefined, "optional">;
65
+ }, "required", "action" | "actorId" | "resourceType" | "resourceId" | "severity" | "ipAddress" | "userAgent" | "sessionId" | "tags" | "retentionCategory" | "before" | "after" | "generateDiff" | `before.${string}` | `after.${string}`>;
66
+ /**
67
+ * Query filters validator.
68
+ */
69
+ export declare const vQueryFilters: import("convex/values").VObject<{
70
+ severity?: ("info" | "warning" | "error" | "critical")[] | undefined;
71
+ tags?: string[] | undefined;
72
+ actions?: string[] | undefined;
73
+ resourceTypes?: string[] | undefined;
74
+ actorIds?: string[] | undefined;
75
+ fromTimestamp?: number | undefined;
76
+ toTimestamp?: number | undefined;
77
+ }, {
78
+ severity: import("convex/values").VArray<("info" | "warning" | "error" | "critical")[] | undefined, import("convex/values").VUnion<"info" | "warning" | "error" | "critical", [import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warning", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"critical", "required">], "required", never>, "optional">;
79
+ actions: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
80
+ resourceTypes: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
81
+ actorIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
82
+ fromTimestamp: import("convex/values").VFloat64<number | undefined, "optional">;
83
+ toTimestamp: import("convex/values").VFloat64<number | undefined, "optional">;
84
+ tags: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
85
+ }, "required", "severity" | "tags" | "actions" | "resourceTypes" | "actorIds" | "fromTimestamp" | "toTimestamp">;
86
+ /**
87
+ * Pagination validator.
88
+ */
89
+ export declare const vPagination: import("convex/values").VObject<{
90
+ cursor?: string | undefined;
91
+ limit: number;
92
+ }, {
93
+ cursor: import("convex/values").VString<string | undefined, "optional">;
94
+ limit: import("convex/values").VFloat64<number, "required">;
95
+ }, "required", "cursor" | "limit">;
96
+ /**
97
+ * Report format validator.
98
+ */
99
+ export declare const vReportFormat: import("convex/values").VUnion<"json" | "csv", [import("convex/values").VLiteral<"json", "required">, import("convex/values").VLiteral<"csv", "required">], "required", never>;
100
+ /**
101
+ * Anomaly pattern validator.
102
+ */
103
+ export declare const vAnomalyPattern: import("convex/values").VObject<{
104
+ action: string;
105
+ threshold: number;
106
+ windowMinutes: number;
107
+ }, {
108
+ action: import("convex/values").VString<string, "required">;
109
+ threshold: import("convex/values").VFloat64<number, "required">;
110
+ windowMinutes: import("convex/values").VFloat64<number, "required">;
111
+ }, "required", "action" | "threshold" | "windowMinutes">;
112
+ /**
113
+ * Cleanup options validator.
114
+ */
115
+ export declare const vCleanupOptions: import("convex/values").VObject<{
116
+ retentionCategory?: string | undefined;
117
+ olderThanDays?: number | undefined;
118
+ preserveSeverity?: ("info" | "warning" | "error" | "critical")[] | undefined;
119
+ batchSize?: number | undefined;
120
+ }, {
121
+ olderThanDays: import("convex/values").VFloat64<number | undefined, "optional">;
122
+ preserveSeverity: import("convex/values").VArray<("info" | "warning" | "error" | "critical")[] | undefined, import("convex/values").VUnion<"info" | "warning" | "error" | "critical", [import("convex/values").VLiteral<"info", "required">, import("convex/values").VLiteral<"warning", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"critical", "required">], "required", never>, "optional">;
123
+ retentionCategory: import("convex/values").VString<string | undefined, "optional">;
124
+ batchSize: import("convex/values").VFloat64<number | undefined, "optional">;
125
+ }, "required", "retentionCategory" | "olderThanDays" | "preserveSeverity" | "batchSize">;
126
+ /**
127
+ * Configuration options validator.
128
+ */
129
+ export declare const vConfigOptions: import("convex/values").VObject<{
130
+ defaultRetentionDays?: number | undefined;
131
+ criticalRetentionDays?: number | undefined;
132
+ piiFieldsToRedact?: string[] | undefined;
133
+ samplingEnabled?: boolean | undefined;
134
+ samplingRate?: number | undefined;
135
+ customRetention?: {
136
+ category: string;
137
+ retentionDays: number;
138
+ }[] | undefined;
139
+ }, {
140
+ defaultRetentionDays: import("convex/values").VFloat64<number | undefined, "optional">;
141
+ criticalRetentionDays: import("convex/values").VFloat64<number | undefined, "optional">;
142
+ piiFieldsToRedact: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
143
+ samplingEnabled: import("convex/values").VBoolean<boolean | undefined, "optional">;
144
+ samplingRate: import("convex/values").VFloat64<number | undefined, "optional">;
145
+ customRetention: import("convex/values").VArray<{
146
+ category: string;
147
+ retentionDays: number;
148
+ }[] | undefined, import("convex/values").VObject<{
149
+ category: string;
150
+ retentionDays: number;
151
+ }, {
152
+ category: import("convex/values").VString<string, "required">;
153
+ retentionDays: import("convex/values").VFloat64<number, "required">;
154
+ }, "required", "category" | "retentionDays">, "optional">;
155
+ }, "required", "defaultRetentionDays" | "criticalRetentionDays" | "piiFieldsToRedact" | "samplingEnabled" | "samplingRate" | "customRetention">;
156
+ export type Severity = Infer<typeof vSeverity>;
157
+ export type AuditEventInput = Infer<typeof vAuditEventInput>;
158
+ export type ChangeEventInput = Infer<typeof vChangeEventInput>;
159
+ export type QueryFilters = Infer<typeof vQueryFilters>;
160
+ export type Pagination = Infer<typeof vPagination>;
161
+ export type ReportFormat = Infer<typeof vReportFormat>;
162
+ export type AnomalyPattern = Infer<typeof vAnomalyPattern>;
163
+ export type CleanupOptions = Infer<typeof vCleanupOptions>;
164
+ export type ConfigOptions = Infer<typeof vConfigOptions>;
165
+ /**
166
+ * Full audit event with generated fields.
167
+ */
168
+ export type AuditEvent = AuditEventInput & {
169
+ _id: string;
170
+ _creationTime: number;
171
+ timestamp: number;
172
+ before?: unknown;
173
+ after?: unknown;
174
+ diff?: string;
175
+ };
176
+ /**
177
+ * Paginated result type.
178
+ */
179
+ export type PaginatedResult<T> = {
180
+ items: T[];
181
+ cursor: string | null;
182
+ hasMore: boolean;
183
+ };
184
+ /**
185
+ * Anomaly detection result.
186
+ */
187
+ export type Anomaly = {
188
+ action: string;
189
+ count: number;
190
+ threshold: number;
191
+ windowMinutes: number;
192
+ detectedAt: number;
193
+ };
194
+ /**
195
+ * Report result type.
196
+ */
197
+ export type Report = {
198
+ format: ReportFormat;
199
+ data: string;
200
+ generatedAt: number;
201
+ recordCount: number;
202
+ };
203
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/component/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,SAAS,gUAKrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;8LAY3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;yOAc5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;gHAQxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;kCAGtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,gLAGzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;wDAI1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;wFAK1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;+IAczB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAC/C,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,gBAAgB,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,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { v } from "convex/values";
2
+ /**
3
+ * Severity levels for audit events.
4
+ */
5
+ export const vSeverity = v.union(v.literal("info"), v.literal("warning"), v.literal("error"), v.literal("critical"));
6
+ /**
7
+ * Base audit event validator (without timestamp - added automatically).
8
+ */
9
+ export const vAuditEventInput = v.object({
10
+ action: v.string(),
11
+ actorId: v.optional(v.string()),
12
+ resourceType: v.optional(v.string()),
13
+ resourceId: v.optional(v.string()),
14
+ metadata: v.optional(v.any()),
15
+ severity: vSeverity,
16
+ ipAddress: v.optional(v.string()),
17
+ userAgent: v.optional(v.string()),
18
+ sessionId: v.optional(v.string()),
19
+ tags: v.optional(v.array(v.string())),
20
+ retentionCategory: v.optional(v.string()),
21
+ });
22
+ /**
23
+ * Change tracking event validator.
24
+ */
25
+ export const vChangeEventInput = v.object({
26
+ action: v.string(),
27
+ actorId: v.optional(v.string()),
28
+ resourceType: v.string(),
29
+ resourceId: v.string(),
30
+ before: v.optional(v.any()),
31
+ after: v.optional(v.any()),
32
+ generateDiff: v.optional(v.boolean()),
33
+ severity: v.optional(vSeverity),
34
+ ipAddress: v.optional(v.string()),
35
+ userAgent: v.optional(v.string()),
36
+ sessionId: v.optional(v.string()),
37
+ tags: v.optional(v.array(v.string())),
38
+ retentionCategory: v.optional(v.string()),
39
+ });
40
+ /**
41
+ * Query filters validator.
42
+ */
43
+ export const vQueryFilters = v.object({
44
+ severity: v.optional(v.array(vSeverity)),
45
+ actions: v.optional(v.array(v.string())),
46
+ resourceTypes: v.optional(v.array(v.string())),
47
+ actorIds: v.optional(v.array(v.string())),
48
+ fromTimestamp: v.optional(v.number()),
49
+ toTimestamp: v.optional(v.number()),
50
+ tags: v.optional(v.array(v.string())),
51
+ });
52
+ /**
53
+ * Pagination validator.
54
+ */
55
+ export const vPagination = v.object({
56
+ cursor: v.optional(v.string()),
57
+ limit: v.number(),
58
+ });
59
+ /**
60
+ * Report format validator.
61
+ */
62
+ export const vReportFormat = v.union(v.literal("json"), v.literal("csv"));
63
+ /**
64
+ * Anomaly pattern validator.
65
+ */
66
+ export const vAnomalyPattern = v.object({
67
+ action: v.string(),
68
+ threshold: v.number(),
69
+ windowMinutes: v.number(),
70
+ });
71
+ /**
72
+ * Cleanup options validator.
73
+ */
74
+ export const vCleanupOptions = v.object({
75
+ olderThanDays: v.optional(v.number()),
76
+ preserveSeverity: v.optional(v.array(vSeverity)),
77
+ retentionCategory: v.optional(v.string()),
78
+ batchSize: v.optional(v.number()),
79
+ });
80
+ /**
81
+ * Configuration options validator.
82
+ */
83
+ export const vConfigOptions = v.object({
84
+ defaultRetentionDays: v.optional(v.number()),
85
+ criticalRetentionDays: v.optional(v.number()),
86
+ piiFieldsToRedact: v.optional(v.array(v.string())),
87
+ samplingEnabled: v.optional(v.boolean()),
88
+ samplingRate: v.optional(v.number()),
89
+ customRetention: v.optional(v.array(v.object({
90
+ category: v.string(),
91
+ retentionDays: v.number(),
92
+ }))),
93
+ });
94
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/component/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAGlC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAC9B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EACjB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAClB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC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