@revenexx/cover 0.2.27 → 0.2.28
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/package.json +1 -1
- package/server/utils/liveCatalog.ts +20 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.28",
|
|
4
4
|
"description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -73,22 +73,37 @@ export interface LiveSearchParams {
|
|
|
73
73
|
* A live catalogue image value, resolved to a src the client can load as-is.
|
|
74
74
|
*
|
|
75
75
|
* The `image` common attribute is either an absolute URL (the PIM's own media
|
|
76
|
-
* CDN) or a
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* CDN) or a storage key. The key is served through the platform's `/cdn/` path
|
|
77
|
+
* — the edge CDN in production, the theme's `/cdn/` proxy route in dev and in
|
|
78
|
+
* the editor canvas.
|
|
79
|
+
*
|
|
80
|
+
* THE KEY MAY ALREADY CARRY THE TENANT FOLDER, and it must not end up in the
|
|
81
|
+
* url twice. The DAM stores `delivery_path` as `<tenant>/<file>` and hands that
|
|
82
|
+
* through to the attribute, while the edge resolves the tenant from the request
|
|
83
|
+
* host and therefore expects the key WITHOUT it — one build serves every
|
|
84
|
+
* customer domain. Prefixing blindly produced `/cdn/acme/photo.jpg`, which
|
|
85
|
+
* 404s, and on a tile that surfaced as the icon fallback: images "gone" on a
|
|
86
|
+
* catalogue whose files were all there.
|
|
87
|
+
*
|
|
88
|
+
* Only a leading segment equal to this tenant is dropped, so a file that
|
|
89
|
+
* happens to live in a same-named subfolder deeper in the key is left alone.
|
|
79
90
|
*
|
|
80
91
|
* Normalising HERE is what keeps the client rule unambiguous: a bare storage
|
|
81
92
|
* key and a bundled demo filename look identical, and only the server knows
|
|
82
93
|
* which mode produced the value.
|
|
83
94
|
*
|
|
84
95
|
* Exported because manufacturer logos (ApiBrandService) are the same kind of
|
|
85
|
-
* value read from a different attribute.
|
|
96
|
+
* value read from a different attribute — and hit the same double prefix.
|
|
86
97
|
*/
|
|
87
98
|
export function liveImageSrc(raw: string): string {
|
|
88
99
|
if (/^https?:\/\//.test(raw) || raw.startsWith("/")) {
|
|
89
100
|
return raw;
|
|
90
101
|
}
|
|
91
|
-
|
|
102
|
+
const tenant = revenexxTenantKey();
|
|
103
|
+
const key = tenant && raw.startsWith(`${tenant}/`)
|
|
104
|
+
? raw.slice(tenant.length + 1)
|
|
105
|
+
: raw;
|
|
106
|
+
return `/cdn/${key}`;
|
|
92
107
|
}
|
|
93
108
|
|
|
94
109
|
/** Fallback attribute code holding a manufacturer's logo on the product doc. */
|