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.
- package/dist/.init/content/pages/welcome.json +1 -1
- package/dist/.mcp/later/dev.json +1 -1
- package/dist/.mcp/online/dev.json +1 -1
- package/dist/adapter/next/cms.js +29 -22
- package/dist/adapter/next/handler.js +1 -0
- package/dist/backend/Handler.d.ts +3 -1
- package/dist/backend/Handler.js +27 -16
- package/dist/backend/api/CreateBackend.js +2 -2
- package/dist/backend/api/GithubApi.js +4 -4
- package/dist/backend/api/database.js +2 -2
- package/dist/backend/store/GeneratedDatabase.js +4 -2
- package/dist/bundled.d.ts +507 -124
- package/dist/chunks/{chunk-XESQKG2I.js → chunk-4VKHBA57.js} +1 -1
- package/dist/cli/Generate.js +7 -2
- package/dist/cli/Mcp.js +1 -1
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/generate/LinkMediaFiles.js +3 -3
- package/dist/cli/generate/MediaLocations.js +3 -3
- package/dist/cli/serve/mcp/DevMcp.js +1 -1
- package/dist/cli/serve/mcp/McpTools.js +51 -28
- package/dist/cloud/CloudRemote.js +1 -1
- package/dist/components/Alert.js +2 -2
- package/dist/components/Breadcrumbs.js +6 -6
- package/dist/components/Button.js +2 -2
- package/dist/components/Calendar.js +14 -14
- package/dist/components/Checkbox.js +6 -6
- package/dist/components/Collapsible.js +5 -5
- package/dist/components/ComboBox.js +10 -10
- package/dist/components/Command.js +11 -11
- package/dist/components/ContentCard.js +26 -26
- package/dist/components/ContentGrid.js +12 -12
- package/dist/components/DataList.js +2 -2
- package/dist/components/Dialog.js +5 -5
- package/dist/components/DropZone.js +3 -3
- package/dist/components/DropdownMenu.js +6 -6
- package/dist/components/Empty.js +3 -3
- package/dist/components/Field.d.ts +1 -1
- package/dist/components/Field.js +5 -4
- package/dist/components/List.d.ts +4 -1
- package/dist/components/List.js +31 -27
- package/dist/components/MediaPreview.js +2 -2
- package/dist/components/MultipleSelect.js +17 -17
- package/dist/components/NavRail.js +5 -5
- package/dist/components/NumberField.js +3 -3
- package/dist/components/Page.js +5 -5
- package/dist/components/PreviewFrame.js +6 -6
- package/dist/components/RadioGroup.js +6 -6
- package/dist/components/Resizable.js +3 -3
- package/dist/components/SearchField.js +4 -4
- package/dist/components/Select.js +9 -9
- package/dist/components/Sheet.d.ts +4 -2
- package/dist/components/Sheet.js +21 -7
- package/dist/components/Sidebar.js +5 -5
- package/dist/components/SortableList.js +10 -10
- package/dist/components/Spinner.js +3 -3
- package/dist/components/Surface.js +1 -1
- package/dist/components/Switch.js +4 -4
- package/dist/components/Table.d.ts +2 -0
- package/dist/components/Table.js +96 -64
- package/dist/components/Tabs.js +4 -4
- package/dist/components/TagGroup.js +6 -6
- package/dist/components/TextField.js +8 -8
- package/dist/components/TimeField.js +4 -41
- package/dist/components/Toolbar.js +1 -1
- package/dist/components/Tooltip.js +3 -3
- package/dist/components/Tree.js +28 -28
- package/dist/components/internal/DateControl.js +9 -9
- package/dist/components/internal/ListBoxGroup.js +2 -2
- package/dist/components/internal/ListBoxOption.js +9 -9
- package/dist/components/internal/PopoverSurface.js +2 -2
- package/dist/components/internal/SelectionCheckbox.js +3 -3
- package/dist/components/internal/ToggleButton.js +2 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.js +10 -0
- package/dist/core/Config.d.ts +36 -1
- package/dist/core/Config.js +149 -9
- package/dist/core/Document.d.ts +5 -3
- package/dist/core/Document.js +6 -6
- package/dist/core/Field.d.ts +13 -2
- package/dist/core/Field.js +6 -2
- package/dist/core/Graph.d.ts +6 -0
- package/dist/core/Internal.d.ts +3 -0
- package/dist/core/Internal.js +4 -0
- package/dist/core/Overview.d.ts +8 -2
- package/dist/core/Root.d.ts +19 -6
- package/dist/core/Root.js +6 -4
- package/dist/core/Schema.js +7 -2
- package/dist/core/Scope.d.ts +7 -0
- package/dist/core/Scope.js +32 -5
- package/dist/core/Type.d.ts +22 -14
- package/dist/core/Type.js +13 -8
- package/dist/core/Validation.d.ts +5 -0
- package/dist/core/Validation.js +2 -1
- package/dist/core/db/LinkResolver.d.ts +3 -0
- package/dist/core/db/LocalStore.d.ts +12 -0
- package/dist/core/db/Operation.d.ts +6 -0
- package/dist/core/db/Operation.js +68 -14
- package/dist/core/db/SyncStats.d.ts +16 -0
- package/dist/core/db/SyncStats.js +56 -0
- package/dist/core/db/WriteableGraph.d.ts +1 -14
- package/dist/core/db/WriteableGraph.js +5 -3
- package/dist/core/field/ListField.js +4 -2
- package/dist/core/field/RecordField.js +4 -2
- package/dist/core/field/RichTextField.js +6 -5
- package/dist/core/field/UnionField.js +3 -2
- package/dist/core/media/CompressPdf.browser.js +1 -1
- package/dist/core/media/CompressPdf.js +1 -1
- package/dist/core/media/CreatePreview.browser.js +1 -1
- package/dist/core/media/FileAccept.d.ts +7 -0
- package/dist/core/media/FileAccept.js +29 -0
- package/dist/core/media/MediaRoot.js +2 -4
- package/dist/core/media/MediaTypes.d.ts +126 -2
- package/dist/core/media/MediaTypes.js +143 -42
- package/dist/core/media/Summary.d.ts +9 -9
- package/dist/core/media/Summary.js +10 -10
- package/dist/dashboard/App.js +3 -3
- package/dist/dashboard/app/ActivityStatus.js +12 -12
- package/dist/dashboard/app/AuthView.js +4 -4
- package/dist/dashboard/app/BlockSheet.js +5 -5
- package/dist/dashboard/app/BlockSheetStoryFrame.js +3 -3
- package/dist/dashboard/app/BlockTabs.d.ts +12 -0
- package/dist/dashboard/app/BlockTabs.js +26 -0
- package/dist/dashboard/app/CompactField.js +23 -22
- package/dist/dashboard/app/CroppedImage.js +3 -3
- package/dist/dashboard/app/DashboardErrorBoundary.js +2 -2
- package/dist/dashboard/app/DashboardLayout.js +3 -3
- package/dist/dashboard/app/EntryForm.d.ts +6 -0
- package/dist/dashboard/app/{SettingsTab.js → EntryForm.js} +9 -8
- package/dist/dashboard/app/EntryHeader.js +11 -11
- package/dist/dashboard/app/EntryReferences.js +3 -3
- package/dist/dashboard/app/EntrySidebar.js +15 -15
- package/dist/dashboard/app/EntrySidebarPreview.js +4 -4
- package/dist/dashboard/app/EntryStatusIcon.js +3 -3
- package/dist/dashboard/app/Explorer.d.ts +4 -3
- package/dist/dashboard/app/Explorer.js +68 -303
- package/dist/dashboard/app/ExplorerBatchActions.js +2 -2
- package/dist/dashboard/app/ExplorerBreadcrumbs.d.ts +13 -0
- package/dist/dashboard/app/ExplorerBreadcrumbs.js +119 -0
- package/dist/dashboard/app/ExplorerControls.js +5 -5
- package/dist/dashboard/app/ExplorerList.js +4 -4
- package/dist/dashboard/app/ExplorerModal.js +3 -3
- package/dist/dashboard/app/ExplorerScope.d.ts +7 -0
- package/dist/dashboard/app/ExplorerScope.js +159 -0
- package/dist/dashboard/app/ExplorerTable.js +8 -8
- package/dist/dashboard/app/ExplorerTabs.js +2 -2
- package/dist/dashboard/app/ImageEditor.js +27 -27
- package/dist/dashboard/app/LinkPicker.js +5 -2
- package/dist/dashboard/app/LocaleMenu.js +6 -6
- package/dist/dashboard/app/MediaPreviewCell.js +4 -4
- package/dist/dashboard/app/OverviewCell.js +11 -10
- package/dist/dashboard/app/PendingUploadsView.d.ts +1 -0
- package/dist/dashboard/app/PendingUploadsView.js +29 -5
- package/dist/dashboard/app/RemoveDialog.js +4 -4
- package/dist/dashboard/app/RemoveRedirect.js +2 -2
- package/dist/dashboard/app/SearchBar.js +1 -1
- package/dist/dashboard/app/SidebarTree.js +16 -16
- package/dist/dashboard/app/WorkspaceMenu.js +6 -6
- package/dist/dashboard/app/WorkspaceRoots.js +10 -10
- package/dist/dashboard/app/editor/FileEditor.js +67 -37
- package/dist/dashboard/app/editor/FilePreview.d.ts +4 -1
- package/dist/dashboard/app/editor/FilePreview.js +2 -4
- package/dist/dashboard/app/editor/MediaAltField.view.js +1 -1
- package/dist/dashboard/app/modals/CreateEntry.js +3 -3
- package/dist/dashboard/app/pages/EntryPage.js +19 -19
- package/dist/dashboard/app/pages/SplashPage.js +35 -35
- package/dist/dashboard/app/pages/UsersPage.js +7 -7
- package/dist/dashboard/app/ui/DashboardModal.js +15 -15
- package/dist/dashboard/atoms/config.d.ts +1 -1
- package/dist/dashboard/atoms/create.js +13 -8
- package/dist/dashboard/atoms/entry.d.ts +1 -1
- package/dist/dashboard/atoms/entry.js +15 -10
- package/dist/dashboard/atoms/explorer.d.ts +24 -7
- package/dist/dashboard/atoms/explorer.js +45 -25
- package/dist/dashboard/atoms/move.js +1 -2
- package/dist/dashboard/atoms/nav.js +18 -10
- package/dist/dashboard/atoms/overview.d.ts +4 -2
- package/dist/dashboard/atoms/overview.js +1 -0
- package/dist/dashboard/atoms/remove.js +3 -3
- package/dist/dashboard/atoms/upload.d.ts +15 -1
- package/dist/dashboard/atoms/upload.js +37 -13
- package/dist/dashboard/boot/DashboardWorker.js +3 -1
- package/dist/dashboard/cms/EntryTable.js +18 -13
- package/dist/dashboard/icons.d.ts +1 -0
- package/dist/dashboard/icons.js +20 -0
- package/dist/database/EntryDatabase.d.ts +5 -0
- package/dist/database/EntryDatabase.js +16 -10
- package/dist/database/EntryStore.js +31 -9
- package/dist/database/EntryTransaction.js +10 -5
- package/dist/database/query/EntryQuery.js +39 -2
- package/dist/database/query/ResolveQuery.d.ts +1 -1
- package/dist/database/query/ResolveQuery.js +9 -2
- package/dist/database/sync/Derive.d.ts +2 -1
- package/dist/database/sync/Derive.js +2 -1
- package/dist/database/sync/EntrySyncer.d.ts +2 -1
- package/dist/database/sync/EntrySyncer.js +8 -7
- package/dist/database/sync/Ingest.d.ts +2 -2
- package/dist/database/sync/Ingest.js +48 -33
- package/dist/field/check/CheckField.view.js +1 -0
- package/dist/field/code/CodeField.view.js +14 -13
- package/dist/field/link/FileLink.d.ts +2 -2
- package/dist/field/link/FileLink.js +7 -6
- package/dist/field/link/ImageLink.d.ts +9 -9
- package/dist/field/link/ImageLink.js +14 -23
- package/dist/field/link/LinkField.view.js +29 -21
- package/dist/field/list/ListField.d.ts +3 -2
- package/dist/field/list/ListField.view.js +32 -15
- package/dist/field/localiser/LocalisedField.view.js +23 -3
- package/dist/field/localiser/Localiser.d.ts +17 -1
- package/dist/field/localiser/Localiser.js +127 -0
- package/dist/field/metadata/MetadataField.view.js +18 -18
- package/dist/field/number/NumberField.view.js +3 -2
- package/dist/field/object/ObjectField.d.ts +3 -1
- package/dist/field/object/ObjectField.view.js +34 -13
- package/dist/field/richtext/PickTextLink.js +4 -14
- package/dist/field/richtext/RichTextBlock.js +3 -3
- package/dist/field/richtext/RichTextExtensions.js +26 -26
- package/dist/field/richtext/RichTextField.story.d.ts +1 -0
- package/dist/field/richtext/RichTextField.view.js +8 -7
- package/dist/field/richtext/RichTextInsertMenu.js +17 -3
- package/dist/field/tabs/Tabs.d.ts +12 -3
- package/dist/field/tabs/Tabs.js +11 -2
- package/dist/field.d.ts +1 -1
- package/dist/field.js +2 -1
- package/dist/index.css +178 -139
- package/dist/picker/entry/EntryPicker.d.ts +2 -1
- package/dist/picker/entry/EntryPicker.js +1 -1
- package/dist/preview/widget.d.ts +3 -0
- package/dist/preview/widget.js +26 -8
- package/dist/ui/RichText.js +31 -1
- package/docs/ai-setup.md +3 -3
- package/docs/components/list.md +2 -1
- package/docs/fields/list.md +9 -5
- package/docs/fields/tabs.md +24 -0
- package/docs/fields.md +2 -2
- package/docs/instant-publishing.md +14 -2
- package/docs/internationalization.md +31 -14
- package/docs/overviews.md +2 -1
- package/docs/query/structural.md +2 -1
- package/docs/quickstart.md +5 -5
- package/docs/schema/document.md +1 -1
- package/docs/schema/type.md +1 -1
- package/docs/upgrading.md +1 -1
- package/docs/workspaces/media.md +86 -0
- package/llms-full.txt +183 -37
- package/package.json +1 -1
- package/readme.md +2 -2
- package/dist/dashboard/app/BlockSettings.d.ts +0 -9
- package/dist/dashboard/app/BlockSettings.js +0 -16
- package/dist/dashboard/app/SettingsTab.d.ts +0 -6
- package/dist/chunks/{chunk-6FQ5IMNA.js → chunk-4ZA6KZHS.js} +3 -3
- /package/dist/chunks/{dist-OU2RRDGP.js → dist-IDG44KDI.js} +0 -0
package/dist/.mcp/later/dev.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"url":"http://localhost:1","pid":
|
|
1
|
+
{"url":"http://localhost:1","pid":2823}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"url":"http://localhost:
|
|
1
|
+
{"url":"http://localhost:44703","pid":2823}
|
package/dist/adapter/next/cms.js
CHANGED
|
@@ -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,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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 = "
|
|
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(
|
|
230
|
+
await this.throttle(
|
|
231
|
+
() => this.#syncDb(db, client, "interval", stats),
|
|
232
|
+
syncInterval
|
|
233
|
+
);
|
|
227
234
|
}
|
|
228
235
|
return answer();
|
|
229
236
|
}
|
|
@@ -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;
|
package/dist/backend/Handler.js
CHANGED
|
@@ -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 {
|
|
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(
|
|
65
|
+
async function syncForRead(sync2) {
|
|
64
66
|
try {
|
|
65
|
-
await within(
|
|
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(() =>
|
|
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:
|
|
113
|
-
previewUrl:
|
|
118
|
+
location: FileData.location,
|
|
119
|
+
previewUrl: FileData.previewUrl
|
|
114
120
|
};
|
|
115
121
|
const query = {
|
|
116
|
-
type:
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
313
|
+
else sha2 = await sync(cnx, "after commit");
|
|
306
314
|
} catch {
|
|
307
|
-
sha2 = await
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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-
|
|
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-
|
|
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
|
-
|
|
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);
|