@myvitalrx/metadata-runtime 1.16.0 → 1.17.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.js CHANGED
@@ -1,9 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
3
- import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
4
- import crypto, { createHash } from 'crypto';
5
- import { AsyncLocalStorage } from 'async_hooks';
6
- import { Logger } from '@aws-lambda-powertools/logger';
2
+ import { createHash } from 'crypto';
3
+ import { createLogger, createOperationalLogger, createPerformanceTimer, getContext } from '@api-hub/observability';
7
4
  import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
8
5
 
9
6
  // ../../libs/runtime-metadata/src/lib/constants/RuntimeMetadataConstants.ts
@@ -32,6 +29,10 @@ var RUNTIME_METADATA_EVENTS = {
32
29
  DOWNLOAD_COMPLETE: "runtimeMetadata.download.complete",
33
30
  DOWNLOAD_FAILED: "runtimeMetadata.download.failed",
34
31
  MANIFEST_LOADED: "runtimeMetadata.manifest.loaded",
32
+ /** Runtime cache received a release catalog (extension status or S3 manifest). */
33
+ METADATA_MANIFEST_LOADED: "metadata.manifest.loaded",
34
+ /** supportsType decision against the published type catalog. */
35
+ METADATA_TYPE_CHECK: "metadata.type.check",
35
36
  /** Authoritative keys after manifest parse (metadataTypes + lookupIndex type prefixes). */
36
37
  PROJECTION_MANIFEST_LOADED: "projection.manifest.loaded",
37
38
  /** Per-file download begin. */
@@ -138,25 +139,13 @@ var PROJECTION_STATUS = {
138
139
  function lookupIndexKey(typeCode, valueCode) {
139
140
  return `${typeCode}:${valueCode}`;
140
141
  }
142
+
143
+ // ../../libs/metadata/src/constants/index.ts
141
144
  var STATUS = {
142
145
  ACTIVE: "ACTIVE",
143
146
  INACTIVE: "INACTIVE",
144
147
  DELETED: "DELETED"
145
148
  };
146
- var region = process.env.DEFAULT_REGION || process.env.DP_REGION || "us-east-1";
147
- var config = {
148
- region
149
- };
150
- var ddbClient = new DynamoDBClient(config);
151
- DynamoDBDocumentClient.from(ddbClient, {
152
- marshallOptions: {
153
- removeUndefinedValues: true,
154
- convertClassInstanceToMap: true
155
- },
156
- unmarshallOptions: {
157
- wrapNumbers: false
158
- }
159
- });
160
149
 
161
150
  // ../../libs/utils/src/helper/object.helpers.ts
162
151
  function stableStringify(value) {
@@ -191,553 +180,6 @@ function sha256Hex(data) {
191
180
  return createHash("sha256").update(data).digest("hex");
192
181
  }
193
182
 
194
- // ../../libs/observability/src/config/config.ts
195
- var LEVEL_TO_FLOOR = {
196
- DEBUG: 10,
197
- INFO: 20,
198
- WARN: 30,
199
- ERROR: 40
200
- };
201
- function clamp01(n) {
202
- if (Number.isNaN(n) || n < 0) return 0;
203
- if (n > 1) return 1;
204
- return n;
205
- }
206
- function normalizeLogLevel(value) {
207
- const u = (value ?? "").toUpperCase();
208
- if (u === "DEBUG" || u === "WARN" || u === "ERROR" || u === "INFO") {
209
- return u;
210
- }
211
- return "ERROR";
212
- }
213
- function getDefaultInput() {
214
- return {
215
- serviceName: process.env.SERVICE_NAME ?? "unknown-service",
216
- logLevel: normalizeLogLevel(process.env.LOG_LEVEL),
217
- sampling: {
218
- info: Number(process.env.LOG_SAMPLE_INFO ?? 1),
219
- debug: Number(process.env.LOG_SAMPLE_DEBUG ?? 0.01)
220
- },
221
- redactPII: process.env.REDACT_PII !== "false",
222
- enforceLogPolicy: true,
223
- metricsNamespace: process.env.METRICS_NAMESPACE ?? "ApiHub",
224
- logPolicyViolationsToStderr: process.env.LOG_POLICY_STDERR === "true"
225
- };
226
- }
227
- function resolveConfig(input) {
228
- const logLevel = normalizeLogLevel(input.logLevel);
229
- const sampling = input.sampling ?? {};
230
- return {
231
- serviceName: input.serviceName ?? "unknown-service",
232
- logLevel,
233
- logLevelFloor: LEVEL_TO_FLOOR[logLevel],
234
- sampling: {
235
- info: clamp01(sampling.info ?? 1),
236
- debug: clamp01(sampling.debug ?? 0.01)
237
- },
238
- redactPII: input.redactPII ?? true,
239
- enforceLogPolicy: input.enforceLogPolicy ?? true,
240
- metricsNamespace: input.metricsNamespace ?? "ApiHub",
241
- logPolicyViolationsToStderr: input.logPolicyViolationsToStderr ?? false
242
- };
243
- }
244
- var overrideInput = {};
245
- var resolved = null;
246
- function configureObservability(input) {
247
- overrideInput = {
248
- ...overrideInput,
249
- ...input
250
- };
251
- resolved = null;
252
- }
253
- function getConfig() {
254
- if (!resolved) {
255
- const base = getDefaultInput();
256
- const merged = {
257
- ...base,
258
- ...overrideInput,
259
- sampling: {
260
- ...base.sampling,
261
- ...overrideInput.sampling
262
- }
263
- };
264
- resolved = resolveConfig(merged);
265
- }
266
- return resolved;
267
- }
268
- var store = new AsyncLocalStorage();
269
- var getContext = () => {
270
- return store.getStore() ?? { correlationId: "unknown" };
271
- };
272
- var baseLogger;
273
- function getBaseLogger() {
274
- if (!baseLogger) {
275
- baseLogger = new Logger({
276
- serviceName: process.env.SERVICE_NAME || "unknown-service",
277
- logLevel: process.env.LOG_LEVEL || "ERROR"
278
- });
279
- }
280
- return baseLogger;
281
- }
282
-
283
- // ../../libs/observability/src/logger/level-sampling.ts
284
- function shouldSample(level) {
285
- const cfg = getConfig();
286
- if (level === "INFO") {
287
- return Math.random() < cfg.sampling.info;
288
- }
289
- if (level === "DEBUG") {
290
- return Math.random() < cfg.sampling.debug;
291
- }
292
- return true;
293
- }
294
-
295
- // ../../libs/observability/src/core/pii.ts
296
- var KEY_REDACT = /* @__PURE__ */ new Set([
297
- "password",
298
- "email",
299
- "phone",
300
- "token",
301
- "authorization",
302
- "cookie",
303
- "set-cookie"
304
- ]);
305
- var EMAIL_RE = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
306
- var PHONE_RE = /(?:\+?\d{1,3}[-.\s]?)?(?:\(?\d{3}\)?[-.\s]?){2}\d{4}/g;
307
- var JWT_LIKE_RE = /eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g;
308
- var BEARER_RE = /Bearer\s+[A-Za-z0-9\-._~+/]+=*/gi;
309
- var toLowerKey = (value) => value.toLowerCase();
310
- function redactStringPattern(value) {
311
- let out = value;
312
- out = out.replace(EMAIL_RE, "[REDACTED_EMAIL]");
313
- out = out.replace(BEARER_RE, "Bearer [REDACTED]");
314
- out = out.replace(JWT_LIKE_RE, "[REDACTED_TOKEN]");
315
- out = out.replace(PHONE_RE, "[REDACTED_PHONE]");
316
- return out;
317
- }
318
- function redactPiiValue(data, _config) {
319
- if (Array.isArray(data)) {
320
- return data.map((item) => redactPiiValue(item));
321
- }
322
- if (typeof data === "string") {
323
- return redactStringPattern(data);
324
- }
325
- if (typeof data !== "object" || data === null) {
326
- return data;
327
- }
328
- const output = {};
329
- for (const [key, value] of Object.entries(data)) {
330
- if (KEY_REDACT.has(toLowerKey(key))) {
331
- output[key] = "[REDACTED]";
332
- continue;
333
- }
334
- if (typeof value === "string") {
335
- output[key] = redactStringPattern(value);
336
- } else {
337
- output[key] = redactPiiValue(value);
338
- }
339
- }
340
- return output;
341
- }
342
-
343
- // ../../libs/observability/src/logger/controlled-logging.ts
344
- function enforcePolicy(payload) {
345
- if (!payload || typeof payload !== "object") return payload;
346
- const cfg = getConfig();
347
- let cloned = { ...payload };
348
- if ("request" in cloned) cloned.request = "[BLOCKED]";
349
- if ("response" in cloned) cloned.response = "[BLOCKED]";
350
- if (cfg.redactPII) {
351
- cloned = redactPiiValue(cloned);
352
- }
353
- return cloned;
354
- }
355
-
356
- // ../../libs/observability/src/core/utils.ts
357
- var safeStringify = (value) => {
358
- const visited = /* @__PURE__ */ new WeakSet();
359
- return JSON.stringify(value, (_key, current) => {
360
- if (typeof current === "object" && current !== null) {
361
- if (visited.has(current)) {
362
- return "[Circular]";
363
- }
364
- visited.add(current);
365
- }
366
- return current;
367
- });
368
- };
369
- var safeParse = (value) => {
370
- const serialized = safeStringify(value);
371
- return JSON.parse(serialized);
372
- };
373
-
374
- // ../../libs/observability/src/logger/serialize-error.ts
375
- function isErrorLike(error) {
376
- if (error instanceof Error) {
377
- return true;
378
- }
379
- if (typeof error !== "object" || error === null) {
380
- return false;
381
- }
382
- const candidate = error;
383
- return typeof candidate.message === "string";
384
- }
385
- function serializeErrorLike(error) {
386
- return {
387
- name: error.name ?? "Error",
388
- message: error.message,
389
- ...error.stack ? { stack: error.stack } : {},
390
- ...typeof error.code === "string" ? { code: error.code } : {},
391
- ...typeof error.statusCode === "number" ? { statusCode: error.statusCode } : {},
392
- ...error.details !== void 0 ? { details: safeParse(error.details) } : {},
393
- ...error.cause !== void 0 ? { cause: safeParse(error.cause) } : {}
394
- };
395
- }
396
- function serializeError(error) {
397
- if (isErrorLike(error)) {
398
- return serializeErrorLike(error);
399
- }
400
- if (typeof error === "object" && error !== null) {
401
- return {
402
- name: "SerializedUnknownRejection",
403
- message: "Non-Error value logged",
404
- value: safeParse(error)
405
- };
406
- }
407
- return {
408
- name: "UnknownError",
409
- message: String(error)
410
- };
411
- }
412
-
413
- // ../../libs/observability/src/logger/logger.ts
414
- function getLogger(extra) {
415
- const base = getBaseLogger();
416
- const ctx = getContext();
417
- const child = base.createChild();
418
- child.appendKeys({
419
- ...ctx,
420
- ...extra,
421
- correlationId: ctx.correlationId,
422
- awsRequestId: ctx.awsRequestId,
423
- functionName: ctx.functionName
424
- });
425
- return {
426
- debug: (msg, payload) => {
427
- if (shouldSample("DEBUG")) {
428
- child.debug(msg, enforcePolicy(payload));
429
- }
430
- },
431
- info: (msg, payload) => {
432
- if (shouldSample("INFO")) {
433
- child.info(msg, enforcePolicy(payload));
434
- }
435
- },
436
- warn: (msg, payload) => {
437
- child.warn(msg, enforcePolicy(payload));
438
- },
439
- error: (msg, err, payload) => {
440
- child.error(msg, {
441
- ...enforcePolicy(payload),
442
- error: serializeError(err)
443
- // 🔥 ALWAYS structured
444
- });
445
- }
446
- };
447
- }
448
-
449
- // ../../libs/observability/src/logger/structured-logger.ts
450
- function applyLoggerOptions(options) {
451
- if (!options) return;
452
- const serviceName = options.serviceName ?? options.service;
453
- if (serviceName !== void 0 || options.redactPII !== void 0) {
454
- configureObservability({
455
- ...serviceName !== void 0 ? { serviceName } : {},
456
- ...options.redactPII !== void 0 ? { redactPII: options.redactPII } : {}
457
- });
458
- }
459
- }
460
- var StructuredLogger = class {
461
- constructor(persistentKeys = {}) {
462
- this.persistentKeys = persistentKeys;
463
- }
464
- persistentKeys;
465
- getPersistentKeys() {
466
- return { ...this.persistentKeys };
467
- }
468
- info(entry) {
469
- const { event = "log", ...rest } = entry;
470
- getLogger(this.persistentKeys).info(String(event), rest);
471
- }
472
- warn(entry) {
473
- const { event = "log", ...rest } = entry;
474
- getLogger(this.persistentKeys).warn(String(event), rest);
475
- }
476
- error(entry) {
477
- const { event = "log", err, error: err2, ...rest } = entry;
478
- const errVal = err ?? err2;
479
- getLogger(this.persistentKeys).error(String(event), errVal, rest);
480
- }
481
- debug(entry) {
482
- const { event = "log", ...rest } = entry;
483
- getLogger(this.persistentKeys).debug(String(event), rest);
484
- }
485
- http(entry) {
486
- this.info(entry);
487
- }
488
- verbose(entry) {
489
- this.debug(entry);
490
- }
491
- };
492
- function createLogger(options) {
493
- applyLoggerOptions(options);
494
- return new StructuredLogger();
495
- }
496
-
497
- // ../../libs/observability/src/http/performance-timer.ts
498
- function createTimer(operation, correlationId) {
499
- const startTime = Date.now();
500
- return {
501
- end: () => {
502
- const duration = Date.now() - startTime;
503
- getLogger().info("performance_timer", {
504
- operation,
505
- duration,
506
- correlationId
507
- });
508
- }
509
- };
510
- }
511
- function createPerformanceTimer(...args) {
512
- if (typeof args[0] === "string") {
513
- return createTimer(
514
- args[0],
515
- typeof args[1] === "string" ? args[1] : void 0
516
- );
517
- }
518
- if (typeof args[1] === "string") {
519
- return createTimer(
520
- args[1],
521
- typeof args[2] === "string" ? args[2] : void 0
522
- );
523
- }
524
- throw new Error(
525
- "createPerformanceTimer: expected (operation, correlationId?) or (logger, operation, correlationId?)"
526
- );
527
- }
528
-
529
- // ../../libs/observability/src/logging/operational-logger.ts
530
- var LEVEL_RANK = {
531
- DEBUG: 10,
532
- INFO: 20,
533
- WARN: 30,
534
- ERROR: 40
535
- };
536
- var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
537
- "payload",
538
- "body",
539
- "records",
540
- "items",
541
- "relationships",
542
- "token",
543
- "authorization",
544
- "secret",
545
- "password",
546
- "accesskey",
547
- "accesskeyid",
548
- "secretaccesskey",
549
- "sessiontoken",
550
- "credentials",
551
- "cookie",
552
- "metadata",
553
- "response",
554
- "request",
555
- "attributes",
556
- "lookupindex",
557
- "domainfiles",
558
- "snapshot"
559
- ]);
560
- var METADATA_LOG_DEFAULTS = {
561
- SLOW_HTTP_MS: 100,
562
- SLOW_S3_MS: 500,
563
- SLOW_REFRESH_MS: 2e3,
564
- SLOW_LOOKUP_MS: 50,
565
- SLOW_INIT_MS: 3e3,
566
- SUMMARY_EVERY: 200
567
- };
568
- function resolveMetadataLogPolicy(env = process.env) {
569
- const verbose = isTruthy(env.METADATA_LOG_VERBOSE);
570
- const level = verbose ? "DEBUG" : normalizeLevel(env.METADATA_LOG_LEVEL ?? env.LOG_LEVEL) ?? "INFO";
571
- return {
572
- level,
573
- verbose,
574
- sampleInfo: sampleRate(env.METADATA_LOG_SAMPLE_INFO, 1),
575
- sampleDebug: sampleRate(env.METADATA_LOG_SAMPLE_DEBUG, 1),
576
- slowHttpMs: positiveInt(env.METADATA_SLOW_HTTP_MS, METADATA_LOG_DEFAULTS.SLOW_HTTP_MS),
577
- slowS3Ms: positiveInt(env.METADATA_SLOW_S3_MS, METADATA_LOG_DEFAULTS.SLOW_S3_MS),
578
- slowRefreshMs: positiveInt(
579
- env.METADATA_SLOW_REFRESH_MS,
580
- METADATA_LOG_DEFAULTS.SLOW_REFRESH_MS
581
- ),
582
- slowLookupMs: positiveInt(
583
- env.METADATA_SLOW_LOOKUP_MS,
584
- METADATA_LOG_DEFAULTS.SLOW_LOOKUP_MS
585
- ),
586
- slowInitMs: positiveInt(env.METADATA_SLOW_INIT_MS, METADATA_LOG_DEFAULTS.SLOW_INIT_MS),
587
- summaryEvery: nonNegativeInt(
588
- env.METADATA_LOG_SUMMARY_EVERY,
589
- METADATA_LOG_DEFAULTS.SUMMARY_EVERY
590
- )
591
- };
592
- }
593
- function createOperationalLogger(sink, env = process.env) {
594
- const policy = resolveMetadataLogPolicy(env);
595
- function enabled(level) {
596
- return LEVEL_RANK[policy.level] <= LEVEL_RANK[methodLevel(level)];
597
- }
598
- function emit(level, event, fields) {
599
- if (!enabled(level)) {
600
- return;
601
- }
602
- if (level === "info" && !sampled(policy.sampleInfo)) {
603
- return;
604
- }
605
- if (level === "debug" && !sampled(policy.sampleDebug)) {
606
- return;
607
- }
608
- const entry = {
609
- event,
610
- ...sanitize(resolveFields(fields))
611
- };
612
- deliver(sink, level, entry, env);
613
- }
614
- return {
615
- policy,
616
- isEnabled: enabled,
617
- debug: (event, fields) => emit("debug", event, fields),
618
- info: (event, fields) => emit("info", event, fields),
619
- warn: (event, fields) => emit("warn", event, fields),
620
- error: (event, fields) => emit("error", event, fields),
621
- observe(input) {
622
- const slow = input.durationMs >= input.thresholdMs;
623
- if (slow) {
624
- if (!enabled("warn")) {
625
- return;
626
- }
627
- emit("warn", input.event, () => ({
628
- ...resolveFields(input.fields),
629
- durationMs: input.durationMs,
630
- thresholdMs: input.thresholdMs,
631
- slow: true
632
- }));
633
- return;
634
- }
635
- emit("debug", input.event, () => ({
636
- ...resolveFields(input.fields),
637
- durationMs: input.durationMs
638
- }));
639
- }
640
- };
641
- }
642
- function deliver(sink, level, entry, env) {
643
- if (level === "debug" && !platformEmits("debug", env)) {
644
- sink.info({ ...entry, logLevel: "debug" });
645
- return;
646
- }
647
- const method = sink[level];
648
- if (typeof method === "function") {
649
- method.call(sink, entry);
650
- }
651
- }
652
- function platformEmits(level, env) {
653
- const platform = normalizeLevel(env.LOG_LEVEL) ?? "ERROR";
654
- return LEVEL_RANK[platform] <= LEVEL_RANK[methodLevel(level)];
655
- }
656
- function methodLevel(level) {
657
- switch (level) {
658
- case "debug":
659
- return "DEBUG";
660
- case "info":
661
- return "INFO";
662
- case "warn":
663
- return "WARN";
664
- default:
665
- return "ERROR";
666
- }
667
- }
668
- function resolveFields(fields) {
669
- if (!fields) {
670
- return {};
671
- }
672
- return typeof fields === "function" ? fields() : fields;
673
- }
674
- function sanitize(fields) {
675
- const out = {};
676
- for (const [key, value] of Object.entries(fields)) {
677
- if (value === void 0 || SENSITIVE_KEYS.has(key.toLowerCase())) {
678
- continue;
679
- }
680
- if (key === "message" && typeof value === "string") {
681
- if (out.errorMessage === void 0) {
682
- out.errorMessage = value;
683
- }
684
- continue;
685
- }
686
- out[key] = value;
687
- }
688
- return out;
689
- }
690
- function normalizeLevel(value) {
691
- const upper = (value ?? "").trim().toUpperCase();
692
- if (upper === "DEBUG" || upper === "INFO" || upper === "WARN" || upper === "ERROR") {
693
- return upper;
694
- }
695
- return void 0;
696
- }
697
- function sampleRate(raw, fallback) {
698
- if (raw == null || raw.trim() === "") {
699
- return fallback;
700
- }
701
- const parsed = Number(raw);
702
- if (!Number.isFinite(parsed) || parsed < 0) {
703
- return 0;
704
- }
705
- if (parsed > 1) {
706
- return 1;
707
- }
708
- return parsed;
709
- }
710
- function sampled(rate) {
711
- if (rate <= 0) {
712
- return false;
713
- }
714
- if (rate >= 1) {
715
- return true;
716
- }
717
- return Math.random() < rate;
718
- }
719
- function positiveInt(raw, fallback) {
720
- const parsed = Number(raw);
721
- if (!raw || !Number.isFinite(parsed) || parsed < 0) {
722
- return fallback;
723
- }
724
- return Math.floor(parsed);
725
- }
726
- function nonNegativeInt(raw, fallback) {
727
- if (raw == null || raw.trim() === "") {
728
- return fallback;
729
- }
730
- const parsed = Number(raw);
731
- if (!Number.isFinite(parsed) || parsed < 0) {
732
- return fallback;
733
- }
734
- return Math.floor(parsed);
735
- }
736
- function isTruthy(value) {
737
- const normalized = (value ?? "").trim().toLowerCase();
738
- return normalized === "true" || normalized === "1" || normalized === "yes";
739
- }
740
-
741
183
  // ../../libs/utils/src/errors/base.error.ts
742
184
  var BaseError = class extends Error {
743
185
  statusCode;
@@ -757,390 +199,10 @@ var BaseError = class extends Error {
757
199
  }
758
200
  };
759
201
 
760
- // ../../libs/utils/src/middleware/withLambdaHandler.ts
761
- createLogger({
762
- service: "api-service",
763
- redactPII: true
764
- });
765
- createLogger({
766
- service: "dynamo-repository",
767
- redactPII: true
768
- });
769
-
770
202
  // ../../libs/metadata/src/models/relation-types.ts
771
- var RELATION_TYPES = [
772
- "PARENT_CHILD",
773
- "VALID_IN",
774
- "SUPPORTED_BY",
775
- "BELONGS_TO_CATEGORY",
776
- "REQUIRES"
777
- ];
778
203
  var RELATION_STATUS = {
779
204
  ACTIVE: "ACTIVE"};
780
205
 
781
- // ../../libs/metadata/src/validators/code-patterns.ts
782
- var METADATA_TYPE_CODE_PATTERN = /^[A-Z][A-Za-z0-9]*$/;
783
- var METADATA_VALUE_CODE_PATTERN = /^[A-Z0-9]+(_[A-Z0-9]+)*$/;
784
-
785
- // ../../libs/metadata/src/validators/relation.ts
786
- new Set(RELATION_TYPES);
787
-
788
- // ../../libs/metadata/src/domain/lifecycle-filter.ts
789
- var LIFECYCLE_QUERY_STATUS = {
790
- ACTIVE: "ACTIVE",
791
- INACTIVE: "INACTIVE",
792
- DELETED: "DELETED",
793
- ALL: "ALL"
794
- };
795
- new Set(Object.values(LIFECYCLE_QUERY_STATUS));
796
- var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
797
- var ENCODING_LEN = 32;
798
- var RANDOM_LEN = 16;
799
- var TIME_LEN = 10;
800
- var TIME_MAX = 281474976710655;
801
- var ULIDErrorCode;
802
- (function(ULIDErrorCode2) {
803
- ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
804
- ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
805
- ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
806
- ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
807
- ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
808
- ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
809
- ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
810
- ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
811
- ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
812
- ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
813
- })(ULIDErrorCode || (ULIDErrorCode = {}));
814
- var ULIDError = class extends Error {
815
- constructor(errorCode, message) {
816
- super(`${message} (${errorCode})`);
817
- this.name = "ULIDError";
818
- this.code = errorCode;
819
- }
820
- };
821
- function randomChar(prng) {
822
- const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
823
- return ENCODING.charAt(randomPosition);
824
- }
825
- function replaceCharAt(str, index, char) {
826
- if (index > str.length - 1) {
827
- return str;
828
- }
829
- return str.substr(0, index) + char + str.substr(index + 1);
830
- }
831
- function incrementBase32(str) {
832
- let done = void 0, index = str.length, char, charIndex, output = str;
833
- const maxCharIndex = ENCODING_LEN - 1;
834
- while (!done && index-- >= 0) {
835
- char = output[index];
836
- charIndex = ENCODING.indexOf(char);
837
- if (charIndex === -1) {
838
- throw new ULIDError(ULIDErrorCode.Base32IncorrectEncoding, "Incorrectly encoded string");
839
- }
840
- if (charIndex === maxCharIndex) {
841
- output = replaceCharAt(output, index, ENCODING[0]);
842
- continue;
843
- }
844
- done = replaceCharAt(output, index, ENCODING[charIndex + 1]);
845
- }
846
- if (typeof done === "string") {
847
- return done;
848
- }
849
- throw new ULIDError(ULIDErrorCode.Base32IncorrectEncoding, "Failed incrementing string");
850
- }
851
- function detectPRNG(root) {
852
- const rootLookup = detectRoot();
853
- const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof crypto !== "undefined" ? crypto : null);
854
- if (typeof globalCrypto?.getRandomValues === "function") {
855
- return () => {
856
- const buffer = new Uint8Array(1);
857
- globalCrypto.getRandomValues(buffer);
858
- return buffer[0] / 256;
859
- };
860
- } else if (typeof globalCrypto?.randomBytes === "function") {
861
- return () => globalCrypto.randomBytes(1).readUInt8() / 256;
862
- } else if (crypto?.randomBytes) {
863
- return () => crypto.randomBytes(1).readUInt8() / 256;
864
- }
865
- throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
866
- }
867
- function detectRoot() {
868
- if (inWebWorker())
869
- return self;
870
- if (typeof window !== "undefined") {
871
- return window;
872
- }
873
- if (typeof global !== "undefined") {
874
- return global;
875
- }
876
- if (typeof globalThis !== "undefined") {
877
- return globalThis;
878
- }
879
- return null;
880
- }
881
- function encodeRandom(len, prng) {
882
- let str = "";
883
- for (; len > 0; len--) {
884
- str = randomChar(prng) + str;
885
- }
886
- return str;
887
- }
888
- function encodeTime(now, len = TIME_LEN) {
889
- if (isNaN(now)) {
890
- throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now}`);
891
- } else if (now > TIME_MAX) {
892
- throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now}`);
893
- } else if (now < 0) {
894
- throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now}`);
895
- } else if (Number.isInteger(now) === false) {
896
- throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now}`);
897
- }
898
- let mod, str = "";
899
- for (let currentLen = len; currentLen > 0; currentLen--) {
900
- mod = now % ENCODING_LEN;
901
- str = ENCODING.charAt(mod) + str;
902
- now = (now - mod) / ENCODING_LEN;
903
- }
904
- return str;
905
- }
906
- function inWebWorker() {
907
- return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
908
- }
909
- function monotonicFactory(prng) {
910
- const currentPRNG = detectPRNG();
911
- let lastTime = 0, lastRandom;
912
- return function _ulid(seedTime) {
913
- const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
914
- if (seed <= lastTime) {
915
- const incrementedRandom = lastRandom = incrementBase32(lastRandom);
916
- return encodeTime(lastTime, TIME_LEN) + incrementedRandom;
917
- }
918
- lastTime = seed;
919
- const newRandom = lastRandom = encodeRandom(RANDOM_LEN, currentPRNG);
920
- return encodeTime(seed, TIME_LEN) + newRandom;
921
- };
922
- }
923
-
924
- // ../../libs/metadata/src/repositories/dynamodb/metadata.repository.impl.ts
925
- monotonicFactory();
926
- monotonicFactory();
927
- var RELATION_TYPE_ZOD_ENUM = RELATION_TYPES;
928
- var contextSchema = z.object({
929
- module: z.string().min(1),
930
- category: z.string().min(1),
931
- condition: z.string().min(1),
932
- country: z.string().min(1)
933
- });
934
- z.object({
935
- metadataTypeCode: z.string().regex(METADATA_TYPE_CODE_PATTERN, "Invalid metadataTypeCode"),
936
- displayName: z.string().min(1).max(100),
937
- description: z.string().optional(),
938
- valueDataType: z.enum(["Enum", "Numeric", "Boolean", "Text"]),
939
- multiSelectAllowed: z.boolean(),
940
- applicableModules: z.array(z.string()).optional(),
941
- attributeSchema: z.record(z.string(), z.unknown()).optional(),
942
- status: z.enum(["ACTIVE", "INACTIVE"]),
943
- supportsRelations: z.boolean().optional(),
944
- relationFieldLabel: z.string().max(150).nullable().optional(),
945
- targetMetadataTypeCode: z.string().regex(METADATA_TYPE_CODE_PATTERN).nullable().optional(),
946
- selectionMode: z.enum(["SINGLE", "MULTI"]).nullable().optional(),
947
- relationRequired: z.boolean().nullable().optional(),
948
- relationType: z.enum(RELATION_TYPE_ZOD_ENUM).nullable().optional(),
949
- createdBy: z.string().optional(),
950
- lastModifiedBy: z.string().optional()
951
- });
952
- z.object({
953
- status: z.enum(["ACTIVE", "INACTIVE"]),
954
- lastModifiedBy: z.string().optional()
955
- });
956
- var applicabilityObjectSchema = z.object({
957
- module: z.array(z.string()),
958
- category: z.array(z.string()),
959
- condition: z.array(z.string()),
960
- country: z.array(z.string()),
961
- language: z.array(z.string()).optional()
962
- });
963
- z.object({
964
- valueCode: z.string().regex(METADATA_VALUE_CODE_PATTERN, "Invalid valueCode").optional(),
965
- metadataValueCode: z.string().regex(METADATA_VALUE_CODE_PATTERN, "Invalid metadataValueCode").optional(),
966
- label: z.string().min(1).max(150),
967
- description: z.string().max(2e3).optional(),
968
- sortOrder: z.number().int().min(0).optional(),
969
- status: z.enum(["ACTIVE", "INACTIVE"]),
970
- isGlobal: z.boolean(),
971
- attributes: z.record(z.string(), z.unknown()).optional(),
972
- valueAttributes: z.record(z.string(), z.unknown()).optional(),
973
- applicability: applicabilityObjectSchema.optional(),
974
- applicableModules: z.array(z.string()).optional(),
975
- applicableCategories: z.array(z.string()).optional(),
976
- applicableConditions: z.array(z.string()).optional(),
977
- applicableCountries: z.array(z.string()).optional(),
978
- applicableLanguages: z.array(z.string()).optional(),
979
- relationships: z.array(
980
- z.object({
981
- targetMetadataValueCode: z.string().regex(METADATA_VALUE_CODE_PATTERN, "Invalid targetMetadataValueCode")
982
- })
983
- ).optional()
984
- }).refine((b) => !!(b.valueCode || b.metadataValueCode), { message: "valueCode or metadataValueCode is required" });
985
- z.object({
986
- metadataTypeCode: z.string().min(1),
987
- metadataValueCode: z.string().min(1),
988
- context: contextSchema
989
- });
990
- var paginationSchema = z.object({
991
- limit: z.coerce.number().int().min(1).max(100).optional().default(50),
992
- nextToken: z.string().optional()
993
- });
994
- paginationSchema.extend({
995
- module: z.string().optional(),
996
- category: z.string().optional(),
997
- condition: z.string().optional(),
998
- country: z.string().optional(),
999
- language: z.string().optional()
1000
- });
1001
- z.object({
1002
- dimension: z.enum(["module", "category", "condition", "country", "language"], {
1003
- message: "dimension must be module, category, condition, country, or language"
1004
- })
1005
- });
1006
- z.object({
1007
- limit: z.coerce.number().int().min(1).max(100).optional().default(50),
1008
- nextToken: z.string().optional()
1009
- });
1010
- z.object({
1011
- metadataTypeCode: z.string().regex(METADATA_TYPE_CODE_PATTERN, "Invalid metadataTypeCode")
1012
- });
1013
- z.object({
1014
- metadataTypeCode: z.string().regex(METADATA_TYPE_CODE_PATTERN, "Invalid metadataTypeCode"),
1015
- metadataValueCode: z.string().regex(METADATA_VALUE_CODE_PATTERN, "Invalid metadataValueCode")
1016
- });
1017
-
1018
- // ../../libs/metadata/src/validators/validate-inputs.ts
1019
- new Set(RELATION_TYPES);
1020
-
1021
- // ../../libs/metadata/src/mappers/metadata-request.mapper.ts
1022
- createLogger({
1023
- service: "metadata-registry-service",
1024
- redactPII: true
1025
- });
1026
-
1027
- // ../../libs/metadata/src/change-policy/types/policy-group.codes.ts
1028
- var POLICY_GROUP = {
1029
- IDENTITY_IMMUTABLE: "IDENTITY_IMMUTABLE",
1030
- DISPLAY_ONLY: "DISPLAY_ONLY",
1031
- AVAILABILITY_STATUS: "AVAILABILITY_STATUS",
1032
- APPLICABILITY_SCOPE: "APPLICABILITY_SCOPE",
1033
- STRUCTURED_BEHAVIOR: "STRUCTURED_BEHAVIOR",
1034
- CLINICAL_INTERPRETATION: "CLINICAL_INTERPRETATION",
1035
- EXPANDABLE_OPTION: "EXPANDABLE_OPTION",
1036
- FIXED_TEMPLATE_VALUE: "FIXED_TEMPLATE_VALUE",
1037
- RUNTIME_PINNED: "RUNTIME_PINNED"
1038
- };
1039
- var POLICY_GROUP_CODES = Object.values(POLICY_GROUP);
1040
- var VERSION_IMPACT = {
1041
- DESCRIPTIVE: "Descriptive",
1042
- ADDITIVE: "Additive",
1043
- BREAKING: "Breaking"
1044
- };
1045
- var VERSION_IMPACT_CODES = Object.values(VERSION_IMPACT);
1046
- var RUNTIME_IMPACT = {
1047
- NONE: "None",
1048
- DISPLAY_ONLY: "DisplayOnly",
1049
- REVIEW_REQUIRED: "ReviewRequired",
1050
- MIGRATION_REQUIRED: "MigrationRequired"
1051
- };
1052
- var RUNTIME_IMPACT_CODES = Object.values(RUNTIME_IMPACT);
1053
- var MERGE_BEHAVIOR = {
1054
- SILENT_DISPLAY_REFRESH: "SilentDisplayRefresh",
1055
- ADD_ONLY: "AddOnly",
1056
- PRESERVE_ORG_OVERRIDE: "PreserveOrgOverride",
1057
- MANUAL_REVIEW: "ManualReview",
1058
- BLOCK: "Block"
1059
- };
1060
- var MERGE_BEHAVIOR_CODES = Object.values(MERGE_BEHAVIOR);
1061
- var CHANGE_POLICY_OPERATION = {
1062
- ADD: "Add",
1063
- UPDATE: "Update",
1064
- INACTIVATE: "Inactivate",
1065
- RETIRE: "Retire",
1066
- PUBLISH: "Publish"
1067
- };
1068
- var CHANGE_POLICY_OPERATION_CODES = Object.values(CHANGE_POLICY_OPERATION);
1069
- var APPLICABILITY_CHANGE_KIND = {
1070
- EXPAND: "Expand",
1071
- RESTRICT: "Restrict",
1072
- ANY: "Any"
1073
- };
1074
- var APPLICABILITY_CHANGE_KIND_CODES = Object.values(APPLICABILITY_CHANGE_KIND);
1075
- var changePolicyRuleSchema = z.object({
1076
- ruleId: z.string().min(1),
1077
- objectPath: z.string().min(1),
1078
- operation: z.enum(CHANGE_POLICY_OPERATION_CODES),
1079
- changeKind: z.enum(APPLICABILITY_CHANGE_KIND_CODES).optional(),
1080
- policyGroup: z.enum(POLICY_GROUP_CODES),
1081
- versionImpact: z.enum(VERSION_IMPACT_CODES),
1082
- requiresMetadataVersion: z.boolean(),
1083
- requiresTemplateAdoption: z.boolean(),
1084
- requiresOrgCapabilityReevaluation: z.boolean(),
1085
- runtimeImpact: z.enum(RUNTIME_IMPACT_CODES),
1086
- canAutoApplyToPublishedCarePlan: z.boolean(),
1087
- canAutoApplyToActiveRuntime: z.boolean(),
1088
- mergeBehavior: z.enum(MERGE_BEHAVIOR_CODES),
1089
- uxDiffRequired: z.boolean(),
1090
- notes: z.string().optional()
1091
- });
1092
- z.object({
1093
- version: z.string().min(1),
1094
- rules: z.array(changePolicyRuleSchema).min(1)
1095
- });
1096
-
1097
- // ../../libs/metadata/src/services/metadata-value-retire.service.ts
1098
- monotonicFactory();
1099
-
1100
- // ../../libs/metadata/src/services/metadata-change-request.service.ts
1101
- monotonicFactory();
1102
- z.object({
1103
- /**
1104
- * When true, a latest INACTIVE version is projected. Default false: the latest
1105
- * version must be ACTIVE, and an older ACTIVE version is not used instead.
1106
- */
1107
- includeInactive: z.boolean().optional(),
1108
- /**
1109
- * When true, every published version of a value is retained under `versions`.
1110
- * Default false: runtime projection keeps only the latest version.
1111
- * Historical versions remain in the registry/audit model.
1112
- */
1113
- includeAllVersions: z.boolean().optional(),
1114
- /** Numeric schema version stamped for transitional validators. */
1115
- schemaVersion: z.number().int().positive().optional(),
1116
- /** Wire projectionVersion string (e.g. `1.0`). */
1117
- projectionVersion: z.string().min(1).optional(),
1118
- /**
1119
- * Optional storage key prefix hint for adapters (not used by pure build).
1120
- * Callers may also pass prefix directly to {@link S3ProjectionStorage}.
1121
- */
1122
- storagePrefix: z.string().min(1).optional(),
1123
- /**
1124
- * Maximum unresolved non-authorization relationships that may be omitted
1125
- * from one release. Above this count, publication fails.
1126
- * The worker parses `PROJECTION_MAX_EXCLUDED_RELATIONSHIPS`.
1127
- */
1128
- maxExcludedRelationships: z.number().int().nonnegative().optional(),
1129
- /**
1130
- * Maximum percentage of the relationship collection that may be omitted.
1131
- * Above this share, publication fails so an incomplete snapshot is not
1132
- * treated as a successful release. Integer 0–100.
1133
- */
1134
- maxExcludedRelationshipPercent: z.number().int().min(0).max(100).optional(),
1135
- /**
1136
- * When true, unresolved Role, Module, Feature, and PermissionAction
1137
- * relationships are excluded under the same thresholds. Default false:
1138
- * those relationships still fail the release.
1139
- * The worker parses `PROJECTION_ALLOW_UNRESOLVED_AUTHORIZATION_RELATIONS`.
1140
- */
1141
- allowUnresolvedAuthorizationRelations: z.boolean().optional()
1142
- });
1143
-
1144
206
  // ../../libs/metadata-projection/src/lib/errors/ProjectionError.ts
