@mudrichenkoevgeny/shared-foundation 0.0.50 → 0.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +15 -15
- package/index.js +68 -54
- package/index.mjs +68 -54
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1165,8 +1165,8 @@ readonly minSupportedAppVersions: Record<string, string>;
|
|
|
1165
1165
|
export declare const toOpenGlobalSettings: (payload: OpenGlobalSettingsPayload) => OpenGlobalSettings;
|
|
1166
1166
|
export declare const toOpenGlobalSettingsPayload: (domain: OpenGlobalSettings) => OpenGlobalSettingsPayload;
|
|
1167
1167
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1168
|
+
export interface AuditEvent {
|
|
1169
|
+
readonly id: AuditEventId;
|
|
1170
1170
|
readonly actorId: UserId | null;
|
|
1171
1171
|
readonly actorType: AuditActorType;
|
|
1172
1172
|
readonly actorUserRole: UserRole | null;
|
|
@@ -1178,18 +1178,18 @@ readonly status: AuditStatus;
|
|
|
1178
1178
|
readonly metadata: AuditEventMetadata[];
|
|
1179
1179
|
readonly message: string | null;
|
|
1180
1180
|
readonly createdAt: Instant;
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
export declare const toAuditEvent: (payload: AuditEventPayload, actionTypeParser: CompositeAuditActionTypeParser, resourceTypeParser: CompositeAuditResourceTypeParser, metadataKeyParser: CompositeAuditMetadataKeyParser) => AuditEvent;
|
|
1184
|
+
export declare const toAuditEventPayload: (domain: AuditEvent) => AuditEventPayload;
|
|
1185
1185
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1186
|
+
export interface AuditEventMetadata {
|
|
1187
|
+
readonly key: AuditMetadataKey;
|
|
1188
1188
|
readonly value: string;
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
export declare const toAuditEventMetadata: (payload: AuditEventMetadataPayload, metadataKeyParser: CompositeAuditMetadataKeyParser) => AuditEventMetadata;
|
|
1192
|
+
export declare const toAuditEventMetadataPayload: (domain: AuditEventMetadata) => AuditEventMetadataPayload;
|
|
1193
1193
|
|
|
1194
1194
|
export interface AuthData {
|
|
1195
1195
|
readonly userDetails: UserDetails;
|
|
@@ -1369,17 +1369,17 @@ export interface AuditResourceTypeParser {
|
|
|
1369
1369
|
}
|
|
1370
1370
|
|
|
1371
1371
|
export declare class CompositeAuditActionTypeParser {
|
|
1372
|
-
constructor(auditActionTypes: Array<((value: string) => AuditActionType | null) | AuditActionTypeParser
|
|
1372
|
+
constructor(auditActionTypes: Array<((value: string) => AuditActionType | null) | AuditActionTypeParser | Record<string, string>>);
|
|
1373
1373
|
fromValueOrThrow(value: string): AuditActionType;
|
|
1374
1374
|
}
|
|
1375
1375
|
|
|
1376
1376
|
export declare class CompositeAuditMetadataKeyParser {
|
|
1377
|
-
constructor(metadataKeys: Array<((value: string) => AuditMetadataKey | null) | AuditMetadataKeyParser
|
|
1377
|
+
constructor(metadataKeys: Array<((value: string) => AuditMetadataKey | null) | AuditMetadataKeyParser | Record<string, string>>);
|
|
1378
1378
|
fromValueOrThrow(value: string): AuditMetadataKey;
|
|
1379
1379
|
}
|
|
1380
1380
|
|
|
1381
1381
|
export declare class CompositeAuditResourceTypeParser {
|
|
1382
|
-
constructor(auditResourceTypes: Array<((value: string) => AuditResourceType | null) | AuditResourceTypeParser
|
|
1382
|
+
constructor(auditResourceTypes: Array<((value: string) => AuditResourceType | null) | AuditResourceTypeParser | Record<string, string>>);
|
|
1383
1383
|
fromValueOrThrow(value: string): AuditResourceType;
|
|
1384
1384
|
}
|
|
1385
1385
|
|
package/index.js
CHANGED
|
@@ -295,11 +295,16 @@ export const refreshTokenHashSchema = z.string().transform((val, ctx) => {
|
|
|
295
295
|
|
|
296
296
|
fromValueOrThrow(value) {
|
|
297
297
|
for (const parse of this.auditActionTypes) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (
|
|
302
|
-
|
|
298
|
+
if (typeof parse === 'function') {
|
|
299
|
+
const result = parse(value);
|
|
300
|
+
if (result !== null && result !== undefined) return result;
|
|
301
|
+
} else if (parse && typeof parse.parseOrNull === 'function') {
|
|
302
|
+
const result = parse.parseOrNull(value);
|
|
303
|
+
if (result !== null && result !== undefined) return result;
|
|
304
|
+
} else if (parse && typeof parse === 'object') {
|
|
305
|
+
// Support passing the enum object directly (e.g. UserAuditActionType)
|
|
306
|
+
const matchedValue = Object.values(parse).find(val => val === value);
|
|
307
|
+
if (matchedValue !== undefined) return matchedValue;
|
|
303
308
|
}
|
|
304
309
|
}
|
|
305
310
|
throw new Error("Unknown value of AuditActionType: '" + value + "'");
|
|
@@ -313,11 +318,15 @@ export class CompositeAuditMetadataKeyParser {
|
|
|
313
318
|
|
|
314
319
|
fromValueOrThrow(value) {
|
|
315
320
|
for (const parse of this.metadataKeys) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
+
if (typeof parse === 'function') {
|
|
322
|
+
const result = parse(value);
|
|
323
|
+
if (result !== null && result !== undefined) return result;
|
|
324
|
+
} else if (parse && typeof parse.parseOrNull === 'function') {
|
|
325
|
+
const result = parse.parseOrNull(value);
|
|
326
|
+
if (result !== null && result !== undefined) return result;
|
|
327
|
+
} else if (parse && typeof parse === 'object') {
|
|
328
|
+
const matchedValue = Object.values(parse).find(val => val === value);
|
|
329
|
+
if (matchedValue !== undefined) return matchedValue;
|
|
321
330
|
}
|
|
322
331
|
}
|
|
323
332
|
throw new Error("Unknown value of AuditMetadataKey: '" + value + "'");
|
|
@@ -331,11 +340,15 @@ export class CompositeAuditResourceTypeParser {
|
|
|
331
340
|
|
|
332
341
|
fromValueOrThrow(value) {
|
|
333
342
|
for (const parse of this.auditResourceTypes) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
|
|
343
|
+
if (typeof parse === 'function') {
|
|
344
|
+
const result = parse(value);
|
|
345
|
+
if (result !== null && result !== undefined) return result;
|
|
346
|
+
} else if (parse && typeof parse.parseOrNull === 'function') {
|
|
347
|
+
const result = parse.parseOrNull(value);
|
|
348
|
+
if (result !== null && result !== undefined) return result;
|
|
349
|
+
} else if (parse && typeof parse === 'object') {
|
|
350
|
+
const matchedValue = Object.values(parse).find(val => val === value);
|
|
351
|
+
if (matchedValue !== undefined) return matchedValue;
|
|
339
352
|
}
|
|
340
353
|
}
|
|
341
354
|
throw new Error("Unknown value of AuditResourceType: '" + value + "'");
|
|
@@ -1220,45 +1233,46 @@ contact_support_email: domain.contactSupportEmail,
|
|
|
1220
1233
|
min_supported_app_versions: domain.minSupportedAppVersions
|
|
1221
1234
|
});
|
|
1222
1235
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
actorId: payload.
|
|
1226
|
-
actorType: payload.
|
|
1227
|
-
actorUserRole: payload.
|
|
1228
|
-
action: payload.action,
|
|
1229
|
-
resource: payload.resource,
|
|
1230
|
-
resourceId: payload.
|
|
1231
|
-
resourceValueSensitivity:
|
|
1232
|
-
status: payload.status,
|
|
1233
|
-
metadata: payload.metadata ? payload.metadata.map(val => toAuditEventMetadata(val)) : [],
|
|
1234
|
-
message: payload.message,
|
|
1235
|
-
createdAt: payload.
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
action: domain.action,
|
|
1244
|
-
resource: domain.resource,
|
|
1245
|
-
|
|
1246
|
-
status: domain.status,
|
|
1247
|
-
metadata: domain.metadata ? domain.metadata.map(val => toAuditEventMetadataPayload(val)) : [],
|
|
1248
|
-
message: domain.message,
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
value: payload.value
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1236
|
+
export const toAuditEvent = (payload, actionTypeParser, resourceTypeParser, metadataKeyParser) => ({
|
|
1237
|
+
id: toAuditEventIdOrThrow(payload.id),
|
|
1238
|
+
actorId: payload.actorId,
|
|
1239
|
+
actorType: payload.actorType,
|
|
1240
|
+
actorUserRole: payload.actorUserRole,
|
|
1241
|
+
action: actionTypeParser.fromValueOrThrow(payload.action),
|
|
1242
|
+
resource: resourceTypeParser.fromValueOrThrow(payload.resource),
|
|
1243
|
+
resourceId: payload.resourceId,
|
|
1244
|
+
resourceValueSensitivity: 'non_sensitive',
|
|
1245
|
+
status: payload.status,
|
|
1246
|
+
metadata: payload.metadata ? payload.metadata.map(val => toAuditEventMetadata(val, metadataKeyParser)) : [],
|
|
1247
|
+
message: payload.message,
|
|
1248
|
+
createdAt: payload.createdAt
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
export const toAuditEventPayload = (domain) => ({
|
|
1252
|
+
id: domain.id,
|
|
1253
|
+
actorId: domain.actorId,
|
|
1254
|
+
actorType: domain.actorType,
|
|
1255
|
+
actorUserRole: domain.actorUserRole,
|
|
1256
|
+
action: domain.action,
|
|
1257
|
+
resource: domain.resource,
|
|
1258
|
+
resourceId: domain.resourceId,
|
|
1259
|
+
status: domain.status,
|
|
1260
|
+
metadata: domain.metadata ? domain.metadata.map(val => toAuditEventMetadataPayload(val)) : [],
|
|
1261
|
+
message: domain.message,
|
|
1262
|
+
createdAt: domain.createdAt
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
export const toAuditEventMetadata = (payload, metadataKeyParser) => ({
|
|
1266
|
+
key: metadataKeyParser.fromValueOrThrow(payload.key),
|
|
1267
|
+
value: payload.value,
|
|
1268
|
+
valueSensitivity: payload.valueSensitivity
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
export const toAuditEventMetadataPayload = (domain) => ({
|
|
1272
|
+
key: domain.key,
|
|
1273
|
+
value: domain.value,
|
|
1274
|
+
valueSensitivity: domain.valueSensitivity
|
|
1275
|
+
});
|
|
1262
1276
|
|
|
1263
1277
|
export const toAuthData = (payload) => ({
|
|
1264
1278
|
userDetails: toUserDetails(payload.user),
|
package/index.mjs
CHANGED
|
@@ -295,11 +295,16 @@ export const refreshTokenHashSchema = z.string().transform((val, ctx) => {
|
|
|
295
295
|
|
|
296
296
|
fromValueOrThrow(value) {
|
|
297
297
|
for (const parse of this.auditActionTypes) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (
|
|
302
|
-
|
|
298
|
+
if (typeof parse === 'function') {
|
|
299
|
+
const result = parse(value);
|
|
300
|
+
if (result !== null && result !== undefined) return result;
|
|
301
|
+
} else if (parse && typeof parse.parseOrNull === 'function') {
|
|
302
|
+
const result = parse.parseOrNull(value);
|
|
303
|
+
if (result !== null && result !== undefined) return result;
|
|
304
|
+
} else if (parse && typeof parse === 'object') {
|
|
305
|
+
// Support passing the enum object directly (e.g. UserAuditActionType)
|
|
306
|
+
const matchedValue = Object.values(parse).find(val => val === value);
|
|
307
|
+
if (matchedValue !== undefined) return matchedValue;
|
|
303
308
|
}
|
|
304
309
|
}
|
|
305
310
|
throw new Error("Unknown value of AuditActionType: '" + value + "'");
|
|
@@ -313,11 +318,15 @@ export class CompositeAuditMetadataKeyParser {
|
|
|
313
318
|
|
|
314
319
|
fromValueOrThrow(value) {
|
|
315
320
|
for (const parse of this.metadataKeys) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
+
if (typeof parse === 'function') {
|
|
322
|
+
const result = parse(value);
|
|
323
|
+
if (result !== null && result !== undefined) return result;
|
|
324
|
+
} else if (parse && typeof parse.parseOrNull === 'function') {
|
|
325
|
+
const result = parse.parseOrNull(value);
|
|
326
|
+
if (result !== null && result !== undefined) return result;
|
|
327
|
+
} else if (parse && typeof parse === 'object') {
|
|
328
|
+
const matchedValue = Object.values(parse).find(val => val === value);
|
|
329
|
+
if (matchedValue !== undefined) return matchedValue;
|
|
321
330
|
}
|
|
322
331
|
}
|
|
323
332
|
throw new Error("Unknown value of AuditMetadataKey: '" + value + "'");
|
|
@@ -331,11 +340,15 @@ export class CompositeAuditResourceTypeParser {
|
|
|
331
340
|
|
|
332
341
|
fromValueOrThrow(value) {
|
|
333
342
|
for (const parse of this.auditResourceTypes) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
|
|
343
|
+
if (typeof parse === 'function') {
|
|
344
|
+
const result = parse(value);
|
|
345
|
+
if (result !== null && result !== undefined) return result;
|
|
346
|
+
} else if (parse && typeof parse.parseOrNull === 'function') {
|
|
347
|
+
const result = parse.parseOrNull(value);
|
|
348
|
+
if (result !== null && result !== undefined) return result;
|
|
349
|
+
} else if (parse && typeof parse === 'object') {
|
|
350
|
+
const matchedValue = Object.values(parse).find(val => val === value);
|
|
351
|
+
if (matchedValue !== undefined) return matchedValue;
|
|
339
352
|
}
|
|
340
353
|
}
|
|
341
354
|
throw new Error("Unknown value of AuditResourceType: '" + value + "'");
|
|
@@ -1220,45 +1233,46 @@ contact_support_email: domain.contactSupportEmail,
|
|
|
1220
1233
|
min_supported_app_versions: domain.minSupportedAppVersions
|
|
1221
1234
|
});
|
|
1222
1235
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
actorId: payload.
|
|
1226
|
-
actorType: payload.
|
|
1227
|
-
actorUserRole: payload.
|
|
1228
|
-
action: payload.action,
|
|
1229
|
-
resource: payload.resource,
|
|
1230
|
-
resourceId: payload.
|
|
1231
|
-
resourceValueSensitivity:
|
|
1232
|
-
status: payload.status,
|
|
1233
|
-
metadata: payload.metadata ? payload.metadata.map(val => toAuditEventMetadata(val)) : [],
|
|
1234
|
-
message: payload.message,
|
|
1235
|
-
createdAt: payload.
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
action: domain.action,
|
|
1244
|
-
resource: domain.resource,
|
|
1245
|
-
|
|
1246
|
-
status: domain.status,
|
|
1247
|
-
metadata: domain.metadata ? domain.metadata.map(val => toAuditEventMetadataPayload(val)) : [],
|
|
1248
|
-
message: domain.message,
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
value: payload.value
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1236
|
+
export const toAuditEvent = (payload, actionTypeParser, resourceTypeParser, metadataKeyParser) => ({
|
|
1237
|
+
id: toAuditEventIdOrThrow(payload.id),
|
|
1238
|
+
actorId: payload.actorId,
|
|
1239
|
+
actorType: payload.actorType,
|
|
1240
|
+
actorUserRole: payload.actorUserRole,
|
|
1241
|
+
action: actionTypeParser.fromValueOrThrow(payload.action),
|
|
1242
|
+
resource: resourceTypeParser.fromValueOrThrow(payload.resource),
|
|
1243
|
+
resourceId: payload.resourceId,
|
|
1244
|
+
resourceValueSensitivity: 'non_sensitive',
|
|
1245
|
+
status: payload.status,
|
|
1246
|
+
metadata: payload.metadata ? payload.metadata.map(val => toAuditEventMetadata(val, metadataKeyParser)) : [],
|
|
1247
|
+
message: payload.message,
|
|
1248
|
+
createdAt: payload.createdAt
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
export const toAuditEventPayload = (domain) => ({
|
|
1252
|
+
id: domain.id,
|
|
1253
|
+
actorId: domain.actorId,
|
|
1254
|
+
actorType: domain.actorType,
|
|
1255
|
+
actorUserRole: domain.actorUserRole,
|
|
1256
|
+
action: domain.action,
|
|
1257
|
+
resource: domain.resource,
|
|
1258
|
+
resourceId: domain.resourceId,
|
|
1259
|
+
status: domain.status,
|
|
1260
|
+
metadata: domain.metadata ? domain.metadata.map(val => toAuditEventMetadataPayload(val)) : [],
|
|
1261
|
+
message: domain.message,
|
|
1262
|
+
createdAt: domain.createdAt
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
export const toAuditEventMetadata = (payload, metadataKeyParser) => ({
|
|
1266
|
+
key: metadataKeyParser.fromValueOrThrow(payload.key),
|
|
1267
|
+
value: payload.value,
|
|
1268
|
+
valueSensitivity: payload.valueSensitivity
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
export const toAuditEventMetadataPayload = (domain) => ({
|
|
1272
|
+
key: domain.key,
|
|
1273
|
+
value: domain.value,
|
|
1274
|
+
valueSensitivity: domain.valueSensitivity
|
|
1275
|
+
});
|
|
1262
1276
|
|
|
1263
1277
|
export const toAuthData = (payload) => ({
|
|
1264
1278
|
userDetails: toUserDetails(payload.user),
|