alinea 2.0.0-preview.7 → 2.0.0-preview.9
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/LICENSES.md +103 -103
- package/dist/adapter/next/cms.d.ts +18 -4
- package/dist/adapter/next/cms.js +141 -36
- package/dist/adapter/next/handler.d.ts +5 -1
- package/dist/adapter/next/handler.js +77 -17
- package/dist/adapter/next/node.d.ts +5 -0
- package/dist/adapter/next/node.js +16 -0
- package/dist/adapter/next/previews.d.ts +4 -1
- package/dist/adapter/next/previews.js +13 -1
- package/dist/adapter/next/renderStats.d.ts +45 -0
- package/dist/adapter/next/renderStats.js +142 -0
- package/dist/adapter/next/syncCheck.d.ts +8 -2
- package/dist/adapter/next/syncCheck.js +5 -11
- package/dist/adapter/next/with-alinea.js +6 -20
- package/dist/backend/HandleAction.d.ts +1 -1
- package/dist/backend/HandleAction.js +1 -1
- package/dist/backend/Handler.d.ts +2 -2
- package/dist/backend/Handler.js +45 -47
- package/dist/backend/api/CreateBackend.js +15 -3
- package/dist/backend/api/DatabaseApi.js +22 -135
- package/dist/backend/api/ProxyMedia.d.ts +2 -3
- package/dist/backend/api/ProxyMedia.js +7 -22
- package/dist/backend/api/database.js +15 -3
- package/dist/backend/resolver/ParsePreview.d.ts +2 -2
- package/dist/backend/router/NodeHandler.js +2 -0
- package/dist/backend/store/GeneratedDatabase.d.ts +8 -0
- package/dist/backend/store/GeneratedDatabase.js +33 -0
- package/dist/backend/store/GeneratedDatabaseNode.d.ts +4 -0
- package/dist/backend/store/GeneratedDatabaseNode.js +35 -0
- package/dist/backend/util/ORM.js +4 -2
- package/dist/bundled.d.ts +1565 -468
- package/dist/chunks/bun-sqlite-5SHXN3AT.js +18 -0
- package/dist/chunks/chunk-2BJ2IFQM.js +1085 -0
- package/dist/chunks/chunk-2PIFHEYR.js +364 -0
- package/dist/chunks/chunk-66YZ47TY.js +94 -0
- package/dist/chunks/chunk-76VMZTLN.js +55 -0
- package/dist/chunks/chunk-AIU6CMVT.js +495 -0
- package/dist/chunks/chunk-ASYKC6IE.js +103 -0
- package/dist/chunks/chunk-ATF42T2B.js +35 -0
- package/dist/chunks/{chunk-6P4UVRPH.js → chunk-DWR5A5KL.js} +6 -1
- package/dist/chunks/{chunk-NWQXN4SB.js → chunk-ETBQTP2S.js} +40 -29
- package/dist/chunks/chunk-ETWOY4AL.js +100 -0
- package/dist/chunks/chunk-K62JP6HR.js +22 -0
- package/dist/chunks/chunk-MOWR65LM.js +610 -0
- package/dist/chunks/chunk-N47Y62CI.js +396 -0
- package/dist/chunks/chunk-QBPYWU6C.js +24 -0
- package/dist/chunks/{chunk-X47OVDF3.js → chunk-QJGGYF6E.js} +356 -1000
- package/dist/chunks/chunk-QSN6RH6X.js +94 -0
- package/dist/chunks/{chunk-I4GC3E65.js → chunk-UPY2RUZF.js} +0 -1
- package/dist/chunks/chunk-XCZXR3C2.js +112 -0
- package/dist/chunks/chunk-XTWYBWP2.js +81 -0
- package/dist/chunks/node-sqlite-XVNTNMCY.js +18 -0
- package/dist/cli/Generate.js +74 -64
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +6 -1
- package/dist/cli/generate/CopyStaticFiles.js +17 -14
- package/dist/cli/generate/DevDB.d.ts +22 -5
- package/dist/cli/generate/DevDB.js +138 -24
- package/dist/cli/serve/CreateLocalServer.js +22 -4
- package/dist/cli/serve/DevServer.d.ts +2 -0
- package/dist/cli/serve/DevServer.js +7 -2
- package/dist/cli/serve/LiveReload.d.ts +1 -1
- package/dist/cli/serve/LiveReload.js +3 -0
- package/dist/cloud/CloudRemote.js +2 -1
- package/dist/components/Breadcrumbs.js +2 -2
- package/dist/components/Calendar.js +7 -7
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/ColorSwatchPicker.js +2 -2
- package/dist/components/ComboBox.js +14 -14
- package/dist/components/DateField.js +1 -1
- package/dist/components/DatePicker.js +6 -6
- package/dist/components/DateRangePicker.js +4 -4
- package/dist/components/Disclosure.js +8 -8
- package/dist/components/Label.js +6 -6
- package/dist/components/List.js +33 -33
- package/dist/components/Menu.js +2 -2
- package/dist/components/Modal.js +2 -2
- package/dist/components/MultipleSelect.js +23 -23
- package/dist/components/NumberField.js +6 -6
- package/dist/components/ProgressCircle.js +3 -3
- package/dist/components/SearchField.js +8 -8
- package/dist/components/Select.js +8 -8
- package/dist/components/Surface.js +3 -3
- package/dist/components/Switch.js +2 -2
- package/dist/components/Table.js +7 -7
- package/dist/components/Tabs.js +2 -2
- package/dist/components/TagGroup.js +2 -2
- package/dist/components/TextField.js +2 -2
- package/dist/components/TimeField.js +3 -3
- package/dist/components/Toolbar.js +2 -2
- package/dist/components/Tooltip.js +4 -4
- package/dist/components/Tree.d.ts +2 -1
- package/dist/components/Tree.js +6 -6
- package/dist/core/Client.d.ts +1 -4
- package/dist/core/Client.js +5 -7
- package/dist/core/Connection.d.ts +4 -1
- package/dist/core/Connection.js +3 -1
- package/dist/core/Document.js +15 -3
- package/dist/core/Entry.d.ts +3 -0
- package/dist/core/Entry.js +4 -0
- package/dist/core/EntrySeed.d.ts +19 -0
- package/dist/core/EntrySeed.js +136 -0
- package/dist/core/Field.d.ts +7 -0
- package/dist/core/Field.js +4 -0
- package/dist/core/Filter.d.ts +40 -2
- package/dist/core/Filter.js +145 -0
- package/dist/core/Graph.d.ts +9 -0
- package/dist/core/ListRow.d.ts +1 -0
- package/dist/core/ListRow.js +1 -0
- package/dist/core/Reference.d.ts +1 -0
- package/dist/core/Root.js +1 -1
- package/dist/core/Scope.d.ts +2 -0
- package/dist/core/Scope.js +16 -1
- package/dist/core/Type.d.ts +2 -1
- package/dist/core/Type.js +13 -1
- package/dist/core/db/EntryAliases.js +1 -11
- package/dist/core/db/EntryReference.d.ts +0 -6
- package/dist/core/db/IndexEvent.d.ts +2 -1
- package/dist/core/db/IndexEvent.js +11 -3
- package/dist/core/db/LinkResolver.d.ts +6 -6
- package/dist/core/db/LinkResolver.js +0 -52
- package/dist/core/db/LocalStore.d.ts +27 -0
- package/dist/core/field/ListField.js +19 -0
- package/dist/core/field/RecordField.js +8 -0
- package/dist/core/field/RichTextField.js +42 -0
- package/dist/core/field/UnionField.js +8 -0
- package/dist/core/source/FSSource.d.ts +14 -2
- package/dist/core/source/FSSource.js +58 -13
- package/dist/core/source/GitUtils.d.ts +4 -0
- package/dist/core/source/GitUtils.js +9 -10
- package/dist/core/source/GithubSource.js +60 -21
- package/dist/core/source/IndexedDBSource.d.ts +2 -1
- package/dist/core/source/IndexedDBSource.js +67 -53
- package/dist/core/source/MemorySource.js +5 -3
- package/dist/core/source/OverlaySource.d.ts +5 -2
- package/dist/core/source/OverlaySource.js +31 -3
- package/dist/core/source/Source.d.ts +3 -0
- package/dist/core/source/Source.js +15 -2
- package/dist/core/source/Tree.d.ts +10 -7
- package/dist/core/source/Tree.js +118 -70
- package/dist/core/source/Utils.js +6 -3
- package/dist/core/util/Arrays.d.ts +1 -0
- package/dist/core/util/Arrays.js +10 -0
- package/dist/core/util/Async.d.ts +7 -0
- package/dist/core/util/Async.js +15 -0
- package/dist/core/util/Checks.js +1 -1
- package/dist/core/util/EntryFilenames.d.ts +22 -1
- package/dist/core/util/EntryFilenames.js +56 -2
- package/dist/core/util/IndexedDB.d.ts +4 -0
- package/dist/core/util/IndexedDB.js +20 -0
- package/dist/core/util/Paths.js +5 -1
- package/dist/dashboard/App.js +3 -3
- package/dist/dashboard/ViewKeys.d.ts +1 -0
- package/dist/dashboard/ViewKeys.js +1 -0
- package/dist/dashboard/app/AccessDenied.js +2 -2
- package/dist/dashboard/app/ActivityStatus.js +14 -14
- package/dist/dashboard/app/AppShell.js +2 -2
- package/dist/dashboard/app/AuthView.js +12 -12
- package/dist/dashboard/app/CompactField.js +11 -11
- package/dist/dashboard/app/DashboardErrorBoundary.js +6 -6
- package/dist/dashboard/app/DashboardLayout.js +3 -3
- package/dist/dashboard/app/EntryHeader.js +8 -8
- package/dist/dashboard/app/EntryReferences.js +8 -8
- package/dist/dashboard/app/EntrySidebar.js +15 -15
- package/dist/dashboard/app/EntrySidebarPreview.js +7 -7
- package/dist/dashboard/app/EntryTranslationBanner.js +5 -5
- package/dist/dashboard/app/Explorer.js +39 -39
- package/dist/dashboard/app/ExplorerCards.js +31 -31
- package/dist/dashboard/app/ExplorerFileCard.js +19 -19
- package/dist/dashboard/app/ExplorerList.js +10 -10
- package/dist/dashboard/app/ExplorerModal.js +5 -5
- package/dist/dashboard/app/ExplorerTable.js +47 -47
- package/dist/dashboard/app/LinkPicker.js +5 -5
- package/dist/dashboard/app/LocaleMenu.js +4 -4
- package/dist/dashboard/app/SidebarTree.js +76 -40
- package/dist/dashboard/app/WorkspaceMenu.js +9 -9
- package/dist/dashboard/app/WorkspaceRoots.js +22 -22
- package/dist/dashboard/app/editor/FileEditor.js +28 -28
- package/dist/dashboard/app/editor/FilePreview.js +6 -6
- package/dist/dashboard/app/modals/CreateEntry.js +3 -3
- package/dist/dashboard/app/pages/EntryPage.js +18 -18
- package/dist/dashboard/app/pages/RootPage.js +3 -3
- package/dist/dashboard/app/pages/SplashPage.js +45 -45
- package/dist/dashboard/app/pages/UsersPage.js +34 -34
- package/dist/dashboard/app/ui/DashboardModal.js +18 -18
- package/dist/dashboard/app/ui/Rail.js +5 -5
- package/dist/dashboard/app/ui/Sidebar.js +2 -2
- package/dist/dashboard/atoms/config.d.ts +4 -4
- package/dist/dashboard/atoms/entry.d.ts +8 -9
- package/dist/dashboard/atoms/entry.js +34 -4
- package/dist/dashboard/atoms/explorer.d.ts +2 -0
- package/dist/dashboard/atoms/explorer.js +7 -2
- package/dist/dashboard/boot/Boot.js +2 -3
- package/dist/dashboard/boot/DashboardWorker.d.ts +3 -3
- package/dist/dashboard/boot/DashboardWorker.js +82 -27
- package/dist/dashboard/boot/LoadWorker.js +2 -3
- package/dist/dashboard/boot/WorkerDB.d.ts +2 -2
- package/dist/dashboard/icons.d.ts +2 -0
- package/dist/dashboard/icons.js +40 -0
- package/dist/dashboard/plugins/alineaFixturePlugin.js +14 -3
- package/dist/database/BrowserEntryStore.d.ts +42 -0
- package/dist/database/BrowserEntryStore.js +182 -0
- package/dist/database/DatabaseSource.d.ts +13 -0
- package/dist/database/DatabaseSource.js +25 -0
- package/dist/database/DatabaseTables.d.ts +38 -0
- package/dist/database/DatabaseTables.js +53 -0
- package/dist/database/EntryDatabase.d.ts +97 -0
- package/dist/database/EntryDatabase.js +528 -0
- package/dist/database/EntryStore.d.ts +58 -0
- package/dist/database/EntryStore.js +230 -0
- package/dist/database/EntryTransaction.d.ts +33 -0
- package/dist/database/EntryTransaction.js +907 -0
- package/dist/database/EntryUrlAliases.d.ts +2 -0
- package/dist/database/EntryUrlAliases.js +69 -0
- package/dist/database/LocalDB.d.ts +39 -0
- package/dist/database/LocalDB.js +79 -0
- package/dist/database/Version.d.ts +9 -0
- package/dist/database/Version.js +13 -0
- package/dist/database/driver/DatabaseHandle.d.ts +17 -0
- package/dist/database/driver/DatabaseHandle.js +0 -0
- package/dist/database/driver/OverlayExtension.browser.d.ts +2 -0
- package/dist/database/driver/OverlayExtension.browser.js +9 -0
- package/dist/database/driver/OverlayExtension.d.ts +1 -0
- package/dist/database/driver/OverlayExtension.js +7 -0
- package/dist/database/driver/RuntimeDatabase.d.ts +13 -0
- package/dist/database/driver/RuntimeDatabase.js +77 -0
- package/dist/database/driver/WasmDatabase.d.ts +29 -0
- package/dist/database/driver/WasmDatabase.js +46 -0
- package/dist/database/entry/EntryData.d.ts +13 -0
- package/dist/database/entry/EntryData.js +51 -0
- package/dist/database/entry/EntryTable.d.ts +189 -0
- package/dist/database/entry/EntryTable.js +186 -0
- package/dist/database/query/Condition.d.ts +8 -0
- package/dist/database/query/Condition.js +117 -0
- package/dist/database/query/EntryQuery.d.ts +44 -0
- package/dist/database/query/EntryQuery.js +412 -0
- package/dist/database/query/EntryReferences.d.ts +5 -0
- package/dist/database/query/EntryReferences.js +70 -0
- package/dist/database/query/Relation.d.ts +11 -0
- package/dist/database/query/Relation.js +113 -0
- package/dist/database/query/ResolveQuery.d.ts +12 -0
- package/dist/database/query/ResolveQuery.js +189 -0
- package/dist/database/query/Search.d.ts +38 -0
- package/dist/database/query/Search.js +149 -0
- package/dist/database/sync/Derive.d.ts +8 -0
- package/dist/database/sync/Derive.js +270 -0
- package/dist/database/sync/EntryParser.d.ts +8 -0
- package/dist/database/sync/EntryParser.js +90 -0
- package/dist/database/sync/EntrySyncer.d.ts +25 -0
- package/dist/database/sync/EntrySyncer.js +89 -0
- package/dist/database/sync/Ingest.d.ts +21 -0
- package/dist/database/sync/Ingest.js +145 -0
- package/dist/database/sync/SyncQueries.d.ts +160 -0
- package/dist/database/sync/SyncQueries.js +216 -0
- package/dist/field/check/CheckField.view.js +2 -2
- package/dist/field/code/CodeField.view.js +10 -10
- package/dist/field/link/LinkField.js +23 -0
- package/dist/field/link/LinkField.view.js +42 -41
- package/dist/field/list/ListField.view.js +172 -150
- package/dist/field/metadata/MetadataField.d.ts +28 -3
- package/dist/field/metadata/MetadataField.js +44 -7
- package/dist/field/metadata/MetadataField.view.d.ts +5 -0
- package/dist/field/metadata/MetadataField.view.js +31 -16
- package/dist/field/richtext/RichTextDocument.js +4 -3
- package/dist/field/richtext/RichTextExtensions.d.ts +1 -1
- package/dist/field/richtext/RichTextExtensions.js +33 -29
- package/dist/field/richtext/RichTextField.view.js +17 -8
- package/dist/field/richtext/RichTextInsertMenu.js +2 -2
- package/dist/field/views.js +2 -0
- package/dist/next.cjs +6 -20
- package/dist/next.d.ts +4 -3
- package/dist/next.edge.d.ts +1 -1
- package/dist/next.js +1 -2
- package/dist/picker/entry/EntryPicker.js +2 -1
- package/dist/picker/url/UrlPicker.js +1 -0
- package/dist/preview/widget.d.ts +45 -0
- package/dist/preview/widget.js +96 -1
- package/dist/query.d.ts +28 -0
- package/package.json +6 -1
- package/dist/adapter/next/DevRemote.d.ts +0 -3
- package/dist/adapter/next/DevRemote.js +0 -45
- package/dist/backend/store/GeneratedSource.d.ts +0 -2
- package/dist/backend/store/GeneratedSource.js +0 -21
- package/dist/chunks/chunk-G6E35DMJ.js +0 -1997
- package/dist/core/db/EntryDB.d.ts +0 -19
- package/dist/core/db/EntryDB.js +0 -48
- package/dist/core/db/EntryIndex.d.ts +0 -143
- package/dist/core/db/EntryIndex.js +0 -2773
- package/dist/core/db/EntryReferenceIndex.d.ts +0 -21
- package/dist/core/db/EntryReferenceIndex.js +0 -131
- package/dist/core/db/EntryResolver.d.ts +0 -56
- package/dist/core/db/EntryResolver.js +0 -699
- package/dist/core/db/EntryTarget.d.ts +0 -5
- package/dist/core/db/EntryTransaction.d.ts +0 -31
- package/dist/core/db/EntryTransaction.js +0 -956
- package/dist/core/db/LocalDB.d.ts +0 -42
- package/dist/core/db/LocalDB.js +0 -127
- package/dist/core/db/TestDB.d.ts +0 -19
- package/dist/core/db/TestDB.js +0 -50
- /package/dist/core/db/{EntryTarget.js → LocalStore.js} +0 -0
package/dist/backend/Handler.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
object,
|
|
5
5
|
optional,
|
|
6
6
|
string
|
|
7
|
-
} from "../chunks/chunk-
|
|
7
|
+
} from "../chunks/chunk-UPY2RUZF.js";
|
|
8
8
|
import {
|
|
9
9
|
PLazy
|
|
10
10
|
} from "../chunks/chunk-IKINPSS5.js";
|
|
@@ -19,8 +19,10 @@ 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 { Entry } from "alinea/core/Entry";
|
|
22
23
|
import { ErrorCode, HttpError } from "alinea/core/HttpError";
|
|
23
24
|
import { MediaLocation } from "alinea/core/media/MediaLocation";
|
|
25
|
+
import { MediaFile } from "alinea/core/media/MediaTypes";
|
|
24
26
|
import { assertUploadSize } from "alinea/core/media/UploadLimits";
|
|
25
27
|
import { Permission, Policy } from "alinea/core/Role";
|
|
26
28
|
import { getScope } from "alinea/core/Scope";
|
|
@@ -30,7 +32,7 @@ import { isRecord } from "alinea/core/util/Objects";
|
|
|
30
32
|
import { isAbsolute, normalize } from "alinea/core/util/Paths";
|
|
31
33
|
import { InvalidCredentialsError, MissingCredentialsError } from "./Auth.js";
|
|
32
34
|
import { HandleAction } from "./HandleAction.js";
|
|
33
|
-
import {
|
|
35
|
+
import { proxyMediaUrl } from "./api/ProxyMedia.js";
|
|
34
36
|
import { applyPreview, decodePreviewRequest } from "./resolver/ParsePreview.js";
|
|
35
37
|
import { compressResponse } from "./router/Router.js";
|
|
36
38
|
import { createThrottledSync } from "./util/Syncable.js";
|
|
@@ -51,9 +53,18 @@ function createHandler({
|
|
|
51
53
|
const local = await db;
|
|
52
54
|
const simulateLatency = process.env.ALINEA_LATENCY;
|
|
53
55
|
if (simulateLatency) await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
56
|
+
async function syncForRead(cnx) {
|
|
57
|
+
try {
|
|
58
|
+
await local.syncWith(cnx);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.warn(
|
|
61
|
+
`Alinea could not sync with the remote, serving current content: ${error instanceof Error ? error.message : String(error)}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
54
65
|
async function periodicSync(cnx, syncInterval) {
|
|
55
66
|
if (dev) return;
|
|
56
|
-
return throttle(() =>
|
|
67
|
+
return throttle(() => syncForRead(cnx), syncInterval);
|
|
57
68
|
}
|
|
58
69
|
try {
|
|
59
70
|
const previews = new JWTPreviews(context.apiKey);
|
|
@@ -87,23 +98,33 @@ function createHandler({
|
|
|
87
98
|
throw new HttpError(400, "Invalid file path");
|
|
88
99
|
await periodicSync(cnx);
|
|
89
100
|
const requestedUrl = Config.filePathname(cms.config, normalized);
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
const select = {
|
|
102
|
+
url: Entry.url,
|
|
103
|
+
filePath: Entry.filePath,
|
|
104
|
+
workspace: Entry.workspace,
|
|
105
|
+
location: MediaFile.location,
|
|
106
|
+
previewUrl: MediaFile.previewUrl
|
|
107
|
+
};
|
|
108
|
+
const query = {
|
|
109
|
+
type: MediaFile,
|
|
110
|
+
status: "published",
|
|
111
|
+
main: true,
|
|
112
|
+
select
|
|
113
|
+
};
|
|
114
|
+
const entry = await local.first({ ...query, url: requestedUrl }) ?? await local.first({ ...query, alias: requestedUrl });
|
|
94
115
|
if (!entry) return new Response("Not found", { status: 404 });
|
|
95
116
|
if (entry.url !== requestedUrl && !proxy)
|
|
96
117
|
return new Response(null, {
|
|
97
118
|
status: 308,
|
|
98
119
|
headers: { location: entry.url }
|
|
99
120
|
});
|
|
100
|
-
const wasBuilt = local.
|
|
101
|
-
const previewUrl = entry.
|
|
102
|
-
const location = entry.
|
|
121
|
+
const wasBuilt = await local.includedAtBuild(entry.filePath);
|
|
122
|
+
const previewUrl = entry.previewUrl;
|
|
123
|
+
const location = entry.location;
|
|
103
124
|
if (typeof location !== "string")
|
|
104
125
|
return new Response("Not found", { status: 404 });
|
|
105
126
|
const previewSource = typeof previewUrl === "string" && previewUrl ? new URL(previewUrl, request.url).href : void 0;
|
|
106
|
-
async function proxyMedia(source2, cacheControl
|
|
127
|
+
async function proxyMedia(source2, cacheControl) {
|
|
107
128
|
const previewEntryId = uploadPreviewEntryId(
|
|
108
129
|
source2,
|
|
109
130
|
context.handlerUrl
|
|
@@ -114,13 +135,12 @@ function createHandler({
|
|
|
114
135
|
} else {
|
|
115
136
|
response = await proxyMediaUrl(
|
|
116
137
|
request,
|
|
117
|
-
new URL(source2, request.url)
|
|
118
|
-
isAllowed
|
|
138
|
+
new URL(source2, request.url)
|
|
119
139
|
);
|
|
120
140
|
}
|
|
121
141
|
return mediaResponse(request, response, cacheControl);
|
|
122
142
|
}
|
|
123
|
-
if (!wasBuilt && previewSource) {
|
|
143
|
+
if (!context.isDev && !wasBuilt && previewSource) {
|
|
124
144
|
if (proxy) return proxyMedia(previewSource, "private, no-store");
|
|
125
145
|
return redirectFile(previewSource, "private, no-store");
|
|
126
146
|
}
|
|
@@ -132,18 +152,10 @@ function createHandler({
|
|
|
132
152
|
if (!source || source === requestedUrl)
|
|
133
153
|
return new Response("Not found", { status: 404 });
|
|
134
154
|
if (!proxy) return redirectFile(source, "public, max-age=60");
|
|
135
|
-
const
|
|
136
|
-
cms.config,
|
|
137
|
-
context.isDev ? "development" : "production"
|
|
138
|
-
);
|
|
139
|
-
const deliveryBase = configuredBase ?? context.handlerUrl;
|
|
140
|
-
const sourceUrl = new URL(source, deliveryBase);
|
|
141
|
-
const deliveryOrigin = new URL(deliveryBase).origin;
|
|
142
|
-
const handlerPath = context.handlerUrl.pathname;
|
|
155
|
+
const deliveryBase = !context.isDev && Config.baseUrl(cms.config, "production") || context.handlerUrl;
|
|
143
156
|
return proxyMedia(
|
|
144
|
-
|
|
145
|
-
"public, max-age=60"
|
|
146
|
-
(url2) => url2.origin === deliveryOrigin && url2.pathname !== handlerPath && !url2.pathname.startsWith(`${handlerPath}/`)
|
|
157
|
+
new URL(source, deliveryBase).href,
|
|
158
|
+
"public, max-age=60"
|
|
147
159
|
);
|
|
148
160
|
}
|
|
149
161
|
const action = params.get("action");
|
|
@@ -245,8 +257,8 @@ function createHandler({
|
|
|
245
257
|
);
|
|
246
258
|
} else {
|
|
247
259
|
const preview = await decodePreviewRequest(query.preview);
|
|
248
|
-
if ("contentHash" in preview && local.sha !== preview.contentHash)
|
|
249
|
-
await
|
|
260
|
+
if ("contentHash" in preview && await local.sha !== preview.contentHash)
|
|
261
|
+
await syncForRead(cnx);
|
|
250
262
|
query.preview = await applyPreview(local, preview);
|
|
251
263
|
}
|
|
252
264
|
return Response.json(await local.resolve(query) ?? null);
|
|
@@ -294,23 +306,6 @@ function createHandler({
|
|
|
294
306
|
}
|
|
295
307
|
return Response.json({ sha });
|
|
296
308
|
}
|
|
297
|
-
if (action === HandleAction.Commit && request.method === "POST") {
|
|
298
|
-
if (!context.isDev)
|
|
299
|
-
throw new HttpError(400, "Commits are only accepted in development");
|
|
300
|
-
const developmentKey = request.headers.get(developmentKeyHeader);
|
|
301
|
-
if (!context.apiKey || developmentKey !== context.apiKey)
|
|
302
|
-
throw new HttpError(401, "Invalid development commit credentials");
|
|
303
|
-
const user = expectUser();
|
|
304
|
-
expectJson();
|
|
305
|
-
const commit = {
|
|
306
|
-
...await body,
|
|
307
|
-
user: user.claims
|
|
308
|
-
};
|
|
309
|
-
let { sha } = await cnx.write(commit);
|
|
310
|
-
if (sha === commit.intoSha) await local.write(commit);
|
|
311
|
-
else sha = await local.syncWith(cnx);
|
|
312
|
-
return Response.json({ sha });
|
|
313
|
-
}
|
|
314
309
|
if (action === HandleAction.History && request.method === "GET") {
|
|
315
310
|
expectUser();
|
|
316
311
|
expectJson();
|
|
@@ -322,10 +317,15 @@ function createHandler({
|
|
|
322
317
|
if (action === HandleAction.Tree && request.method === "GET") {
|
|
323
318
|
expectJson();
|
|
324
319
|
const sha = string(url.searchParams.get("sha"));
|
|
325
|
-
await
|
|
320
|
+
await syncForRead(cnx);
|
|
326
321
|
const tree = await local.getTreeIfDifferent(sha);
|
|
327
322
|
return compressResponse(request, Response.json(tree ?? null));
|
|
328
323
|
}
|
|
324
|
+
if (action === HandleAction.Sha && request.method === "GET") {
|
|
325
|
+
expectJson();
|
|
326
|
+
await syncForRead(cnx);
|
|
327
|
+
return Response.json(await local.sha);
|
|
328
|
+
}
|
|
329
329
|
if (action === HandleAction.Blob && request.method === "POST") {
|
|
330
330
|
const { shas } = object({ shas: array(string) })(await body);
|
|
331
331
|
await periodicSync(cnx);
|
|
@@ -431,8 +431,6 @@ function uploadPreviewEntryId(previewSource, handlerUrl) {
|
|
|
431
431
|
return previewUrl.searchParams.get("entryId") ?? void 0;
|
|
432
432
|
}
|
|
433
433
|
function mediaResponse(request, upstream, cacheControl) {
|
|
434
|
-
if (isRedirectStatus(upstream.status))
|
|
435
|
-
return new Response("Media backend returned a redirect", { status: 502 });
|
|
436
434
|
const responseHeaders = new Headers({
|
|
437
435
|
"cache-control": upstream.ok || upstream.status === 304 ? cacheControl : "no-store"
|
|
438
436
|
});
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
driver_exports
|
|
3
|
-
} from "../../chunks/chunk-
|
|
4
|
-
import "../../chunks/chunk-
|
|
5
|
-
import "../../chunks/chunk-
|
|
3
|
+
} from "../../chunks/chunk-QJGGYF6E.js";
|
|
4
|
+
import "../../chunks/chunk-QSN6RH6X.js";
|
|
5
|
+
import "../../chunks/chunk-ETWOY4AL.js";
|
|
6
|
+
import "../../chunks/chunk-66YZ47TY.js";
|
|
7
|
+
import "../../chunks/chunk-AIU6CMVT.js";
|
|
8
|
+
import "../../chunks/chunk-N47Y62CI.js";
|
|
9
|
+
import "../../chunks/chunk-QBPYWU6C.js";
|
|
10
|
+
import "../../chunks/chunk-2BJ2IFQM.js";
|
|
11
|
+
import "../../chunks/chunk-XCZXR3C2.js";
|
|
12
|
+
import "../../chunks/chunk-MOWR65LM.js";
|
|
13
|
+
import "../../chunks/chunk-76VMZTLN.js";
|
|
14
|
+
import "../../chunks/chunk-2PIFHEYR.js";
|
|
15
|
+
import "../../chunks/chunk-K62JP6HR.js";
|
|
16
|
+
import "../../chunks/chunk-ATF42T2B.js";
|
|
17
|
+
import "../../chunks/chunk-ETBQTP2S.js";
|
|
6
18
|
import "../../chunks/chunk-CQ52GEHY.js";
|
|
7
19
|
|
|
8
20
|
// src/backend/api/CreateBackend.ts
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
include
|
|
3
|
+
} from "../../chunks/chunk-XTWYBWP2.js";
|
|
4
|
+
import {
|
|
5
|
+
blob,
|
|
6
|
+
id,
|
|
7
|
+
integer,
|
|
8
|
+
text,
|
|
9
|
+
varchar
|
|
10
|
+
} from "../../chunks/chunk-ASYKC6IE.js";
|
|
11
|
+
import {
|
|
12
|
+
Builder
|
|
13
|
+
} from "../../chunks/chunk-2BJ2IFQM.js";
|
|
14
|
+
import {
|
|
15
|
+
eq
|
|
16
|
+
} from "../../chunks/chunk-XCZXR3C2.js";
|
|
17
|
+
import {
|
|
11
18
|
table
|
|
12
|
-
} from "../../chunks/chunk-
|
|
19
|
+
} from "../../chunks/chunk-MOWR65LM.js";
|
|
20
|
+
import "../../chunks/chunk-76VMZTLN.js";
|
|
21
|
+
import "../../chunks/chunk-2PIFHEYR.js";
|
|
22
|
+
import "../../chunks/chunk-K62JP6HR.js";
|
|
23
|
+
import "../../chunks/chunk-ATF42T2B.js";
|
|
13
24
|
import {
|
|
14
|
-
getData,
|
|
15
|
-
internalData,
|
|
16
|
-
internalSql,
|
|
17
25
|
sql
|
|
18
|
-
} from "../../chunks/chunk-
|
|
26
|
+
} from "../../chunks/chunk-ETBQTP2S.js";
|
|
19
27
|
import {
|
|
20
28
|
PLazy
|
|
21
29
|
} from "../../chunks/chunk-IKINPSS5.js";
|
|
@@ -26,127 +34,6 @@ import { createId } from "alinea/core/Id";
|
|
|
26
34
|
import { assert } from "alinea/core/util/Assert";
|
|
27
35
|
import { basename, extname } from "alinea/core/util/Paths";
|
|
28
36
|
import { slugify } from "alinea/core/util/Slugs";
|
|
29
|
-
|
|
30
|
-
// node_modules/rado/dist/universal/columns.js
|
|
31
|
-
var idType = new ColumnType(
|
|
32
|
-
"id",
|
|
33
|
-
[],
|
|
34
|
-
sql.universal({
|
|
35
|
-
sqlite: sql`integer`,
|
|
36
|
-
postgres: sql`integer generated always as identity`,
|
|
37
|
-
mysql: sql`int not null auto_increment`
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
var blobType = new ColumnType(
|
|
41
|
-
"blob",
|
|
42
|
-
[],
|
|
43
|
-
sql.universal({
|
|
44
|
-
postgres: sql`bytea`,
|
|
45
|
-
default: sql`blob`
|
|
46
|
-
})
|
|
47
|
-
);
|
|
48
|
-
var numberType = new ColumnType(
|
|
49
|
-
"number",
|
|
50
|
-
[],
|
|
51
|
-
sql.universal({
|
|
52
|
-
mysql: sql`double`,
|
|
53
|
-
default: sql`numeric`
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
var jsonbType = new ColumnType(
|
|
57
|
-
"json",
|
|
58
|
-
[],
|
|
59
|
-
sql.universal({
|
|
60
|
-
mysql: sql`json`,
|
|
61
|
-
default: sql`jsonb`
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
function id(name) {
|
|
65
|
-
return new Column({
|
|
66
|
-
name,
|
|
67
|
-
type: idType,
|
|
68
|
-
primary: true,
|
|
69
|
-
notNull: true
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function text(name) {
|
|
73
|
-
return new Column({ name, type: column.text() });
|
|
74
|
-
}
|
|
75
|
-
function varchar(name, options) {
|
|
76
|
-
return new Column({ name, type: column.varchar(options?.length) });
|
|
77
|
-
}
|
|
78
|
-
function integer(name) {
|
|
79
|
-
return new Column({ name, type: column.integer() });
|
|
80
|
-
}
|
|
81
|
-
function blob(name) {
|
|
82
|
-
return new Column({
|
|
83
|
-
name,
|
|
84
|
-
type: blobType,
|
|
85
|
-
mapFromDriverValue(value) {
|
|
86
|
-
return new Uint8Array(value);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// node_modules/rado/dist/core/expr/Include.js
|
|
92
|
-
var Include = class {
|
|
93
|
-
[internalData];
|
|
94
|
-
constructor(data) {
|
|
95
|
-
this[internalData] = data;
|
|
96
|
-
}
|
|
97
|
-
#mapFromDriverValue = (value, specs) => {
|
|
98
|
-
const query = getData(this);
|
|
99
|
-
const parsed = specs.parsesJson ? value : JSON.parse(value);
|
|
100
|
-
const selected = querySelection(query);
|
|
101
|
-
if (query.first) {
|
|
102
|
-
const result = parsed ? selected.mapRow({ values: parsed, index: 0, specs }) : null;
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
if (!parsed) return [];
|
|
106
|
-
const rows = parsed;
|
|
107
|
-
const ctx = {
|
|
108
|
-
values: void 0,
|
|
109
|
-
index: 0,
|
|
110
|
-
specs
|
|
111
|
-
};
|
|
112
|
-
for (let i = 0; i < rows.length; i++) {
|
|
113
|
-
ctx.values = rows[i];
|
|
114
|
-
ctx.index = 0;
|
|
115
|
-
rows[i] = selected.mapRow(ctx);
|
|
116
|
-
}
|
|
117
|
-
return rows ?? [];
|
|
118
|
-
};
|
|
119
|
-
get [internalSql]() {
|
|
120
|
-
return includeQuery(getData(this)).mapWith({
|
|
121
|
-
mapFromDriverValue: this.#mapFromDriverValue
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
function include(select) {
|
|
126
|
-
return new Include({ ...getData(select), first: false });
|
|
127
|
-
}
|
|
128
|
-
((include2) => {
|
|
129
|
-
function one(select) {
|
|
130
|
-
return new Include({
|
|
131
|
-
...getData(select),
|
|
132
|
-
first: true
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
include2.one = one;
|
|
136
|
-
})(include || (include = {}));
|
|
137
|
-
function includeQuery(query) {
|
|
138
|
-
const { first, limit, offset, orderBy } = query;
|
|
139
|
-
const wrapQuery = Boolean(limit || offset || orderBy);
|
|
140
|
-
const innerQuery = selectQuery(query);
|
|
141
|
-
const inner = wrapQuery ? sql`select * from (${innerQuery}) as __` : innerQuery;
|
|
142
|
-
const fields = querySelection(query).fieldNames();
|
|
143
|
-
const subject = jsonArray(
|
|
144
|
-
...fields.map((name) => sql`_.${sql.identifier(name)}`)
|
|
145
|
-
);
|
|
146
|
-
return sql`(select ${first ? subject : jsonAggregateArray(subject)} from (${inner}) as _)`;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// src/backend/api/DatabaseApi.ts
|
|
150
37
|
import { HandleAction } from "../HandleAction.js";
|
|
151
38
|
var UploadTable = table("alinea_upload", {
|
|
152
39
|
entryId: varchar(void 0, { length: 27 }).primaryKey(),
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { type Request
|
|
2
|
-
export declare function proxyMediaUrl(request: Request, source: URL
|
|
3
|
-
export declare function isRedirectStatus(status: number): boolean;
|
|
1
|
+
import { type Request } from '@alinea/iso';
|
|
2
|
+
export declare function proxyMediaUrl(request: Request, source: URL): Promise<Response>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../../chunks/chunk-CQ52GEHY.js";
|
|
2
2
|
|
|
3
3
|
// src/backend/api/ProxyMedia.ts
|
|
4
|
-
import { Headers
|
|
5
|
-
|
|
4
|
+
import { Headers } from "@alinea/iso";
|
|
5
|
+
function proxyMediaUrl(request, source) {
|
|
6
6
|
const headers = new Headers();
|
|
7
7
|
for (const name of [
|
|
8
8
|
"range",
|
|
@@ -13,27 +13,12 @@ async function proxyMediaUrl(request, source, isAllowed = (url) => url.origin ==
|
|
|
13
13
|
const value = request.headers.get(name);
|
|
14
14
|
if (value) headers.set(name, value);
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
method: request.method,
|
|
22
|
-
headers,
|
|
23
|
-
redirect: "manual",
|
|
24
|
-
signal: request.signal
|
|
25
|
-
});
|
|
26
|
-
const location = response.headers.get("location");
|
|
27
|
-
if (!isRedirectStatus(response.status) || !location) return response;
|
|
28
|
-
if (redirects === 3)
|
|
29
|
-
return new Response("Too many media redirects", { status: 502 });
|
|
30
|
-
current = new URL(location, current);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function isRedirectStatus(status) {
|
|
34
|
-
return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
|
|
16
|
+
return fetch(source, {
|
|
17
|
+
method: request.method,
|
|
18
|
+
headers,
|
|
19
|
+
signal: request.signal
|
|
20
|
+
});
|
|
35
21
|
}
|
|
36
22
|
export {
|
|
37
|
-
isRedirectStatus,
|
|
38
23
|
proxyMediaUrl
|
|
39
24
|
};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
driver_exports
|
|
3
|
-
} from "../../chunks/chunk-
|
|
4
|
-
import "../../chunks/chunk-
|
|
5
|
-
import "../../chunks/chunk-
|
|
3
|
+
} from "../../chunks/chunk-QJGGYF6E.js";
|
|
4
|
+
import "../../chunks/chunk-QSN6RH6X.js";
|
|
5
|
+
import "../../chunks/chunk-ETWOY4AL.js";
|
|
6
|
+
import "../../chunks/chunk-66YZ47TY.js";
|
|
7
|
+
import "../../chunks/chunk-AIU6CMVT.js";
|
|
8
|
+
import "../../chunks/chunk-N47Y62CI.js";
|
|
9
|
+
import "../../chunks/chunk-QBPYWU6C.js";
|
|
10
|
+
import "../../chunks/chunk-2BJ2IFQM.js";
|
|
11
|
+
import "../../chunks/chunk-XCZXR3C2.js";
|
|
12
|
+
import "../../chunks/chunk-MOWR65LM.js";
|
|
13
|
+
import "../../chunks/chunk-76VMZTLN.js";
|
|
14
|
+
import "../../chunks/chunk-2PIFHEYR.js";
|
|
15
|
+
import "../../chunks/chunk-K62JP6HR.js";
|
|
16
|
+
import "../../chunks/chunk-ATF42T2B.js";
|
|
17
|
+
import "../../chunks/chunk-ETBQTP2S.js";
|
|
6
18
|
import "../../chunks/chunk-CQ52GEHY.js";
|
|
7
19
|
|
|
8
20
|
// src/backend/api/database.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LocalDB } from 'alinea/core/db/LocalDB';
|
|
2
1
|
import { Entry } from 'alinea/core/Entry';
|
|
3
2
|
import type { PreviewRequest, PreviewUpdate } from 'alinea/core/Preview';
|
|
3
|
+
import type { Graph } from 'alinea/core/Graph';
|
|
4
4
|
export interface DecodedEntryPreview {
|
|
5
5
|
entry: Entry;
|
|
6
6
|
}
|
|
7
7
|
export type DecodedPreviewRequest = PreviewUpdate | DecodedEntryPreview;
|
|
8
8
|
export declare function decodePreviewRequest(preview: PreviewRequest): Promise<DecodedPreviewRequest>;
|
|
9
|
-
export declare function applyPreview(local:
|
|
9
|
+
export declare function applyPreview(local: Graph, preview: DecodedPreviewRequest): Promise<PreviewRequest | undefined>;
|
|
@@ -5,6 +5,8 @@ import { Headers, Request } from "@alinea/iso";
|
|
|
5
5
|
import { TLSSocket } from "node:tls";
|
|
6
6
|
async function writeReadableStreamToWritable(stream, writable) {
|
|
7
7
|
const reader = stream.getReader();
|
|
8
|
+
writable.once("close", () => reader.cancel().catch(() => {
|
|
9
|
+
}));
|
|
8
10
|
async function read() {
|
|
9
11
|
const { done, value } = await reader.read();
|
|
10
12
|
if (done) return writable.end();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Config } from 'alinea/core/Config';
|
|
2
|
+
import type { DatabaseHandle } from 'alinea/database/driver/DatabaseHandle';
|
|
3
|
+
import { EntryStore } from 'alinea/database/EntryStore';
|
|
4
|
+
/**
|
|
5
|
+
* Serve a generated database from a connection that keeps its writes in
|
|
6
|
+
* memory, so syncs and commits never reach the generated file.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGeneratedDatabase(config: Config, { database: db, fork, driver }: DatabaseHandle): Promise<EntryStore>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "../../chunks/chunk-CQ52GEHY.js";
|
|
2
|
+
|
|
3
|
+
// src/backend/store/GeneratedDatabase.ts
|
|
4
|
+
import { DatabaseSource } from "alinea/database/DatabaseSource";
|
|
5
|
+
import { assertReadableData } from "alinea/database/entry/EntryData";
|
|
6
|
+
import { EntryDatabase } from "alinea/database/EntryDatabase";
|
|
7
|
+
import { EntryStore } from "alinea/database/EntryStore";
|
|
8
|
+
async function createGeneratedDatabase(config, { database: db, fork, driver }) {
|
|
9
|
+
let initialTree;
|
|
10
|
+
const database = new EntryDatabase(config, db, {
|
|
11
|
+
fork,
|
|
12
|
+
includedAtBuild(filePath) {
|
|
13
|
+
return initialTree?.has(filePath) ?? false;
|
|
14
|
+
},
|
|
15
|
+
// Nothing reopens the in-memory writes: skip storing the synced tree.
|
|
16
|
+
recordsTree: false
|
|
17
|
+
});
|
|
18
|
+
try {
|
|
19
|
+
await assertReadableData(db);
|
|
20
|
+
initialTree = await database.getTree();
|
|
21
|
+
return new EntryStore(config, database, new DatabaseSource(database), {
|
|
22
|
+
ownsDatabase: true,
|
|
23
|
+
sourceFollowsDatabase: true,
|
|
24
|
+
driver
|
|
25
|
+
});
|
|
26
|
+
} catch (error) {
|
|
27
|
+
await database.close();
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
createGeneratedDatabase
|
|
33
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Config } from 'alinea/core/Config';
|
|
2
|
+
import type { DatabaseOptions } from 'rado';
|
|
3
|
+
/** Open the traced generated file as an in-memory overlay. */
|
|
4
|
+
export declare function generatedDatabase(config: Config, options?: DatabaseOptions): Promise<import("../../database/EntryStore.js").EntryStore>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "../../chunks/chunk-CQ52GEHY.js";
|
|
2
|
+
|
|
3
|
+
// src/backend/store/GeneratedDatabaseNode.ts
|
|
4
|
+
import { runtimeDatabase } from "alinea/database/driver/RuntimeDatabase";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { createGeneratedDatabase } from "./GeneratedDatabase.js";
|
|
7
|
+
async function generatedDatabasePath() {
|
|
8
|
+
const { database } = await import("@alinea/generated/database.node.js");
|
|
9
|
+
if (!(database instanceof URL))
|
|
10
|
+
throw new Error("The generated database location is missing");
|
|
11
|
+
return fileURLToPath(database);
|
|
12
|
+
}
|
|
13
|
+
var stores = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var loggers = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
function generatedDatabase(config, options = {}) {
|
|
16
|
+
if (options.logQuery) loggers.set(config, options.logQuery);
|
|
17
|
+
let store = stores.get(config);
|
|
18
|
+
if (!store) {
|
|
19
|
+
store = generatedDatabasePath().then(
|
|
20
|
+
(path) => runtimeDatabase({
|
|
21
|
+
path,
|
|
22
|
+
overlay: true,
|
|
23
|
+
logQuery: (query, durationMs) => loggers.get(config)?.(query, durationMs)
|
|
24
|
+
})
|
|
25
|
+
).then((db) => createGeneratedDatabase(config, db));
|
|
26
|
+
stores.set(config, store);
|
|
27
|
+
store.catch(() => {
|
|
28
|
+
if (stores.get(config) === store) stores.delete(config);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return store;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
generatedDatabase
|
|
35
|
+
};
|
package/dist/backend/util/ORM.js
CHANGED