@the-smithy/hearth 0.22.0 → 0.24.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.
- package/dist/{chunk-RZNKY7HG.js → chunk-GTKPZN53.js} +10 -0
- package/dist/{client-BXkB1aKA.d.ts → client-E1ie4g_L.d.ts} +11 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/next.d.ts +5 -1
- package/dist/next.js +5 -1
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +6 -0
- package/package.json +2 -2
|
@@ -297,6 +297,16 @@ function createCore(options) {
|
|
|
297
297
|
/** Check a preview token from a Hearth preview link. Throws (unauthorized) if it's expired or for another site. */
|
|
298
298
|
verify: (token, o = {}) => request("/preview", { ...o, preview: token, resource: "preview.verify" })
|
|
299
299
|
},
|
|
300
|
+
globalBlocks: {
|
|
301
|
+
/**
|
|
302
|
+
* Every published global block on the site (Global blocks in Hearth), resolved, with what it is and where editors
|
|
303
|
+
* placed it: pop-ups (`popup` set), menu dropdowns (`usedOn.menuItems`), pages. Place any of them anywhere.
|
|
304
|
+
* Empty from Hearth versions without them.
|
|
305
|
+
*/
|
|
306
|
+
list: async (o = {}) => await maybe("/global-blocks", { ...o, resource: "globalBlocks.list" }) ?? [],
|
|
307
|
+
/** One global block by its key ("contact") or id, or null if there's none or it isn't published. */
|
|
308
|
+
get: (ref, o = {}) => maybe(`/global-blocks/${encodeURIComponent(ref)}`, { ...o, resource: "globalBlocks.get" })
|
|
309
|
+
},
|
|
300
310
|
customBlocks: {
|
|
301
311
|
/** The site's own block types (Custom blocks in Hearth): each one's key, name and fields, for rendering `custom` blocks. */
|
|
302
312
|
list: (o = {}) => request("/custom-blocks", { ...o, resource: "customBlocks.list" })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Collection, CollectionEntry, HearthEvent, Site, PageSummary, Page, HearthEventDetail, RegistrationInput, RegistrationResult, VolunteerInput, VolunteerResult, CategoryGroup, SitemapEntry, Redirect, AnalyticsReport, Fundraiser, FundraiserDetail, DonationInput, DonationCheckout, HearthForm } from '@the-smithy/hearth-schema';
|
|
1
|
+
import { Collection, CollectionEntry, HearthEvent, Site, PageSummary, Page, HearthEventDetail, RegistrationInput, RegistrationResult, VolunteerInput, VolunteerResult, CategoryGroup, SitemapEntry, Redirect, AnalyticsReport, Fundraiser, FundraiserDetail, DonationInput, DonationCheckout, GlobalBlock, HearthForm } from '@the-smithy/hearth-schema';
|
|
2
2
|
|
|
3
3
|
type HearthErrorCode = "unauthorized" | "not_found" | "bad_request" | "feature_disabled" | "rate_limited" | "server_error" | "network" | "timeout" | "invalid_response";
|
|
4
4
|
/** Any failure talking to Hearth. Messages never contain the API key. */
|
|
@@ -227,6 +227,16 @@ declare function createCore(options: HearthClientOptions): {
|
|
|
227
227
|
/** Check a preview token from a Hearth preview link. Throws (unauthorized) if it's expired or for another site. */
|
|
228
228
|
verify: (token: string, o?: Omit<CallOptions, "preview">) => Promise<PreviewSession>;
|
|
229
229
|
};
|
|
230
|
+
globalBlocks: {
|
|
231
|
+
/**
|
|
232
|
+
* Every published global block on the site (Global blocks in Hearth), resolved, with what it is and where editors
|
|
233
|
+
* placed it: pop-ups (`popup` set), menu dropdowns (`usedOn.menuItems`), pages. Place any of them anywhere.
|
|
234
|
+
* Empty from Hearth versions without them.
|
|
235
|
+
*/
|
|
236
|
+
list: (o?: CallOptions) => Promise<GlobalBlock[]>;
|
|
237
|
+
/** One global block by its key ("contact") or id, or null if there's none or it isn't published. */
|
|
238
|
+
get: (ref: string, o?: CallOptions) => Promise<GlobalBlock | null>;
|
|
239
|
+
};
|
|
230
240
|
customBlocks: {
|
|
231
241
|
/** The site's own block types (Custom blocks in Hearth): each one's key, name and fields, for rendering `custom` blocks. */
|
|
232
242
|
list: (o?: CallOptions) => Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as HearthCore, a as HearthClientOptions } from './client-
|
|
2
|
-
export { C as CallOptions, b as CollectionPage, D as DEFAULT_BASE_URL, E as EventCollectionPage, F as FormResult, c as FormValues, d as HearthError, e as HearthErrorCode, f as HearthHooks, N as NextFetchOptions, P as PreviewSession, R as RequestContext, g as RequestOptions, h as findRedirect, i as isHearthError, n as normalizeSlug } from './client-
|
|
3
|
-
export { AnalyticsReport, AnalyticsRow, Block, BlockOf, CategoryGroup, CategoryRef, Collection, CollectionEntry, CollectionRef, DonationCheckout, DonationInput, EntryDetails, EventCustomFields, EventRegistration, EventTicket, EventVolunteerShift, EventVolunteering, Fundraiser, FundraiserDetail, HearthEvent, HearthEventDetail, ImageRef, KnownBlock, Page, PageMeta, PageSummary, Position, Redirect, RegistrationInput, RegistrationResult, ResolvedBlock, Site, SiteAnalytics, SiteSettings, SitemapEntry, UnknownBlock, VolunteerInput, VolunteerResult, WebhookPayload, directionsUrl, focalPosition, pinned, videoEmbedUrl } from '@the-smithy/hearth-schema';
|
|
1
|
+
import { H as HearthCore, a as HearthClientOptions } from './client-E1ie4g_L.js';
|
|
2
|
+
export { C as CallOptions, b as CollectionPage, D as DEFAULT_BASE_URL, E as EventCollectionPage, F as FormResult, c as FormValues, d as HearthError, e as HearthErrorCode, f as HearthHooks, N as NextFetchOptions, P as PreviewSession, R as RequestContext, g as RequestOptions, h as findRedirect, i as isHearthError, n as normalizeSlug } from './client-E1ie4g_L.js';
|
|
3
|
+
export { AnalyticsReport, AnalyticsRow, Block, BlockOf, CategoryGroup, CategoryRef, Collection, CollectionEntry, CollectionRef, DonationCheckout, DonationInput, EntryDetails, EventCustomFields, EventRegistration, EventTicket, EventVolunteerShift, EventVolunteering, Fundraiser, FundraiserDetail, GlobalBlock, GlobalPopup, HearthEvent, HearthEventDetail, ImageRef, KnownBlock, Page, PageMeta, PageSummary, Position, Redirect, RegistrationInput, RegistrationResult, ResolvedBlock, SharedFrom, Site, SiteAnalytics, SiteSettings, SitemapEntry, UnknownBlock, VolunteerInput, VolunteerResult, WebhookPayload, directionsUrl, focalPosition, pinned, videoEmbedUrl } from '@the-smithy/hearth-schema';
|
|
4
4
|
|
|
5
5
|
/** A plugin adds resources (and can use the core's `request`) under its own names. */
|
|
6
6
|
type HearthPlugin<T extends object = object> = {
|
package/dist/index.js
CHANGED
package/dist/next.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HearthCore, b as CollectionPage, E as EventCollectionPage, F as FormResult, c as FormValues } from './client-
|
|
1
|
+
import { H as HearthCore, b as CollectionPage, E as EventCollectionPage, F as FormResult, c as FormValues } from './client-E1ie4g_L.js';
|
|
2
2
|
import * as _the_smithy_hearth_schema from '@the-smithy/hearth-schema';
|
|
3
3
|
import { Site, PageMeta } from '@the-smithy/hearth-schema';
|
|
4
4
|
import { Metadata, MetadataRoute } from 'next';
|
|
@@ -170,6 +170,10 @@ declare function createHearthNext(client: HearthCore, { tag, revalidate }?: Hear
|
|
|
170
170
|
optional?: boolean | undefined;
|
|
171
171
|
})[];
|
|
172
172
|
}[]>;
|
|
173
|
+
/** Every global block (to place anywhere, and for pop-ups and menu dropdowns); drafts while previewing. */
|
|
174
|
+
getGlobalBlocks: () => Promise<_the_smithy_hearth_schema.GlobalBlock[]>;
|
|
175
|
+
/** One global block by key or id, or null; its draft while previewing. */
|
|
176
|
+
getGlobalBlock: (ref: string) => Promise<_the_smithy_hearth_schema.GlobalBlock | null>;
|
|
173
177
|
getCollections: () => Promise<_the_smithy_hearth_schema.Collection[]>;
|
|
174
178
|
getCollection: (slug: string, opts?: {
|
|
175
179
|
limit?: number;
|
package/dist/next.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
findRedirect,
|
|
3
3
|
isHearthError,
|
|
4
4
|
normalizeSlug
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GTKPZN53.js";
|
|
6
6
|
import {
|
|
7
7
|
parseWebhook,
|
|
8
8
|
tagsForWebhook
|
|
@@ -60,6 +60,10 @@ function createHearthNext(client, { tag = "hearth", revalidate = 3600 } = {}) {
|
|
|
60
60
|
getEvents: (opts) => client.events.list(opts, tags(`${tag}:events`)),
|
|
61
61
|
getCategories: () => client.categories.list(tags(`${tag}:site`)),
|
|
62
62
|
getCustomBlocks: () => client.customBlocks.list(tags(`${tag}:site`)),
|
|
63
|
+
/** Every global block (to place anywhere, and for pop-ups and menu dropdowns); drafts while previewing. */
|
|
64
|
+
getGlobalBlocks: async () => client.globalBlocks.list(await read(`${tag}:global`)),
|
|
65
|
+
/** One global block by key or id, or null; its draft while previewing. */
|
|
66
|
+
getGlobalBlock: async (ref) => client.globalBlocks.get(ref, await read(`${tag}:global`)),
|
|
63
67
|
getCollections: () => client.collections.list(tags(`${tag}:site`, `${tag}:pages`)),
|
|
64
68
|
getCollection: (slug, opts) => client.collections.get(slug, opts, tags(`${tag}:pages`, `${tag}:events`)),
|
|
65
69
|
getEvent: async (slug) => client.events.get(slug, await read(`${tag}:events`)),
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Site, Page, HearthEvent, HearthEventDetail, SitemapEntry, Redirect, Collection, CollectionEntry, CategoryGroup, Fundraiser, FundraiserDetail, HearthForm } from '@the-smithy/hearth-schema';
|
|
1
|
+
import { Site, Page, HearthEvent, HearthEventDetail, SitemapEntry, Redirect, GlobalBlock, Collection, CollectionEntry, CategoryGroup, Fundraiser, FundraiserDetail, HearthForm } from '@the-smithy/hearth-schema';
|
|
2
2
|
|
|
3
3
|
type MockHearthData = {
|
|
4
4
|
site?: Partial<Site>;
|
|
@@ -8,6 +8,8 @@ type MockHearthData = {
|
|
|
8
8
|
/** The site's llms.txt; null (the default) is a site without one. */
|
|
9
9
|
llmsTxt?: string | null;
|
|
10
10
|
redirects?: Redirect[];
|
|
11
|
+
/** The site's global blocks (pop-ups, menu dropdowns). */
|
|
12
|
+
globalBlocks?: GlobalBlock[];
|
|
11
13
|
/** Collections, with their entries (page collections) keyed by collection slug. */
|
|
12
14
|
collections?: Collection[];
|
|
13
15
|
entries?: Record<string, CollectionEntry[]>;
|
package/dist/testing.js
CHANGED
|
@@ -48,6 +48,12 @@ function createMockHearth(data = {}) {
|
|
|
48
48
|
if (rest === "/sitemap") return json({ data: data.sitemap ?? [] });
|
|
49
49
|
if (rest === "/llms") return json({ data: data.llmsTxt ?? null });
|
|
50
50
|
if (rest === "/redirects") return json({ data: data.redirects ?? [] });
|
|
51
|
+
if (rest === "/global-blocks") return json({ data: data.globalBlocks ?? [] });
|
|
52
|
+
if (rest.startsWith("/global-blocks/")) {
|
|
53
|
+
const ref = decodeURIComponent(rest.slice(15));
|
|
54
|
+
const block = (data.globalBlocks ?? []).find((g) => g.key === ref || g.id === ref);
|
|
55
|
+
return block ? json({ data: block }) : notFound();
|
|
56
|
+
}
|
|
51
57
|
if (rest === "/fundraisers" || rest.startsWith("/fundraisers?")) {
|
|
52
58
|
const status = url.searchParams.get("status") ?? "active";
|
|
53
59
|
return json({ data: (data.fundraisers ?? []).filter((f) => status === "all" || f.status === status) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@the-smithy/hearth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Typed client for the Hearth Delivery API: content, SEO, forms and publish webhooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"llms.md"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@the-smithy/hearth-schema": "^0.
|
|
52
|
+
"@the-smithy/hearth-schema": "^0.24.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"next": ">=15",
|