@c-rex/services 0.1.19 → 0.1.20

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 (35) hide show
  1. package/dist/{client-requests.d.mts → generated/client-requests.d.mts} +11 -7
  2. package/dist/{client-requests.d.ts → generated/client-requests.d.ts} +11 -7
  3. package/dist/{client-requests.js → generated/client-requests.js} +90 -80
  4. package/dist/generated/client-requests.js.map +1 -0
  5. package/dist/{client-requests.mjs → generated/client-requests.mjs} +88 -80
  6. package/dist/generated/client-requests.mjs.map +1 -0
  7. package/dist/{server-requests.d.mts → generated/server-requests.d.mts} +11 -7
  8. package/dist/{server-requests.d.ts → generated/server-requests.d.ts} +11 -7
  9. package/dist/{server-requests.js → generated/server-requests.js} +103 -81
  10. package/dist/generated/server-requests.js.map +1 -0
  11. package/dist/{server-requests.mjs → generated/server-requests.mjs} +101 -81
  12. package/dist/generated/server-requests.mjs.map +1 -0
  13. package/dist/index.d.mts +44 -0
  14. package/dist/index.d.ts +44 -0
  15. package/dist/index.js +3268 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.mjs +2905 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/read-models/index.d.mts +244 -0
  20. package/dist/read-models/index.d.ts +244 -0
  21. package/dist/read-models/index.js +1268 -0
  22. package/dist/read-models/index.js.map +1 -0
  23. package/dist/read-models/index.mjs +1226 -0
  24. package/dist/read-models/index.mjs.map +1 -0
  25. package/dist/vcard/index.d.mts +102 -0
  26. package/dist/vcard/index.d.ts +102 -0
  27. package/dist/vcard/index.js +561 -0
  28. package/dist/vcard/index.js.map +1 -0
  29. package/dist/vcard/index.mjs +522 -0
  30. package/dist/vcard/index.mjs.map +1 -0
  31. package/package.json +69 -49
  32. package/dist/client-requests.js.map +0 -1
  33. package/dist/client-requests.mjs.map +0 -1
  34. package/dist/server-requests.js.map +0 -1
  35. package/dist/server-requests.mjs.map +0 -1
