@backmatter/core 0.0.12 → 0.0.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/core",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Experimental Backmatter SDK. APIs will break. Not ready for production.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -22,6 +22,11 @@ export type CreateBackmatterOptions<Models extends readonly ModelDef[] = readonl
22
22
  * `@backmatter/next` turns this on.
23
23
  */
24
24
  taggedApiFetch?: boolean;
25
+ /**
26
+ * When false, skip the boot-time schema PUT. Query clients (catch-all,
27
+ * revalidate) set this; `.backmatter/sync` leaves the default.
28
+ */
29
+ sync?: boolean;
25
30
  };
26
31
 
27
32
  export type BackmatterClient<Models extends readonly ModelDef[] = readonly ModelDef[]> = {
@@ -59,7 +64,7 @@ function toSnapshots(models: readonly ModelDef[]): ModelSnapshot[] {
59
64
  export function createBackmatter<const Models extends readonly ModelDef[]>(
60
65
  options: CreateBackmatterOptions<Models>,
61
66
  ): BackmatterClient<Models> {
62
- const { models: modelDefs, blocks: blockDefs, taggedApiFetch, ...rest } = options;
67
+ const { models: modelDefs, blocks: blockDefs, taggedApiFetch, sync = true, ...rest } = options;
63
68
  const config = resolveConfig(rest);
64
69
  const models = toSnapshots(modelDefs);
65
70
  const siteRoot = config.siteRoot ?? process.cwd();
@@ -73,7 +78,7 @@ export function createBackmatter<const Models extends readonly ModelDef[]>(
73
78
  }
74
79
 
75
80
  // backmatter CLI imports the config to read models; never sync from there.
76
- if (apiUrl && hostToken && workspaceId) {
81
+ if (sync && apiUrl && hostToken && workspaceId) {
77
82
  if (process.env.BACKMATTER_CLI === "1") {
78
83
  console.warn("backmatter: schema sync skipped (BACKMATTER_CLI=1)");
79
84
  } else {
@@ -95,7 +95,7 @@ export function detectSdk(root: string): string {
95
95
 
96
96
  function renderCachedCmsClient(): string[] {
97
97
  return [
98
- "const raw = createBackmatter({ ...config, models });",
98
+ "const raw = createBackmatter({ ...config, models, sync: false });",
99
99
  "",
100
100
  "async function getDoc(locale: string, type: string, slug: string) {",
101
101
  ' "use cache";',
@@ -180,7 +180,7 @@ export function renderSyncBarrel(input: {
180
180
  lines.push(`export const blocks = [${input.blocks.map((b) => b.name).join(", ")}] as const;`);
181
181
  lines.push("");
182
182
  lines.push("/** Typed content client: cms.query.{type}, cms.getDoc, cms.listDocs. */");
183
- lines.push("export const cms = createBackmatter({ ...config, models, blocks });");
183
+ lines.push("export const cms = createBackmatter({ ...config, models, blocks, sync: true });");
184
184
  return `${lines.join("\n")}\n`;
185
185
  }
186
186