@maykonpaulo/maestro-core 0.7.0-next.0 → 0.7.0-next.1
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/dist/index.d.ts +36 -2
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -909,8 +909,29 @@ interface IntrospectionResult {
|
|
|
909
909
|
relations: RelationIntrospectionSchema[];
|
|
910
910
|
}
|
|
911
911
|
|
|
912
|
+
/**
|
|
913
|
+
* Execution context passed to an `IntrospectionProvider`. Intentionally generic and provider-agnostic:
|
|
914
|
+
* it carries cross-cutting concerns (who triggered the run, how to log, how to cancel) but never
|
|
915
|
+
* datasource-specific detail. Connection strings, hosts, ports, schemas, credentials and ORM/driver
|
|
916
|
+
* clients belong to the concrete provider's own constructor/options, not to this shared contract.
|
|
917
|
+
*/
|
|
918
|
+
interface IntrospectionContext {
|
|
919
|
+
correlationId?: string;
|
|
920
|
+
actor?: Actor;
|
|
921
|
+
metadata?: Metadata;
|
|
922
|
+
logger?: Logger;
|
|
923
|
+
signal?: AbortSignal;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Contract implemented by external adapters that discover the structure of a system or data source
|
|
928
|
+
* and report it back as an `IntrospectionResult`. The core only defines and executes this contract —
|
|
929
|
+
* it never implements a concrete provider (no database connection, driver or ORM).
|
|
930
|
+
*/
|
|
912
931
|
interface IntrospectionProvider {
|
|
913
|
-
|
|
932
|
+
/** Identifies the provider in logs and error messages, e.g. "postgres", "fake-in-memory". */
|
|
933
|
+
readonly name?: string;
|
|
934
|
+
introspect(context?: IntrospectionContext): Promise<IntrospectionResult> | IntrospectionResult;
|
|
914
935
|
}
|
|
915
936
|
|
|
916
937
|
interface YamlParser {
|
|
@@ -1072,6 +1093,19 @@ declare function validateIntrospectionResult(value: unknown): IntrospectionValid
|
|
|
1072
1093
|
*/
|
|
1073
1094
|
declare function normalizeIntrospectionResult(result: IntrospectionResult): IntrospectionResult;
|
|
1074
1095
|
|
|
1096
|
+
interface RunIntrospectionResult {
|
|
1097
|
+
/** The provider's `name`, or `"unknown"` when the provider does not declare one. */
|
|
1098
|
+
provider: string;
|
|
1099
|
+
result: IntrospectionResult;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Runs an `IntrospectionProvider`, then validates and normalizes its output before returning it. This
|
|
1103
|
+
* is the only sanctioned way to consume a provider's result: a provider can never hand back a
|
|
1104
|
+
* structurally invalid `IntrospectionResult` silently — `validateIntrospectionResult` failures and
|
|
1105
|
+
* provider exceptions both surface as a `MaestroError`.
|
|
1106
|
+
*/
|
|
1107
|
+
declare function runIntrospectionProvider(provider: IntrospectionProvider, context?: IntrospectionContext): Promise<RunIntrospectionResult>;
|
|
1108
|
+
|
|
1075
1109
|
interface GeneratedConfig {
|
|
1076
1110
|
entities: Record<string, EntitySchema>;
|
|
1077
1111
|
relations: Record<string, RelationSchema>;
|
|
@@ -1528,4 +1562,4 @@ declare class DefaultGovernanceApi implements GovernanceApi {
|
|
|
1528
1562
|
getPolicyViolations(filter?: PolicyViolationFilter): Promise<PolicyViolation[]>;
|
|
1529
1563
|
}
|
|
1530
1564
|
|
|
1531
|
-
export { type Actor, type ActorType, type AuditEvent, type AuditFilter, type AuditLevel, type AuditRecordedPayload, AuditRecorder, type AuditRepository, type AuditTimeline, type AuthorizationContext, type AuthorizationDecision, type AuthorizationDeniedPayload, type AuthorizationProvider, type AuthorizationResult, type CompileDeclarationsOptions, type ConfigProvider, type ConfirmationApproval, type ConfirmationApprovedPayload, type ConfirmationDeclaration, ConfirmationEngine, type ConfirmationRejectedPayload, type ConfirmationRepository, type ConfirmationRequest, type ConfirmationRequestedPayload, type ConfirmationStatus, ConsoleLogger, ConsoleStructuredLogger, type ConsumerActionsConfig, type ConsumerDeclaration, type ConsumerDetailConfig, type ConsumerFormConfig, type ConsumerFormsConfig, type ConsumerListConfig, type ConsumerProjectionFields, type ConsumerProjectionOperations, type ContextAction, type ContextActionCondition, type ContextActionStyle, ContextualAuthorizationEngine, type CorrelationContext, type CorrelationId, type CreateMaestroFromIntrospectionOptions, CsvExportProvider, type CursorPagination, DEFAULT_CAPABILITIES, type DatasourceDeleteContext, type DatasourceFindContext, type DatasourceProvider, type DatasourceQueryContext, DatasourceRegistry, type DatasourceUpdateContext, type DatasourceWriteContext, type DeclarativeCompilationResult, type DeclarativeConfig, type DeclarativeFileConfig, type DeclarativeFileFormat, type DeclarativeGeneratorMetadataInput, type DeclarativeGeneratorOptions, type DeclarativeGeneratorSchemaInput, type DeclarativeSerializationFormat, DefaultGovernanceApi, type DiffChange, type DiffChangeKind, DiffEngine, type DiffEngineOptions, type DiffSummary, type DomainEvent, type EntityCapabilities, type EntityDeclaration, type EntityDiffChange, type EntityDiffChangeKind, type EntityExportConfig, type EntityIntrospectionSchema, type EntityLabelConfig, type EntityMetadata, type EntitySchema, type EntitySourceConfig, type EnumOption, type EnumOptionDeclaration, ErrorCode, type EventBus, type EventHandler, type ExportConfig, type ExportFormat, type ExportOptions, type ExportProvider, type ExportResult, type FeatureFlag, type FeatureFlagProvider, type FieldDeclaration, type FieldDetailConfig, type FieldDiffChange, type FieldDiffChangeKind, type FieldFormConfig, type FieldIntrospectionSchema, type FieldListConfig, type FieldMetadata, type FieldSchema, type FieldSchemaDetailConfig, type FieldSchemaEnumOption, type FieldSchemaFormConfig, type FieldSchemaListConfig, type FieldType, type FileSystemReader, type FilterDescriptor, type FilterOperator, GOVERNANCE_EVENT_TYPES, type GeneratedConfig, type GovernanceApi, type GovernanceEventBus, type GovernanceEventType, type ImpactLevel, InMemoryAuditRepository, InMemoryConfigProvider, InMemoryConfirmationRepository, InMemoryDatasourceProvider, InMemoryEventBus, InMemoryFeatureFlagProvider, InMemoryGovernanceEventBus, InMemoryPolicyProvider, InMemorySnapshotRepository, type IndexIntrospectionSchema, type IntrospectionDiff, type IntrospectionProvider, type IntrospectionReport, type IntrospectionReportChange, type IntrospectionReportStats, type IntrospectionResult, IntrospectionRuntime, type IntrospectionRuntimeResult, type IntrospectionRuntimeRunOptions, type IntrospectionSnapshot, type IntrospectionValidationIssue, type IntrospectionValidationResult, type ListResult, type LoadDeclarativeConfigFromFileOptions, type LoadDeclarativeConfigFromStringOptions, type LoadedConfig, type LogEntry, type LogLevel, type Logger, type MaestroActorResolver, type MaestroConfig, MaestroEngine, MaestroError, type MaestroFileLoaderOptions, type MaestroHttpHandler, type MaestroHttpHandlers, type MaestroHttpOptions, type MaestroHttpRequest, type MaestroHttpResponse, type MaestroMetadata, type MaestroRequestContext, type MergeIntrospectionOptions, type MergeStrategy, type Metadata, MetadataEngine, MetadataRiskClassifier, type MetadataValue, type OffsetPagination, type OperationContext, type OperationDeclaration, type OperationDef, type OperationExecutedPayload, type OperationLogStatus, type OperationMetadata, OperationRegistry, type OperationResult, type OperationScope, type OperationalRisk, type PagePagination, type PaginationInput, type Permission, type PolicyContext, type PolicyDecision, PolicyEngine, type PolicyEvaluationResult, type PolicyProvider, type PolicyRule, type PolicyRuleResult, type PolicyTriggeredPayload, type PolicyViolation, type PolicyViolationFilter, type QueryInput, RbacEngine, type RbacPolicy, type RecordAuditInput, type RelationDeclaration, type RelationDiffChange, type RelationDiffChangeKind, type RelationDisplayConfig, type RelationEndpoint, type RelationIntrospectionSchema, type RelationMetadata, type RelationSchema, type RelationType, ReportGenerator, type RequestConfirmationInput, type ResolvedConsumerProjection, type ResourceRef, type RiskClassificationInput, type RiskClassifier, type Role, type SchemaValidationError, type SchemaValidationResult, type SearchConfig, type SearchInput, type SerializeDeclarativeConfigOptions, type SnapshotRepository, type SoftDeleteConfig, type SortDescriptor, type SortDirection, type StructuredLogEntry, type StructuredLogger, type YamlParser, type YamlSerializer, compileDeclarations, createMaestro, createMaestroFromIntrospection, createMaestroHttpHandlers, detectDisplayField, generateAllConfigs, generateCorrelationId, generateDeclarativeConfigFromMetadata, generateDeclarativeConfigFromSchema, generateEntityConfig, generateRelationConfig, humanizeFieldName, inferFieldType, isSearchCandidate, isSoftDeleteCandidate, isTimestampField, loadDeclarativeConfigFromFile, loadDeclarativeConfigFromString, loadMaestroConfig, mergeIntrospectionWithOverrides, normalizeIntrospectionResult, parseQueryInput, resolveConsumerProjections, serializeDeclarativeConfig, serializeDeclarativeConfigToJson, serializeDeclarativeConfigToYaml, tableNameToEntityId, tableNameToLabel, validateConsumerDeclaration, validateEntityDeclaration, validateIntrospectionResult, validateMaestroConfig };
|
|
1565
|
+
export { type Actor, type ActorType, type AuditEvent, type AuditFilter, type AuditLevel, type AuditRecordedPayload, AuditRecorder, type AuditRepository, type AuditTimeline, type AuthorizationContext, type AuthorizationDecision, type AuthorizationDeniedPayload, type AuthorizationProvider, type AuthorizationResult, type CompileDeclarationsOptions, type ConfigProvider, type ConfirmationApproval, type ConfirmationApprovedPayload, type ConfirmationDeclaration, ConfirmationEngine, type ConfirmationRejectedPayload, type ConfirmationRepository, type ConfirmationRequest, type ConfirmationRequestedPayload, type ConfirmationStatus, ConsoleLogger, ConsoleStructuredLogger, type ConsumerActionsConfig, type ConsumerDeclaration, type ConsumerDetailConfig, type ConsumerFormConfig, type ConsumerFormsConfig, type ConsumerListConfig, type ConsumerProjectionFields, type ConsumerProjectionOperations, type ContextAction, type ContextActionCondition, type ContextActionStyle, ContextualAuthorizationEngine, type CorrelationContext, type CorrelationId, type CreateMaestroFromIntrospectionOptions, CsvExportProvider, type CursorPagination, DEFAULT_CAPABILITIES, type DatasourceDeleteContext, type DatasourceFindContext, type DatasourceProvider, type DatasourceQueryContext, DatasourceRegistry, type DatasourceUpdateContext, type DatasourceWriteContext, type DeclarativeCompilationResult, type DeclarativeConfig, type DeclarativeFileConfig, type DeclarativeFileFormat, type DeclarativeGeneratorMetadataInput, type DeclarativeGeneratorOptions, type DeclarativeGeneratorSchemaInput, type DeclarativeSerializationFormat, DefaultGovernanceApi, type DiffChange, type DiffChangeKind, DiffEngine, type DiffEngineOptions, type DiffSummary, type DomainEvent, type EntityCapabilities, type EntityDeclaration, type EntityDiffChange, type EntityDiffChangeKind, type EntityExportConfig, type EntityIntrospectionSchema, type EntityLabelConfig, type EntityMetadata, type EntitySchema, type EntitySourceConfig, type EnumOption, type EnumOptionDeclaration, ErrorCode, type EventBus, type EventHandler, type ExportConfig, type ExportFormat, type ExportOptions, type ExportProvider, type ExportResult, type FeatureFlag, type FeatureFlagProvider, type FieldDeclaration, type FieldDetailConfig, type FieldDiffChange, type FieldDiffChangeKind, type FieldFormConfig, type FieldIntrospectionSchema, type FieldListConfig, type FieldMetadata, type FieldSchema, type FieldSchemaDetailConfig, type FieldSchemaEnumOption, type FieldSchemaFormConfig, type FieldSchemaListConfig, type FieldType, type FileSystemReader, type FilterDescriptor, type FilterOperator, GOVERNANCE_EVENT_TYPES, type GeneratedConfig, type GovernanceApi, type GovernanceEventBus, type GovernanceEventType, type ImpactLevel, InMemoryAuditRepository, InMemoryConfigProvider, InMemoryConfirmationRepository, InMemoryDatasourceProvider, InMemoryEventBus, InMemoryFeatureFlagProvider, InMemoryGovernanceEventBus, InMemoryPolicyProvider, InMemorySnapshotRepository, type IndexIntrospectionSchema, type IntrospectionContext, type IntrospectionDiff, type IntrospectionProvider, type IntrospectionReport, type IntrospectionReportChange, type IntrospectionReportStats, type IntrospectionResult, IntrospectionRuntime, type IntrospectionRuntimeResult, type IntrospectionRuntimeRunOptions, type IntrospectionSnapshot, type IntrospectionValidationIssue, type IntrospectionValidationResult, type ListResult, type LoadDeclarativeConfigFromFileOptions, type LoadDeclarativeConfigFromStringOptions, type LoadedConfig, type LogEntry, type LogLevel, type Logger, type MaestroActorResolver, type MaestroConfig, MaestroEngine, MaestroError, type MaestroFileLoaderOptions, type MaestroHttpHandler, type MaestroHttpHandlers, type MaestroHttpOptions, type MaestroHttpRequest, type MaestroHttpResponse, type MaestroMetadata, type MaestroRequestContext, type MergeIntrospectionOptions, type MergeStrategy, type Metadata, MetadataEngine, MetadataRiskClassifier, type MetadataValue, type OffsetPagination, type OperationContext, type OperationDeclaration, type OperationDef, type OperationExecutedPayload, type OperationLogStatus, type OperationMetadata, OperationRegistry, type OperationResult, type OperationScope, type OperationalRisk, type PagePagination, type PaginationInput, type Permission, type PolicyContext, type PolicyDecision, PolicyEngine, type PolicyEvaluationResult, type PolicyProvider, type PolicyRule, type PolicyRuleResult, type PolicyTriggeredPayload, type PolicyViolation, type PolicyViolationFilter, type QueryInput, RbacEngine, type RbacPolicy, type RecordAuditInput, type RelationDeclaration, type RelationDiffChange, type RelationDiffChangeKind, type RelationDisplayConfig, type RelationEndpoint, type RelationIntrospectionSchema, type RelationMetadata, type RelationSchema, type RelationType, ReportGenerator, type RequestConfirmationInput, type ResolvedConsumerProjection, type ResourceRef, type RiskClassificationInput, type RiskClassifier, type Role, type RunIntrospectionResult, type SchemaValidationError, type SchemaValidationResult, type SearchConfig, type SearchInput, type SerializeDeclarativeConfigOptions, type SnapshotRepository, type SoftDeleteConfig, type SortDescriptor, type SortDirection, type StructuredLogEntry, type StructuredLogger, type YamlParser, type YamlSerializer, compileDeclarations, createMaestro, createMaestroFromIntrospection, createMaestroHttpHandlers, detectDisplayField, generateAllConfigs, generateCorrelationId, generateDeclarativeConfigFromMetadata, generateDeclarativeConfigFromSchema, generateEntityConfig, generateRelationConfig, humanizeFieldName, inferFieldType, isSearchCandidate, isSoftDeleteCandidate, isTimestampField, loadDeclarativeConfigFromFile, loadDeclarativeConfigFromString, loadMaestroConfig, mergeIntrospectionWithOverrides, normalizeIntrospectionResult, parseQueryInput, resolveConsumerProjections, runIntrospectionProvider, serializeDeclarativeConfig, serializeDeclarativeConfigToJson, serializeDeclarativeConfigToYaml, tableNameToEntityId, tableNameToLabel, validateConsumerDeclaration, validateEntityDeclaration, validateIntrospectionResult, validateMaestroConfig };
|
package/dist/index.js
CHANGED
|
@@ -2624,6 +2624,38 @@ function normalizeIntrospectionResult(result) {
|
|
|
2624
2624
|
return { entities, relations };
|
|
2625
2625
|
}
|
|
2626
2626
|
|
|
2627
|
+
// src/introspection/runIntrospectionProvider.ts
|
|
2628
|
+
function errorMessage(error) {
|
|
2629
|
+
return error instanceof Error ? error.message : String(error);
|
|
2630
|
+
}
|
|
2631
|
+
async function runIntrospectionProvider(provider, context) {
|
|
2632
|
+
const providerName = provider.name ?? "unknown";
|
|
2633
|
+
let raw;
|
|
2634
|
+
try {
|
|
2635
|
+
raw = await provider.introspect(context);
|
|
2636
|
+
} catch (cause) {
|
|
2637
|
+
throw new MaestroError(
|
|
2638
|
+
"INTERNAL_ERROR" /* INTERNAL_ERROR */,
|
|
2639
|
+
`Introspection provider "${providerName}" threw during introspect(): ${errorMessage(cause)}`,
|
|
2640
|
+
{ details: { provider: providerName }, cause }
|
|
2641
|
+
);
|
|
2642
|
+
}
|
|
2643
|
+
const validation = validateIntrospectionResult(raw);
|
|
2644
|
+
if (!validation.valid) {
|
|
2645
|
+
const issueSummary = validation.issues.map((issue) => `${issue.path}: ${issue.message}`).join("; ");
|
|
2646
|
+
const details = {
|
|
2647
|
+
provider: providerName,
|
|
2648
|
+
issues: validation.issues.map((issue) => ({ path: issue.path, message: issue.message }))
|
|
2649
|
+
};
|
|
2650
|
+
throw new MaestroError(
|
|
2651
|
+
"VALIDATION_ERROR" /* VALIDATION_ERROR */,
|
|
2652
|
+
`Introspection provider "${providerName}" returned an invalid IntrospectionResult: ${issueSummary}`,
|
|
2653
|
+
{ details }
|
|
2654
|
+
);
|
|
2655
|
+
}
|
|
2656
|
+
return { provider: providerName, result: normalizeIntrospectionResult(raw) };
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2627
2659
|
// src/config-generator/ConfigGenerator.ts
|
|
2628
2660
|
function detectSoftDelete2(fields) {
|
|
2629
2661
|
const PRIORITY = [
|
|
@@ -3822,6 +3854,7 @@ export {
|
|
|
3822
3854
|
normalizeIntrospectionResult,
|
|
3823
3855
|
parseQueryInput,
|
|
3824
3856
|
resolveConsumerProjections,
|
|
3857
|
+
runIntrospectionProvider,
|
|
3825
3858
|
serializeDeclarativeConfig,
|
|
3826
3859
|
serializeDeclarativeConfigToJson,
|
|
3827
3860
|
serializeDeclarativeConfigToYaml,
|