@c-rex/services 0.3.0-build.39 → 0.3.0-build.41

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.
Files changed (33) hide show
  1. package/dist/index.d.mts +3 -1
  2. package/dist/index.d.ts +3 -1
  3. package/dist/index.js +430 -147
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +411 -143
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/metadata-visibility-policy.d.mts +29 -0
  8. package/dist/metadata-visibility-policy.d.ts +29 -0
  9. package/dist/metadata-visibility-policy.js +129 -0
  10. package/dist/metadata-visibility-policy.js.map +1 -0
  11. package/dist/metadata-visibility-policy.mjs +95 -0
  12. package/dist/metadata-visibility-policy.mjs.map +1 -0
  13. package/dist/read-models/index.d.mts +17 -39
  14. package/dist/read-models/index.d.ts +17 -39
  15. package/dist/read-models/index.js +430 -149
  16. package/dist/read-models/index.js.map +1 -1
  17. package/dist/read-models/index.mjs +410 -144
  18. package/dist/read-models/index.mjs.map +1 -1
  19. package/dist/read-models/metadata-display-builder.d.mts +34 -0
  20. package/dist/read-models/metadata-display-builder.d.ts +34 -0
  21. package/dist/read-models/metadata-display-builder.js +521 -0
  22. package/dist/read-models/metadata-display-builder.js.map +1 -0
  23. package/dist/read-models/metadata-display-builder.mjs +489 -0
  24. package/dist/read-models/metadata-display-builder.mjs.map +1 -0
  25. package/dist/read-models/metadata-presentation-config.js +2 -2
  26. package/dist/read-models/metadata-presentation-config.js.map +1 -1
  27. package/dist/read-models/metadata-presentation-config.mjs +2 -2
  28. package/dist/read-models/metadata-presentation-config.mjs.map +1 -1
  29. package/dist/read-models/metadata-view-profile.js +63 -4
  30. package/dist/read-models/metadata-view-profile.js.map +1 -1
  31. package/dist/read-models/metadata-view-profile.mjs +63 -4
  32. package/dist/read-models/metadata-view-profile.mjs.map +1 -1
  33. package/package.json +19 -1
