@happyvertical/smrt-secrets 0.40.44 → 0.40.45

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