alinea 1.4.4 → 1.4.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.
- package/dist/.init/content/pages/welcome.json +1 -1
- package/dist/LICENSES.md +14 -14
- package/dist/adapter/next/cms.d.ts +0 -12
- package/dist/adapter/next/cms.js +2 -44
- package/dist/adapter/next/context.js +2 -2
- package/dist/adapter/next/handler.js +16 -21
- package/dist/backend/Handler.js +2 -3
- package/dist/backend/Previews.d.ts +1 -2
- package/dist/backend/api/CreateBackend.js +1 -1
- package/dist/backend/api/DatabaseApi.d.ts +1 -2
- package/dist/backend/api/DatabaseApi.js +76 -6
- package/dist/bundled.d.ts +10254 -0
- package/dist/chunks/{chunk-HFLX6EP2.js → chunk-BWPXC7VK.js} +1 -1
- package/dist/chunks/{chunk-JWAXPICL.js → chunk-H54PGW2N.js} +86 -96
- package/dist/chunks/{chunk-67DMRQ2R.js → chunk-R2IV7GJV.js} +1 -23
- package/dist/chunks/{chunk-43XCFOO4.js → chunk-WR25RMMO.js} +1 -1
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/serve/CreateLocalServer.js +2 -1
- package/dist/cloud/CloudRemote.js +1 -1
- package/dist/core/Doc.d.ts +3 -3
- package/dist/core/Entry.d.ts +5 -2
- package/dist/core/Entry.js +3 -0
- package/dist/core/EntryRecord.d.ts +2 -2
- package/dist/core/EntrySearch.js +2 -2
- package/dist/core/Graph.d.ts +4 -2
- package/dist/core/Preview.d.ts +2 -3
- package/dist/core/Scope.d.ts +12 -2
- package/dist/core/Scope.js +40 -10
- package/dist/core/db/EntryIndex.d.ts +6 -8
- package/dist/core/db/EntryIndex.js +42 -12
- package/dist/core/db/EntryResolver.d.ts +1 -1
- package/dist/core/db/EntryResolver.js +4 -6
- package/dist/core/db/EntryTransaction.js +6 -1
- package/dist/core/db/WriteableGraph.d.ts +5 -3
- package/dist/core/media/Summary.d.ts +4 -0
- package/dist/core/media/Summary.js +2 -0
- package/dist/core/util/ContentHash.d.ts +2 -2
- package/dist/core/util/EntryFilenames.d.ts +2 -2
- package/dist/core/util/EntryFilenames.js +1 -1
- package/dist/core/util/EntryRows.d.ts +2 -2
- package/dist/dashboard/Routes.d.ts +4 -1
- package/dist/dashboard/atoms/DashboardAtoms.js +1 -1
- package/dist/dashboard/atoms/DbAtoms.js +3 -3
- package/dist/dashboard/atoms/Edits.d.ts +1 -1
- package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +7 -5
- package/dist/dashboard/atoms/EntryEditorAtoms.js +3 -6
- package/dist/dashboard/atoms/EntrySummaryAtoms.js +3 -3
- package/dist/dashboard/atoms/LocationAtoms.js +3 -3
- package/dist/dashboard/atoms/NavigationAtoms.js +3 -3
- package/dist/dashboard/boot/Boot.d.ts +1 -0
- package/dist/dashboard/boot/BootDev.js +8 -1
- package/dist/dashboard/hook/UseUploads.d.ts +4 -5
- package/dist/dashboard/util/KeepPreviousData.d.ts +8 -1
- package/dist/dashboard/util/KeepPreviousData.js +20 -15
- package/dist/dashboard/view/EntryEdit.js +7 -18
- package/dist/dashboard/view/diff/EntryDiff.d.ts +3 -3
- package/dist/dashboard/view/entry/EntryPreview.js +3 -3
- package/dist/dashboard/view/entry/EntrySummary.d.ts +1 -1
- package/dist/dashboard/view/entry/EntrySummary.js +6 -4
- package/dist/dashboard/view/entry/EntryTitle.js +13 -13
- package/dist/dashboard/view/entry/NewEntry.js +4 -1
- package/dist/dashboard/view/media/FileEntry.js +3 -2
- package/dist/field/link/LinkField.view.js +1 -1
- package/dist/field/list/ListField.view.js +6 -4
- package/dist/index.css +37 -10
- package/dist/picker/url/UrlPickerRow.js +14 -5
- package/dist/query.d.ts +7 -0
- package/dist/ui/Button.d.ts +1 -1
- package/dist/ui/Button.js +11 -2
- package/dist/ui/Statusbar.d.ts +4 -3
- package/dist/ui/Statusbar.js +22 -8
- package/dist/ui/icons/IcRoundCheckBox.d.ts +0 -1
- package/dist/ui/icons/IcRoundCheckBox.js +1 -3
- package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.d.ts +0 -1
- package/dist/ui/icons/IcRoundCheckBoxOutlineBlank.js +1 -3
- package/package.json +1 -1
- package/dist/chunks/chunk-HI4G24AL.js +0 -76
- package/dist/core/EntryRow.d.ts +0 -39
- package/dist/core/EntryRow.js +0 -95
package/dist/LICENSES.md
CHANGED
|
@@ -157,7 +157,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
157
157
|
|
|
158
158
|
===
|
|
159
159
|
|
|
160
|
-
#
|
|
160
|
+
# domhandler@5.0.3 (BSD-2-Clause)
|
|
161
161
|
|
|
162
162
|
Copyright (c) Felix Böhm
|
|
163
163
|
All rights reserved.
|
|
@@ -174,7 +174,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
174
174
|
|
|
175
175
|
===
|
|
176
176
|
|
|
177
|
-
#
|
|
177
|
+
# domutils@3.1.0 (BSD-2-Clause)
|
|
178
178
|
|
|
179
179
|
Copyright (c) Felix Böhm
|
|
180
180
|
All rights reserved.
|
|
@@ -467,6 +467,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
467
467
|
SOFTWARE.
|
|
468
468
|
|
|
469
469
|
|
|
470
|
+
===
|
|
471
|
+
|
|
472
|
+
# @headless-tree/react@0.0.15 (MIT)
|
|
473
|
+
|
|
474
|
+
MIT
|
|
475
|
+
|
|
476
|
+
===
|
|
477
|
+
|
|
478
|
+
# @headless-tree/core@0.0.15 (MIT)
|
|
479
|
+
|
|
480
|
+
MIT
|
|
481
|
+
|
|
470
482
|
===
|
|
471
483
|
|
|
472
484
|
# dom-serializer@2.0.0 (MIT)
|
|
@@ -484,18 +496,6 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
484
496
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
485
497
|
|
|
486
498
|
|
|
487
|
-
===
|
|
488
|
-
|
|
489
|
-
# @headless-tree/core@0.0.15 (MIT)
|
|
490
|
-
|
|
491
|
-
MIT
|
|
492
|
-
|
|
493
|
-
===
|
|
494
|
-
|
|
495
|
-
# @headless-tree/react@0.0.15 (MIT)
|
|
496
|
-
|
|
497
|
-
MIT
|
|
498
|
-
|
|
499
499
|
===
|
|
500
500
|
|
|
501
501
|
# y-prosemirror@1.2.15 (MIT)
|
|
@@ -2,11 +2,8 @@ import { CMS } from 'alinea/core/CMS';
|
|
|
2
2
|
import type { Config } from 'alinea/core/Config';
|
|
3
3
|
import type { UploadResponse } from 'alinea/core/Connection';
|
|
4
4
|
import type { GraphQuery } from 'alinea/core/Graph';
|
|
5
|
-
import type { PreviewRequest } from 'alinea/core/Preview';
|
|
6
5
|
import type { User } from 'alinea/core/User';
|
|
7
|
-
import { LocalDB } from 'alinea/core/db/LocalDB';
|
|
8
6
|
import type { Mutation } from 'alinea/core/db/Mutation';
|
|
9
|
-
import PLazy from 'p-lazy';
|
|
10
7
|
export interface PreviewProps {
|
|
11
8
|
widget?: boolean;
|
|
12
9
|
workspace?: string;
|
|
@@ -14,16 +11,7 @@ export interface PreviewProps {
|
|
|
14
11
|
}
|
|
15
12
|
export declare class NextCMS<Definition extends Config = Config> extends CMS<Definition> {
|
|
16
13
|
#private;
|
|
17
|
-
lastSync: number;
|
|
18
|
-
db: PLazy<LocalDB>;
|
|
19
|
-
init: PLazy<{
|
|
20
|
-
db: LocalDB;
|
|
21
|
-
previews: {
|
|
22
|
-
parse(preview: PreviewRequest, sync: () => Promise<unknown>): Promise<PreviewRequest | undefined>;
|
|
23
|
-
};
|
|
24
|
-
}>;
|
|
25
14
|
constructor(config: Definition);
|
|
26
|
-
sync(): Promise<string>;
|
|
27
15
|
resolve<Query extends GraphQuery>(query: Query): Promise<any>;
|
|
28
16
|
user(): Promise<User | undefined>;
|
|
29
17
|
mutate(mutations: Array<Mutation>): Promise<{
|
package/dist/adapter/next/cms.js
CHANGED
|
@@ -1,45 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PLazy
|
|
3
|
-
} from "../../chunks/chunk-IKINPSS5.js";
|
|
4
1
|
import "../../chunks/chunk-NZLE2WMY.js";
|
|
5
2
|
|
|
6
3
|
// src/adapter/next/cms.tsx
|
|
7
4
|
import { Headers } from "@alinea/iso";
|
|
8
|
-
import { createPreviewParser } from "alinea/backend/resolver/ParsePreview";
|
|
9
|
-
import { generatedSource } from "alinea/backend/store/GeneratedSource";
|
|
10
5
|
import { COOKIE_NAME } from "alinea/cloud/CloudRemote";
|
|
11
6
|
import { CMS } from "alinea/core/CMS";
|
|
12
7
|
import { Client } from "alinea/core/Client";
|
|
13
8
|
import { outcome } from "alinea/core/Outcome";
|
|
14
|
-
import { LocalDB } from "alinea/core/db/LocalDB";
|
|
15
9
|
import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
|
|
16
10
|
import { requestContext } from "./context.js";
|
|
17
11
|
import { jsx } from "react/jsx-runtime";
|
|
18
12
|
var NextCMS = class extends CMS {
|
|
19
|
-
lastSync = 0;
|
|
20
|
-
db = PLazy.from(async () => {
|
|
21
|
-
if (process.env.NEXT_RUNTIME === "edge")
|
|
22
|
-
throw new Error("Local db not available in edge");
|
|
23
|
-
const source = await generatedSource;
|
|
24
|
-
const db = new LocalDB(this.config, source);
|
|
25
|
-
await db.sync();
|
|
26
|
-
return db;
|
|
27
|
-
});
|
|
28
|
-
init = PLazy.from(async () => {
|
|
29
|
-
const db = await this.db;
|
|
30
|
-
const previews = createPreviewParser(db);
|
|
31
|
-
return { db, previews };
|
|
32
|
-
});
|
|
33
13
|
constructor(config) {
|
|
34
14
|
super(config);
|
|
35
15
|
}
|
|
36
|
-
async sync() {
|
|
37
|
-
const { db } = await this.init;
|
|
38
|
-
return db.sync();
|
|
39
|
-
}
|
|
40
16
|
async resolve(query) {
|
|
41
17
|
let status = query.status;
|
|
42
|
-
const {
|
|
18
|
+
const { handlerUrl, apiKey } = await requestContext(this.config);
|
|
43
19
|
const client = new Client({
|
|
44
20
|
config: this.config,
|
|
45
21
|
url: handlerUrl.href,
|
|
@@ -58,25 +34,7 @@ var NextCMS = class extends CMS {
|
|
|
58
34
|
const payload = getPreviewPayloadFromCookies(cookie.getAll());
|
|
59
35
|
if (payload) preview = { payload };
|
|
60
36
|
}
|
|
61
|
-
|
|
62
|
-
return client.resolve({ preview, ...query, status });
|
|
63
|
-
const { PHASE_PRODUCTION_BUILD } = await import("next/constants");
|
|
64
|
-
const isBuild = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD;
|
|
65
|
-
const { db, previews } = await this.init;
|
|
66
|
-
const sync = () => db.syncWith(client).catch(console.error);
|
|
67
|
-
if (!isBuild) {
|
|
68
|
-
if (preview) {
|
|
69
|
-
preview = await previews.parse(preview, sync);
|
|
70
|
-
} else {
|
|
71
|
-
const syncInterval = query.syncInterval ?? 60;
|
|
72
|
-
const now = Date.now();
|
|
73
|
-
if (now - this.lastSync >= syncInterval * 1e3) {
|
|
74
|
-
this.lastSync = now;
|
|
75
|
-
await sync();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return db.resolve({ preview, ...query, status });
|
|
37
|
+
return client.resolve({ preview, ...query, status });
|
|
80
38
|
}
|
|
81
39
|
async #authenticatedClient() {
|
|
82
40
|
const { handlerUrl, apiKey } = await requestContext(this.config);
|
|
@@ -4,7 +4,7 @@ import "../../chunks/chunk-NZLE2WMY.js";
|
|
|
4
4
|
import { generatedRelease } from "alinea/backend/store/GeneratedRelease";
|
|
5
5
|
import { Config } from "alinea/core/Config";
|
|
6
6
|
async function requestContext(config) {
|
|
7
|
-
const apiKey = process.env.NODE_ENV === "development" ? "dev" :
|
|
7
|
+
const apiKey = process.env.ALINEA_API_KEY || (process.env.NODE_ENV === "development" ? "dev" : await generatedRelease);
|
|
8
8
|
const dev = process.env.ALINEA_DEV_SERVER;
|
|
9
9
|
if (dev) return { isDev: true, handlerUrl: new URL("/api", dev), apiKey };
|
|
10
10
|
const nodeEnv = process.env.NODE_ENV;
|
|
@@ -13,7 +13,7 @@ async function requestContext(config) {
|
|
|
13
13
|
return {
|
|
14
14
|
isDev: false,
|
|
15
15
|
handlerUrl: new URL(config.handlerUrl ?? "/api/cms", baseUrl),
|
|
16
|
-
apiKey
|
|
16
|
+
apiKey
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PLazy
|
|
3
|
+
} from "../../chunks/chunk-IKINPSS5.js";
|
|
1
4
|
import "../../chunks/chunk-NZLE2WMY.js";
|
|
2
5
|
|
|
3
6
|
// src/adapter/next/handler.ts
|
|
@@ -7,10 +10,10 @@ import {
|
|
|
7
10
|
import {
|
|
8
11
|
createBackend
|
|
9
12
|
} from "alinea/backend/api/CreateBackend";
|
|
13
|
+
import { generatedSource } from "alinea/backend/store/GeneratedSource";
|
|
10
14
|
import { JWTPreviews } from "alinea/backend/util/JWTPreviews";
|
|
11
15
|
import { CloudRemote } from "alinea/cloud/CloudRemote";
|
|
12
|
-
import {
|
|
13
|
-
import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
|
|
16
|
+
import { LocalDB } from "alinea/core/db/LocalDB";
|
|
14
17
|
import { NextCMS } from "./cms.js";
|
|
15
18
|
import { requestContext } from "./context.js";
|
|
16
19
|
var handlers = /* @__PURE__ */ new WeakMap();
|
|
@@ -18,35 +21,27 @@ function createHandler(input) {
|
|
|
18
21
|
const options = input instanceof NextCMS ? { cms: input } : input;
|
|
19
22
|
const remote = options.remote ?? (options.backend ? createBackend(options.backend) : (context) => new CloudRemote(context, options.cms));
|
|
20
23
|
if (handlers.has(options.cms)) return handlers.get(options.cms);
|
|
24
|
+
const config = options.cms.config;
|
|
25
|
+
const db = PLazy.from(async () => {
|
|
26
|
+
const source = await generatedSource;
|
|
27
|
+
const db2 = new LocalDB(config, source);
|
|
28
|
+
await db2.sync();
|
|
29
|
+
return db2;
|
|
30
|
+
});
|
|
21
31
|
const handleBackend = createCoreHandler({
|
|
22
32
|
...options,
|
|
23
33
|
remote,
|
|
24
|
-
db
|
|
34
|
+
db
|
|
25
35
|
});
|
|
26
36
|
const handle = async (request) => {
|
|
27
37
|
try {
|
|
28
|
-
const context = await requestContext(
|
|
38
|
+
const context = await requestContext(config);
|
|
29
39
|
const previews = new JWTPreviews(context.apiKey);
|
|
30
40
|
const { searchParams } = new URL(request.url);
|
|
31
41
|
const previewToken = searchParams.get("preview");
|
|
32
42
|
if (previewToken) {
|
|
33
|
-
const { draftMode
|
|
34
|
-
const {
|
|
35
|
-
const previewToken2 = searchParams2.get("preview");
|
|
36
|
-
if (!previewToken2) return new Response("Not found", { status: 404 });
|
|
37
|
-
const info = await previews.verify(previewToken2);
|
|
38
|
-
const cookie = await cookies();
|
|
39
|
-
const resolver = context.isDev ? options.cms : await options.cms.db;
|
|
40
|
-
const payload = getPreviewPayloadFromCookies(cookie.getAll());
|
|
41
|
-
const url = await resolver.resolve({
|
|
42
|
-
first: true,
|
|
43
|
-
select: Entry.url,
|
|
44
|
-
id: info.entryId,
|
|
45
|
-
locale: info.locale,
|
|
46
|
-
preview: payload ? { payload } : void 0,
|
|
47
|
-
status: "preferDraft"
|
|
48
|
-
});
|
|
49
|
-
if (!url) return new Response("Not found", { status: 404 });
|
|
43
|
+
const { draftMode } = await import("next/headers");
|
|
44
|
+
const { url } = await previews.verify(previewToken);
|
|
50
45
|
const source = new URL(request.url);
|
|
51
46
|
if (source.hostname === "0.0.0.0") source.hostname = "localhost";
|
|
52
47
|
const location = new URL(url, source.origin);
|
package/dist/backend/Handler.js
CHANGED
|
@@ -25,8 +25,7 @@ var PrepareBody = object({
|
|
|
25
25
|
filename: string
|
|
26
26
|
});
|
|
27
27
|
var PreviewBody = object({
|
|
28
|
-
|
|
29
|
-
entryId: string
|
|
28
|
+
url: string
|
|
30
29
|
});
|
|
31
30
|
function createHandler({
|
|
32
31
|
cms,
|
|
@@ -158,6 +157,7 @@ function createHandler({
|
|
|
158
157
|
}
|
|
159
158
|
if (action === HandleAction.Blob && request.method === "POST") {
|
|
160
159
|
const { shas } = object({ shas: array(string) })(await body);
|
|
160
|
+
await periodicSync(cnx);
|
|
161
161
|
const tree = await local.source.getTree();
|
|
162
162
|
const fromLocal = [];
|
|
163
163
|
const fromRemote = [];
|
|
@@ -173,7 +173,6 @@ function createHandler({
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
if (fromRemote.length > 0) {
|
|
176
|
-
await periodicSync(cnx);
|
|
177
176
|
const blobs = cnx.getBlobs(fromRemote);
|
|
178
177
|
for await (const [sha, blob] of blobs) {
|
|
179
178
|
formData.append(sha, new Blob([blob]));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { RequestContext } from 'alinea/core/Connection';
|
|
2
|
-
import type { DraftsApi, UploadResponse, UploadsApi } from 'alinea/core/Connection';
|
|
1
|
+
import type { DraftsApi, RequestContext, UploadResponse, UploadsApi } from 'alinea/core/Connection';
|
|
3
2
|
import { type Draft, type DraftKey } from 'alinea/core/Draft';
|
|
4
3
|
import { type Database } from 'rado';
|
|
5
4
|
export interface DatabaseOptions {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
primaryKey
|
|
3
|
-
} from "../../chunks/chunk-HI4G24AL.js";
|
|
4
1
|
import {
|
|
5
2
|
blob,
|
|
6
3
|
text
|
|
7
|
-
} from "../../chunks/chunk-
|
|
4
|
+
} from "../../chunks/chunk-R2IV7GJV.js";
|
|
8
5
|
import {
|
|
9
6
|
eq
|
|
10
7
|
} from "../../chunks/chunk-TO6JVYUN.js";
|
|
11
8
|
import {
|
|
12
9
|
table
|
|
13
|
-
} from "../../chunks/chunk-
|
|
14
|
-
import
|
|
10
|
+
} from "../../chunks/chunk-H54PGW2N.js";
|
|
11
|
+
import {
|
|
12
|
+
getData,
|
|
13
|
+
getField,
|
|
14
|
+
internalConstraint,
|
|
15
|
+
internalData,
|
|
16
|
+
sql
|
|
17
|
+
} from "../../chunks/chunk-PNILF4WM.js";
|
|
15
18
|
import {
|
|
16
19
|
PLazy
|
|
17
20
|
} from "../../chunks/chunk-IKINPSS5.js";
|
|
@@ -22,6 +25,73 @@ import { parseDraftKey } from "alinea/core/Draft";
|
|
|
22
25
|
import { createId } from "alinea/core/Id";
|
|
23
26
|
import { basename, extname } from "alinea/core/util/Paths";
|
|
24
27
|
import { slugify } from "alinea/core/util/Slugs";
|
|
28
|
+
|
|
29
|
+
// node_modules/rado/dist/core/Constraint.js
|
|
30
|
+
var UniqueConstraint = class _UniqueConstraint {
|
|
31
|
+
[internalData];
|
|
32
|
+
constructor(data) {
|
|
33
|
+
this[internalData] = data;
|
|
34
|
+
}
|
|
35
|
+
on(...columns) {
|
|
36
|
+
const fields = columns.map(getField);
|
|
37
|
+
return new _UniqueConstraint({ ...getData(this), fields });
|
|
38
|
+
}
|
|
39
|
+
nullsNotDistinct() {
|
|
40
|
+
return new _UniqueConstraint({ ...getData(this), nullsNotDistinct: true });
|
|
41
|
+
}
|
|
42
|
+
get [internalConstraint]() {
|
|
43
|
+
const { fields, nullsNotDistinct } = getData(this);
|
|
44
|
+
return sql.join([
|
|
45
|
+
sql`unique`,
|
|
46
|
+
nullsNotDistinct ? sql`nulls not distinct` : void 0,
|
|
47
|
+
sql`(${sql.join(
|
|
48
|
+
fields.map((field) => sql.identifier(field.fieldName)),
|
|
49
|
+
sql`, `
|
|
50
|
+
)})`
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var PrimaryKeyConstraint = class {
|
|
55
|
+
constructor(data) {
|
|
56
|
+
this.data = data;
|
|
57
|
+
this[internalData] = data;
|
|
58
|
+
}
|
|
59
|
+
[internalData];
|
|
60
|
+
get [internalConstraint]() {
|
|
61
|
+
const { fields } = getData(this);
|
|
62
|
+
return sql`primary key (${sql.join(
|
|
63
|
+
fields.map((field) => sql.identifier(field.fieldName)),
|
|
64
|
+
sql`, `
|
|
65
|
+
)})`;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function primaryKey(...fields) {
|
|
69
|
+
return new PrimaryKeyConstraint({ fields: fields.map(getField) });
|
|
70
|
+
}
|
|
71
|
+
var ForeignKeyConstraint = class _ForeignKeyConstraint {
|
|
72
|
+
[internalData];
|
|
73
|
+
constructor(data) {
|
|
74
|
+
this[internalData] = data;
|
|
75
|
+
}
|
|
76
|
+
references(...fields) {
|
|
77
|
+
return new _ForeignKeyConstraint({
|
|
78
|
+
...getData(this),
|
|
79
|
+
references: fields.map(getField)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
get [internalConstraint]() {
|
|
83
|
+
const { fields, references } = getData(this);
|
|
84
|
+
return sql`foreign key (${sql.join(
|
|
85
|
+
fields.map((field) => sql.identifier(field.fieldName)),
|
|
86
|
+
sql`, `
|
|
87
|
+
)}) references ${sql.identifier(references[0].targetName)} (${sql.join(
|
|
88
|
+
references.map((field) => sql.identifier(field.fieldName)),
|
|
89
|
+
sql`, `
|
|
90
|
+
)})`;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/backend/api/DatabaseApi.ts
|
|
25
95
|
import { HandleAction } from "../HandleAction.js";
|
|
26
96
|
import { is } from "../util/ORM.js";
|
|
27
97
|
var DraftTable = table(
|