@blinkk/root-cms 3.1.3 → 3.1.5

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 (147) hide show
  1. package/dist/app.js +3 -5
  2. package/dist/{chunk-4VZTYUQ7.js → chunk-6CTCV2PN.js} +192 -14
  3. package/dist/{chunk-AFBSITEO.js → chunk-ETHWZSNM.js} +4 -0
  4. package/dist/chunk-MUXSUGFF.js +764 -0
  5. package/dist/cli.js +1 -1
  6. package/dist/client.js +1 -1
  7. package/dist/core/ai-tools.d.ts +82 -42
  8. package/dist/core/ai.d.ts +54 -218
  9. package/dist/core/plugin.d.ts +10 -4
  10. package/dist/core/schema.d.ts +88 -3
  11. package/dist/core.js +1 -1
  12. package/dist/functions.js +2 -3
  13. package/dist/plugin.js +43 -209
  14. package/dist/shared/ai/models.d.ts +110 -0
  15. package/dist/shared/ai/prompt-utils.d.ts +59 -0
  16. package/dist/ui/AIPage-25WICIOT.js +1 -0
  17. package/dist/ui/AssetsPage-WKTM2J2G.js +1 -0
  18. package/dist/ui/CollectionPage-5ZOVG7IG.js +1 -0
  19. package/dist/ui/ComparePage-DDIFYYTK.js +1 -0
  20. package/dist/ui/DataPage-RFNGSDDN.js +1 -0
  21. package/dist/ui/DataSourcePage-U46CDIH2.js +1 -0
  22. package/dist/ui/DocTranslationsPage-BFCM2PE3.js +1 -0
  23. package/dist/ui/DocumentPage-OTBXM55S.js +1 -0
  24. package/dist/ui/EditDataSourcePage-NKKIF6AD.js +1 -0
  25. package/dist/ui/EditReleasePage-TKNOUT7A.js +1 -0
  26. package/dist/ui/EmbeddedAIPage-4AX7VO3T.js +1 -0
  27. package/dist/ui/EmbeddedDocumentPage-2CNQJTW5.js +1 -0
  28. package/dist/ui/{ImageEditorDialog-GGS4VFEA.js → ImageEditorDialog-YDKOGVJV.js} +1 -1
  29. package/dist/ui/LogsPage-SCECIAZH.js +1 -0
  30. package/dist/ui/NewDataSourcePage-FAOPK2RZ.js +1 -0
  31. package/dist/ui/NewReleasePage-HD6T6UV2.js +1 -0
  32. package/dist/ui/{NotFoundPage-WXEZQZK6.js → NotFoundPage-JRYFUENW.js} +1 -1
  33. package/dist/ui/ProjectPage-2WIMWCSX.js +1 -0
  34. package/dist/ui/ReleasePage-GUMEMLF6.js +1 -0
  35. package/dist/ui/ReleasesPage-AW6PICTQ.js +1 -0
  36. package/dist/ui/SettingsPage-KFLNZ356.js +1 -0
  37. package/dist/ui/{SidebarToolsPage-API53RRR.js → SidebarToolsPage-3R7BQ2F7.js} +1 -1
  38. package/dist/ui/TaskPage-GZGPKIL5.js +1 -0
  39. package/dist/ui/TasksPage-G3GBTV3L.js +1 -0
  40. package/dist/ui/TranslationsArbPage-K272JEAA.js +2 -0
  41. package/dist/ui/TranslationsEditPage-XWXPNKRQ.js +1 -0
  42. package/dist/ui/{TranslationsPage-NGGZB4L6.js → TranslationsPage-7KUHVTLK.js} +1 -1
  43. package/dist/ui/ai-tools-7S4URTMT.js +1 -0
  44. package/dist/ui/{chunk-TVYAZN2Q.js → chunk-2FQMT5AB.js} +1 -1
  45. package/dist/ui/{chunk-J5E457OI.js → chunk-2PTLQRTU.js} +1 -1
  46. package/dist/ui/{chunk-UPDL6UXI.js → chunk-2RRM4HEQ.js} +1 -1
  47. package/dist/ui/{chunk-WYJJZTCI.js → chunk-34W6H4YG.js} +1 -1
  48. package/dist/ui/{chunk-4FGASIIX.js → chunk-44ZU5WMI.js} +1 -1
  49. package/dist/ui/{chunk-3E6CASIN.js → chunk-535JU7FU.js} +1 -1
  50. package/dist/ui/chunk-5KSGCGYY.js +1 -0
  51. package/dist/ui/{chunk-ZMS6NIGG.js → chunk-75NMQ3LW.js} +1 -1
  52. package/dist/ui/{chunk-Y3MCFLQU.js → chunk-7UHZS56B.js} +57 -57
  53. package/dist/ui/chunk-AAR7DBEN.js +110 -0
  54. package/dist/ui/{chunk-JS6TK4OP.js → chunk-ATTW36EM.js} +1 -1
  55. package/dist/ui/{chunk-DIFPCF7I.js → chunk-DWV5J2W7.js} +1 -1
  56. package/dist/ui/chunk-DZYYWCHX.js +3 -0
  57. package/dist/ui/chunk-F7RQT4XN.js +1 -0
  58. package/dist/ui/chunk-FVWSVOOY.js +1 -0
  59. package/dist/ui/chunk-GCSN3YEC.js +31 -0
  60. package/dist/ui/{chunk-CAY5NM4Z.js → chunk-H37RXS4R.js} +1 -1
  61. package/dist/ui/{chunk-JTIQBW33.js → chunk-HV3JJ5UT.js} +1 -1
  62. package/dist/ui/{chunk-MSYTAJBV.js → chunk-HXSB6YB2.js} +1 -1
  63. package/dist/ui/chunk-IGZDFHVM.js +1 -0
  64. package/dist/ui/chunk-ISUGBMXC.js +1 -0
  65. package/dist/ui/{chunk-G5ZZDHWA.js → chunk-JBLSUM6W.js} +1 -1
  66. package/dist/ui/{chunk-T77VOWHP.js → chunk-N5RJIILP.js} +1 -1
  67. package/dist/ui/{chunk-BW2MKGNP.js → chunk-NCZD5IWS.js} +1 -1
  68. package/dist/ui/chunk-NXWYS4HG.js +19 -0
  69. package/dist/ui/{chunk-FXIR2RBE.js → chunk-OWBT6YUM.js} +1 -1
  70. package/dist/ui/chunk-OWYV43BT.js +1 -0
  71. package/dist/ui/{chunk-QHJOTXYB.js → chunk-PIJ3E47R.js} +1 -1
  72. package/dist/ui/{chunk-ENQKSLGJ.js → chunk-PLYSJ7W5.js} +1 -1
  73. package/dist/ui/{chunk-FJLNXXE3.js → chunk-QFDU6FXP.js} +1 -1
  74. package/dist/ui/{chunk-P2Z66DHV.js → chunk-QLIIVG5Q.js} +1 -1
  75. package/dist/ui/{chunk-HARRKJFZ.js → chunk-QRAFYIAW.js} +1 -1
  76. package/dist/ui/{chunk-2EPQJUGM.js → chunk-QWB6MAPJ.js} +1 -1
  77. package/dist/ui/{chunk-W6LP22IK.js → chunk-RB23LLKL.js} +1 -1
  78. package/dist/ui/chunk-RN4XVVWD.js +1 -0
  79. package/dist/ui/{chunk-BOER3EAW.js → chunk-SYDHFYRC.js} +1 -1
  80. package/dist/ui/{chunk-NSI5JSVV.js → chunk-T5BJNOWE.js} +1 -1
  81. package/dist/ui/chunk-TNW2GNUR.js +1 -0
  82. package/dist/ui/{chunk-WFQU7V3W.js → chunk-UCYWQEAS.js} +1 -1
  83. package/dist/ui/{chunk-GT5EQSEX.js → chunk-UJX25CXD.js} +1 -1
  84. package/dist/ui/chunk-UPN3EMUS.js +1 -0
  85. package/dist/ui/{chunk-NJMNOITA.js → chunk-VPZHG7JL.js} +1 -1
  86. package/dist/ui/{chunk-BUNR5EU3.js → chunk-WASID5UU.js} +1 -1
  87. package/dist/ui/chunk-WC7KMPEQ.js +1 -0
  88. package/dist/ui/chunk-WRA24P66.js +7 -0
  89. package/dist/ui/{chunk-LROR6N3B.js.LEGAL.txt → chunk-WRA24P66.js.LEGAL.txt} +5 -1
  90. package/dist/ui/chunk-XACLTYBB.js +5 -0
  91. package/dist/ui/{chunk-VD6G5NV4.js → chunk-XOWWPE7X.js} +12 -12
  92. package/dist/ui/chunk-XUBZH4ON.js +1 -0
  93. package/dist/ui/{chunk-QF3GPZTI.js → chunk-Y5EOMMNI.js} +1 -1
  94. package/dist/ui/{chunk-NSOTG64N.js → chunk-YBHFGQ3Z.js} +1 -1
  95. package/dist/ui/chunk-YP6ZH3MT.js +1 -0
  96. package/dist/ui/{chunk-UUVAD4U4.js → chunk-Z3ZJJWFT.js} +1 -1
  97. package/dist/ui/ui.css +1 -1
  98. package/dist/ui/ui.js +1 -1
  99. package/package.json +3 -3
  100. package/dist/chunk-4G7S2LJH.js +0 -1411
  101. package/dist/chunk-AJDMNTZQ.js +0 -187
  102. package/dist/ui/AIPage-VOTAEVJE.js +0 -1
  103. package/dist/ui/AssetsPage-EWGRMRPJ.js +0 -1
  104. package/dist/ui/CollectionPage-N5JIAUDS.js +0 -1
  105. package/dist/ui/ComparePage-JDPVU2VA.js +0 -1
  106. package/dist/ui/DataPage-37D4CMLZ.js +0 -1
  107. package/dist/ui/DataSourcePage-LX5ASYQN.js +0 -1
  108. package/dist/ui/DocTranslationsPage-V5M4KB7X.js +0 -1
  109. package/dist/ui/DocumentPage-SURTQJPG.js +0 -1
  110. package/dist/ui/EditDataSourcePage-O7DOV5LX.js +0 -1
  111. package/dist/ui/EditReleasePage-NDYTKGXY.js +0 -1
  112. package/dist/ui/EmbeddedAIPage-RJOUIPF2.js +0 -1
  113. package/dist/ui/EmbeddedDocumentPage-SLEULNNI.js +0 -1
  114. package/dist/ui/LogsPage-ZGBP3I35.js +0 -1
  115. package/dist/ui/NewDataSourcePage-GQONTMP4.js +0 -1
  116. package/dist/ui/NewReleasePage-7ZKXHDTD.js +0 -1
  117. package/dist/ui/ProjectPage-F7W7X6YO.js +0 -1
  118. package/dist/ui/ReleasePage-ZKMNYPML.js +0 -1
  119. package/dist/ui/ReleasesPage-JHCE6AEJ.js +0 -1
  120. package/dist/ui/SettingsPage-MWCPZPGE.js +0 -1
  121. package/dist/ui/TaskPage-73NLAR4J.js +0 -1
  122. package/dist/ui/TasksPage-IKPW2OQO.js +0 -1
  123. package/dist/ui/TranslationsArbPage-QVN66DIW.js +0 -2
  124. package/dist/ui/TranslationsEditPage-ZOELF5PK.js +0 -1
  125. package/dist/ui/ai-tools-4DWMFQS6.js +0 -1
  126. package/dist/ui/chunk-2RAVKX2Z.js +0 -19
  127. package/dist/ui/chunk-344GZOGG.js +0 -84
  128. package/dist/ui/chunk-4ISFTE2G.js +0 -5
  129. package/dist/ui/chunk-BT2NTAW2.js +0 -1
  130. package/dist/ui/chunk-C2BLMTPR.js +0 -3
  131. package/dist/ui/chunk-D3UIZHRK.js +0 -1
  132. package/dist/ui/chunk-DS27MO63.js +0 -1
  133. package/dist/ui/chunk-HO3W4RVG.js +0 -1
  134. package/dist/ui/chunk-IOR72US3.js +0 -1
  135. package/dist/ui/chunk-KRNQ6L35.js +0 -1
  136. package/dist/ui/chunk-LROR6N3B.js +0 -7
  137. package/dist/ui/chunk-N3JSLTMV.js +0 -1
  138. package/dist/ui/chunk-PPYM4O5N.js +0 -1
  139. package/dist/ui/chunk-TOGLZDK3.js +0 -1
  140. package/dist/ui/chunk-TPJCPCRR.js +0 -1
  141. package/dist/ui/chunk-VPHBKJ3I.js +0 -1
  142. package/dist/ui/chunk-YUU6LWQK.js +0 -1
  143. package/dist/ui/chunk-Z6DBYLIM.js +0 -1
  144. /package/dist/ui/{ImageEditorDialog-GGS4VFEA.js.LEGAL.txt → ImageEditorDialog-YDKOGVJV.js.LEGAL.txt} +0 -0
  145. /package/dist/ui/{chunk-Y3MCFLQU.js.LEGAL.txt → chunk-7UHZS56B.js.LEGAL.txt} +0 -0
  146. /package/dist/ui/{chunk-NJMNOITA.js.LEGAL.txt → chunk-VPZHG7JL.js.LEGAL.txt} +0 -0
  147. /package/dist/ui/{chunk-VD6G5NV4.js.LEGAL.txt → chunk-XOWWPE7X.js.LEGAL.txt} +0 -0