@@ -0,0 +1,522 @@
1
+ // src/vcard/profile-utils.ts
2
+ import { CrexSDK } from "@c-rex/core/sdk";
3
+ import { UI_LANG_KEY } from "@c-rex/constants";
4
+ import { cookies } from "next/headers";
5
+ var DEFAULT_LOGO_SRC = "/img/logo.png";
6
+ var normalizePathLikeImageSource = (value) => {
7
+ if (!value) return void 0;
8
+ const trimmed = value.trim();
9
+ if (!trimmed) return void 0;
10
+ if (trimmed.startsWith("data:") || trimmed.startsWith("http://") || trimmed.startsWith("https://") || trimmed.startsWith("/")) {
11
+ return trimmed;
12
+ }
13
+ return `/${trimmed}`;
14
+ };
15
+ var resolveLogoSource = (images = []) => {
16
+ const sourceFirst = images.map((image) => normalizePathLikeImageSource(image.source)).find((value) => Boolean(value));
17
+ if (!sourceFirst) {
18
+ console.warn("[VCardProfile] No usable VCARD image source found. Ignoring 'value' until IDS provides absolute resource URLs.");
19
+ }
20
+ return sourceFirst;
21
+ };
22
+ var normalizeHref = (value) => {
23
+ if (!value) return void 0;
24
+ const trimmed = value.trim();
25
+ if (!trimmed) return void 0;
26
+ if (trimmed.startsWith("http://") || trimmed.startsWith("https://") || trimmed.startsWith("mailto:") || trimmed.startsWith("tel:")) {
27
+ return trimmed;
28
+ }
29
+ return `https://${trimmed}`;
30
+ };
31
+ var SOCIAL_MEDIA_TYPE_URI = "https://www.c-rex.net/ns/iirds/vcard#SocialMedia";
32
+ var SOCIAL_MEDIA_TYPE_URI_NORMALIZED = SOCIAL_MEDIA_TYPE_URI.toLowerCase();
33
+ var isSocialMediaType = (value) => {
34
+ if (!value) return false;
35
+ const normalized = value.trim().toLowerCase();
36
+ return normalized === SOCIAL_MEDIA_TYPE_URI_NORMALIZED || normalized.endsWith("#socialmedia");
37
+ };
38
+ var isSocialMediaUrlEntry = (url) => {
39
+ const hasTypedMarker = Array.isArray(url.types) && url.types.some((type) => isSocialMediaType(type));
40
+ if (hasTypedMarker) return true;
41
+ const hasClassMarker = Array.isArray(url.classes) && url.classes.some((cls) => isSocialMediaType(cls?.id));
42
+ if (hasClassMarker) return true;
43
+ const hasClassLabelMarker = Array.isArray(url.classes) && url.classes.some(
44
+ (cls) => (cls?.labels || []).some((label) => (label.value || "").trim().toLowerCase() === "social media")
45
+ );
46
+ return hasClassLabelMarker;
47
+ };
48
+ var SOCIAL_PROVIDER_BY_HOST = [
49
+ { hostPattern: /(^|\.)x\.com$/i, label: "X" },
50
+ { hostPattern: /(^|\.)twitter\.com$/i, label: "Twitter" },
51
+ { hostPattern: /(^|\.)facebook\.com$/i, label: "Facebook" },
52
+ { hostPattern: /(^|\.)instagram\.com$/i, label: "Instagram" },
53
+ { hostPattern: /(^|\.)youtube\.com$/i, label: "YouTube" },
54
+ { hostPattern: /(^|\.)youtu\.be$/i, label: "YouTube" },
55
+ { hostPattern: /(^|\.)linkedin\.com$/i, label: "LinkedIn" },
56
+ { hostPattern: /(^|\.)xing\.com$/i, label: "Xing" }
57
+ ];
58
+ var resolveSocialProviderLabel = (href) => {
59
+ try {
60
+ const hostname = new URL(href).hostname.toLowerCase();
61
+ const provider = SOCIAL_PROVIDER_BY_HOST.find((entry) => entry.hostPattern.test(hostname));
62
+ return provider?.label || hostname.replace(/^www\./i, "");
63
+ } catch {
64
+ return "Social";
65
+ }
66
+ };
67
+ var isKnownSocialProviderHref = (href) => {
68
+ try {
69
+ const hostname = new URL(href).hostname.toLowerCase();
70
+ return SOCIAL_PROVIDER_BY_HOST.some((entry) => entry.hostPattern.test(hostname));
71
+ } catch {
72
+ return false;
73
+ }
74
+ };
75
+ var resolveTypedSocialLinks = (urls = []) => {
76
+ const items = urls.filter((url) => {
77
+ if (isSocialMediaUrlEntry(url)) return true;
78
+ const href = normalizeHref(url.value);
79
+ return Boolean(href && isKnownSocialProviderHref(href));
80
+ }).map((url) => normalizeHref(url.value)).filter((value) => Boolean(value));
81
+ const byHref = /* @__PURE__ */ new Map();
82
+ items.forEach((href) => {
83
+ if (byHref.has(href)) return;
84
+ const label = resolveSocialProviderLabel(href);
85
+ byHref.set(href, {
86
+ href,
87
+ label,
88
+ provider: label
89
+ });
90
+ });
91
+ return Array.from(byHref.values());
92
+ };
93
+ var normalizePhone = (value) => {
94
+ if (!value) return void 0;
95
+ return value.replace(/^tel:/i, "").trim() || void 0;
96
+ };
97
+ var isDialablePhone = (value) => {
98
+ if (!value) return false;
99
+ const normalized = value.trim();
100
+ if (!normalized) return false;
101
+ if (!/\d/.test(normalized)) return false;
102
+ return /^[+\d()[\]\-./\s]+$/.test(normalized);
103
+ };
104
+ var normalizePhoneHref = (value) => {
105
+ if (!value) return void 0;
106
+ const normalizedPhone = normalizePhone(value);
107
+ if (!normalizedPhone || !isDialablePhone(normalizedPhone)) return void 0;
108
+ return `tel:${normalizedPhone}`;
109
+ };
110
+ var normalizeEmail = (value) => {
111
+ if (!value) return void 0;
112
+ return value.replace(/^mailto:/i, "").trim() || void 0;
113
+ };
114
+ var normalizeLanguage = (value) => {
115
+ return (value || "").trim().toLowerCase().replace("_", "-");
116
+ };
117
+ var getLiteralLanguage = (literal) => {
118
+ const language = literal.language || literal["xml:lang"] || "";
119
+ return normalizeLanguage(language);
120
+ };
121
+ var getLocalizedLiteral = (labels = [], uiLanguage) => {
122
+ const normalizedUiLanguage = normalizeLanguage(uiLanguage);
123
+ const normalizedUiBaseLanguage = normalizedUiLanguage.split("-")[0];
124
+ const exact = labels.find((item) => getLiteralLanguage(item) === normalizedUiLanguage)?.value?.trim();
125
+ if (exact) return exact;
126
+ const base = labels.find((item) => getLiteralLanguage(item).startsWith(`${normalizedUiBaseLanguage}`))?.value?.trim();
127
+ if (base) return base;
128
+ const fallback = labels.find((item) => (item.value || "").trim().length > 0)?.value?.trim();
129
+ return fallback || void 0;
130
+ };
131
+ var buildTelephoneEntries = (telephones = [], uiLanguage) => {
132
+ return telephones.reduce((entries, telephone) => {
133
+ const normalizedValue = normalizePhone(telephone.value);
134
+ if (!normalizedValue) return entries;
135
+ const classLabels = (telephone.classes || []).map((cls) => getLocalizedLiteral(cls.labels || [], uiLanguage)).filter((value) => Boolean(value));
136
+ const dedupedClassLabels = Array.from(
137
+ new Map(classLabels.map((value) => [value.toLowerCase(), value])).values()
138
+ );
139
+ entries.push({
140
+ label: dedupedClassLabels.length > 0 ? dedupedClassLabels.join(" ") : "",
141
+ value: normalizedValue,
142
+ href: normalizePhoneHref(telephone.value)
143
+ });
144
+ return entries;
145
+ }, []);
146
+ };
147
+ var resolveUiLanguage = () => {
148
+ const sdk = new CrexSDK();
149
+ const clientConfig = sdk.getClientConfig();
150
+ const defaultLanguage = normalizeLanguage(clientConfig.languageSwitcher.default || "en-us");
151
+ const uiLanguageFromCookie = cookies().get(UI_LANG_KEY)?.value;
152
+ return normalizeLanguage(uiLanguageFromCookie) || defaultLanguage;
153
+ };
154
+ var buildAddressLines = (address) => {
155
+ if (!address) return [];
156
+ const line1 = [address.streetAddress].filter(Boolean).join(" ").trim();
157
+ const line2 = [address.postalCode, address.locality].filter(Boolean).join(" ").trim();
158
+ const line3 = [address.countryName].filter(Boolean).join(" ").trim();
159
+ return [line1, line2, line3].filter((line) => line.length > 0);
160
+ };
161
+ var mapVCardEntityToBaseProfile = (entity, options) => {
162
+ const preferredAddress = entity.addresses?.[0];
163
+ const preferredEmail = entity.emails?.[0];
164
+ const preferredWebsite = entity.urls?.find((item) => normalizeHref(item.value));
165
+ const logoSrc = resolveLogoSource([...entity.logos || [], ...entity.photos || []]) || (options.logoFallbackSrc || DEFAULT_LOGO_SRC);
166
+ return {
167
+ id: entity.id || void 0,
168
+ displayName: entity.organizationName?.trim() || entity.fullName?.trim() || options.displayNameFallback,
169
+ logoSrc,
170
+ addressLines: buildAddressLines(preferredAddress),
171
+ email: normalizeEmail(preferredEmail?.value),
172
+ telephoneEntries: buildTelephoneEntries(entity.telephones || [], options.uiLanguage),
173
+ website: normalizeHref(preferredWebsite?.value)
174
+ };
175
+ };
176
+ var decodeEncodedVcardId = (encodedId) => {
177
+ try {
178
+ return decodeURIComponent(encodedId);
179
+ } catch (error) {
180
+ console.error(`[VCardProfile] Invalid encoded VCARD ID value: "${encodedId}".`, error);
181
+ return void 0;
182
+ }
183
+ };
184
+ var getServerConfig = () => {
185
+ const sdk = new CrexSDK();
186
+ return sdk.getServerConfig();
187
+ };
188
+
189
+ // src/vcard/organization-profile.ts
190
+ import {
191
+ CREX_API_CACHE_TAG,
192
+ CREX_API_CACHE_VCARD_TAG,
193
+ CREX_READMODEL_CACHE_ORGANIZATION_TAG,
194
+ CREX_READMODEL_CACHE_TAG,
195
+ CREX_READMODEL_CACHE_VCARD_TAG
196
+ } from "@c-rex/core/requests";
197
+ import { unstable_cache } from "next/cache";
198
+
199
+ // src/base-server-request.ts
200
+ import { CrexApi } from "@c-rex/core/requests";
201
+
202
+ // src/server-request-context.ts
203
+ import { AsyncLocalStorage } from "async_hooks";
204
+ var requestContextStorage = new AsyncLocalStorage();
205
+ var withServerRequestContext = async (context, run) => {
206
+ return requestContextStorage.run(context, run);
207
+ };
208
+ var getServerRequestContext = () => {
209
+ return requestContextStorage.getStore();
210
+ };
211
+
212
+ // src/base-server-request.ts
213
+ var baseServerRequest = async (endpoint, query) => {
214
+ const api = new CrexApi();
215
+ const requestContext = getServerRequestContext();
216
+ const response = await api.execute({
217
+ url: endpoint,
218
+ method: "GET",
219
+ params: query,
220
+ skipCookieTokenLookup: requestContext?.skipCookieTokenLookup,
221
+ authToken: requestContext?.authToken
222
+ });
223
+ return response;
224
+ };
225
+
226
+ // src/generated/server-requests.ts
227
+ var individualsGetAllServer = async (query) => {
228
+ return baseServerRequest("vcard/v1/Individuals", query);
229
+ };
230
+ var individualsGetByIdServer = async (params, query) => {
231
+ return baseServerRequest(`vcard/v1/Individuals/${encodeURIComponent(String(params.id))}`, query);
232
+ };
233
+ var organizationsGetAllServer = async (query) => {
234
+ return baseServerRequest("vcard/v1/Organizations", query);
235
+ };
236
+ var organizationsGetByIdServer = async (params, query) => {
237
+ return baseServerRequest(`vcard/v1/Organizations/${encodeURIComponent(String(params.id))}`, query);
238
+ };
239
+ var vCardsGetAllServer = async (query) => {
240
+ return baseServerRequest("vcard/v1/VCards", query);
241
+ };
242
+ var vCardsGetByIdServer = async (params, query) => {
243
+ return baseServerRequest(`vcard/v1/VCards/${encodeURIComponent(String(params.id))}`, query);
244
+ };
245
+
246
+ // src/read-models/cache-policy.ts
247
+ var readPositiveInt = (rawValue, fallback) => {
248
+ const parsed = Number(rawValue);
249
+ if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
250
+ return Math.floor(parsed);
251
+ };
252
+ var READMODEL_CACHE_POLICY = {
253
+ metadataRevalidateSeconds: readPositiveInt(
254
+ process.env.CREX_CACHE_REVALIDATE_METADATA_SECONDS,
255
+ 2 * 60 * 60
256
+ ),
257
+ vcardRevalidateSeconds: readPositiveInt(
258
+ process.env.CREX_CACHE_REVALIDATE_VCARD_SECONDS,
259
+ 6 * 60 * 60
260
+ ),
261
+ requestsRevalidateSeconds: readPositiveInt(
262
+ process.env.CREX_CACHE_REVALIDATE_REQUESTS_SECONDS,
263
+ 15 * 60
264
+ )
265
+ };
266
+
267
+ // src/vcard/organization-profile.ts
268
+ var toOrganizationProfile = (organization, options) => {
269
+ const base = mapVCardEntityToBaseProfile(organization, {
270
+ uiLanguage: options.uiLanguage,
271
+ displayNameFallback: options.displayNameFallback,
272
+ logoFallbackSrc: options.logoFallbackSrc
273
+ });
274
+ return {
275
+ ...base,
276
+ organizationName: base.displayName,
277
+ socialLinks: resolveTypedSocialLinks(organization.urls || []).map((item) => ({
278
+ label: item.label,
279
+ href: item.href
280
+ }))
281
+ };
282
+ };
283
+ var ORGANIZATION_PROFILE_REQUIRED_FIELDS = [
284
+ "organizationName",
285
+ "fullName",
286
+ "logos",
287
+ "photos",
288
+ "emails",
289
+ "telephones",
290
+ "addresses",
291
+ "urls"
292
+ ];
293
+ var resolveOrganizationProfileQuery = (query) => {
294
+ if (!query) return void 0;
295
+ if (!Array.isArray(query.Fields) || query.Fields.length === 0) return query;
296
+ const mergedFields = Array.from(/* @__PURE__ */ new Set([...query.Fields, ...ORGANIZATION_PROFILE_REQUIRED_FIELDS]));
297
+ return {
298
+ ...query,
299
+ Fields: mergedFields
300
+ };
301
+ };
302
+ var fetchOrganizationProfileById = async (id, query, context) => {
303
+ try {
304
+ const organization = await organizationsGetByIdServer({ id }, resolveOrganizationProfileQuery(query));
305
+ return toOrganizationProfile(organization, {
306
+ uiLanguage: context.uiLanguage,
307
+ displayNameFallback: context.fallbackName,
308
+ logoFallbackSrc: context.logoFallbackSrc
309
+ });
310
+ } catch (error) {
311
+ console.error(`[OrganizationProfile] Failed to load VCARD organization "${id}".`, error);
312
+ return {
313
+ id,
314
+ logoSrc: context.logoFallbackSrc,
315
+ displayName: context.fallbackName,
316
+ organizationName: context.fallbackName,
317
+ addressLines: [],
318
+ telephoneEntries: [],
319
+ socialLinks: []
320
+ };
321
+ }
322
+ };
323
+ var getOrganizationProfileById = async (id, query) => {
324
+ const serverConfig = getServerConfig();
325
+ const uiLanguage = resolveUiLanguage();
326
+ const fallbackName = serverConfig.projectName;
327
+ const logoFallbackSrc = serverConfig.organization?.logoFallbackSrc || DEFAULT_LOGO_SRC;
328
+ return fetchOrganizationProfileById(id, query, {
329
+ uiLanguage,
330
+ fallbackName,
331
+ logoFallbackSrc
332
+ });
333
+ };
334
+ var getOrganizationProfileByIdCached = unstable_cache(
335
+ async (id, query, context) => withServerRequestContext(
336
+ { skipCookieTokenLookup: true },
337
+ () => fetchOrganizationProfileById(id, query, context)
338
+ ),
339
+ ["read-model", "organization-profile-v2"],
340
+ {
341
+ revalidate: READMODEL_CACHE_POLICY.vcardRevalidateSeconds,
342
+ tags: [
343
+ CREX_API_CACHE_TAG,
344
+ CREX_API_CACHE_VCARD_TAG,
345
+ CREX_READMODEL_CACHE_TAG,
346
+ CREX_READMODEL_CACHE_VCARD_TAG,
347
+ CREX_READMODEL_CACHE_ORGANIZATION_TAG
348
+ ]
349
+ }
350
+ );
351
+ var getOrganizationsProfiles = async (query) => {
352
+ const serverConfig = getServerConfig();
353
+ const uiLanguage = resolveUiLanguage();
354
+ const fallbackName = serverConfig.projectName;
355
+ const logoFallbackSrc = serverConfig.organization?.logoFallbackSrc || DEFAULT_LOGO_SRC;
356
+ const result = await organizationsGetAllServer(query);
357
+ return result.items.map(
358
+ (organization) => toOrganizationProfile(organization, {
359
+ uiLanguage,
360
+ displayNameFallback: fallbackName,
361
+ logoFallbackSrc
362
+ })
363
+ );
364
+ };
365
+ var getOrganizationProfile = async () => {
366
+ const serverConfig = getServerConfig();
367
+ const rawVcardId = process.env.CREX_ORGANIZATION_VCARD_ID?.trim();
368
+ const encodedVcardId = process.env.CREX_ORGANIZATION_VCARD_ID_ENCODED?.trim();
369
+ const decodedEncodedVcardId = encodedVcardId ? decodeEncodedVcardId(encodedVcardId) : void 0;
370
+ const configuredVcardId = rawVcardId || decodedEncodedVcardId || serverConfig.organization?.vcardId?.trim();
371
+ if (!configuredVcardId) {
372
+ console.info("[OrganizationProfile] No VCARD organization ID configured. Using fallback branding.");
373
+ const logoFallbackSrc2 = serverConfig.organization?.logoFallbackSrc || DEFAULT_LOGO_SRC;
374
+ const fallbackName2 = serverConfig.projectName;
375
+ return {
376
+ logoSrc: logoFallbackSrc2,
377
+ displayName: fallbackName2,
378
+ organizationName: fallbackName2,
379
+ addressLines: [],
380
+ telephoneEntries: [],
381
+ socialLinks: []
382
+ };
383
+ }
384
+ if (rawVcardId && rawVcardId.startsWith("http") && !rawVcardId.includes("#")) {
385
+ console.warn(
386
+ `[OrganizationProfile] VCARD ID does not contain "#": "${rawVcardId}". If this value comes from .env, wrap it in quotes or use CREX_ORGANIZATION_VCARD_ID_ENCODED.`
387
+ );
388
+ }
389
+ const uiLanguage = resolveUiLanguage();
390
+ const fallbackName = serverConfig.projectName;
391
+ const logoFallbackSrc = serverConfig.organization?.logoFallbackSrc || DEFAULT_LOGO_SRC;
392
+ const context = {
393
+ uiLanguage,
394
+ fallbackName,
395
+ logoFallbackSrc
396
+ };
397
+ if (process.env.NODE_ENV === "test") {
398
+ return fetchOrganizationProfileById(configuredVcardId, void 0, context);
399
+ }
400
+ return getOrganizationProfileByIdCached(configuredVcardId, void 0, context);
401
+ };
402
+ var getOrganizationBranding = async () => {
403
+ const profile = await getOrganizationProfile();
404
+ return {
405
+ logoSrc: profile.logoSrc,
406
+ organizationName: profile.organizationName
407
+ };
408
+ };
409
+
410
+ // src/vcard/individual-profile.ts
411
+ var toIndividualProfile = (individual, options) => {
412
+ const base = mapVCardEntityToBaseProfile(individual, {
413
+ uiLanguage: options.uiLanguage,
414
+ displayNameFallback: options.displayNameFallback,
415
+ logoFallbackSrc: options.logoFallbackSrc
416
+ });
417
+ return {
418
+ ...base,
419
+ fullName: base.displayName,
420
+ title: individual.title?.trim() || void 0,
421
+ role: individual.role?.trim() || void 0
422
+ };
423
+ };
424
+ var getIndividualProfileById = async (id, query) => {
425
+ const uiLanguage = resolveUiLanguage();
426
+ try {
427
+ const individual = await individualsGetByIdServer({ id }, query);
428
+ return toIndividualProfile(individual, {
429
+ uiLanguage,
430
+ displayNameFallback: id,
431
+ logoFallbackSrc: DEFAULT_LOGO_SRC
432
+ });
433
+ } catch (error) {
434
+ console.error(`[IndividualProfile] Failed to load VCARD individual "${id}".`, error);
435
+ return {
436
+ id,
437
+ logoSrc: DEFAULT_LOGO_SRC,
438
+ displayName: id,
439
+ fullName: id,
440
+ addressLines: [],
441
+ telephoneEntries: []
442
+ };
443
+ }
444
+ };
445
+ var getIndividualsProfiles = async (query) => {
446
+ const uiLanguage = resolveUiLanguage();
447
+ const result = await individualsGetAllServer(query);
448
+ return result.items.map(
449
+ (individual) => toIndividualProfile(individual, {
450
+ uiLanguage,
451
+ displayNameFallback: individual.id || "Unknown individual",
452
+ logoFallbackSrc: DEFAULT_LOGO_SRC
453
+ })
454
+ );
455
+ };
456
+
457
+ // src/vcard/vcard-profile.ts
458
+ var toVCardProfile = (vcard, options) => {
459
+ const base = mapVCardEntityToBaseProfile(vcard, {
460
+ uiLanguage: options.uiLanguage,
461
+ displayNameFallback: options.displayNameFallback,
462
+ logoFallbackSrc: options.logoFallbackSrc
463
+ });
464
+ return {
465
+ ...base,
466
+ fullName: base.displayName
467
+ };
468
+ };
469
+ var getVCardProfileById = async (id, query) => {
470
+ const uiLanguage = resolveUiLanguage();
471
+ try {
472
+ const vcard = await vCardsGetByIdServer({ id }, query);
473
+ return toVCardProfile(vcard, {
474
+ uiLanguage,
475
+ displayNameFallback: id,
476
+ logoFallbackSrc: DEFAULT_LOGO_SRC
477
+ });
478
+ } catch (error) {
479
+ console.error(`[VCardProfile] Failed to load VCARD "${id}".`, error);
480
+ return {
481
+ id,
482
+ logoSrc: DEFAULT_LOGO_SRC,
483
+ displayName: id,
484
+ fullName: id,
485
+ addressLines: [],
486
+ telephoneEntries: []
487
+ };
488
+ }
489
+ };
490
+ var getVCardProfiles = async (query) => {
491
+ const uiLanguage = resolveUiLanguage();
492
+ const result = await vCardsGetAllServer(query);
493
+ return result.items.map(
494
+ (vcard) => toVCardProfile(vcard, {
495
+ uiLanguage,
496
+ displayNameFallback: vcard.id || "Unknown vCard",
497
+ logoFallbackSrc: DEFAULT_LOGO_SRC
498
+ })
499
+ );
500
+ };
501
+ export {
502
+ DEFAULT_LOGO_SRC,
503
+ buildTelephoneEntries,
504
+ decodeEncodedVcardId,
505
+ getIndividualProfileById,
506
+ getIndividualsProfiles,
507
+ getOrganizationBranding,
508
+ getOrganizationProfile,
509
+ getOrganizationProfileById,
510
+ getOrganizationsProfiles,
511
+ getServerConfig,
512
+ getVCardProfileById,
513
+ getVCardProfiles,
514
+ mapVCardEntityToBaseProfile,
515
+ normalizeEmail,
516
+ normalizeHref,
517
+ resolveLogoSource,
518
+ resolveSocialProviderLabel,
519
+ resolveTypedSocialLinks,
520
+ resolveUiLanguage
521
+ };
522
+ //# sourceMappingURL=index.mjs.map