@bagelink/blox 1.18.10 → 1.18.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.
package/dist/index.cjs CHANGED
@@ -465,6 +465,7 @@ function withLocaleRoutes(path, component, supportedLocales, defaultLocale = "en
465
465
  const MANIFEST_VERSION = 1;
466
466
  function definitionToEntry(type, def) {
467
467
  const { schema } = def;
468
+ const dataSources = schema.dataSource === true || schema.dataSource === false || !schema.dataSource ? void 0 : Array.isArray(schema.dataSource) ? schema.dataSource : [schema.dataSource];
468
469
  let propsSchema = null;
469
470
  const fields = schema.fields;
470
471
  if (fields && typeof fields.toJSONSchema === "function") {
@@ -483,6 +484,7 @@ function definitionToEntry(type, def) {
483
484
  icon: schema.icon,
484
485
  description: schema.description,
485
486
  dataSource: !!schema.dataSource,
487
+ dataSources,
486
488
  category: schema.category,
487
489
  order: schema.order,
488
490
  global: schema.global,
package/dist/index.mjs CHANGED
@@ -466,6 +466,7 @@ function withLocaleRoutes(path, component, supportedLocales, defaultLocale = "en
466
466
  const MANIFEST_VERSION = 1;
467
467
  function definitionToEntry(type, def) {
468
468
  const { schema } = def;
469
+ const dataSources = schema.dataSource === true || schema.dataSource === false || !schema.dataSource ? void 0 : Array.isArray(schema.dataSource) ? schema.dataSource : [schema.dataSource];
469
470
  let propsSchema = null;
470
471
  const fields = schema.fields;
471
472
  if (fields && typeof fields.toJSONSchema === "function") {
@@ -484,6 +485,7 @@ function definitionToEntry(type, def) {
484
485
  icon: schema.icon,
485
486
  description: schema.description,
486
487
  dataSource: !!schema.dataSource,
488
+ dataSources,
487
489
  category: schema.category,
488
490
  order: schema.order,
489
491
  global: schema.global,
@@ -1,5 +1,6 @@
1
1
  import { BloxInstance } from './core';
2
2
  import { BlockDefinition } from './schema';
3
+ import { BlockDataSource } from './defineBlock';
3
4
  /**
4
5
  * Backend-friendly description of a single registered block.
5
6
  *
@@ -19,6 +20,8 @@ export interface BlockManifestEntry {
19
20
  description?: string;
20
21
  /** True when the block fetches its own data from a datastore collection. */
21
22
  dataSource?: boolean;
23
+ /** Declared datastore dependencies (used by build-time collection discovery). */
24
+ dataSources?: BlockDataSource[];
22
25
  /** Group key for the editor block picker. */
23
26
  category?: string;
24
27
  /** Sort order in the editor block picker (lower first). */
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IAClC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAA;IACb,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC3C,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,YAAY;IAC5B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAA;IACf,6DAA6D;IAC7D,MAAM,EAAE,kBAAkB,EAAE,CAAA;CAC5B;AAoCD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACvC,YAA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C,YAAY,CAKd;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAElE"}
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
- import { f as fetchCmsSiteData, g as generateSitemapArtifacts, d as validateNoRedirectingLinks, i as isErrorPagePath } from "./validate-output-vq09gBSr.js";
5
+ import { f as fetchCmsSiteData, g as generateSitemapArtifacts, d as validateNoRedirectingLinks, i as isErrorPagePath } from "./validate-output-UVCDNeUA.js";
6
6
  const AUTO_SHARD_CAP = Number(process.env.BLOX_SSG_SHARD_CAP) || 6;
7
7
  const PREFETCH_BUDGET = Number(process.env.BLOX_SSG_PREFETCH_BUDGET) || 24;
8
8
  const SEQUENTIAL_SHARDS = process.env.BLOX_SSG_SEQUENTIAL === "1";
@@ -145,7 +145,7 @@ async function runSharded(opts) {
145
145
  }
146
146
  if (process.env.BLOX_SSG_LLM !== "0" && !((_a = website == null ? void 0 : website.seo) == null ? void 0 : _a.noindex)) {
147
147
  try {
148
- const { mergeLlmParts } = await import("./validate-output-vq09gBSr.js").then((n) => n.E);
148
+ const { mergeLlmParts } = await import("./validate-output-UVCDNeUA.js").then((n) => n.E);
149
149
  const mergeWebsite = website;
150
150
  const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
151
151
  const { pages } = await mergeLlmParts({
@@ -26,7 +26,7 @@ const node_child_process = require("node:child_process");
26
26
  const os = require("node:os");
27
27
  const path = require("node:path");
28
28
  const process = require("node:process");
29
- const llmArtifacts = require("./validate-output-lWCssQLz.cjs");
29
+ const llmArtifacts = require("./validate-output-K-8pYmLz.cjs");
30
30
  const AUTO_SHARD_CAP = Number(process.env.BLOX_SSG_SHARD_CAP) || 6;
31
31
  const PREFETCH_BUDGET = Number(process.env.BLOX_SSG_PREFETCH_BUDGET) || 24;
32
32
  const SEQUENTIAL_SHARDS = process.env.BLOX_SSG_SEQUENTIAL === "1";
@@ -169,7 +169,7 @@ async function runSharded(opts) {
169
169
  }
170
170
  if (process.env.BLOX_SSG_LLM !== "0" && !((_a = website == null ? void 0 : website.seo) == null ? void 0 : _a.noindex)) {
171
171
  try {
172
- const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-lWCssQLz.cjs")).then((n) => n.llmArtifacts);
172
+ const { mergeLlmParts } = await Promise.resolve().then(() => require("./validate-output-K-8pYmLz.cjs")).then((n) => n.llmArtifacts);
173
173
  const mergeWebsite = website;
174
174
  const partFiles = Array.from({ length: total }, (_, i) => path.join(llmPartsDir, `part.${i}.json`));
175
175
  const { pages } = await mergeLlmParts({
package/dist/ssg/cli.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  const process = require("node:process");
4
4
  const fs = require("node:fs/promises");
5
5
  const ssg_buildGrant = require("./build-grant.cjs");
6
- const llmArtifacts = require("../validate-output-lWCssQLz.cjs");
6
+ const llmArtifacts = require("../validate-output-K-8pYmLz.cjs");
7
7
  const localeStrategy = require("../localeStrategy-OwRIn35C.cjs");
8
8
  function installFetchTimeout() {
9
9
  const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
@@ -145,10 +145,19 @@ Environment:
145
145
  process.env.BLOX_BUILD_TOKEN = buildGrant.grant;
146
146
  }
147
147
  const buildRequest = buildGrant ? { websiteId: buildGrant.websiteId, token: buildGrant.grant } : {};
148
+ if (buildGrant) {
149
+ const { apiBase: apiBase2 } = await resolveApiBase(mode);
150
+ const manifestPath = "dist/.blox-manifest.json";
151
+ const manifestExists = await fs.stat(manifestPath).then(() => true, () => false);
152
+ if (manifestExists) {
153
+ await llmArtifacts.uploadBloxManifest(apiBase2, buildGrant.websiteId, buildRequest);
154
+ console.log("Uploaded .blox-manifest.json before route discovery");
155
+ }
156
+ }
148
157
  if (shardsOpt !== null || routesCmd) {
149
158
  const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
150
159
  const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
151
- const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-vKgYfLjY.cjs"));
160
+ const { runSharded } = await Promise.resolve().then(() => require("../shard-runner-nITsCO5r.cjs"));
152
161
  const code = await runSharded({
153
162
  shards: shardsOpt ?? "auto",
154
163
  mode,
package/dist/ssg/cli.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import process from "node:process";
3
3
  import fs from "node:fs/promises";
4
4
  import { resolveBloxBuildGrant } from "./build-grant.mjs";
5
- import { v as validateSsgOutput, u as uploadBloxManifest, p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, b as buildCollectionResolver, a as prerender, c as validateInternalLinks, d as validateNoRedirectingLinks } from "../validate-output-vq09gBSr.js";
5
+ import { v as validateSsgOutput, u as uploadBloxManifest, p as polyfillBloxSsgGlobals, f as fetchCmsSiteData, b as buildCollectionResolver, a as prerender, c as validateInternalLinks, d as validateNoRedirectingLinks } from "../validate-output-UVCDNeUA.js";
6
6
  import { s as setPageSlugMap } from "../localeStrategy-hXlNof1E.js";
7
7
  function installFetchTimeout() {
8
8
  const ms = Number(process.env.BLOX_SSG_FETCH_TIMEOUT_MS) || 2e4;
@@ -144,10 +144,19 @@ Environment:
144
144
  process.env.BLOX_BUILD_TOKEN = buildGrant.grant;
145
145
  }
146
146
  const buildRequest = buildGrant ? { websiteId: buildGrant.websiteId, token: buildGrant.grant } : {};
147
+ if (buildGrant) {
148
+ const { apiBase: apiBase2 } = await resolveApiBase(mode);
149
+ const manifestPath = "dist/.blox-manifest.json";
150
+ const manifestExists = await fs.stat(manifestPath).then(() => true, () => false);
151
+ if (manifestExists) {
152
+ await uploadBloxManifest(apiBase2, buildGrant.websiteId, buildRequest);
153
+ console.log("Uploaded .blox-manifest.json before route discovery");
154
+ }
155
+ }
147
156
  if (shardsOpt !== null || routesCmd) {
148
157
  const { apiBase: apiBase2, websiteName: configWebsiteName2 } = await resolveApiBase(mode);
149
158
  const websiteName2 = process.env.WEBSITE_NAME ?? configWebsiteName2 ?? "default";
150
- const { runSharded } = await import("../shard-runner-CMBTsNS8.js");
159
+ const { runSharded } = await import("../shard-runner-DPI12yYi.js");
151
160
  const code = await runSharded({
152
161
  shards: shardsOpt ?? "auto",
153
162
  mode,
@@ -20,7 +20,7 @@ export interface CmsSiteData {
20
20
  */
21
21
  pageSlugMap: Record<string, Record<string, string>>;
22
22
  redirects: RedirectEntry[];
23
- /** Datastore collections referenced by any page's data_bindings. */
23
+ /** Datastore collections referenced by page bindings or used block manifests. */
24
24
  collections: CollectionRef[];
25
25
  /**
26
26
  * Full datastore items per collection, bulk-loaded during route expansion.
@@ -51,9 +51,9 @@ export type CollectionResolver = (collection: string, options: {
51
51
  * detail pages resolve from memory during SSR instead of one network round-trip
52
52
  * per page. Supports the SCIM `q` subset the renderer emits: `field eq "value"`.
53
53
  *
54
- * Returns `null` for collections that were NOT bulk-loaded during route expansion
55
- * (i.e. not referenced by any dynamic template), so the caller can fall back to a
56
- * live HTTP fetch instead of silently returning an empty list.
54
+ * Returns `null` for collections that were NOT bulk-loaded from page bindings
55
+ * or block manifest dependencies, so the caller can fall back to a live HTTP
56
+ * fetch instead of silently returning an empty list.
57
57
  */
58
58
  export declare function buildCollectionResolver(collectionItems: Record<string, Record<string, unknown>[]>): CollectionResolver;
59
59
  //# sourceMappingURL=cms-routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cms-routes.d.ts","sourceRoot":"","sources":["../../src/ssg/cms-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAoB9D,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU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,GAAG,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KACrE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACtC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,GACxD,kBAAkB,CAapB"}
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const llmArtifacts = require("../validate-output-lWCssQLz.cjs");
25
+ const llmArtifacts = require("../validate-output-K-8pYmLz.cjs");
26
26
  const ssg_buildGrant = require("./build-grant.cjs");
27
27
  const ssg_client = require("../client-AoDTJJXJ.cjs");
28
28
  const vue = require("vue");
@@ -1,5 +1,5 @@
1
- import { e as buildPageHead, h as primaryContextEntry, j as buildJsonLd, k as extractPageText, B as BloxBuildResponseError, l as bloxBuildJson } from "../validate-output-vq09gBSr.js";
2
- import { m, n, f, o, q, r, s, g, t, w, x, y, z, A, p, a, C, D, u, c, v } from "../validate-output-vq09gBSr.js";
1
+ import { e as buildPageHead, h as primaryContextEntry, j as buildJsonLd, k as extractPageText, B as BloxBuildResponseError, l as bloxBuildJson } from "../validate-output-UVCDNeUA.js";
2
+ import { m, n, f, o, q, r, s, g, t, w, x, y, z, A, p, a, C, D, u, c, v } from "../validate-output-UVCDNeUA.js";
3
3
  import { parseBloxBuildGrantBody, resolveBloxBuildGrant } from "./build-grant.mjs";
4
4
  import { a as BLOX_HYDRATION_WINDOW_KEY } from "../client-Ce9fRCGH.js";
5
5
  import { createSSRApp, h, Suspense } from "vue";
@@ -144,6 +144,15 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
144
144
  paths: localePaths.map((path2) => localizePath(path2, locale, defaultLocale2))
145
145
  };
146
146
  }));
147
+ const manifestCollections = baseBundle.collections ?? [];
148
+ await preloadCollections(
149
+ apiBase,
150
+ websiteId,
151
+ manifestCollections,
152
+ defaultLocale2,
153
+ requestOptions,
154
+ collectionItems
155
+ );
147
156
  const paths2 = [...new Set(localizedBundles.flatMap((result) => result.paths))];
148
157
  const pathSet2 = new Set(paths2);
149
158
  const defaultPages2 = ((_c = localizedBundles.find((result) => result.locale === defaultLocale2)) == null ? void 0 : _c.bundle.pages) ?? [];
@@ -175,7 +184,10 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
175
184
  pageSlugs: [...new Set(localizedBundles.flatMap((result) => result.bundle.pages.flatMap((page) => page.slug ? [localizePath(page.slug, result.locale, defaultLocale2)] : [])))],
176
185
  pageSlugMap: buildPageSlugMap(localizedBundles, defaultLocale2),
177
186
  redirects: redirects2,
178
- collections: extractCollectionRefs(localizedBundles.flatMap((result) => result.bundle.pages)),
187
+ collections: mergeCollectionRefs(
188
+ extractCollectionRefs(localizedBundles.flatMap((result) => result.bundle.pages)),
189
+ manifestCollections
190
+ ),
179
191
  collectionItems
180
192
  };
181
193
  }
@@ -299,6 +311,33 @@ async function expandRoutes(apiBase, pages, requestOptions, locale, collectItems
299
311
  }
300
312
  return [...new Set(routes)];
301
313
  }
314
+ function mergeCollectionRefs(...groups) {
315
+ const refs = /* @__PURE__ */ new Map();
316
+ for (const group of groups) {
317
+ for (const ref of group) refs.set(`${ref.store}/${ref.collection}`, ref);
318
+ }
319
+ return [...refs.values()];
320
+ }
321
+ async function preloadCollections(apiBase, websiteId, refs, locale, requestOptions, collectItems) {
322
+ const pageSize = 1e3;
323
+ await Promise.all(refs.map(async (ref) => {
324
+ if (ref.collection in collectItems) return;
325
+ const items = [];
326
+ for (let offset = 0; ; offset += pageSize) {
327
+ const response = await bloxBuildJson(
328
+ `${apiBase}/blox-build/websites/${websiteId}/collections/${ref.store}/${ref.collection}?offset=${offset}&limit=${pageSize}&locale=${encodeURIComponent(locale)}`,
329
+ {},
330
+ requestOptions
331
+ );
332
+ if (!Array.isArray(response.items)) {
333
+ throw new TypeError(`Blox collection response is invalid: ${ref.store}/${ref.collection}`);
334
+ }
335
+ items.push(...response.items);
336
+ if (response.items.length < pageSize) break;
337
+ }
338
+ collectItems[ref.collection] = items;
339
+ }));
340
+ }
302
341
  function extractCollectionRefs(pages) {
303
342
  const seen = /* @__PURE__ */ new Set();
304
343
  const refs = [];
@@ -121,6 +121,15 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
121
121
  paths: localePaths.map((path2) => localizePath(path2, locale, defaultLocale2))
122
122
  };
123
123
  }));
124
+ const manifestCollections = baseBundle.collections ?? [];
125
+ await preloadCollections(
126
+ apiBase,
127
+ websiteId,
128
+ manifestCollections,
129
+ defaultLocale2,
130
+ requestOptions,
131
+ collectionItems
132
+ );
124
133
  const paths2 = [...new Set(localizedBundles.flatMap((result) => result.paths))];
125
134
  const pathSet2 = new Set(paths2);
126
135
  const defaultPages2 = ((_c = localizedBundles.find((result) => result.locale === defaultLocale2)) == null ? void 0 : _c.bundle.pages) ?? [];
@@ -152,7 +161,10 @@ async function fetchCmsSiteData(apiBase, websiteName, requestOptions = {}) {
152
161
  pageSlugs: [...new Set(localizedBundles.flatMap((result) => result.bundle.pages.flatMap((page) => page.slug ? [localizePath(page.slug, result.locale, defaultLocale2)] : [])))],
153
162
  pageSlugMap: buildPageSlugMap(localizedBundles, defaultLocale2),
154
163
  redirects: redirects2,
155
- collections: extractCollectionRefs(localizedBundles.flatMap((result) => result.bundle.pages)),
164
+ collections: mergeCollectionRefs(
165
+ extractCollectionRefs(localizedBundles.flatMap((result) => result.bundle.pages)),
166
+ manifestCollections
167
+ ),
156
168
  collectionItems
157
169
  };
158
170
  }
@@ -276,6 +288,33 @@ async function expandRoutes(apiBase, pages, requestOptions, locale, collectItems
276
288
  }
277
289
  return [...new Set(routes)];
278
290
  }
291
+ function mergeCollectionRefs(...groups) {
292
+ const refs = /* @__PURE__ */ new Map();
293
+ for (const group of groups) {
294
+ for (const ref of group) refs.set(`${ref.store}/${ref.collection}`, ref);
295
+ }
296
+ return [...refs.values()];
297
+ }
298
+ async function preloadCollections(apiBase, websiteId, refs, locale, requestOptions, collectItems) {
299
+ const pageSize = 1e3;
300
+ await Promise.all(refs.map(async (ref) => {
301
+ if (ref.collection in collectItems) return;
302
+ const items = [];
303
+ for (let offset = 0; ; offset += pageSize) {
304
+ const response = await bloxBuildJson(
305
+ `${apiBase}/blox-build/websites/${websiteId}/collections/${ref.store}/${ref.collection}?offset=${offset}&limit=${pageSize}&locale=${encodeURIComponent(locale)}`,
306
+ {},
307
+ requestOptions
308
+ );
309
+ if (!Array.isArray(response.items)) {
310
+ throw new TypeError(`Blox collection response is invalid: ${ref.store}/${ref.collection}`);
311
+ }
312
+ items.push(...response.items);
313
+ if (response.items.length < pageSize) break;
314
+ }
315
+ collectItems[ref.collection] = items;
316
+ }));
317
+ }
279
318
  function extractCollectionRefs(pages) {
280
319
  const seen = /* @__PURE__ */ new Set();
281
320
  const refs = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/blox",
3
3
  "type": "module",
4
- "version": "1.18.10",
4
+ "version": "1.18.11",
5
5
  "description": "Blox page builder library for drag-and-drop page building and static data management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",