package/dist/app.js CHANGED
@@ -1,10 +1,7 @@
1
1
  import {
2
2
  getServerVersion,
3
3
  serializeAiConfig
4
- } from "./chunk-4G7S2LJH.js";
5
- import "./chunk-4VZTYUQ7.js";
6
- import "./chunk-AFBSITEO.js";
7
- import "./chunk-J72JK4KR.js";
4
+ } from "./chunk-MUXSUGFF.js";
8
5
  import {
9
6
  getCollectionSchema,
10
7
  getProjectSchemas
@@ -180,7 +177,8 @@ function serializeCollection(collection) {
180
177
  autoSlug: collection.autoSlug,
181
178
  autolock: collection.autolock,
182
179
  autolockReason: collection.autolockReason,
183
- sortOptions: collection.sortOptions
180
+ sortOptions: collection.sortOptions,
181
+ viewOptions: collection.viewOptions
184
182
  };
185
183
  }
186
184
  function isFunction(value) {
@@ -1,6 +1,10 @@
1
1
  import {
2
+ RootCMSClient,
2
3
  getCmsPlugin
3
- } from "./chunk-AFBSITEO.js";
4
+ } from "./chunk-ETHWZSNM.js";
5
+
6
+ // core/cron.ts
7
+ import { Timestamp as Timestamp3 } from "firebase-admin/firestore";
4
8
 
