@crombolo/core 0.26.0 → 0.28.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/documents.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/core",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Domain model, entity keys and shared contracts for crombolo. No I/O.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
package/src/documents.ts CHANGED
@@ -127,3 +127,11 @@ export function normaliseValueCulture(
127
127
  ): string | null {
128
128
  return propertyVariesByCulture ? culture : null
129
129
  }
130
+
131
+ /** The file path a media item's `umbracoFile` holds, whether an upload or a cropper value. */
132
+ export function mediaFileOf(media: Pick<DocumentAggregate, 'values'>): string | null {
133
+ const value = media.values.find((v) => v.alias === 'umbracoFile')?.value
134
+ if (typeof value === 'string') return value || null
135
+ const src = (value as { src?: unknown } | null | undefined)?.src
136
+ return typeof src === 'string' && src ? src : null
137
+ }