1145
207
  var ProjectionError = class extends BaseError {
1146
208
  constructor(message, statusCode = 400, code = "PROJECTION_ERROR", details, options) {
@@ -1148,7 +210,6 @@ var ProjectionError = class extends BaseError {
1148
210
  this.name = "ProjectionError";
1149
211
  }
1150
212
  };
1151
- new AsyncLocalStorage();
1152
213
 
1153
214
  // ../../libs/metadata-projection/src/lib/serializer/ProjectionSerializer.ts
1154
215
  var ProjectionSerializer = class _ProjectionSerializer {
@@ -1554,139 +615,6 @@ var StorageError = class extends BaseError {
1554
615
  this.name = "StorageError";
1555
616
  }
1556
617
  };
1557
- var statusSchema = z.enum([STATUS.ACTIVE, STATUS.INACTIVE, STATUS.DELETED]);
1558
- var applicabilitySchema = z.object({
1559
- module: z.array(z.string()),
1560
- category: z.array(z.string()),
1561
- condition: z.array(z.string()),
1562
- country: z.array(z.string()),
1563
- language: z.array(z.string()).optional()
1564
- });
1565
- var metadataTypeRecordSchema = z.object({
1566
- metadataTypeCode: z.string().min(1),
1567
- version: z.number().int().nonnegative(),
1568
- displayName: z.string().min(1),
1569
- description: z.string().optional(),
1570
- valueDataType: z.string().min(1),
1571
- multiSelectAllowed: z.boolean(),
1572
- applicableModules: z.array(z.string()),
1573
- supportsRelations: z.boolean(),
1574
- relationFieldLabel: z.string().nullable(),
1575
- targetMetadataTypeCode: z.string().nullable(),
1576
- selectionMode: z.enum(["SINGLE", "MULTI"]).nullable(),
1577
- relationRequired: z.boolean().nullable(),
1578
- relationType: z.string().nullable(),
1579
- valueApplicabilityConfig: z.object({
1580
- moduleScoped: z.boolean().optional(),
1581
- categoryDependent: z.boolean().optional(),
1582
- conditionDependent: z.boolean().optional(),
1583
- countryDependent: z.boolean().optional(),
1584
- languageDependent: z.boolean().optional()
1585
- }).optional(),
1586
- attributeSchema: z.record(z.string(), z.unknown()).optional(),
1587
- status: statusSchema,
1588
- createdAt: z.string().min(1),
1589
- lastModifiedAt: z.string().min(1),
1590
- createdBy: z.string().optional(),
1591
- lastModifiedBy: z.string().optional()
1592
- });
1593
- var metadataValueRecordSchema = z.object({
1594
- metadataTypeCode: z.string().min(1),
1595
- valueCode: z.string().min(1),
1596
- version: z.number().int().nonnegative(),
1597
- label: z.string().min(1),
1598
- description: z.string().optional(),
1599
- sortOrder: z.number().int(),
1600
- status: statusSchema,
1601
- isGlobal: z.boolean(),
1602
- attributes: z.record(z.string(), z.unknown()),
1603
- applicability: applicabilitySchema,
1604
- applSkKeys: z.array(z.string()),
1605
- createdAt: z.string().min(1),
1606
- lastModifiedAt: z.string().min(1),
1607
- createdBy: z.string().optional(),
1608
- lastModifiedBy: z.string().optional(),
1609
- deletedAt: z.string().optional(),
1610
- deletedBy: z.string().optional(),
1611
- deleteReason: z.string().optional(),
1612
- previousStatus: statusSchema.optional()
1613
- });
1614
- var metadataRelationRecordSchema = z.object({
1615
- id: z.string().min(1),
1616
- relationType: z.string().min(1),
1617
- fromMetadataTypeCode: z.string().min(1),
1618
- fromMetadataValueCode: z.string().min(1),
1619
- toMetadataTypeCode: z.string().min(1),
1620
- toMetadataValueCode: z.string().min(1),
1621
- status: z.enum(["ACTIVE", "INACTIVE"]),
1622
- createdAt: z.string().min(1),
1623
- createdBy: z.string().optional(),
1624
- updatedAt: z.string().optional(),
1625
- updatedBy: z.string().optional()
1626
- });
1627
- z.object({
1628
- environment: z.string().min(1),
1629
- releaseId: z.string().min(1).optional(),
1630
- revision: z.string().min(1).optional(),
1631
- generatedAt: z.string().min(1).optional(),
1632
- types: z.array(metadataTypeRecordSchema),
1633
- values: z.array(metadataValueRecordSchema),
1634
- relations: z.array(metadataRelationRecordSchema).optional()
1635
- });
1636
- var projectionTypeSchema = z.string().min(1);
1637
- var artifactSchema = z.object({
1638
- fileName: z.string().min(1),
1639
- projectionType: projectionTypeSchema,
1640
- contentType: z.literal("application/json"),
1641
- body: z.string().min(1),
1642
- contentHash: z.string().min(1),
1643
- parsed: z.unknown()
1644
- });
1645
- var metadataTypeEntrySchema = z.object({
1646
- typeCode: z.string().min(1),
1647
- projectionFile: z.string().min(1)
1648
- });
1649
- var lookupIndexEntrySchema = z.object({
1650
- typeCode: z.string().min(1),
1651
- valueCode: z.string().min(1),
1652
- projectionFile: z.string().min(1)
1653
- });
1654
- var manifestSchema = z.object({
1655
- releaseId: z.string().min(1),
1656
- environment: z.string().min(1),
1657
- generatedAt: z.string().min(1),
1658
- projectionVersion: z.string().min(1),
1659
- metadataCount: z.number().int().nonnegative(),
1660
- artifactCount: z.number().int().nonnegative(),
1661
- contentHash: z.string().min(1),
1662
- artifacts: z.array(z.string().min(1)),
1663
- files: z.array(
1664
- z.object({
1665
- fileName: z.string().min(1),
1666
- projectionType: projectionTypeSchema,
1667
- contentHash: z.string().min(1),
1668
- itemCount: z.number().int().nonnegative()
1669
- })
1670
- ),
1671
- metadataTypes: z.record(z.string(), metadataTypeEntrySchema),
1672
- lookupIndex: z.record(z.string(), lookupIndexEntrySchema),
1673
- lifecycle: z.object({
1674
- values: z.literal("activeAndInactive"),
1675
- relations: z.literal("activeAndInactive")
1676
- }).optional(),
1677
- revision: z.string().min(1),
1678
- schemaVersion: z.number().int().positive()
1679
- });
1680
- z.object({
1681
- releaseId: z.string().min(1),
1682
- environment: z.string().min(1),
1683
- generatedAt: z.string().min(1),
1684
- projectionVersion: z.string().min(1),
1685
- revision: z.string().min(1),
1686
- metadataCount: z.number().int().nonnegative(),
1687
- manifest: manifestSchema,
1688
- artifacts: z.array(artifactSchema).min(1)
1689
- });
1690
618
 
1691
619
  // ../../libs/metadata-projection/src/lib/validators/RelationshipIndexValidator.ts
1692
620
  var RELATIONSHIP_KEY_PATTERN = /^[^:\s]+:.+$/;
@@ -2133,15 +1061,15 @@ function typedRelationIndexFor(relations, index) {
2133
1061
  return built;
2134
1062
  }
2135
1063
  function filterTypedRelations(relations, query, index) {
2136
- const resolved2 = typedRelationIndexFor(relations, index);
1064
+ const resolved = typedRelationIndexFor(relations, index);
2137
1065
  const filter = query.status ?? METADATA_STATUS_FILTER.ACTIVE;
2138
- if (!resolved2.complete) {
1066
+ if (!resolved.complete) {
2139
1067
  return relations.filter(
2140
1068
  (relation) => matchesForward(relation, query) && statusMatchesRelation(relation, filter)
2141
1069
  );
2142
1070
  }
2143
1071
  const bucket = typedRelationsForEndpoint(
2144
- resolved2,
1072
+ resolved,
2145
1073
  "OUTGOING",
2146
1074
  typedRelationEndpointKey(query.fromType, query.fromValue),
2147
1075
  filter
@@ -2236,9 +1164,6 @@ function parseTypedRelationshipFile(parsed, expected) {
2236
1164
  return relations;
2237
1165
  }
2238
1166
 
2239
- // ../../libs/metadata-projection/src/lib/release/validateReleaseForActivation.ts
2240
- createLogger({ serviceName: "metadata-projection" });
2241
-
2242
1167
  // ../../libs/metadata-projection/src/lib/runtime-query/publishedValueListing.ts
2243
1168
  var PUBLISHED_VALUE_LIST_LIMITS = {
2244
1169
  MAX_PAGE_SIZE: 500,
@@ -2739,11 +1664,11 @@ function relationshipKey(relation) {
2739
1664
  ].join("\0");
2740
1665
  }
2741
1666
  function resolveRelationshipStatus(status) {
2742
- const resolved2 = resolveMetadataStatusFilter({ status });
2743
- if (!resolved2.ok) {
2744
- return resolved2;
1667
+ const resolved = resolveMetadataStatusFilter({ status });
1668
+ if (!resolved.ok) {
1669
+ return resolved;
2745
1670
  }
2746
- return { ok: true, filter: resolved2.filter };
1671
+ return { ok: true, filter: resolved.filter };
2747
1672
  }
2748
1673
  function lifecycleUnsupported(message) {
2749
1674
  return { ok: false, code: METADATA_LIFECYCLE_UNSUPPORTED, message };
@@ -2909,27 +1834,6 @@ function validateRelationshipQuery(query) {
2909
1834
  }
2910
1835
  return void 0;
2911
1836
  }
2912
- var metadataPublishedPayloadSchema = z.object({
2913
- changeRequestId: z.string().min(1),
2914
- changeRevision: z.string().min(1).optional(),
2915
- metadataTypeCode: z.string().min(1),
2916
- metadataValueCode: z.string().min(1).optional(),
2917
- entityType: z.enum(["METADATA_TYPE", "METADATA_VALUE"]),
2918
- operation: z.enum(["Add", "Update"]),
2919
- publishStrategy: z.enum(["IN_PLACE", "NEW_VERSION"]),
2920
- version: z.number().int().positive(),
2921
- publishedAt: z.string().min(1)
2922
- });
2923
- Object.assign(
2924
- metadataPublishedPayloadSchema,
2925
- {
2926
- __meta: {
2927
- eventType: "MetadataPublished.v1",
2928
- eventVersion: "1.0.0",
2929
- source: "metadata-registry"
2930
- }
2931
- }
2932
- );
2933
1837
 
2934
1838
  // ../../libs/runtime-metadata/src/lib/config/RuntimeMetadataConfig.ts
2935
1839
  var runtimeMetadataConfigSchema = z.object({
@@ -3163,12 +2067,48 @@ function isMetadataValueObjectArray(val) {
3163
2067
  if (!Array.isArray(val) || val.length === 0) {
3164
2068
  return false;
3165
2069
  }
3166
- return val.every(isMetadataValueObject);
2070
+ return val.every(isMetadataValueObject);
2071
+ }
2072
+
2073
+ // ../../libs/runtime-metadata/src/lib/utils/linkedEntityMetadataType.ts
2074
+ var APPLIES_TO_LINKED_ENTITY_METADATA_TYPE = {
2075
+ METRIC: "MetricCode",
2076
+ SYMPTOM_QUESTION: "QuestionCode",
2077
+ DEVICE: "DeviceCode",
2078
+ ENGAGEMENT_EVENT: "EngagementEventCode"
2079
+ };
2080
+ function linkedEntityMetadataTypeFromAppliesTo(appliesToType) {
2081
+ const code = appliesToType?.trim().toUpperCase() ?? "";
2082
+ if (!code) {
2083
+ return void 0;
2084
+ }
2085
+ return APPLIES_TO_LINKED_ENTITY_METADATA_TYPE[code];
2086
+ }
2087
+ function readAppliesToTypeValue(parent) {
2088
+ if (!parent) {
2089
+ return void 0;
2090
+ }
2091
+ const raw = parent["AppliesToType"] ?? parent["appliesToType"] ?? parent["APPLIES_TO_TYPE"];
2092
+ if (typeof raw === "string" && raw.trim()) {
2093
+ return raw.trim();
2094
+ }
2095
+ if (isMetadataValueObject(raw) && raw.value.trim()) {
2096
+ return raw.value.trim();
2097
+ }
2098
+ if (isMetadataReference(raw) && raw.valueCode.trim()) {
2099
+ return raw.valueCode.trim();
2100
+ }
2101
+ return void 0;
2102
+ }
2103
+ function isLinkedEntityCodeField(field) {
2104
+ const normalized = field.trim();
2105
+ return normalized === "LinkedEntityCode" || normalized === "linkedEntityCode" || normalized === "LINKED_ENTITY_CODE" || normalized === "LinkedEntity" || normalized === "linkedEntity";
3167
2106
  }
3168
2107
 
3169
2108
  // ../../libs/runtime-metadata/src/lib/utils/normalizeRuntimeMetadataTypeCode.ts
3170
2109
  var RUNTIME_METADATA_TYPE_CODE_ALIASES = {
3171
- Speciality: "Specialty"
2110
+ Speciality: "Specialty",
2111
+ OrganizationType: "OrganisationType"
3172
2112
  };
3173
2113
  function normalizeRuntimeMetadataTypeCode(metadataTypeCode) {
3174
2114
  const trimmed = metadataTypeCode?.trim() ?? "";
@@ -3231,6 +2171,11 @@ var NON_METADATA_KEYS = /* @__PURE__ */ new Set([
3231
2171
  "orgTemplateId",
3232
2172
  "platformTemplateId",
3233
2173
  "templateName",
2174
+ "templateType",
2175
+ "templateLevel",
2176
+ "metadataMode",
2177
+ "MetadataMode",
2178
+ "metadataType",
3234
2179
  "monitoringName",
3235
2180
  "subtitle",
3236
2181
  "requirement",
@@ -3277,6 +2222,33 @@ function isWorkflowStepRecord(node) {
3277
2222
  function isWorkflowStepRuleField(key, parent) {
3278
2223
  return WORKFLOW_STEP_RULE_KEYS.has(key) && isWorkflowStepRecord(parent);
3279
2224
  }
2225
+ function isPlainRuleObject(value) {
2226
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2227
+ }
2228
+ function isTemplateRuleNode(value) {
2229
+ if (!isPlainRuleObject(value)) {
2230
+ return false;
2231
+ }
2232
+ const enable = value["enable"];
2233
+ const orgedit = value["orgedit"];
2234
+ const metadataMode = value["metadataMode"];
2235
+ const hasFlags = typeof enable === "boolean" && typeof orgedit === "boolean";
2236
+ const hasMode = typeof metadataMode === "string" && metadataMode.trim().length > 0;
2237
+ return hasFlags || hasMode && ("min" in value || "max" in value);
2238
+ }
2239
+ function isTemplateRulesMap(value) {
2240
+ if (!isPlainRuleObject(value)) {
2241
+ return false;
2242
+ }
2243
+ const entries = Object.values(value);
2244
+ if (entries.length === 0) {
2245
+ return false;
2246
+ }
2247
+ return entries.every((entry) => entry == null || isTemplateRuleNode(entry));
2248
+ }
2249
+ function isTemplateRuleConfiguration(key, value) {
2250
+ return key === "rules" || isTemplateRuleNode(value) || isTemplateRulesMap(value);
2251
+ }
3280
2252
  var DEFAULT_EXCLUDED = new Set(DEFAULT_EXCLUDED_CODE_FIELDS);
3281
2253
  function typeCodeFromCodeFieldName(fieldName, excluded = DEFAULT_EXCLUDED) {
3282
2254
  if (typeof fieldName !== "string" || fieldName.length <= 4) {
@@ -3285,7 +2257,7 @@ function typeCodeFromCodeFieldName(fieldName, excluded = DEFAULT_EXCLUDED) {
3285
2257
  if (!fieldName.endsWith("Code")) {
3286
2258
  return void 0;
3287
2259
  }
3288
- if (fieldName.includes("__Code")) {
2260
+ if (fieldName.length > 6 && fieldName.toLowerCase().endsWith("__code")) {
3289
2261
  return void 0;
3290
2262
  }
3291
2263
  if (excluded.has(fieldName)) {
@@ -3308,10 +2280,15 @@ function createCodeFieldExclusionSet(extra) {
3308
2280
  }
3309
2281
 
3310
2282
  // ../../libs/runtime-metadata/src/lib/utils/collectResponseTypeCodes.ts
2283
+ var METADATA_TRAVERSAL_MAX_DEPTH = 32;
2284
+ var METADATA_TRAVERSAL_MAX_NODES = 8e3;
2285
+ var LINKED_ENTITY_CONCRETE_TYPES = [
2286
+ ...new Set(Object.values(APPLIES_TO_LINKED_ENTITY_METADATA_TYPE))
2287
+ ];
3311
2288
  function collectResponseTypeCodes(value, options) {
3312
2289
  const collected = /* @__PURE__ */ new Set();
3313
- const knownSet = options?.knownTypes ? options.knownTypes instanceof Set ? options.knownTypes : new Set(options.knownTypes) : void 0;
3314
- walk(value, collected, void 0, /* @__PURE__ */ new WeakSet(), exclusionSet(options), knownSet, "", options?.diagnostics);
2290
+ const state = createWalkState(options, collected, void 0);
2291
+ walk(value, state, 0);
3315
2292
  if (options?.diagnostics) {
3316
2293
  options.diagnostics.totalUniqueTypesDiscovered = collected.size;
3317
2294
  }
@@ -3319,8 +2296,8 @@ function collectResponseTypeCodes(value, options) {
3319
2296
  }
3320
2297
  function collectResponseReferences(value, options) {
3321
2298
  const collected = /* @__PURE__ */ new Map();
3322
- const knownSet = options?.knownTypes ? options.knownTypes instanceof Set ? options.knownTypes : new Set(options.knownTypes) : void 0;
3323
- walk(value, void 0, collected, /* @__PURE__ */ new WeakSet(), exclusionSet(options), knownSet, "", options?.diagnostics);
2299
+ const state = createWalkState(options, void 0, collected);
2300
+ walk(value, state, 0);
3324
2301
  if (options?.diagnostics) {
3325
2302
  options.diagnostics.totalUniqueTypeValuesDiscovered = collected.size;
3326
2303
  }
@@ -3332,6 +2309,20 @@ function collectResponseReferences(value, options) {
3332
2309
  function exclusionSet(options) {
3333
2310
  return createCodeFieldExclusionSet(options?.excludedCodeFields);
3334
2311
  }
2312
+ function createWalkState(options, typeCodes, references) {
2313
+ const knownSet = options?.knownTypes ? options.knownTypes instanceof Set ? options.knownTypes : new Set(options.knownTypes) : void 0;
2314
+ const isKnownType = options?.isKnownType;
2315
+ const probe = isKnownType ? (typeCode) => isKnownType(typeCode) : knownSet ? (typeCode) => knownSet.has(typeCode) : () => void 0;
2316
+ return {
2317
+ typeCodes,
2318
+ references,
2319
+ visited: /* @__PURE__ */ new WeakSet(),
2320
+ excludedCodeFields: exclusionSet(options),
2321
+ probe,
2322
+ hasCatalog: isKnownType != null || knownSet != null,
2323
+ nodes: 0
2324
+ };
2325
+ }
3335
2326
  function pushUnique(candidates, value) {
3336
2327
  const trimmed = value?.trim() ?? "";
3337
2328
  if (!trimmed || candidates.includes(trimmed)) {
@@ -3346,6 +2337,29 @@ function pascalCaseToken(token) {
3346
2337
  const lower = token.toLowerCase();
3347
2338
  return lower.charAt(0).toUpperCase() + lower.slice(1);
3348
2339
  }
2340
+ var FIELD_KEY_METADATA_TYPE_ALIASES = {
2341
+ DefaultPriority: "Priority",
2342
+ Speciality: "Specialty",
2343
+ SPECIALITY: "Specialty",
2344
+ speciality: "Specialty",
2345
+ AllowedDevice: "Device",
2346
+ AllowedDevices: "Device",
2347
+ /** Template device dropdown may publish as Device or DeviceCode. */
2348
+ allowedDevice: "Device",
2349
+ allowedDevices: "Device"
2350
+ };
2351
+ var RELATED_METADATA_TYPE_CANDIDATES = {
2352
+ goalDuration: ["DurationType"],
2353
+ GoalDuration: ["DurationType"],
2354
+ GOAL_DURATION: ["GoalDuration", "DurationType"],
2355
+ defaultDurationType: ["DurationType"],
2356
+ DefaultDurationType: ["DurationType"],
2357
+ DEFAULT_DURATION_TYPE: ["DurationType"],
2358
+ measurementType: ["GoalMeasurementType"],
2359
+ MeasurementType: ["GoalMeasurementType"],
2360
+ goalMeasurementType: ["MeasurementType"],
2361
+ GoalMeasurementType: ["MeasurementType"]
2362
+ };
3349
2363
  function getCandidateTypeCodesForKey(key) {
3350
2364
  const candidates = [];
3351
2365
  const capitalized = key.charAt(0).toUpperCase() + key.slice(1);
@@ -3353,7 +2367,13 @@ function getCandidateTypeCodesForKey(key) {
3353
2367
  pushUnique(candidates, pascalCaseToken(key));
3354
2368
  }
3355
2369
  pushUnique(candidates, capitalized);
2370
+ pushUnique(candidates, normalizeRuntimeMetadataTypeCode(capitalized));
3356
2371
  pushUnique(candidates, normalizeRuntimeMetadataTypeCode(key));
2372
+ const fieldAlias = FIELD_KEY_METADATA_TYPE_ALIASES[key] ?? FIELD_KEY_METADATA_TYPE_ALIASES[capitalized];
2373
+ if (fieldAlias) {
2374
+ pushUnique(candidates, fieldAlias);
2375
+ pushUnique(candidates, normalizeRuntimeMetadataTypeCode(fieldAlias));
2376
+ }
3357
2377
  if (/code$/i.test(key) && key.length > 4) {
3358
2378
  const base = key.slice(0, -4);
3359
2379
  pushUnique(candidates, base.charAt(0).toUpperCase() + base.slice(1));
@@ -3364,13 +2384,26 @@ function getCandidateTypeCodesForKey(key) {
3364
2384
  }
3365
2385
  if (capitalized === "AllowedDevice" || capitalized === "AllowedDevices") {
3366
2386
  pushUnique(candidates, "Device");
2387
+ pushUnique(candidates, "DeviceCode");
3367
2388
  }
3368
2389
  if (capitalized === "LinkedEntityCode" || capitalized === "LinkedEntity") {
3369
2390
  pushUnique(candidates, "MetricCode");
3370
2391
  pushUnique(candidates, "QuestionCode");
2392
+ pushUnique(candidates, "DeviceCode");
2393
+ pushUnique(candidates, "EngagementEventCode");
2394
+ }
2395
+ const related = RELATED_METADATA_TYPE_CANDIDATES[key] ?? RELATED_METADATA_TYPE_CANDIDATES[capitalized];
2396
+ if (related) {
2397
+ for (const typeCode of related) {
2398
+ pushUnique(candidates, typeCode);
2399
+ pushUnique(candidates, normalizeRuntimeMetadataTypeCode(typeCode));
2400
+ }
3371
2401
  }
3372
2402
  const pluralKey = isAllCapsToken(key) ? key.toLowerCase() : key;
3373
- if (pluralKey.endsWith("ies") && pluralKey.length > 3) {
2403
+ if (/types$/i.test(pluralKey) && pluralKey.length > 5) {
2404
+ const base = pluralKey.slice(0, -1);
2405
+ pushUnique(candidates, base.charAt(0).toUpperCase() + base.slice(1));
2406
+ } else if (pluralKey.endsWith("ies") && pluralKey.length > 3) {
3374
2407
  const base = pluralKey.slice(0, -3) + "y";
3375
2408
  pushUnique(candidates, base.charAt(0).toUpperCase() + base.slice(1));
3376
2409
  } else if (pluralKey.endsWith("es") && pluralKey.length > 2) {
@@ -3383,101 +2416,130 @@ function getCandidateTypeCodesForKey(key) {
3383
2416
  return candidates;
3384
2417
  }
3385
2418
  var getCandidatesForKey = getCandidateTypeCodesForKey;
3386
- function walk(value, typeCodes, references, visited, excludedCodeFields, knownSet, currentPath = "", diagnostics) {
2419
+ function resolveFieldTypeCodes(field, parent, state, sample) {
2420
+ if (isLinkedEntityCodeField(field)) {
2421
+ const fromApplies = linkedEntityMetadataTypeFromAppliesTo(
2422
+ readAppliesToTypeValue(parent)
2423
+ );
2424
+ if (fromApplies && state.probe(fromApplies) !== false) {
2425
+ return [fromApplies];
2426
+ }
2427
+ if (!fromApplies && state.hasCatalog) {
2428
+ const concrete = LINKED_ENTITY_CONCRETE_TYPES.filter(
2429
+ (typeCode) => state.probe(typeCode) === true
2430
+ );
2431
+ if (concrete.length > 0) {
2432
+ return concrete;
2433
+ }
2434
+ }
2435
+ }
2436
+ const candidates = getCandidatesForKey(field);
2437
+ if (state.hasCatalog) {
2438
+ return candidates.filter((candidate) => state.probe(candidate) === true);
2439
+ }
2440
+ if ("labelKey" in sample || /code$/i.test(field)) {
2441
+ return candidates[0] ? [candidates[0]] : [];
2442
+ }
2443
+ return [];
2444
+ }
2445
+ function walk(value, state, depth) {
3387
2446
  if (value === null || value === void 0) {
3388
2447
  return;
3389
2448
  }
3390
2449
  if (typeof value !== "object") {
3391
2450
  return;
3392
2451
  }
3393
- if (visited.has(value)) {
2452
+ if (depth > METADATA_TRAVERSAL_MAX_DEPTH || state.nodes >= METADATA_TRAVERSAL_MAX_NODES) {
2453
+ return;
2454
+ }
2455
+ if (state.visited.has(value)) {
3394
2456
  return;
3395
2457
  }
3396
- visited.add(value);
2458
+ state.visited.add(value);
2459
+ state.nodes += 1;
3397
2460
  if (Array.isArray(value)) {
3398
2461
  for (const item of value) {
3399
- walk(item, typeCodes, references, visited, excludedCodeFields, knownSet);
2462
+ walk(item, state, depth + 1);
3400
2463
  }
3401
2464
  return;
3402
2465
  }
3403
2466
  if (isMetadataReference(value)) {
3404
- addReference(value.typeCode, value.valueCode, typeCodes, references);
2467
+ addReference(value.typeCode, value.valueCode, state.typeCodes, state.references);
3405
2468
  }
3406
2469
  const record = value;
3407
2470
  if (record["ref"] === "META" && typeof record["typeCode"] === "string") {
3408
2471
  const valCode = typeof record["valueCode"] === "string" ? record["valueCode"] : "";
3409
- addReference(record["typeCode"], valCode, typeCodes, references);
2472
+ addReference(record["typeCode"], valCode, state.typeCodes, state.references);
3410
2473
  }
3411
2474
  for (const [field, child] of Object.entries(record)) {
3412
- if (excludedCodeFields.has(field)) {
2475
+ if (state.excludedCodeFields.has(field)) {
3413
2476
  continue;
3414
2477
  }
3415
- if (field.includes("__Code")) {
2478
+ if (field.length > 6 && field.toLowerCase().endsWith("__code")) {
3416
2479
  continue;
3417
2480
  }
3418
2481
  if (NON_METADATA_KEYS.has(field)) {
3419
- walk(child, typeCodes, references, visited, excludedCodeFields, knownSet);
2482
+ walk(child, state, depth + 1);
3420
2483
  continue;
3421
2484
  }
3422
2485
  if (isWorkflowStepRuleField(field, record)) {
3423
2486
  if (typeof child === "object" && child !== null) {
3424
- walk(child, typeCodes, references, visited, excludedCodeFields, knownSet);
2487
+ walk(child, state, depth + 1);
3425
2488
  }
3426
2489
  continue;
3427
2490
  }
3428
- if (isMetadataValueObject(child)) {
3429
- const candidates = getCandidatesForKey(field);
3430
- let matchedType;
3431
- if (knownSet) {
3432
- matchedType = candidates.find((c) => knownSet.has(c));
3433
- } else if ("labelKey" in child || field.endsWith("Code")) {
3434
- matchedType = candidates[0];
3435
- }
3436
- if (matchedType) {
3437
- addReference(matchedType, child.value, typeCodes, references);
3438
- continue;
3439
- }
2491
+ if (isTemplateRuleConfiguration(field, child)) {
2492
+ continue;
3440
2493
  }
3441
- if (isMetadataValueObjectArray(child)) {
3442
- const candidates = getCandidatesForKey(field);
3443
- let matchedType;
3444
- if (knownSet) {
3445
- matchedType = candidates.find((c) => knownSet.has(c));
3446
- } else if (child.some((item) => "labelKey" in item) || field.endsWith("Code")) {
3447
- matchedType = candidates[0];
2494
+ if (isMetadataValueObject(child)) {
2495
+ for (const matchedType of resolveFieldTypeCodes(field, record, state, child)) {
2496
+ addReference(matchedType, child.value, state.typeCodes, state.references);
3448
2497
  }
3449
- if (matchedType) {
2498
+ } else if (isMetadataValueObjectArray(child)) {
2499
+ const matchedTypes = resolveFieldTypeCodes(field, record, state, child[0]);
2500
+ if (matchedTypes.length > 0) {
3450
2501
  for (const item of child) {
3451
- addReference(matchedType, item.value, typeCodes, references);
2502
+ for (const matchedType of matchedTypes) {
2503
+ addReference(matchedType, item.value, state.typeCodes, state.references);
2504
+ }
3452
2505
  }
3453
- continue;
3454
2506
  }
3455
2507
  }
3456
2508
  collectStringCodeField(
3457
2509
  field,
3458
2510
  child,
3459
- typeCodes,
3460
- references,
3461
- excludedCodeFields
2511
+ state.typeCodes,
2512
+ state.references,
2513
+ state.excludedCodeFields
3462
2514
  );
3463
- if (knownSet) {
3464
- const candidates = getCandidatesForKey(field);
3465
- for (const cand of candidates) {
3466
- if (knownSet.has(cand)) {
3467
- if (typeof child === "string" && child.trim().length > 0) {
3468
- addReference(cand, child, typeCodes, references);
3469
- break;
3470
- }
3471
- if (Array.isArray(child) && child.length > 0 && child.every((c) => typeof c === "string")) {
3472
- for (const item of child) {
3473
- addReference(cand, item, typeCodes, references);
3474
- }
3475
- break;
2515
+ if (state.hasCatalog) {
2516
+ if (typeof child === "string" && child.trim().length > 0) {
2517
+ for (const matchedType of resolveFieldTypeCodes(
2518
+ field,
2519
+ record,
2520
+ state,
2521
+ { value: child.trim() }
2522
+ )) {
2523
+ addReference(matchedType, child, state.typeCodes, state.references);
2524
+ }
2525
+ } else if (Array.isArray(child) && child.length > 0 && child.every((item) => typeof item === "string" && item.trim().length > 0)) {
2526
+ const sample = String(child[0]).trim();
2527
+ const matchedTypes = resolveFieldTypeCodes(field, record, state, {
2528
+ value: sample
2529
+ });
2530
+ for (const item of child) {
2531
+ for (const matchedType of matchedTypes) {
2532
+ addReference(
2533
+ matchedType,
2534
+ String(item),
2535
+ state.typeCodes,
2536
+ state.references
2537
+ );
3476
2538
  }
3477
2539
  }
3478
2540
  }
3479
2541
  }
3480
- walk(child, typeCodes, references, visited, excludedCodeFields, knownSet);
2542
+ walk(child, state, depth + 1);
3481
2543
  }
3482
2544
  }
3483
2545
  function collectStringCodeField(field, child, typeCodes, references, excludedCodeFields) {
@@ -3605,7 +2667,7 @@ function readModelGroupsFromManifest(manifest) {
3605
2667
  metadata: metadataGroupFromManifest(manifest)
3606
2668
  };
3607
2669
  }
3608
- var projectionTypeSchema2 = z.string().min(1);
2670
+ var projectionTypeSchema = z.string().min(1);
3609
2671
  var manifestLocalizationSchema = z.object({
3610
2672
  defaultLocale: z.string().min(1),
3611
2673
  supportedLocales: z.array(z.string().min(1)),
@@ -3623,7 +2685,7 @@ var projectionManifestSchema = z.object({
3623
2685
  files: z.array(
3624
2686
  z.object({
3625
2687
  fileName: z.string().min(1),
3626
- projectionType: projectionTypeSchema2,
2688
+ projectionType: projectionTypeSchema,
3627
2689
  contentHash: z.string().min(1),
3628
2690
  itemCount: z.number().int().nonnegative()
3629
2691
  })
@@ -4071,13 +3133,6 @@ var MetadataDownloader = class {
4071
3133
  );
4072
3134
  loadedFiles.push(fileName);
4073
3135
  domainFiles.set(metadataTypeCode, file);
4074
- logs.debug(RUNTIME_METADATA_EVENTS.PROJECTION_FILE_LOADED, () => ({
4075
- releaseId,
4076
- metadataType: metadataTypeCode,
4077
- projectionFile: fileName,
4078
- recordCount: typeof file.records === "object" && file.records ? Object.keys(file.records).length : 0,
4079
- mode: "selective"
4080
- }));
4081
3136
  }
4082
3137
  const sortedLoadedFiles = loadedFiles.sort((a, b) => a.localeCompare(b));
4083
3138
  logs.info(RUNTIME_METADATA_EVENTS.DOWNLOAD_COMPLETE, {
@@ -4330,7 +3385,15 @@ var MetadataCache = class {
4330
3385
  this.status = status;
4331
3386
  }
4332
3387
  isReady() {
4333
- return this.snapshot !== null && this.status !== CACHE_STATUS.EMPTY;
3388
+ if (this.snapshot === null || this.status === CACHE_STATUS.EMPTY) {
3389
+ return false;
3390
+ }
3391
+ const metadataTypes = this.snapshot.manifest?.metadataTypes;
3392
+ return metadataTypes != null && Object.keys(metadataTypes).length > 0;
3393
+ }
3394
+ hasCatalog() {
3395
+ const metadataTypes = this.snapshot?.manifest?.metadataTypes;
3396
+ return metadataTypes != null && Object.keys(metadataTypes).length > 0;
4334
3397
  }
4335
3398
  getSnapshot() {
4336
3399
  return this.snapshot;
@@ -4433,7 +3496,8 @@ var MetadataCache = class {
4433
3496
  ) : void 0
4434
3497
  });
4435
3498
  this.snapshot = snapshot;
4436
- this.status = CACHE_STATUS.READY;
3499
+ const typeCount = Object.keys(snapshot.manifest.metadataTypes).length;
3500
+ this.status = typeCount > 0 ? CACHE_STATUS.READY : CACHE_STATUS.EMPTY;
4437
3501
  return snapshot;
4438
3502
  }
4439
3503
  /**
@@ -4508,7 +3572,8 @@ var MetadataCache = class {
4508
3572
  /**
4509
3573
  * Merge individual resolved entries into domain record maps (same release).
4510
3574
  * Used after an extension batch lookup so {@link MetadataResolver.resolve}
4511
- * remains synchronous.
3575
+ * remains synchronous. Also updates lookupIndex and default-locale labels so
3576
+ * cache-only helpers work from extension-provided data.
4512
3577
  */
4513
3578
  hydrateEntries(entries, guard) {
4514
3579
  if (!this.snapshot) {
@@ -4521,6 +3586,19 @@ var MetadataCache = class {
4521
3586
  return this.snapshot;
4522
3587
  }
4523
3588
  const byType = /* @__PURE__ */ new Map();
3589
+ const lookupIndex = { ...this.snapshot.manifest.lookupIndex };
3590
+ const defaultLocale = this.snapshot.manifest.localization?.defaultLocale ?? "en-US";
3591
+ const localization = new Map(
3592
+ [...this.snapshot.localization?.entries() ?? []].map(([locale, map]) => [
3593
+ locale,
3594
+ new Map(map)
3595
+ ])
3596
+ );
3597
+ let localeMap = localization.get(defaultLocale);
3598
+ if (!localeMap) {
3599
+ localeMap = /* @__PURE__ */ new Map();
3600
+ localization.set(defaultLocale, localeMap);
3601
+ }
4524
3602
  for (const item of entries) {
4525
3603
  let typeMap = byType.get(item.typeCode);
4526
3604
  if (!typeMap) {
@@ -4528,6 +3606,16 @@ var MetadataCache = class {
4528
3606
  byType.set(item.typeCode, typeMap);
4529
3607
  }
4530
3608
  typeMap.set(item.valueCode, item.entry);
3609
+ const key = lookupIndexKey(item.typeCode, item.valueCode);
3610
+ lookupIndex[key] = {
3611
+ typeCode: item.typeCode,
3612
+ valueCode: item.valueCode,
3613
+ projectionFile: projectionFileName(item.typeCode)
3614
+ };
3615
+ const label = item.localizedLabel?.trim() || item.entry.label?.trim() || item.entry.displayName?.trim();
3616
+ if (label) {
3617
+ localeMap.set(`${item.typeCode}.${item.valueCode}`, label);
3618
+ }
4531
3619
  }
4532
3620
  const mergedDomain = new Map(this.snapshot.domainFiles);
4533
3621
  const additionalFiles = [];
@@ -4560,10 +3648,81 @@ var MetadataCache = class {
4560
3648
  .../* @__PURE__ */ new Set([...this.snapshot.loadedFiles, ...additionalFiles])
4561
3649
  ].sort((a, b) => a.localeCompare(b))
4562
3650
  );
3651
+ const existingLocalization = this.snapshot.manifest.localization;
3652
+ const supportedLocales = [
3653
+ .../* @__PURE__ */ new Set([
3654
+ ...existingLocalization?.supportedLocales ?? [],
3655
+ ...localization.keys()
3656
+ ])
3657
+ ].sort((a, b) => a.localeCompare(b));
4563
3658
  const snapshot = Object.freeze({
4564
3659
  ...this.snapshot,
4565
3660
  domainFiles: mergedDomain,
4566
- loadedFiles
3661
+ loadedFiles,
3662
+ manifest: Object.freeze({
3663
+ ...this.snapshot.manifest,
3664
+ lookupIndex: Object.freeze({ ...lookupIndex }),
3665
+ localization: Object.freeze({
3666
+ defaultLocale,
3667
+ supportedLocales,
3668
+ files: Object.freeze({
3669
+ ...existingLocalization?.files ?? {},
3670
+ ...Object.fromEntries(
3671
+ supportedLocales.map((locale) => [
3672
+ locale,
3673
+ existingLocalization?.files?.[locale] ?? `localization/${locale}.json`
3674
+ ])
3675
+ )
3676
+ })
3677
+ })
3678
+ }),
3679
+ localization: Object.freeze(
3680
+ new Map(
3681
+ [...localization.entries()].map(([locale, map]) => [
3682
+ locale,
3683
+ Object.freeze(new Map(map))
3684
+ ])
3685
+ )
3686
+ )
3687
+ });
3688
+ this.snapshot = snapshot;
3689
+ this.status = CACHE_STATUS.READY;
3690
+ return snapshot;
3691
+ }
3692
+ /**
3693
+ * Merge type-catalog fields (e.g. valueDataType) into the synthetic extension
3694
+ * manifest so synchronous helpers can read them after listTypeValues.
3695
+ */
3696
+ mergeTypeCatalog(types, guard) {
3697
+ if (!this.snapshot) {
3698
+ throw new Error("Cannot merge type catalog into an empty metadata cache");
3699
+ }
3700
+ if (Object.keys(types).length === 0) {
3701
+ return this.snapshot;
3702
+ }
3703
+ if (!this.guardAllowsWrite(guard)) {
3704
+ return this.snapshot;
3705
+ }
3706
+ const metadataTypes = { ...this.snapshot.manifest.metadataTypes };
3707
+ for (const [typeCode, entry] of Object.entries(types)) {
3708
+ const existing = metadataTypes[typeCode];
3709
+ metadataTypes[typeCode] = {
3710
+ ...existing ?? {},
3711
+ ...entry,
3712
+ typeCode: entry.typeCode || typeCode,
3713
+ projectionFile: entry.projectionFile || existing?.projectionFile || `${typeCode}.json`,
3714
+ localizedDisplayName: {
3715
+ ...existing?.localizedDisplayName ?? {},
3716
+ ...entry.localizedDisplayName ?? {}
3717
+ }
3718
+ };
3719
+ }
3720
+ const snapshot = Object.freeze({
3721
+ ...this.snapshot,
3722
+ manifest: Object.freeze({
3723
+ ...this.snapshot.manifest,
3724
+ metadataTypes: Object.freeze(metadataTypes)
3725
+ })
4567
3726
  });
4568
3727
  this.snapshot = snapshot;
4569
3728
  this.status = CACHE_STATUS.READY;
@@ -4584,8 +3743,6 @@ var MetadataCache = class {
4584
3743
  return guard.generation === this.generation && guard.releaseId === this.snapshot.releaseId;
4585
3744
  }
4586
3745
  };
4587
-
4588
- // ../../libs/runtime-metadata/src/lib/resolver/MetadataResolver.ts
4589
3746
  var MetadataResolver = class {
4590
3747
  cache;
4591
3748
  logger;
@@ -4620,9 +3777,7 @@ var MetadataResolver = class {
4620
3777
  * Falls back to default locale if requested locale does not have the key.
4621
3778
  */
4622
3779
  resolveLocalization(typeCode, valueCode, locale) {
4623
- if (!this.cache.isReady()) {
4624
- return void 0;
4625
- }
3780
+ this.assertReady();
4626
3781
  const targetLocale = locale?.trim() || this.cache.getManifest()?.localization?.defaultLocale || "en-US";
4627
3782
  const locMap = this.cache.getLocalizationMap(targetLocale);
4628
3783
  const key = `${typeCode}.${valueCode}`;
@@ -4636,15 +3791,22 @@ var MetadataResolver = class {
4636
3791
  return defaultMap.get(key);
4637
3792
  }
4638
3793
  }
3794
+ const file = this.cache.getDomainFile(typeCode);
3795
+ const record = file?.records[valueCode];
3796
+ const entry = record?.versions[String(record.latestVersion)];
3797
+ if (entry) {
3798
+ const fromEntry = entry.localizedLabels?.[targetLocale] || entry.localizedLabels?.[defaultLocale] || entry.label || entry.displayName;
3799
+ if (fromEntry?.trim()) {
3800
+ return fromEntry.trim();
3801
+ }
3802
+ }
4639
3803
  return void 0;
4640
3804
  }
4641
3805
  /**
4642
3806
  * Look up localized display name for a MetadataType from manifest or domain file.
4643
3807
  */
4644
3808
  getTypeLocalizedDisplayName(typeCode, locale) {
4645
- if (!this.cache.isReady()) {
4646
- return void 0;
4647
- }
3809
+ this.assertReady();
4648
3810
  const targetType = this.resolveMetadataTypeCode(typeCode);
4649
3811
  if (!targetType) {
4650
3812
  return void 0;
@@ -4669,9 +3831,7 @@ var MetadataResolver = class {
4669
3831
  * Value data type for a MetadataType (e.g. STRING, INTEGER).
4670
3832
  */
4671
3833
  getValueDataType(typeCode) {
4672
- if (!this.cache.isReady()) {
4673
- return void 0;
4674
- }
3834
+ this.assertReady();
4675
3835
  const targetType = this.resolveMetadataTypeCode(typeCode);
4676
3836
  if (!targetType) {
4677
3837
  return void 0;
@@ -4679,7 +3839,16 @@ var MetadataResolver = class {
4679
3839
  const manifest = this.cache.getManifest();
4680
3840
  const manifestType = manifest?.metadataTypes[targetType];
4681
3841
  const file = this.cache.getDomainFile(targetType);
4682
- return manifestType?.valueDataType ?? file?.valueDataType;
3842
+ const valueDataType = manifestType?.valueDataType ?? file?.valueDataType;
3843
+ if (valueDataType != null && valueDataType !== "") {
3844
+ return valueDataType;
3845
+ }
3846
+ if (!file) {
3847
+ throw new MetadataNotReadyError(
3848
+ `Metadata type catalog is not loaded for ${targetType}`
3849
+ );
3850
+ }
3851
+ return void 0;
4683
3852
  }
4684
3853
  /**
4685
3854
  * Whether the given MetadataTypeCode is listed in the loaded manifest.
@@ -4687,25 +3856,17 @@ var MetadataResolver = class {
4687
3856
  */
4688
3857
  supportsType(typeCode) {
4689
3858
  const requestedType = typeCode?.trim() ?? "";
4690
- const logs = createOperationalLogger(this.logger);
4691
- if (!this.cache.isReady()) {
4692
- logs.debug(RUNTIME_METADATA_EVENTS.PROJECTION_PROVIDER_SUPPORTS_TYPE, {
4693
- requestedType,
4694
- supported: false,
4695
- reason: "cacheNotReady",
4696
- cacheStatus: this.cache.getStatus()
4697
- });
3859
+ const normalizedType = normalizeRuntimeMetadataTypeCode(requestedType);
3860
+ const metadataTypes = this.cache.getManifest()?.metadataTypes;
3861
+ const availableTypeCount = metadataTypes ? Object.keys(metadataTypes).length : 0;
3862
+ const cacheReady = this.cache.isReady();
3863
+ const catalogAvailable = cacheReady && availableTypeCount > 0;
3864
+ if (!catalogAvailable) {
4698
3865
  return false;
4699
3866
  }
4700
- const supported = this.resolveMetadataTypeCode(requestedType) !== void 0;
4701
- logs.debug(RUNTIME_METADATA_EVENTS.PROJECTION_PROVIDER_SUPPORTS_TYPE, () => ({
4702
- requestedType,
4703
- supported,
4704
- availableTypeCount: Object.keys(this.cache.getManifest()?.metadataTypes ?? {}).length,
4705
- cacheStatus: this.cache.getStatus(),
4706
- releaseId: this.cache.getReleaseId()
4707
- }));
4708
- return supported;
3867
+ return Boolean(
3868
+ normalizedType && metadataTypes && normalizedType in metadataTypes
3869
+ );
4709
3870
  }
4710
3871
  /** MetadataTypeCodes available for resolve (from manifest.metadataTypes). */
4711
3872
  listMetadataTypes() {
@@ -4841,8 +4002,6 @@ var MetadataResolver = class {
4841
4002
  }
4842
4003
  }
4843
4004
  };
4844
-
4845
- // ../../libs/runtime-metadata/src/lib/refresh/MetadataRefreshService.ts
4846
4005
  var MetadataRefreshService = class {
4847
4006
  cache;
4848
4007
  downloader;
@@ -4933,6 +4092,7 @@ var MetadataRefreshService = class {
4933
4092
  const current = this.cache.getManifest();
4934
4093
  const target = preferredRevision?.trim() || this.configuredRevision || await this.downloader.discoverLatestRevision();
4935
4094
  const logs = createOperationalLogger(this.logger);
4095
+ const started = Date.now();
4936
4096
  logs.debug(RUNTIME_METADATA_EVENTS.PERIODIC_CHECK, {
4937
4097
  revision: target,
4938
4098
  currentRevision: current?.revision ?? null
@@ -4959,9 +4119,11 @@ var MetadataRefreshService = class {
4959
4119
  err: err instanceof Error ? err : void 0,
4960
4120
  revision: target,
4961
4121
  message: this.lastRefreshError,
4962
- retainedCache: this.cache.isReady()
4122
+ retainedCache: this.cache.isReady(),
4123
+ durationMs: Date.now() - started,
4124
+ outcome: "error"
4963
4125
  });
4964
- return false;
4126
+ throw err;
4965
4127
  }
4966
4128
  }
4967
4129
  startPeriodicCheck(intervalMs) {
@@ -4970,7 +4132,7 @@ var MetadataRefreshService = class {
4970
4132
  return;
4971
4133
  }
4972
4134
  this.periodicTimer = setInterval(() => {
4973
- void this.checkAndRefresh();
4135
+ void this.checkAndRefresh().catch(() => void 0);
4974
4136
  }, intervalMs);
4975
4137
  if (typeof this.periodicTimer.unref === "function") {
4976
4138
  this.periodicTimer.unref();
@@ -5060,9 +4222,10 @@ var MetadataRefreshService = class {
5060
4222
  reason,
5061
4223
  message: this.lastRefreshError,
5062
4224
  retainedCache: this.cache.isReady(),
5063
- durationMs: Date.now() - started
4225
+ durationMs: Date.now() - started,
4226
+ outcome: "error"
5064
4227
  });
5065
- return false;
4228
+ throw err;
5066
4229
  }
5067
4230
  }
5068
4231
  };
@@ -5108,7 +4271,8 @@ var MetadataHealthService = class {
5108
4271
  var METADATA_EXTENSION_DEFAULTS = {
5109
4272
  HOST: "127.0.0.1",
5110
4273
  PORT: 12701,
5111
- FALLBACK: "s3",
4274
+ /** Consumers use the metadata extension exclusively; never silent S3 failover. */
4275
+ FALLBACK: "none",
5112
4276
  RECOVERY_INTERVAL_MS: 2e3,
5113
4277
  STARTUP_TIMEOUT_MS: 8e3,
5114
4278
  INVOKE_REFRESH_MS: 3e4,
@@ -5186,11 +4350,11 @@ function isFreshProjectionState(state) {
5186
4350
  return state?.trim().toLowerCase() === "ready";
5187
4351
  }
5188
4352
  function assertMetadataReadPolicy(policy, state, releaseId) {
5189
- const resolved2 = policy ?? METADATA_READ_POLICY.ALLOW_STALE;
5190
- if (resolved2 !== METADATA_READ_POLICY.ALLOW_STALE && resolved2 !== METADATA_READ_POLICY.REQUIRE_FRESH) {
4353
+ const resolved = policy ?? METADATA_READ_POLICY.ALLOW_STALE;
4354
+ if (resolved !== METADATA_READ_POLICY.ALLOW_STALE && resolved !== METADATA_READ_POLICY.REQUIRE_FRESH) {
5191
4355
  throw new MetadataDiscoveryError("Unsupported metadata read policy");
5192
4356
  }
5193
- if (resolved2 === METADATA_READ_POLICY.REQUIRE_FRESH && !isFreshProjectionState(state)) {
4357
+ if (resolved === METADATA_READ_POLICY.REQUIRE_FRESH && !isFreshProjectionState(state)) {
5194
4358
  throw new MetadataFreshnessError(state, releaseId);
5195
4359
  }
5196
4360
  }
@@ -5279,7 +4443,8 @@ var ExtensionMetadataProvider = class {
5279
4443
  durationMs: Date.now() - started,
5280
4444
  attempts,
5281
4445
  state: status.state,
5282
- releaseId: status.releaseId
4446
+ releaseId: status.releaseId,
4447
+ ...correlationLogFields()
5283
4448
  });
5284
4449
  return status;
5285
4450
  }
@@ -5306,7 +4471,9 @@ var ExtensionMetadataProvider = class {
5306
4471
  attempts,
5307
4472
  outcome: "unavailable",
5308
4473
  unreachable,
5309
- timedOut
4474
+ timedOut,
4475
+ timeoutMs: this.readyTimeoutMs,
4476
+ ...correlationLogFields()
5310
4477
  });
5311
4478
  throw new MetadataProjectionUnavailableError(
5312
4479
  detail ? `${reason}: ${detail}` : reason,
@@ -5632,17 +4799,19 @@ var ExtensionMetadataProvider = class {
5632
4799
  try {
5633
4800
  const body = await this.requestJson("GET", path);
5634
4801
  return body.value;
5635
- } catch {
5636
- return void 0;
4802
+ } catch (err) {
4803
+ if (isNotFound(err)) return void 0;
4804
+ throw err;
5637
4805
  }
5638
4806
  }
5639
4807
  async getLocalizationMap(locale) {
5640
4808
  const path = `/v1/localization/${encodeURIComponent(locale)}`;
5641
4809
  try {
5642
4810
  const body = await this.requestJson("GET", path);
5643
- return body.items;
5644
- } catch {
5645
- return void 0;
4811
+ return body.items ?? {};
4812
+ } catch (err) {
4813
+ if (isNotFound(err)) return void 0;
4814
+ throw err;
5646
4815
  }
5647
4816
  }
5648
4817
  async requestRefresh(releaseId) {
@@ -5656,15 +4825,15 @@ var ExtensionMetadataProvider = class {
5656
4825
  return body.changed === true;
5657
4826
  }
5658
4827
  async assertQueryLifecycle(kind, options) {
5659
- const resolved2 = resolveMetadataStatusFilter({
4828
+ const resolved = resolveMetadataStatusFilter({
5660
4829
  status: options?.status,
5661
4830
  includeInactive: options?.includeInactive
5662
4831
  });
5663
- if (!resolved2.ok) {
5664
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
4832
+ if (!resolved.ok) {
4833
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
5665
4834
  }
5666
- if (!resolved2.enforceCapability) {
5667
- return resolved2.filter;
4835
+ if (!resolved.enforceCapability) {
4836
+ return resolved.filter;
5668
4837
  }
5669
4838
  if (!this.lifecycleSupport) {
5670
4839
  const status = await this.getStatus();
@@ -5679,7 +4848,7 @@ var ExtensionMetadataProvider = class {
5679
4848
  METADATA_LIFECYCLE_UNSUPPORTED
5680
4849
  );
5681
4850
  }
5682
- return resolved2.filter;
4851
+ return resolved.filter;
5683
4852
  }
5684
4853
  toMetadataValue(item, locale) {
5685
4854
  if (!item?.typeCode || !item.valueCode) {
@@ -5941,7 +5110,9 @@ var ExtensionMetadataProvider = class {
5941
5110
  });
5942
5111
  }
5943
5112
  async requestJson(method, path, payload) {
5944
- const started = Date.now();
5113
+ const started = performance.now();
5114
+ const endpoint = extensionEndpoint(this.baseUrl);
5115
+ const batchCount = requestBatchCount(payload);
5945
5116
  const controller = new AbortController();
5946
5117
  const timer = setTimeout(() => controller.abort(), this.requestTimeoutMs);
5947
5118
  try {
@@ -6003,15 +5174,56 @@ var ExtensionMetadataProvider = class {
6003
5174
  err.code = "RUNTIME_METADATA_NOT_FOUND";
6004
5175
  throw err;
6005
5176
  }
5177
+ const durationMs = Math.round(performance.now() - started);
5178
+ createOperationalLogger(this.logger).warn(
5179
+ "runtimeMetadata.extension.requestFailed",
5180
+ {
5181
+ operation: "requestJson",
5182
+ method,
5183
+ path,
5184
+ host: endpoint.host,
5185
+ port: endpoint.port,
5186
+ durationMs,
5187
+ timeoutMs: this.requestTimeoutMs,
5188
+ ...batchCount !== void 0 ? { batchCount } : {},
5189
+ upstreamStatus: response.status,
5190
+ errorCode: code,
5191
+ ...correlationLogFields()
5192
+ }
5193
+ );
6006
5194
  if (response.status === 503 || code === "METADATA_PROJECTION_UNAVAILABLE") {
6007
5195
  throw new MetadataProjectionUnavailableError(
6008
5196
  errorBody.message ?? "Metadata projection is unavailable",
6009
- { retryable: true, metadata: { code, path } }
5197
+ {
5198
+ retryable: true,
5199
+ metadata: {
5200
+ code,
5201
+ path,
5202
+ host: endpoint.host,
5203
+ port: endpoint.port,
5204
+ durationMs,
5205
+ timeoutMs: this.requestTimeoutMs,
5206
+ upstreamStatus: response.status,
5207
+ ...batchCount !== void 0 ? { batchCount } : {}
5208
+ }
5209
+ }
6010
5210
  );
6011
5211
  }
6012
5212
  throw new MetadataProjectionUnavailableError(
6013
5213
  errorBody.message ?? `Extension request failed: ${response.status}`,
6014
- { retryable: response.status >= 500, metadata: { code, path } }
5214
+ {
5215
+ retryable: response.status >= 500,
5216
+ metadata: {
5217
+ code,
5218
+ path,
5219
+ host: endpoint.host,
5220
+ port: endpoint.port,
5221
+ durationMs,
5222
+ timeoutMs: this.requestTimeoutMs,
5223
+ upstreamStatus: response.status,
5224
+ ...batchCount !== void 0 ? { batchCount } : {}
5225
+ }
5226
+ }
6015
5227
  );
6016
5228
  }
6017
5229
  return parsed;
@@ -6023,16 +5235,40 @@ var ExtensionMetadataProvider = class {
6023
5235
  throw err;
6024
5236
  }
6025
5237
  const aborted = err.name === "AbortError";
5238
+ const durationMs = Math.round(performance.now() - started);
5239
+ const network = networkErrorFields(err);
6026
5240
  createOperationalLogger(this.logger).warn("runtimeMetadata.extension.requestFailed", {
5241
+ operation: "requestJson",
5242
+ method,
6027
5243
  path,
5244
+ host: endpoint.host,
5245
+ port: endpoint.port,
6028
5246
  aborted,
6029
- message: err instanceof Error ? err.message : String(err)
5247
+ durationMs,
5248
+ timeoutMs: this.requestTimeoutMs,
5249
+ ...batchCount !== void 0 ? { batchCount } : {},
5250
+ errorName: network.errorName,
5251
+ errorCode: network.errorCode,
5252
+ causeName: network.causeName,
5253
+ causeCode: network.causeCode,
5254
+ causeMessage: network.causeMessage,
5255
+ message: err instanceof Error ? err.message : String(err),
5256
+ ...correlationLogFields()
6030
5257
  });
6031
5258
  throw new MetadataProjectionUnavailableError(
6032
5259
  aborted ? "Metadata extension request timed out" : "Metadata extension is unavailable",
6033
5260
  {
6034
5261
  retryable: true,
6035
- metadata: { path, unreachable: !aborted, durationMs: Date.now() - started }
5262
+ metadata: {
5263
+ path,
5264
+ unreachable: !aborted,
5265
+ durationMs,
5266
+ host: endpoint.host,
5267
+ port: endpoint.port,
5268
+ timeoutMs: this.requestTimeoutMs,
5269
+ ...batchCount !== void 0 ? { batchCount } : {},
5270
+ ...network
5271
+ }
6036
5272
  }
6037
5273
  );
6038
5274
  } finally {
@@ -6064,6 +5300,45 @@ function parseTypeCatalog(raw, fallbackTypeCode) {
6064
5300
  function isUnsupportedExtensionRoute(status, body) {
6065
5301
  return status === 404 && (body.code === "METADATA_EXTENSION_ROUTE_UNSUPPORTED" || body.message === "Unknown extension route");
6066
5302
  }
5303
+ function extensionEndpoint(baseUrl) {
5304
+ try {
5305
+ const url = new URL(baseUrl);
5306
+ const port = url.port || (url.protocol === "https:" ? "443" : url.protocol === "http:" ? "80" : "");
5307
+ return { host: url.hostname || "unknown", port: port || "unknown" };
5308
+ } catch {
5309
+ return { host: "unknown", port: "unknown" };
5310
+ }
5311
+ }
5312
+ function requestBatchCount(payload) {
5313
+ if (!payload || typeof payload !== "object") {
5314
+ return void 0;
5315
+ }
5316
+ const body = payload;
5317
+ if (Array.isArray(body.sourceValues)) {
5318
+ return body.sourceValues.length;
5319
+ }
5320
+ if (Array.isArray(body.queries)) {
5321
+ return body.queries.length;
5322
+ }
5323
+ if (Array.isArray(body.values)) {
5324
+ return body.values.length;
5325
+ }
5326
+ if (Array.isArray(body.refs)) {
5327
+ return body.refs.length;
5328
+ }
5329
+ return void 0;
5330
+ }
5331
+ function networkErrorFields(err) {
5332
+ const error = err;
5333
+ const cause = error?.cause;
5334
+ return {
5335
+ ...typeof error?.name === "string" ? { errorName: error.name } : {},
5336
+ ...typeof error?.code === "string" ? { errorCode: error.code } : {},
5337
+ ...typeof cause?.name === "string" ? { causeName: cause.name } : {},
5338
+ ...typeof cause?.code === "string" ? { causeCode: cause.code } : {},
5339
+ ...typeof cause?.message === "string" ? { causeMessage: cause.message } : {}
5340
+ };
5341
+ }
6067
5342
  function isNotFound(err) {
6068
5343
  return err.code === "RUNTIME_METADATA_NOT_FOUND";
6069
5344
  }
@@ -6073,12 +5348,16 @@ function isUnavailable(err) {
6073
5348
  function isServingState(state) {
6074
5349
  return state === "READY" || state === "STALE" || state === "DEGRADED";
6075
5350
  }
6076
- function correlationHeaders() {
5351
+ function correlationLogFields() {
6077
5352
  const correlationId = getContext().correlationId;
6078
5353
  if (!correlationId || correlationId === "unknown") {
6079
5354
  return {};
6080
5355
  }
6081
- return { "x-correlation-id": correlationId };
5356
+ return { correlationId };
5357
+ }
5358
+ function correlationHeaders() {
5359
+ const fields = correlationLogFields();
5360
+ return fields.correlationId ? { "x-correlation-id": fields.correlationId } : {};
6082
5361
  }
6083
5362
  function discoveryQuery(options) {
6084
5363
  const params = new URLSearchParams();
@@ -6366,10 +5645,12 @@ var ProviderFailoverCoordinator = class {
6366
5645
  }
6367
5646
  this.state = PROVIDER_TRANSPORT_STATE.EXTENSION_UNAVAILABLE;
6368
5647
  this.lastProbeAt = this.now();
5648
+ const correlationId = getContext().correlationId;
6369
5649
  createOperationalLogger(this.logger).warn(RUNTIME_METADATA_EVENTS.PROVIDER_FALLBACK, {
6370
5650
  reason,
6371
5651
  fallback: METADATA_PROVIDER_KIND.S3,
6372
- recoverable: true
5652
+ recoverable: true,
5653
+ ...correlationId && correlationId !== "unknown" ? { correlationId } : {}
6373
5654
  });
6374
5655
  await this.onFallbackActivated?.(reason);
6375
5656
  }
@@ -6395,8 +5676,6 @@ var ProviderFailoverCoordinator = class {
6395
5676
  function isExtensionServing(status) {
6396
5677
  return SERVING_STATES.has(status.state) && Boolean(status.releaseId);
6397
5678
  }
6398
-
6399
- // ../../libs/runtime-metadata/src/lib/provider/S3MetadataProvider.ts
6400
5679
  var S3MetadataProvider = class {
6401
5680
  cache;
6402
5681
  resolver;
@@ -6432,9 +5711,9 @@ var S3MetadataProvider = class {
6432
5711
  };
6433
5712
  }
6434
5713
  async getValue(typeCode, valueCode, options) {
6435
- const resolved2 = this.valueFilter(options);
5714
+ const resolved = this.valueFilter(options);
6436
5715
  await this.ensureTypesLoaded([typeCode]);
6437
- if (resolved2.filter === METADATA_STATUS_FILTER.ACTIVE) {
5716
+ if (resolved.filter === METADATA_STATUS_FILTER.ACTIVE) {
6438
5717
  try {
6439
5718
  const entry2 = this.resolver.resolve(typeCode, valueCode, options?.version);
6440
5719
  return projectionEntryToMetadataValue(
@@ -6453,7 +5732,7 @@ var S3MetadataProvider = class {
6453
5732
  const entry = findPublishedEntry(
6454
5733
  this.cache.getDomainFile(typeCode),
6455
5734
  valueCode,
6456
- resolved2.filter
5735
+ resolved.filter
6457
5736
  );
6458
5737
  return entry ? projectionEntryToMetadataValue(typeCode, valueCode, entry, options?.locale) : null;
6459
5738
  }
@@ -6502,13 +5781,13 @@ var S3MetadataProvider = class {
6502
5781
  };
6503
5782
  }
6504
5783
  async listRelations(query) {
6505
- const resolved2 = resolveMetadataStatusFilter({ status: query.status });
6506
- if (!resolved2.ok) {
6507
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
5784
+ const resolved = resolveMetadataStatusFilter({ status: query.status });
5785
+ if (!resolved.ok) {
5786
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
6508
5787
  }
6509
5788
  const relations = this.cache.getTypedRelations();
6510
5789
  if (!relations) {
6511
- if (resolved2.filter !== METADATA_STATUS_FILTER.ACTIVE) {
5790
+ if (resolved.filter !== METADATA_STATUS_FILTER.ACTIVE) {
6512
5791
  throw new MetadataDiscoveryError(
6513
5792
  "INACTIVE and ALL relationship queries require typed-relations.json",
6514
5793
  METADATA_LIFECYCLE_UNSUPPORTED
@@ -6525,7 +5804,7 @@ var S3MetadataProvider = class {
6525
5804
  supported: true,
6526
5805
  relations: filterTypedRelations(relations, {
6527
5806
  ...query,
6528
- status: resolved2.filter
5807
+ status: resolved.filter
6529
5808
  })
6530
5809
  };
6531
5810
  }
@@ -6557,15 +5836,15 @@ var S3MetadataProvider = class {
6557
5836
  if (sourceValueCodes.length === 0) {
6558
5837
  return [];
6559
5838
  }
6560
- const resolved2 = this.valueFilter(options);
5839
+ const resolved = this.valueFilter(options);
6561
5840
  await this.ensureTypesLoaded([sourceTypeCode, targetTypeCode]);
6562
- if (resolved2.filter !== METADATA_STATUS_FILTER.ACTIVE) {
5841
+ if (resolved.filter !== METADATA_STATUS_FILTER.ACTIVE) {
6563
5842
  return this.relatedGroupsForStatus(
6564
5843
  sourceTypeCode,
6565
5844
  sourceValueCodes,
6566
5845
  targetTypeCode,
6567
- resolved2.filter,
6568
- resolved2.enforceCapability,
5846
+ resolved.filter,
5847
+ resolved.enforceCapability,
6569
5848
  options
6570
5849
  );
6571
5850
  }
@@ -6589,8 +5868,8 @@ var S3MetadataProvider = class {
6589
5868
  if (!file) {
6590
5869
  return null;
6591
5870
  }
6592
- const resolved2 = this.valueFilter(options);
6593
- const values = entriesForStatus(file, resolved2.filter).map(
5871
+ const resolved = this.valueFilter(options);
5872
+ const values = entriesForStatus(file, resolved.filter).map(
6594
5873
  (entry) => projectionEntryToMetadataValue(typeCode, entry.code, entry, options?.locale)
6595
5874
  );
6596
5875
  return {
@@ -6651,9 +5930,9 @@ var S3MetadataProvider = class {
6651
5930
  const releaseId = await this.prepareDiscoveryRead(query.readPolicy, query.releaseId);
6652
5931
  const relations = this.cache.getTypedRelations();
6653
5932
  const relationshipIndex = this.cache.getRelationshipIndex();
6654
- const resolved2 = resolveMetadataStatusFilter({ status: query.status });
6655
- if (!resolved2.ok) {
6656
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
5933
+ const resolved = resolveMetadataStatusFilter({ status: query.status });
5934
+ if (!resolved.ok) {
5935
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
6657
5936
  }
6658
5937
  const listed = resolvePublishedRelationshipQuery({
6659
5938
  typedSupported: relations !== void 0,
@@ -6665,7 +5944,7 @@ var S3MetadataProvider = class {
6665
5944
  targetTypeCode: query.targetTypeCode,
6666
5945
  relationType: query.relationType,
6667
5946
  direction: query.direction,
6668
- status: resolved2.filter
5947
+ status: resolved.filter
6669
5948
  });
6670
5949
  if (!listed.ok) {
6671
5950
  throwPublishedListFailure(listed);
@@ -6709,13 +5988,13 @@ var S3MetadataProvider = class {
6709
5988
  "METADATA_TYPE_INCOMPLETE"
6710
5989
  );
6711
5990
  }
6712
- const resolved2 = resolveMetadataStatusFilter({ status: options?.status });
6713
- if (!resolved2.ok) {
6714
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
5991
+ const resolved = resolveMetadataStatusFilter({ status: options?.status });
5992
+ if (!resolved.ok) {
5993
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
6715
5994
  }
6716
- if (resolved2.enforceCapability) {
5995
+ if (resolved.enforceCapability) {
6717
5996
  const blocked = lifecycleQueryFailure(
6718
- resolved2.filter,
5997
+ resolved.filter,
6719
5998
  inactiveValuesPublished(this.cache.getManifest()?.lifecycle)
6720
5999
  );
6721
6000
  if (blocked) {
@@ -6728,7 +6007,7 @@ var S3MetadataProvider = class {
6728
6007
  }
6729
6008
  const listed = listPublishedValues(extracted.entries, {
6730
6009
  releaseId,
6731
- status: projectionStatusLiterals(resolved2.filter),
6010
+ status: projectionStatusLiterals(resolved.filter),
6732
6011
  limit: options?.limit,
6733
6012
  cursor: options?.cursor,
6734
6013
  sortBy: options?.sortBy,
@@ -6758,23 +6037,23 @@ var S3MetadataProvider = class {
6758
6037
  );
6759
6038
  }
6760
6039
  valueFilter(options) {
6761
- const resolved2 = resolveMetadataStatusFilter({
6040
+ const resolved = resolveMetadataStatusFilter({
6762
6041
  status: options?.status,
6763
6042
  includeInactive: options?.includeInactive
6764
6043
  });
6765
- if (!resolved2.ok) {
6766
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
6044
+ if (!resolved.ok) {
6045
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
6767
6046
  }
6768
- if (resolved2.enforceCapability) {
6047
+ if (resolved.enforceCapability) {
6769
6048
  const blocked = lifecycleQueryFailure(
6770
- resolved2.filter,
6049
+ resolved.filter,
6771
6050
  inactiveValuesPublished(this.cache.getManifest()?.lifecycle)
6772
6051
  );
6773
6052
  if (blocked) {
6774
6053
  throw new MetadataDiscoveryError(blocked.message, blocked.code);
6775
6054
  }
6776
6055
  }
6777
- return resolved2;
6056
+ return resolved;
6778
6057
  }
6779
6058
  async relatedGroupsForStatus(sourceTypeCode, sourceValueCodes, targetTypeCode, filter, enforceCapability, options) {
6780
6059
  const relations = this.cache.getTypedRelations();
@@ -7014,8 +6293,8 @@ var RuntimeMetadataService = class {
7014
6293
  logs.debug(RUNTIME_METADATA_EVENTS.INIT_START, {
7015
6294
  transport: "extension"
7016
6295
  });
7017
- const ready = await this.initializeFromExtension();
7018
- if (ready) {
6296
+ const outcome = await this.initializeFromExtension();
6297
+ if (outcome === "ready") {
7019
6298
  const durationMs = Date.now() - started;
7020
6299
  logs.info(RUNTIME_METADATA_EVENTS.INIT_COMPLETE, {
7021
6300
  transport: "extension",
@@ -7035,20 +6314,24 @@ var RuntimeMetadataService = class {
7035
6314
  return;
7036
6315
  }
7037
6316
  if (!this.metadataProviderFallback) {
6317
+ const catalogEmpty = outcome === "catalog-empty";
7038
6318
  logs.error(RUNTIME_METADATA_EVENTS.INIT_FAILED, {
7039
6319
  transport: "extension",
7040
- reason: "fallback-disabled",
6320
+ reason: catalogEmpty ? "extension-catalog-empty" : "fallback-disabled",
7041
6321
  durationMs: Date.now() - started,
7042
6322
  ...correlationFields()
7043
6323
  });
7044
6324
  throw new MetadataProjectionUnavailableError(
7045
- "Metadata extension is unavailable and S3 fallback is disabled",
6325
+ catalogEmpty ? "Metadata extension is ready but did not publish a metadata type catalog, and S3 fallback is disabled" : "Metadata extension is unavailable and S3 fallback is disabled",
7046
6326
  { retryable: true }
7047
6327
  );
7048
6328
  }
7049
- await this.providerCoordinator.activateFallback("extension-init");
6329
+ await this.providerCoordinator.activateFallback(
6330
+ outcome === "catalog-empty" ? "extension-catalog-empty" : "extension-init"
6331
+ );
7050
6332
  }
7051
6333
  await this.refreshService.initialize(revision ?? this.config.revision);
6334
+ this.logInstalledManifest("s3");
7052
6335
  this.startS3PeriodicCheck();
7053
6336
  }
7054
6337
  /**
@@ -7147,8 +6430,22 @@ var RuntimeMetadataService = class {
7147
6430
  totalUniqueTypesDiscovered: 0,
7148
6431
  totalUniqueTypeValuesDiscovered: 0
7149
6432
  };
7150
- const references = collectResponseReferences(response, { knownTypes, diagnostics });
7151
- const typeCodes = collectResponseTypeCodes(response, { knownTypes, diagnostics });
6433
+ let references = collectResponseReferences(response, { knownTypes, diagnostics });
6434
+ let typeCodes = collectResponseTypeCodes(response, { knownTypes, diagnostics });
6435
+ if ((!knownTypes || knownTypes.length === 0) && this.cache.isReady()) {
6436
+ const refreshedTypes = this.listMetadataTypes();
6437
+ if (refreshedTypes.length > 0) {
6438
+ references = collectResponseReferences(response, {
6439
+ knownTypes: refreshedTypes,
6440
+ diagnostics
6441
+ });
6442
+ typeCodes = collectResponseTypeCodes(response, {
6443
+ knownTypes: refreshedTypes,
6444
+ diagnostics
6445
+ });
6446
+ }
6447
+ }
6448
+ const knownTypesAvailable = knownTypes?.length ?? 0;
7152
6449
  logs.debug("metadata-enrichment.trace.typeDetection.completed", () => ({
7153
6450
  stage: "ensureProjectionsForResponse",
7154
6451
  hasPotentialMetadata: true,
@@ -7157,7 +6454,7 @@ var RuntimeMetadataService = class {
7157
6454
  totalUniqueTypeValuesDiscovered: diagnostics.totalUniqueTypeValuesDiscovered,
7158
6455
  referencesFound: references.length,
7159
6456
  typeCodeCount: typeCodes.length,
7160
- knownTypesAvailable: knownTypes ? knownTypes.length : 0
6457
+ knownTypesAvailable
7161
6458
  }));
7162
6459
  if (references.length === 0) {
7163
6460
  return;
@@ -7168,11 +6465,13 @@ var RuntimeMetadataService = class {
7168
6465
  );
7169
6466
  const batch = await this.batchGet(compact);
7170
6467
  if (batch.unavailable) {
7171
- await this.providerCoordinator.activateFallback("extension-lookup");
7172
- await this.ensureProjectionTypesLoaded(
7173
- collectResponseTypeCodes(response, { knownTypes })
6468
+ throw new MetadataProjectionUnavailableError(
6469
+ "Metadata extension batch lookup is unavailable",
6470
+ {
6471
+ retryable: true,
6472
+ metadata: { operation: "ensureProjectionsForResponse" }
6473
+ }
7174
6474
  );
7175
- return;
7176
6475
  }
7177
6476
  return;
7178
6477
  }
@@ -7192,7 +6491,6 @@ var RuntimeMetadataService = class {
7192
6491
  if (!this.cache.isReady()) {
7193
6492
  await this.initialize();
7194
6493
  }
7195
- const startLoadTime = Date.now();
7196
6494
  const inMemoryBefore = metadataTypeCodes.filter((c) => Boolean(this.cache.getDomainFile(c)));
7197
6495
  const missingInitial = this.findMissingTypeCodes(metadataTypeCodes);
7198
6496
  const logs = createOperationalLogger(this.logger);
@@ -7205,13 +6503,6 @@ var RuntimeMetadataService = class {
7205
6503
  while (true) {
7206
6504
  const missing = this.findMissingTypeCodes(metadataTypeCodes);
7207
6505
  if (missing.length === 0) {
7208
- logs.debug("metadata-enrichment.trace.metadataLoading.completed", {
7209
- stage: "ensureProjectionTypesLoaded",
7210
- durationMs: Date.now() - startLoadTime,
7211
- s3IoAttempted: missingInitial.length > 0,
7212
- outcome: "all_types_in_cache",
7213
- totalRequested: metadataTypeCodes.length
7214
- });
7215
6506
  return;
7216
6507
  }
7217
6508
  const inFlight = missing.map((code) => this.domainLoadInFlight.get(code)).filter((p) => p != null);
@@ -7451,24 +6742,46 @@ var RuntimeMetadataService = class {
7451
6742
  }
7452
6743
  }
7453
6744
  async batchGet(references, options) {
6745
+ const started = Date.now();
7454
6746
  let provider;
7455
6747
  try {
7456
6748
  provider = await this.activeProvider();
7457
6749
  const generationAtStart = this.cache.getGeneration();
7458
6750
  const result = await provider.batchGet(references, options);
6751
+ const durationMs = Date.now() - started;
6752
+ const uniqueCount = new Set(references.filter((ref) => ref.trim())).size;
7459
6753
  createOperationalLogger(this.logger).debug(RUNTIME_METADATA_EVENTS.BATCH_LOOKUP, {
7460
- requested: references.length,
7461
- resolved: Object.keys(result.items).length,
7462
- invalid: result.invalidReferences.length,
7463
- unavailable: result.unavailable,
6754
+ event: "metadata.lookup.completed",
6755
+ operation: "batchGet",
6756
+ component: "consumer",
7464
6757
  transport: this.providerCoordinator.getActiveKind(),
7465
- releaseId: result.releaseId
6758
+ releaseId: result.releaseId,
6759
+ durationMs,
6760
+ requestedCount: references.length,
6761
+ uniqueCount,
6762
+ resolvedCount: Object.keys(result.items).length,
6763
+ invalidCount: result.invalidReferences.length,
6764
+ providerRequestCount: 1,
6765
+ outcome: "success",
6766
+ ...correlationFields()
7466
6767
  });
7467
- if (result.unavailable && this.metadataProviderFallback && provider !== this.metadataProviderFallback) {
7468
- await this.providerCoordinator.activateFallback("batch-unavailable");
7469
- return this.metadataProviderFallback.batchGet(references, options);
6768
+ if (result.unavailable) {
6769
+ if (this.metadataProviderFallback && provider !== this.metadataProviderFallback) {
6770
+ await this.providerCoordinator.activateFallback("batch-unavailable");
6771
+ return this.metadataProviderFallback.batchGet(references, options);
6772
+ }
6773
+ if (this.metadataProviderFallback) {
6774
+ return result;
6775
+ }
6776
+ throw new MetadataProjectionUnavailableError(
6777
+ "Metadata extension batch lookup is unavailable",
6778
+ {
6779
+ retryable: true,
6780
+ metadata: { operation: "batchGet", requestedCount: references.length }
6781
+ }
6782
+ );
7470
6783
  }
7471
- this.installBatchReleaseIfCurrent(result, generationAtStart);
6784
+ await this.installBatchReleaseIfCurrent(result, generationAtStart);
7472
6785
  this.hydrateProviderValues(
7473
6786
  Object.values(result.items),
7474
6787
  {
@@ -7484,6 +6797,15 @@ var RuntimeMetadataService = class {
7484
6797
  return fallback.batchGet(references, options);
7485
6798
  }
7486
6799
  }
6800
+ createOperationalLogger(this.logger).error("metadata.lookup.failed", {
6801
+ operation: "batchGet",
6802
+ component: "consumer",
6803
+ transport: this.providerCoordinator.getActiveKind(),
6804
+ durationMs: Date.now() - started,
6805
+ errorCode: err instanceof MetadataProjectionUnavailableError ? err.code : err instanceof Error ? err.name : "METADATA_LOOKUP_FAILED",
6806
+ outcome: "error",
6807
+ ...correlationFields()
6808
+ });
7487
6809
  throw err;
7488
6810
  }
7489
6811
  }
@@ -7610,6 +6932,25 @@ var RuntimeMetadataService = class {
7610
6932
  const guard = this.currentWriteGuard();
7611
6933
  const listed = await provider.listTypeValues(typeCode, options);
7612
6934
  this.hydrateProviderValues(listed?.values ?? [], guard);
6935
+ if (listed?.type) {
6936
+ const typeCode2 = listed.type.metadataType;
6937
+ this.cache.mergeTypeCatalog(
6938
+ {
6939
+ [typeCode2]: {
6940
+ typeCode: typeCode2,
6941
+ projectionFile: `${typeCode2}.json`,
6942
+ valueDataType: listed.type.valueDataType,
6943
+ multiSelectAllowed: listed.type.multiSelectAllowed,
6944
+ ...listed.type.displayName ? {
6945
+ localizedDisplayName: {
6946
+ [this.cache.getManifest()?.localization?.defaultLocale ?? "en-US"]: listed.type.displayName
6947
+ }
6948
+ } : {}
6949
+ }
6950
+ },
6951
+ guard
6952
+ );
6953
+ }
7613
6954
  return listed;
7614
6955
  } catch (err) {
7615
6956
  if (await this.tryActivateFallbackFromError(err, "extension-list", provider)) {
@@ -7777,6 +7118,22 @@ var RuntimeMetadataService = class {
7777
7118
  getActiveProviderKind() {
7778
7119
  return this.providerCoordinator.getActiveKind();
7779
7120
  }
7121
+ /**
7122
+ * One localization dictionary for a locale (`localization/<locale>.json`).
7123
+ * A missing locale file returns undefined. Transport and projection failures throw.
7124
+ * An empty dictionary is a published file, not a failed read.
7125
+ */
7126
+ async getLocalizationMap(locale) {
7127
+ const provider = await this.activeProvider();
7128
+ const reader = provider.getLocalizationMap;
7129
+ if (typeof reader !== "function") {
7130
+ throw new MetadataProjectionUnavailableError(
7131
+ "Localization maps are not available from the active metadata provider",
7132
+ { retryable: false }
7133
+ );
7134
+ }
7135
+ return reader.call(provider, locale);
7136
+ }
7780
7137
  getProviderTransportState() {
7781
7138
  return this.providerCoordinator.getState();
7782
7139
  }
@@ -7808,45 +7165,69 @@ var RuntimeMetadataService = class {
7808
7165
  return changed;
7809
7166
  }
7810
7167
  async initializeFromExtension() {
7168
+ const started = Date.now();
7811
7169
  try {
7812
7170
  const extension = this.metadataProvider;
7813
7171
  const status = extension.waitUntilReady ? await extension.waitUntilReady() : await extension.getStatus();
7814
7172
  if (!isExtensionServing(status)) {
7815
- return false;
7173
+ return "unavailable";
7816
7174
  }
7817
- this.installExtensionManifest(
7175
+ const installed = this.installExtensionManifest(
7818
7176
  status.releaseId ?? "",
7819
7177
  status.metadataTypes ?? [],
7820
7178
  {
7821
7179
  forceReset: true
7822
7180
  }
7823
7181
  );
7824
- return true;
7182
+ return installed ? "ready" : "catalog-empty";
7825
7183
  } catch (err) {
7826
7184
  if (err instanceof MetadataExtensionContractError) {
7827
7185
  createOperationalLogger(this.logger).error(RUNTIME_METADATA_EVENTS.INIT_FAILED, {
7828
7186
  reason: "extension-contract",
7829
- message: err.message
7187
+ message: err.message,
7188
+ durationMs: Date.now() - started,
7189
+ ...correlationFields()
7830
7190
  });
7831
7191
  throw err;
7832
7192
  }
7833
7193
  createOperationalLogger(this.logger).warn(RUNTIME_METADATA_EVENTS.PROVIDER_FALLBACK, {
7834
7194
  reason: "extension-unavailable",
7835
7195
  recoverable: true,
7836
- message: err instanceof Error ? err.message : String(err)
7196
+ durationMs: Date.now() - started,
7197
+ message: err instanceof Error ? err.message : String(err),
7198
+ ...correlationFields()
7837
7199
  });
7838
- return false;
7200
+ return "unavailable";
7839
7201
  }
7840
7202
  }
7841
7203
  installExtensionManifest(releaseId, metadataTypes, options) {
7842
7204
  if (!releaseId) {
7843
- return;
7205
+ return false;
7844
7206
  }
7845
7207
  const uniqueTypes = [...new Set(metadataTypes.filter((code) => code.trim()))].sort(
7846
7208
  (a, b) => a.localeCompare(b)
7847
7209
  );
7848
- if (!options?.forceReset && this.cache.isReady() && this.cache.getReleaseId() === releaseId) {
7849
- return;
7210
+ const installedTypeCount = Object.keys(
7211
+ this.cache.getManifest()?.metadataTypes ?? {}
7212
+ ).length;
7213
+ if (!options?.forceReset && this.cache.isReady() && this.cache.getReleaseId() === releaseId && installedTypeCount > 0) {
7214
+ return true;
7215
+ }
7216
+ if (uniqueTypes.length === 0) {
7217
+ createOperationalLogger(this.logger).warn(
7218
+ RUNTIME_METADATA_EVENTS.METADATA_MANIFEST_LOADED,
7219
+ {
7220
+ releaseId,
7221
+ transport: "extension",
7222
+ hasManifest: false,
7223
+ metadataTypeCount: 0,
7224
+ lookupIndexCount: 0,
7225
+ cacheStatus: this.cache.getStatus(),
7226
+ catalogAvailable: false,
7227
+ reason: "extension-catalog-empty"
7228
+ }
7229
+ );
7230
+ return false;
7850
7231
  }
7851
7232
  const types = {};
7852
7233
  for (const typeCode of uniqueTypes) {
@@ -7902,6 +7283,30 @@ var RuntimeMetadataService = class {
7902
7283
  };
7903
7284
  this.cache.replace(bundle);
7904
7285
  this.syncUnsupportedProjectionRelease(releaseId);
7286
+ this.logInstalledManifest("extension");
7287
+ return true;
7288
+ }
7289
+ logInstalledManifest(transport) {
7290
+ const manifest = this.cache.getManifest();
7291
+ const metadataTypeCount = Object.keys(manifest?.metadataTypes ?? {}).length;
7292
+ const lookupIndexCount = Object.keys(manifest?.lookupIndex ?? {}).length;
7293
+ const catalogAvailable = metadataTypeCount > 0;
7294
+ const logs = createOperationalLogger(this.logger);
7295
+ const payload = {
7296
+ releaseId: this.cache.getReleaseId(),
7297
+ transport,
7298
+ hasManifest: manifest != null,
7299
+ metadataTypeCount,
7300
+ lookupIndexCount,
7301
+ cacheStatus: this.cache.getStatus(),
7302
+ catalogAvailable,
7303
+ ...catalogAvailable ? {} : { reason: "catalog-empty" }
7304
+ };
7305
+ if (!catalogAvailable) {
7306
+ logs.warn(RUNTIME_METADATA_EVENTS.METADATA_MANIFEST_LOADED, payload);
7307
+ return;
7308
+ }
7309
+ logs.info(RUNTIME_METADATA_EVENTS.METADATA_MANIFEST_LOADED, payload);
7905
7310
  }
7906
7311
  hydrateProviderValues(values, guard) {
7907
7312
  if (!this.cache.isReady() || values.length === 0 || !guard.releaseId) {
@@ -7911,7 +7316,8 @@ var RuntimeMetadataService = class {
7911
7316
  values.map((value) => ({
7912
7317
  typeCode: value.typeCode,
7913
7318
  valueCode: value.valueCode,
7914
- entry: value.entry
7319
+ entry: value.entry,
7320
+ localizedLabel: value.localizedLabel
7915
7321
  })),
7916
7322
  guard
7917
7323
  );
@@ -7922,7 +7328,7 @@ var RuntimeMetadataService = class {
7922
7328
  generation: captured?.generation ?? this.cache.getGeneration()
7923
7329
  };
7924
7330
  }
7925
- installBatchReleaseIfCurrent(result, generationAtStart) {
7331
+ async installBatchReleaseIfCurrent(result, generationAtStart) {
7926
7332
  if (!result.releaseId || !this.usesExtensionTransport()) {
7927
7333
  return;
7928
7334
  }
@@ -7934,14 +7340,18 @@ var RuntimeMetadataService = class {
7934
7340
  if (staleInFlight) {
7935
7341
  return;
7936
7342
  }
7937
- this.installExtensionManifest(
7343
+ const status = await this.metadataProvider.getStatus();
7344
+ if (status.releaseId !== result.releaseId) {
7345
+ return;
7346
+ }
7347
+ const installed = this.installExtensionManifest(
7938
7348
  result.releaseId,
7939
- Object.keys(result.items).map((key) => {
7940
- const sep = key.indexOf(":");
7941
- return sep > 0 ? key.slice(0, sep) : key;
7942
- }),
7349
+ status.metadataTypes ?? [],
7943
7350
  { forceReset: true }
7944
7351
  );
7352
+ if (!installed) {
7353
+ this.cache.clear();
7354
+ }
7945
7355
  }
7946
7356
  async withDiscoveryProvider(readPolicy, run) {
7947
7357
  try {
@@ -8020,13 +7430,11 @@ async function mapPool(items, limit, run) {
8020
7430
  await Promise.all(workers);
8021
7431
  return results;
8022
7432
  }
8023
-
8024
- // ../../libs/runtime-metadata/src/lib/integration/createRuntimeMetadataFromEnv.ts
8025
7433
  function createRuntimeMetadataFromEnv(options) {
8026
7434
  const env = options.env ?? process.env;
8027
7435
  const bucket = resolveMetadataProjectionsBucket(env);
8028
7436
  const environment = (options.environment ?? env.PROJECTION_ENVIRONMENT ?? env.STAGE ?? env.NODE_ENV ?? "dev").trim().toLowerCase();
8029
- const config2 = {
7437
+ const config = {
8030
7438
  bucket,
8031
7439
  prefix: resolveProjectionsPrefix(env),
8032
7440
  environment,
@@ -8038,12 +7446,12 @@ function createRuntimeMetadataFromEnv(options) {
8038
7446
  };
8039
7447
  return new RuntimeMetadataService({
8040
7448
  client: options.client,
8041
- config: config2,
7449
+ config,
8042
7450
  env,
8043
7451
  logger: options.logger ?? createLogger({ serviceName: "runtime-metadata" })
8044
7452
  });
8045
7453
  }
8046
- var logger2 = createLogger({
7454
+ var logger = createLogger({
8047
7455
  service: process.env.SERVICE_NAME ?? "api-service",
8048
7456
  redactPII: true
8049
7457
  });
@@ -8062,7 +7470,7 @@ function getRuntimeMetadataService() {
8062
7470
  client: new S3Client({
8063
7471
  region: process.env.AWS_REGION ?? process.env.REGION
8064
7472
  }),
8065
- logger: logger2
7473
+ logger
8066
7474
  });
8067
7475
  }
8068
7476
  return metadataServiceInstance;
@@ -8133,6 +7541,8 @@ var InMemoryMetadataProvider = class {
8133
7541
  knownTypeCodes = /* @__PURE__ */ new Set();
8134
7542
  lifecycleSupported;
8135
7543
  permissionRegistry;
7544
+ localization;
7545
+ localizationUnavailable;
8136
7546
  activeByType = /* @__PURE__ */ new Map();
8137
7547
  inactiveByType = /* @__PURE__ */ new Map();
8138
7548
  constructor(options = {}) {
@@ -8140,6 +7550,8 @@ var InMemoryMetadataProvider = class {
8140
7550
  this.unavailable = options.unavailable === true;
8141
7551
  this.lifecycleSupported = options.lifecycleSupported !== false;
8142
7552
  this.permissionRegistry = options.permissionRegistry;
7553
+ this.localization = options.localization;
7554
+ this.localizationUnavailable = options.localizationUnavailable === true;
8143
7555
  this.relations = options.relations;
8144
7556
  this.typedRelationIndex = options.relations ? buildTypedRelationIndex(options.relations) : void 0;
8145
7557
  for (const typeCode of options.knownTypeCodes ?? []) {
@@ -8194,9 +7606,9 @@ var InMemoryMetadataProvider = class {
8194
7606
  { retryable: true }
8195
7607
  );
8196
7608
  }
8197
- const resolved2 = this.readFilter(options);
7609
+ const resolved = this.readFilter(options);
8198
7610
  const record = this.byKey.get(formatMetadataReference(typeCode, valueCode));
8199
- if (!record || !statusMatchesFilter(record.entry.status, resolved2.filter)) {
7611
+ if (!record || !statusMatchesFilter(record.entry.status, resolved.filter)) {
8200
7612
  return null;
8201
7613
  }
8202
7614
  return projectionEntryToMetadataValue(
@@ -8254,12 +7666,12 @@ var InMemoryMetadataProvider = class {
8254
7666
  { retryable: true }
8255
7667
  );
8256
7668
  }
8257
- const resolved2 = resolveMetadataStatusFilter({ status: query.status });
8258
- if (!resolved2.ok) {
8259
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
7669
+ const resolved = resolveMetadataStatusFilter({ status: query.status });
7670
+ if (!resolved.ok) {
7671
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
8260
7672
  }
8261
7673
  if (!this.relations) {
8262
- if (resolved2.filter !== METADATA_STATUS_FILTER.ACTIVE) {
7674
+ if (resolved.filter !== METADATA_STATUS_FILTER.ACTIVE) {
8263
7675
  throw new MetadataDiscoveryError(
8264
7676
  "INACTIVE and ALL relationship queries require typed-relations.json",
8265
7677
  METADATA_LIFECYCLE_UNSUPPORTED
@@ -8272,7 +7684,7 @@ var InMemoryMetadataProvider = class {
8272
7684
  supported: true,
8273
7685
  relations: filterTypedRelations(this.relations, {
8274
7686
  ...query,
8275
- status: resolved2.filter
7687
+ status: resolved.filter
8276
7688
  })
8277
7689
  };
8278
7690
  }
@@ -8285,6 +7697,16 @@ var InMemoryMetadataProvider = class {
8285
7697
  }
8286
7698
  return this.relatedValuesFor(sourceTypeCode, sourceValueCode, targetTypeCode, options);
8287
7699
  }
7700
+ async getLocalizationMap(locale) {
7701
+ if (this.unavailable || this.localizationUnavailable) {
7702
+ throw new MetadataProjectionUnavailableError("Localization projection is unavailable", {
7703
+ retryable: true
7704
+ });
7705
+ }
7706
+ const dictionary = this.localization?.[locale];
7707
+ if (!dictionary) return void 0;
7708
+ return { ...dictionary };
7709
+ }
8288
7710
  async getPermissionRegistry() {
8289
7711
  if (this.unavailable || !this.permissionRegistry) {
8290
7712
  throw new MetadataProjectionUnavailableError(
@@ -8319,15 +7741,15 @@ var InMemoryMetadataProvider = class {
8319
7741
  return groups;
8320
7742
  }
8321
7743
  async relatedValuesFor(sourceTypeCode, sourceValueCode, targetTypeCode, options) {
8322
- const resolved2 = this.readFilter(options);
8323
- if (resolved2.filter !== METADATA_STATUS_FILTER.ACTIVE && !this.relations) {
8324
- if (resolved2.enforceCapability) {
7744
+ const resolved = this.readFilter(options);
7745
+ if (resolved.filter !== METADATA_STATUS_FILTER.ACTIVE && !this.relations) {
7746
+ if (resolved.enforceCapability) {
8325
7747
  throw new MetadataDiscoveryError(
8326
7748
  "INACTIVE and ALL related-value queries require typed-relations.json",
8327
7749
  METADATA_LIFECYCLE_UNSUPPORTED
8328
7750
  );
8329
7751
  }
8330
- } else if (resolved2.filter !== METADATA_STATUS_FILTER.ACTIVE && this.relations) {
7752
+ } else if (resolved.filter !== METADATA_STATUS_FILTER.ACTIVE && this.relations) {
8331
7753
  const listed = resolvePublishedRelationshipQuery({
8332
7754
  typedSupported: true,
8333
7755
  relations: this.relations,
@@ -8335,7 +7757,7 @@ var InMemoryMetadataProvider = class {
8335
7757
  sourceTypeCode,
8336
7758
  sourceValueCode,
8337
7759
  targetTypeCode,
8338
- status: resolved2.filter
7760
+ status: resolved.filter
8339
7761
  });
8340
7762
  if (!listed.ok) {
8341
7763
  throw new MetadataDiscoveryError(listed.message, listed.code);
@@ -8378,8 +7800,8 @@ var InMemoryMetadataProvider = class {
8378
7800
  if (!this.hasType(typeCode)) {
8379
7801
  return null;
8380
7802
  }
8381
- const resolved2 = this.readFilter(options);
8382
- const records = this.recordsForFilter(typeCode, resolved2.filter);
7803
+ const resolved = this.readFilter(options);
7804
+ const records = this.recordsForFilter(typeCode, resolved.filter);
8383
7805
  const values = [];
8384
7806
  for (const record of records) {
8385
7807
  const value = await this.getValue(record.typeCode, record.valueCode, options);
@@ -8446,9 +7868,9 @@ var InMemoryMetadataProvider = class {
8446
7868
  }
8447
7869
  async getRelationships(query) {
8448
7870
  this.assertReadable(query.readPolicy, query.releaseId);
8449
- const resolved2 = resolveMetadataStatusFilter({ status: query.status });
8450
- if (!resolved2.ok) {
8451
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
7871
+ const resolved = resolveMetadataStatusFilter({ status: query.status });
7872
+ if (!resolved.ok) {
7873
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
8452
7874
  }
8453
7875
  const listed = resolvePublishedRelationshipQuery({
8454
7876
  typedSupported: this.relations !== void 0,
@@ -8459,7 +7881,7 @@ var InMemoryMetadataProvider = class {
8459
7881
  targetTypeCode: query.targetTypeCode,
8460
7882
  relationType: query.relationType,
8461
7883
  direction: query.direction,
8462
- status: resolved2.filter
7884
+ status: resolved.filter
8463
7885
  });
8464
7886
  if (!listed.ok) {
8465
7887
  throwPublishedListFailure(listed);
@@ -8474,22 +7896,22 @@ var InMemoryMetadataProvider = class {
8474
7896
  if (!this.hasType(typeCode)) {
8475
7897
  throw new UnknownMetadataTypeError(typeCode);
8476
7898
  }
8477
- const resolved2 = resolveMetadataStatusFilter({ status: options?.status });
8478
- if (!resolved2.ok) {
8479
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
7899
+ const resolved = resolveMetadataStatusFilter({ status: options?.status });
7900
+ if (!resolved.ok) {
7901
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
8480
7902
  }
8481
- if (resolved2.enforceCapability && !this.lifecycleSupported) {
7903
+ if (resolved.enforceCapability && !this.lifecycleSupported) {
8482
7904
  throw new MetadataDiscoveryError(
8483
7905
  "This projection release does not publish inactive lifecycle records. An INACTIVE or ALL query cannot be answered from active-only artifacts.",
8484
7906
  METADATA_LIFECYCLE_UNSUPPORTED
8485
7907
  );
8486
7908
  }
8487
- const entries = this.recordsForFilter(typeCode, resolved2.filter).map(
7909
+ const entries = this.recordsForFilter(typeCode, resolved.filter).map(
8488
7910
  (record) => record.entry
8489
7911
  );
8490
7912
  const listed = listPublishedValues(entries, {
8491
7913
  releaseId: this.releaseId,
8492
- status: projectionStatusLiterals(resolved2.filter),
7914
+ status: projectionStatusLiterals(resolved.filter),
8493
7915
  limit: options?.limit,
8494
7916
  cursor: options?.cursor,
8495
7917
  sortBy: options?.sortBy,
@@ -8540,20 +7962,20 @@ var InMemoryMetadataProvider = class {
8540
7962
  }
8541
7963
  }
8542
7964
  readFilter(options) {
8543
- const resolved2 = resolveMetadataStatusFilter({
7965
+ const resolved = resolveMetadataStatusFilter({
8544
7966
  status: options?.status,
8545
7967
  includeInactive: options?.includeInactive
8546
7968
  });
8547
- if (!resolved2.ok) {
8548
- throw new MetadataDiscoveryError(resolved2.message, resolved2.code);
7969
+ if (!resolved.ok) {
7970
+ throw new MetadataDiscoveryError(resolved.message, resolved.code);
8549
7971
  }
8550
- if (resolved2.enforceCapability && !this.lifecycleSupported) {
7972
+ if (resolved.enforceCapability && !this.lifecycleSupported) {
8551
7973
  throw new MetadataDiscoveryError(
8552
7974
  "This projection release does not publish inactive lifecycle records. An INACTIVE or ALL query cannot be answered from active-only artifacts.",
8553
7975
  METADATA_LIFECYCLE_UNSUPPORTED
8554
7976
  );
8555
7977
  }
8556
- return resolved2;
7978
+ return resolved;
8557
7979
  }
8558
7980
  recordsForFilter(typeCode, filter) {
8559
7981
  if (filter === METADATA_STATUS_FILTER.INACTIVE) {
@@ -8580,6 +8002,6 @@ var InMemoryMetadataProvider = class {
8580
8002
  }
8581
8003
  };
8582
8004
 
8583
- export { CACHE_STATUS, DEFAULT_EXCLUDED_CODE_FIELDS, DEFAULT_PROVIDER_RECOVERY_COOLDOWN_MS, ExtensionMetadataProvider, InMemoryMetadataProvider, InvalidMetadataReferenceError, METADATA_ATTRIBUTE_FILTER_KEY, METADATA_PROJECTIONS_BUCKET_ENV, METADATA_PROVIDER_KIND, METADATA_READ_POLICY, METADATA_RELATION_DIRECTION, ManifestValidationError, MetadataCache, MetadataDiscoveryError, MetadataDownloader, MetadataExtensionContractError, MetadataFreshnessError, MetadataHealthService, MetadataLoader, MetadataLookupError, MetadataNotReadyError, MetadataProjectionUnavailableError, MetadataRefreshService, MetadataReleaseMismatchError, MetadataResolver, NON_METADATA_KEYS, PROVIDER_TRANSPORT_STATE, ProjectionDownloadError, ProviderFailoverCoordinator, REFRESH_STATUS, RELATIONSHIP_QUERY_BATCH_LIMIT, RUNTIME_METADATA_EVENTS, RUNTIME_METADATA_INTEGRATION_TARGETS, RUNTIME_METADATA_TYPE_CODE_ALIASES, RuntimeMetadataError, RuntimeMetadataService, S3MetadataProvider, 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 };
8005
+ export { APPLIES_TO_LINKED_ENTITY_METADATA_TYPE, CACHE_STATUS, DEFAULT_EXCLUDED_CODE_FIELDS, DEFAULT_PROVIDER_RECOVERY_COOLDOWN_MS, ExtensionMetadataProvider, FIELD_KEY_METADATA_TYPE_ALIASES, InMemoryMetadataProvider, InvalidMetadataReferenceError, METADATA_ATTRIBUTE_FILTER_KEY, METADATA_PROJECTIONS_BUCKET_ENV, METADATA_PROVIDER_KIND, METADATA_READ_POLICY, METADATA_RELATION_DIRECTION, METADATA_TRAVERSAL_MAX_DEPTH, METADATA_TRAVERSAL_MAX_NODES, ManifestValidationError, MetadataCache, MetadataDiscoveryError, MetadataDownloader, MetadataExtensionContractError, MetadataFreshnessError, MetadataHealthService, MetadataLoader, MetadataLookupError, MetadataNotReadyError, MetadataProjectionUnavailableError, MetadataRefreshService, MetadataReleaseMismatchError, MetadataResolver, NON_METADATA_KEYS, PROVIDER_TRANSPORT_STATE, ProjectionDownloadError, ProviderFailoverCoordinator, REFRESH_STATUS, RELATIONSHIP_QUERY_BATCH_LIMIT, RUNTIME_METADATA_EVENTS, RUNTIME_METADATA_INTEGRATION_TARGETS, RUNTIME_METADATA_TYPE_CODE_ALIASES, RuntimeMetadataError, RuntimeMetadataService, S3MetadataProvider, UnknownMetadataTypeError, WORKFLOW_STEP_RULE_KEYS, assertMetadataReadPolicy, assertReleasePin, canonicalMetadataProjectionsBucketName, collectResponseReferences, collectResponseTypeCodes, createCodeFieldExclusionSet, createRuntimeMetadataFromEnv, defaultExtensionBaseUrl, ensureRuntimeMetadataLoaded, formatMetadataReference, getCandidateTypeCodesForKey, getRuntimeMetadataHealth, getRuntimeMetadataService, hasPotentialMetadata, isCompactMetadataReference, isExtensionEnabled, isExtensionServing, isFreshProjectionState, isLinkedEntityCodeField, isMetadataProjectionConfigured, isMetadataProjectionsBucketConfigured, isMetadataReference, isMetadataValueObject, isMetadataValueObjectArray, isTemplateRuleConfiguration, isTemplateRuleNode, isTemplateRulesMap, isWorkflowStepRecord, isWorkflowStepRuleField, linkedEntityMetadataTypeFromAppliesTo, localizedLabelFromEntry, manifestLocalizationSchema, metadataGroupFromManifest, metadataValueToReference, normalizeRuntimeMetadataTypeCode, onMetadataProjectionCompleted, parseMetadataReference, projectionEntryToMetadataValue, projectionManifestSchema, readAppliesToTypeValue, readMetadataProjectionsBucket, readModelGroupsFromManifest, relatedValueCodes, resetRuntimeMetadataBootstrapState, resolveMetadataProjectionsBucket, resolveRuntimeMetadataConfig, runtimeMetadataConfigSchema, selectMetadataProvider, supportsMetadataDiscovery, throwPublishedListFailure, tryGetRuntimeMetadataService, tryParseMetadataReference, typeCodeFromCodeFieldName };
8584
8006
  //# sourceMappingURL=index.js.map
8585
8007
  //# sourceMappingURL=index.js.map