5
9
  // core/search-index.ts
6
10
  import fs from "node:fs";
@@ -673,8 +677,8 @@ var SearchIndexService = class {
673
677
  async listAllDocs(collectionIds) {
674
678
  const all = [];
675
679
  for (const collectionId of collectionIds) {
676
- const path2 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
677
- const snap = await this.db.collection(path2).get();
680
+ const path3 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
681
+ const snap = await this.db.collection(path3).get();
678
682
  snap.forEach((d) => {
679
683
  const docId = `${collectionId}/${d.id}`;
680
684
  if (!this.isDocIndexable(docId)) {
@@ -696,8 +700,8 @@ var SearchIndexService = class {
696
700
  async listChangedDocs(collectionIds, lastRun) {
697
701
  const all = [];
698
702
  for (const collectionId of collectionIds) {
699
- const path2 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
700
- const q = this.db.collection(path2).where("sys.modifiedAt", ">=", lastRun);
703
+ const path3 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
704
+ const q = this.db.collection(path3).where("sys.modifiedAt", ">=", lastRun);
701
705
  const snap = await q.get();
702
706
  snap.forEach((d) => {
703
707
  const docId = `${collectionId}/${d.id}`;
@@ -721,8 +725,8 @@ var SearchIndexService = class {
721
725
  async hasChangesSince(lastRun, docMap = null) {
722
726
  const collectionIds = await this.listCollectionIds();
723
727
  for (const collectionId of collectionIds) {
724
- const path2 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
725
- const q = this.db.collection(path2).where("sys.modifiedAt", ">=", lastRun).limit(1);
728
+ const path3 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
729
+ const q = this.db.collection(path3).where("sys.modifiedAt", ">=", lastRun).limit(1);
726
730
  const snap = await q.get();
727
731
  if (!snap.empty) {
728
732
  return true;
@@ -735,8 +739,8 @@ var SearchIndexService = class {
735
739
  }
736
740
  const liveIds = /* @__PURE__ */ new Set();
737
741
  for (const collectionId of collectionIds) {
738
- const path2 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
739
- const snap = await this.db.collection(path2).select().get();
742
+ const path3 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
743
+ const snap = await this.db.collection(path3).select().get();
740
744
  snap.forEach((d) => {
741
745
  const docId = `${collectionId}/${d.id}`;
742
746
  if (this.isDocIndexable(docId)) {
@@ -803,8 +807,8 @@ var SearchIndexService = class {
803
807
  );
804
808
  continue;
805
809
  }
806
- const path2 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
807
- const snap = await this.db.collection(path2).get();
810
+ const path3 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
811
+ const snap = await this.db.collection(path3).get();
808
812
  snap.forEach((d) => {
809
813
  const data = d.data() || {};
810
814
  const slug = data.slug || d.id;
@@ -880,8 +884,8 @@ var SearchIndexService = class {
880
884
  }
881
885
  const liveIds = /* @__PURE__ */ new Set();
882
886
  for (const collectionId of collectionIds) {
883
- const path2 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
884
- const snap = await this.db.collection(path2).select().get();
887
+ const path3 = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
888
+ const snap = await this.db.collection(path3).select().get();
885
889
  snap.forEach((d) => {
886
890
  const docId = `${collectionId}/${d.id}`;
887
891
  if (this.isDocIndexable(docId)) {
@@ -997,6 +1001,180 @@ var SearchIndexService = class {
997
1001
  }
998
1002
  };
999
1003
 
1004
+ // core/versions.ts
1005
+ import fs2 from "node:fs";
1006
+ import path2 from "node:path";
1007
+ import { Timestamp as Timestamp2 } from "firebase-admin/firestore";
1008
+ import glob2 from "tiny-glob";
1009
+ var DOCUMENT_SAVE_OFFSET = 5 * 60 * 1e3;
1010
+ var VersionsService = class {
1011
+ constructor(rootConfig) {
1012
+ this.rootConfig = rootConfig;
1013
+ const cmsPlugin = getCmsPlugin(rootConfig);
1014
+ const cmsPluginOptions = cmsPlugin.getConfig();
1015
+ const projectId = cmsPluginOptions.id || "default";
1016
+ this.projectId = projectId;
1017
+ this.db = cmsPlugin.getFirestore();
1018
+ }
1019
+ /**
1020
+ * Saves a version of all documents that have been edited since the last run.
1021
+ */
1022
+ async saveVersions() {
1023
+ const lastRun = await this.getLastRun();
1024
+ const lastRunWithOffset = lastRun === 0 ? lastRun : lastRun - DOCUMENT_SAVE_OFFSET;
1025
+ const changedDocs = await this.getDocsModifiedAfter(lastRunWithOffset);
1026
+ const now = Timestamp2.now().toMillis();
1027
+ const versions = changedDocs.filter((doc) => {
1028
+ const modifiedAt = doc.sys.modifiedAt.toMillis();
1029
+ if (modifiedAt > now - DOCUMENT_SAVE_OFFSET) {
1030
+ return false;
1031
+ }
1032
+ const publishedAt = doc.sys.publishedAt?.toMillis?.();
1033
+ if (publishedAt && Math.abs(publishedAt - modifiedAt) < 5e3) {
1034
+ return false;
1035
+ }
1036
+ return true;
1037
+ });
1038
+ if (versions.length > 0) {
1039
+ this.saveVersionsToFirestore(versions);
1040
+ }
1041
+ this.saveLastRun(now);
1042
+ }
1043
+ async saveVersionsToFirestore(versions) {
1044
+ const batch = this.db.batch();
1045
+ versions.forEach((version) => {
1046
+ if (!version.collection || !version.slug || !version.sys?.modifiedAt) {
1047
+ return;
1048
+ }
1049
+ const modifiedAtMillis = version.sys.modifiedAt.toMillis();
1050
+ const versionPath = `Projects/${this.projectId}/Collections/${version.collection}/Drafts/${version.slug}/Versions/${modifiedAtMillis}`;
1051
+ console.log(versionPath);
1052
+ const versionRef = this.db.doc(versionPath);
1053
+ batch.set(versionRef, version);
1054
+ });
1055
+ await batch.commit();
1056
+ console.log(`versions: saved ${versions.length} versions`);
1057
+ }
1058
+ /**
1059
+ * Returns the last time (in millis) saveVersions() was run, or 0 if has
1060
+ * never been run.
1061
+ */
1062
+ async getLastRun() {
1063
+ const projectDocRef = this.db.collection("Projects").doc(this.projectId);
1064
+ const projectDoc = await projectDocRef.get();
1065
+ if (projectDoc.exists) {
1066
+ const data = projectDoc.data() || {};
1067
+ const ts = data.versionsLastRun;
1068
+ if (ts) {
1069
+ return ts.toMillis();
1070
+ }
1071
+ }
1072
+ return 0;
1073
+ }
1074
+ /**
1075
+ * Saves {versionLastRun: <timestamp>} to the Projects/<projectId> doc.
1076
+ */
1077
+ async saveLastRun(millis) {
1078
+ const ts = Timestamp2.fromMillis(millis);
1079
+ const projectDocRef = this.db.collection("Projects").doc(this.projectId);
1080
+ await projectDocRef.set({ versionsLastRun: ts }, { merge: true });
1081
+ }
1082
+ /**
1083
+ * Returns a list of all docs that were edited after a certain time.
1084
+ */
1085
+ async getDocsModifiedAfter(millis) {
1086
+ const ts = Timestamp2.fromMillis(millis);
1087
+ const results = [];
1088
+ const collectionIds = await this.listCollections();
1089
+ for (const collectionId of collectionIds) {
1090
+ const collectionPath = `Projects/${this.projectId}/Collections/${collectionId}/Drafts`;
1091
+ const query = this.db.collection(collectionPath).where("sys.modifiedAt", ">=", ts);
1092
+ const querySnapshot = await query.get();
1093
+ querySnapshot.forEach((doc) => {
1094
+ results.push(doc.data());
1095
+ });
1096
+ }
1097
+ return results;
1098
+ }
1099
+ /**
1100
+ * Returns a list of collection ids for the Root project.
1101
+ */
1102
+ async listCollections() {
1103
+ const collectionsDir = path2.join(this.rootConfig.rootDir, "collections");
1104
+ if (!fs2.existsSync(collectionsDir)) {
1105
+ return [];
1106
+ }
1107
+ const collectionIds = [];
1108
+ const collectionFileNames = await glob2("*.schema.ts", {
1109
+ cwd: collectionsDir
1110
+ });
1111
+ collectionFileNames.forEach((filename) => {
1112
+ collectionIds.push(filename.slice(0, -10));
1113
+ });
1114
+ return collectionIds;
1115
+ }
1116
+ };
1117
+
1118
+ // core/cron.ts
1119
+ var SEARCH_INDEX_MIN_INTERVAL_MS = 5 * 60 * 1e3;
1120
+ async function runCronJobs(rootConfig, options = {}) {
1121
+ await Promise.all([
1122
+ runCronJob("publishScheduledDocs", runPublishScheduledDocs, rootConfig),
1123
+ runCronJob(
1124
+ "syncScheduledDataSources",
1125
+ runSyncScheduledDataSources,
1126
+ rootConfig
1127
+ ),
1128
+ runCronJob("saveVersions", runSaveVersions, rootConfig),
1129
+ runCronJob(
1130
+ "incrementalSearchIndex",
1131
+ runIncrementalSearchIndex,
1132
+ rootConfig,
1133
+ options.loadSchema
1134
+ )
1135
+ ]);
1136
+ }
1137
+ async function runCronJob(name, fn, ...args) {
1138
+ try {
1139
+ await fn(...args);
1140
+ } catch (err) {
1141
+ console.log(`cron failed: ${name}`);
1142
+ console.error(String(err.stack || err));
1143
+ throw err;
1144
+ }
1145
+ }
1146
+ async function runPublishScheduledDocs(rootConfig) {
1147
+ const cmsClient = new RootCMSClient(rootConfig);
1148
+ await cmsClient.publishScheduledDocs();
1149
+ await cmsClient.publishScheduledReleases();
1150
+ }
1151
+ async function runSyncScheduledDataSources(rootConfig) {
1152
+ const cmsClient = new RootCMSClient(rootConfig);
1153
+ await cmsClient.syncScheduledDataSources();
1154
+ }
1155
+ async function runSaveVersions(rootConfig) {
1156
+ const service = new VersionsService(rootConfig);
1157
+ await service.saveVersions();
1158
+ }
1159
+ async function runIncrementalSearchIndex(rootConfig, loadSchema) {
1160
+ const service = new SearchIndexService(rootConfig, loadSchema);
1161
+ const status = await service.getStatus();
1162
+ if (status.lastRun !== null) {
1163
+ const elapsed = Date.now() - status.lastRun;
1164
+ if (elapsed < SEARCH_INDEX_MIN_INTERVAL_MS) {
1165
+ return;
1166
+ }
1167
+ const hasChanges = await service.hasChangesSince(
1168
+ Timestamp3.fromMillis(status.lastRun)
1169
+ );
1170
+ if (!hasChanges) {
1171
+ return;
1172
+ }
1173
+ }
1174
+ await service.rebuildIndex({ force: false });
1175
+ }
1176
+
1000
1177
  export {
1001
- SearchIndexService
1178
+ SearchIndexService,
1179
+ runCronJobs
1002
1180
  };
@@ -670,6 +670,7 @@ function setValueAtPath(obj, path, value) {
670
670
  }
671
671
 
672
672
  // core/client.ts
673
+ var FIRESTORE_DOC_ID_MAX_BYTES = 1500;
673
674
  var RootCMSClient = class {
674
675
  constructor(rootConfig) {
675
676
  this.rootConfig = rootConfig;
@@ -708,6 +709,9 @@ var RootCMSClient = class {
708
709
  }
709
710
  const modeCollection = this.getModeCollection(options.mode);
710
711
  slug = normalizeSlug(slug);
712
+ if (Buffer.byteLength(slug, "utf8") > FIRESTORE_DOC_ID_MAX_BYTES) {
713
+ return null;
714
+ }
711
715
  const dbPath = `Projects/${this.projectId}/Collections/${collectionId}/${modeCollection}/${slug}`;
712
716
  const docRef = this.db.doc(dbPath);
713
717
  const doc = await docRef.get();