@@ -0,0 +1,34 @@
1
+ import { RenditionModel, InformationUnitModel, LiteralModel, ObjectRefModel } from '@c-rex/interfaces';
2
+ import { InformationUnitPropertyKey } from './metadata-presentation-config.mjs';
3
+
4
+ type MetadataFacetPresentationItem = {
5
+ label: string;
6
+ groupLabel?: string;
7
+ sectionLabel?: string;
8
+ hidden?: boolean;
9
+ };
10
+ type MetadataFacetPresentation = Partial<Record<InformationUnitPropertyKey, Record<string, MetadataFacetPresentationItem>>>;
11
+ type MetadataFacetLabelOverride = MetadataFacetPresentationItem;
12
+ type MetadataFacetLabelOverrides = MetadataFacetPresentation;
13
+ type MetadataDisplayRow = {
14
+ key: InformationUnitPropertyKey;
15
+ label: string;
16
+ labelSource: "translationKey" | "direct";
17
+ values: string[];
18
+ valueType?: "text" | "language" | "rendition";
19
+ renditions?: RenditionModel[];
20
+ };
21
+ type BuildMetadataDisplayRowsOptions = {
22
+ uiLanguage: string;
23
+ includeProperties: InformationUnitPropertyKey[];
24
+ presentation?: MetadataFacetPresentation;
25
+ overrides?: MetadataFacetPresentation;
26
+ };
27
+ declare const resolveLiteralLabel: (labels?: LiteralModel[] | null, uiLanguage?: string) => string | undefined;
28
+ declare const resolveObjectRefLabel: (item: ObjectRefModel, uiLanguage: string) => string | undefined;
29
+ declare const resolveObjectRefClassLabel: (item: ObjectRefModel, uiLanguage: string) => string | undefined;
30
+ declare const resolveFacetPresentationProperties: (includeProperties: InformationUnitPropertyKey[]) => InformationUnitPropertyKey[];
31
+ declare const resolveOverrideProperties: (includeProperties: InformationUnitPropertyKey[]) => InformationUnitPropertyKey[];
32
+ declare const buildMetadataDisplayRows: (data: InformationUnitModel, options: BuildMetadataDisplayRowsOptions) => MetadataDisplayRow[];
33
+
34
+ export { type MetadataDisplayRow, type MetadataFacetLabelOverride, type MetadataFacetLabelOverrides, type MetadataFacetPresentation, type MetadataFacetPresentationItem, buildMetadataDisplayRows, resolveFacetPresentationProperties, resolveLiteralLabel, resolveObjectRefClassLabel, resolveObjectRefLabel, resolveOverrideProperties };
@@ -0,0 +1,34 @@
1
+ import { RenditionModel, InformationUnitModel, LiteralModel, ObjectRefModel } from '@c-rex/interfaces';
2
+ import { InformationUnitPropertyKey } from './metadata-presentation-config.js';
3
+
4
+ type MetadataFacetPresentationItem = {
5
+ label: string;
6
+ groupLabel?: string;
7
+ sectionLabel?: string;
8
+ hidden?: boolean;
9
+ };
10
+ type MetadataFacetPresentation = Partial<Record<InformationUnitPropertyKey, Record<string, MetadataFacetPresentationItem>>>;
11
+ type MetadataFacetLabelOverride = MetadataFacetPresentationItem;
12
+ type MetadataFacetLabelOverrides = MetadataFacetPresentation;
13
+ type MetadataDisplayRow = {
14
+ key: InformationUnitPropertyKey;
15
+ label: string;
16
+ labelSource: "translationKey" | "direct";
17
+ values: string[];
18
+ valueType?: "text" | "language" | "rendition";
19
+ renditions?: RenditionModel[];
20
+ };
21
+ type BuildMetadataDisplayRowsOptions = {
22
+ uiLanguage: string;
23
+ includeProperties: InformationUnitPropertyKey[];
24
+ presentation?: MetadataFacetPresentation;
25
+ overrides?: MetadataFacetPresentation;
26
+ };
27
+ declare const resolveLiteralLabel: (labels?: LiteralModel[] | null, uiLanguage?: string) => string | undefined;
28
+ declare const resolveObjectRefLabel: (item: ObjectRefModel, uiLanguage: string) => string | undefined;
29
+ declare const resolveObjectRefClassLabel: (item: ObjectRefModel, uiLanguage: string) => string | undefined;
30
+ declare const resolveFacetPresentationProperties: (includeProperties: InformationUnitPropertyKey[]) => InformationUnitPropertyKey[];
31
+ declare const resolveOverrideProperties: (includeProperties: InformationUnitPropertyKey[]) => InformationUnitPropertyKey[];
32
+ declare const buildMetadataDisplayRows: (data: InformationUnitModel, options: BuildMetadataDisplayRowsOptions) => MetadataDisplayRow[];
33
+
34
+ export { type MetadataDisplayRow, type MetadataFacetLabelOverride, type MetadataFacetLabelOverrides, type MetadataFacetPresentation, type MetadataFacetPresentationItem, buildMetadataDisplayRows, resolveFacetPresentationProperties, resolveLiteralLabel, resolveObjectRefClassLabel, resolveObjectRefLabel, resolveOverrideProperties };
@@ -0,0 +1,521 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/read-models/metadata-display-builder.ts
21
+ var metadata_display_builder_exports = {};
22
+ __export(metadata_display_builder_exports, {
23
+ buildMetadataDisplayRows: () => buildMetadataDisplayRows,
24
+ resolveFacetPresentationProperties: () => resolveFacetPresentationProperties,
25
+ resolveLiteralLabel: () => resolveLiteralLabel,
26
+ resolveObjectRefClassLabel: () => resolveObjectRefClassLabel,
27
+ resolveObjectRefLabel: () => resolveObjectRefLabel,
28
+ resolveOverrideProperties: () => resolveOverrideProperties
29
+ });
30
+ module.exports = __toCommonJS(metadata_display_builder_exports);
31
+
32
+ // src/read-models/metadata-presentation-config.ts
33
+ var INFORMATION_UNIT_PROPERTY_PRESENTATION = {
34
+ id: {
35
+ valueKind: "scalar",
36
+ facet: { supported: false, sectionStrategy: "none" },
37
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
38
+ },
39
+ shortId: {
40
+ valueKind: "scalar",
41
+ facet: { supported: false, sectionStrategy: "none" },
42
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
43
+ },
44
+ score: {
45
+ valueKind: "scalar",
46
+ facet: { supported: false, sectionStrategy: "none" },
47
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
48
+ },
49
+ class: {
50
+ valueKind: "objectRef",
51
+ facet: { supported: false, sectionStrategy: "none" },
52
+ metadataDisplay: { supported: false, sectionStrategy: "class" }
53
+ },
54
+ labels: {
55
+ valueKind: "literalArray",
56
+ facet: { supported: false, sectionStrategy: "none" },
57
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
58
+ },
59
+ comments: {
60
+ valueKind: "literalArray",
61
+ facet: { supported: false, sectionStrategy: "none" },
62
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
63
+ },
64
+ descriptions: {
65
+ valueKind: "literalArray",
66
+ facet: { supported: false, sectionStrategy: "none" },
67
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
68
+ },
69
+ synonyms: {
70
+ valueKind: "stringArray",
71
+ facet: { supported: false, sectionStrategy: "none" },
72
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
73
+ },
74
+ packages: {
75
+ valueKind: "objectRefArray",
76
+ facet: { supported: true, sectionStrategy: "none" },
77
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
78
+ },
79
+ hasInformationUnits: {
80
+ valueKind: "scalar",
81
+ facet: { supported: false, sectionStrategy: "none" },
82
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
83
+ },
84
+ links: {
85
+ valueKind: "resourceLinkArray",
86
+ facet: { supported: false, sectionStrategy: "none" },
87
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
88
+ },
89
+ revision: {
90
+ valueKind: "scalar",
91
+ facet: { supported: false, sectionStrategy: "none" },
92
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
93
+ },
94
+ created: {
95
+ valueKind: "scalar",
96
+ facet: { supported: false, sectionStrategy: "none" },
97
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
98
+ },
99
+ modified: {
100
+ valueKind: "scalar",
101
+ facet: { supported: false, sectionStrategy: "none" },
102
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
103
+ },
104
+ abstract: {
105
+ valueKind: "literalArray",
106
+ facet: { supported: false, sectionStrategy: "none" },
107
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
108
+ },
109
+ replaces: {
110
+ valueKind: "objectRef",
111
+ facet: { supported: false, sectionStrategy: "none" },
112
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
113
+ },
114
+ versionOf: {
115
+ valueKind: "objectRef",
116
+ facet: { supported: false, sectionStrategy: "none" },
117
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
118
+ },
119
+ titles: {
120
+ valueKind: "literalArray",
121
+ facet: { supported: false, sectionStrategy: "none" },
122
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
123
+ },
124
+ languages: {
125
+ valueKind: "stringArray",
126
+ facet: { supported: true, sectionStrategy: "none" },
127
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
128
+ },
129
+ parties: {
130
+ valueKind: "objectRefArray",
131
+ facet: { supported: true, sectionStrategy: "partyRole" },
132
+ metadataDisplay: { supported: true, sectionStrategy: "partyRole" }
133
+ },
134
+ renditions: {
135
+ valueKind: "renditionArray",
136
+ facet: { supported: false, sectionStrategy: "none" },
137
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
138
+ },
139
+ identities: {
140
+ valueKind: "objectRefArray",
141
+ facet: { supported: false, sectionStrategy: "none" },
142
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
143
+ },
144
+ components: {
145
+ valueKind: "objectRefArray",
146
+ facet: { supported: true, sectionStrategy: "class" },
147
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
148
+ },
149
+ informationSubjects: {
150
+ valueKind: "objectRefArray",
151
+ facet: { supported: true, sectionStrategy: "class" },
152
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
153
+ },
154
+ topicTypes: {
155
+ valueKind: "objectRefArray",
156
+ facet: { supported: true, sectionStrategy: "class" },
157
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
158
+ },
159
+ documentTypes: {
160
+ valueKind: "objectRefArray",
161
+ facet: { supported: true, sectionStrategy: "class" },
162
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
163
+ },
164
+ directoryNodes: {
165
+ valueKind: "objectRefArray",
166
+ facet: { supported: false, sectionStrategy: "none" },
167
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
168
+ },
169
+ contentLifeCycleStatus: {
170
+ valueKind: "objectRefArray",
171
+ facet: { supported: true, sectionStrategy: "class" },
172
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
173
+ },
174
+ applicableForTypes: {
175
+ valueKind: "objectRefArray",
176
+ facet: { supported: true, sectionStrategy: "none" },
177
+ metadataDisplay: { supported: true, sectionStrategy: "none" }
178
+ },
179
+ planningTimes: {
180
+ valueKind: "objectRefArray",
181
+ facet: { supported: true, sectionStrategy: "class" },
182
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
183
+ },
184
+ events: {
185
+ valueKind: "objectRefArray",
186
+ facet: { supported: true, sectionStrategy: "class" },
187
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
188
+ },
189
+ functionalMetadata: {
190
+ valueKind: "objectRefArray",
191
+ facet: { supported: true, sectionStrategy: "class" },
192
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
193
+ },
194
+ informationUnits: {
195
+ valueKind: "objectRefArray",
196
+ facet: { supported: false, sectionStrategy: "none" },
197
+ metadataDisplay: { supported: false, sectionStrategy: "none" }
198
+ },
199
+ productFeatures: {
200
+ valueKind: "objectRefArray",
201
+ facet: { supported: true, sectionStrategy: "class" },
202
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
203
+ },
204
+ productLifeCyclePhases: {
205
+ valueKind: "objectRefArray",
206
+ facet: { supported: true, sectionStrategy: "class" },
207
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
208
+ },
209
+ productMetadata: {
210
+ valueKind: "objectRefArray",
211
+ facet: { supported: true, sectionStrategy: "class" },
212
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
213
+ },
214
+ productVariants: {
215
+ valueKind: "objectRefArray",
216
+ facet: { supported: true, sectionStrategy: "class" },
217
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
218
+ },
219
+ qualifications: {
220
+ valueKind: "objectRefArray",
221
+ facet: { supported: true, sectionStrategy: "class" },
222
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
223
+ },
224
+ supplies: {
225
+ valueKind: "objectRefArray",
226
+ facet: { supported: true, sectionStrategy: "class" },
227
+ metadataDisplay: { supported: true, sectionStrategy: "class" }
228
+ }
229
+ };
230
+
231
+ // src/read-models/metadata-visibility-policy.ts
232
+ var CONTENT_LICENSE_CLASS_ID = "https://ids.c-crex.net/ns/iirds/ext#ContentLicense";
233
+ var METADATA_VISIBILITY_POLICY = {
234
+ parties: {
235
+ cacheFamily: "parties"
236
+ },
237
+ components: {
238
+ cacheFamily: "components"
239
+ },
240
+ informationSubjects: {
241
+ cacheFamily: "informationSubjects"
242
+ },
243
+ topicTypes: {
244
+ cacheFamily: "topicTypes"
245
+ },
246
+ documentTypes: {
247
+ cacheFamily: "documentTypes"
248
+ },
249
+ contentLifeCycleStatus: {
250
+ cacheFamily: "contentLifeCycleStatus"
251
+ },
252
+ applicableForTypes: {
253
+ cacheFamily: "documentTypes"
254
+ },
255
+ planningTimes: {
256
+ cacheFamily: "planningTimes"
257
+ },
258
+ functionalMetadata: {
259
+ cacheFamily: "functionalMetadata"
260
+ },
261
+ productFeatures: {
262
+ cacheFamily: "productFeatures"
263
+ },
264
+ productLifeCyclePhases: {
265
+ cacheFamily: "productLifeCyclePhases"
266
+ },
267
+ productMetadata: {
268
+ cacheFamily: "productMetadata"
269
+ },
270
+ productVariants: {
271
+ cacheFamily: "productVariants"
272
+ },
273
+ qualifications: {
274
+ cacheFamily: "qualifications",
275
+ deniedClassIds: [CONTENT_LICENSE_CLASS_ID]
276
+ },
277
+ supplies: {
278
+ cacheFamily: "supplies"
279
+ }
280
+ };
281
+ var runtimeSuppressedFamilies = /* @__PURE__ */ new Map();
282
+ var getMetadataCacheFamily = (property) => METADATA_VISIBILITY_POLICY[property]?.cacheFamily;
283
+ var isMetadataGroupDenied = (property, options) => {
284
+ const policy = METADATA_VISIBILITY_POLICY[property];
285
+ const classId = options.classId?.trim();
286
+ const partyRoleId = options.partyRoleId?.trim();
287
+ if (classId && policy?.deniedClassIds?.includes(classId)) {
288
+ return true;
289
+ }
290
+ if (partyRoleId && policy?.deniedPartyRoleIds?.includes(partyRoleId)) {
291
+ return true;
292
+ }
293
+ return false;
294
+ };
295
+ var isMetadataPropertyRuntimeSuppressed = (property) => {
296
+ const family = getMetadataCacheFamily(property);
297
+ return family ? runtimeSuppressedFamilies.has(family) : false;
298
+ };
299
+
300
+ // src/read-models/metadata-display-builder.ts
301
+ var DEFAULT_IGNORED_FORMATS = [
302
+ "application/xhtml+xml",
303
+ "application/json",
304
+ "application/llm+xml",
305
+ "text/html"
306
+ ];
307
+ var normalizeLanguageCode = (value) => {
308
+ const trimmed = value.trim();
309
+ if (!trimmed) return trimmed;
310
+ const [rawLang, rawCountry, ...rest] = trimmed.split("-");
311
+ const lang = (rawLang || "").toLowerCase();
312
+ if (!rawCountry) return lang;
313
+ const country = rawCountry.toUpperCase();
314
+ const suffix = rest.length > 0 ? `-${rest.join("-")}` : "";
315
+ return `${lang}-${country}${suffix}`;
316
+ };
317
+ var sortAndDeduplicateLanguages = (languages) => {
318
+ const normalized = languages.map((item) => (item || "").trim()).filter((item) => item.length > 0).map((item) => normalizeLanguageCode(item));
319
+ return Array.from(new Set(normalized)).sort((a, b) => a.localeCompare(b));
320
+ };
321
+ var resolvePreferredLanguage = (languages, uiLanguage) => {
322
+ if (!languages || languages.length === 0) return void 0;
323
+ const normalizedUiLanguage = normalizeLanguageCode(uiLanguage);
324
+ const baseLanguage = normalizedUiLanguage.split("-")[0];
325
+ const normalized = sortAndDeduplicateLanguages(languages);
326
+ const exact = normalized.find((item) => item === normalizedUiLanguage);
327
+ if (exact) return exact;
328
+ const base = normalized.find((item) => item === baseLanguage || item.startsWith(`${baseLanguage}-`));
329
+ if (base) return base;
330
+ const english = normalized.find((item) => item === "en" || item === "en-US" || item.startsWith("en-"));
331
+ if (english) return english;
332
+ return normalized[0];
333
+ };
334
+ var getFirstLinkByRel = (item, rel) => item.links?.find((link) => link.rel === rel)?.href;
335
+ var hasRenderableFileRenditions = (renditions) => {
336
+ if (!renditions || renditions.length === 0) return false;
337
+ return renditions.some((item) => {
338
+ if (!item.format || DEFAULT_IGNORED_FORMATS.includes(item.format)) return false;
339
+ return Boolean(getFirstLinkByRel(item, "download") || getFirstLinkByRel(item, "view"));
340
+ });
341
+ };
342
+ var resolveLiteralLabel = (labels, uiLanguage) => {
343
+ if (!labels || labels.length === 0) return void 0;
344
+ const language = uiLanguage || "en";
345
+ const preferred = resolvePreferredLanguage(
346
+ labels.map((item) => item.language || ""),
347
+ language
348
+ );
349
+ if (preferred) {
350
+ const exact = labels.find((item) => item.language === preferred)?.value;
351
+ if (exact) return exact;
352
+ }
353
+ return labels.find((item) => item.value)?.value || void 0;
354
+ };
355
+ var resolveObjectRefLabel = (item, uiLanguage) => {
356
+ return resolveLiteralLabel(item.labels || [], uiLanguage) || item.shortId || item.id || void 0;
357
+ };
358
+ var resolveObjectRefClassLabel = (item, uiLanguage) => {
359
+ return resolveLiteralLabel(item.class?.labels || [], uiLanguage) || item.class?.shortId || item.class?.id || void 0;
360
+ };
361
+ var asObjectRefArray = (value) => {
362
+ if (!Array.isArray(value)) return [];
363
+ return value.filter((item) => Boolean(item && typeof item === "object"));
364
+ };
365
+ var asLiteralArray = (value) => {
366
+ if (!Array.isArray(value)) return [];
367
+ return value.filter((item) => Boolean(item && typeof item === "object"));
368
+ };
369
+ var shouldUseFacetPresentation = (strategy) => {
370
+ return strategy === "class" || strategy === "partyRole";
371
+ };
372
+ var resolveFacetPresentationProperties = (includeProperties) => {
373
+ return includeProperties.filter((key) => {
374
+ const config = INFORMATION_UNIT_PROPERTY_PRESENTATION[key];
375
+ if (!config?.metadataDisplay?.supported) return false;
376
+ if (config.valueKind !== "objectRefArray" && config.valueKind !== "objectRef") return false;
377
+ return shouldUseFacetPresentation(config.metadataDisplay.sectionStrategy);
378
+ });
379
+ };
380
+ var resolveOverrideProperties = resolveFacetPresentationProperties;
381
+ var buildMetadataDisplayRows = (data, options) => {
382
+ const uiLanguage = options.uiLanguage;
383
+ const preferredTitle = resolveLiteralLabel(data.titles || [], uiLanguage) || resolveLiteralLabel(data.labels || [], uiLanguage);
384
+ const rows = [];
385
+ for (const key of options.includeProperties) {
386
+ const config = INFORMATION_UNIT_PROPERTY_PRESENTATION[key];
387
+ if (!config?.metadataDisplay?.supported) continue;
388
+ if (isMetadataPropertyRuntimeSuppressed(key)) continue;
389
+ if (key === "labels") continue;
390
+ if (key === "titles") {
391
+ if (preferredTitle) {
392
+ rows.push({
393
+ key,
394
+ label: key,
395
+ labelSource: "translationKey",
396
+ values: [preferredTitle],
397
+ valueType: "text"
398
+ });
399
+ }
400
+ continue;
401
+ }
402
+ const value = data[key];
403
+ if (value === null || value === void 0) continue;
404
+ if (key === "languages") {
405
+ const languages = sortAndDeduplicateLanguages(value || []);
406
+ if (languages.length > 0) {
407
+ rows.push({
408
+ key,
409
+ label: key,
410
+ labelSource: "translationKey",
411
+ values: languages,
412
+ valueType: "language"
413
+ });
414
+ }
415
+ continue;
416
+ }
417
+ if (config.valueKind === "scalar") {
418
+ rows.push({
419
+ key,
420
+ label: key,
421
+ labelSource: "translationKey",
422
+ values: [String(value)],
423
+ valueType: "text"
424
+ });
425
+ continue;
426
+ }
427
+ if (config.valueKind === "stringArray") {
428
+ const values = Array.from(new Set(value.map((item) => String(item)).filter(Boolean)));
429
+ if (values.length > 0) {
430
+ rows.push({
431
+ key,
432
+ label: key,
433
+ labelSource: "translationKey",
434
+ values,
435
+ valueType: "text"
436
+ });
437
+ }
438
+ continue;
439
+ }
440
+ if (config.valueKind === "literalArray") {
441
+ const preferred = resolveLiteralLabel(asLiteralArray(value), uiLanguage);
442
+ if (preferred) {
443
+ rows.push({
444
+ key,
445
+ label: key,
446
+ labelSource: "translationKey",
447
+ values: [preferred],
448
+ valueType: "text"
449
+ });
450
+ }
451
+ continue;
452
+ }
453
+ if (config.valueKind === "objectRef") {
454
+ const label = resolveObjectRefLabel(value, uiLanguage);
455
+ if (label) {
456
+ rows.push({
457
+ key,
458
+ label: key,
459
+ labelSource: "translationKey",
460
+ values: [label],
461
+ valueType: "text"
462
+ });
463
+ }
464
+ continue;
465
+ }
466
+ if (config.valueKind === "objectRefArray") {
467
+ const refs = asObjectRefArray(value);
468
+ if (refs.length === 0) continue;
469
+ const groupedValues = /* @__PURE__ */ new Map();
470
+ refs.forEach((ref) => {
471
+ const shortId = ref.shortId || "";
472
+ const presentationMap = (options.presentation || options.overrides)?.[key];
473
+ const presentationItem = (shortId ? presentationMap?.[shortId] : void 0) || (ref.id ? presentationMap?.[ref.id] : void 0);
474
+ if (presentationItem?.hidden) return;
475
+ if (isMetadataGroupDenied(key, { classId: ref.class?.id })) return;
476
+ const valueLabel = presentationItem?.label || resolveObjectRefLabel(ref, uiLanguage);
477
+ if (!valueLabel) return;
478
+ const sectionLabel = config.metadataDisplay.sectionStrategy === "none" ? key : presentationItem?.sectionLabel || resolveObjectRefClassLabel(ref, uiLanguage) || key;
479
+ const existing = groupedValues.get(sectionLabel) || /* @__PURE__ */ new Set();
480
+ existing.add(valueLabel);
481
+ groupedValues.set(sectionLabel, existing);
482
+ });
483
+ Array.from(groupedValues.entries()).sort(([left], [right]) => left.localeCompare(right)).forEach(([sectionLabel, valueSet]) => {
484
+ const values = Array.from(valueSet).sort((a, b) => a.localeCompare(b));
485
+ if (values.length === 0) return;
486
+ rows.push({
487
+ key,
488
+ label: sectionLabel,
489
+ labelSource: sectionLabel === key ? "translationKey" : "direct",
490
+ values,
491
+ valueType: "text"
492
+ });
493
+ });
494
+ continue;
495
+ }
496
+ if (config.valueKind === "renditionArray") {
497
+ const renditions = Array.isArray(value) ? value.filter((item) => Boolean(item && typeof item === "object")) : [];
498
+ if (renditions.length === 0) continue;
499
+ if (!hasRenderableFileRenditions(renditions)) continue;
500
+ rows.push({
501
+ key,
502
+ label: "files",
503
+ labelSource: "translationKey",
504
+ values: [],
505
+ valueType: "rendition",
506
+ renditions
507
+ });
508
+ }
509
+ }
510
+ return rows;
511
+ };
512
+ // Annotate the CommonJS export names for ESM import in node:
513
+ 0 && (module.exports = {
514
+ buildMetadataDisplayRows,
515
+ resolveFacetPresentationProperties,
516
+ resolveLiteralLabel,
517
+ resolveObjectRefClassLabel,
518
+ resolveObjectRefLabel,
519
+ resolveOverrideProperties
520
+ });
521
+ //# sourceMappingURL=metadata-display-builder.js.map