@backmatter/core 0.0.47 → 0.0.48
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/src/block.ts +0 -1
- package/src/fields.ts +0 -2
- package/src/model.ts +0 -1
- package/src/node/cli.ts +6 -3
- package/src/node/generate.ts +6 -3
- package/src/query.ts +1 -1
- package/src/validate.ts +1 -1
package/package.json
CHANGED
package/src/block.ts
CHANGED
package/src/fields.ts
CHANGED
package/src/model.ts
CHANGED
package/src/node/cli.ts
CHANGED
|
@@ -277,7 +277,7 @@ export default defineConfig({
|
|
|
277
277
|
function renderCatchAllPage(): string {
|
|
278
278
|
return `// ${CATCH_ALL_DIR}/page.tsx — mounts every model at its route, including / via indexSlug.
|
|
279
279
|
import { cacheLife } from "next/cache";
|
|
280
|
-
import { cacheLifeProfile } from "@backmatter/core";
|
|
280
|
+
import { cacheLifeProfile, type CacheLifeProfile } from "@backmatter/core";
|
|
281
281
|
import { createCatchAll } from "@backmatter/next/routes";
|
|
282
282
|
import { cms } from "${REGISTRY_SPECIFIER}";
|
|
283
283
|
import { components as mdxComponents } from "${REGISTRY_SPECIFIER}/mdx";
|
|
@@ -292,11 +292,14 @@ const route = createCatchAll(cms, { components, blocks: blockLoaders, fallbacks:
|
|
|
292
292
|
|
|
293
293
|
export const generateStaticParams = route.generateStaticParams;
|
|
294
294
|
|
|
295
|
+
// Next types cacheLife against this host's profile names; the config may name any of them.
|
|
296
|
+
const contentCacheLife = cacheLife as (profile: CacheLifeProfile) => void;
|
|
297
|
+
|
|
295
298
|
async function cachedParams<T extends { backmatter?: string[] }>(
|
|
296
299
|
params: Promise<T> | T,
|
|
297
300
|
): Promise<T> {
|
|
298
301
|
"use cache";
|
|
299
|
-
|
|
302
|
+
contentCacheLife(cacheLifeProfile(cms.config));
|
|
300
303
|
return params;
|
|
301
304
|
}
|
|
302
305
|
|
|
@@ -630,5 +633,5 @@ export async function main(argv: string[]): Promise<number> {
|
|
|
630
633
|
}
|
|
631
634
|
|
|
632
635
|
if (import.meta.main) {
|
|
633
|
-
main(process.argv.slice(2)).then((code) => process.exit(code));
|
|
636
|
+
void main(process.argv.slice(2)).then((code) => process.exit(code));
|
|
634
637
|
}
|
package/src/node/generate.ts
CHANGED
|
@@ -105,16 +105,19 @@ function renderCachedCmsClient(typeArgs: string): string[] {
|
|
|
105
105
|
return [
|
|
106
106
|
"const raw = createBackmatter({ ...config, models, sync: false });",
|
|
107
107
|
"",
|
|
108
|
+
"// Next types cacheLife against this host's profile names; the config may name any of them.",
|
|
109
|
+
"const contentCacheLife = cacheLife as (profile: CacheLifeProfile) => void;",
|
|
110
|
+
"",
|
|
108
111
|
"async function cachedGetDoc(type: string, slug: string) {",
|
|
109
112
|
' "use cache";',
|
|
110
|
-
"
|
|
113
|
+
" contentCacheLife(cacheLifeProfile(config));",
|
|
111
114
|
" cacheTag(...contentCacheTags(type, slug));",
|
|
112
115
|
" return raw.getDoc(type, slug);",
|
|
113
116
|
"}",
|
|
114
117
|
"",
|
|
115
118
|
"async function cachedListDocs(filter?: { type?: string }) {",
|
|
116
119
|
' "use cache";',
|
|
117
|
-
"
|
|
120
|
+
" contentCacheLife(cacheLifeProfile(config));",
|
|
118
121
|
" cacheTag(...listCacheTags(filter?.type));",
|
|
119
122
|
" return raw.listDocs(filter);",
|
|
120
123
|
"}",
|
|
@@ -153,7 +156,7 @@ export function renderModelsBarrel(input: {
|
|
|
153
156
|
const typeArgs = blocks.length > 0 ? "<typeof models, Blocks>" : "";
|
|
154
157
|
const lines = [GENERATED_HEADER, `import { createBackmatter } from "${input.sdk}";`];
|
|
155
158
|
if (nextHost) {
|
|
156
|
-
lines.push('import { cacheLifeProfile, contentCacheTags, createQuery, listCacheTags } from "@backmatter/core";');
|
|
159
|
+
lines.push('import { cacheLifeProfile, contentCacheTags, createQuery, listCacheTags, type CacheLifeProfile } from "@backmatter/core";');
|
|
157
160
|
lines.push('import { currentPreviewContent } from "@backmatter/next/preview-content";');
|
|
158
161
|
lines.push('import { cacheLife, cacheTag } from "next/cache";');
|
|
159
162
|
}
|
package/src/query.ts
CHANGED
|
@@ -438,7 +438,7 @@ async function selected(
|
|
|
438
438
|
export function createQuery<
|
|
439
439
|
const Models extends readonly ModelDef[],
|
|
440
440
|
const Blocks extends readonly BlockDef[] = [],
|
|
441
|
-
>(models: Models, loader: DocLoader,
|
|
441
|
+
>(models: Models, loader: DocLoader, _blocks?: Blocks): Query<Models, Blocks> {
|
|
442
442
|
const byType = new Map<string, ModelDef>(models.map((m) => [m.type, m]));
|
|
443
443
|
|
|
444
444
|
function slugForGet(type: string, arg?: string): string {
|
package/src/validate.ts
CHANGED
|
@@ -63,7 +63,7 @@ function isMissingValue(value: unknown, field: FieldSnapshot | undefined): boole
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function issueMessage(
|
|
66
|
-
issue: z.core.$ZodIssue
|
|
66
|
+
issue: z.core.$ZodIssue,
|
|
67
67
|
model: Pick<ModelSnapshot, "fields">,
|
|
68
68
|
data: Frontmatter,
|
|
69
69
|
objects: ObjectSnapshot[],
|