@getquick/content 0.3.0 → 0.3.2

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/server.js CHANGED
@@ -1,7 +1,7 @@
1
- import { _ as uriPath, a as siteLanguages, b as parseWordPressBlocks, c as parseDesignBlocks, d as decodeEntities, g as stripHtml, h as routeOf, i as routeLanguage, l as renderDesignPattern, n as isLanguageHome, p as menuItemHref, r as languageSubject, u as cmsTime, x as renderWordPressBlocks, y as hasVideoHero } from "./site-language-cBP8SFrS.js";
1
+ import { D as renderWordPressBlocks, E as parseWordPressBlocks, T as hasVideoHero, V as enhanceDesignNavigationHtml, Z as resolveDesignTheme, _ as uriPath, a as siteLanguages, c as parseDesignBlocks, d as decodeEntities, et as assertDesignBlocks, g as stripHtml, h as routeOf, i as routeLanguage, l as renderDesignPattern, n as isLanguageHome, p as menuItemHref, r as languageSubject, tt as enhanceDesignCoverVideosHtml, u as cmsTime, w as hasDesignCarousel, x as preloadDesignQueryPosts } from "./site-language-BcPac0Ia.js";
2
2
  import { t as bearerMatches } from "./bearer-DMOCoSci.js";
3
3
  import { _ as consentConfiguration } from "./state-BYWc5TUB.js";
4
- import { i as rewriteEmbeds, l as parseLegalLanguage } from "./embeds-p9SyGNZI.js";
4
+ import { i as rewriteEmbeds, l as parseLegalLanguage } from "./embeds-CJJemAmE.js";
5
5
  //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
6
6
  var util;
7
7
  (function(util) {
@@ -4767,6 +4767,48 @@ function configuredRefresh(languages, delivery) {
4767
4767
  return { handleRefresh };
4768
4768
  }
4769
4769
  //#endregion
4770
+ //#region frontend/src/design-blocks.ts
4771
+ /** Validate publication trees with the producer/renderer contract, preserving every node. */
4772
+ const designBlocksSchema = unknownType().transform((value, context) => {
4773
+ try {
4774
+ assertDesignBlocks(value);
4775
+ return value;
4776
+ } catch {
4777
+ context.addIssue({
4778
+ code: "custom",
4779
+ message: "Invalid canonical Design block list"
4780
+ });
4781
+ return NEVER;
4782
+ }
4783
+ });
4784
+ /** The nullable GraphQL field is absent on older CMS releases and block recovery reads. */
4785
+ const designBlocksJsonSchema = stringType().nullish().transform((value, context) => {
4786
+ if (value == null) return void 0;
4787
+ try {
4788
+ return JSON.parse(value);
4789
+ } catch {
4790
+ context.addIssue({
4791
+ code: "custom",
4792
+ message: "Invalid canonical Design block JSON"
4793
+ });
4794
+ return NEVER;
4795
+ }
4796
+ }).pipe(designBlocksSchema.optional());
4797
+ //#endregion
4798
+ //#region frontend/src/design-theme.ts
4799
+ /** Both CMS reads and stored publications use the owning theme validator. */
4800
+ const designThemeSchema = unknownType().transform((value, context) => {
4801
+ try {
4802
+ return resolveDesignTheme(value);
4803
+ } catch {
4804
+ context.addIssue({
4805
+ code: "custom",
4806
+ message: "Invalid resolved Design theme"
4807
+ });
4808
+ return NEVER;
4809
+ }
4810
+ });
4811
+ //#endregion
4770
4812
  //#region frontend/src/published-html.ts
4771
4813
  /** The one step every published body passes through: the identity unless configured. */
4772
4814
  function publishedHtml(languages, transform) {
@@ -4806,7 +4848,8 @@ function publishedHtml(languages, transform) {
4806
4848
  ...home,
4807
4849
  page: {
4808
4850
  ...home.page,
4809
- content: transform(home.page.content, served)
4851
+ content: transform(home.page.content, served),
4852
+ ...home.page.designBlocks ? { designBlocks: blocks(home.page.designBlocks, served) } : {}
4810
4853
  }
4811
4854
  },
4812
4855
  chrome: chrome(delivery.content.chrome, served)
@@ -4827,7 +4870,8 @@ function publishedHtml(languages, transform) {
4827
4870
  ...delivery.content,
4828
4871
  entry: {
4829
4872
  ...entry,
4830
- content: transform(entry.content, served)
4873
+ content: transform(entry.content, served),
4874
+ ...entry.designBlocks ? { designBlocks: blocks(entry.designBlocks, served) } : {}
4831
4875
  },
4832
4876
  chrome: chrome(delivery.content.chrome, served)
4833
4877
  }
@@ -4920,10 +4964,13 @@ function configuredDelivery(config, languages, wordpress, transformHtml) {
4920
4964
  title: stringType(),
4921
4965
  content: stringType(),
4922
4966
  hasVideoHero: booleanType(),
4967
+ databaseId: numberType().int().positive().optional(),
4968
+ designBlocks: designBlocksSchema.optional(),
4923
4969
  ...extended
4924
4970
  }),
4925
4971
  spacingSizes,
4926
- colors
4972
+ colors,
4973
+ theme: designThemeSchema.optional()
4927
4974
  });
