alinea 2.0.0-rc1 → 2.0.0-rc2

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 (252) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/.mcp/later/dev.json +1 -1
  3. package/dist/.mcp/online/dev.json +1 -1
  4. package/dist/adapter/next/cms.js +29 -22
  5. package/dist/adapter/next/handler.js +1 -0
  6. package/dist/backend/Handler.d.ts +3 -1
  7. package/dist/backend/Handler.js +27 -16
  8. package/dist/backend/api/CreateBackend.js +2 -2
  9. package/dist/backend/api/GithubApi.js +4 -4
  10. package/dist/backend/api/database.js +2 -2
  11. package/dist/backend/store/GeneratedDatabase.js +4 -2
  12. package/dist/bundled.d.ts +507 -124
  13. package/dist/chunks/{chunk-XESQKG2I.js → chunk-4VKHBA57.js} +1 -1
  14. package/dist/cli/Generate.js +7 -2
  15. package/dist/cli/Mcp.js +1 -1
  16. package/dist/cli/Serve.js +1 -1
  17. package/dist/cli/bin.js +1 -1
  18. package/dist/cli/generate/LinkMediaFiles.js +3 -3
  19. package/dist/cli/generate/MediaLocations.js +3 -3
  20. package/dist/cli/serve/mcp/DevMcp.js +1 -1
  21. package/dist/cli/serve/mcp/McpTools.js +51 -28
  22. package/dist/cloud/CloudRemote.js +1 -1
  23. package/dist/components/Alert.js +2 -2
  24. package/dist/components/Breadcrumbs.js +6 -6
  25. package/dist/components/Button.js +2 -2
  26. package/dist/components/Calendar.js +14 -14
  27. package/dist/components/Checkbox.js +6 -6
  28. package/dist/components/Collapsible.js +5 -5
  29. package/dist/components/ComboBox.js +10 -10
  30. package/dist/components/Command.js +11 -11
  31. package/dist/components/ContentCard.js +26 -26
  32. package/dist/components/ContentGrid.js +12 -12
  33. package/dist/components/DataList.js +2 -2
  34. package/dist/components/Dialog.js +5 -5
  35. package/dist/components/DropZone.js +3 -3
  36. package/dist/components/DropdownMenu.js +6 -6
  37. package/dist/components/Empty.js +3 -3
  38. package/dist/components/Field.d.ts +1 -1
  39. package/dist/components/Field.js +5 -4
  40. package/dist/components/List.d.ts +4 -1
  41. package/dist/components/List.js +31 -27
  42. package/dist/components/MediaPreview.js +2 -2
  43. package/dist/components/MultipleSelect.js +17 -17
  44. package/dist/components/NavRail.js +5 -5
  45. package/dist/components/NumberField.js +3 -3
  46. package/dist/components/Page.js +5 -5
  47. package/dist/components/PreviewFrame.js +6 -6
  48. package/dist/components/RadioGroup.js +6 -6
  49. package/dist/components/Resizable.js +3 -3
  50. package/dist/components/SearchField.js +4 -4
  51. package/dist/components/Select.js +9 -9
  52. package/dist/components/Sheet.d.ts +4 -2
  53. package/dist/components/Sheet.js +21 -7
  54. package/dist/components/Sidebar.js +5 -5
  55. package/dist/components/SortableList.js +10 -10
  56. package/dist/components/Spinner.js +3 -3
  57. package/dist/components/Surface.js +1 -1
  58. package/dist/components/Switch.js +4 -4
  59. package/dist/components/Table.d.ts +2 -0
  60. package/dist/components/Table.js +96 -64
  61. package/dist/components/Tabs.js +4 -4
  62. package/dist/components/TagGroup.js +6 -6
  63. package/dist/components/TextField.js +8 -8
  64. package/dist/components/TimeField.js +4 -41
  65. package/dist/components/Toolbar.js +1 -1
  66. package/dist/components/Tooltip.js +3 -3
  67. package/dist/components/Tree.js +28 -28
  68. package/dist/components/internal/DateControl.js +9 -9
  69. package/dist/components/internal/ListBoxGroup.js +2 -2
  70. package/dist/components/internal/ListBoxOption.js +9 -9
  71. package/dist/components/internal/PopoverSurface.js +2 -2
  72. package/dist/components/internal/SelectionCheckbox.js +3 -3
  73. package/dist/components/internal/ToggleButton.js +2 -2
  74. package/dist/config.d.ts +1 -0
  75. package/dist/config.js +10 -0
  76. package/dist/core/Config.d.ts +36 -1
  77. package/dist/core/Config.js +149 -9
  78. package/dist/core/Document.d.ts +5 -3
  79. package/dist/core/Document.js +6 -6
  80. package/dist/core/Field.d.ts +13 -2
  81. package/dist/core/Field.js +6 -2
  82. package/dist/core/Graph.d.ts +6 -0
  83. package/dist/core/Internal.d.ts +3 -0
  84. package/dist/core/Internal.js +4 -0
  85. package/dist/core/Overview.d.ts +8 -2
  86. package/dist/core/Root.d.ts +19 -6
  87. package/dist/core/Root.js +6 -4
  88. package/dist/core/Schema.js +7 -2
  89. package/dist/core/Scope.d.ts +7 -0
  90. package/dist/core/Scope.js +32 -5
  91. package/dist/core/Type.d.ts +22 -14
  92. package/dist/core/Type.js +13 -8
  93. package/dist/core/Validation.d.ts +5 -0
  94. package/dist/core/Validation.js +2 -1
  95. package/dist/core/db/LinkResolver.d.ts +3 -0
  96. package/dist/core/db/LocalStore.d.ts +12 -0
  97. package/dist/core/db/Operation.d.ts +6 -0
  98. package/dist/core/db/Operation.js +68 -14
  99. package/dist/core/db/SyncStats.d.ts +16 -0
  100. package/dist/core/db/SyncStats.js +56 -0
  101. package/dist/core/db/WriteableGraph.d.ts +1 -14
  102. package/dist/core/db/WriteableGraph.js +5 -3
  103. package/dist/core/field/ListField.js +4 -2
  104. package/dist/core/field/RecordField.js +4 -2
  105. package/dist/core/field/RichTextField.js +6 -5
  106. package/dist/core/field/UnionField.js +3 -2
  107. package/dist/core/media/CompressPdf.browser.js +1 -1
  108. package/dist/core/media/CompressPdf.js +1 -1
  109. package/dist/core/media/CreatePreview.browser.js +1 -1
  110. package/dist/core/media/FileAccept.d.ts +7 -0
  111. package/dist/core/media/FileAccept.js +29 -0
  112. package/dist/core/media/MediaRoot.js +2 -4
  113. package/dist/core/media/MediaTypes.d.ts +126 -2
  114. package/dist/core/media/MediaTypes.js +143 -42
  115. package/dist/core/media/Summary.d.ts +9 -9
  116. package/dist/core/media/Summary.js +10 -10
  117. package/dist/dashboard/App.js +3 -3
  118. package/dist/dashboard/app/ActivityStatus.js +12 -12
  119. package/dist/dashboard/app/AuthView.js +4 -4
  120. package/dist/dashboard/app/BlockSheet.js +5 -5
  121. package/dist/dashboard/app/BlockSheetStoryFrame.js +3 -3
  122. package/dist/dashboard/app/BlockTabs.d.ts +12 -0
  123. package/dist/dashboard/app/BlockTabs.js +26 -0
  124. package/dist/dashboard/app/CompactField.js +23 -22
  125. package/dist/dashboard/app/CroppedImage.js +3 -3
  126. package/dist/dashboard/app/DashboardErrorBoundary.js +2 -2
  127. package/dist/dashboard/app/DashboardLayout.js +3 -3
  128. package/dist/dashboard/app/EntryForm.d.ts +6 -0
  129. package/dist/dashboard/app/{SettingsTab.js → EntryForm.js} +9 -8
  130. package/dist/dashboard/app/EntryHeader.js +11 -11
  131. package/dist/dashboard/app/EntryReferences.js +3 -3
  132. package/dist/dashboard/app/EntrySidebar.js +15 -15
  133. package/dist/dashboard/app/EntrySidebarPreview.js +4 -4
  134. package/dist/dashboard/app/EntryStatusIcon.js +3 -3
  135. package/dist/dashboard/app/Explorer.d.ts +4 -3
  136. package/dist/dashboard/app/Explorer.js +68 -303
  137. package/dist/dashboard/app/ExplorerBatchActions.js +2 -2
  138. package/dist/dashboard/app/ExplorerBreadcrumbs.d.ts +13 -0
  139. package/dist/dashboard/app/ExplorerBreadcrumbs.js +119 -0
  140. package/dist/dashboard/app/ExplorerControls.js +5 -5
  141. package/dist/dashboard/app/ExplorerList.js +4 -4
  142. package/dist/dashboard/app/ExplorerModal.js +3 -3
  143. package/dist/dashboard/app/ExplorerScope.d.ts +7 -0
  144. package/dist/dashboard/app/ExplorerScope.js +159 -0
  145. package/dist/dashboard/app/ExplorerTable.js +8 -8
  146. package/dist/dashboard/app/ExplorerTabs.js +2 -2
  147. package/dist/dashboard/app/ImageEditor.js +27 -27
  148. package/dist/dashboard/app/LinkPicker.js +5 -2
  149. package/dist/dashboard/app/LocaleMenu.js +6 -6
  150. package/dist/dashboard/app/MediaPreviewCell.js +4 -4
  151. package/dist/dashboard/app/OverviewCell.js +11 -10
  152. package/dist/dashboard/app/PendingUploadsView.d.ts +1 -0
  153. package/dist/dashboard/app/PendingUploadsView.js +29 -5
  154. package/dist/dashboard/app/RemoveDialog.js +4 -4
  155. package/dist/dashboard/app/RemoveRedirect.js +2 -2
  156. package/dist/dashboard/app/SearchBar.js +1 -1
  157. package/dist/dashboard/app/SidebarTree.js +16 -16
  158. package/dist/dashboard/app/WorkspaceMenu.js +6 -6
  159. package/dist/dashboard/app/WorkspaceRoots.js +10 -10
  160. package/dist/dashboard/app/editor/FileEditor.js +67 -37
  161. package/dist/dashboard/app/editor/FilePreview.d.ts +4 -1
  162. package/dist/dashboard/app/editor/FilePreview.js +2 -4
  163. package/dist/dashboard/app/editor/MediaAltField.view.js +1 -1
  164. package/dist/dashboard/app/modals/CreateEntry.js +3 -3
  165. package/dist/dashboard/app/pages/EntryPage.js +19 -19
  166. package/dist/dashboard/app/pages/SplashPage.js +35 -35
  167. package/dist/dashboard/app/pages/UsersPage.js +7 -7
  168. package/dist/dashboard/app/ui/DashboardModal.js +15 -15
  169. package/dist/dashboard/atoms/config.d.ts +1 -1
  170. package/dist/dashboard/atoms/create.js +13 -8
  171. package/dist/dashboard/atoms/entry.d.ts +1 -1
  172. package/dist/dashboard/atoms/entry.js +15 -10
  173. package/dist/dashboard/atoms/explorer.d.ts +24 -7
  174. package/dist/dashboard/atoms/explorer.js +45 -25
  175. package/dist/dashboard/atoms/move.js +1 -2
  176. package/dist/dashboard/atoms/nav.js +18 -10
  177. package/dist/dashboard/atoms/overview.d.ts +4 -2
  178. package/dist/dashboard/atoms/overview.js +1 -0
  179. package/dist/dashboard/atoms/remove.js +3 -3
  180. package/dist/dashboard/atoms/upload.d.ts +15 -1
  181. package/dist/dashboard/atoms/upload.js +37 -13
  182. package/dist/dashboard/boot/DashboardWorker.js +3 -1
  183. package/dist/dashboard/cms/EntryTable.js +18 -13
  184. package/dist/dashboard/icons.d.ts +1 -0
  185. package/dist/dashboard/icons.js +20 -0
  186. package/dist/database/EntryDatabase.d.ts +5 -0
  187. package/dist/database/EntryDatabase.js +16 -10
  188. package/dist/database/EntryStore.js +31 -9
  189. package/dist/database/EntryTransaction.js +10 -5
  190. package/dist/database/query/EntryQuery.js +39 -2
  191. package/dist/database/query/ResolveQuery.d.ts +1 -1
  192. package/dist/database/query/ResolveQuery.js +9 -2
  193. package/dist/database/sync/Derive.d.ts +2 -1
  194. package/dist/database/sync/Derive.js +2 -1
  195. package/dist/database/sync/EntrySyncer.d.ts +2 -1
  196. package/dist/database/sync/EntrySyncer.js +8 -7
  197. package/dist/database/sync/Ingest.d.ts +2 -2
  198. package/dist/database/sync/Ingest.js +48 -33
  199. package/dist/field/check/CheckField.view.js +1 -0
  200. package/dist/field/code/CodeField.view.js +14 -13
  201. package/dist/field/link/FileLink.d.ts +2 -2
  202. package/dist/field/link/FileLink.js +7 -6
  203. package/dist/field/link/ImageLink.d.ts +9 -9
  204. package/dist/field/link/ImageLink.js +14 -23
  205. package/dist/field/link/LinkField.view.js +29 -21
  206. package/dist/field/list/ListField.d.ts +3 -2
  207. package/dist/field/list/ListField.view.js +32 -15
  208. package/dist/field/localiser/LocalisedField.view.js +23 -3
  209. package/dist/field/localiser/Localiser.d.ts +17 -1
  210. package/dist/field/localiser/Localiser.js +127 -0
  211. package/dist/field/metadata/MetadataField.view.js +18 -18
  212. package/dist/field/number/NumberField.view.js +3 -2
  213. package/dist/field/object/ObjectField.d.ts +3 -1
  214. package/dist/field/object/ObjectField.view.js +34 -13
  215. package/dist/field/richtext/PickTextLink.js +4 -14
  216. package/dist/field/richtext/RichTextBlock.js +3 -3
  217. package/dist/field/richtext/RichTextExtensions.js +26 -26
  218. package/dist/field/richtext/RichTextField.story.d.ts +1 -0
  219. package/dist/field/richtext/RichTextField.view.js +8 -7
  220. package/dist/field/richtext/RichTextInsertMenu.js +17 -3
  221. package/dist/field/tabs/Tabs.d.ts +12 -3
  222. package/dist/field/tabs/Tabs.js +11 -2
  223. package/dist/field.d.ts +1 -1
  224. package/dist/field.js +2 -1
  225. package/dist/index.css +178 -139
  226. package/dist/picker/entry/EntryPicker.d.ts +2 -1
  227. package/dist/picker/entry/EntryPicker.js +1 -1
  228. package/dist/preview/widget.d.ts +3 -0
  229. package/dist/preview/widget.js +26 -8
  230. package/dist/ui/RichText.js +31 -1
  231. package/docs/ai-setup.md +3 -3
  232. package/docs/components/list.md +2 -1
  233. package/docs/fields/list.md +9 -5
  234. package/docs/fields/tabs.md +24 -0
  235. package/docs/fields.md +2 -2
  236. package/docs/instant-publishing.md +14 -2
  237. package/docs/internationalization.md +31 -14
  238. package/docs/overviews.md +2 -1
  239. package/docs/query/structural.md +2 -1
  240. package/docs/quickstart.md +5 -5
  241. package/docs/schema/document.md +1 -1
  242. package/docs/schema/type.md +1 -1
  243. package/docs/upgrading.md +1 -1
  244. package/docs/workspaces/media.md +86 -0
  245. package/llms-full.txt +183 -37
  246. package/package.json +1 -1
  247. package/readme.md +2 -2
  248. package/dist/dashboard/app/BlockSettings.d.ts +0 -9
  249. package/dist/dashboard/app/BlockSettings.js +0 -16
  250. package/dist/dashboard/app/SettingsTab.d.ts +0 -6
  251. package/dist/chunks/{chunk-6FQ5IMNA.js → chunk-4ZA6KZHS.js} +3 -3
  252. /package/dist/chunks/{dist-OU2RRDGP.js → dist-IDG44KDI.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "3KgiHxzm2cdTeGlC66cfjP7DF7E",
2
+ "_id": "3LPm4jGH99HwrI2UuHOH2RWkGp8",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
@@ -1 +1 @@
1
- {"url":"http://localhost:1","pid":3049}
1
+ {"url":"http://localhost:1","pid":2823}
@@ -1 +1 @@
1
- {"url":"http://localhost:38103","pid":3049}
1
+ {"url":"http://localhost:44703","pid":2823}
@@ -15,6 +15,7 @@ import { CMS } from "alinea/core/CMS";
15
15
  import {
16
16
  withDevelopmentKey
17
17
  } from "alinea/core/Connection";
18
+ import { loggedSync, syncStats } from "alinea/core/db/SyncStats";
18
19
  import { outcome } from "alinea/core/Outcome";
19
20
  import { getScope } from "alinea/core/Scope";
20
21
  import { trace } from "alinea/core/Trace";
@@ -93,25 +94,27 @@ var NextCMS = class extends CMS {
93
94
  return { isBuild, useLocalDb: !isEdge && (!context.isDev || isBuild) };
94
95
  }
95
96
  /** Renders keep serving the current content when the handler is unreachable. */
96
- async #syncDb(db, client, stats) {
97
- if (stats)
98
- return stats.track(
99
- { kind: "sync", summary: "sync" },
100
- (row) => timed(row, () => this.#syncDb(db, client, void 0))
101
- );
102
- try {
103
- const sha = await within(
104
- db.syncWith(client, preValidatedRemote),
105
- syncWait
106
- );
107
- this.#syncedAt = Date.now();
108
- return sha;
109
- } catch (error) {
110
- console.warn(
111
- `Alinea could not sync with the handler, serving current content: ${error instanceof Error ? error.message : String(error)}`
112
- );
113
- return db.sha;
114
- }
97
+ async #syncDb(db, client, reason, render) {
98
+ const stats = syncStats();
99
+ const sync = async () => {
100
+ try {
101
+ const options = { ...preValidatedRemote, stats };
102
+ const synced = process.env.NODE_ENV === "production" ? loggedSync(db, client, reason, options) : db.syncWith(client, options);
103
+ const sha = await within(synced, syncWait);
104
+ this.#syncedAt = Date.now();
105
+ return sha;
106
+ } catch (error) {
107
+ console.warn(
108
+ `Alinea could not sync with the handler, serving current content: ${error instanceof Error ? error.message : String(error)}`
109
+ );
110
+ return db.sha;
111
+ }
112
+ };
113
+ if (!render) return sync();
114
+ return render.track(
115
+ { kind: "sync", summary: `sync (${reason})`, sync: stats },
116
+ (row) => timed(row, sync)
117
+ );
115
118
  }
116
119
  #applyPreview = cache(async () => {
117
120
  const context = await requestContext(this.config);
@@ -153,6 +156,7 @@ var NextCMS = class extends CMS {
153
156
  await this.#syncDb(
154
157
  db,
155
158
  createClient(this.config, context),
159
+ `preview at ${decoded.contentHash.slice(0, 7)}`,
156
160
  this.#render().stats
157
161
  );
158
162
  return applyPreviewUpdate(db, decoded);
@@ -184,7 +188,7 @@ var NextCMS = class extends CMS {
184
188
  async #resolve(query, row) {
185
189
  let status = query.status;
186
190
  const { context, hasPreview, isDraft, isBuild, preview, useLocalDb } = await this.#applyPreview();
187
- if (isDraft && !status) status = "preferDraft";
191
+ if (isDraft && !status) status = "preview";
188
192
  const request = { ...query, preview, status };
189
193
  const client = createClient(this.config, context);
190
194
  if (row) row.source = useLocalDb ? "database" : "handler";
@@ -214,7 +218,7 @@ var NextCMS = class extends CMS {
214
218
  } else {
215
219
  const tracked = {
216
220
  sha: db.sha,
217
- syncWith: () => this.#syncDb(db, client, stats)
221
+ syncWith: () => this.#syncDb(db, client, "stale", stats)
218
222
  };
219
223
  const settled = !isDraft && await syncIfStale(
220
224
  tracked,
@@ -223,7 +227,10 @@ var NextCMS = class extends CMS {
223
227
  contentShaWindow(this.config.syncInterval)
224
228
  );
225
229
  if (!settled)
226
- await this.throttle(() => this.#syncDb(db, client, stats), syncInterval);
230
+ await this.throttle(
231
+ () => this.#syncDb(db, client, "interval", stats),
232
+ syncInterval
233
+ );
227
234
  }
228
235
  return answer();
229
236
  }
@@ -52,6 +52,7 @@ function createHandlerWithDatabase(input, openGeneratedDatabase) {
52
52
  ...options,
53
53
  remote,
54
54
  db,
55
+ logSyncs: process.env.NODE_ENV === "production",
55
56
  afterCommit
56
57
  });
57
58
  async function handleDevelopment(request, context) {
@@ -32,6 +32,8 @@ export interface HandlerOptions extends HandlerHooks {
32
32
  cms: CMS;
33
33
  db: LocalStore | Promise<LocalStore>;
34
34
  remote?: (context: RequestContext) => RemoteConnection;
35
+ /** Log why and how long each sync took, for a deployed handler */
36
+ logSyncs?: boolean;
35
37
  forwardMutations?(request: Request, context: AuthedContext): Promise<Response | undefined>;
36
38
  }
37
- export declare function createHandler({ cms, remote, db, forwardMutations, ...hooks }: HandlerOptions): Handler;
39
+ export declare function createHandler({ cms, remote, db, forwardMutations, logSyncs, ...hooks }: HandlerOptions): Handler;
@@ -19,6 +19,7 @@ import {
19
19
  } from "alinea/core/BlobTransport";
20
20
  import { Config } from "alinea/core/Config";
21
21
  import { developmentKeyHeader } from "alinea/core/Connection";
22
+ import { loggedSync } from "alinea/core/db/SyncStats";
22
23
  import {
23
24
  committedEntries,
24
25
  removedEntries
@@ -26,7 +27,7 @@ import {
26
27
  import { Entry } from "alinea/core/Entry";
27
28
  import { ErrorCode, HttpError } from "alinea/core/HttpError";
28
29
  import { MediaLocation } from "alinea/core/media/MediaLocation";
29
- import { MediaFile } from "alinea/core/media/MediaTypes";
30
+ import { FileData } from "alinea/core/media/MediaTypes";
30
31
  import { assertUploadSize } from "alinea/core/media/UploadLimits";
31
32
  import { Permission, Policy } from "alinea/core/Role";
32
33
  import { getScope } from "alinea/core/Scope";
@@ -52,6 +53,7 @@ function createHandler({
52
53
  remote = (context) => new CloudRemote(context, cms.config),
53
54
  db,
54
55
  forwardMutations,
56
+ logSyncs = false,
55
57
  ...hooks
56
58
  }) {
57
59
  const throttle = createThrottledSync();
@@ -60,18 +62,22 @@ function createHandler({
60
62
  const local = await db;
61
63
  const simulateLatency = process.env.ALINEA_LATENCY;
62
64
  if (simulateLatency) await new Promise((resolve) => setTimeout(resolve, 2e3));
63
- async function syncForRead(sync) {
65
+ async function syncForRead(sync2) {
64
66
  try {
65
- await within(sync, syncWait);
67
+ await within(sync2, syncWait);
66
68
  } catch (error) {
67
69
  console.warn(
68
70
  `Alinea could not sync with the remote, serving current content: ${error instanceof Error ? error.message : String(error)}`
69
71
  );
70
72
  }
71
73
  }
74
+ function sync(remote2, reason) {
75
+ if (dev || !logSyncs) return local.syncWith(remote2);
76
+ return loggedSync(local, remote2, reason);
77
+ }
72
78
  async function periodicSync(cnx, syncInterval) {
73
79
  if (dev) return;
74
- return syncForRead(throttle(() => local.syncWith(cnx), syncInterval));
80
+ return syncForRead(throttle(() => sync(cnx, "interval"), syncInterval));
75
81
  }
76
82
  try {
77
83
  const previews = new JWTPreviews(context.apiKey);
@@ -109,11 +115,11 @@ function createHandler({
109
115
  url: Entry.url,
110
116
  filePath: Entry.filePath,
111
117
  workspace: Entry.workspace,
112
- location: MediaFile.location,
113
- previewUrl: MediaFile.previewUrl
118
+ location: FileData.location,
119
+ previewUrl: FileData.previewUrl
114
120
  };
115
121
  const query = {
116
- type: MediaFile,
122
+ type: Config.fileTypes(cms.config),
117
123
  status: "published",
118
124
  main: true,
119
125
  select
@@ -265,7 +271,9 @@ function createHandler({
265
271
  } else {
266
272
  const preview = await decodePreviewRequest(query.preview);
267
273
  if ("contentHash" in preview && await local.sha !== preview.contentHash)
268
- await syncForRead(local.syncWith(cnx));
274
+ await syncForRead(
275
+ sync(cnx, `preview at ${preview.contentHash.slice(0, 7)}`)
276
+ );
269
277
  query.preview = await applyPreview(local, preview);
270
278
  }
271
279
  return Response.json(await local.resolve(query) ?? null);
@@ -279,7 +287,7 @@ function createHandler({
279
287
  expectJson();
280
288
  const policy = await user.policy;
281
289
  let mutations = await body;
282
- await local.syncWith(cnx);
290
+ await sync(cnx, "commit");
283
291
  const adjusted = await hooks.beforeCommit?.({
284
292
  mutations,
285
293
  user: user.claims
@@ -287,7 +295,7 @@ function createHandler({
287
295
  if (adjusted) mutations = adjusted;
288
296
  const before = hooks.afterCommit ? await committedEntries(local, mutations) : [];
289
297
  const attempt = async (retry = 0) => {
290
- if (retry > 0) await local.syncWith(cnx);
298
+ if (retry > 0) await sync(cnx, "commit retry");
291
299
  const request2 = {
292
300
  ...await local.request(mutations, policy),
293
301
  user: user.claims
@@ -302,9 +310,9 @@ function createHandler({
302
310
  }
303
311
  try {
304
312
  if (sha2 === request2.intoSha) await local.write(request2);
305
- else sha2 = await local.syncWith(cnx);
313
+ else sha2 = await sync(cnx, "after commit");
306
314
  } catch {
307
- sha2 = await local.syncWith(cnx).catch(() => sha2);
315
+ sha2 = await sync(cnx, "after commit").catch(() => sha2);
308
316
  }
309
317
  return sha2;
310
318
  };
@@ -335,7 +343,7 @@ function createHandler({
335
343
  const owners = () => historyEntries(local, contentDir, file, record);
336
344
  let entries = await owners();
337
345
  if (entries.length === 0) {
338
- await syncForRead(local.syncWith(cnx));
346
+ await syncForRead(sync(cnx, "history of an unknown entry"));
339
347
  entries = await owners();
340
348
  }
341
349
  if (entries.length === 0)
@@ -349,26 +357,29 @@ function createHandler({
349
357
  expectJson();
350
358
  const sha = string(url.searchParams.get("sha"));
351
359
  let source = cnx;
360
+ const start = performance.now();
352
361
  try {
353
362
  const remoteTree = await cnx.getTreeIfDifferent(sha);
354
363
  if (!remoteTree) return Response.json(null);
355
364
  source = sourceAtTree(cnx, remoteTree);
356
365
  } catch {
357
366
  }
358
- await syncForRead(local.syncWith(source));
367
+ const remoteMs = Math.round(performance.now() - start);
368
+ const reason = `tree from ${sha.slice(0, 7)}, remote tree ${remoteMs} ms`;
369
+ await syncForRead(sync(source, reason));
359
370
  const tree = await local.getTreeIfDifferent(sha);
360
371
  return compressResponse(request, Response.json(tree ?? null));
361
372
  }
362
373
  if (action === HandleAction.Sha && request.method === "GET") {
363
374
  expectJson();
364
- await syncForRead(local.syncWith(cnx));
375
+ await syncForRead(sync(cnx, "sha"));
365
376
  return Response.json(await local.sha);
366
377
  }
367
378
  if (action === HandleAction.Blob && request.method === "POST") {
368
379
  const { shas } = object({ shas: array(string) })(await body);
369
380
  let tree = await local.source.getTree();
370
381
  if (!dev && shas.some((sha) => !tree.hasSha(sha))) {
371
- await syncForRead(local.syncWith(cnx));
382
+ await syncForRead(sync(cnx, "blobs of a newer tree"));
372
383
  tree = await local.source.getTree();
373
384
  }
374
385
  const fromLocal = [];
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  driver_exports
3
- } from "../../chunks/chunk-6FQ5IMNA.js";
4
- import "../../chunks/chunk-A2I6MCCS.js";
3
+ } from "../../chunks/chunk-4ZA6KZHS.js";
5
4
  import "../../chunks/chunk-VA6NC3MI.js";
5
+ import "../../chunks/chunk-A2I6MCCS.js";
6
6
  import "../../chunks/chunk-RAR44T5O.js";
7
7
  import "../../chunks/chunk-PTYZMV5G.js";
8
8
  import "../../chunks/chunk-N47Y62CI.js";
@@ -38,12 +38,12 @@ var GithubApi = class extends GithubSource {
38
38
  if (currentSha !== request.fromSha)
39
39
  throw new ShaMismatchError(currentSha, request.fromSha);
40
40
  const { user } = request;
41
- let commitMessage = request.description;
42
- if (user?.name && user.email) {
43
- commitMessage += `
41
+ let commitMessage = `${request.description}
44
42
 
43
+ Alinea-Content: ${request.intoSha}`;
44
+ if (user?.name && user.email)
45
+ commitMessage += `
45
46
  Co-authored-by: ${user.name} <${user.email}>`;
46
- }
47
47
  const newCommit = this.#options.author ? await this.#commitThroughRest(
48
48
  current,
49
49
  request.changes,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  driver_exports
3
- } from "../../chunks/chunk-6FQ5IMNA.js";
4
- import "../../chunks/chunk-A2I6MCCS.js";
3
+ } from "../../chunks/chunk-4ZA6KZHS.js";
5
4
  import "../../chunks/chunk-VA6NC3MI.js";
5
+ import "../../chunks/chunk-A2I6MCCS.js";
6
6
  import "../../chunks/chunk-RAR44T5O.js";
7
7
  import "../../chunks/chunk-PTYZMV5G.js";
8
8
  import "../../chunks/chunk-N47Y62CI.js";
@@ -12,8 +12,10 @@ async function createGeneratedDatabase(config, { database: db, fork, driver }) {
12
12
  includedAtBuild(filePath) {
13
13
  return initialTree?.has(filePath) ?? false;
14
14
  },
15
- // Nothing reopens the in-memory writes: skip storing the synced tree.
16
- recordsTree: false
15
+ // Nothing reopens the in-memory writes: skip storing the synced tree,
16
+ // and keep the statistics of the build instead of analyzing them.
17
+ recordsTree: false,
18
+ analyzes: false
17
19
  });
18
20
  try {
19
21
  await assertReadableData(db);