@decocms/parity 0.33.16 → 0.33.17

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.
Files changed (2) hide show
  1. package/dist/cli.js +93 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -57639,6 +57639,18 @@ function summarizeSections(data) {
57639
57639
  return counts.length > 0 ? `${s.componentKey} (${counts.join(", ")})` : s.componentKey;
57640
57640
  });
57641
57641
  }
57642
+ function toDataPlaneShape(node) {
57643
+ if (Array.isArray(node))
57644
+ return node.map(toDataPlaneShape);
57645
+ if (node && typeof node === "object") {
57646
+ const obj = node;
57647
+ if (obj.values && typeof obj.values === "object") {
57648
+ return collectionToArray(obj).sort((a, b) => (a.$position ?? 0) - (b.$position ?? 0)).map(({ id, $position, ...rest }) => toDataPlaneShape(rest));
57649
+ }
57650
+ return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, toDataPlaneShape(v)]));
57651
+ }
57652
+ return node;
57653
+ }
57642
57654
  function localeSwitch(value) {
57643
57655
  return {
57644
57656
  $fnType: "switch",
@@ -57787,9 +57799,73 @@ function unrenderableSections(usedKeys, contentType) {
57787
57799
  return [];
57788
57800
  return [...new Set(usedKeys.filter((k) => !allowed.includes(k)))];
57789
57801
  }
57802
+ function parseJsonc(raw) {
57803
+ const withoutComments = raw.replace(/\/\/.*$/gm, "");
57804
+ const withoutTrailingCommas = withoutComments.replace(/,(\s*[}\]])/g, "$1");
57805
+ return JSON.parse(withoutTrailingCommas);
57806
+ }
57807
+ function localComponentSchemas(repoDir) {
57808
+ const dir = join18(repoDir, "cms", "faststore", "components");
57809
+ if (!existsSync13(dir))
57810
+ return {};
57811
+ const out = {};
57812
+ for (const file of readdirSync3(dir)) {
57813
+ if (!file.endsWith(".jsonc"))
57814
+ continue;
57815
+ try {
57816
+ const parsed = parseJsonc(readFileSync16(join18(dir, file), "utf8"));
57817
+ if (!parsed.$componentKey)
57818
+ continue;
57819
+ out[parsed.$componentKey] = {
57820
+ properties: Object.keys(parsed.properties ?? {}),
57821
+ required: parsed.required ?? []
57822
+ };
57823
+ } catch {}
57824
+ }
57825
+ return out;
57826
+ }
57827
+ function publishedComponentSchemas(contentType) {
57828
+ const items = contentType?.properties?.sections?.items;
57829
+ const anyOf = items?.anyOf ?? [];
57830
+ const out = {};
57831
+ for (const s of anyOf) {
57832
+ const key = String(s.$componentKey ?? "");
57833
+ if (!key)
57834
+ continue;
57835
+ out[key] = {
57836
+ properties: Object.keys(s.properties ?? {}),
57837
+ required: s.required ?? []
57838
+ };
57839
+ }
57840
+ return out;
57841
+ }
57842
+ function propertyDrift(published, repoDir) {
57843
+ const local = localComponentSchemas(repoDir);
57844
+ const drift = [];
57845
+ for (const [contentType, schema] of Object.entries(published)) {
57846
+ const remote = publishedComponentSchemas(schema);
57847
+ for (const [componentKey, localShape] of Object.entries(local)) {
57848
+ const remoteShape = remote[componentKey];
57849
+ if (!remoteShape)
57850
+ continue;
57851
+ const missingProps = localShape.properties.filter((p) => !remoteShape.properties.includes(p));
57852
+ const newlyRequiredProps = localShape.required.filter((p) => remoteShape.properties.includes(p) && !remoteShape.required.includes(p));
57853
+ if (missingProps.length > 0 || newlyRequiredProps.length > 0) {
57854
+ drift.push({ contentType, componentKey, missingProps, newlyRequiredProps });
57855
+ }
57856
+ }
57857
+ }
57858
+ return drift;
57859
+ }
57790
57860
 
57791
57861
  // src/commands/cms.ts
