@happyvertical/smrt-secrets 0.34.8 → 0.34.9

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.
@@ -1,149 +1,153 @@
1
1
  {
2
2
  "version": "1.0.0",
3
- "timestamp": 1782318233036,
3
+ "timestamp": 1782329189998,
4
4
  "packageName": "@happyvertical/smrt-secrets",
5
- "packageVersion": "0.34.8",
5
+ "packageVersion": "0.34.9",
6
6
  "objects": {
7
- "@happyvertical/smrt-secrets:SecretAuditLogCollection": {
8
- "name": "secretauditlogcollection",
9
- "className": "SecretAuditLogCollection",
10
- "qualifiedName": "@happyvertical/smrt-secrets:SecretAuditLogCollection",
11
- "collection": "secretauditlogs",
12
- "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/collections/SecretAuditLogCollection.ts",
7
+ "@happyvertical/smrt-secrets:Secret": {
8
+ "name": "secret",
9
+ "className": "Secret",
10
+ "qualifiedName": "@happyvertical/smrt-secrets:Secret",
11
+ "collection": "secrets",
12
+ "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/models/Secret.ts",
13
13
  "packageName": "@happyvertical/smrt-secrets",
14
- "fields": {},
15
- "methods": {
16
- "listLogs": {
17
- "name": "listLogs",
18
- "async": true,
19
- "parameters": [
20
- {
21
- "name": "options",
22
- "type": "ListAuditLogsOptions",
23
- "optional": true
14
+ "fields": {
15
+ "tenantId": {
16
+ "type": "text",
17
+ "required": false,
18
+ "default": "",
19
+ "_meta": {
20
+ "sqlType": "UUID",
21
+ "__tenancy": {
22
+ "isTenantIdField": true,
23
+ "mode": "required",
24
+ "field": "tenantId",
25
+ "autoFilter": true,
26
+ "autoPopulate": true,
27
+ "allowSuperAdminBypass": false
24
28
  }
25
- ],
26
- "returnType": "Promise<SecretAuditLog[]>",
27
- "isStatic": false,
28
- "isPublic": true
29
+ }
29
30
  },
30
- "getSecretHistory": {
31
- "name": "getSecretHistory",
32
- "async": true,
33
- "parameters": [
34
- {
35
- "name": "secretName",
36
- "type": "string",
37
- "optional": false
38
- },
39
- {
40
- "name": "limit",
41
- "type": "number",
42
- "optional": true
43
- }
44
- ],
45
- "returnType": "Promise<SecretAuditLog[]>",
31
+ "name": {
32
+ "type": "text",
33
+ "required": false,
34
+ "default": ""
35
+ },
36
+ "description": {
37
+ "type": "text",
38
+ "required": false,
39
+ "default": ""
40
+ },
41
+ "category": {
42
+ "type": "text",
43
+ "required": false,
44
+ "default": ""
45
+ },
46
+ "encryptedValue": {
47
+ "type": "text",
48
+ "required": false,
49
+ "default": ""
50
+ },
51
+ "keyVersion": {
52
+ "type": "integer",
53
+ "required": false,
54
+ "default": 1
55
+ },
56
+ "status": {
57
+ "type": "text",
58
+ "required": false,
59
+ "default": "active"
60
+ },
61
+ "expiresAt": {
62
+ "type": "datetime",
63
+ "required": false
64
+ },
65
+ "lastAccessedAt": {
66
+ "type": "datetime",
67
+ "required": false
68
+ },
69
+ "accessCount": {
70
+ "type": "integer",
71
+ "required": false,
72
+ "default": 0
73
+ },
74
+ "metadata": {
75
+ "type": "json",
76
+ "required": false,
77
+ "default": {}
78
+ }
79
+ },
80
+ "methods": {
81
+ "isActive": {
82
+ "name": "isActive",
83
+ "async": false,
84
+ "parameters": [],
85
+ "returnType": "boolean",
46
86
  "isStatic": false,
47
87
  "isPublic": true
48
88
  },
49
- "getUserActivity": {
50
- "name": "getUserActivity",
51
- "async": true,
52
- "parameters": [
53
- {
54
- "name": "userId",
55
- "type": "string",
56
- "optional": false
57
- },
58
- {
59
- "name": "limit",
60
- "type": "number",
61
- "optional": true
62
- }
63
- ],
64
- "returnType": "Promise<SecretAuditLog[]>",
89
+ "isExpired": {
90
+ "name": "isExpired",
91
+ "async": false,
92
+ "parameters": [],
93
+ "returnType": "boolean",
65
94
  "isStatic": false,
66
95
  "isPublic": true
67
96
  },
68
- "getRecentFailures": {
69
- "name": "getRecentFailures",
70
- "async": true,
71
- "parameters": [
72
- {
73
- "name": "limit",
74
- "type": "number",
75
- "optional": true
76
- }
77
- ],
78
- "returnType": "Promise<SecretAuditLog[]>",
97
+ "isUsable": {
98
+ "name": "isUsable",
99
+ "async": false,
100
+ "parameters": [],
101
+ "returnType": "boolean",
79
102
  "isStatic": false,
80
103
  "isPublic": true
81
104
  },
82
- "getRecentDenials": {
83
- "name": "getRecentDenials",
84
- "async": true,
85
- "parameters": [
86
- {
87
- "name": "limit",
88
- "type": "number",
89
- "optional": true
90
- }
91
- ],
92
- "returnType": "Promise<SecretAuditLog[]>",
105
+ "recordAccess": {
106
+ "name": "recordAccess",
107
+ "async": false,
108
+ "parameters": [],
109
+ "returnType": "void",
93
110
  "isStatic": false,
94
111
  "isPublic": true
95
112
  },
96
- "countByAction": {
97
- "name": "countByAction",
98
- "async": true,
99
- "parameters": [
100
- {
101
- "name": "since",
102
- "type": "Date",
103
- "optional": true
104
- }
105
- ],
106
- "returnType": "Promise<Record<SecretAuditAction, number>>",
113
+ "disable": {
114
+ "name": "disable",
115
+ "async": false,
116
+ "parameters": [],
117
+ "returnType": "void",
107
118
  "isStatic": false,
108
119
  "isPublic": true
109
120
  },
110
- "countByResult": {
111
- "name": "countByResult",
112
- "async": true,
113
- "parameters": [
114
- {
115
- "name": "since",
116
- "type": "Date",
117
- "optional": true
118
- }
119
- ],
120
- "returnType": "Promise<Record<SecretAuditResult, number>>",
121
+ "enable": {
122
+ "name": "enable",
123
+ "async": false,
124
+ "parameters": [],
125
+ "returnType": "void",
121
126
  "isStatic": false,
122
127
  "isPublic": true
128
+ }
129
+ },
130
+ "decoratorConfig": {
131
+ "tenantScoped": true,
132
+ "api": {
133
+ "include": []
123
134
  },
124
- "cleanup": {
125
- "name": "cleanup",
126
- "async": true,
127
- "parameters": [
128
- {
129
- "name": "olderThanDays",
130
- "type": "number",
131
- "optional": true
132
- }
135
+ "mcp": {
136
+ "include": []
137
+ },
138
+ "cli": {
139
+ "include": [
140
+ "list"
133
141
  ],
134
- "returnType": "Promise<number>",
135
- "isStatic": false,
136
- "isPublic": true
142
+ "skipApiCheck": true
137
143
  }
138
144
  },
139
- "decoratorConfig": {},
140
- "extends": "SmrtCollection",
141
- "extendsTypeArg": "SecretAuditLog",
142
- "exportName": "SecretAuditLogCollection",
143
- "collectionExportName": "SecretAuditLogCollectionCollection",
145
+ "extends": "SmrtObject",
146
+ "exportName": "Secret",
147
+ "collectionExportName": "SecretCollection",
144
148
  "schema": {
145
- "tableName": "secret_audit_log_collections",
146
- "ddl": "CREATE TABLE IF NOT EXISTS \"secret_audit_log_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
149
+ "tableName": "secrets",
150
+ "ddl": "CREATE TABLE IF NOT EXISTS \"secrets\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"category\" TEXT DEFAULT '',\n \"encrypted_value\" TEXT DEFAULT '',\n \"key_version\" INTEGER DEFAULT 1,\n \"status\" TEXT DEFAULT 'active',\n \"expires_at\" TIMESTAMP,\n \"last_accessed_at\" TIMESTAMP,\n \"access_count\" INTEGER DEFAULT 0,\n \"metadata\" JSON DEFAULT '{}'\n);",
147
151
  "columns": {
148
152
  "id": {
149
153
  "type": "UUID",
@@ -169,218 +173,81 @@
169
173
  "type": "TIMESTAMP",
170
174
  "notNull": true,
171
175
  "default": "current_timestamp"
172
- }
173
- },
174
- "indexes": [
175
- {
176
- "name": "secret_audit_log_collections_id_idx",
177
- "columns": [
178
- "id"
179
- ]
180
176
  },
181
- {
182
- "name": "secret_audit_log_collections_slug_context_idx",
183
- "columns": [
184
- "slug",
185
- "context"
186
- ],
187
- "unique": true
188
- }
189
- ],
190
- "version": "7bb61130"
191
- }
192
- },
193
- "@happyvertical/smrt-secrets:SecretCollection": {
194
- "name": "secretcollection",
195
- "className": "SecretCollection",
196
- "qualifiedName": "@happyvertical/smrt-secrets:SecretCollection",
197
- "collection": "secrets",
198
- "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/collections/SecretCollection.ts",
199
- "packageName": "@happyvertical/smrt-secrets",
200
- "fields": {},
201
- "methods": {
202
- "findByName": {
203
- "name": "findByName",
204
- "async": true,
205
- "parameters": [
206
- {
207
- "name": "tenantId",
208
- "type": "string",
209
- "optional": false
210
- },
211
- {
212
- "name": "name",
213
- "type": "string",
214
- "optional": false
215
- }
216
- ],
217
- "returnType": "Promise<Secret | null>",
218
- "isStatic": false,
219
- "isPublic": true
220
- },
221
- "listSecrets": {
222
- "name": "listSecrets",
223
- "async": true,
224
- "parameters": [
225
- {
226
- "name": "tenantId",
227
- "type": "string",
228
- "optional": false
229
- },
230
- {
231
- "name": "options",
232
- "type": "ListSecretsOptions",
233
- "optional": true
234
- }
235
- ],
236
- "returnType": "Promise<Secret[]>",
237
- "isStatic": false,
238
- "isPublic": true
239
- },
240
- "listActive": {
241
- "name": "listActive",
242
- "async": true,
243
- "parameters": [
244
- {
245
- "name": "tenantId",
246
- "type": "string",
247
- "optional": false
248
- }
249
- ],
250
- "returnType": "Promise<Secret[]>",
251
- "isStatic": false,
252
- "isPublic": true
253
- },
254
- "listByCategory": {
255
- "name": "listByCategory",
256
- "async": true,
257
- "parameters": [
258
- {
259
- "name": "tenantId",
260
- "type": "string",
261
- "optional": false
262
- },
263
- {
264
- "name": "category",
265
- "type": "string",
266
- "optional": false
267
- }
268
- ],
269
- "returnType": "Promise<Secret[]>",
270
- "isStatic": false,
271
- "isPublic": true
272
- },
273
- "listExpiring": {
274
- "name": "listExpiring",
275
- "async": true,
276
- "parameters": [
277
- {
278
- "name": "tenantId",
279
- "type": "string",
280
- "optional": false
281
- },
282
- {
283
- "name": "daysAhead",
284
- "type": "number",
285
- "optional": true
286
- }
287
- ],
288
- "returnType": "Promise<Secret[]>",
289
- "isStatic": false,
290
- "isPublic": true
291
- },
292
- "getCategories": {
293
- "name": "getCategories",
294
- "async": true,
295
- "parameters": [
296
- {
297
- "name": "tenantId",
298
- "type": "string",
299
- "optional": false
300
- }
301
- ],
302
- "returnType": "Promise<string[]>",
303
- "isStatic": false,
304
- "isPublic": true
305
- },
306
- "countByStatus": {
307
- "name": "countByStatus",
308
- "async": true,
309
- "parameters": [
310
- {
311
- "name": "tenantId",
312
- "type": "string",
313
- "optional": false
314
- }
315
- ],
316
- "returnType": "Promise<Record<SecretStatus, number>>",
317
- "isStatic": false,
318
- "isPublic": true
319
- },
320
- "deleteByName": {
321
- "name": "deleteByName",
322
- "async": true,
323
- "parameters": [
324
- {
325
- "name": "tenantId",
326
- "type": "string",
327
- "optional": false
328
- },
329
- {
330
- "name": "name",
331
- "type": "string",
332
- "optional": false
333
- }
334
- ],
335
- "returnType": "Promise<boolean>",
336
- "isStatic": false,
337
- "isPublic": true
338
- }
339
- },
340
- "decoratorConfig": {},
341
- "extends": "SmrtCollection",
342
- "extendsTypeArg": "Secret",
343
- "exportName": "SecretCollection",
344
- "collectionExportName": "SecretCollectionCollection",
345
- "schema": {
346
- "tableName": "secret_collections",
347
- "ddl": "CREATE TABLE IF NOT EXISTS \"secret_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
348
- "columns": {
349
- "id": {
177
+ "tenant_id": {
350
178
  "type": "UUID",
351
- "primaryKey": true,
352
- "referenceKind": "id",
353
- "notNull": true
179
+ "referenceKind": "tenantId",
180
+ "notNull": false,
181
+ "unique": false
354
182
  },
355
- "slug": {
183
+ "name": {
356
184
  "type": "TEXT",
357
- "notNull": true
185
+ "notNull": false,
186
+ "unique": false,
187
+ "default": ""
358
188
  },
359
- "context": {
189
+ "description": {
360
190
  "type": "TEXT",
361
- "notNull": true,
191
+ "notNull": false,
192
+ "unique": false,
362
193
  "default": ""
363
194
  },
364
- "created_at": {
195
+ "category": {
196
+ "type": "TEXT",
197
+ "notNull": false,
198
+ "unique": false,
199
+ "default": ""
200
+ },
201
+ "encrypted_value": {
202
+ "type": "TEXT",
203
+ "notNull": false,
204
+ "unique": false,
205
+ "default": ""
206
+ },
207
+ "key_version": {
208
+ "type": "INTEGER",
209
+ "notNull": false,
210
+ "unique": false,
211
+ "default": 1
212
+ },
213
+ "status": {
214
+ "type": "TEXT",
215
+ "notNull": false,
216
+ "unique": false,
217
+ "default": "active"
218
+ },
219
+ "expires_at": {
365
220
  "type": "TIMESTAMP",
366
- "notNull": true,
367
- "default": "current_timestamp"
221
+ "notNull": false,
222
+ "unique": false
368
223
  },
369
- "updated_at": {
224
+ "last_accessed_at": {
370
225
  "type": "TIMESTAMP",
371
- "notNull": true,
372
- "default": "current_timestamp"
226
+ "notNull": false,
227
+ "unique": false
228
+ },
229
+ "access_count": {
230
+ "type": "INTEGER",
231
+ "notNull": false,
232
+ "unique": false,
233
+ "default": 0
234
+ },
235
+ "metadata": {
236
+ "type": "JSON",
237
+ "notNull": false,
238
+ "unique": false,
239
+ "default": {}
373
240
  }
374
241
  },
375
242
  "indexes": [
376
243
  {
377
- "name": "secret_collections_id_idx",
244
+ "name": "secrets_id_idx",
378
245
  "columns": [
379
246
  "id"
380
247
  ]
381
248
  },
382
249
  {
383
- "name": "secret_collections_slug_context_idx",
250
+ "name": "secrets_slug_context_idx",
384
251
  "columns": [
385
252
  "slug",
386
253
  "context"
@@ -388,131 +255,144 @@
388
255
  "unique": true
389
256
  }
390
257
  ],
391
- "version": "5f18a721"
258
+ "version": "6298a980"
392
259
  }
393
260
  },
394
- "@happyvertical/smrt-secrets:TenantKeyCollection": {
395
- "name": "tenantkeycollection",
396
- "className": "TenantKeyCollection",
397
- "qualifiedName": "@happyvertical/smrt-secrets:TenantKeyCollection",
398
- "collection": "tenantkeys",
399
- "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/collections/TenantKeyCollection.ts",
261
+ "@happyvertical/smrt-secrets:SecretAuditLog": {
262
+ "name": "secretauditlog",
263
+ "className": "SecretAuditLog",
264
+ "qualifiedName": "@happyvertical/smrt-secrets:SecretAuditLog",
265
+ "collection": "secretauditlogs",
266
+ "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/models/SecretAuditLog.ts",
400
267
  "packageName": "@happyvertical/smrt-secrets",
401
- "fields": {},
402
- "methods": {
403
- "getActiveKey": {
404
- "name": "getActiveKey",
405
- "async": true,
406
- "parameters": [
407
- {
408
- "name": "tenantId",
409
- "type": "string",
410
- "optional": false
268
+ "fields": {
269
+ "tenantId": {
270
+ "type": "text",
271
+ "required": false,
272
+ "_meta": {
273
+ "sqlType": "UUID",
274
+ "__tenancy": {
275
+ "isTenantIdField": true,
276
+ "mode": "required",
277
+ "field": "tenantId",
278
+ "autoFilter": true,
279
+ "autoPopulate": true,
280
+ "allowSuperAdminBypass": false
411
281
  }
412
- ],
413
- "returnType": "Promise<TenantKey | null>",
414
- "isStatic": false,
415
- "isPublic": true
282
+ }
416
283
  },
417
- "listKeyVersions": {
418
- "name": "listKeyVersions",
419
- "async": true,
420
- "parameters": [
421
- {
422
- "name": "tenantId",
423
- "type": "string",
424
- "optional": false
425
- }
426
- ],
427
- "returnType": "Promise<TenantKey[]>",
284
+ "secretId": {
285
+ "type": "foreignKey",
286
+ "required": false,
287
+ "related": "Secret"
288
+ },
289
+ "secretName": {
290
+ "type": "text",
291
+ "required": false,
292
+ "default": ""
293
+ },
294
+ "userId": {
295
+ "type": "crossPackageRef",
296
+ "required": false,
297
+ "related": "@happyvertical/smrt-users:User"
298
+ },
299
+ "action": {
300
+ "type": "text",
301
+ "required": false,
302
+ "default": "read"
303
+ },
304
+ "result": {
305
+ "type": "text",
306
+ "required": false,
307
+ "default": "success"
308
+ },
309
+ "ipAddress": {
310
+ "type": "text",
311
+ "required": false,
312
+ "default": ""
313
+ },
314
+ "userAgent": {
315
+ "type": "text",
316
+ "required": false,
317
+ "default": ""
318
+ },
319
+ "details": {
320
+ "type": "json",
321
+ "required": false,
322
+ "default": {}
323
+ }
324
+ },
325
+ "methods": {
326
+ "isSuccess": {
327
+ "name": "isSuccess",
328
+ "async": false,
329
+ "parameters": [],
330
+ "returnType": "boolean",
428
331
  "isStatic": false,
429
332
  "isPublic": true
430
333
  },
431
- "getKeyVersion": {
432
- "name": "getKeyVersion",
433
- "async": true,
434
- "parameters": [
435
- {
436
- "name": "tenantId",
437
- "type": "string",
438
- "optional": false
439
- },
440
- {
441
- "name": "version",
442
- "type": "number",
443
- "optional": false
444
- }
445
- ],
446
- "returnType": "Promise<TenantKey | null>",
334
+ "isFailure": {
335
+ "name": "isFailure",
336
+ "async": false,
337
+ "parameters": [],
338
+ "returnType": "boolean",
447
339
  "isStatic": false,
448
340
  "isPublic": true
449
341
  },
450
- "findKeysNeedingRotation": {
451
- "name": "findKeysNeedingRotation",
452
- "async": true,
342
+ "isDenied": {
343
+ "name": "isDenied",
344
+ "async": false,
453
345
  "parameters": [],
454
- "returnType": "Promise<TenantKey[]>",
346
+ "returnType": "boolean",
455
347
  "isStatic": false,
456
348
  "isPublic": true
457
349
  },
458
- "listAllActiveKeys": {
459
- "name": "listAllActiveKeys",
460
- "async": true,
350
+ "isReadAction": {
351
+ "name": "isReadAction",
352
+ "async": false,
461
353
  "parameters": [],
462
- "returnType": "Promise<TenantKey[]>",
354
+ "returnType": "boolean",
463
355
  "isStatic": false,
464
356
  "isPublic": true
465
357
  },
466
- "countByStatus": {
467
- "name": "countByStatus",
468
- "async": true,
358
+ "isWriteAction": {
359
+ "name": "isWriteAction",
360
+ "async": false,
469
361
  "parameters": [],
470
- "returnType": "Promise<Record<TenantKeyStatus, number>>",
362
+ "returnType": "boolean",
471
363
  "isStatic": false,
472
364
  "isPublic": true
473
365
  },
474
- "markCompromised": {
475
- "name": "markCompromised",
476
- "async": true,
477
- "parameters": [
478
- {
479
- "name": "tenantId",
480
- "type": "string",
481
- "optional": false
482
- },
483
- {
484
- "name": "keyId",
485
- "type": "string",
486
- "optional": false
487
- }
488
- ],
489
- "returnType": "Promise<boolean>",
366
+ "isKeyOperation": {
367
+ "name": "isKeyOperation",
368
+ "async": false,
369
+ "parameters": [],
370
+ "returnType": "boolean",
490
371
  "isStatic": false,
491
372
  "isPublic": true
373
+ }
374
+ },
375
+ "decoratorConfig": {
376
+ "tenantScoped": true,
377
+ "api": {
378
+ "include": []
492
379
  },
493
- "cleanupRetiredKeys": {
494
- "name": "cleanupRetiredKeys",
495
- "async": true,
496
- "parameters": [
497
- {
498
- "name": "olderThanDays",
499
- "type": "number",
500
- "optional": true
501
- }
380
+ "mcp": {
381
+ "include": []
382
+ },
383
+ "cli": {
384
+ "include": [
385
+ "list"
502
386
  ],
503
- "returnType": "Promise<number>",
504
- "isStatic": false,
505
- "isPublic": true
387
+ "skipApiCheck": true
506
388
  }
507
389
  },
508
- "decoratorConfig": {},
509
- "extends": "SmrtCollection",
510
- "extendsTypeArg": "TenantKey",
511
- "exportName": "TenantKeyCollection",
512
- "collectionExportName": "TenantKeyCollectionCollection",
390
+ "extends": "SmrtObject",
391
+ "exportName": "SecretAuditLog",
392
+ "collectionExportName": "SecretAuditLogCollection",
513
393
  "schema": {
514
- "tableName": "tenant_key_collections",
515
- "ddl": "CREATE TABLE IF NOT EXISTS \"tenant_key_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
394
+ "tableName": "secret_audit_logs",
395
+ "ddl": "CREATE TABLE IF NOT EXISTS \"secret_audit_logs\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"secret_id\" UUID,\n \"secret_name\" TEXT DEFAULT '',\n \"user_id\" UUID,\n \"action\" TEXT DEFAULT 'read',\n \"result\" TEXT DEFAULT 'success',\n \"ip_address\" TEXT DEFAULT '',\n \"user_agent\" TEXT DEFAULT '',\n \"details\" JSON DEFAULT '{}'\n);",
516
396
  "columns": {
517
397
  "id": {
518
398
  "type": "UUID",
@@ -538,17 +418,71 @@
538
418
  "type": "TIMESTAMP",
539
419
  "notNull": true,
540
420
  "default": "current_timestamp"
421
+ },
422
+ "tenant_id": {
423
+ "type": "UUID",
424
+ "referenceKind": "tenantId",
425
+ "notNull": false,
426
+ "unique": false
427
+ },
428
+ "secret_id": {
429
+ "type": "UUID",
430
+ "referenceKind": "foreignKey",
431
+ "notNull": false,
432
+ "unique": false
433
+ },
434
+ "secret_name": {
435
+ "type": "TEXT",
436
+ "notNull": false,
437
+ "unique": false,
438
+ "default": ""
439
+ },
440
+ "user_id": {
441
+ "type": "UUID",
442
+ "referenceKind": "crossPackageRef",
443
+ "notNull": false,
444
+ "unique": false
445
+ },
446
+ "action": {
447
+ "type": "TEXT",
448
+ "notNull": false,
449
+ "unique": false,
450
+ "default": "read"
451
+ },
452
+ "result": {
453
+ "type": "TEXT",
454
+ "notNull": false,
455
+ "unique": false,
456
+ "default": "success"
457
+ },
458
+ "ip_address": {
459
+ "type": "TEXT",
460
+ "notNull": false,
461
+ "unique": false,
462
+ "default": ""
463
+ },
464
+ "user_agent": {
465
+ "type": "TEXT",
466
+ "notNull": false,
467
+ "unique": false,
468
+ "default": ""
469
+ },
470
+ "details": {
471
+ "type": "JSON",
472
+ "notNull": false,
473
+ "unique": false,
474
+ "default": {}
541
475
  }
542
476
  },
543
477
  "indexes": [
544
478
  {
545
- "name": "tenant_key_collections_id_idx",
479
+ "name": "secret_audit_logs_id_idx",
546
480
  "columns": [
547
481
  "id"
548
482
  ]
549
483
  },
550
484
  {
551
- "name": "tenant_key_collections_slug_context_idx",
485
+ "name": "secret_audit_logs_slug_context_idx",
552
486
  "columns": [
553
487
  "slug",
554
488
  "context"
@@ -556,80 +490,49 @@
556
490
  "unique": true
557
491
  }
558
492
  ],
559
- "version": "26616d13"
493
+ "version": "af0d679d"
560
494
  }
561
495
  },
562
- "@happyvertical/smrt-secrets:Secret": {
563
- "name": "secret",
564
- "className": "Secret",
565
- "qualifiedName": "@happyvertical/smrt-secrets:Secret",
566
- "collection": "secrets",
567
- "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/models/Secret.ts",
496
+ "@happyvertical/smrt-secrets:TenantKey": {
497
+ "name": "tenantkey",
498
+ "className": "TenantKey",
499
+ "qualifiedName": "@happyvertical/smrt-secrets:TenantKey",
500
+ "collection": "tenantkeys",
501
+ "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/models/TenantKey.ts",
568
502
  "packageName": "@happyvertical/smrt-secrets",
569
503
  "fields": {
570
504
  "tenantId": {
571
- "type": "text",
572
- "required": false,
573
- "default": "",
574
- "_meta": {
575
- "sqlType": "UUID",
576
- "__tenancy": {
577
- "isTenantIdField": true,
578
- "mode": "required",
579
- "field": "tenantId",
580
- "autoFilter": true,
581
- "autoPopulate": true,
582
- "allowSuperAdminBypass": false
583
- }
584
- }
585
- },
586
- "name": {
587
505
  "type": "text",
588
506
  "required": false,
589
507
  "default": ""
590
508
  },
591
- "description": {
509
+ "wrappedKey": {
592
510
  "type": "text",
593
511
  "required": false,
594
512
  "default": ""
595
513
  },
596
- "category": {
514
+ "amkKeyId": {
597
515
  "type": "text",
598
516
  "required": false,
599
517
  "default": ""
600
518
  },
601
- "encryptedValue": {
519
+ "status": {
602
520
  "type": "text",
603
521
  "required": false,
604
- "default": ""
522
+ "default": "active"
605
523
  },
606
- "keyVersion": {
524
+ "version": {
607
525
  "type": "integer",
608
526
  "required": false,
609
527
  "default": 1
610
528
  },
611
- "status": {
612
- "type": "text",
613
- "required": false,
614
- "default": "active"
615
- },
616
- "expiresAt": {
529
+ "rotateAfter": {
617
530
  "type": "datetime",
618
531
  "required": false
619
532
  },
620
- "lastAccessedAt": {
533
+ "retiredAt": {
621
534
  "type": "datetime",
622
535
  "required": false
623
- },
624
- "accessCount": {
625
- "type": "integer",
626
- "required": false,
627
- "default": 0
628
- },
629
- "metadata": {
630
- "type": "json",
631
- "required": false,
632
- "default": {}
633
536
  }
634
537
  },
635
538
  "methods": {
@@ -641,40 +544,56 @@
641
544
  "isStatic": false,
642
545
  "isPublic": true
643
546
  },
644
- "isExpired": {
645
- "name": "isExpired",
547
+ "needsRotation": {
548
+ "name": "needsRotation",
646
549
  "async": false,
647
550
  "parameters": [],
648
551
  "returnType": "boolean",
649
552
  "isStatic": false,
650
553
  "isPublic": true
651
554
  },
652
- "isUsable": {
653
- "name": "isUsable",
555
+ "isRetired": {
556
+ "name": "isRetired",
654
557
  "async": false,
655
558
  "parameters": [],
656
559
  "returnType": "boolean",
657
560
  "isStatic": false,
658
561
  "isPublic": true
659
562
  },
660
- "recordAccess": {
661
- "name": "recordAccess",
563
+ "isCompromised": {
564
+ "name": "isCompromised",
565
+ "async": false,
566
+ "parameters": [],
567
+ "returnType": "boolean",
568
+ "isStatic": false,
569
+ "isPublic": true
570
+ },
571
+ "canDecrypt": {
572
+ "name": "canDecrypt",
573
+ "async": false,
574
+ "parameters": [],
575
+ "returnType": "boolean",
576
+ "isStatic": false,
577
+ "isPublic": true
578
+ },
579
+ "canEncrypt": {
580
+ "name": "canEncrypt",
662
581
  "async": false,
663
582
  "parameters": [],
664
- "returnType": "void",
583
+ "returnType": "boolean",
665
584
  "isStatic": false,
666
585
  "isPublic": true
667
586
  },
668
- "disable": {
669
- "name": "disable",
587
+ "retire": {
588
+ "name": "retire",
670
589
  "async": false,
671
590
  "parameters": [],
672
591
  "returnType": "void",
673
592
  "isStatic": false,
674
593
  "isPublic": true
675
594
  },
676
- "enable": {
677
- "name": "enable",
595
+ "markCompromised": {
596
+ "name": "markCompromised",
678
597
  "async": false,
679
598
  "parameters": [],
680
599
  "returnType": "void",
@@ -683,7 +602,6 @@
683
602
  }
684
603
  },
685
604
  "decoratorConfig": {
686
- "tenantScoped": true,
687
605
  "api": {
688
606
  "include": []
689
607
  },
@@ -692,17 +610,18 @@
692
610
  },
693
611
  "cli": {
694
612
  "include": [
695
- "list"
613
+ "list",
614
+ "get"
696
615
  ],
697
616
  "skipApiCheck": true
698
617
  }
699
618
  },
700
619
  "extends": "SmrtObject",
701
- "exportName": "Secret",
702
- "collectionExportName": "SecretCollection",
620
+ "exportName": "TenantKey",
621
+ "collectionExportName": "TenantKeyCollection",
703
622
  "schema": {
704
- "tableName": "secrets",
705
- "ddl": "CREATE TABLE IF NOT EXISTS \"secrets\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"category\" TEXT DEFAULT '',\n \"encrypted_value\" TEXT DEFAULT '',\n \"key_version\" INTEGER DEFAULT 1,\n \"status\" TEXT DEFAULT 'active',\n \"expires_at\" TIMESTAMP,\n \"last_accessed_at\" TIMESTAMP,\n \"access_count\" INTEGER DEFAULT 0,\n \"metadata\" JSON DEFAULT '{}'\n);",
623
+ "tableName": "tenant_keys",
624
+ "ddl": "CREATE TABLE IF NOT EXISTS \"tenant_keys\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" TEXT DEFAULT '',\n \"wrapped_key\" TEXT DEFAULT '',\n \"amk_key_id\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'active',\n \"version\" INTEGER DEFAULT 1,\n \"rotate_after\" TIMESTAMP,\n \"retired_at\" TIMESTAMP\n);",
706
625
  "columns": {
707
626
  "id": {
708
627
  "type": "UUID",
@@ -730,79 +649,55 @@
730
649
  "default": "current_timestamp"
731
650
  },
732
651
  "tenant_id": {
733
- "type": "UUID",
734
- "referenceKind": "tenantId",
735
- "notNull": false,
736
- "unique": false
737
- },
738
- "name": {
739
652
  "type": "TEXT",
740
653
  "notNull": false,
741
654
  "unique": false,
742
655
  "default": ""
743
656
  },
744
- "description": {
657
+ "wrapped_key": {
745
658
  "type": "TEXT",
746
659
  "notNull": false,
747
660
  "unique": false,
748
661
  "default": ""
749
662
  },
750
- "category": {
663
+ "amk_key_id": {
751
664
  "type": "TEXT",
752
665
  "notNull": false,
753
666
  "unique": false,
754
667
  "default": ""
755
668
  },
756
- "encrypted_value": {
669
+ "status": {
757
670
  "type": "TEXT",
758
671
  "notNull": false,
759
672
  "unique": false,
760
- "default": ""
673
+ "default": "active"
761
674
  },
762
- "key_version": {
675
+ "version": {
763
676
  "type": "INTEGER",
764
677
  "notNull": false,
765
678
  "unique": false,
766
679
  "default": 1
767
680
  },
768
- "status": {
769
- "type": "TEXT",
770
- "notNull": false,
771
- "unique": false,
772
- "default": "active"
773
- },
774
- "expires_at": {
681
+ "rotate_after": {
775
682
  "type": "TIMESTAMP",
776
683
  "notNull": false,
777
684
  "unique": false
778
685
  },
779
- "last_accessed_at": {
686
+ "retired_at": {
780
687
  "type": "TIMESTAMP",
781
688
  "notNull": false,
782
689
  "unique": false
783
- },
784
- "access_count": {
785
- "type": "INTEGER",
786
- "notNull": false,
787
- "unique": false,
788
- "default": 0
789
- },
790
- "metadata": {
791
- "type": "JSON",
792
- "notNull": false,
793
- "unique": false,
794
- "default": {}
795
690
  }
796
691
  },
797
692
  "indexes": [
798
693
  {
799
- "name": "secrets_id_idx",
694
+ "name": "tenant_keys_id_idx",
800
695
  "columns": [
801
696
  "id"
802
697
  ]
803
698
  },
804
699
  {
805
- "name": "secrets_slug_context_idx",
700
+ "name": "tenant_keys_slug_context_idx",
806
701
  "columns": [
807
702
  "slug",
808
703
  "context"
@@ -810,144 +705,149 @@
810
705
  "unique": true
811
706
  }
812
707
  ],
813
- "version": "6298a980"
708
+ "version": "79fd7e46"
814
709
  }
815
710
  },
816
- "@happyvertical/smrt-secrets:SecretAuditLog": {
817
- "name": "secretauditlog",
818
- "className": "SecretAuditLog",
819
- "qualifiedName": "@happyvertical/smrt-secrets:SecretAuditLog",
711
+ "@happyvertical/smrt-secrets:SecretAuditLogCollection": {
712
+ "name": "secretauditlogcollection",
713
+ "className": "SecretAuditLogCollection",
714
+ "qualifiedName": "@happyvertical/smrt-secrets:SecretAuditLogCollection",
820
715
  "collection": "secretauditlogs",
821
- "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/models/SecretAuditLog.ts",
716
+ "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/collections/SecretAuditLogCollection.ts",
822
717
  "packageName": "@happyvertical/smrt-secrets",
823
- "fields": {
824
- "tenantId": {
825
- "type": "text",
826
- "required": false,
827
- "_meta": {
828
- "sqlType": "UUID",
829
- "__tenancy": {
830
- "isTenantIdField": true,
831
- "mode": "required",
832
- "field": "tenantId",
833
- "autoFilter": true,
834
- "autoPopulate": true,
835
- "allowSuperAdminBypass": false
836
- }
837
- }
838
- },
839
- "secretId": {
840
- "type": "foreignKey",
841
- "required": false,
842
- "related": "Secret"
843
- },
844
- "secretName": {
845
- "type": "text",
846
- "required": false,
847
- "default": ""
848
- },
849
- "userId": {
850
- "type": "crossPackageRef",
851
- "required": false,
852
- "related": "@happyvertical/smrt-users:User"
853
- },
854
- "action": {
855
- "type": "text",
856
- "required": false,
857
- "default": "read"
858
- },
859
- "result": {
860
- "type": "text",
861
- "required": false,
862
- "default": "success"
863
- },
864
- "ipAddress": {
865
- "type": "text",
866
- "required": false,
867
- "default": ""
868
- },
869
- "userAgent": {
870
- "type": "text",
871
- "required": false,
872
- "default": ""
873
- },
874
- "details": {
875
- "type": "json",
876
- "required": false,
877
- "default": {}
878
- }
879
- },
718
+ "fields": {},
880
719
  "methods": {
881
- "isSuccess": {
882
- "name": "isSuccess",
883
- "async": false,
884
- "parameters": [],
885
- "returnType": "boolean",
720
+ "listLogs": {
721
+ "name": "listLogs",
722
+ "async": true,
723
+ "parameters": [
724
+ {
725
+ "name": "options",
726
+ "type": "ListAuditLogsOptions",
727
+ "optional": true
728
+ }
729
+ ],
730
+ "returnType": "Promise<SecretAuditLog[]>",
886
731
  "isStatic": false,
887
732
  "isPublic": true
888
733
  },
889
- "isFailure": {
890
- "name": "isFailure",
891
- "async": false,
892
- "parameters": [],
893
- "returnType": "boolean",
734
+ "getSecretHistory": {
735
+ "name": "getSecretHistory",
736
+ "async": true,
737
+ "parameters": [
738
+ {
739
+ "name": "secretName",
740
+ "type": "string",
741
+ "optional": false
742
+ },
743
+ {
744
+ "name": "limit",
745
+ "type": "number",
746
+ "optional": true
747
+ }
748
+ ],
749
+ "returnType": "Promise<SecretAuditLog[]>",
894
750
  "isStatic": false,
895
751
  "isPublic": true
896
752
  },
897
- "isDenied": {
898
- "name": "isDenied",
899
- "async": false,
900
- "parameters": [],
901
- "returnType": "boolean",
753
+ "getUserActivity": {
754
+ "name": "getUserActivity",
755
+ "async": true,
756
+ "parameters": [
757
+ {
758
+ "name": "userId",
759
+ "type": "string",
760
+ "optional": false
761
+ },
762
+ {
763
+ "name": "limit",
764
+ "type": "number",
765
+ "optional": true
766
+ }
767
+ ],
768
+ "returnType": "Promise<SecretAuditLog[]>",
902
769
  "isStatic": false,
903
770
  "isPublic": true
904
771
  },
905
- "isReadAction": {
906
- "name": "isReadAction",
907
- "async": false,
908
- "parameters": [],
909
- "returnType": "boolean",
772
+ "getRecentFailures": {
773
+ "name": "getRecentFailures",
774
+ "async": true,
775
+ "parameters": [
776
+ {
777
+ "name": "limit",
778
+ "type": "number",
779
+ "optional": true
780
+ }
781
+ ],
782
+ "returnType": "Promise<SecretAuditLog[]>",
910
783
  "isStatic": false,
911
784
  "isPublic": true
912
785
  },
913
- "isWriteAction": {
914
- "name": "isWriteAction",
915
- "async": false,
916
- "parameters": [],
917
- "returnType": "boolean",
786
+ "getRecentDenials": {
787
+ "name": "getRecentDenials",
788
+ "async": true,
789
+ "parameters": [
790
+ {
791
+ "name": "limit",
792
+ "type": "number",
793
+ "optional": true
794
+ }
795
+ ],
796
+ "returnType": "Promise<SecretAuditLog[]>",
918
797
  "isStatic": false,
919
798
  "isPublic": true
920
799
  },
921
- "isKeyOperation": {
922
- "name": "isKeyOperation",
923
- "async": false,
924
- "parameters": [],
925
- "returnType": "boolean",
800
+ "countByAction": {
801
+ "name": "countByAction",
802
+ "async": true,
803
+ "parameters": [
804
+ {
805
+ "name": "since",
806
+ "type": "Date",
807
+ "optional": true
808
+ }
809
+ ],
810
+ "returnType": "Promise<Record<SecretAuditAction, number>>",
926
811
  "isStatic": false,
927
812
  "isPublic": true
928
- }
929
- },
930
- "decoratorConfig": {
931
- "tenantScoped": true,
932
- "api": {
933
- "include": []
934
813
  },
935
- "mcp": {
936
- "include": []
814
+ "countByResult": {
815
+ "name": "countByResult",
816
+ "async": true,
817
+ "parameters": [
818
+ {
819
+ "name": "since",
820
+ "type": "Date",
821
+ "optional": true
822
+ }
823
+ ],
824
+ "returnType": "Promise<Record<SecretAuditResult, number>>",
825
+ "isStatic": false,
826
+ "isPublic": true
937
827
  },
938
- "cli": {
939
- "include": [
940
- "list"
828
+ "cleanup": {
829
+ "name": "cleanup",
830
+ "async": true,
831
+ "parameters": [
832
+ {
833
+ "name": "olderThanDays",
834
+ "type": "number",
835
+ "optional": true
836
+ }
941
837
  ],
942
- "skipApiCheck": true
838
+ "returnType": "Promise<number>",
839
+ "isStatic": false,
840
+ "isPublic": true
943
841
  }
944
842
  },
945
- "extends": "SmrtObject",
946
- "exportName": "SecretAuditLog",
947
- "collectionExportName": "SecretAuditLogCollection",
843
+ "decoratorConfig": {},
844
+ "extends": "SmrtCollection",
845
+ "extendsTypeArg": "SecretAuditLog",
846
+ "exportName": "SecretAuditLogCollection",
847
+ "collectionExportName": "SecretAuditLogCollectionCollection",
948
848
  "schema": {
949
- "tableName": "secret_audit_logs",
950
- "ddl": "CREATE TABLE IF NOT EXISTS \"secret_audit_logs\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"secret_id\" UUID,\n \"secret_name\" TEXT DEFAULT '',\n \"user_id\" UUID,\n \"action\" TEXT DEFAULT 'read',\n \"result\" TEXT DEFAULT 'success',\n \"ip_address\" TEXT DEFAULT '',\n \"user_agent\" TEXT DEFAULT '',\n \"details\" JSON DEFAULT '{}'\n);",
849
+ "tableName": "secret_audit_log_collections",
850
+ "ddl": "CREATE TABLE IF NOT EXISTS \"secret_audit_log_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
951
851
  "columns": {
952
852
  "id": {
953
853
  "type": "UUID",
@@ -973,71 +873,218 @@
973
873
  "type": "TIMESTAMP",
974
874
  "notNull": true,
975
875
  "default": "current_timestamp"
876
+ }
877
+ },
878
+ "indexes": [
879
+ {
880
+ "name": "secret_audit_log_collections_id_idx",
881
+ "columns": [
882
+ "id"
883
+ ]
976
884
  },
977
- "tenant_id": {
978
- "type": "UUID",
979
- "referenceKind": "tenantId",
980
- "notNull": false,
981
- "unique": false
982
- },
983
- "secret_id": {
984
- "type": "UUID",
985
- "referenceKind": "foreignKey",
986
- "notNull": false,
987
- "unique": false
988
- },
989
- "secret_name": {
990
- "type": "TEXT",
991
- "notNull": false,
992
- "unique": false,
993
- "default": ""
994
- },
995
- "user_id": {
885
+ {
886
+ "name": "secret_audit_log_collections_slug_context_idx",
887
+ "columns": [
888
+ "slug",
889
+ "context"
890
+ ],
891
+ "unique": true
892
+ }
893
+ ],
894
+ "version": "7bb61130"
895
+ }
896
+ },
897
+ "@happyvertical/smrt-secrets:SecretCollection": {
898
+ "name": "secretcollection",
899
+ "className": "SecretCollection",
900
+ "qualifiedName": "@happyvertical/smrt-secrets:SecretCollection",
901
+ "collection": "secrets",
902
+ "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/collections/SecretCollection.ts",
903
+ "packageName": "@happyvertical/smrt-secrets",
904
+ "fields": {},
905
+ "methods": {
906
+ "findByName": {
907
+ "name": "findByName",
908
+ "async": true,
909
+ "parameters": [
910
+ {
911
+ "name": "tenantId",
912
+ "type": "string",
913
+ "optional": false
914
+ },
915
+ {
916
+ "name": "name",
917
+ "type": "string",
918
+ "optional": false
919
+ }
920
+ ],
921
+ "returnType": "Promise<Secret | null>",
922
+ "isStatic": false,
923
+ "isPublic": true
924
+ },
925
+ "listSecrets": {
926
+ "name": "listSecrets",
927
+ "async": true,
928
+ "parameters": [
929
+ {
930
+ "name": "tenantId",
931
+ "type": "string",
932
+ "optional": false
933
+ },
934
+ {
935
+ "name": "options",
936
+ "type": "ListSecretsOptions",
937
+ "optional": true
938
+ }
939
+ ],
940
+ "returnType": "Promise<Secret[]>",
941
+ "isStatic": false,
942
+ "isPublic": true
943
+ },
944
+ "listActive": {
945
+ "name": "listActive",
946
+ "async": true,
947
+ "parameters": [
948
+ {
949
+ "name": "tenantId",
950
+ "type": "string",
951
+ "optional": false
952
+ }
953
+ ],
954
+ "returnType": "Promise<Secret[]>",
955
+ "isStatic": false,
956
+ "isPublic": true
957
+ },
958
+ "listByCategory": {
959
+ "name": "listByCategory",
960
+ "async": true,
961
+ "parameters": [
962
+ {
963
+ "name": "tenantId",
964
+ "type": "string",
965
+ "optional": false
966
+ },
967
+ {
968
+ "name": "category",
969
+ "type": "string",
970
+ "optional": false
971
+ }
972
+ ],
973
+ "returnType": "Promise<Secret[]>",
974
+ "isStatic": false,
975
+ "isPublic": true
976
+ },
977
+ "listExpiring": {
978
+ "name": "listExpiring",
979
+ "async": true,
980
+ "parameters": [
981
+ {
982
+ "name": "tenantId",
983
+ "type": "string",
984
+ "optional": false
985
+ },
986
+ {
987
+ "name": "daysAhead",
988
+ "type": "number",
989
+ "optional": true
990
+ }
991
+ ],
992
+ "returnType": "Promise<Secret[]>",
993
+ "isStatic": false,
994
+ "isPublic": true
995
+ },
996
+ "getCategories": {
997
+ "name": "getCategories",
998
+ "async": true,
999
+ "parameters": [
1000
+ {
1001
+ "name": "tenantId",
1002
+ "type": "string",
1003
+ "optional": false
1004
+ }
1005
+ ],
1006
+ "returnType": "Promise<string[]>",
1007
+ "isStatic": false,
1008
+ "isPublic": true
1009
+ },
1010
+ "countByStatus": {
1011
+ "name": "countByStatus",
1012
+ "async": true,
1013
+ "parameters": [
1014
+ {
1015
+ "name": "tenantId",
1016
+ "type": "string",
1017
+ "optional": false
1018
+ }
1019
+ ],
1020
+ "returnType": "Promise<Record<SecretStatus, number>>",
1021
+ "isStatic": false,
1022
+ "isPublic": true
1023
+ },
1024
+ "deleteByName": {
1025
+ "name": "deleteByName",
1026
+ "async": true,
1027
+ "parameters": [
1028
+ {
1029
+ "name": "tenantId",
1030
+ "type": "string",
1031
+ "optional": false
1032
+ },
1033
+ {
1034
+ "name": "name",
1035
+ "type": "string",
1036
+ "optional": false
1037
+ }
1038
+ ],
1039
+ "returnType": "Promise<boolean>",
1040
+ "isStatic": false,
1041
+ "isPublic": true
1042
+ }
1043
+ },
1044
+ "decoratorConfig": {},
1045
+ "extends": "SmrtCollection",
1046
+ "extendsTypeArg": "Secret",
1047
+ "exportName": "SecretCollection",
1048
+ "collectionExportName": "SecretCollectionCollection",
1049
+ "schema": {
1050
+ "tableName": "secret_collections",
1051
+ "ddl": "CREATE TABLE IF NOT EXISTS \"secret_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1052
+ "columns": {
1053
+ "id": {
996
1054
  "type": "UUID",
997
- "referenceKind": "crossPackageRef",
998
- "notNull": false,
999
- "unique": false
1000
- },
1001
- "action": {
1002
- "type": "TEXT",
1003
- "notNull": false,
1004
- "unique": false,
1005
- "default": "read"
1006
- },
1007
- "result": {
1008
- "type": "TEXT",
1009
- "notNull": false,
1010
- "unique": false,
1011
- "default": "success"
1055
+ "primaryKey": true,
1056
+ "referenceKind": "id",
1057
+ "notNull": true
1012
1058
  },
1013
- "ip_address": {
1059
+ "slug": {
1014
1060
  "type": "TEXT",
1015
- "notNull": false,
1016
- "unique": false,
1017
- "default": ""
1061
+ "notNull": true
1018
1062
  },
1019
- "user_agent": {
1063
+ "context": {
1020
1064
  "type": "TEXT",
1021
- "notNull": false,
1022
- "unique": false,
1065
+ "notNull": true,
1023
1066
  "default": ""
1024
1067
  },
1025
- "details": {
1026
- "type": "JSON",
1027
- "notNull": false,
1028
- "unique": false,
1029
- "default": {}
1068
+ "created_at": {
1069
+ "type": "TIMESTAMP",
1070
+ "notNull": true,
1071
+ "default": "current_timestamp"
1072
+ },
1073
+ "updated_at": {
1074
+ "type": "TIMESTAMP",
1075
+ "notNull": true,
1076
+ "default": "current_timestamp"
1030
1077
  }
1031
1078
  },
1032
1079
  "indexes": [
1033
1080
  {
1034
- "name": "secret_audit_logs_id_idx",
1081
+ "name": "secret_collections_id_idx",
1035
1082
  "columns": [
1036
1083
  "id"
1037
1084
  ]
1038
1085
  },
1039
1086
  {
1040
- "name": "secret_audit_logs_slug_context_idx",
1087
+ "name": "secret_collections_slug_context_idx",
1041
1088
  "columns": [
1042
1089
  "slug",
1043
1090
  "context"
@@ -1045,138 +1092,131 @@
1045
1092
  "unique": true
1046
1093
  }
1047
1094
  ],
1048
- "version": "af0d679d"
1095
+ "version": "5f18a721"
1049
1096
  }
1050
1097
  },
1051
- "@happyvertical/smrt-secrets:TenantKey": {
1052
- "name": "tenantkey",
1053
- "className": "TenantKey",
1054
- "qualifiedName": "@happyvertical/smrt-secrets:TenantKey",
1098
+ "@happyvertical/smrt-secrets:TenantKeyCollection": {
1099
+ "name": "tenantkeycollection",
1100
+ "className": "TenantKeyCollection",
1101
+ "qualifiedName": "@happyvertical/smrt-secrets:TenantKeyCollection",
1055
1102
  "collection": "tenantkeys",
1056
- "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/models/TenantKey.ts",
1103
+ "filePath": "/home/runner/_work/smrt/smrt/packages/secrets/src/collections/TenantKeyCollection.ts",
1057
1104
  "packageName": "@happyvertical/smrt-secrets",
1058
- "fields": {
1059
- "tenantId": {
1060
- "type": "text",
1061
- "required": false,
1062
- "default": ""
1063
- },
1064
- "wrappedKey": {
1065
- "type": "text",
1066
- "required": false,
1067
- "default": ""
1068
- },
1069
- "amkKeyId": {
1070
- "type": "text",
1071
- "required": false,
1072
- "default": ""
1073
- },
1074
- "status": {
1075
- "type": "text",
1076
- "required": false,
1077
- "default": "active"
1078
- },
1079
- "version": {
1080
- "type": "integer",
1081
- "required": false,
1082
- "default": 1
1083
- },
1084
- "rotateAfter": {
1085
- "type": "datetime",
1086
- "required": false
1087
- },
1088
- "retiredAt": {
1089
- "type": "datetime",
1090
- "required": false
1091
- }
1092
- },
1105
+ "fields": {},
1093
1106
  "methods": {
1094
- "isActive": {
1095
- "name": "isActive",
1096
- "async": false,
1097
- "parameters": [],
1098
- "returnType": "boolean",
1099
- "isStatic": false,
1100
- "isPublic": true
1101
- },
1102
- "needsRotation": {
1103
- "name": "needsRotation",
1104
- "async": false,
1105
- "parameters": [],
1106
- "returnType": "boolean",
1107
+ "getActiveKey": {
1108
+ "name": "getActiveKey",
1109
+ "async": true,
1110
+ "parameters": [
1111
+ {
1112
+ "name": "tenantId",
1113
+ "type": "string",
1114
+ "optional": false
1115
+ }
1116
+ ],
1117
+ "returnType": "Promise<TenantKey | null>",
1107
1118
  "isStatic": false,
1108
1119
  "isPublic": true
1109
1120
  },
1110
- "isRetired": {
1111
- "name": "isRetired",
1112
- "async": false,
1113
- "parameters": [],
1114
- "returnType": "boolean",
1121
+ "listKeyVersions": {
1122
+ "name": "listKeyVersions",
1123
+ "async": true,
1124
+ "parameters": [
1125
+ {
1126
+ "name": "tenantId",
1127
+ "type": "string",
1128
+ "optional": false
1129
+ }
1130
+ ],
1131
+ "returnType": "Promise<TenantKey[]>",
1115
1132
  "isStatic": false,
1116
1133
  "isPublic": true
1117
1134
  },
1118
- "isCompromised": {
1119
- "name": "isCompromised",
1120
- "async": false,
1121
- "parameters": [],
1122
- "returnType": "boolean",
1135
+ "getKeyVersion": {
1136
+ "name": "getKeyVersion",
1137
+ "async": true,
1138
+ "parameters": [
1139
+ {
1140
+ "name": "tenantId",
1141
+ "type": "string",
1142
+ "optional": false
1143
+ },
1144
+ {
1145
+ "name": "version",
1146
+ "type": "number",
1147
+ "optional": false
1148
+ }
1149
+ ],
1150
+ "returnType": "Promise<TenantKey | null>",
1123
1151
  "isStatic": false,
1124
1152
  "isPublic": true
1125
1153
  },
1126
- "canDecrypt": {
1127
- "name": "canDecrypt",
1128
- "async": false,
1154
+ "findKeysNeedingRotation": {
1155
+ "name": "findKeysNeedingRotation",
1156
+ "async": true,
1129
1157
  "parameters": [],
1130
- "returnType": "boolean",
1158
+ "returnType": "Promise<TenantKey[]>",
1131
1159
  "isStatic": false,
1132
1160
  "isPublic": true
1133
1161
  },
1134
- "canEncrypt": {
1135
- "name": "canEncrypt",
1136
- "async": false,
1162
+ "listAllActiveKeys": {
1163
+ "name": "listAllActiveKeys",
1164
+ "async": true,
1137
1165
  "parameters": [],
1138
- "returnType": "boolean",
1166
+ "returnType": "Promise<TenantKey[]>",
1139
1167
  "isStatic": false,
1140
1168
  "isPublic": true
1141
1169
  },
1142
- "retire": {
1143
- "name": "retire",
1144
- "async": false,
1170
+ "countByStatus": {
1171
+ "name": "countByStatus",
1172
+ "async": true,
1145
1173
  "parameters": [],
1146
- "returnType": "void",
1174
+ "returnType": "Promise<Record<TenantKeyStatus, number>>",
1147
1175
  "isStatic": false,
1148
1176
  "isPublic": true
1149
1177
  },
1150
1178
  "markCompromised": {
1151
1179
  "name": "markCompromised",
1152
- "async": false,
1153
- "parameters": [],
1154
- "returnType": "void",
1180
+ "async": true,
1181
+ "parameters": [
1182
+ {
1183
+ "name": "tenantId",
1184
+ "type": "string",
1185
+ "optional": false
1186
+ },
1187
+ {
1188
+ "name": "keyId",
1189
+ "type": "string",
1190
+ "optional": false
1191
+ }
1192
+ ],
1193
+ "returnType": "Promise<boolean>",
1155
1194
  "isStatic": false,
1156
1195
  "isPublic": true
1157
- }
1158
- },
1159
- "decoratorConfig": {
1160
- "api": {
1161
- "include": []
1162
- },
1163
- "mcp": {
1164
- "include": []
1165
1196
  },
1166
- "cli": {
1167
- "include": [
1168
- "list",
1169
- "get"
1197
+ "cleanupRetiredKeys": {
1198
+ "name": "cleanupRetiredKeys",
1199
+ "async": true,
1200
+ "parameters": [
1201
+ {
1202
+ "name": "olderThanDays",
1203
+ "type": "number",
1204
+ "optional": true
1205
+ }
1170
1206
  ],
1171
- "skipApiCheck": true
1207
+ "returnType": "Promise<number>",
1208
+ "isStatic": false,
1209
+ "isPublic": true
1172
1210
  }
1173
1211
  },
1174
- "extends": "SmrtObject",
1175
- "exportName": "TenantKey",
1176
- "collectionExportName": "TenantKeyCollection",
1212
+ "decoratorConfig": {},
1213
+ "extends": "SmrtCollection",
1214
+ "extendsTypeArg": "TenantKey",
1215
+ "exportName": "TenantKeyCollection",
1216
+ "collectionExportName": "TenantKeyCollectionCollection",
1177
1217
  "schema": {
1178
- "tableName": "tenant_keys",
1179
- "ddl": "CREATE TABLE IF NOT EXISTS \"tenant_keys\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" TEXT DEFAULT '',\n \"wrapped_key\" TEXT DEFAULT '',\n \"amk_key_id\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'active',\n \"version\" INTEGER DEFAULT 1,\n \"rotate_after\" TIMESTAMP,\n \"retired_at\" TIMESTAMP\n);",
1218
+ "tableName": "tenant_key_collections",
1219
+ "ddl": "CREATE TABLE IF NOT EXISTS \"tenant_key_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1180
1220
  "columns": {
1181
1221
  "id": {
1182
1222
  "type": "UUID",
@@ -1202,57 +1242,17 @@
1202
1242
  "type": "TIMESTAMP",
1203
1243
  "notNull": true,
1204
1244
  "default": "current_timestamp"
1205
- },
1206
- "tenant_id": {
1207
- "type": "TEXT",
1208
- "notNull": false,
1209
- "unique": false,
1210
- "default": ""
1211
- },
1212
- "wrapped_key": {
1213
- "type": "TEXT",
1214
- "notNull": false,
1215
- "unique": false,
1216
- "default": ""
1217
- },
1218
- "amk_key_id": {
1219
- "type": "TEXT",
1220
- "notNull": false,
1221
- "unique": false,
1222
- "default": ""
1223
- },
1224
- "status": {
1225
- "type": "TEXT",
1226
- "notNull": false,
1227
- "unique": false,
1228
- "default": "active"
1229
- },
1230
- "version": {
1231
- "type": "INTEGER",
1232
- "notNull": false,
1233
- "unique": false,
1234
- "default": 1
1235
- },
1236
- "rotate_after": {
1237
- "type": "TIMESTAMP",
1238
- "notNull": false,
1239
- "unique": false
1240
- },
1241
- "retired_at": {
1242
- "type": "TIMESTAMP",
1243
- "notNull": false,
1244
- "unique": false
1245
1245
  }
1246
1246
  },
1247
1247
  "indexes": [
1248
1248
  {
1249
- "name": "tenant_keys_id_idx",
1249
+ "name": "tenant_key_collections_id_idx",
1250
1250
  "columns": [
1251
1251
  "id"
1252
1252
  ]
1253
1253
  },
1254
1254
  {
1255
- "name": "tenant_keys_slug_context_idx",
1255
+ "name": "tenant_key_collections_slug_context_idx",
1256
1256
  "columns": [
1257
1257
  "slug",
1258
1258
  "context"
@@ -1260,7 +1260,7 @@
1260
1260
  "unique": true
1261
1261
  }
1262
1262
  ],
1263
- "version": "79fd7e46"
1263
+ "version": "26616d13"
1264
1264
  }
1265
1265
  }
1266
1266
  },