@forklaunch/core 1.5.1 → 1.5.3
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/lib/cache/{index.d.mts → cacheKey.d.ts} +2 -6
- package/lib/cache/cacheKey.d.ts.map +1 -0
- package/lib/cache/index.d.ts +4 -15
- package/lib/cache/index.d.ts.map +1 -0
- package/lib/{ttlCache.interface-B3xaLT00.d.ts → cache/interfaces/ttlCache.interface.d.ts} +3 -5
- package/lib/cache/interfaces/ttlCache.interface.d.ts.map +1 -0
- package/lib/{ttlCacheRecord.types-oX0ti5SP.d.mts → cache/types/ttlCacheRecord.types.d.ts} +3 -4
- package/lib/cache/types/ttlCacheRecord.types.d.ts.map +1 -0
- package/lib/controllers/index.d.ts +2 -13
- package/lib/controllers/index.d.ts.map +1 -0
- package/lib/controllers/{index.d.mts → interfaces/controller.interface.d.ts} +2 -3
- package/lib/controllers/interfaces/controller.interface.d.ts.map +1 -0
- package/lib/environment/index.d.ts +2 -28
- package/lib/environment/index.d.ts.map +1 -0
- package/lib/environment/{index.d.mts → loadCascadingEnv.d.ts} +4 -5
- package/lib/environment/loadCascadingEnv.d.ts.map +1 -0
- package/lib/http/application/expressLikeApplication.d.ts +34 -0
- package/lib/http/application/expressLikeApplication.d.ts.map +1 -0
- package/lib/http/bootstrap/listen.d.ts +2 -0
- package/lib/http/bootstrap/listen.d.ts.map +1 -0
- package/lib/http/cluster/cluster.types.d.ts +17 -0
- package/lib/http/cluster/cluster.types.d.ts.map +1 -0
- package/lib/http/cluster/isPortBound.d.ts +2 -0
- package/lib/http/cluster/isPortBound.d.ts.map +1 -0
- package/lib/http/createHmacToken.d.ts +19 -0
- package/lib/http/createHmacToken.d.ts.map +1 -0
- package/lib/http/discriminateAuthMethod.d.ts +85 -0
- package/lib/http/discriminateAuthMethod.d.ts.map +1 -0
- package/lib/http/generateHmacAuthHeaders.d.ts +31 -0
- package/lib/http/generateHmacAuthHeaders.d.ts.map +1 -0
- package/lib/http/guards/hasFeatureChecks.d.ts +2 -0
- package/lib/http/guards/hasFeatureChecks.d.ts.map +1 -0
- package/lib/http/guards/hasPermissionChecks.d.ts +2 -0
- package/lib/http/guards/hasPermissionChecks.d.ts.map +1 -0
- package/lib/http/guards/hasRoleChecks.d.ts +2 -0
- package/lib/http/guards/hasRoleChecks.d.ts.map +1 -0
- package/lib/http/guards/hasScopeChecks.d.ts +2 -0
- package/lib/http/guards/hasScopeChecks.d.ts.map +1 -0
- package/lib/http/guards/hasSend.d.ts +17 -0
- package/lib/http/guards/hasSend.d.ts.map +1 -0
- package/lib/http/guards/hasSubscriptionChecks.d.ts +2 -0
- package/lib/http/guards/hasSubscriptionChecks.d.ts.map +1 -0
- package/lib/http/guards/hasVersionedSchema.d.ts +2 -0
- package/lib/http/guards/hasVersionedSchema.d.ts.map +1 -0
- package/lib/http/guards/isBasicAuthMethod.d.ts +3 -0
- package/lib/http/guards/isBasicAuthMethod.d.ts.map +1 -0
- package/lib/http/guards/isConstrainedForklaunchRouter.d.ts +21 -0
- package/lib/http/guards/isConstrainedForklaunchRouter.d.ts.map +1 -0
- package/lib/http/guards/isExpressLikeSchemaHandler.d.ts +32 -0
- package/lib/http/guards/isExpressLikeSchemaHandler.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchExpressLikeRouter.d.ts +28 -0
- package/lib/http/guards/isForklaunchExpressLikeRouter.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchRequest.d.ts +26 -0
- package/lib/http/guards/isForklaunchRequest.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchResponse.d.ts +23 -0
- package/lib/http/guards/isForklaunchResponse.d.ts.map +1 -0
- package/lib/http/guards/isForklaunchRouter.d.ts +21 -0
- package/lib/http/guards/isForklaunchRouter.d.ts.map +1 -0
- package/lib/http/guards/isHmacMethod.d.ts +9 -0
- package/lib/http/guards/isHmacMethod.d.ts.map +1 -0
- package/lib/http/guards/isHttpContractDetails.d.ts +29 -0
- package/lib/http/guards/isHttpContractDetails.d.ts.map +1 -0
- package/lib/http/guards/isJwtAuthMethod.d.ts +3 -0
- package/lib/http/guards/isJwtAuthMethod.d.ts.map +1 -0
- package/lib/http/guards/isLoggerMeta.d.ts +3 -0
- package/lib/http/guards/isLoggerMeta.d.ts.map +1 -0
- package/lib/http/guards/isPath.d.ts +2 -0
- package/lib/http/guards/isPath.d.ts.map +1 -0
- package/lib/http/guards/isPathParamContractDetails.d.ts +4 -0
- package/lib/http/guards/isPathParamContractDetails.d.ts.map +1 -0
- package/lib/http/guards/isRequestShape.d.ts +3 -0
- package/lib/http/guards/isRequestShape.d.ts.map +1 -0
- package/lib/http/guards/isResponseCompiledSchema.d.ts +3 -0
- package/lib/http/guards/isResponseCompiledSchema.d.ts.map +1 -0
- package/lib/http/guards/isSdkHandler.d.ts +9 -0
- package/lib/http/guards/isSdkHandler.d.ts.map +1 -0
- package/lib/http/guards/isSdkRouter.d.ts +9 -0
- package/lib/http/guards/isSdkRouter.d.ts.map +1 -0
- package/lib/http/guards/isTypedHandler.d.ts +5 -0
- package/lib/http/guards/isTypedHandler.d.ts.map +1 -0
- package/lib/http/guards/isVersionedInputSchema.d.ts +3 -0
- package/lib/http/guards/isVersionedInputSchema.d.ts.map +1 -0
- package/lib/http/handlers/delete.d.ts +5 -0
- package/lib/http/handlers/delete.d.ts.map +1 -0
- package/lib/http/handlers/get.d.ts +5 -0
- package/lib/http/handlers/get.d.ts.map +1 -0
- package/lib/http/handlers/head.d.ts +5 -0
- package/lib/http/handlers/head.d.ts.map +1 -0
- package/lib/http/handlers/middleware.d.ts +10 -0
- package/lib/http/handlers/middleware.d.ts.map +1 -0
- package/lib/http/handlers/options.d.ts +5 -0
- package/lib/http/handlers/options.d.ts.map +1 -0
- package/lib/http/handlers/patch.d.ts +5 -0
- package/lib/http/handlers/patch.d.ts.map +1 -0
- package/lib/http/handlers/post.d.ts +5 -0
- package/lib/http/handlers/post.d.ts.map +1 -0
- package/lib/http/handlers/put.d.ts +5 -0
- package/lib/http/handlers/put.d.ts.map +1 -0
- package/lib/http/handlers/trace.d.ts +5 -0
- package/lib/http/handlers/trace.d.ts.map +1 -0
- package/lib/http/handlers/typedAuthHandler.d.ts +5 -0
- package/lib/http/handlers/typedAuthHandler.d.ts.map +1 -0
- package/lib/http/handlers/typedHandler.d.ts +14 -0
- package/lib/http/handlers/typedHandler.d.ts.map +1 -0
- package/lib/http/httpStatusCodes.d.ts +75 -0
- package/lib/http/httpStatusCodes.d.ts.map +1 -0
- package/lib/http/index.d.ts +47 -1244
- package/lib/http/index.d.ts.map +1 -0
- package/lib/http/index.js +445 -410
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +439 -407
- package/lib/http/index.mjs.map +1 -1
- package/lib/http/interfaces/expressLikeRouter.interface.d.ts +25 -0
- package/lib/http/interfaces/expressLikeRouter.interface.d.ts.map +1 -0
- package/lib/http/mcpGenerator/mcpGenerator.d.ts +17 -0
- package/lib/http/mcpGenerator/mcpGenerator.d.ts.map +1 -0
- package/lib/http/middleware/request/auth.middleware.d.ts +16 -0
- package/lib/http/middleware/request/auth.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/cors.middleware.d.ts +13 -0
- package/lib/http/middleware/request/cors.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/createContext.middleware.d.ts +15 -0
- package/lib/http/middleware/request/createContext.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/enrichDetails.middleware.d.ts +18 -0
- package/lib/http/middleware/request/enrichDetails.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/parse.middleware.d.ts +17 -0
- package/lib/http/middleware/request/parse.middleware.d.ts.map +1 -0
- package/lib/http/middleware/request/tenantContext.middleware.d.ts +41 -0
- package/lib/http/middleware/request/tenantContext.middleware.d.ts.map +1 -0
- package/lib/http/middleware/response/enrichExpressLikeSend.middleware.d.ts +32 -0
- package/lib/http/middleware/response/enrichExpressLikeSend.middleware.d.ts.map +1 -0
- package/lib/http/middleware/response/parse.middleware.d.ts +31 -0
- package/lib/http/middleware/response/parse.middleware.d.ts.map +1 -0
- package/lib/http/openApiV3Generator/openApiV3Generator.d.ts +17 -0
- package/lib/http/openApiV3Generator/openApiV3Generator.d.ts.map +1 -0
- package/lib/http/rateLimit/index.d.ts +2 -0
- package/lib/http/rateLimit/index.d.ts.map +1 -0
- package/lib/http/rateLimit/rateLimiter.d.ts +66 -0
- package/lib/http/rateLimit/rateLimiter.d.ts.map +1 -0
- package/lib/http/router/discriminateBody.d.ts +43 -0
- package/lib/http/router/discriminateBody.d.ts.map +1 -0
- package/lib/http/router/expressLikeRouter.d.ts +240 -0
- package/lib/http/router/expressLikeRouter.d.ts.map +1 -0
- package/lib/http/router/routerSharedLogic.d.ts +50 -0
- package/lib/http/router/routerSharedLogic.d.ts.map +1 -0
- package/lib/http/router/unpackRouters.d.ts +7 -0
- package/lib/http/router/unpackRouters.d.ts.map +1 -0
- package/lib/http/telemetry/auditLogger.d.ts +21 -0
- package/lib/http/telemetry/auditLogger.d.ts.map +1 -0
- package/lib/http/telemetry/constants.d.ts +6 -0
- package/lib/http/telemetry/constants.d.ts.map +1 -0
- package/lib/http/telemetry/evaluateTelemetryOptions.d.ts +11 -0
- package/lib/http/telemetry/evaluateTelemetryOptions.d.ts.map +1 -0
- package/lib/http/telemetry/metricsDefinition.d.ts +3 -0
- package/lib/http/telemetry/metricsDefinition.d.ts.map +1 -0
- package/lib/http/telemetry/openTelemetryCollector.d.ts +53 -0
- package/lib/http/telemetry/openTelemetryCollector.d.ts.map +1 -0
- package/lib/http/telemetry/pinoLogger.d.ts +20 -0
- package/lib/http/telemetry/pinoLogger.d.ts.map +1 -0
- package/lib/http/telemetry/recordMetric.d.ts +5 -0
- package/lib/http/telemetry/recordMetric.d.ts.map +1 -0
- package/lib/http/types/apiDefinition.types.d.ts +471 -0
- package/lib/http/types/apiDefinition.types.d.ts.map +1 -0
- package/lib/http/types/contractDetails.types.d.ts +404 -0
- package/lib/http/types/contractDetails.types.d.ts.map +1 -0
- package/lib/http/types/docsConfiguration.types.d.ts +7 -0
- package/lib/http/types/docsConfiguration.types.d.ts.map +1 -0
- package/lib/http/types/expressLikeOptions.d.ts +224 -0
- package/lib/http/types/expressLikeOptions.d.ts.map +1 -0
- package/lib/http/types/expressLikeRouter.types.d.ts +127 -0
- package/lib/http/types/expressLikeRouter.types.d.ts.map +1 -0
- package/lib/http/types/openTelemetryCollector.types.d.ts +21 -0
- package/lib/http/types/openTelemetryCollector.types.d.ts.map +1 -0
- package/lib/http/types/router.types.d.ts +52 -0
- package/lib/http/types/router.types.d.ts.map +1 -0
- package/lib/http/types/sdk.types.d.ts +259 -0
- package/lib/http/types/sdk.types.d.ts.map +1 -0
- package/lib/http/types/typedHandler.types.d.ts +18 -0
- package/lib/http/types/typedHandler.types.d.ts.map +1 -0
- package/lib/mappers/guards/isSchemaResolutionFunction.d.ts +10 -0
- package/lib/mappers/guards/isSchemaResolutionFunction.d.ts.map +1 -0
- package/lib/mappers/index.d.ts +3 -68
- package/lib/mappers/index.d.ts.map +1 -0
- package/lib/mappers/mapServiceSchemas.d.ts +33 -0
- package/lib/mappers/mapServiceSchemas.d.ts.map +1 -0
- package/lib/mappers/mapper.d.ts +26 -0
- package/lib/mappers/mapper.d.ts.map +1 -0
- package/lib/mappers/types/schemaResolution.types.d.ts +9 -0
- package/lib/mappers/types/schemaResolution.types.d.ts.map +1 -0
- package/lib/objectstore/index.d.ts +3 -71
- package/lib/objectstore/index.d.ts.map +1 -0
- package/lib/objectstore/{index.d.mts → interfaces/objectstore.interface.d.ts} +3 -16
- package/lib/objectstore/interfaces/objectstore.interface.d.ts.map +1 -0
- package/lib/objectstore/objectstoreKey.d.ts +11 -0
- package/lib/objectstore/objectstoreKey.d.ts.map +1 -0
- package/lib/persistence/complianceEventSubscriber.d.ts +13 -0
- package/lib/persistence/complianceEventSubscriber.d.ts.map +1 -0
- package/lib/persistence/compliancePropertyBuilder.d.ts +26 -0
- package/lib/persistence/compliancePropertyBuilder.d.ts.map +1 -0
- package/lib/persistence/complianceTypes.d.ts +64 -0
- package/lib/persistence/complianceTypes.d.ts.map +1 -0
- package/lib/persistence/defineComplianceEntity.d.ts +19 -0
- package/lib/persistence/defineComplianceEntity.d.ts.map +1 -0
- package/lib/persistence/encryptedType.d.ts +85 -0
- package/lib/persistence/encryptedType.d.ts.map +1 -0
- package/lib/persistence/fieldEncryptor.d.ts +48 -0
- package/lib/persistence/fieldEncryptor.d.ts.map +1 -0
- package/lib/persistence/index.d.ts +10 -403
- package/lib/persistence/index.d.ts.map +1 -0
- package/lib/persistence/index.js.map +1 -1
- package/lib/persistence/index.mjs.map +1 -1
- package/lib/persistence/rls.d.ts +56 -0
- package/lib/persistence/rls.d.ts.map +1 -0
- package/lib/persistence/tenantEm.d.ts +60 -0
- package/lib/persistence/tenantEm.d.ts.map +1 -0
- package/lib/persistence/tenantFilter.d.ts +47 -0
- package/lib/persistence/tenantFilter.d.ts.map +1 -0
- package/lib/secrets/index.d.ts +2 -0
- package/lib/secrets/index.d.ts.map +1 -0
- package/lib/secrets/secretsAccessor.d.ts +17 -0
- package/lib/secrets/secretsAccessor.d.ts.map +1 -0
- package/lib/services/complianceDataService.d.ts +47 -0
- package/lib/services/complianceDataService.d.ts.map +1 -0
- package/lib/services/configInjector.d.ts +43 -0
- package/lib/services/configInjector.d.ts.map +1 -0
- package/lib/services/guards/isConstructed.d.ts +3 -0
- package/lib/services/guards/isConstructed.d.ts.map +1 -0
- package/lib/services/guards/isConstructedSingleton.d.ts +3 -0
- package/lib/services/guards/isConstructedSingleton.d.ts.map +1 -0
- package/lib/services/guards/isConstructor.d.ts +3 -0
- package/lib/services/guards/isConstructor.d.ts.map +1 -0
- package/lib/services/index.d.ts +10 -184
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/retentionService.d.ts +31 -0
- package/lib/services/retentionService.d.ts.map +1 -0
- package/lib/services/runRetentionEnforcement.d.ts +19 -0
- package/lib/services/runRetentionEnforcement.d.ts.map +1 -0
- package/lib/services/types/configInjector.types.d.ts +39 -0
- package/lib/services/types/configInjector.types.d.ts.map +1 -0
- package/lib/services/types/entityManager.types.d.ts +4 -0
- package/lib/services/types/entityManager.types.d.ts.map +1 -0
- package/lib/services/types/service.types.d.ts +5 -0
- package/lib/services/types/service.types.d.ts.map +1 -0
- package/lib/ws/asyncApiV3Generator/asyncApiV3Generator.d.ts +12 -0
- package/lib/ws/asyncApiV3Generator/asyncApiV3Generator.d.ts.map +1 -0
- package/lib/ws/index.d.ts +4 -67
- package/lib/ws/index.d.ts.map +1 -0
- package/lib/ws/index.js.map +1 -1
- package/lib/ws/index.mjs.map +1 -1
- package/lib/ws/types/eventSchema.types.d.ts +28 -0
- package/lib/ws/types/eventSchema.types.d.ts.map +1 -0
- package/lib/ws/webSocketLike.d.ts +18 -0
- package/lib/ws/webSocketLike.d.ts.map +1 -0
- package/package.json +47 -46
- package/LICENSE +0 -21
- package/lib/apiDefinition.types-DF_crhB0.d.mts +0 -1092
- package/lib/apiDefinition.types-DW4lfZqy.d.ts +0 -1092
- package/lib/http/index.d.mts +0 -1244
- package/lib/mappers/index.d.mts +0 -68
- package/lib/openTelemetryCollector-BS-ej09T.d.mts +0 -70
- package/lib/openTelemetryCollector-BS-ej09T.d.ts +0 -70
- package/lib/persistence/index.d.mts +0 -403
- package/lib/services/index.d.mts +0 -185
- package/lib/ttlCache.interface-CEOkrt8d.d.mts +0 -77
- package/lib/ttlCacheRecord.types-oX0ti5SP.d.ts +0 -25
- package/lib/ws/index.d.mts +0 -67
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complianceEventSubscriber.d.ts","sourceRoot":"","sources":["../../src/persistence/complianceEventSubscriber.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAwCxE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type PropertyBuilders } from '@mikro-orm/core';
|
|
2
|
+
/**
|
|
3
|
+
* ForkLaunch property builder. Drop-in replacement for MikroORM's `p`
|
|
4
|
+
* that adds `.compliance(level)` to every scalar property builder
|
|
5
|
+
* and auto-classifies relation builders as 'none'.
|
|
6
|
+
*
|
|
7
|
+
* - Scalar fields: `fp.string().compliance('pii')` — must call `.compliance()`
|
|
8
|
+
* - Relation fields: `fp.manyToOne(Target)` — auto-classified, no `.compliance()` needed
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { defineComplianceEntity, fp } from '@forklaunch/core/persistence';
|
|
13
|
+
*
|
|
14
|
+
* const User = defineComplianceEntity({
|
|
15
|
+
* name: 'User',
|
|
16
|
+
* properties: {
|
|
17
|
+
* id: fp.uuid().primary().compliance('none'),
|
|
18
|
+
* email: fp.string().unique().compliance('pii'),
|
|
19
|
+
* medicalRecord: fp.string().nullable().compliance('phi'),
|
|
20
|
+
* organization: () => fp.manyToOne(Organization).nullable(),
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const fp: PropertyBuilders;
|
|
26
|
+
//# sourceMappingURL=compliancePropertyBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compliancePropertyBuilder.d.ts","sourceRoot":"","sources":["../../src/persistence/compliancePropertyBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA8OjE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,EAAE,EAAE,gBAsCK,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare const ComplianceLevel: {
|
|
2
|
+
readonly pii: 'pii';
|
|
3
|
+
readonly phi: 'phi';
|
|
4
|
+
readonly pci: 'pci';
|
|
5
|
+
readonly none: 'none';
|
|
6
|
+
};
|
|
7
|
+
export type ComplianceLevel = (typeof ComplianceLevel)[keyof typeof ComplianceLevel];
|
|
8
|
+
export declare const COMPLIANCE_KEY: '~compliance';
|
|
9
|
+
export declare function registerEntityCompliance(entityName: string, fields: Map<string, ComplianceLevel>): void;
|
|
10
|
+
export declare function getComplianceMetadata(entityName: string, fieldName: string): ComplianceLevel;
|
|
11
|
+
export declare function getEntityComplianceFields(entityName: string): Map<string, ComplianceLevel> | undefined;
|
|
12
|
+
export declare function entityHasEncryptedFields(entityName: string): boolean;
|
|
13
|
+
export declare const RetentionAction: {
|
|
14
|
+
readonly delete: 'delete';
|
|
15
|
+
readonly anonymize: 'anonymize';
|
|
16
|
+
};
|
|
17
|
+
export type RetentionAction = (typeof RetentionAction)[keyof typeof RetentionAction];
|
|
18
|
+
export interface RetentionPolicy {
|
|
19
|
+
duration: string;
|
|
20
|
+
action: RetentionAction;
|
|
21
|
+
}
|
|
22
|
+
export declare const RetentionDuration: {
|
|
23
|
+
readonly days: (n: number) => string;
|
|
24
|
+
readonly months: (n: number) => string;
|
|
25
|
+
readonly years: (n: number) => string;
|
|
26
|
+
};
|
|
27
|
+
export interface ParsedDuration {
|
|
28
|
+
years: number;
|
|
29
|
+
months: number;
|
|
30
|
+
days: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse an ISO 8601 duration string into calendar units.
|
|
34
|
+
* Returns structured units to enable calendar-aware date arithmetic.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseDuration(iso: string): ParsedDuration;
|
|
37
|
+
/**
|
|
38
|
+
* Subtract a parsed duration from a date using calendar-aware arithmetic.
|
|
39
|
+
* Handles month-end clamping and leap years correctly.
|
|
40
|
+
*/
|
|
41
|
+
export declare function subtractDuration(from: Date, duration: ParsedDuration): Date;
|
|
42
|
+
export declare function registerEntityUserIdField(entityName: string, field: string): void;
|
|
43
|
+
export declare function getEntityUserIdField(entityName: string): string;
|
|
44
|
+
export declare function getAllUserIdFields(): ReadonlyMap<string, string>;
|
|
45
|
+
export declare function registerEntityRetention(entityName: string, policy: RetentionPolicy): void;
|
|
46
|
+
export declare function getEntityRetention(entityName: string): RetentionPolicy | undefined;
|
|
47
|
+
export declare function getAllRetentionPolicies(): ReadonlyMap<string, RetentionPolicy>;
|
|
48
|
+
/**
|
|
49
|
+
* Adds `compliance` to PropertyOptions, which flows into IncludeKeys
|
|
50
|
+
* for all scalar/enum/embedded builders (PropertyOptions is extended by
|
|
51
|
+
* EnumOptions and EmbeddedOptions). Relation builders use ReferenceOptions
|
|
52
|
+
* instead, so they don't get .compliance() — which is what we want.
|
|
53
|
+
*/
|
|
54
|
+
declare module '@mikro-orm/core' {
|
|
55
|
+
interface PropertyOptions<Owner> {
|
|
56
|
+
compliance?: ComplianceLevel;
|
|
57
|
+
}
|
|
58
|
+
interface UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys> {
|
|
59
|
+
compliance(level: ComplianceLevel): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
|
|
60
|
+
readonly '~c': true;
|
|
61
|
+
}, IncludeKeys>, IncludeKeys & keyof UniversalPropertyOptionsBuilder<never, never, never>>;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=complianceTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complianceTypes.d.ts","sourceRoot":"","sources":["../../src/persistence/complianceTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;aAC1B,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,GAAG,EAAE,KAAK;aACV,IAAI,EAAE,MAAM;CACJ,CAAC;AACX,MAAM,MAAM,eAAe,GACzB,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEzD,eAAO,MAAM,cAAc,EAAG,aAAsB,CAAC;AAQrD,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GACnC,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B,CACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,eAAe,GACtB,IAAI,CAEN;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GACjB,eAAe,GAAG,SAAS,CAE7B;AAED,wBAAgB,uBAAuB,IAAI,WAAW,CACpD,MAAM,EACN,eAAe,CAChB,CAEA;AAMD;;;;;GAKG;AACH,OAAO,QAAQ,iBAAiB,CAAC;IAE/B,UAAU,eAAe,CAAC,KAAK;QAC7B,UAAU,CAAC,EAAE,eAAe,CAAC;KAC9B;IAED,UAAU,+BAA+B,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW;QACnE,UAAU,CACR,KAAK,EAAE,eAAe,GACrB,IAAI,CACL,+BAA+B,CAC7B,KAAK,EACL,OAAO,GAAG;YAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;SAAE,EACjC,WAAW,CACZ,EACD,WAAW,GAAG,MAAM,+BAA+B,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CACzE,CAAC;KACH;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EntityMetadataWithProperties, type EntitySchemaWithMeta, type InferEntityFromProperties } from '@mikro-orm/core';
|
|
2
|
+
import { type RetentionPolicy } from './complianceTypes';
|
|
3
|
+
type ValidateProperties<T> = {
|
|
4
|
+
[K in keyof T]: T[K] extends {
|
|
5
|
+
'~options': {
|
|
6
|
+
readonly '~c': true;
|
|
7
|
+
};
|
|
8
|
+
} | ((...args: never[]) => unknown) ? T[K] : {
|
|
9
|
+
'~options': {
|
|
10
|
+
readonly '~c': true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function defineComplianceEntity<const TName extends string, const TTableName extends string, const TProperties extends Record<string, unknown>, const TPK extends (keyof TProperties)[] | undefined = undefined, const TBase = never, const TRepository = never, const TForceObject extends boolean = false>(meta: EntityMetadataWithProperties<TName, TTableName, TProperties & ValidateProperties<TProperties>, TPK, TBase, TRepository, TForceObject> & {
|
|
15
|
+
retention?: RetentionPolicy;
|
|
16
|
+
userIdField?: string;
|
|
17
|
+
}): EntitySchemaWithMeta<TName, TTableName, InferEntityFromProperties<TProperties, TPK, TBase, TRepository, TForceObject>, TBase, TProperties>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=defineComplianceEntity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineComplianceEntity.d.ts","sourceRoot":"","sources":["../../src/persistence/defineComplianceEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAOL,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,kBAAkB,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAClB;QAAE,UAAU,EAAE;YAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;SAAE,CAAA;KAAE,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,GACvE,CAAC,CAAC,CAAC,CAAC,GACJ;QAAE,UAAU,EAAE;YAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;SAAE,CAAA;KAAE;CAC5C,CAAC;AAQF,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,KAAK,SAAS,MAAM,EAC1B,KAAK,CAAC,UAAU,SAAS,MAAM,EAC/B,KAAK,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjD,KAAK,CAAC,GAAG,SAAS,CAAC,MAAM,WAAW,CAAC,EAAE,GAAG,SAAS,GAAG,SAAS,EAC/D,KAAK,CAAC,KAAK,GAAG,KAAK,EACnB,KAAK,CAAC,WAAW,GAAG,KAAK,EACzB,KAAK,CAAC,YAAY,SAAS,OAAO,GAAG,KAAK,EAE1C,IAAI,EAAE,4BAA4B,CAChC,KAAK,EACL,UAAU,EACV,WAAW,GAAG,kBAAkB,CAAC,WAAW,CAAC,EAC7C,GAAG,EACH,KAAK,EACL,WAAW,EACX,YAAY,CACb,GAAG;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD,oBAAoB,CACrB,KAAK,EACL,UAAU,EACV,yBAAyB,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,CAAC,EAC7E,KAAK,EACL,WAAW,CACZ,CAwEA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Type, type Platform, type TransformContext } from '@mikro-orm/core';
|
|
2
|
+
import type { FieldEncryptor } from './fieldEncryptor';
|
|
3
|
+
/**
|
|
4
|
+
* Register the FieldEncryptor instance for use by EncryptedType.
|
|
5
|
+
* Call this once at application bootstrap (e.g., in mikro-orm.config.ts).
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerEncryptor(encryptor: FieldEncryptor): void;
|
|
8
|
+
/**
|
|
9
|
+
* Set the encryption tenant ID for the current async context.
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT: this uses `AsyncLocalStorage.enterWith`, which mutates the
|
|
12
|
+
* current async resource's store. It does NOT reliably propagate through
|
|
13
|
+
* `pg` connection pool callback async resources — pooled connections are
|
|
14
|
+
* long-lived async resources created at pool init, and resumption
|
|
15
|
+
* callbacks run in the pool's resource, not the caller's. As a result,
|
|
16
|
+
* MikroORM hydration of encrypted columns can read an empty / wrong
|
|
17
|
+
* tenant id from `getCurrentTenantId()` even when this was called
|
|
18
|
+
* correctly at the start of the request.
|
|
19
|
+
*
|
|
20
|
+
* Prefer `withEncryptionContext(tenantId, fn)` (or the
|
|
21
|
+
* `wrapEmWithTenantContext` helper) for any code path that hits the
|
|
22
|
+
* database. `setEncryptionTenantId` remains useful as a best-effort seed
|
|
23
|
+
* for purely synchronous code paths.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setEncryptionTenantId(tenantId: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Run `fn` inside a fresh AsyncLocalStorage scope bound to `tenantId`.
|
|
28
|
+
*
|
|
29
|
+
* Unlike `setEncryptionTenantId`, this uses `AsyncLocalStorage.run`, which
|
|
30
|
+
* creates a new async resource bound to the store. Node's promise hooks
|
|
31
|
+
* propagate the store forward through pool callback async resources, so
|
|
32
|
+
* MikroORM hydration of encrypted columns inside `fn` (even after multiple
|
|
33
|
+
* awaits and a pg pool roundtrip) sees the correct tenant id.
|
|
34
|
+
*
|
|
35
|
+
* Most application code should not call this directly — use
|
|
36
|
+
* `wrapEmWithTenantContext(em, tenantId)` in your DI EntityManager
|
|
37
|
+
* factory and every method on the returned EM will be wrapped
|
|
38
|
+
* automatically.
|
|
39
|
+
*/
|
|
40
|
+
export declare function withEncryptionContext<T>(tenantId: string, fn: () => T): T;
|
|
41
|
+
/**
|
|
42
|
+
* Get the current tenant ID. Returns empty string when no context is set
|
|
43
|
+
* (startup, seeders, better-auth, background jobs).
|
|
44
|
+
*/
|
|
45
|
+
export declare function getCurrentTenantId(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve a MikroORM type value (string, constructor, or instance) to a
|
|
48
|
+
* Type instance. Returns undefined if unresolvable.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveTypeInstance(type: unknown): Type<unknown, unknown> | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* MikroORM custom Type that transparently encrypts/decrypts values.
|
|
53
|
+
*
|
|
54
|
+
* Works with any JS type. Non-string values are serialized before
|
|
55
|
+
* encryption and hydrated after decryption using the original Type's
|
|
56
|
+
* runtimeType for correct JS type reconstruction.
|
|
57
|
+
*
|
|
58
|
+
* DB column is always `text` — the encrypted ciphertext is a string
|
|
59
|
+
* regardless of the original JS type.
|
|
60
|
+
*
|
|
61
|
+
* For array container types, the element type is tracked separately
|
|
62
|
+
* so each element is hydrated individually after decryption.
|
|
63
|
+
*/
|
|
64
|
+
export declare class EncryptedType extends Type<unknown, string | null> {
|
|
65
|
+
readonly _elementRuntimeType: string;
|
|
66
|
+
readonly _isArray: boolean;
|
|
67
|
+
readonly _enumValues: unknown[] | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* @param elementRuntimeType - The runtimeType of the (element) type,
|
|
70
|
+
* e.g. 'string', 'number', 'Date', 'bigint', 'Buffer', 'any'.
|
|
71
|
+
* @param isArray - Whether this is an array container type.
|
|
72
|
+
* @param enumValues - Optional list of allowed enum values for app-level
|
|
73
|
+
* validation (used when an enum field has encrypted compliance).
|
|
74
|
+
*/
|
|
75
|
+
constructor(elementRuntimeType?: string, isArray?: boolean, enumValues?: unknown[]);
|
|
76
|
+
convertToDatabaseValue(value: unknown, _platform: Platform, _context?: TransformContext): string | null;
|
|
77
|
+
convertToJSValue(value: string | null, _platform: Platform): unknown;
|
|
78
|
+
getColumnType(): string;
|
|
79
|
+
get runtimeType(): string;
|
|
80
|
+
ensureComparable(): boolean;
|
|
81
|
+
private serialize;
|
|
82
|
+
private deserialize;
|
|
83
|
+
private tryJsonParse;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=encryptedType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryptedType.d.ts","sourceRoot":"","sources":["../../src/persistence/encryptedType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAoBvD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAEjE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED;;;;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|
5
|
+
export declare class DecryptionError extends Error {
|
|
6
|
+
readonly name: 'DecryptionError';
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class EncryptionRequiredError extends Error {
|
|
10
|
+
readonly name: 'EncryptionRequiredError';
|
|
11
|
+
constructor(message?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class FieldEncryptor {
|
|
14
|
+
private readonly masterKey;
|
|
15
|
+
constructor(masterKey: string);
|
|
16
|
+
/**
|
|
17
|
+
* Derive a per-tenant 32-byte key using HKDF-SHA256.
|
|
18
|
+
* The master key is used as input key material and the tenantId as info context.
|
|
19
|
+
*/
|
|
20
|
+
deriveKey(tenantId: string): Buffer;
|
|
21
|
+
/**
|
|
22
|
+
* Derive a deterministic IV from the key and plaintext using HMAC-SHA256,
|
|
23
|
+
* truncated to IV_BYTES. Same plaintext + same key → same IV → same
|
|
24
|
+
* ciphertext. This enables WHERE clause matching on encrypted columns
|
|
25
|
+
* while maintaining AES-256-GCM authenticated encryption.
|
|
26
|
+
*
|
|
27
|
+
* Meets SOC 2, HIPAA, PCI DSS, GDPR requirements for encryption at rest.
|
|
28
|
+
*/
|
|
29
|
+
private deriveDeterministicIv;
|
|
30
|
+
/**
|
|
31
|
+
* Encrypt a plaintext string.
|
|
32
|
+
*
|
|
33
|
+
* Uses deterministic encryption (HMAC-derived IV) so the same plaintext
|
|
34
|
+
* always produces the same ciphertext. This enables database WHERE clause
|
|
35
|
+
* matching and UNIQUE constraints on encrypted columns.
|
|
36
|
+
*
|
|
37
|
+
* @returns Format: `v2:{base64(iv)}:{base64(authTag)}:{base64(ciphertext)}`
|
|
38
|
+
*/
|
|
39
|
+
encrypt(plaintext: string | null): string | null;
|
|
40
|
+
encrypt(plaintext: string | null, tenantId: string): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Decrypt a ciphertext string produced by {@link encrypt}.
|
|
43
|
+
* Supports both v1 (random IV) and v2 (deterministic IV) formats.
|
|
44
|
+
*/
|
|
45
|
+
decrypt(ciphertext: string | null): string | null;
|
|
46
|
+
decrypt(ciphertext: string | null, tenantId: string): string | null;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=fieldEncryptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldEncryptor.d.ts","sourceRoot":"","sources":["../../src/persistence/fieldEncryptor.ts"],"names":[],"mappings":"AAMA,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAG,2BAA2B,CAAU;IACrD,YAAY,OAAO,SAA2C,EAE7D;CACF;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAG,iBAAiB,CAAU;IAC3C,YACE,OAAO,SAAyE,EAGjF;CACF;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAG,yBAAyB,CAAU;IACnD,YACE,OAAO,SAAmE,EAG3E;CACF;AAgBD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,YAAY,SAAS,EAAE,MAAM,EAK5B;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIlC;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;IAQ7B;;;;;;;;OAQG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACjD,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAwBnE;;;OAGG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IAClD,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CA+BrE"}
|