4928
4975
  const translation = objectType({
4929
4976
  uri: stringType(),
@@ -4957,8 +5004,11 @@ function configuredDelivery(config, languages, wordpress, transformHtml) {
4957
5004
  date: stringType(),
4958
5005
  featuredImage: image,
4959
5006
  hasVideoHero: booleanType(),
5007
+ databaseId: numberType().int().positive().optional(),
5008
+ designBlocks: designBlocksSchema.optional(),
4960
5009
  spacingSizes,
4961
5010
  colors,
5011
+ theme: designThemeSchema.optional(),
4962
5012
  ...extended
4963
5013
  });
4964
5014
  const legalRole = objectType({
@@ -5001,7 +5051,8 @@ function configuredDelivery(config, languages, wordpress, transformHtml) {
5001
5051
  });
5002
5052
  const designPresets = objectType({
5003
5053
  spacingSizes,
5004
- colors
5054
+ colors,
5055
+ theme: designThemeSchema.optional()
5005
5056
  });
5006
5057
  const archives = recordType(stringType());
5007
5058
  const parseWith = (schema) => (body) => {
@@ -5051,7 +5102,8 @@ function configuredDelivery(config, languages, wordpress, transformHtml) {
5051
5102
  return design ? {
5052
5103
  ...content,
5053
5104
  spacingSizes: design.spacingSizes,
5054
- colors: design.colors
5105
+ colors: design.colors,
5106
+ theme: design.theme
5055
5107
  } : content;
5056
5108
  }
5057
5109
  /**
@@ -6087,6 +6139,7 @@ function configuredWordPress(config, languages) {
6087
6139
  });
6088
6140
  const imageEdge = objectType({ node: image.nullable() }).nullable();
6089
6141
  const designTokens = objectType({
6142
+ theme: designThemeSchema.optional(),
6090
6143
  spacingSizes: arrayType(objectType({
6091
6144
  slug: stringType(),
6092
6145
  size: stringType()
@@ -6104,6 +6157,8 @@ function configuredWordPress(config, languages) {
6104
6157
  nodeByUri: unionType([objectType({
6105
6158
  __typename: literalType("Page"),
6106
6159
  id: stringType().nullable().optional(),
6160
+ databaseId: numberType().int().positive().optional(),
6161
+ getquickBlocksJson: designBlocksJsonSchema,
6107
6162
  isFrontPage: booleanType(),
6108
6163
  title: stringType().nullable(),
6109
6164
  content: stringType().nullable(),
@@ -6113,6 +6168,8 @@ function configuredWordPress(config, languages) {
6113
6168
  });
6114
6169
  const pageEntry = objectType({
6115
6170
  id: stringType(),
6171
+ databaseId: numberType().int().positive().optional(),
6172
+ getquickBlocksJson: designBlocksJsonSchema,
6116
6173
  title: stringType().nullable(),
6117
6174
  content: stringType().nullable(),
6118
6175
  uri: stringType(),
@@ -6146,6 +6203,8 @@ function configuredWordPress(config, languages) {
6146
6203
  });
6147
6204
  const nodeEntry = objectType({
6148
6205
  __typename: stringType(),
6206
+ databaseId: numberType().int().positive().optional(),
6207
+ getquickBlocksJson: designBlocksJsonSchema,
6149
6208
  id: stringType(),
6150
6209
  uri: stringType().nullable(),
6151
6210
  status: stringType().nullable(),
@@ -6162,7 +6221,7 @@ function configuredWordPress(config, languages) {
6162
6221
  translations: translated.translations.optional()
6163
6222
  }).passthrough();
6164
6223
  const nodeEntryData = objectType({
6165
- node: unionType([nodeEntry, objectType({ __typename: stringType() })]).nullable(),
6224
+ node: unionType([nodeEntry, objectType({ __typename: stringType().refine((name) => name !== "Post" && name !== "Page" && !collectionOf(name)) })]).nullable(),
6166
6225
  designTokens
6167
6226
  });
6168
6227
  const translatedEntryData = objectType({
@@ -6249,6 +6308,8 @@ function configuredWordPress(config, languages) {
6249
6308
  __typename
6250
6309
  ... on Page {
6251
6310
  id
6311
+ databaseId
6312
+ getquickBlocksJson @include(if: $withBlocks)
6252
6313
  title
6253
6314
  content
6254
6315
  blocks(attributes: true, htmlContent: true, dynamicContent: true, postTemplate: false)
@@ -6257,6 +6318,7 @@ function configuredWordPress(config, languages) {
6257
6318
  }
6258
6319
  }
6259
6320
  designTokens {
6321
+ theme
6260
6322
  spacingSizes {
6261
6323
  slug
6262
6324
  size
@@ -6278,6 +6340,8 @@ function configuredWordPress(config, languages) {
6278
6340
  __typename
6279
6341
  ... on Page {
6280
6342
  id
6343
+ databaseId
6344
+ getquickBlocksJson @include(if: $withBlocks)
6281
6345
  title
6282
6346
  content
6283
6347
  blocks(attributes: true, htmlContent: true, dynamicContent: true, postTemplate: false)
@@ -6286,6 +6350,7 @@ function configuredWordPress(config, languages) {
6286
6350
  }
6287
6351
  }
6288
6352
  designTokens {
6353
+ theme
6289
6354
  spacingSizes {
6290
6355
  slug
6291
6356
  size
@@ -6354,6 +6419,7 @@ function configuredWordPress(config, languages) {
6354
6419
  return `
6355
6420
  query EntryByUri($uri: String!, $withBlocks: Boolean = true) {
6356
6421
  designTokens {
6422
+ theme
6357
6423
  colors {
6358
6424
  slug
6359
6425
  color
@@ -6365,6 +6431,8 @@ function configuredWordPress(config, languages) {
6365
6431
  }
6366
6432
  postBy(uri: $uri) {
6367
6433
  id
6434
+ databaseId
6435
+ getquickBlocksJson @include(if: $withBlocks)
6368
6436
  title
6369
6437
  excerpt
6370
6438
  content
@@ -6384,6 +6452,8 @@ function configuredWordPress(config, languages) {
6384
6452
  }
6385
6453
  pageBy(uri: $uri) {
6386
6454
  id
6455
+ databaseId
6456
+ getquickBlocksJson @include(if: $withBlocks)
6387
6457
  title
6388
6458
  content
6389
6459
  blocks(attributes: true, htmlContent: true, dynamicContent: true, postTemplate: false)
@@ -6427,6 +6497,7 @@ function configuredWordPress(config, languages) {
6427
6497
  return `
6428
6498
  query EntryByUri($uri: String!, $withBlocks: Boolean = true) {
6429
6499
  designTokens {
6500
+ theme
6430
6501
  colors {
6431
6502
  slug
6432
6503
  color
@@ -6464,7 +6535,11 @@ function configuredWordPress(config, languages) {
6464
6535
  altText
6465
6536
  }
6466
6537
  }
6467
- }${typeFields("Post", `${languageFields}${extensionFields("post")}`)}${typeFields("Page", `${languageFields}${extensionFields("page")}`)}${itemFields}
6538
+ }${typeFields("Post", `
6539
+ databaseId
6540
+ getquickBlocksJson @include(if: $withBlocks)${languageFields}${extensionFields("post")}`)}${typeFields("Page", `
6541
+ databaseId
6542
+ getquickBlocksJson @include(if: $withBlocks)${languageFields}${extensionFields("page")}`)}${itemFields}
6468
6543
  }
6469
6544
  }
6470
6545
  `;
@@ -6474,6 +6549,7 @@ function configuredWordPress(config, languages) {
6474
6549
  const designQuery = `
6475
6550
  query DesignPresets {
6476
6551
  designTokens {
6552
+ theme
6477
6553
  spacingSizes {
6478
6554
  slug
6479
6555
  size
@@ -6522,6 +6598,8 @@ function configuredWordPress(config, languages) {
6522
6598
  function normalizePost(post) {
6523
6599
  return {
6524
6600
  id: post.id,
6601
+ ...post.databaseId !== void 0 ? { databaseId: post.databaseId } : {},
6602
+ ...post.getquickBlocksJson !== void 0 ? { designBlocks: post.getquickBlocksJson } : {},
6525
6603
  title: post.title ?? "",
6526
6604
  excerpt: post.excerpt ?? "",
6527
6605
  content: post.content ?? "",
@@ -6534,9 +6612,11 @@ function configuredWordPress(config, languages) {
6534
6612
  /** A read WordPress didn't complete; becomes an Unavailable delivery. */
6535
6613
  class CmsFailureError extends Error {
6536
6614
  failure;
6537
- constructor(failure, options) {
6615
+ graphqlErrors;
6616
+ constructor(failure, options, graphqlErrors) {
6538
6617
  super(failure.message, options);
6539
6618
  this.failure = failure;
6619
+ this.graphqlErrors = graphqlErrors;
6540
6620
  }
6541
6621
  }
6542
6622
  function describeIssues(error) {
@@ -6639,7 +6719,7 @@ function configuredWordPress(config, languages) {
6639
6719
  if (result?.errors?.length) throw new CmsFailureError({
6640
6720
  reason: "graphql",
6641
6721
  message: safeMessage(result.errors.map((error) => error.message).join(", "))
6642
- });
6722
+ }, void 0, result.errors.map((error) => error.message));
6643
6723
  const parsed = schema.safeParse(result?.data);
6644
6724
  if (!parsed.success) throw new CmsFailureError({
6645
6725
  reason: "schema",
@@ -6657,16 +6737,25 @@ function configuredWordPress(config, languages) {
6657
6737
  * too is a failure, never absence.
6658
6738
  */
6659
6739
  async function queryWithBlockRecovery(schema, queryText, variables = {}) {
6740
+ const read = async (readVariables) => {
6741
+ try {
6742
+ return await query(schema, queryText, readVariables);
6743
+ } catch (error) {
6744
+ if (!(error instanceof CmsFailureError) || error.failure.reason !== "graphql" || !error.graphqlErrors?.length || !error.graphqlErrors.every((message) => /^Cannot query field "getquickBlocksJson" on type "(?:Post|Page)"\.(?: Did you mean [^\n]+)?$/.test(message))) throw error;
6745
+ queryText = queryText.replace(/getquickBlocksJson @include\(if: \$withBlocks\)/g, "");
6746
+ return query(schema, queryText, readVariables);
6747
+ }
6748
+ };
6660
6749
  try {
6661
6750
  return {
6662
- data: await query(schema, queryText, variables),
6751
+ data: await read(variables),
6663
6752
  blocksOmitted: false
6664
6753
  };
6665
6754
  } catch (error) {
6666
6755
  if (!isServerError(error)) throw error;
6667
6756
  try {
6668
6757
  return {
6669
- data: await query(schema, queryText, {
6758
+ data: await read({
6670
6759
  ...variables,
6671
6760
  withBlocks: false
6672
6761
  }),
@@ -6724,14 +6813,17 @@ function configuredWordPress(config, languages) {
6724
6813
  description: data.generalSettings.description ?? ""
6725
6814
  },
6726
6815
  page: {
6816
+ ...node.databaseId !== void 0 ? { databaseId: node.databaseId } : {},
6817
+ ...node.getquickBlocksJson !== void 0 ? { designBlocks: node.getquickBlocksJson } : {},
6727
6818
  title: node.title ?? "",
6728
- content: containsVideoHero ? renderWordPressBlocks(blocks) : node.content ?? "",
6819
+ content: containsVideoHero || hasDesignCarousel(blocks) ? renderWordPressBlocks(blocks) : node.content ?? "",
6729
6820
  hasVideoHero: containsVideoHero,
6730
6821
  ...extended("page", node, blocksOmitted)
6731
6822
  },
6732
6823
  blocksOmitted,
6733
6824
  spacingSizes: data.designTokens.spacingSizes,
6734
- colors: data.designTokens.colors
6825
+ colors: data.designTokens.colors,
6826
+ ...data.designTokens.theme ? { theme: data.designTokens.theme } : {}
6735
6827
  }
6736
6828
  };
6737
6829
  });
@@ -6754,12 +6846,13 @@ function configuredWordPress(config, languages) {
6754
6846
  kind: "found",
6755
6847
  content: {
6756
6848
  ...normalized,
6757
- content: containsVideoHero ? renderWordPressBlocks(blocks) : normalized.content,
6849
+ content: containsVideoHero || hasDesignCarousel(blocks) ? renderWordPressBlocks(blocks) : normalized.content,
6758
6850
  hasVideoHero: containsVideoHero,
6759
6851
  blocksOmitted,
6760
6852
  modifiedAt: cmsTime(post.modifiedGmt),
6761
6853
  spacingSizes: data.designTokens.spacingSizes,
6762
6854
  colors: data.designTokens.colors,
6855
+ ...data.designTokens.theme ? { theme: data.designTokens.theme } : {},
6763
6856
  ...multilingual ? languageOf(post) : {},
6764
6857
  ...extended(data.postBy ? "post" : "page", post, blocksOmitted)
6765
6858
  }
@@ -6796,12 +6889,13 @@ function configuredWordPress(config, languages) {
6796
6889
  kind: "found",
6797
6890
  content: {
6798
6891
  ...normalized,
6799
- content: containsVideoHero ? renderWordPressBlocks(blocks) : normalized.content,
6892
+ content: containsVideoHero || hasDesignCarousel(blocks) ? renderWordPressBlocks(blocks) : normalized.content,
6800
6893
  hasVideoHero: containsVideoHero,
6801
6894
  blocksOmitted,
6802
6895
  modifiedAt: cmsTime(node.modifiedGmt),
6803
6896
  spacingSizes: data.designTokens.spacingSizes,
6804
6897
  colors: data.designTokens.colors,
6898
+ ...data.designTokens.theme ? { theme: data.designTokens.theme } : {},
6805
6899
  ...multilingual ? languageOf(entry) : {},
6806
6900
  ...item ? { collection: {
6807
6901
  name: item[0],
@@ -6837,7 +6931,8 @@ function configuredWordPress(config, languages) {
6837
6931
  kind: "found",
6838
6932
  content: {
6839
6933
  spacingSizes: designTokens.spacingSizes,
6840
- colors: designTokens.colors
6934
+ colors: designTokens.colors,
6935
+ ...designTokens.theme ? { theme: designTokens.theme } : {}
6841
6936
  }
6842
6937
  };
6843
6938
  });
@@ -7133,11 +7228,11 @@ function createContentRuntime(input) {
7133
7228
  new URL(config.graphqlEndpoint).hostname,
7134
7229
  ...consent.firstPartyHosts ?? []
7135
7230
  ] : [];
7136
- const delivery = configuredDelivery(config, languages, wordpress, embedConfiguration ? (html, language) => rewriteEmbeds(html, {
7231
+ const delivery = configuredDelivery(config, languages, wordpress, (html, language) => enhanceDesignNavigationHtml(enhanceDesignCoverVideosHtml(embedConfiguration ? rewriteEmbeds(html, {
7137
7232
  configuration: embedConfiguration,
7138
7233
  language: language.lang,
7139
7234
  firstPartyHosts
7140
- }).html : void 0);
7235
+ }).html : html)));
7141
7236
  const events = configuredEvents(config, languages, delivery, wordpress);
7142
7237
  const refresh = configuredRefresh(languages, delivery);
7143
7238
  const answer = (status, error, headers = {}) => Response.json({ error }, {
@@ -7196,10 +7291,21 @@ function createContentRuntime(input) {
7196
7291
  * `renderDesignPattern`), with links into the CMS or `siteOrigin` served
7197
7292
  * as this Site's paths.
7198
7293
  */
7294
+ /** Preload selected standard Post/Page records through the existing store reader. */
7295
+ preloadDesignQueryPosts: (pattern, siteOrigin) => preloadDesignQueryPosts(pattern, async (item) => {
7296
+ if (item.type && item.type !== "post" && item.type !== "page") throw new Error(`Neutral query preload is not available for ${item.type}`);
7297
+ const delivered = await delivery.publishedEntry(item.uri, siteOrigin);
7298
+ return delivered.kind === "found" ? delivered.content.entry : null;
7299
+ }),
7199
7300
  renderDesignPattern: (pattern, options = {}) => {
7200
7301
  const { siteOrigin, internalOrigins: extraOrigins = [], ...rest } = options;
7201
7302
  return renderDesignPattern(pattern, {
7202
7303
  ...rest,
7304
+ mediaHtml: embedConfiguration ? (html) => rewriteEmbeds(html, {
7305
+ configuration: embedConfiguration,
7306
+ language: routeLanguage(rest.home ?? "/", languages).lang,
7307
+ firstPartyHosts
7308
+ }).html : rest.mediaHtml,
7203
7309
  internalOrigins: [...internalOrigins(config, siteOrigin), ...extraOrigins]
7204
7310
  });
7205
7311
  },