@myvitalrx/metadata-runtime 1.10.0 → 1.12.0

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 CHANGED
@@ -199,6 +199,14 @@ declare class MetadataProjectionUnavailableError extends RuntimeMetadataError {
199
199
  metadata?: Record<string, unknown>;
200
200
  });
201
201
  }
202
+ /**
203
+ * The attached extension does not implement the route the SDK called.
204
+ * This is a permanent contract mismatch, not a missing metadata value
205
+ * and not a transient connectivity failure.
206
+ */
207
+ declare class MetadataExtensionContractError extends RuntimeMetadataError {
208
+ constructor(message: string, path?: string);
209
+ }
202
210
  /** Discovery query was rejected before a listing or relationship read. */
203
211
  declare class MetadataDiscoveryError extends RuntimeMetadataError {
204
212
  constructor(message: string, code?: string);
@@ -301,6 +309,15 @@ interface ProjectionManifest {
301
309
  * Generated automatically from domain projection records at publish time.
302
310
  */
303
311
  lookupIndex: Record<string, ManifestLookupIndexEntry>;
312
+ /**
313
+ * Present when this release retains latest INACTIVE values and relationships.
314
+ * Older releases omit it. Explicit INACTIVE or ALL value queries must not
315
+ * treat that omission as an empty inactive catalogue.
316
+ */
317
+ lifecycle?: {
318
+ values: 'activeAndInactive';
319
+ relations: 'activeAndInactive';
320
+ };
304
321
  /**
305
322
  * Optional localization projection artifacts published in this release.
306
323
  */
@@ -484,6 +501,40 @@ declare class StructuredLogger {
484
501
  verbose(entry: LogEntry): void;
485
502
  }
486
503
 
504
+ /**
505
+ * Governed metadata lifecycle.
506
+ *
507
+ * Registry and relation rows use `ACTIVE` / `INACTIVE`.
508
+ * Projection value entries use camelCase `active` / `inactive`.
509
+ * Comparisons accept both casings. `DELETED` is never a lifecycle query hit.
510
+ */
511
+ declare const METADATA_STATUS: {
512
+ readonly ACTIVE: "ACTIVE";
513
+ readonly INACTIVE: "INACTIVE";
514
+ };
515
+ type MetadataStatus = (typeof METADATA_STATUS)[keyof typeof METADATA_STATUS];
516
+ declare const METADATA_STATUS_FILTER: {
517
+ readonly ACTIVE: "ACTIVE";
518
+ readonly INACTIVE: "INACTIVE";
519
+ readonly ALL: "ALL";
520
+ };
521
+ type MetadataStatusFilter = (typeof METADATA_STATUS_FILTER)[keyof typeof METADATA_STATUS_FILTER];
522
+
523
+ /**
524
+ * In-memory buckets for one typed catalog.
525
+ * Built once per loaded release. Lookups read one endpoint bucket.
526
+ */
527
+ type TypedRelationStatusBuckets = ReadonlyMap<MetadataStatus, ReadonlyMap<string, readonly TypedProjectionRelation[]>>;
528
+ type TypedRelationIndex = {
529
+ /** False when any row is missing a required field. Queries must not succeed. */
530
+ complete: boolean;
531
+ outgoing: ReadonlyMap<string, readonly TypedProjectionRelation[]>;
532
+ incoming: ReadonlyMap<string, readonly TypedProjectionRelation[]>;
533
+ /** Endpoint buckets split by relationship status. Default queries read ACTIVE only. */
534
+ outgoingByStatus: TypedRelationStatusBuckets;
535
+ incomingByStatus: TypedRelationStatusBuckets;
536
+ };
537
+
487
538
  declare const PUBLISHED_VALUE_SORT: {
488
539
  readonly SORT_ORDER: "sortOrder";
489
540
  readonly VALUE_CODE: "valueCode";
@@ -558,6 +609,8 @@ type MetadataCacheSnapshot = {
558
609
  * Undefined when the release does not publish the catalog.
559
610
  */
560
611
  readonly typedRelations?: readonly TypedProjectionRelation[];
612
+ /** Built once when `typedRelations` is installed. */
613
+ readonly typedRelationIndex?: TypedRelationIndex;
561
614
  readonly manifest: ProjectionManifest;
562
615
  readonly localization?: ReadonlyMap<string, ReadonlyMap<string, string>>;
563
616
  };
@@ -1184,6 +1237,7 @@ declare class MetadataCache implements ReadModelCache<MetadataCacheSnapshot, Pro
1184
1237
  getRelationshipIndex(): RelationshipIndex | undefined;
1185
1238
  /** Undefined when the active release has no typed relation catalog. */
1186
1239
  getTypedRelations(): readonly TypedProjectionRelation[] | undefined;
1240
+ getTypedRelationIndex(): TypedRelationIndex | undefined;
1187
1241
  getLocalization(locale: string): ReadonlyMap<string, string> | undefined;
1188
1242
  getLocalizationMap(locale: string): ReadonlyMap<string, string> | undefined;
1189
1243
  getLocalizationValue(key: string, locale?: string): string | undefined;
@@ -1379,14 +1433,22 @@ type MetadataResolveOptions = {
1379
1433
  /**
1380
1434
  * Include latest INACTIVE values from `inactiveRecords`.
1381
1435
  * Default lookups stay active-record only.
1436
+ * Prefer `status` for new callers. `includeInactive: true` remains ALL.
1382
1437
  */
1383
1438
  includeInactive?: boolean;
1439
+ /**
1440
+ * Lifecycle filter. Omitted and `ACTIVE` return active records.
1441
+ * `INACTIVE` and `ALL` fail when the release has no lifecycle coverage.
1442
+ */
1443
+ status?: MetadataStatusFilter;
1384
1444
  };
1385
1445
  type MetadataRelationQuery = {
1386
1446
  fromType: string;
1387
1447
  fromValue: string;
1388
1448
  relationType?: string;
1389
1449
  toType?: string;
1450
+ /** Omitted is ACTIVE. */
1451
+ status?: MetadataStatusFilter;
1390
1452
  };
1391
1453
  type MetadataRelationRow = TypedProjectionRelation;
1392
1454
  type MetadataRelationListResult = {
@@ -1424,6 +1486,14 @@ type MetadataProviderStatus = {
1424
1486
  metadataTypes?: readonly string[];
1425
1487
  /** Present when the extension recorded a load or refresh failure. */
1426
1488
  lastError?: string | null;
1489
+ /**
1490
+ * Whether the loaded release can answer explicit INACTIVE and ALL queries.
1491
+ * Absent on extension builds that predate lifecycle coverage.
1492
+ */
1493
+ lifecycle?: {
1494
+ values: boolean;
1495
+ relations: boolean;
1496
+ };
1427
1497
  };
1428
1498
  type MetadataBatchResult = {
1429
1499
  releaseId: string | null;
@@ -1555,11 +1625,20 @@ interface MetadataRelationshipQuery {
1555
1625
  targetTypeCode?: string;
1556
1626
  relationType?: string;
1557
1627
  direction?: MetadataRelationDirection;
1628
+ /**
1629
+ * Omitted is ACTIVE. `INACTIVE` and `ALL` are not answered from
1630
+ * `relationship-index.json`.
1631
+ */
1632
+ status?: MetadataStatusFilter;
1558
1633
  releaseId?: string;
1559
1634
  readPolicy?: MetadataReadPolicy;
1560
1635
  }
1561
1636
  interface MetadataRelationship {
1562
- relationType: string;
1637
+ /**
1638
+ * Present when the release has a typed relation catalog.
1639
+ * Omitted for adjacency rows read from `relationship-index.json`.
1640
+ */
1641
+ relationType?: string;
1563
1642
  status: string;
1564
1643
  direction: MetadataRelationDirection;
1565
1644
  fromMetadataTypeCode: string;
@@ -1572,7 +1651,10 @@ interface MetadataRelationship {
1572
1651
  }
1573
1652
  interface MetadataRelationshipResult {
1574
1653
  releaseId: string | null;
1575
- /** False when this release has no typed relation catalog. */
1654
+ /**
1655
+ * False when this release has neither a typed relation catalog nor a
1656
+ * loaded relationship index. An empty index is supported.
1657
+ */
1576
1658
  supported: boolean;
1577
1659
  relationships: MetadataRelationship[];
1578
1660
  }
@@ -1912,6 +1994,7 @@ declare class ExtensionMetadataProvider implements MetadataProvider, MetadataDis
1912
1994
  private readonly readyTimeoutMs;
1913
1995
  private readonly requestTimeoutMs;
1914
1996
  private readonly logger;
1997
+ private lifecycleSupport?;
1915
1998
  private readonly fetchImpl;
1916
1999
  constructor(options: ExtensionMetadataProviderOptions);
1917
2000
  isAvailable(): Promise<boolean>;
@@ -1933,6 +2016,7 @@ declare class ExtensionMetadataProvider implements MetadataProvider, MetadataDis
1933
2016
  getLocalizationValue(keyOrTypeCode: string, valueCodeOrLocale?: string, maybeLocale?: string): Promise<string | undefined>;
1934
2017
  getLocalizationMap(locale: string): Promise<Record<string, string> | undefined>;
1935
2018
  requestRefresh(releaseId?: string): Promise<boolean>;
2019
+ private assertQueryLifecycle;
1936
2020
  private toMetadataValue;
1937
2021
  private assertDiscoveryPolicy;
1938
2022
  private requestJson;
@@ -1971,6 +2055,9 @@ declare class S3MetadataProvider implements MetadataProvider, MetadataDiscoveryP
1971
2055
  private prepareDiscoveryRead;
1972
2056
  private listLoadedType;
1973
2057
  private isKnownType;
2058
+ private valueFilter;
2059
+ private relatedGroupsForStatus;
2060
+ private relatedGroupsFromAdjacency;
1974
2061
  }
1975
2062
  declare function relatedValueCodes(index: RelationshipIndex | undefined, sourceTypeCode: string, sourceValueCode: string, targetTypeCode: string): string[];
1976
2063
  /** S3 client is owned by RuntimeMetadataService; listed for documentation. */
@@ -1993,6 +2080,11 @@ type InMemoryMetadataProviderOptions = {
1993
2080
  * Types present on `records` are known without being listed here.
1994
2081
  */
1995
2082
  knownTypeCodes?: readonly string[];
2083
+ /**
2084
+ * When false, explicit INACTIVE and ALL queries fail.
2085
+ * Default true so in-memory catalogues can answer lifecycle filters.
2086
+ */
2087
+ lifecycleSupported?: boolean;
1996
2088
  };
1997
2089
  /**
1998
2090
  * Test / local provider. Never talks to S3 or the extension.
@@ -2004,7 +2096,11 @@ declare class InMemoryMetadataProvider implements MetadataProvider, MetadataDisc
2004
2096
  private readonly byKey;
2005
2097
  private readonly related;
2006
2098
  private readonly relations;
2099
+ private readonly typedRelationIndex;
2007
2100
  private readonly knownTypeCodes;
2101
+ private readonly lifecycleSupported;
2102
+ private readonly activeByType;
2103
+ private readonly inactiveByType;
2008
2104
  constructor(options?: InMemoryMetadataProviderOptions);
2009
2105
  isAvailable(): Promise<boolean>;
2010
2106
  setUnavailable(unavailable: boolean): void;
@@ -2026,6 +2122,9 @@ declare class InMemoryMetadataProvider implements MetadataProvider, MetadataDisc
2026
2122
  getRelationships(query: MetadataRelationshipQuery): Promise<MetadataRelationshipResult>;
2027
2123
  private listOneType;
2028
2124
  private hasType;
2125
+ private indexRecords;
2126
+ private readFilter;
2127
+ private recordsForFilter;
2029
2128
  private assertReadable;
2030
2129
  }
2031
2130
 
@@ -2089,4 +2188,4 @@ declare class ProviderFailoverCoordinator {
2089
2188
  }
2090
2189
  declare function isExtensionServing(status: MetadataProviderStatus): boolean;
2091
2190
 
2092
- export { CACHE_STATUS, type CacheStatus, type CandidateDiagnostic, type CollectMetadataDiagnostics, type CollectResponseMetadataOptions, type CreateRuntimeMetadataFromEnvOptions, DEFAULT_EXCLUDED_CODE_FIELDS, DEFAULT_PROVIDER_RECOVERY_COOLDOWN_MS, ExtensionMetadataProvider, type ExtensionMetadataProviderOptions, type ExtensionMetadataTypeInfo, InMemoryMetadataProvider, type InMemoryMetadataProviderOptions, type InMemoryMetadataRecord, InvalidMetadataReferenceError, type ListedMetadataType, type LoadedProjectionBundle, METADATA_ATTRIBUTE_FILTER_KEY, METADATA_PROJECTIONS_BUCKET_ENV, METADATA_PROVIDER_KIND, METADATA_READ_POLICY, METADATA_RELATION_DIRECTION, type ManifestCompareResult, type ManifestLookupIndexEntry, type ManifestMetadataTypeEntry, ManifestValidationError, type MetadataAttributeFilterKey, type MetadataBatchListOptions, type MetadataBatchListResult, type MetadataBatchResult, type MetadataBatchTypeList, MetadataCache, type MetadataCacheSnapshot, type MetadataCacheWriteGuard, MetadataDiscoveryError, type MetadataDiscoveryProvider, MetadataDownloader, type MetadataDownloaderOptions, MetadataFreshnessError, type MetadataHealthReport, MetadataHealthService, type MetadataHealthServiceOptions, type MetadataListOptions, type MetadataListResult, MetadataLoader, type MetadataLoaderOptions, MetadataLookupError, MetadataNotReadyError, MetadataProjectionUnavailableError, type MetadataProvider, type MetadataProviderKind, type MetadataProviderStatus, type MetadataReadPolicy, type MetadataReadSession, type MetadataReference, MetadataRefreshService, type MetadataRefreshServiceOptions, type MetadataRelatedGroup, type MetadataRelationDirection, type MetadataRelationListResult, type MetadataRelationQuery, type MetadataRelationRow, type MetadataRelationship, type MetadataRelationshipQuery, type MetadataRelationshipResult, MetadataReleaseMismatchError, type MetadataResolveOptions, MetadataResolver, type MetadataResolverOptions, type MetadataTypeCatalogInfo, type MetadataValue, NON_METADATA_KEYS, PROVIDER_TRANSPORT_STATE, ProjectionDownloadError, type ProjectionEntry, type ProjectionVersionEntry, ProviderFailoverCoordinator, type ProviderFailoverCoordinatorOptions, type ProviderTransportState, REFRESH_STATUS, RUNTIME_METADATA_EVENTS, RUNTIME_METADATA_INTEGRATION_TARGETS, RUNTIME_METADATA_TYPE_CODE_ALIASES, type ReadModelArtifact, type ReadModelBundle, type ReadModelCache, type ReadModelCacheLoader, type ReadModelDownloader, type ReadModelGroupDescriptor, type ReadModelGroupId, type ReadModelManifestGroupView, type ReadModelManifestGroups, type ReadModelProvider, type ReadModelRefreshCoordinator, type ReadModelResolver, type RefreshStatus, type ResolvableMetadataType, type ResolvedProjectionEntry, type RuntimeMetadataConfig, type RuntimeMetadataConfigInput, RuntimeMetadataError, RuntimeMetadataService, type RuntimeMetadataServiceOptions, S3MetadataProvider, type S3MetadataProviderClient, type S3MetadataProviderOptions, type SelectMetadataProviderInput, type SelectedMetadataProvider, UnknownMetadataTypeError, WORKFLOW_STEP_RULE_KEYS, assertMetadataReadPolicy, assertReleasePin, canonicalMetadataProjectionsBucketName, collectResponseReferences, collectResponseTypeCodes, createCodeFieldExclusionSet, createRuntimeMetadataFromEnv, defaultExtensionBaseUrl, ensureRuntimeMetadataLoaded, formatMetadataReference, getCandidateTypeCodesForKey, getRuntimeMetadataHealth, getRuntimeMetadataService, hasPotentialMetadata, isCompactMetadataReference, isExtensionEnabled, isExtensionServing, isFreshProjectionState, isMetadataProjectionConfigured, isMetadataProjectionsBucketConfigured, isMetadataReference, isMetadataValueObject, isMetadataValueObjectArray, isWorkflowStepRecord, isWorkflowStepRuleField, localizedLabelFromEntry, manifestLocalizationSchema, metadataGroupFromManifest, metadataValueToReference, normalizeRuntimeMetadataTypeCode, onMetadataProjectionCompleted, parseMetadataReference, projectionEntryToMetadataValue, projectionManifestSchema, readMetadataProjectionsBucket, readModelGroupsFromManifest, relatedValueCodes, resetRuntimeMetadataBootstrapState, resolveMetadataProjectionsBucket, resolveRuntimeMetadataConfig, runtimeMetadataConfigSchema, selectMetadataProvider, supportsMetadataDiscovery, throwPublishedListFailure, tryGetRuntimeMetadataService, tryParseMetadataReference, typeCodeFromCodeFieldName };
2191
+ export { CACHE_STATUS, type CacheStatus, type CandidateDiagnostic, type CollectMetadataDiagnostics, type CollectResponseMetadataOptions, type CreateRuntimeMetadataFromEnvOptions, DEFAULT_EXCLUDED_CODE_FIELDS, DEFAULT_PROVIDER_RECOVERY_COOLDOWN_MS, ExtensionMetadataProvider, type ExtensionMetadataProviderOptions, type ExtensionMetadataTypeInfo, InMemoryMetadataProvider, type InMemoryMetadataProviderOptions, type InMemoryMetadataRecord, InvalidMetadataReferenceError, type ListedMetadataType, type LoadedProjectionBundle, METADATA_ATTRIBUTE_FILTER_KEY, METADATA_PROJECTIONS_BUCKET_ENV, METADATA_PROVIDER_KIND, METADATA_READ_POLICY, METADATA_RELATION_DIRECTION, type ManifestCompareResult, type ManifestLookupIndexEntry, type ManifestMetadataTypeEntry, ManifestValidationError, type MetadataAttributeFilterKey, type MetadataBatchListOptions, type MetadataBatchListResult, type MetadataBatchResult, type MetadataBatchTypeList, MetadataCache, type MetadataCacheSnapshot, type MetadataCacheWriteGuard, MetadataDiscoveryError, type MetadataDiscoveryProvider, MetadataDownloader, type MetadataDownloaderOptions, MetadataExtensionContractError, MetadataFreshnessError, type MetadataHealthReport, MetadataHealthService, type MetadataHealthServiceOptions, type MetadataListOptions, type MetadataListResult, MetadataLoader, type MetadataLoaderOptions, MetadataLookupError, MetadataNotReadyError, MetadataProjectionUnavailableError, type MetadataProvider, type MetadataProviderKind, type MetadataProviderStatus, type MetadataReadPolicy, type MetadataReadSession, type MetadataReference, MetadataRefreshService, type MetadataRefreshServiceOptions, type MetadataRelatedGroup, type MetadataRelationDirection, type MetadataRelationListResult, type MetadataRelationQuery, type MetadataRelationRow, type MetadataRelationship, type MetadataRelationshipQuery, type MetadataRelationshipResult, MetadataReleaseMismatchError, type MetadataResolveOptions, MetadataResolver, type MetadataResolverOptions, type MetadataTypeCatalogInfo, type MetadataValue, NON_METADATA_KEYS, PROVIDER_TRANSPORT_STATE, ProjectionDownloadError, type ProjectionEntry, type ProjectionVersionEntry, ProviderFailoverCoordinator, type ProviderFailoverCoordinatorOptions, type ProviderTransportState, REFRESH_STATUS, RUNTIME_METADATA_EVENTS, RUNTIME_METADATA_INTEGRATION_TARGETS, RUNTIME_METADATA_TYPE_CODE_ALIASES, type ReadModelArtifact, type ReadModelBundle, type ReadModelCache, type ReadModelCacheLoader, type ReadModelDownloader, type ReadModelGroupDescriptor, type ReadModelGroupId, type ReadModelManifestGroupView, type ReadModelManifestGroups, type ReadModelProvider, type ReadModelRefreshCoordinator, type ReadModelResolver, type RefreshStatus, type ResolvableMetadataType, type ResolvedProjectionEntry, type RuntimeMetadataConfig, type RuntimeMetadataConfigInput, RuntimeMetadataError, RuntimeMetadataService, type RuntimeMetadataServiceOptions, S3MetadataProvider, type S3MetadataProviderClient, type S3MetadataProviderOptions, type SelectMetadataProviderInput, type SelectedMetadataProvider, UnknownMetadataTypeError, WORKFLOW_STEP_RULE_KEYS, assertMetadataReadPolicy, assertReleasePin, canonicalMetadataProjectionsBucketName, collectResponseReferences, collectResponseTypeCodes, createCodeFieldExclusionSet, createRuntimeMetadataFromEnv, defaultExtensionBaseUrl, ensureRuntimeMetadataLoaded, formatMetadataReference, getCandidateTypeCodesForKey, getRuntimeMetadataHealth, getRuntimeMetadataService, hasPotentialMetadata, isCompactMetadataReference, isExtensionEnabled, isExtensionServing, isFreshProjectionState, isMetadataProjectionConfigured, isMetadataProjectionsBucketConfigured, isMetadataReference, isMetadataValueObject, isMetadataValueObjectArray, isWorkflowStepRecord, isWorkflowStepRuleField, localizedLabelFromEntry, manifestLocalizationSchema, metadataGroupFromManifest, metadataValueToReference, normalizeRuntimeMetadataTypeCode, onMetadataProjectionCompleted, parseMetadataReference, projectionEntryToMetadataValue, projectionManifestSchema, readMetadataProjectionsBucket, readModelGroupsFromManifest, relatedValueCodes, resetRuntimeMetadataBootstrapState, resolveMetadataProjectionsBucket, resolveRuntimeMetadataConfig, runtimeMetadataConfigSchema, selectMetadataProvider, supportsMetadataDiscovery, throwPublishedListFailure, tryGetRuntimeMetadataService, tryParseMetadataReference, typeCodeFromCodeFieldName };