@contractspec/module.audit-trail 1.44.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.
- package/LICENSE +21 -0
- package/README.md +113 -0
- package/dist/audit-trail.feature.d.ts +12 -0
- package/dist/audit-trail.feature.d.ts.map +1 -0
- package/dist/audit-trail.feature.js +59 -0
- package/dist/audit-trail.feature.js.map +1 -0
- package/dist/contracts/index.d.ts +583 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +370 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/entities/index.d.ts +91 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +126 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/storage/index.d.ts +88 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +112 -0
- package/dist/storage/index.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { ScalarTypeEnum, defineEnum } from "@contractspec/lib.schema";
|
|
2
|
+
import { defineCommand, defineQuery, defineSchemaModel } from "@contractspec/lib.contracts";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/index.ts
|
|
5
|
+
const OWNERS = ["platform.audit-trail"];
|
|
6
|
+
const AuditLogModel = defineSchemaModel({
|
|
7
|
+
name: "AuditLog",
|
|
8
|
+
description: "Detailed audit log entry",
|
|
9
|
+
fields: {
|
|
10
|
+
id: {
|
|
11
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
12
|
+
isOptional: false
|
|
13
|
+
},
|
|
14
|
+
eventName: {
|
|
15
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
+
isOptional: false
|
|
17
|
+
},
|
|
18
|
+
eventVersion: {
|
|
19
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
20
|
+
isOptional: false
|
|
21
|
+
},
|
|
22
|
+
payload: {
|
|
23
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
24
|
+
isOptional: false
|
|
25
|
+
},
|
|
26
|
+
actorId: {
|
|
27
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
28
|
+
isOptional: true
|
|
29
|
+
},
|
|
30
|
+
actorType: {
|
|
31
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
32
|
+
isOptional: true
|
|
33
|
+
},
|
|
34
|
+
actorEmail: {
|
|
35
|
+
type: ScalarTypeEnum.EmailAddress(),
|
|
36
|
+
isOptional: true
|
|
37
|
+
},
|
|
38
|
+
targetId: {
|
|
39
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
40
|
+
isOptional: true
|
|
41
|
+
},
|
|
42
|
+
targetType: {
|
|
43
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
44
|
+
isOptional: true
|
|
45
|
+
},
|
|
46
|
+
orgId: {
|
|
47
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
48
|
+
isOptional: true
|
|
49
|
+
},
|
|
50
|
+
traceId: {
|
|
51
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
52
|
+
isOptional: true
|
|
53
|
+
},
|
|
54
|
+
clientIp: {
|
|
55
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
56
|
+
isOptional: true
|
|
57
|
+
},
|
|
58
|
+
occurredAt: {
|
|
59
|
+
type: ScalarTypeEnum.DateTime(),
|
|
60
|
+
isOptional: false
|
|
61
|
+
},
|
|
62
|
+
recordedAt: {
|
|
63
|
+
type: ScalarTypeEnum.DateTime(),
|
|
64
|
+
isOptional: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const AuditQueryInputModel = defineSchemaModel({
|
|
69
|
+
name: "AuditQueryInput",
|
|
70
|
+
description: "Input for querying audit logs",
|
|
71
|
+
fields: {
|
|
72
|
+
eventName: {
|
|
73
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
74
|
+
isOptional: true
|
|
75
|
+
},
|
|
76
|
+
actorId: {
|
|
77
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
78
|
+
isOptional: true
|
|
79
|
+
},
|
|
80
|
+
targetId: {
|
|
81
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
82
|
+
isOptional: true
|
|
83
|
+
},
|
|
84
|
+
targetType: {
|
|
85
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
86
|
+
isOptional: true
|
|
87
|
+
},
|
|
88
|
+
orgId: {
|
|
89
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
90
|
+
isOptional: true
|
|
91
|
+
},
|
|
92
|
+
traceId: {
|
|
93
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
94
|
+
isOptional: true
|
|
95
|
+
},
|
|
96
|
+
from: {
|
|
97
|
+
type: ScalarTypeEnum.DateTime(),
|
|
98
|
+
isOptional: true
|
|
99
|
+
},
|
|
100
|
+
to: {
|
|
101
|
+
type: ScalarTypeEnum.DateTime(),
|
|
102
|
+
isOptional: true
|
|
103
|
+
},
|
|
104
|
+
limit: {
|
|
105
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
106
|
+
isOptional: true,
|
|
107
|
+
defaultValue: 100
|
|
108
|
+
},
|
|
109
|
+
offset: {
|
|
110
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
111
|
+
isOptional: true,
|
|
112
|
+
defaultValue: 0
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const AuditQueryOutputModel = defineSchemaModel({
|
|
117
|
+
name: "AuditQueryOutput",
|
|
118
|
+
description: "Output from querying audit logs",
|
|
119
|
+
fields: {
|
|
120
|
+
logs: {
|
|
121
|
+
type: AuditLogModel,
|
|
122
|
+
isArray: true,
|
|
123
|
+
isOptional: false
|
|
124
|
+
},
|
|
125
|
+
total: {
|
|
126
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
127
|
+
isOptional: false
|
|
128
|
+
},
|
|
129
|
+
hasMore: {
|
|
130
|
+
type: ScalarTypeEnum.Boolean(),
|
|
131
|
+
isOptional: false
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const ExportFormatEnum = defineEnum("ExportFormat", [
|
|
136
|
+
"json",
|
|
137
|
+
"csv",
|
|
138
|
+
"parquet"
|
|
139
|
+
]);
|
|
140
|
+
const AuditExportInputModel = defineSchemaModel({
|
|
141
|
+
name: "AuditExportInput",
|
|
142
|
+
description: "Input for exporting audit logs",
|
|
143
|
+
fields: {
|
|
144
|
+
orgId: {
|
|
145
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
146
|
+
isOptional: false
|
|
147
|
+
},
|
|
148
|
+
from: {
|
|
149
|
+
type: ScalarTypeEnum.DateTime(),
|
|
150
|
+
isOptional: false
|
|
151
|
+
},
|
|
152
|
+
to: {
|
|
153
|
+
type: ScalarTypeEnum.DateTime(),
|
|
154
|
+
isOptional: false
|
|
155
|
+
},
|
|
156
|
+
format: {
|
|
157
|
+
type: ExportFormatEnum,
|
|
158
|
+
isOptional: true,
|
|
159
|
+
defaultValue: "json"
|
|
160
|
+
},
|
|
161
|
+
eventNames: {
|
|
162
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
163
|
+
isArray: true,
|
|
164
|
+
isOptional: true
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const ExportStatusEnum = defineEnum("ExportStatus", [
|
|
169
|
+
"pending",
|
|
170
|
+
"processing",
|
|
171
|
+
"completed",
|
|
172
|
+
"failed"
|
|
173
|
+
]);
|
|
174
|
+
const AuditExportOutputModel = defineSchemaModel({
|
|
175
|
+
name: "AuditExportOutput",
|
|
176
|
+
description: "Output from initiating an audit export",
|
|
177
|
+
fields: {
|
|
178
|
+
exportId: {
|
|
179
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
180
|
+
isOptional: false
|
|
181
|
+
},
|
|
182
|
+
status: {
|
|
183
|
+
type: ExportStatusEnum,
|
|
184
|
+
isOptional: false
|
|
185
|
+
},
|
|
186
|
+
downloadUrl: {
|
|
187
|
+
type: ScalarTypeEnum.URL(),
|
|
188
|
+
isOptional: true
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
const AuditStatsInputModel = defineSchemaModel({
|
|
193
|
+
name: "AuditStatsInput",
|
|
194
|
+
description: "Input for getting audit statistics",
|
|
195
|
+
fields: {
|
|
196
|
+
orgId: {
|
|
197
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
198
|
+
isOptional: true
|
|
199
|
+
},
|
|
200
|
+
from: {
|
|
201
|
+
type: ScalarTypeEnum.DateTime(),
|
|
202
|
+
isOptional: true
|
|
203
|
+
},
|
|
204
|
+
to: {
|
|
205
|
+
type: ScalarTypeEnum.DateTime(),
|
|
206
|
+
isOptional: true
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
const AuditStatsOutputModel = defineSchemaModel({
|
|
211
|
+
name: "AuditStatsOutput",
|
|
212
|
+
description: "Audit log statistics",
|
|
213
|
+
fields: {
|
|
214
|
+
totalLogs: {
|
|
215
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
216
|
+
isOptional: false
|
|
217
|
+
},
|
|
218
|
+
uniqueActors: {
|
|
219
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
220
|
+
isOptional: false
|
|
221
|
+
},
|
|
222
|
+
uniqueTargets: {
|
|
223
|
+
type: ScalarTypeEnum.Int_unsecure(),
|
|
224
|
+
isOptional: false
|
|
225
|
+
},
|
|
226
|
+
eventCounts: {
|
|
227
|
+
type: ScalarTypeEnum.JSONObject(),
|
|
228
|
+
isOptional: false
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
/**
|
|
233
|
+
* Query audit logs.
|
|
234
|
+
*/
|
|
235
|
+
const QueryAuditLogsContract = defineQuery({
|
|
236
|
+
meta: {
|
|
237
|
+
key: "audit.logs.query",
|
|
238
|
+
version: 1,
|
|
239
|
+
stability: "stable",
|
|
240
|
+
owners: [...OWNERS],
|
|
241
|
+
tags: [
|
|
242
|
+
"audit",
|
|
243
|
+
"logs",
|
|
244
|
+
"query"
|
|
245
|
+
],
|
|
246
|
+
description: "Query audit logs with filters.",
|
|
247
|
+
goal: "Enable searching and filtering of audit history.",
|
|
248
|
+
context: "Admin dashboard, compliance reporting, debugging."
|
|
249
|
+
},
|
|
250
|
+
io: {
|
|
251
|
+
input: AuditQueryInputModel,
|
|
252
|
+
output: AuditQueryOutputModel
|
|
253
|
+
},
|
|
254
|
+
policy: { auth: "admin" }
|
|
255
|
+
});
|
|
256
|
+
/**
|
|
257
|
+
* Get audit log by ID.
|
|
258
|
+
*/
|
|
259
|
+
const GetAuditLogContract = defineQuery({
|
|
260
|
+
meta: {
|
|
261
|
+
key: "audit.logs.get",
|
|
262
|
+
version: 1,
|
|
263
|
+
stability: "stable",
|
|
264
|
+
owners: [...OWNERS],
|
|
265
|
+
tags: [
|
|
266
|
+
"audit",
|
|
267
|
+
"logs",
|
|
268
|
+
"get"
|
|
269
|
+
],
|
|
270
|
+
description: "Get a specific audit log by ID.",
|
|
271
|
+
goal: "View detailed audit log entry.",
|
|
272
|
+
context: "Log detail view."
|
|
273
|
+
},
|
|
274
|
+
io: {
|
|
275
|
+
input: defineSchemaModel({
|
|
276
|
+
name: "GetAuditLogInput",
|
|
277
|
+
fields: { logId: {
|
|
278
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
279
|
+
isOptional: false
|
|
280
|
+
} }
|
|
281
|
+
}),
|
|
282
|
+
output: AuditLogModel
|
|
283
|
+
},
|
|
284
|
+
policy: { auth: "admin" }
|
|
285
|
+
});
|
|
286
|
+
/**
|
|
287
|
+
* Get audit logs by trace ID.
|
|
288
|
+
*/
|
|
289
|
+
const GetAuditTraceContract = defineQuery({
|
|
290
|
+
meta: {
|
|
291
|
+
key: "audit.trace.get",
|
|
292
|
+
version: 1,
|
|
293
|
+
stability: "stable",
|
|
294
|
+
owners: [...OWNERS],
|
|
295
|
+
tags: [
|
|
296
|
+
"audit",
|
|
297
|
+
"trace",
|
|
298
|
+
"get"
|
|
299
|
+
],
|
|
300
|
+
description: "Get all audit logs for a trace.",
|
|
301
|
+
goal: "View complete request trace for debugging.",
|
|
302
|
+
context: "Request tracing, debugging."
|
|
303
|
+
},
|
|
304
|
+
io: {
|
|
305
|
+
input: defineSchemaModel({
|
|
306
|
+
name: "GetAuditTraceInput",
|
|
307
|
+
fields: { traceId: {
|
|
308
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
309
|
+
isOptional: false
|
|
310
|
+
} }
|
|
311
|
+
}),
|
|
312
|
+
output: defineSchemaModel({
|
|
313
|
+
name: "GetAuditTraceOutput",
|
|
314
|
+
fields: { logs: {
|
|
315
|
+
type: AuditLogModel,
|
|
316
|
+
isArray: true,
|
|
317
|
+
isOptional: false
|
|
318
|
+
} }
|
|
319
|
+
})
|
|
320
|
+
},
|
|
321
|
+
policy: { auth: "admin" }
|
|
322
|
+
});
|
|
323
|
+
/**
|
|
324
|
+
* Export audit logs.
|
|
325
|
+
*/
|
|
326
|
+
const ExportAuditLogsContract = defineCommand({
|
|
327
|
+
meta: {
|
|
328
|
+
key: "audit.logs.export",
|
|
329
|
+
version: 1,
|
|
330
|
+
stability: "stable",
|
|
331
|
+
owners: [...OWNERS],
|
|
332
|
+
tags: [
|
|
333
|
+
"audit",
|
|
334
|
+
"logs",
|
|
335
|
+
"export"
|
|
336
|
+
],
|
|
337
|
+
description: "Export audit logs for compliance reporting.",
|
|
338
|
+
goal: "Generate audit reports for compliance.",
|
|
339
|
+
context: "Compliance reporting, external audits."
|
|
340
|
+
},
|
|
341
|
+
io: {
|
|
342
|
+
input: AuditExportInputModel,
|
|
343
|
+
output: AuditExportOutputModel
|
|
344
|
+
},
|
|
345
|
+
policy: { auth: "admin" }
|
|
346
|
+
});
|
|
347
|
+
/**
|
|
348
|
+
* Get audit statistics.
|
|
349
|
+
*/
|
|
350
|
+
const GetAuditStatsContract = defineQuery({
|
|
351
|
+
meta: {
|
|
352
|
+
key: "audit.stats",
|
|
353
|
+
version: 1,
|
|
354
|
+
stability: "stable",
|
|
355
|
+
owners: [...OWNERS],
|
|
356
|
+
tags: ["audit", "stats"],
|
|
357
|
+
description: "Get audit log statistics.",
|
|
358
|
+
goal: "Monitor audit activity levels.",
|
|
359
|
+
context: "Admin dashboard, monitoring."
|
|
360
|
+
},
|
|
361
|
+
io: {
|
|
362
|
+
input: AuditStatsInputModel,
|
|
363
|
+
output: AuditStatsOutputModel
|
|
364
|
+
},
|
|
365
|
+
policy: { auth: "admin" }
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
//#endregion
|
|
369
|
+
export { AuditExportInputModel, AuditExportOutputModel, AuditLogModel, AuditQueryInputModel, AuditQueryOutputModel, AuditStatsInputModel, AuditStatsOutputModel, ExportAuditLogsContract, ExportFormatEnum, ExportStatusEnum, GetAuditLogContract, GetAuditStatsContract, GetAuditTraceContract, QueryAuditLogsContract };
|
|
370
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/contracts/index.ts"],"sourcesContent":["import {\n defineCommand,\n defineQuery,\n defineSchemaModel,\n} from '@contractspec/lib.contracts';\nimport { ScalarTypeEnum, defineEnum } from '@contractspec/lib.schema';\n\nconst OWNERS = ['platform.audit-trail'] as const;\n\n// ============ Schemas ============\n\nexport const AuditLogModel = defineSchemaModel({\n name: 'AuditLog',\n description: 'Detailed audit log entry',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n eventName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n eventVersion: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n payload: { type: ScalarTypeEnum.JSONObject(), isOptional: false },\n actorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n actorType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n actorEmail: { type: ScalarTypeEnum.EmailAddress(), isOptional: true },\n targetId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n targetType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n clientIp: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n occurredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n recordedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nexport const AuditQueryInputModel = defineSchemaModel({\n name: 'AuditQueryInput',\n description: 'Input for querying audit logs',\n fields: {\n eventName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n actorId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n targetId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n targetType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n from: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n to: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n limit: {\n type: ScalarTypeEnum.Int_unsecure(),\n isOptional: true,\n defaultValue: 100,\n },\n offset: {\n type: ScalarTypeEnum.Int_unsecure(),\n isOptional: true,\n defaultValue: 0,\n },\n },\n});\n\nexport const AuditQueryOutputModel = defineSchemaModel({\n name: 'AuditQueryOutput',\n description: 'Output from querying audit logs',\n fields: {\n logs: { type: AuditLogModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n hasMore: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n },\n});\n\nexport const ExportFormatEnum = defineEnum('ExportFormat', [\n 'json',\n 'csv',\n 'parquet',\n]);\n\nexport const AuditExportInputModel = defineSchemaModel({\n name: 'AuditExportInput',\n description: 'Input for exporting audit logs',\n fields: {\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n from: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n to: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n format: { type: ExportFormatEnum, isOptional: true, defaultValue: 'json' },\n eventNames: {\n type: ScalarTypeEnum.String_unsecure(),\n isArray: true,\n isOptional: true,\n },\n },\n});\n\nexport const ExportStatusEnum = defineEnum('ExportStatus', [\n 'pending',\n 'processing',\n 'completed',\n 'failed',\n]);\n\nexport const AuditExportOutputModel = defineSchemaModel({\n name: 'AuditExportOutput',\n description: 'Output from initiating an audit export',\n fields: {\n exportId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n status: { type: ExportStatusEnum, isOptional: false },\n downloadUrl: { type: ScalarTypeEnum.URL(), isOptional: true },\n },\n});\n\nexport const AuditStatsInputModel = defineSchemaModel({\n name: 'AuditStatsInput',\n description: 'Input for getting audit statistics',\n fields: {\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n from: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n to: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n },\n});\n\nexport const AuditStatsOutputModel = defineSchemaModel({\n name: 'AuditStatsOutput',\n description: 'Audit log statistics',\n fields: {\n totalLogs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n uniqueActors: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n uniqueTargets: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n eventCounts: { type: ScalarTypeEnum.JSONObject(), isOptional: false },\n },\n});\n\n// ============ Contracts ============\n\n/**\n * Query audit logs.\n */\nexport const QueryAuditLogsContract = defineQuery({\n meta: {\n key: 'audit.logs.query',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['audit', 'logs', 'query'],\n description: 'Query audit logs with filters.',\n goal: 'Enable searching and filtering of audit history.',\n context: 'Admin dashboard, compliance reporting, debugging.',\n },\n io: {\n input: AuditQueryInputModel,\n output: AuditQueryOutputModel,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Get audit log by ID.\n */\nexport const GetAuditLogContract = defineQuery({\n meta: {\n key: 'audit.logs.get',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['audit', 'logs', 'get'],\n description: 'Get a specific audit log by ID.',\n goal: 'View detailed audit log entry.',\n context: 'Log detail view.',\n },\n io: {\n input: defineSchemaModel({\n name: 'GetAuditLogInput',\n fields: {\n logId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n }),\n output: AuditLogModel,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Get audit logs by trace ID.\n */\nexport const GetAuditTraceContract = defineQuery({\n meta: {\n key: 'audit.trace.get',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['audit', 'trace', 'get'],\n description: 'Get all audit logs for a trace.',\n goal: 'View complete request trace for debugging.',\n context: 'Request tracing, debugging.',\n },\n io: {\n input: defineSchemaModel({\n name: 'GetAuditTraceInput',\n fields: {\n traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n }),\n output: defineSchemaModel({\n name: 'GetAuditTraceOutput',\n fields: {\n logs: { type: AuditLogModel, isArray: true, isOptional: false },\n },\n }),\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Export audit logs.\n */\nexport const ExportAuditLogsContract = defineCommand({\n meta: {\n key: 'audit.logs.export',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['audit', 'logs', 'export'],\n description: 'Export audit logs for compliance reporting.',\n goal: 'Generate audit reports for compliance.',\n context: 'Compliance reporting, external audits.',\n },\n io: {\n input: AuditExportInputModel,\n output: AuditExportOutputModel,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Get audit statistics.\n */\nexport const GetAuditStatsContract = defineQuery({\n meta: {\n key: 'audit.stats',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['audit', 'stats'],\n description: 'Get audit log statistics.',\n goal: 'Monitor audit activity levels.',\n context: 'Admin dashboard, monitoring.',\n },\n io: {\n input: AuditStatsInputModel,\n output: AuditStatsOutputModel,\n },\n policy: {\n auth: 'admin',\n },\n});\n"],"mappings":";;;;AAOA,MAAM,SAAS,CAAC,uBAAuB;AAIvC,MAAa,gBAAgB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACjE,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE,cAAc;GAAE,MAAM,eAAe,cAAc;GAAE,YAAY;GAAO;EACxE,SAAS;GAAE,MAAM,eAAe,YAAY;GAAE,YAAY;GAAO;EACjE,SAAS;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACrE,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACvE,YAAY;GAAE,MAAM,eAAe,cAAc;GAAE,YAAY;GAAM;EACrE,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACtE,YAAY;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACxE,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACnE,SAAS;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACrE,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACtE,YAAY;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EAClE,YAAY;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EACnE;CACF,CAAC;AAEF,MAAa,uBAAuB,kBAAkB;CACpD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACvE,SAAS;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACrE,UAAU;GAAE,MA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GACN,QAAQ,EACN,OAAO;IAAE,MAAM,eAAe,iBAAiB;IAAE,YAAY;IAAO,EACrE;GACF,CAAC;EACF,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC;;;;AAKF,MAAa,wBAAwB,YAAY;CAC/C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAS;GAAS;GAAM;EAC/B,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO,kBAAkB;GACvB,MAAM;GACN,QAAQ,EACN,SAAS;IAAE,MAAM,eAAe,iBAAiB;IAAE,YAAY;IAAO,EACvE;GACF,CAAC;EACF,QAAQ,kBAAkB;GACxB,MAAM;GACN,QAAQ,EACN,MAAM;IAAE,MAAM;IAAe,SAAS;IAAM,YAAY;IAAO,EAChE;GACF,CAAC;EACH;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC;;;;AAKF,MAAa,0BAA0B,cAAc;CACnD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAS;GAAQ;GAAS;EACjC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC;;;;AAKF,MAAa,wBAAwB,YAAY;CAC/C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM,CAAC,SAAS,QAAQ;EACxB,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as _contractspec_lib_schema147 from "@contractspec/lib.schema";
|
|
2
|
+
import { ModuleSchemaContribution } from "@contractspec/lib.schema";
|
|
3
|
+
|
|
4
|
+
//#region src/entities/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* AuditLog entity - main audit log entry.
|
|
7
|
+
*/
|
|
8
|
+
declare const AuditLogEntity: _contractspec_lib_schema147.EntitySpec<{
|
|
9
|
+
id: _contractspec_lib_schema147.EntityScalarField;
|
|
10
|
+
eventName: _contractspec_lib_schema147.EntityScalarField;
|
|
11
|
+
eventVersion: _contractspec_lib_schema147.EntityScalarField;
|
|
12
|
+
payload: _contractspec_lib_schema147.EntityScalarField;
|
|
13
|
+
actorId: _contractspec_lib_schema147.EntityScalarField;
|
|
14
|
+
actorType: _contractspec_lib_schema147.EntityScalarField;
|
|
15
|
+
actorEmail: _contractspec_lib_schema147.EntityScalarField;
|
|
16
|
+
targetId: _contractspec_lib_schema147.EntityScalarField;
|
|
17
|
+
targetType: _contractspec_lib_schema147.EntityScalarField;
|
|
18
|
+
orgId: _contractspec_lib_schema147.EntityScalarField;
|
|
19
|
+
tenantId: _contractspec_lib_schema147.EntityScalarField;
|
|
20
|
+
traceId: _contractspec_lib_schema147.EntityScalarField;
|
|
21
|
+
spanId: _contractspec_lib_schema147.EntityScalarField;
|
|
22
|
+
requestId: _contractspec_lib_schema147.EntityScalarField;
|
|
23
|
+
sessionId: _contractspec_lib_schema147.EntityScalarField;
|
|
24
|
+
clientIp: _contractspec_lib_schema147.EntityScalarField;
|
|
25
|
+
userAgent: _contractspec_lib_schema147.EntityScalarField;
|
|
26
|
+
tags: _contractspec_lib_schema147.EntityScalarField;
|
|
27
|
+
metadata: _contractspec_lib_schema147.EntityScalarField;
|
|
28
|
+
occurredAt: _contractspec_lib_schema147.EntityScalarField;
|
|
29
|
+
recordedAt: _contractspec_lib_schema147.EntityScalarField;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* AuditLogArchive entity - archived logs for long-term retention.
|
|
33
|
+
*/
|
|
34
|
+
declare const AuditLogArchiveEntity: _contractspec_lib_schema147.EntitySpec<{
|
|
35
|
+
id: _contractspec_lib_schema147.EntityScalarField;
|
|
36
|
+
batchId: _contractspec_lib_schema147.EntityScalarField;
|
|
37
|
+
logCount: _contractspec_lib_schema147.EntityScalarField;
|
|
38
|
+
fromDate: _contractspec_lib_schema147.EntityScalarField;
|
|
39
|
+
toDate: _contractspec_lib_schema147.EntityScalarField;
|
|
40
|
+
storagePath: _contractspec_lib_schema147.EntityScalarField;
|
|
41
|
+
storageType: _contractspec_lib_schema147.EntityScalarField;
|
|
42
|
+
compressedSize: _contractspec_lib_schema147.EntityScalarField;
|
|
43
|
+
checksum: _contractspec_lib_schema147.EntityScalarField;
|
|
44
|
+
retainUntil: _contractspec_lib_schema147.EntityScalarField;
|
|
45
|
+
createdAt: _contractspec_lib_schema147.EntityScalarField;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* All audit trail entities for schema composition.
|
|
49
|
+
*/
|
|
50
|
+
declare const auditTrailEntities: (_contractspec_lib_schema147.EntitySpec<{
|
|
51
|
+
id: _contractspec_lib_schema147.EntityScalarField;
|
|
52
|
+
eventName: _contractspec_lib_schema147.EntityScalarField;
|
|
53
|
+
eventVersion: _contractspec_lib_schema147.EntityScalarField;
|
|
54
|
+
payload: _contractspec_lib_schema147.EntityScalarField;
|
|
55
|
+
actorId: _contractspec_lib_schema147.EntityScalarField;
|
|
56
|
+
actorType: _contractspec_lib_schema147.EntityScalarField;
|
|
57
|
+
actorEmail: _contractspec_lib_schema147.EntityScalarField;
|
|
58
|
+
targetId: _contractspec_lib_schema147.EntityScalarField;
|
|
59
|
+
targetType: _contractspec_lib_schema147.EntityScalarField;
|
|
60
|
+
orgId: _contractspec_lib_schema147.EntityScalarField;
|
|
61
|
+
tenantId: _contractspec_lib_schema147.EntityScalarField;
|
|
62
|
+
traceId: _contractspec_lib_schema147.EntityScalarField;
|
|
63
|
+
spanId: _contractspec_lib_schema147.EntityScalarField;
|
|
64
|
+
requestId: _contractspec_lib_schema147.EntityScalarField;
|
|
65
|
+
sessionId: _contractspec_lib_schema147.EntityScalarField;
|
|
66
|
+
clientIp: _contractspec_lib_schema147.EntityScalarField;
|
|
67
|
+
userAgent: _contractspec_lib_schema147.EntityScalarField;
|
|
68
|
+
tags: _contractspec_lib_schema147.EntityScalarField;
|
|
69
|
+
metadata: _contractspec_lib_schema147.EntityScalarField;
|
|
70
|
+
occurredAt: _contractspec_lib_schema147.EntityScalarField;
|
|
71
|
+
recordedAt: _contractspec_lib_schema147.EntityScalarField;
|
|
72
|
+
}> | _contractspec_lib_schema147.EntitySpec<{
|
|
73
|
+
id: _contractspec_lib_schema147.EntityScalarField;
|
|
74
|
+
batchId: _contractspec_lib_schema147.EntityScalarField;
|
|
75
|
+
logCount: _contractspec_lib_schema147.EntityScalarField;
|
|
76
|
+
fromDate: _contractspec_lib_schema147.EntityScalarField;
|
|
77
|
+
toDate: _contractspec_lib_schema147.EntityScalarField;
|
|
78
|
+
storagePath: _contractspec_lib_schema147.EntityScalarField;
|
|
79
|
+
storageType: _contractspec_lib_schema147.EntityScalarField;
|
|
80
|
+
compressedSize: _contractspec_lib_schema147.EntityScalarField;
|
|
81
|
+
checksum: _contractspec_lib_schema147.EntityScalarField;
|
|
82
|
+
retainUntil: _contractspec_lib_schema147.EntityScalarField;
|
|
83
|
+
createdAt: _contractspec_lib_schema147.EntityScalarField;
|
|
84
|
+
}>)[];
|
|
85
|
+
/**
|
|
86
|
+
* Module schema contribution for audit trail.
|
|
87
|
+
*/
|
|
88
|
+
declare const auditTrailSchemaContribution: ModuleSchemaContribution;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { AuditLogArchiveEntity, AuditLogEntity, auditTrailEntities, auditTrailSchemaContribution };
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/entities/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAMa,cAAA,cAqFX,8BArFyB,UAqFzB,CAAA;EAAA,EAAA,EAAA,2BAAA,CAAA,iBAAA;;;;;;;;;;;;;;;;;;;;;;;AAKF;;cAAa,mDAAqB;MA+BhC,2BAAA,CAAA;;;;;;;;;4DA/BgC;EAAA,SAAA,+CAAA;AAoClC,CAAA,CAAA;;;;cAAa,iDAAkB;MAA0C,2BAAA,CAAA;;;;;;;;;;;;;;;;;qDAA1C;EAAA,QAAA,+CAAA;;;;MAAA,2BAAA,CAAA;;;;;;;;;EAKlB,WAAA,+CAA8B;;;;;;cAA9B,8BAA8B"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { defineEntity, field, index } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* AuditLog entity - main audit log entry.
|
|
6
|
+
*/
|
|
7
|
+
const AuditLogEntity = defineEntity({
|
|
8
|
+
name: "AuditLog",
|
|
9
|
+
description: "Audit log entry for tracking system events.",
|
|
10
|
+
schema: "lssm_audit",
|
|
11
|
+
map: "audit_log",
|
|
12
|
+
fields: {
|
|
13
|
+
id: field.id({ description: "Unique audit log ID" }),
|
|
14
|
+
eventName: field.string({ description: "Event name/type" }),
|
|
15
|
+
eventVersion: field.int({ description: "Event version" }),
|
|
16
|
+
payload: field.json({ description: "Event payload (may be redacted)" }),
|
|
17
|
+
actorId: field.string({
|
|
18
|
+
isOptional: true,
|
|
19
|
+
description: "User/service that triggered the event"
|
|
20
|
+
}),
|
|
21
|
+
actorType: field.string({
|
|
22
|
+
isOptional: true,
|
|
23
|
+
description: "Actor type (user, system, service)"
|
|
24
|
+
}),
|
|
25
|
+
actorEmail: field.string({
|
|
26
|
+
isOptional: true,
|
|
27
|
+
description: "Actor email (for searchability)"
|
|
28
|
+
}),
|
|
29
|
+
targetId: field.string({
|
|
30
|
+
isOptional: true,
|
|
31
|
+
description: "Resource affected by the event"
|
|
32
|
+
}),
|
|
33
|
+
targetType: field.string({
|
|
34
|
+
isOptional: true,
|
|
35
|
+
description: "Resource type"
|
|
36
|
+
}),
|
|
37
|
+
orgId: field.string({
|
|
38
|
+
isOptional: true,
|
|
39
|
+
description: "Organization context"
|
|
40
|
+
}),
|
|
41
|
+
tenantId: field.string({
|
|
42
|
+
isOptional: true,
|
|
43
|
+
description: "Tenant context"
|
|
44
|
+
}),
|
|
45
|
+
traceId: field.string({
|
|
46
|
+
isOptional: true,
|
|
47
|
+
description: "Distributed trace ID"
|
|
48
|
+
}),
|
|
49
|
+
spanId: field.string({
|
|
50
|
+
isOptional: true,
|
|
51
|
+
description: "Span ID"
|
|
52
|
+
}),
|
|
53
|
+
requestId: field.string({
|
|
54
|
+
isOptional: true,
|
|
55
|
+
description: "Request ID"
|
|
56
|
+
}),
|
|
57
|
+
sessionId: field.string({
|
|
58
|
+
isOptional: true,
|
|
59
|
+
description: "Session ID"
|
|
60
|
+
}),
|
|
61
|
+
clientIp: field.string({
|
|
62
|
+
isOptional: true,
|
|
63
|
+
description: "Client IP address"
|
|
64
|
+
}),
|
|
65
|
+
userAgent: field.string({
|
|
66
|
+
isOptional: true,
|
|
67
|
+
description: "User agent string"
|
|
68
|
+
}),
|
|
69
|
+
tags: field.json({
|
|
70
|
+
isOptional: true,
|
|
71
|
+
description: "Custom tags for filtering"
|
|
72
|
+
}),
|
|
73
|
+
metadata: field.json({
|
|
74
|
+
isOptional: true,
|
|
75
|
+
description: "Additional metadata"
|
|
76
|
+
}),
|
|
77
|
+
occurredAt: field.dateTime({ description: "When the event occurred" }),
|
|
78
|
+
recordedAt: field.createdAt({ description: "When the log was recorded" })
|
|
79
|
+
},
|
|
80
|
+
indexes: [
|
|
81
|
+
index.on(["actorId", "occurredAt"]),
|
|
82
|
+
index.on(["targetId", "occurredAt"]),
|
|
83
|
+
index.on(["orgId", "occurredAt"]),
|
|
84
|
+
index.on(["eventName", "occurredAt"]),
|
|
85
|
+
index.on(["traceId"]),
|
|
86
|
+
index.on(["occurredAt"])
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* AuditLogArchive entity - archived logs for long-term retention.
|
|
91
|
+
*/
|
|
92
|
+
const AuditLogArchiveEntity = defineEntity({
|
|
93
|
+
name: "AuditLogArchive",
|
|
94
|
+
description: "Archived audit logs for long-term retention.",
|
|
95
|
+
schema: "lssm_audit",
|
|
96
|
+
map: "audit_log_archive",
|
|
97
|
+
fields: {
|
|
98
|
+
id: field.id(),
|
|
99
|
+
batchId: field.string({ description: "Archive batch ID" }),
|
|
100
|
+
logCount: field.int({ description: "Number of logs in batch" }),
|
|
101
|
+
fromDate: field.dateTime({ description: "Earliest log in batch" }),
|
|
102
|
+
toDate: field.dateTime({ description: "Latest log in batch" }),
|
|
103
|
+
storagePath: field.string({ description: "Path to archived data" }),
|
|
104
|
+
storageType: field.string({ description: "Storage type (s3, gcs, file)" }),
|
|
105
|
+
compressedSize: field.int({ description: "Compressed size in bytes" }),
|
|
106
|
+
checksum: field.string({ description: "SHA-256 checksum" }),
|
|
107
|
+
retainUntil: field.dateTime({ description: "When archive can be deleted" }),
|
|
108
|
+
createdAt: field.createdAt()
|
|
109
|
+
},
|
|
110
|
+
indexes: [index.on(["fromDate", "toDate"]), index.on(["retainUntil"])]
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* All audit trail entities for schema composition.
|
|
114
|
+
*/
|
|
115
|
+
const auditTrailEntities = [AuditLogEntity, AuditLogArchiveEntity];
|
|
116
|
+
/**
|
|
117
|
+
* Module schema contribution for audit trail.
|
|
118
|
+
*/
|
|
119
|
+
const auditTrailSchemaContribution = {
|
|
120
|
+
moduleId: "@contractspec/module.audit-trail",
|
|
121
|
+
entities: auditTrailEntities
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
export { AuditLogArchiveEntity, AuditLogEntity, auditTrailEntities, auditTrailSchemaContribution };
|
|
126
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["auditTrailSchemaContribution: ModuleSchemaContribution"],"sources":["../../src/entities/index.ts"],"sourcesContent":["import { defineEntity, field, index } from '@contractspec/lib.schema';\nimport type { ModuleSchemaContribution } from '@contractspec/lib.schema';\n\n/**\n * AuditLog entity - main audit log entry.\n */\nexport const AuditLogEntity = defineEntity({\n name: 'AuditLog',\n description: 'Audit log entry for tracking system events.',\n schema: 'lssm_audit',\n map: 'audit_log',\n fields: {\n id: field.id({ description: 'Unique audit log ID' }),\n\n // Event info\n eventName: field.string({ description: 'Event name/type' }),\n eventVersion: field.int({ description: 'Event version' }),\n payload: field.json({ description: 'Event payload (may be redacted)' }),\n\n // Actor info\n actorId: field.string({\n isOptional: true,\n description: 'User/service that triggered the event',\n }),\n actorType: field.string({\n isOptional: true,\n description: 'Actor type (user, system, service)',\n }),\n actorEmail: field.string({\n isOptional: true,\n description: 'Actor email (for searchability)',\n }),\n\n // Target info\n targetId: field.string({\n isOptional: true,\n description: 'Resource affected by the event',\n }),\n targetType: field.string({\n isOptional: true,\n description: 'Resource type',\n }),\n\n // Context\n orgId: field.string({\n isOptional: true,\n description: 'Organization context',\n }),\n tenantId: field.string({ isOptional: true, description: 'Tenant context' }),\n\n // Tracing\n traceId: field.string({\n isOptional: true,\n description: 'Distributed trace ID',\n }),\n spanId: field.string({ isOptional: true, description: 'Span ID' }),\n requestId: field.string({ isOptional: true, description: 'Request ID' }),\n sessionId: field.string({ isOptional: true, description: 'Session ID' }),\n\n // Client info\n clientIp: field.string({\n isOptional: true,\n description: 'Client IP address',\n }),\n userAgent: field.string({\n isOptional: true,\n description: 'User agent string',\n }),\n\n // Metadata\n tags: field.json({\n isOptional: true,\n description: 'Custom tags for filtering',\n }),\n metadata: field.json({\n isOptional: true,\n description: 'Additional metadata',\n }),\n\n // Timestamps\n occurredAt: field.dateTime({ description: 'When the event occurred' }),\n recordedAt: field.createdAt({ description: 'When the log was recorded' }),\n },\n indexes: [\n index.on(['actorId', 'occurredAt']),\n index.on(['targetId', 'occurredAt']),\n index.on(['orgId', 'occurredAt']),\n index.on(['eventName', 'occurredAt']),\n index.on(['traceId']),\n index.on(['occurredAt']),\n ],\n});\n\n/**\n * AuditLogArchive entity - archived logs for long-term retention.\n */\nexport const AuditLogArchiveEntity = defineEntity({\n name: 'AuditLogArchive',\n description: 'Archived audit logs for long-term retention.',\n schema: 'lssm_audit',\n map: 'audit_log_archive',\n fields: {\n id: field.id(),\n\n // Batch info\n batchId: field.string({ description: 'Archive batch ID' }),\n logCount: field.int({ description: 'Number of logs in batch' }),\n\n // Time range\n fromDate: field.dateTime({ description: 'Earliest log in batch' }),\n toDate: field.dateTime({ description: 'Latest log in batch' }),\n\n // Storage\n storagePath: field.string({ description: 'Path to archived data' }),\n storageType: field.string({ description: 'Storage type (s3, gcs, file)' }),\n compressedSize: field.int({ description: 'Compressed size in bytes' }),\n\n // Integrity\n checksum: field.string({ description: 'SHA-256 checksum' }),\n\n // Retention\n retainUntil: field.dateTime({ description: 'When archive can be deleted' }),\n\n // Timestamps\n createdAt: field.createdAt(),\n },\n indexes: [index.on(['fromDate', 'toDate']), index.on(['retainUntil'])],\n});\n\n/**\n * All audit trail entities for schema composition.\n */\nexport const auditTrailEntities = [AuditLogEntity, AuditLogArchiveEntity];\n\n/**\n * Module schema contribution for audit trail.\n */\nexport const auditTrailSchemaContribution: ModuleSchemaContribution = {\n moduleId: '@contractspec/module.audit-trail',\n entities: auditTrailEntities,\n};\n"],"mappings":";;;;;;AAMA,MAAa,iBAAiB,aAAa;CACzC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,IAAI,MAAM,GAAG,EAAE,aAAa,uBAAuB,CAAC;EAGpD,WAAW,MAAM,OAAO,EAAE,aAAa,mBAAmB,CAAC;EAC3D,cAAc,MAAM,IAAI,EAAE,aAAa,iBAAiB,CAAC;EACzD,SAAS,MAAM,KAAK,EAAE,aAAa,mCAAmC,CAAC;EAGvE,SAAS,MAAM,OAAO;GACpB,YAAY;GACZ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Aa,wBAAwB,aAAa;CAChD,MAAM;CACN,aAAa;CACb,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,IAAI,MAAM,IAAI;EAGd,SAAS,MAAM,OAAO,EAAE,aAAa,oBAAoB,CAAC;EAC1D,UAAU,MAAM,IAAI,EAAE,aAAa,2BAA2B,CAAC;EAG/D,UAAU,MAAM,SAAS,EAAE,aAAa,yBAAyB,CAAC;EAClE,QAAQ,MAAM,SAAS,EAAE,aAAa,uBAAuB,CAAC;EAG9D,aAAa,MAAM,OAAO,EAAE,aAAa,yBAAyB,CAAC;EACnE,aAAa,MAAM,OAAO,EAAE,aAAa,gCAAgC,CAAC;EAC1E,gBAAgB,MAAM,IAAI,EAAE,aAAa,4BAA4B,CAAC;EAGtE,UAAU,MAAM,OAAO,EAAE,aAAa,oBAAoB,CAAC;EAG3D,aAAa,MAAM,SAAS,EAAE,aAAa,+BAA+B,CAAC;EAG3E,WAAW,MAAM,WAAW;EAC7B;CACD,SAAS,CAAC,MAAM,GAAG,CAAC,YAAY,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,cAAc,CAAC,CAAC;CACvE,CAAC;;;;AAKF,MAAa,qBAAqB,CAAC,gBAAgB,sBAAsB;;;;AAKzE,MAAaA,+BAAyD;CACpE,UAAU;CACV,UAAU;CACX"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuditTrailFeature } from "./audit-trail.feature.js";
|
|
2
|
+
import { AuditExportInputModel, AuditExportOutputModel, AuditLogModel, AuditQueryInputModel, AuditQueryOutputModel, AuditStatsInputModel, AuditStatsOutputModel, ExportAuditLogsContract, ExportFormatEnum, ExportStatusEnum, GetAuditLogContract, GetAuditStatsContract, GetAuditTraceContract, QueryAuditLogsContract } from "./contracts/index.js";
|
|
3
|
+
import { AuditLogArchiveEntity, AuditLogEntity, auditTrailEntities, auditTrailSchemaContribution } from "./entities/index.js";
|
|
4
|
+
import { AuditStorageAdapter, ExtendedAuditQueryOptions, InMemoryAuditStorage, RetentionPolicy, RetentionPolicyConfig, createInMemoryAuditStorage } from "./storage/index.js";
|
|
5
|
+
import { AuditQueryOptions, AuditRecord, AuditStorage } from "@contractspec/lib.bus";
|
|
6
|
+
export { AuditExportInputModel, AuditExportOutputModel, AuditLogArchiveEntity, AuditLogEntity, AuditLogModel, AuditQueryInputModel, type AuditQueryOptions, AuditQueryOutputModel, type AuditRecord, AuditStatsInputModel, AuditStatsOutputModel, type AuditStorage, AuditStorageAdapter, AuditTrailFeature, ExportAuditLogsContract, ExportFormatEnum, ExportStatusEnum, ExtendedAuditQueryOptions, GetAuditLogContract, GetAuditStatsContract, GetAuditTraceContract, InMemoryAuditStorage, QueryAuditLogsContract, RetentionPolicy, RetentionPolicyConfig, auditTrailEntities, auditTrailSchemaContribution, createInMemoryAuditStorage };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuditTrailFeature } from "./audit-trail.feature.js";
|
|
2
|
+
import { AuditLogArchiveEntity, AuditLogEntity, auditTrailEntities, auditTrailSchemaContribution } from "./entities/index.js";
|
|
3
|
+
import { AuditExportInputModel, AuditExportOutputModel, AuditLogModel, AuditQueryInputModel, AuditQueryOutputModel, AuditStatsInputModel, AuditStatsOutputModel, ExportAuditLogsContract, ExportFormatEnum, ExportStatusEnum, GetAuditLogContract, GetAuditStatsContract, GetAuditTraceContract, QueryAuditLogsContract } from "./contracts/index.js";
|
|
4
|
+
import { InMemoryAuditStorage, RetentionPolicy, createInMemoryAuditStorage } from "./storage/index.js";
|
|
5
|
+
|
|
6
|
+
export { AuditExportInputModel, AuditExportOutputModel, AuditLogArchiveEntity, AuditLogEntity, AuditLogModel, AuditQueryInputModel, AuditQueryOutputModel, AuditStatsInputModel, AuditStatsOutputModel, AuditTrailFeature, ExportAuditLogsContract, ExportFormatEnum, ExportStatusEnum, GetAuditLogContract, GetAuditStatsContract, GetAuditTraceContract, InMemoryAuditStorage, QueryAuditLogsContract, RetentionPolicy, auditTrailEntities, auditTrailSchemaContribution, createInMemoryAuditStorage };
|