57792
57862
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
57863
+ var DICT_SHAPE_CONTENT_TYPES = new Set(["globalSections"]);
57864
+ function withDataPlaneShape(contentType, data) {
57865
+ if (DICT_SHAPE_CONTENT_TYPES.has(contentType))
57866
+ return data;
57867
+ return toDataPlaneShape(data);
57868
+ }
57793
57869
  function config() {
57794
57870
  const account = process.env.PARITY_CMS_ACCOUNT;
57795
57871
  const store = process.env.PARITY_CMS_STORE;
@@ -57848,23 +57924,33 @@ async function cmsDoctorCommand(opts, call = callCms) {
57848
57924
  try {
57849
57925
  const types = await getContentTypes(cfg, call);
57850
57926
  const drift = schemaDrift(types, opts.repo);
57927
+ const propDrift = propertyDrift(types, opts.repo);
57928
+ const blockingProps = propDrift.filter((d) => d.missingProps.length > 0);
57851
57929
  if (opts.json) {
57852
- console.log(JSON.stringify({ session, contentTypes: Object.keys(types), drift }, null, 2));
57853
- return drift.some((d) => d.missingOnAccount.length > 0) ? 1 : 0;
57930
+ console.log(JSON.stringify({ session, contentTypes: Object.keys(types), drift, propDrift }, null, 2));
57931
+ return drift.some((d) => d.missingOnAccount.length > 0) || blockingProps.length > 0 ? 1 : 0;
57854
57932
  }
57855
57933
  if (session)
57856
57934
  console.log(`${chalk7.green("✓")} ${session}`);
57857
57935
  const blocking = drift.filter((d) => d.missingOnAccount.length > 0);
57858
- if (blocking.length === 0) {
57936
+ if (blocking.length === 0 && propDrift.length === 0) {
57859
57937
  console.log(`${chalk7.green("✓")} every section the repo declares is published on the account`);
57860
57938
  }
57861
57939
  for (const d of blocking) {
57862
57940
  console.log(`${chalk7.red("✗")} ${d.contentType}: ${d.missingOnAccount.join(", ")} ${chalk7.dim("— in the repo, not on the account. Upload the schema (`faststore cms-sync`) or it renders nothing.")}`);
57863
57941
  }
57942
+ for (const d of propDrift) {
57943
+ if (d.missingProps.length > 0) {
57944
+ console.log(`${chalk7.red("✗")} ${d.contentType}: ${d.componentKey} — property ${d.missingProps.join(", ")} ${chalk7.dim("in the repo, not on the account. Upload the schema or it renders nothing.")}`);
57945
+ }
57946
+ if (d.newlyRequiredProps.length > 0) {
57947
+ console.log(`${chalk7.yellow("!")} ${d.contentType}: ${d.componentKey} — ${d.newlyRequiredProps.join(", ")} ${chalk7.dim("now required locally but optional on the account. Entries authored before this change may not have it.")}`);
57948
+ }
57949
+ }
57864
57950
  for (const d of drift.filter((x) => x.missingInRepo.length > 0)) {
57865
57951
  console.log(`${chalk7.gray("·")} ${d.contentType}: ${d.missingInRepo.length} section(s) published but not in the repo ${chalk7.dim("(usually core components the repo never overrode)")}`);
57866
57952
  }
57867
- return blocking.length > 0 ? 1 : 0;
57953
+ return blocking.length > 0 || blockingProps.length > 0 ? 1 : 0;
57868
57954
  } catch (err) {
57869
57955
  return fail(err);
57870
57956
  }
@@ -58016,7 +58102,7 @@ async function cmsPushCommand(opts, call = callCms) {
58016
58102
  entryId: local.entryId,
58017
58103
  entryName: local.entryName,
58018
58104
  baseHash: local.baseHash,
58019
- data: local.data,
58105
+ data: withDataPlaneShape(local.contentType, local.data),
58020
58106
  message: opts.message ?? "parity cms push",
58021
58107
  author,
58022
58108
  identifierKeys: local.identifierKeys,
@@ -58179,11 +58265,11 @@ async function cmsCreateCommand(opts, call = callCms) {
58179
58265
  entryId,
58180
58266
  entryName: name,
58181
58267
  baseHash: head,
58182
- data: {
58268
+ data: withDataPlaneShape(opts.contentType, {
58183
58269
  slug: localeSwitch(opts.slug),
58184
58270
  seo: { slug: localeSwitch(opts.slug), title: localeSwitch(name), description: localeSwitch("") },
58185
58271
  sections: { $fnType: "array", values: {} }
58186
- },
58272
+ }),
58187
58273
  message: opts.message ?? `parity cms create ${opts.slug}`,
58188
58274
  author,
58189
58275
  identifierKeys: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.33.16",
3
+ "version": "0.33.17",
4
4
  "description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
5
5
  "type": "module",
6
6
  "license": "MIT",