@myvitalrx/metadata-runtime 1.13.0 → 1.14.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 +49 -0
- package/dist/index.js +221 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -229,6 +229,9 @@ declare class InvalidMetadataReferenceError extends RuntimeMetadataError {
|
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/** Wire projectionVersion stamped on every envelope / manifest / current pointer. */
|
|
233
|
+
declare const PROJECTION_VERSION: "1.0";
|
|
234
|
+
|
|
232
235
|
/**
|
|
233
236
|
* Projection wire type — any non-empty camelCase (or legacy) identifier.
|
|
234
237
|
*
|
|
@@ -501,6 +504,27 @@ declare class StructuredLogger {
|
|
|
501
504
|
verbose(entry: LogEntry): void;
|
|
502
505
|
}
|
|
503
506
|
|
|
507
|
+
/** Document discriminator. Not part of a permission identity. */
|
|
508
|
+
declare const PERMISSION_REGISTRY_METADATA_TYPE: "PermissionRegistry";
|
|
509
|
+
/**
|
|
510
|
+
* One permission. Identity is moduleCode + featureCode + permissionActionCode.
|
|
511
|
+
* `permissionKey` is the deterministic serialization of those three codes.
|
|
512
|
+
* CapabilityCategory is an eligibility gate and is not stored here.
|
|
513
|
+
*/
|
|
514
|
+
type PermissionRegistryEntry = {
|
|
515
|
+
readonly permissionKey: string;
|
|
516
|
+
readonly moduleCode: string;
|
|
517
|
+
readonly featureCode: string;
|
|
518
|
+
readonly permissionActionCode: string;
|
|
519
|
+
};
|
|
520
|
+
type PermissionRegistryDocument = {
|
|
521
|
+
readonly metadataType: typeof PERMISSION_REGISTRY_METADATA_TYPE;
|
|
522
|
+
readonly version: typeof PROJECTION_VERSION;
|
|
523
|
+
readonly releaseId: string;
|
|
524
|
+
readonly generatedAt: string;
|
|
525
|
+
readonly permissions: readonly PermissionRegistryEntry[];
|
|
526
|
+
};
|
|
527
|
+
|
|
504
528
|
/**
|
|
505
529
|
* Governed metadata lifecycle.
|
|
506
530
|
*
|
|
@@ -1143,6 +1167,7 @@ declare class MetadataDownloader implements ReadModelDownloader<LoadedProjection
|
|
|
1143
1167
|
private readonly expectedProjectionVersion;
|
|
1144
1168
|
private readonly logger;
|
|
1145
1169
|
private readonly loader;
|
|
1170
|
+
private readonly objectInFlight;
|
|
1146
1171
|
constructor(options: MetadataDownloaderOptions);
|
|
1147
1172
|
buildKey(releaseId: string, fileName: string): string;
|
|
1148
1173
|
/**
|
|
@@ -1192,10 +1217,12 @@ declare class MetadataDownloader implements ReadModelDownloader<LoadedProjection
|
|
|
1192
1217
|
*/
|
|
1193
1218
|
downloadCommon(manifest: ProjectionManifest): Promise<CommonProjectionFile>;
|
|
1194
1219
|
downloadTypedRelations(manifest: ProjectionManifest): Promise<TypedProjectionRelation[] | undefined>;
|
|
1220
|
+
downloadPermissionRegistry(manifest: ProjectionManifest): Promise<PermissionRegistryDocument>;
|
|
1195
1221
|
downloadRelationshipIndex(manifest: ProjectionManifest): Promise<RelationshipIndex | undefined>;
|
|
1196
1222
|
private assertManifestMatchesRelease;
|
|
1197
1223
|
private parseAndValidateProjectionBody;
|
|
1198
1224
|
private getObjectBody;
|
|
1225
|
+
private fetchObjectBody;
|
|
1199
1226
|
private validateDownloadedFile;
|
|
1200
1227
|
}
|
|
1201
1228
|
|
|
@@ -1518,6 +1545,12 @@ interface MetadataProvider {
|
|
|
1518
1545
|
* Empty `sourceValueCodes` returns `[]`. Order follows `sourceValueCodes`.
|
|
1519
1546
|
*/
|
|
1520
1547
|
getRelatedValueGroups(sourceTypeCode: string, sourceValueCodes: readonly string[], targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataRelatedGroup[]>;
|
|
1548
|
+
/**
|
|
1549
|
+
* Permission vocabulary from the same release as metadata lookups.
|
|
1550
|
+
* Missing or invalid artifacts throw. An empty `permissions` array is a
|
|
1551
|
+
* published registry, not a load failure.
|
|
1552
|
+
*/
|
|
1553
|
+
getPermissionRegistry(): Promise<PermissionRegistryDocument>;
|
|
1521
1554
|
getStatus(): Promise<MetadataProviderStatus>;
|
|
1522
1555
|
isAvailable(): Promise<boolean>;
|
|
1523
1556
|
/**
|
|
@@ -1755,6 +1788,8 @@ declare class RuntimeMetadataService implements ReadModelProvider<ProjectionEntr
|
|
|
1755
1788
|
private readonly logger;
|
|
1756
1789
|
/** Coalesce concurrent cold bootstrap (current.json + manifest.json). */
|
|
1757
1790
|
private initializeInFlight;
|
|
1791
|
+
private permissionRegistryInFlight;
|
|
1792
|
+
private permissionRegistryCache;
|
|
1758
1793
|
/**
|
|
1759
1794
|
* In-flight selective downloads keyed by MetadataTypeCode.
|
|
1760
1795
|
* Concurrent requests (and overlapping type sets) share one download per type
|
|
@@ -1851,6 +1886,13 @@ declare class RuntimeMetadataService implements ReadModelProvider<ProjectionEntr
|
|
|
1851
1886
|
getValue(typeCode: string, valueCode: string, options?: MetadataResolveOptions): Promise<MetadataValue | null>;
|
|
1852
1887
|
batchGet(references: string[], options?: MetadataResolveOptions): Promise<MetadataBatchResult>;
|
|
1853
1888
|
getRelatedValues(sourceTypeCode: string, sourceValueCode: string, targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataValue[]>;
|
|
1889
|
+
/**
|
|
1890
|
+
* Permission vocabulary for the active release.
|
|
1891
|
+
* Concurrent callers share one load. A failed load is not cached.
|
|
1892
|
+
* The last successful document is kept until the release id changes.
|
|
1893
|
+
*/
|
|
1894
|
+
getPermissionRegistry(): Promise<PermissionRegistryDocument>;
|
|
1895
|
+
private loadPermissionRegistry;
|
|
1854
1896
|
getRelatedValueGroups(sourceTypeCode: string, sourceValueCodes: readonly string[], targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataRelatedGroup[]>;
|
|
1855
1897
|
listRelations(query: MetadataRelationQuery): Promise<MetadataRelationListResult>;
|
|
1856
1898
|
listTypeValues(typeCode: string, options?: MetadataResolveOptions): Promise<ListedMetadataType | null>;
|
|
@@ -2015,6 +2057,7 @@ declare class ExtensionMetadataProvider implements MetadataProvider, MetadataDis
|
|
|
2015
2057
|
listRelations(query: MetadataRelationQuery): Promise<MetadataRelationListResult>;
|
|
2016
2058
|
getRelatedValues(sourceTypeCode: string, sourceValueCode: string, targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataValue[]>;
|
|
2017
2059
|
getRelatedValueGroups(sourceTypeCode: string, sourceValueCodes: readonly string[], targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataRelatedGroup[]>;
|
|
2060
|
+
getPermissionRegistry(): Promise<PermissionRegistryDocument>;
|
|
2018
2061
|
getLocalizationValue(keyOrTypeCode: string, valueCodeOrLocale?: string, maybeLocale?: string): Promise<string | undefined>;
|
|
2019
2062
|
getLocalizationMap(locale: string): Promise<Record<string, string> | undefined>;
|
|
2020
2063
|
requestRefresh(releaseId?: string): Promise<boolean>;
|
|
@@ -2040,6 +2083,7 @@ type S3MetadataProviderOptions = {
|
|
|
2040
2083
|
declare class S3MetadataProvider implements MetadataProvider, MetadataDiscoveryProvider {
|
|
2041
2084
|
private readonly cache;
|
|
2042
2085
|
private readonly resolver;
|
|
2086
|
+
private readonly downloader;
|
|
2043
2087
|
private readonly ensureTypesLoaded;
|
|
2044
2088
|
private readonly logger;
|
|
2045
2089
|
constructor(options: S3MetadataProviderOptions);
|
|
@@ -2049,6 +2093,7 @@ declare class S3MetadataProvider implements MetadataProvider, MetadataDiscoveryP
|
|
|
2049
2093
|
batchGet(references: string[], options?: MetadataResolveOptions): Promise<MetadataBatchResult>;
|
|
2050
2094
|
listRelations(query: MetadataRelationQuery): Promise<MetadataRelationListResult>;
|
|
2051
2095
|
getRelatedValues(sourceTypeCode: string, sourceValueCode: string, targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataValue[]>;
|
|
2096
|
+
getPermissionRegistry(): Promise<PermissionRegistryDocument>;
|
|
2052
2097
|
getRelatedValueGroups(sourceTypeCode: string, sourceValueCodes: readonly string[], targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataRelatedGroup[]>;
|
|
2053
2098
|
listTypeValues(typeCode: string, options?: MetadataResolveOptions): Promise<ListedMetadataType | null>;
|
|
2054
2099
|
listValuesByType(typeCode: string, options?: MetadataListOptions): Promise<MetadataListResult>;
|
|
@@ -2087,6 +2132,8 @@ type InMemoryMetadataProviderOptions = {
|
|
|
2087
2132
|
* Default true so in-memory catalogues can answer lifecycle filters.
|
|
2088
2133
|
*/
|
|
2089
2134
|
lifecycleSupported?: boolean;
|
|
2135
|
+
/** When omitted, {@link InMemoryMetadataProvider.getPermissionRegistry} fails closed. */
|
|
2136
|
+
permissionRegistry?: PermissionRegistryDocument;
|
|
2090
2137
|
};
|
|
2091
2138
|
/**
|
|
2092
2139
|
* Test / local provider. Never talks to S3 or the extension.
|
|
@@ -2101,6 +2148,7 @@ declare class InMemoryMetadataProvider implements MetadataProvider, MetadataDisc
|
|
|
2101
2148
|
private readonly typedRelationIndex;
|
|
2102
2149
|
private readonly knownTypeCodes;
|
|
2103
2150
|
private readonly lifecycleSupported;
|
|
2151
|
+
private readonly permissionRegistry;
|
|
2104
2152
|
private readonly activeByType;
|
|
2105
2153
|
private readonly inactiveByType;
|
|
2106
2154
|
constructor(options?: InMemoryMetadataProviderOptions);
|
|
@@ -2116,6 +2164,7 @@ declare class InMemoryMetadataProvider implements MetadataProvider, MetadataDisc
|
|
|
2116
2164
|
batchGet(references: string[], options?: MetadataResolveOptions): Promise<MetadataBatchResult>;
|
|
2117
2165
|
listRelations(query: MetadataRelationQuery): Promise<MetadataRelationListResult>;
|
|
2118
2166
|
getRelatedValues(sourceTypeCode: string, sourceValueCode: string, targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataValue[]>;
|
|
2167
|
+
getPermissionRegistry(): Promise<PermissionRegistryDocument>;
|
|
2119
2168
|
getRelatedValueGroups(sourceTypeCode: string, sourceValueCodes: readonly string[], targetTypeCode: string, options?: MetadataResolveOptions): Promise<MetadataRelatedGroup[]>;
|
|
2120
2169
|
private relatedValuesFor;
|
|
2121
2170
|
listTypeValues(typeCode: string, options?: MetadataResolveOptions): Promise<ListedMetadataType | null>;
|
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ var RUNTIME_METADATA_EVENTS = {
|
|
|
66
66
|
var PROJECTION_SCHEMA_VERSION = 2;
|
|
67
67
|
var PROJECTION_VERSION = "1.0";
|
|
68
68
|
var DEFAULT_STORAGE_PREFIX = "metadata-projections";
|
|
69
|
+
var PERMISSION_REGISTRY_FILE_NAME = "permission-registry.json";
|
|
69
70
|
var CURRENT_POINTER_FILE_NAME = "current.json";
|
|
70
71
|
var RELEASES_FOLDER_NAME = "releases";
|
|
71
72
|
var PROJECTION_TYPE = {
|
|
@@ -102,7 +103,13 @@ var PROJECTION_TYPE = {
|
|
|
102
103
|
*/
|
|
103
104
|
RUNTIME_CONFIG: "runtimeConfig",
|
|
104
105
|
MANIFEST: "manifest",
|
|
105
|
-
LOCALIZATION: "localization"
|
|
106
|
+
LOCALIZATION: "localization",
|
|
107
|
+
/**
|
|
108
|
+
* Denormalized permission vocabulary (`permission-registry.json`).
|
|
109
|
+
* Platform file — not a domain Metadata Type. Identity stays
|
|
110
|
+
* `moduleCode.featureCode.permissionActionCode`.
|
|
111
|
+
*/
|
|
112
|
+
PERMISSION_REGISTRY: "permissionRegistry"
|
|
106
113
|
};
|
|
107
114
|
var PROJECTION_FILE_NAME = {
|
|
108
115
|
[PROJECTION_TYPE.CONDITION]: "Condition.json",
|
|
@@ -115,6 +122,7 @@ var PROJECTION_FILE_NAME = {
|
|
|
115
122
|
[PROJECTION_TYPE.COMMON]: "common.json",
|
|
116
123
|
[PROJECTION_TYPE.RELATIONSHIP_INDEX]: "relationship-index.json",
|
|
117
124
|
[PROJECTION_TYPE.TYPED_RELATIONS]: "typed-relations.json",
|
|
125
|
+
[PROJECTION_TYPE.PERMISSION_REGISTRY]: PERMISSION_REGISTRY_FILE_NAME,
|
|
118
126
|
/** @deprecated No longer published. */
|
|
119
127
|
[PROJECTION_TYPE.RUNTIME_CONFIG]: "runtime-config.json",
|
|
120
128
|
[PROJECTION_TYPE.MANIFEST]: "manifest.json"
|
|
@@ -1542,6 +1550,99 @@ function isRelationshipIndexPayload(value) {
|
|
|
1542
1550
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1543
1551
|
}
|
|
1544
1552
|
|
|
1553
|
+
// ../../libs/metadata-projection/src/lib/permission-registry/PermissionRegistryReadModelBuilder.ts
|
|
1554
|
+
var PERMISSION_REGISTRY_METADATA_TYPE = "PermissionRegistry";
|
|
1555
|
+
|
|
1556
|
+
// ../../libs/metadata-projection/src/lib/permission-registry/parsePermissionRegistryDocument.ts
|
|
1557
|
+
function parsePermissionRegistryDocument(parsed, expected = {}) {
|
|
1558
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1559
|
+
throw new Error("Permission registry must be a JSON object");
|
|
1560
|
+
}
|
|
1561
|
+
const record = parsed;
|
|
1562
|
+
if (record.metadataType !== PERMISSION_REGISTRY_METADATA_TYPE) {
|
|
1563
|
+
throw new Error("Permission registry metadataType is invalid");
|
|
1564
|
+
}
|
|
1565
|
+
if (record.version !== PROJECTION_VERSION) {
|
|
1566
|
+
throw new Error(`Permission registry version ${String(record.version)} is unsupported`);
|
|
1567
|
+
}
|
|
1568
|
+
if (typeof record.releaseId !== "string" || record.releaseId.trim() === "") {
|
|
1569
|
+
throw new Error("Permission registry releaseId is required");
|
|
1570
|
+
}
|
|
1571
|
+
if (expected.releaseId && record.releaseId !== expected.releaseId) {
|
|
1572
|
+
throw new Error(
|
|
1573
|
+
`Permission registry releaseId ${record.releaseId} does not match ${expected.releaseId}`
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
if (typeof record.generatedAt !== "string" || record.generatedAt.trim() === "") {
|
|
1577
|
+
throw new Error("Permission registry generatedAt is required");
|
|
1578
|
+
}
|
|
1579
|
+
if (!Array.isArray(record.permissions)) {
|
|
1580
|
+
throw new Error("Permission registry permissions must be an array");
|
|
1581
|
+
}
|
|
1582
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1583
|
+
const permissions = [];
|
|
1584
|
+
for (const raw of record.permissions) {
|
|
1585
|
+
const entry = parseEntry(raw);
|
|
1586
|
+
if (seen.has(entry.permissionKey)) {
|
|
1587
|
+
throw new Error(`Duplicate permission key ${entry.permissionKey}`);
|
|
1588
|
+
}
|
|
1589
|
+
seen.add(entry.permissionKey);
|
|
1590
|
+
permissions.push(entry);
|
|
1591
|
+
}
|
|
1592
|
+
const document = {
|
|
1593
|
+
metadataType: PERMISSION_REGISTRY_METADATA_TYPE,
|
|
1594
|
+
version: PROJECTION_VERSION,
|
|
1595
|
+
releaseId: record.releaseId,
|
|
1596
|
+
generatedAt: record.generatedAt,
|
|
1597
|
+
permissions
|
|
1598
|
+
};
|
|
1599
|
+
if (expected.contentHash) {
|
|
1600
|
+
const actual = ProjectionHelper.contentHash(document);
|
|
1601
|
+
if (actual !== expected.contentHash) {
|
|
1602
|
+
throw new Error("Permission registry checksum mismatch");
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
return document;
|
|
1606
|
+
}
|
|
1607
|
+
function parseEntry(raw) {
|
|
1608
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
1609
|
+
throw new Error("Permission registry entry must be an object");
|
|
1610
|
+
}
|
|
1611
|
+
const entry = raw;
|
|
1612
|
+
const moduleCode = requiredCode(entry.moduleCode, "moduleCode");
|
|
1613
|
+
const featureCode = requiredCode(entry.featureCode, "featureCode");
|
|
1614
|
+
const permissionActionCode = requiredCode(
|
|
1615
|
+
entry.permissionActionCode,
|
|
1616
|
+
"permissionActionCode"
|
|
1617
|
+
);
|
|
1618
|
+
const permissionKey = requiredToken(entry.permissionKey, "permissionKey");
|
|
1619
|
+
const canonical = `${moduleCode}.${featureCode}.${permissionActionCode}`;
|
|
1620
|
+
if (permissionKey !== canonical) {
|
|
1621
|
+
throw new Error(
|
|
1622
|
+
`Permission key ${permissionKey} does not match ${canonical}`
|
|
1623
|
+
);
|
|
1624
|
+
}
|
|
1625
|
+
return {
|
|
1626
|
+
permissionKey,
|
|
1627
|
+
moduleCode,
|
|
1628
|
+
featureCode,
|
|
1629
|
+
permissionActionCode
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
function requiredCode(value, field) {
|
|
1633
|
+
const code = requiredToken(value, field);
|
|
1634
|
+
if (code.includes(".")) {
|
|
1635
|
+
throw new Error(`Permission registry ${field} must not contain '.'`);
|
|
1636
|
+
}
|
|
1637
|
+
return code;
|
|
1638
|
+
}
|
|
1639
|
+
function requiredToken(value, field) {
|
|
1640
|
+
if (typeof value !== "string" || value.trim() === "" || value !== value.trim()) {
|
|
1641
|
+
throw new Error(`Permission registry ${field} must be a non-empty code`);
|
|
1642
|
+
}
|
|
1643
|
+
return value;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1545
1646
|
// ../../libs/metadata-projection/src/lib/path/ProjectionPathBuilder.ts
|
|
1546
1647
|
var ProjectionPathBuilder = class {
|
|
1547
1648
|
prefix;
|
|
@@ -3482,6 +3583,7 @@ var MetadataDownloader = class {
|
|
|
3482
3583
|
expectedProjectionVersion;
|
|
3483
3584
|
logger;
|
|
3484
3585
|
loader;
|
|
3586
|
+
objectInFlight = /* @__PURE__ */ new Map();
|
|
3485
3587
|
constructor(options) {
|
|
3486
3588
|
if (!options.client) {
|
|
3487
3589
|
throw new RuntimeMetadataError(
|
|
@@ -3837,6 +3939,45 @@ var MetadataDownloader = class {
|
|
|
3837
3939
|
);
|
|
3838
3940
|
}
|
|
3839
3941
|
}
|
|
3942
|
+
async downloadPermissionRegistry(manifest) {
|
|
3943
|
+
const fileName = PROJECTION_FILE_NAME[PROJECTION_TYPE.PERMISSION_REGISTRY];
|
|
3944
|
+
const entry = manifest.files.find((file) => file.fileName === fileName);
|
|
3945
|
+
if (!entry) {
|
|
3946
|
+
throw new ProjectionDownloadError(
|
|
3947
|
+
"permission-registry.json is missing from the projection manifest",
|
|
3948
|
+
{
|
|
3949
|
+
retryable: false,
|
|
3950
|
+
metadata: { releaseId: manifest.releaseId, fileName }
|
|
3951
|
+
}
|
|
3952
|
+
);
|
|
3953
|
+
}
|
|
3954
|
+
const body = await this.getObjectBody(
|
|
3955
|
+
this.buildKey(manifest.releaseId, fileName)
|
|
3956
|
+
);
|
|
3957
|
+
let parsed;
|
|
3958
|
+
try {
|
|
3959
|
+
parsed = JSON.parse(body);
|
|
3960
|
+
} catch {
|
|
3961
|
+
throw new ProjectionDownloadError(`Corrupted JSON for ${fileName}`, {
|
|
3962
|
+
retryable: false,
|
|
3963
|
+
metadata: { fileName, releaseId: manifest.releaseId }
|
|
3964
|
+
});
|
|
3965
|
+
}
|
|
3966
|
+
try {
|
|
3967
|
+
return parsePermissionRegistryDocument(parsed, {
|
|
3968
|
+
releaseId: manifest.releaseId,
|
|
3969
|
+
contentHash: entry.contentHash
|
|
3970
|
+
});
|
|
3971
|
+
} catch (err) {
|
|
3972
|
+
throw new ProjectionDownloadError(
|
|
3973
|
+
err instanceof Error ? err.message : `Invalid permission registry for ${fileName}`,
|
|
3974
|
+
{
|
|
3975
|
+
retryable: false,
|
|
3976
|
+
metadata: { fileName, releaseId: manifest.releaseId }
|
|
3977
|
+
}
|
|
3978
|
+
);
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3840
3981
|
async downloadRelationshipIndex(manifest) {
|
|
3841
3982
|
const fileName = PROJECTION_FILE_NAME[PROJECTION_TYPE.RELATIONSHIP_INDEX];
|
|
3842
3983
|
const entry = manifest.files.find((f) => f.fileName === fileName);
|
|
@@ -3893,7 +4034,18 @@ var MetadataDownloader = class {
|
|
|
3893
4034
|
this.validateDownloadedFile(fileName, contentHash, parsed);
|
|
3894
4035
|
return parsed;
|
|
3895
4036
|
}
|
|
3896
|
-
|
|
4037
|
+
getObjectBody(key) {
|
|
4038
|
+
const existing = this.objectInFlight.get(key);
|
|
4039
|
+
if (existing) {
|
|
4040
|
+
return existing;
|
|
4041
|
+
}
|
|
4042
|
+
const pending = this.fetchObjectBody(key).finally(() => {
|
|
4043
|
+
this.objectInFlight.delete(key);
|
|
4044
|
+
});
|
|
4045
|
+
this.objectInFlight.set(key, pending);
|
|
4046
|
+
return pending;
|
|
4047
|
+
}
|
|
4048
|
+
async fetchObjectBody(key) {
|
|
3897
4049
|
try {
|
|
3898
4050
|
const resp = await this.client.send(
|
|
3899
4051
|
new GetObjectCommand({
|
|
@@ -5222,6 +5374,10 @@ var ExtensionMetadataProvider = class {
|
|
|
5222
5374
|
throw err;
|
|
5223
5375
|
}
|
|
5224
5376
|
}
|
|
5377
|
+
async getPermissionRegistry() {
|
|
5378
|
+
const body = await this.requestJson("GET", "/v1/permission-registry");
|
|
5379
|
+
return parsePermissionRegistryDocument(body);
|
|
5380
|
+
}
|
|
5225
5381
|
async getLocalizationValue(keyOrTypeCode, valueCodeOrLocale, maybeLocale) {
|
|
5226
5382
|
let key;
|
|
5227
5383
|
let locale;
|
|
@@ -5791,14 +5947,15 @@ function isExtensionServing(status) {
|
|
|
5791
5947
|
var S3MetadataProvider = class {
|
|
5792
5948
|
cache;
|
|
5793
5949
|
resolver;
|
|
5950
|
+
downloader;
|
|
5794
5951
|
ensureTypesLoaded;
|
|
5795
5952
|
logger;
|
|
5796
5953
|
constructor(options) {
|
|
5797
5954
|
this.cache = options.cache;
|
|
5798
5955
|
this.resolver = options.resolver;
|
|
5956
|
+
this.downloader = options.downloader;
|
|
5799
5957
|
this.ensureTypesLoaded = options.ensureTypesLoaded;
|
|
5800
5958
|
this.logger = options.logger ?? createLogger({ serviceName: "runtime-metadata" });
|
|
5801
|
-
void options.downloader;
|
|
5802
5959
|
}
|
|
5803
5960
|
async isAvailable() {
|
|
5804
5961
|
return this.cache.isReady();
|
|
@@ -5936,6 +6093,15 @@ var S3MetadataProvider = class {
|
|
|
5936
6093
|
});
|
|
5937
6094
|
return values;
|
|
5938
6095
|
}
|
|
6096
|
+
async getPermissionRegistry() {
|
|
6097
|
+
const manifest = this.cache.getManifest();
|
|
6098
|
+
if (!manifest) {
|
|
6099
|
+
throw new ProjectionDownloadError("Projection manifest is not loaded", {
|
|
6100
|
+
retryable: true
|
|
6101
|
+
});
|
|
6102
|
+
}
|
|
6103
|
+
return this.downloader.downloadPermissionRegistry(manifest);
|
|
6104
|
+
}
|
|
5939
6105
|
async getRelatedValueGroups(sourceTypeCode, sourceValueCodes, targetTypeCode, options) {
|
|
5940
6106
|
if (sourceValueCodes.length === 0) {
|
|
5941
6107
|
return [];
|
|
@@ -6323,6 +6489,8 @@ var RuntimeMetadataService = class {
|
|
|
6323
6489
|
logger;
|
|
6324
6490
|
/** Coalesce concurrent cold bootstrap (current.json + manifest.json). */
|
|
6325
6491
|
initializeInFlight = null;
|
|
6492
|
+
permissionRegistryInFlight = null;
|
|
6493
|
+
permissionRegistryCache = null;
|
|
6326
6494
|
/**
|
|
6327
6495
|
* In-flight selective downloads keyed by MetadataTypeCode.
|
|
6328
6496
|
* Concurrent requests (and overlapping type sets) share one download per type
|
|
@@ -6933,6 +7101,45 @@ var RuntimeMetadataService = class {
|
|
|
6933
7101
|
throw err;
|
|
6934
7102
|
}
|
|
6935
7103
|
}
|
|
7104
|
+
/**
|
|
7105
|
+
* Permission vocabulary for the active release.
|
|
7106
|
+
* Concurrent callers share one load. A failed load is not cached.
|
|
7107
|
+
* The last successful document is kept until the release id changes.
|
|
7108
|
+
*/
|
|
7109
|
+
async getPermissionRegistry() {
|
|
7110
|
+
if (!this.cache.isReady()) {
|
|
7111
|
+
await this.initialize();
|
|
7112
|
+
}
|
|
7113
|
+
const releaseId = this.cache.getReleaseId() ?? "";
|
|
7114
|
+
const cached = this.permissionRegistryCache;
|
|
7115
|
+
if (cached && cached.releaseId === releaseId && releaseId) {
|
|
7116
|
+
return cached.document;
|
|
7117
|
+
}
|
|
7118
|
+
if (!this.permissionRegistryInFlight) {
|
|
7119
|
+
this.permissionRegistryInFlight = this.loadPermissionRegistry(releaseId).finally(
|
|
7120
|
+
() => {
|
|
7121
|
+
this.permissionRegistryInFlight = null;
|
|
7122
|
+
}
|
|
7123
|
+
);
|
|
7124
|
+
}
|
|
7125
|
+
return this.permissionRegistryInFlight;
|
|
7126
|
+
}
|
|
7127
|
+
async loadPermissionRegistry(expectedReleaseId) {
|
|
7128
|
+
const provider = await this.activeProvider();
|
|
7129
|
+
const document = await provider.getPermissionRegistry();
|
|
7130
|
+
const currentReleaseId = this.cache.getReleaseId() ?? "";
|
|
7131
|
+
if (expectedReleaseId && currentReleaseId && expectedReleaseId !== currentReleaseId) {
|
|
7132
|
+
throw new MetadataReleaseMismatchError(expectedReleaseId, currentReleaseId);
|
|
7133
|
+
}
|
|
7134
|
+
if (currentReleaseId && document.releaseId !== currentReleaseId) {
|
|
7135
|
+
throw new MetadataReleaseMismatchError(currentReleaseId, document.releaseId);
|
|
7136
|
+
}
|
|
7137
|
+
this.permissionRegistryCache = {
|
|
7138
|
+
releaseId: document.releaseId,
|
|
7139
|
+
document
|
|
7140
|
+
};
|
|
7141
|
+
return document;
|
|
7142
|
+
}
|
|
6936
7143
|
async getRelatedValueGroups(sourceTypeCode, sourceValueCodes, targetTypeCode, options) {
|
|
6937
7144
|
try {
|
|
6938
7145
|
const provider = await this.activeProvider();
|
|
@@ -7415,12 +7622,14 @@ var InMemoryMetadataProvider = class {
|
|
|
7415
7622
|
typedRelationIndex;
|
|
7416
7623
|
knownTypeCodes = /* @__PURE__ */ new Set();
|
|
7417
7624
|
lifecycleSupported;
|
|
7625
|
+
permissionRegistry;
|
|
7418
7626
|
activeByType = /* @__PURE__ */ new Map();
|
|
7419
7627
|
inactiveByType = /* @__PURE__ */ new Map();
|
|
7420
7628
|
constructor(options = {}) {
|
|
7421
7629
|
this.releaseId = options.releaseId ?? "memory";
|
|
7422
7630
|
this.unavailable = options.unavailable === true;
|
|
7423
7631
|
this.lifecycleSupported = options.lifecycleSupported !== false;
|
|
7632
|
+
this.permissionRegistry = options.permissionRegistry;
|
|
7424
7633
|
this.relations = options.relations;
|
|
7425
7634
|
this.typedRelationIndex = options.relations ? buildTypedRelationIndex(options.relations) : void 0;
|
|
7426
7635
|
for (const typeCode of options.knownTypeCodes ?? []) {
|
|
@@ -7566,6 +7775,15 @@ var InMemoryMetadataProvider = class {
|
|
|
7566
7775
|
}
|
|
7567
7776
|
return this.relatedValuesFor(sourceTypeCode, sourceValueCode, targetTypeCode, options);
|
|
7568
7777
|
}
|
|
7778
|
+
async getPermissionRegistry() {
|
|
7779
|
+
if (this.unavailable || !this.permissionRegistry) {
|
|
7780
|
+
throw new MetadataProjectionUnavailableError(
|
|
7781
|
+
"Permission registry is not available",
|
|
7782
|
+
{ retryable: this.unavailable }
|
|
7783
|
+
);
|
|
7784
|
+
}
|
|
7785
|
+
return this.permissionRegistry;
|
|
7786
|
+
}
|
|
7569
7787
|
async getRelatedValueGroups(sourceTypeCode, sourceValueCodes, targetTypeCode, options) {
|
|
7570
7788
|
if (this.unavailable) {
|
|
7571
7789
|
throw new MetadataProjectionUnavailableError(
|