@teincfood/core 0.9.10 → 0.9.11
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.
|
@@ -49,6 +49,21 @@ export interface MenuItemEnvelopeInput extends MenuItemRecordInput {
|
|
|
49
49
|
/** Extra wire-only keys (e.g. entity id). */
|
|
50
50
|
wireExtra?: Record<string, unknown>;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Image value for a menu-item UPDATE wire payload. The server is the source
|
|
54
|
+
* of truth for the stored key — never re-send a loaded URL and risk
|
|
55
|
+
* overwriting the key with a URL-shaped value. Returns `undefined` when the
|
|
56
|
+
* caller must OMIT `image_url` (server keeps its key untouched):
|
|
57
|
+
* - fresh upload → the bare S3 key;
|
|
58
|
+
* - user removed the photo (had one, now empty) → explicit null (clear it);
|
|
59
|
+
* - loaded an un-storable scheme (tfimg:/blob:/file: poison) → null (heal);
|
|
60
|
+
* - otherwise (loaded URL or bare key, no new upload) → omit (preserve).
|
|
61
|
+
*/
|
|
62
|
+
export declare function imageUrlForUpdateWire(opts: {
|
|
63
|
+
freshKey?: string | null;
|
|
64
|
+
loadedUrl?: string | null;
|
|
65
|
+
hadImage: boolean;
|
|
66
|
+
}): string | null | undefined;
|
|
52
67
|
/**
|
|
53
68
|
* Build the { wire, cacheRecord } pair for a menu item write. Callers pass
|
|
54
69
|
* absolute variant prices (backend model) — the form layer owns the field.
|
|
@@ -122,6 +122,26 @@ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
|
|
122
122
|
function wireId(id) {
|
|
123
123
|
return id && UUID_RE.test(id) ? id : undefined;
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Image value for a menu-item UPDATE wire payload. The server is the source
|
|
127
|
+
* of truth for the stored key — never re-send a loaded URL and risk
|
|
128
|
+
* overwriting the key with a URL-shaped value. Returns `undefined` when the
|
|
129
|
+
* caller must OMIT `image_url` (server keeps its key untouched):
|
|
130
|
+
* - fresh upload → the bare S3 key;
|
|
131
|
+
* - user removed the photo (had one, now empty) → explicit null (clear it);
|
|
132
|
+
* - loaded an un-storable scheme (tfimg:/blob:/file: poison) → null (heal);
|
|
133
|
+
* - otherwise (loaded URL or bare key, no new upload) → omit (preserve).
|
|
134
|
+
*/
|
|
135
|
+
export function imageUrlForUpdateWire(opts) {
|
|
136
|
+
if (opts.freshKey)
|
|
137
|
+
return opts.freshKey;
|
|
138
|
+
const loaded = opts.loadedUrl ?? null;
|
|
139
|
+
if (!loaded)
|
|
140
|
+
return opts.hadImage ? null : undefined;
|
|
141
|
+
if (toStorableImageUrl(loaded) === null)
|
|
142
|
+
return null;
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
125
145
|
/**
|
|
126
146
|
* Build the { wire, cacheRecord } pair for a menu item write. Callers pass
|
|
127
147
|
* absolute variant prices (backend model) — the form layer owns the field.
|
package/package.json
CHANGED