@amboras-dev/storefront-core 2026.11.9 → 2026.11.10
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/CHANGELOG.md +65 -0
- package/bin/checks/check-redirect-boundaries.mjs +21 -4
- package/core-manifest.json +26 -1
- package/dist/hooks/use-store-blog.d.ts +53 -0
- package/dist/hooks/use-store-blog.d.ts.map +1 -0
- package/dist/hooks/use-store-blog.js +77 -0
- package/dist/hooks/use-store-blog.js.map +1 -0
- package/dist/hooks/use-store-metaobjects.d.ts +38 -0
- package/dist/hooks/use-store-metaobjects.d.ts.map +1 -0
- package/dist/hooks/use-store-metaobjects.js +61 -0
- package/dist/hooks/use-store-metaobjects.js.map +1 -0
- package/dist/lib/store-blog.d.ts +214 -0
- package/dist/lib/store-blog.d.ts.map +1 -0
- package/dist/lib/store-blog.js +204 -0
- package/dist/lib/store-blog.js.map +1 -0
- package/dist/lib/store-metafields.d.ts +115 -0
- package/dist/lib/store-metafields.d.ts.map +1 -0
- package/dist/lib/store-metafields.js +112 -0
- package/dist/lib/store-metafields.js.map +1 -0
- package/dist/lib/store-metaobjects.d.ts +75 -0
- package/dist/lib/store-metaobjects.d.ts.map +1 -0
- package/dist/lib/store-metaobjects.js +58 -0
- package/dist/lib/store-metaobjects.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-blog.d.ts","sourceRoot":"","sources":["../../src/lib/store-blog.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAA;AAC9C,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAA;AAE9D,yCAAyC;AACzC,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,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AO,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC1F;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3C,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAUnC;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,EAChD,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAmBzC;AA0BD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAiCjJ"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { safeDecode } from './redirects.js';
|
|
2
|
+
import { medusaBackendUrl, storeGetJsonStrict, storeHeaders } from './store-api.js';
|
|
3
|
+
const DEFAULT_REVALIDATE = 60;
|
|
4
|
+
/** The store API failed a blog read (5xx, timeout, no response, a 4xx other than 404/410). `reason` is PII-free (`HTTP 503`, `TimeoutError`). */
|
|
5
|
+
export class StoreBlogUnavailableError extends Error {
|
|
6
|
+
reason;
|
|
7
|
+
constructor(reason) {
|
|
8
|
+
super(`Blog read failed: ${reason}`);
|
|
9
|
+
this.reason = reason;
|
|
10
|
+
this.name = 'StoreBlogUnavailableError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** ok → the body; Medusa's 404/410 → null; anything else throws, so it never becomes a (cached) 404. */
|
|
14
|
+
async function readBlog(path, revalidate) {
|
|
15
|
+
const result = await storeGetJsonStrict(path, { revalidate });
|
|
16
|
+
if (result.kind === 'ok')
|
|
17
|
+
return result.data;
|
|
18
|
+
if (result.kind === 'miss' && (result.status === 404 || result.status === 410))
|
|
19
|
+
return null;
|
|
20
|
+
throw new StoreBlogUnavailableError(result.kind === 'miss' ? `HTTP ${result.status}` : result.reason);
|
|
21
|
+
}
|
|
22
|
+
/** The store API's page cap for a blog's posts. */
|
|
23
|
+
export const MAX_ARTICLES_PAGE = 50;
|
|
24
|
+
/** `/blogs/<blog>` (handles are URL-encoded). */
|
|
25
|
+
export function blogPath(blogHandle) {
|
|
26
|
+
return `/blogs/${encodeURIComponent(blogHandle)}`;
|
|
27
|
+
}
|
|
28
|
+
/** `/blogs/<blog>/<article>` (handles are URL-encoded). */
|
|
29
|
+
export function articlePath(blogHandle, articleHandle) {
|
|
30
|
+
return `${blogPath(blogHandle)}/${encodeURIComponent(articleHandle)}`;
|
|
31
|
+
}
|
|
32
|
+
/** The store's active blogs (empty when there are none, or on a store API without the route). */
|
|
33
|
+
export async function getBlogs(options = {}) {
|
|
34
|
+
const data = await readBlog('/store/content/blogs', options.revalidate ?? DEFAULT_REVALIDATE);
|
|
35
|
+
return { blogs: data?.blogs ?? [], count: data?.count ?? 0 };
|
|
36
|
+
}
|
|
37
|
+
/** A blog and its published, visible-now posts (newest first), or null when there is no such blog. */
|
|
38
|
+
export async function getBlogArticles(blogHandle, params = {}, options = {}) {
|
|
39
|
+
if (!blogHandle)
|
|
40
|
+
return null;
|
|
41
|
+
const query = new URLSearchParams();
|
|
42
|
+
if (params.limit !== undefined)
|
|
43
|
+
query.set('limit', String(params.limit));
|
|
44
|
+
if (params.offset !== undefined)
|
|
45
|
+
query.set('offset', String(params.offset));
|
|
46
|
+
const qs = query.toString();
|
|
47
|
+
const data = await readBlog(`/store/content/blogs/${encodeURIComponent(safeDecode(blogHandle))}/articles${qs ? `?${qs}` : ''}`, options.revalidate ?? DEFAULT_REVALIDATE);
|
|
48
|
+
return data?.blog ? { ...data, articles: data.articles ?? [] } : null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Every published post across every active blog, newest first, each with its
|
|
52
|
+
* blog (for `/blogs/<blog>/<article>` links). Reads at most
|
|
53
|
+
* `perBlog` (default and cap: 50) posts per blog.
|
|
54
|
+
*/
|
|
55
|
+
export async function getAllArticles(options = {}) {
|
|
56
|
+
const perBlog = Math.min(Math.max(options.perBlog ?? MAX_ARTICLES_PAGE, 1), MAX_ARTICLES_PAGE);
|
|
57
|
+
const { blogs } = await getBlogs(options);
|
|
58
|
+
const lists = await Promise.all(blogs.map(async (blog) => {
|
|
59
|
+
const data = await getBlogArticles(blog.handle, { limit: perBlog }, options);
|
|
60
|
+
return (data?.articles ?? []).map((article) => ({ ...article, blog }));
|
|
61
|
+
}));
|
|
62
|
+
return lists.flat().sort((a, b) => new Date(b.published_at ?? 0).getTime() - new Date(a.published_at ?? 0).getTime());
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* One published post by blog + post handle, or null. A moved post comes back
|
|
66
|
+
* under its CURRENT handles: check `articleRedirectPath` before rendering.
|
|
67
|
+
*/
|
|
68
|
+
export async function getArticle(blogHandle, articleHandle, options = {}) {
|
|
69
|
+
if (!blogHandle || !articleHandle)
|
|
70
|
+
return null;
|
|
71
|
+
const data = await readBlog(`/store/content/blogs/${encodeURIComponent(safeDecode(blogHandle))}/articles/${encodeURIComponent(safeDecode(articleHandle))}`, options.revalidate ?? DEFAULT_REVALIDATE);
|
|
72
|
+
return data?.blog && data.article ? data : null;
|
|
73
|
+
}
|
|
74
|
+
const sameHandle = (asked, current) => asked === current || safeDecode(asked) === current;
|
|
75
|
+
/**
|
|
76
|
+
* The path to 308 to when the post was found under other handles than the URL
|
|
77
|
+
* asked for (its handle or blog changed, or the URL's case differs), else
|
|
78
|
+
* null. Route params may arrive encoded or not; both compare equal.
|
|
79
|
+
*
|
|
80
|
+
* const data = await getArticle(params.blog, params.article)
|
|
81
|
+
* if (!data) notFound()
|
|
82
|
+
* const moved = articleRedirectPath(params.blog, params.article, data)
|
|
83
|
+
* if (moved) permanentRedirect(moved)
|
|
84
|
+
*/
|
|
85
|
+
export function articleRedirectPath(blogHandle, articleHandle, data) {
|
|
86
|
+
if (sameHandle(blogHandle, data.blog.handle) && sameHandle(articleHandle, data.article.handle))
|
|
87
|
+
return null;
|
|
88
|
+
return articlePath(data.blog.handle, data.article.handle);
|
|
89
|
+
}
|
|
90
|
+
/** The path to 308 to when the blog was found under another handle than the URL asked for, else null. */
|
|
91
|
+
export function blogRedirectPath(blogHandle, data) {
|
|
92
|
+
return sameHandle(blogHandle, data.blog.handle) ? null : blogPath(data.blog.handle);
|
|
93
|
+
}
|
|
94
|
+
/** The store API's page cap for an article's comments. */
|
|
95
|
+
export const MAX_COMMENTS_PAGE = 50;
|
|
96
|
+
const COMMENT_FIELDS = ['author', 'email', 'body'];
|
|
97
|
+
function commentsPath(blogHandle, articleHandle) {
|
|
98
|
+
return `/store/content/blogs/${encodeURIComponent(safeDecode(blogHandle))}/articles/${encodeURIComponent(safeDecode(articleHandle))}/comments`;
|
|
99
|
+
}
|
|
100
|
+
const isCommentable = (value) => value === 'no' || value === 'moderate' || value === 'yes';
|
|
101
|
+
/**
|
|
102
|
+
* A page of a published post's PUBLISHED comments, NEWEST FIRST as on Shopify (`limit` up to `MAX_COMMENTS_PAGE`,
|
|
103
|
+
* the total in `count`), with the blog's Comments setting (`commentable`), or null when there is no such post (or
|
|
104
|
+
* the store API predates comments). A moved post is found under its old handles, like `getArticle`. With
|
|
105
|
+
* comments disabled (`commentable: 'no'`) the list is empty: render no comments section at all (Shopify's Dawn).
|
|
106
|
+
* Strict like the other reads: a failed read throws `StoreBlogUnavailableError`.
|
|
107
|
+
*/
|
|
108
|
+
export async function getArticleComments(blogHandle, articleHandle, params = {}, options = {}) {
|
|
109
|
+
if (!blogHandle || !articleHandle)
|
|
110
|
+
return null;
|
|
111
|
+
const query = new URLSearchParams();
|
|
112
|
+
if (params.limit !== undefined)
|
|
113
|
+
query.set('limit', String(params.limit));
|
|
114
|
+
if (params.offset !== undefined)
|
|
115
|
+
query.set('offset', String(params.offset));
|
|
116
|
+
const qs = query.toString();
|
|
117
|
+
const data = await readBlog(`${commentsPath(blogHandle, articleHandle)}${qs ? `?${qs}` : ''}`, options.revalidate ?? DEFAULT_REVALIDATE);
|
|
118
|
+
if (!data)
|
|
119
|
+
return null;
|
|
120
|
+
const comments = Array.isArray(data.comments) ? data.comments : [];
|
|
121
|
+
return {
|
|
122
|
+
comments,
|
|
123
|
+
count: typeof data.count === 'number' ? data.count : comments.length,
|
|
124
|
+
limit: typeof data.limit === 'number' ? data.limit : comments.length,
|
|
125
|
+
offset: typeof data.offset === 'number' ? data.offset : 0,
|
|
126
|
+
commentable: isCommentable(data.commentable) ? data.commentable : 'no',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** Field messages from a 400: `{ errors: { email: '…' } }`, `{ errors: [{ field, message }] }`, or the fields named in `message`. */
|
|
130
|
+
function commentFieldErrors(body, message) {
|
|
131
|
+
const errors = {};
|
|
132
|
+
const raw = body.errors ?? body.fields;
|
|
133
|
+
if (Array.isArray(raw)) {
|
|
134
|
+
for (const item of raw) {
|
|
135
|
+
if (!item || typeof item !== 'object')
|
|
136
|
+
continue;
|
|
137
|
+
const { field, path, message: text } = item;
|
|
138
|
+
const name = typeof field === 'string' ? field : Array.isArray(path) ? path[0] : path;
|
|
139
|
+
if (COMMENT_FIELDS.includes(name) && typeof text === 'string')
|
|
140
|
+
errors[name] ??= text;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (raw && typeof raw === 'object') {
|
|
144
|
+
for (const field of COMMENT_FIELDS) {
|
|
145
|
+
const value = raw[field];
|
|
146
|
+
const text = Array.isArray(value) ? value[0] : value;
|
|
147
|
+
if (typeof text === 'string')
|
|
148
|
+
errors[field] = text;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (Object.keys(errors).length === 0) {
|
|
152
|
+
for (const field of COMMENT_FIELDS)
|
|
153
|
+
if (new RegExp(`\\b${field}\\b`, 'i').test(message))
|
|
154
|
+
errors[field] = message;
|
|
155
|
+
}
|
|
156
|
+
return errors;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Post a shopper's comment on a published post (browser or server; uncached). Never throws: every outcome is a
|
|
160
|
+
* `PostArticleCommentResult`. The store API saves a moderated blog's comment as `pending` and an auto-publishing
|
|
161
|
+
* blog's as `published`; a filled `website` honeypot is answered as posted and stored nowhere.
|
|
162
|
+
*/
|
|
163
|
+
export async function postArticleComment(blogHandle, articleHandle, input) {
|
|
164
|
+
if (!blogHandle || !articleHandle)
|
|
165
|
+
return { kind: 'not_found' };
|
|
166
|
+
let res;
|
|
167
|
+
try {
|
|
168
|
+
res = await fetch(`${medusaBackendUrl()}${commentsPath(blogHandle, articleHandle)}`, {
|
|
169
|
+
method: 'POST',
|
|
170
|
+
headers: storeHeaders(),
|
|
171
|
+
body: JSON.stringify({ author: input.author, email: input.email, body: input.body, website: input.website ?? '' }),
|
|
172
|
+
cache: 'no-store',
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
return { kind: 'unavailable', reason: error instanceof Error || error instanceof DOMException ? error.name : 'UnknownError' };
|
|
177
|
+
}
|
|
178
|
+
let body = {};
|
|
179
|
+
try {
|
|
180
|
+
const parsed = await res.json();
|
|
181
|
+
if (parsed && typeof parsed === 'object')
|
|
182
|
+
body = parsed;
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
body = {};
|
|
186
|
+
}
|
|
187
|
+
if (res.ok) {
|
|
188
|
+
const comment = body.comment;
|
|
189
|
+
const status = comment?.status === 'published' ? 'published' : comment?.status === 'pending' ? 'pending' : null;
|
|
190
|
+
return status ? { kind: 'posted', id: typeof comment?.id === 'string' ? comment.id : '', status } : { kind: 'unavailable', reason: `HTTP ${res.status}` };
|
|
191
|
+
}
|
|
192
|
+
if (res.status === 400) {
|
|
193
|
+
const message = typeof body.message === 'string' ? body.message : '';
|
|
194
|
+
return { kind: 'invalid', errors: commentFieldErrors(body, message), message };
|
|
195
|
+
}
|
|
196
|
+
if (res.status === 403 && body.code === 'comments_disabled')
|
|
197
|
+
return { kind: 'comments_disabled' };
|
|
198
|
+
if (res.status === 429)
|
|
199
|
+
return { kind: 'rate_limited' };
|
|
200
|
+
if (res.status === 404 || res.status === 410)
|
|
201
|
+
return { kind: 'not_found' };
|
|
202
|
+
return { kind: 'unavailable', reason: `HTTP ${res.status}` };
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=store-blog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-blog.js","sourceRoot":"","sources":["../../src/lib/store-blog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAuGnF,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAE7B,iJAAiJ;AACjJ,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAC7B;IAArB,YAAqB,MAAc;QACjC,KAAK,CAAC,qBAAqB,MAAM,EAAE,CAAC,CAAA;QADjB,WAAM,GAAN,MAAM,CAAQ;QAEjC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;CACF;AAED,wGAAwG;AACxG,KAAK,UAAU,QAAQ,CAAI,IAAY,EAAE,UAAkB;IACzD,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAI,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;IAChE,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,C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G,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;IAC1E,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,GAAG,CAAC,MAAM,EAAE,EAAE,CAAA;AAC9D,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { StoreMetaobjectEntry } from './store-metaobjects.js';
|
|
2
|
+
/**
|
|
3
|
+
* Product metafields on the storefront (Shopify `product.metafields`).
|
|
4
|
+
*
|
|
5
|
+
* The store API adds them to a product when asked: `?metafields=ns.key,…` on
|
|
6
|
+
* `GET /store/products(/:id)` returns `product.metafields`, an array in the
|
|
7
|
+
* SAME ORDER as the identifiers (`null` where the product has no value, or the
|
|
8
|
+
* definition is not storefront-visible). A metaobject reference comes WITH the
|
|
9
|
+
* entry — its display name and storefront-visible values — so a product's
|
|
10
|
+
* designer shows without a second request:
|
|
11
|
+
*
|
|
12
|
+
* const [designer] = await getProductMetafields(product.id, ['custom.designer'])
|
|
13
|
+
* const entry = metaobjectOf(designer) // { handle, display_name, values: { name, photo } }
|
|
14
|
+
*
|
|
15
|
+
* FAIL-SOFT: any failure resolves to an array of `null`s of the same length.
|
|
16
|
+
*/
|
|
17
|
+
/** A metaobject entry as a reference summary (one level: a reference inside its values is an id). */
|
|
18
|
+
export interface MetaobjectReference extends StoreMetaobjectEntry {
|
|
19
|
+
__typename: 'Metaobject';
|
|
20
|
+
type: string;
|
|
21
|
+
}
|
|
22
|
+
export interface StoreMetafield {
|
|
23
|
+
namespace: string;
|
|
24
|
+
key: string;
|
|
25
|
+
/** The definition's display name, or null. */
|
|
26
|
+
name: string | null;
|
|
27
|
+
/** Definition type; `list.<type>` for lists. */
|
|
28
|
+
type: string;
|
|
29
|
+
/** As Shopify gives it: strings as-is, anything else JSON-stringified (a list is a JSON array string). */
|
|
30
|
+
value: string;
|
|
31
|
+
/** A single reference (product, variant, collection, metaobject, file) resolved to its summary, or null. */
|
|
32
|
+
reference: ({
|
|
33
|
+
__typename: string;
|
|
34
|
+
id?: string;
|
|
35
|
+
} & Record<string, unknown>) | null;
|
|
36
|
+
/** A list reference's resolvable summaries; null for non-list types. */
|
|
37
|
+
references: Array<{
|
|
38
|
+
__typename: string;
|
|
39
|
+
id?: string;
|
|
40
|
+
} & Record<string, unknown>> | null;
|
|
41
|
+
/** rich_text_field only: the rich-text tree in `value`, rendered to escaped HTML. Render this, not `value`. */
|
|
42
|
+
html?: string;
|
|
43
|
+
}
|
|
44
|
+
/** A file a file-reference metafield points at (a Files-library file). */
|
|
45
|
+
export interface StoreFile {
|
|
46
|
+
__typename: 'MediaImage' | 'GenericFile';
|
|
47
|
+
id?: string;
|
|
48
|
+
url: string;
|
|
49
|
+
alt?: string | null;
|
|
50
|
+
mime_type?: string | null;
|
|
51
|
+
width?: number | null;
|
|
52
|
+
height?: number | null;
|
|
53
|
+
size?: number | null;
|
|
54
|
+
}
|
|
55
|
+
/** Shopify's rich-text tree, as a rich-text metafield (and a metaobject's rich-text field) stores it. */
|
|
56
|
+
export type RichTextNode = {
|
|
57
|
+
type: 'root';
|
|
58
|
+
children: RichTextNode[];
|
|
59
|
+
} | {
|
|
60
|
+
type: 'paragraph';
|
|
61
|
+
children: RichTextNode[];
|
|
62
|
+
} | {
|
|
63
|
+
type: 'heading';
|
|
64
|
+
level: number;
|
|
65
|
+
children: RichTextNode[];
|
|
66
|
+
} | {
|
|
67
|
+
type: 'list';
|
|
68
|
+
listType: 'ordered' | 'unordered';
|
|
69
|
+
children: RichTextNode[];
|
|
70
|
+
} | {
|
|
71
|
+
type: 'list-item';
|
|
72
|
+
children: RichTextNode[];
|
|
73
|
+
} | {
|
|
74
|
+
type: 'text';
|
|
75
|
+
value: string;
|
|
76
|
+
bold?: boolean;
|
|
77
|
+
italic?: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'link';
|
|
80
|
+
url: string;
|
|
81
|
+
title?: string;
|
|
82
|
+
target?: string;
|
|
83
|
+
children: RichTextNode[];
|
|
84
|
+
};
|
|
85
|
+
/** The store API reads at most this many identifiers per request (extra ones are ignored). */
|
|
86
|
+
export declare const MAX_METAFIELD_IDENTIFIERS = 50;
|
|
87
|
+
/**
|
|
88
|
+
* One product's metafields by `namespace.key`, in the order asked. Only the
|
|
89
|
+
* product id is fetched with them (`fields=id`), so this is a light call next
|
|
90
|
+
* to the page's own product read.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getProductMetafields(productId: string, identifiers: readonly string[], options?: {
|
|
93
|
+
revalidate?: number;
|
|
94
|
+
}): Promise<Array<StoreMetafield | null>>;
|
|
95
|
+
/** The metafield `namespace.key` from a product's `metafields` array (as the store API returns it), or null. */
|
|
96
|
+
export declare function findMetafield(metafields: ReadonlyArray<StoreMetafield | null> | null | undefined, identifier: string): StoreMetafield | null;
|
|
97
|
+
/** The metaobject entry a single metaobject-reference metafield points at, or null. */
|
|
98
|
+
export declare function metaobjectOf(metafield: StoreMetafield | null | undefined): MetaobjectReference | null;
|
|
99
|
+
/** The metaobject entries a list metaobject-reference metafield points at (unresolvable ones are left out). */
|
|
100
|
+
export declare function metaobjectsOf(metafield: StoreMetafield | null | undefined): MetaobjectReference[];
|
|
101
|
+
/** The file a single file-reference metafield points at (url, alt text, size), or null. */
|
|
102
|
+
export declare function fileOf(metafield: StoreMetafield | null | undefined): StoreFile | null;
|
|
103
|
+
/**
|
|
104
|
+
* HTML of a rich-text tree (a metaobject's rich-text field, or a parsed metafield value): every
|
|
105
|
+
* text escaped, unsafe link schemes dropped — the same rendering the store API's `html` uses.
|
|
106
|
+
*/
|
|
107
|
+
export declare function richTextToHtml(node: RichTextNode | null | undefined): string;
|
|
108
|
+
/**
|
|
109
|
+
* The HTML to render for a rich-text metafield: the store API's `html`, else the tree in `value`.
|
|
110
|
+
* Anything else in `value` (an older store API's HTML, a value that never became a tree, a
|
|
111
|
+
* non-rich-text metafield passed by mistake) is shown as ESCAPED text, never as markup: this is
|
|
112
|
+
* the string a page renders with dangerouslySetInnerHTML.
|
|
113
|
+
*/
|
|
114
|
+
export declare function metafieldHtml(metafield: StoreMetafield | null | undefined): string;
|
|
115
|
+
//# sourceMappingURL=store-metafields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-metafields.d.ts","sourceRoot":"","sources":["../../src/lib/store-metafields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAGlE;;;;;;;;;;;;;;GAcG;AAEH,qGAAqG;AACrG,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,UAAU,EAAE,YAAY,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,8CAA8C;IAC9C,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,0GAA0G;IAC1G,KAAK,EAAE,MAAM,CAAA;IACb,4GAA4G;IAC5G,SAAS,EAAE,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAA;IACjF,wEAAwE;IACxE,UAAU,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAA;IACvF,+GAA+G;IAC/G,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,0EAA0E;AAC1E,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,YAAY,GAAG,aAAa,CAAA;IACxC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,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,EACjB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpC,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC,CAYvC;AAED,gHAAgH;AAChH,wBAAgB,aAAa,CAAC,UAAU,EAAE,aAAa,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAM5I;AAKD,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,mBAAmB,GAAG,IAAI,CAErG;AAED,+GAA+G;AAC/G,wBAAgB,aAAa,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,mBAAmB,EAAE,CAEjG;AAKD,2FAA2F;AAC3F,wBAAgB,MAAM,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAErF;AAOD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAmC5E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAUlF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { storeGetJson } from './store-api.js';
|
|
2
|
+
/** The store API reads at most this many identifiers per request (extra ones are ignored). */
|
|
3
|
+
export const MAX_METAFIELD_IDENTIFIERS = 50;
|
|
4
|
+
const METAFIELD_ID_RE = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
|
|
5
|
+
/**
|
|
6
|
+
* One product's metafields by `namespace.key`, in the order asked. Only the
|
|
7
|
+
* product id is fetched with them (`fields=id`), so this is a light call next
|
|
8
|
+
* to the page's own product read.
|
|
9
|
+
*/
|
|
10
|
+
export async function getProductMetafields(productId, identifiers, options = {}) {
|
|
11
|
+
const wanted = identifiers.slice(0, MAX_METAFIELD_IDENTIFIERS);
|
|
12
|
+
const valid = wanted.filter((id) => METAFIELD_ID_RE.test(id));
|
|
13
|
+
if (!productId || valid.length === 0)
|
|
14
|
+
return wanted.map(() => null);
|
|
15
|
+
const query = new URLSearchParams({ fields: 'id', metafields: valid.join(',') });
|
|
16
|
+
const data = await storeGetJson(`/store/products/${encodeURIComponent(productId)}?${query.toString()}`, options.revalidate ?? 60);
|
|
17
|
+
const byId = new Map();
|
|
18
|
+
valid.forEach((id, i) => byId.set(id, data?.product?.metafields?.[i] ?? null));
|
|
19
|
+
return wanted.map((id) => byId.get(id) ?? null);
|
|
20
|
+
}
|
|
21
|
+
/** The metafield `namespace.key` from a product's `metafields` array (as the store API returns it), or null. */
|
|
22
|
+
export function findMetafield(metafields, identifier) {
|
|
23
|
+
const dot = identifier.indexOf('.');
|
|
24
|
+
if (dot < 1)
|
|
25
|
+
return null;
|
|
26
|
+
const namespace = identifier.slice(0, dot);
|
|
27
|
+
const key = identifier.slice(dot + 1);
|
|
28
|
+
return metafields?.find((m) => m?.namespace === namespace && m.key === key) ?? null;
|
|
29
|
+
}
|
|
30
|
+
const isMetaobject = (value) => !!value && typeof value === 'object' && value.__typename === 'Metaobject';
|
|
31
|
+
/** The metaobject entry a single metaobject-reference metafield points at, or null. */
|
|
32
|
+
export function metaobjectOf(metafield) {
|
|
33
|
+
return isMetaobject(metafield?.reference) ? metafield.reference : null;
|
|
34
|
+
}
|
|
35
|
+
/** The metaobject entries a list metaobject-reference metafield points at (unresolvable ones are left out). */
|
|
36
|
+
export function metaobjectsOf(metafield) {
|
|
37
|
+
return (metafield?.references ?? []).flatMap((ref) => (isMetaobject(ref) ? [ref] : []));
|
|
38
|
+
}
|
|
39
|
+
const isFile = (value) => !!value && typeof value === 'object' && ['MediaImage', 'GenericFile'].includes(String(value.__typename));
|
|
40
|
+
/** The file a single file-reference metafield points at (url, alt text, size), or null. */
|
|
41
|
+
export function fileOf(metafield) {
|
|
42
|
+
return isFile(metafield?.reference) ? metafield.reference : null;
|
|
43
|
+
}
|
|
44
|
+
// `/\host` is NOT a same-site path: browsers read the backslash as a slash, so it is `//host`.
|
|
45
|
+
const SAFE_URL_RE = /^(https?:|mailto:|tel:|\/(?![\/\\])|#)/i;
|
|
46
|
+
const escapeHtml = (text) => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
47
|
+
/**
|
|
48
|
+
* HTML of a rich-text tree (a metaobject's rich-text field, or a parsed metafield value): every
|
|
49
|
+
* text escaped, unsafe link schemes dropped — the same rendering the store API's `html` uses.
|
|
50
|
+
*/
|
|
51
|
+
export function richTextToHtml(node) {
|
|
52
|
+
if (!node || typeof node !== 'object')
|
|
53
|
+
return '';
|
|
54
|
+
const children = (n) => (Array.isArray(n.children) ? n.children.map(richTextToHtml).join('') : '');
|
|
55
|
+
switch (node.type) {
|
|
56
|
+
case 'root':
|
|
57
|
+
return children(node);
|
|
58
|
+
case 'paragraph':
|
|
59
|
+
return `<p>${children(node)}</p>`;
|
|
60
|
+
case 'heading': {
|
|
61
|
+
const level = Math.min(6, Math.max(1, Math.trunc(node.level) || 1));
|
|
62
|
+
return `<h${level}>${children(node)}</h${level}>`;
|
|
63
|
+
}
|
|
64
|
+
case 'list': {
|
|
65
|
+
const tag = node.listType === 'ordered' ? 'ol' : 'ul';
|
|
66
|
+
return `<${tag}>${children(node)}</${tag}>`;
|
|
67
|
+
}
|
|
68
|
+
case 'list-item':
|
|
69
|
+
return `<li>${children(node)}</li>`;
|
|
70
|
+
case 'text': {
|
|
71
|
+
let html = escapeHtml(String(node.value ?? '')).replace(/\n/g, '<br>');
|
|
72
|
+
if (node.italic)
|
|
73
|
+
html = `<em>${html}</em>`;
|
|
74
|
+
if (node.bold)
|
|
75
|
+
html = `<strong>${html}</strong>`;
|
|
76
|
+
return html;
|
|
77
|
+
}
|
|
78
|
+
case 'link': {
|
|
79
|
+
const inner = children(node);
|
|
80
|
+
const url = String(node.url ?? '').trim();
|
|
81
|
+
if (!SAFE_URL_RE.test(url))
|
|
82
|
+
return inner;
|
|
83
|
+
const title = node.title ? ` title="${escapeHtml(node.title)}"` : '';
|
|
84
|
+
const blank = node.target === '_blank' ? ' target="_blank" rel="noopener noreferrer"' : '';
|
|
85
|
+
return `<a href="${escapeHtml(url)}"${title}${blank}>${inner}</a>`;
|
|
86
|
+
}
|
|
87
|
+
default:
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The HTML to render for a rich-text metafield: the store API's `html`, else the tree in `value`.
|
|
93
|
+
* Anything else in `value` (an older store API's HTML, a value that never became a tree, a
|
|
94
|
+
* non-rich-text metafield passed by mistake) is shown as ESCAPED text, never as markup: this is
|
|
95
|
+
* the string a page renders with dangerouslySetInnerHTML.
|
|
96
|
+
*/
|
|
97
|
+
export function metafieldHtml(metafield) {
|
|
98
|
+
if (!metafield)
|
|
99
|
+
return '';
|
|
100
|
+
if (typeof metafield.html === 'string')
|
|
101
|
+
return metafield.html;
|
|
102
|
+
try {
|
|
103
|
+
const tree = JSON.parse(metafield.value);
|
|
104
|
+
if (tree && typeof tree === 'object' && tree.type === 'root')
|
|
105
|
+
return richTextToHtml(tree);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// not a tree: shown as text below
|
|
109
|
+
}
|
|
110
|
+
return escapeHtml(metafield.value ?? '');
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=store-metafields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-metafields.js","sourceRoot":"","sources":["../../src/lib/store-metafields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AA+D7C,8FAA8F;AAC9F,MAAM,CAAC,MAAM,yBAAyB,GAA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E,CAAA;YACpE,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,EAAE,CAAA;YAC1F,OAAO,YAAY,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,MAAM,CAAA;QACpE,CAAC;QACD;YACE,OAAO,EAAE,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,SAA4C;IACxE,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAA;IACzB,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC,IAAI,CAAA;IAC7D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAiB,CAAA;QACxD,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAK,IAA2B,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,cAAc,CAAC,IAAI,CAAC,CAAA;IACnH,CAAC;IAAC,MAAM,CAAC;QACP,kCAAkC;IACpC,CAAC;IACD,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metaobjects on the storefront (Shopify metaobjects): the merchant defines a
|
|
3
|
+
* content type in the admin (a "Designer" with a name, a photo and a bio, a
|
|
4
|
+
* "FAQ", a "Size chart") and fills in entries. Only ACTIVE entries of a
|
|
5
|
+
* definition with storefront access are served, and each entry carries only
|
|
6
|
+
* its storefront-visible fields.
|
|
7
|
+
*
|
|
8
|
+
* Server-side reads of `GET /store/metaobjects/:type`, cached by Next for
|
|
9
|
+
* `revalidate` seconds (the store API caches the route too and drops it on
|
|
10
|
+
* every metaobject change). FAIL-SOFT like every store-api read: a store API
|
|
11
|
+
* that predates the route, an unknown type or a definition without storefront
|
|
12
|
+
* access resolves to `null` / `[]`, never a throw — a page renders exactly as
|
|
13
|
+
* it would without the data.
|
|
14
|
+
*
|
|
15
|
+
* Browser-side: `useMetaobjects` / `useMetaobject` in `client/use-store-metaobjects`.
|
|
16
|
+
* A metaobject a PRODUCT points at comes with the product: `lib/store-metafields`.
|
|
17
|
+
*/
|
|
18
|
+
/** One metaobject entry as the store API serves it. */
|
|
19
|
+
export interface StoreMetaobjectEntry {
|
|
20
|
+
id: string;
|
|
21
|
+
/** Unique within its type, e.g. `stella-mccartney`. */
|
|
22
|
+
handle: string;
|
|
23
|
+
/** The entry's title (the definition's display field), or null. */
|
|
24
|
+
display_name: string | null;
|
|
25
|
+
/** `{ fieldKey: value }` of the storefront-visible fields. A reference inside a value is an id. */
|
|
26
|
+
values: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface StoreMetaobjectList {
|
|
29
|
+
entries: StoreMetaobjectEntry[];
|
|
30
|
+
count: number;
|
|
31
|
+
}
|
|
32
|
+
export interface MetaobjectListOptions {
|
|
33
|
+
limit?: number;
|
|
34
|
+
offset?: number;
|
|
35
|
+
/** Seconds Next may serve the cached response (default 60). */
|
|
36
|
+
revalidate?: number;
|
|
37
|
+
}
|
|
38
|
+
/** Active entries of one metaobject type (e.g. every `designer`). Empty list when the type is not on the storefront. */
|
|
39
|
+
export declare function getMetaobjects(type: string, options?: MetaobjectListOptions): Promise<StoreMetaobjectList>;
|
|
40
|
+
/** One entry by its handle (e.g. `getMetaobject('designer', 'stella-mccartney')`), or null. */
|
|
41
|
+
export declare function getMetaobject(type: string, handle: string, options?: Pick<MetaobjectListOptions, 'revalidate'>): Promise<StoreMetaobjectEntry | null>;
|
|
42
|
+
/** A field value as text (strings as-is, anything else JSON), or null. Handy for rendering. */
|
|
43
|
+
export declare function metaobjectText(entry: StoreMetaobjectEntry | null | undefined, key: string): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* A metaobject entry's web page (content step 6B; Shopify's "Publish entries as
|
|
46
|
+
* web pages"), served at `/pages/<type>/<handle>`: only an active entry of a
|
|
47
|
+
* definition with storefront access and web pages on. `title` comes from the
|
|
48
|
+
* definition's page-title field (else the entry's display name), `description`
|
|
49
|
+
* from its meta-description field; `entry.values` holds its storefront-visible
|
|
50
|
+
* fields (render them with `metaobjectText`, `fileOf`, `richTextToHtml`).
|
|
51
|
+
*
|
|
52
|
+
* Unlike the list reads above this one is STRICT: a missing entry (404/410) is
|
|
53
|
+
* `null`, so the page answers `notFound()`, but a FAILED read (5xx, timeout, no
|
|
54
|
+
* response, any other 4xx) throws `StoreMetaobjectPageUnavailableError` to the
|
|
55
|
+
* error boundary, so an outage never renders or caches a 404 for a live page.
|
|
56
|
+
*/
|
|
57
|
+
export interface StoreMetaobjectPage {
|
|
58
|
+
type: string;
|
|
59
|
+
/** The definition's name, e.g. "Designer". */
|
|
60
|
+
type_name: string;
|
|
61
|
+
handle: string;
|
|
62
|
+
title: string;
|
|
63
|
+
description: string | null;
|
|
64
|
+
entry: StoreMetaobjectEntry;
|
|
65
|
+
}
|
|
66
|
+
/** The store API failed a metaobject web page read. `reason` is PII-free (`HTTP 503`, `TimeoutError`). */
|
|
67
|
+
export declare class StoreMetaobjectPageUnavailableError extends Error {
|
|
68
|
+
readonly reason: string;
|
|
69
|
+
constructor(reason: string);
|
|
70
|
+
}
|
|
71
|
+
/** `/pages/<type>/<handle>` (both URL-encoded). */
|
|
72
|
+
export declare function metaobjectPagePath(type: string, handle: string): string;
|
|
73
|
+
/** One metaobject entry's web page, or null (not published as a page, a draft, missing). An outage throws. */
|
|
74
|
+
export declare function getMetaobjectPage(type: string, handle: string, options?: Pick<MetaobjectListOptions, 'revalidate'>): Promise<StoreMetaobjectPage | null>;
|
|
75
|
+
//# sourceMappingURL=store-metaobjects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-metaobjects.d.ts","sourceRoot":"","sources":["../../src/lib/store-meta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,CAAA;IAC1B,KAAK,EAAE,oBAAoB,CAAA;CAC5B;AAED,0GAA0G;AAC1G,qBAAa,mCAAoC,SAAQ,KAAK;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;CAIpC;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,8GAA8G;AAC9G,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,IAAI,CAAC,qBAAqB,EAAE,YAAY,CAAM,GACtD,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAWrC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { safeDecode } from './redirects.js';
|
|
2
|
+
import { storeGetJson, storeGetJsonStrict } from './store-api.js';
|
|
3
|
+
const DEFAULT_REVALIDATE = 60;
|
|
4
|
+
function entriesPath(type, params) {
|
|
5
|
+
const query = new URLSearchParams();
|
|
6
|
+
for (const [key, value] of Object.entries(params))
|
|
7
|
+
if (value !== undefined && value !== '')
|
|
8
|
+
query.set(key, String(value));
|
|
9
|
+
const qs = query.toString();
|
|
10
|
+
return `/store/metaobjects/${encodeURIComponent(type)}${qs ? `?${qs}` : ''}`;
|
|
11
|
+
}
|
|
12
|
+
/** Active entries of one metaobject type (e.g. every `designer`). Empty list when the type is not on the storefront. */
|
|
13
|
+
export async function getMetaobjects(type, options = {}) {
|
|
14
|
+
const { limit, offset, revalidate = DEFAULT_REVALIDATE } = options;
|
|
15
|
+
const data = await storeGetJson(entriesPath(type, { limit, offset }), revalidate);
|
|
16
|
+
return { entries: data?.entries ?? [], count: data?.count ?? 0 };
|
|
17
|
+
}
|
|
18
|
+
/** One entry by its handle (e.g. `getMetaobject('designer', 'stella-mccartney')`), or null. */
|
|
19
|
+
export async function getMetaobject(type, handle, options = {}) {
|
|
20
|
+
if (!handle)
|
|
21
|
+
return null;
|
|
22
|
+
const data = await storeGetJson(entriesPath(type, { handle }), options.revalidate ?? DEFAULT_REVALIDATE);
|
|
23
|
+
return data?.entries?.find((entry) => entry.handle === handle) ?? null;
|
|
24
|
+
}
|
|
25
|
+
/** A field value as text (strings as-is, anything else JSON), or null. Handy for rendering. */
|
|
26
|
+
export function metaobjectText(entry, key) {
|
|
27
|
+
const value = entry?.values?.[key];
|
|
28
|
+
if (value === undefined || value === null)
|
|
29
|
+
return null;
|
|
30
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
31
|
+
}
|
|
32
|
+
/** The store API failed a metaobject web page read. `reason` is PII-free (`HTTP 503`, `TimeoutError`). */
|
|
33
|
+
export class StoreMetaobjectPageUnavailableError extends Error {
|
|
34
|
+
reason;
|
|
35
|
+
constructor(reason) {
|
|
36
|
+
super(`Metaobject page read failed: ${reason}`);
|
|
37
|
+
this.reason = reason;
|
|
38
|
+
this.name = 'StoreMetaobjectPageUnavailableError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** `/pages/<type>/<handle>` (both URL-encoded). */
|
|
42
|
+
export function metaobjectPagePath(type, handle) {
|
|
43
|
+
return `/pages/${encodeURIComponent(type)}/${encodeURIComponent(handle)}`;
|
|
44
|
+
}
|
|
45
|
+
/** One metaobject entry's web page, or null (not published as a page, a draft, missing). An outage throws. */
|
|
46
|
+
export async function getMetaobjectPage(type, handle, options = {}) {
|
|
47
|
+
if (!type || !handle)
|
|
48
|
+
return null;
|
|
49
|
+
const result = await storeGetJsonStrict(`/store/metaobjects/${encodeURIComponent(safeDecode(type))}/${encodeURIComponent(safeDecode(handle))}`, { revalidate: options.revalidate ?? DEFAULT_REVALIDATE });
|
|
50
|
+
if (result.kind === 'ok')
|
|
51
|
+
return result.data?.page ?? null;
|
|
52
|
+
// Only Medusa's "no such page" is a miss: a 429, 401/403, 400 or a body that is not JSON must
|
|
53
|
+
// never become a (cached) 404 for a live page.
|
|
54
|
+
if (result.kind === 'miss' && (result.status === 404 || result.status === 410))
|
|
55
|
+
return null;
|
|
56
|
+
throw new StoreMetaobjectPageUnavailableError(result.kind === 'miss' ? `HTTP ${result.status}` : result.reason);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=store-metaobjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-metaobjects.js","sourceRoot":"","sources":["../../src/lib/store-metaobjects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AA2CjE,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAE7B,SAAS,WAAW,CAAC,IAAY,EAAE,MAAmD;IACpF,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAA;IACnC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;YAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACzH,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAA;IAC3B,OAAO,sBAAsB,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AAC9E,CAAC;AAED,wHAAwH;AACxH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,UAAiC,EAAE;IACpF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,GAAG,kBAAkB,EAAE,GAAG,OAAO,CAAA;IAClE,MAAM,IAAI,GAAG,MAAM,YAAY,CAAuD,WAAW,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CA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D,OAAO,UAAU,kBAAkB,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAA;AAC3E,CAAC;AAED,8GAA8G;AAC9G,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,MAAc,EACd,UAAqD,EAAE;IAEvD,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACjC,MAAM,MAAM,GAAG,MAAM,kBAAkB,CACrC,sBAAsB,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,kBAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EACtG,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,kBAAkB,EAAE,CACzD,CAAA;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAA;IAC1D,8FAA8F;IAC9F,+CAA+C;IAC/C,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3F,MAAM,IAAI,mCAAmC,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AACjH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amboras-dev/storefront-core",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.10",
|
|
4
4
|
"description": "The platform half of every Amboras storefront: cart, checkout, payments, auth, orders, subscriptions, catalogue data, analytics, consent, plugin slots, edge proxy and the Next config. Stores keep only design; they import this. ESM, React 19, Next 16.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|