alinea 1.0.4 → 1.0.6
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/backend/Database.js +18 -16
- package/dist/backend/resolver/EntryResolver.js +1 -1
- package/dist/backend/resolver/LinkResolver.d.ts +3 -3
- package/dist/backend/resolver/LinkResolver.js +8 -5
- package/dist/chunks/{chunk-MCCVEGL3.js → chunk-MAYW4CMH.js} +1 -1
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cloud/CloudBackend.js +1 -1
- package/dist/core/shape/RichTextShape.js +1 -1
- package/dist/dashboard/util/PersistentStore.js +1 -1
- package/dist/field/link/EntryLink.js +6 -2
- package/dist/picker/entry/EntryPicker.browser.js +5 -1
- package/dist/picker/entry/EntryPicker.d.ts +4 -0
- package/package.json +1 -1
package/dist/backend/Database.js
CHANGED
|
@@ -622,8 +622,8 @@ ${JSON.stringify(mutation)}`
|
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
624
|
if (fix && v0Ids.size > 0) {
|
|
625
|
-
const
|
|
626
|
-
for (const entry of
|
|
625
|
+
const entries2 = await tx.select().from(EntryRow);
|
|
626
|
+
for (const entry of entries2) {
|
|
627
627
|
const file = entryFile(this.config, entry);
|
|
628
628
|
entry.data = JSON.parse(JSON.stringify(entry.data), (key, value) => {
|
|
629
629
|
if (key === "_entry")
|
|
@@ -704,20 +704,22 @@ ${JSON.stringify(mutation)}`
|
|
|
704
704
|
if (noChanges)
|
|
705
705
|
return;
|
|
706
706
|
await _Database.index(tx);
|
|
707
|
-
|
|
708
|
-
EntryRow.
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
707
|
+
if (inserted.length > 0) {
|
|
708
|
+
const isInserted = sql`(${EntryRow.id}, ${coalesce(
|
|
709
|
+
EntryRow.locale,
|
|
710
|
+
sql`'null'`
|
|
711
|
+
)}, ${EntryRow.status}) in ${values(...inserted)}`;
|
|
712
|
+
const entries2 = await tx.select().from(EntryRow).where(isInserted);
|
|
713
|
+
for (const entry of entries2) {
|
|
714
|
+
const rowHash = await createRowHash(entry);
|
|
715
|
+
await tx.update(EntryRow).set({
|
|
716
|
+
rowHash
|
|
717
|
+
}).where(
|
|
718
|
+
eq(EntryRow.id, entry.id),
|
|
719
|
+
is(EntryRow.locale, entry.locale),
|
|
720
|
+
eq(EntryRow.status, entry.status)
|
|
721
|
+
);
|
|
722
|
+
}
|
|
721
723
|
}
|
|
722
724
|
await this.writeMeta(tx, commitHash);
|
|
723
725
|
});
|
|
@@ -549,7 +549,7 @@ var EntryResolver = class {
|
|
|
549
549
|
const singleResult = this.isSingleResult(query);
|
|
550
550
|
const transact = async (tx) => {
|
|
551
551
|
const rows = await dbQuery.all(tx);
|
|
552
|
-
const linkResolver = new LinkResolver(this, tx, ctx
|
|
552
|
+
const linkResolver = new LinkResolver(this, tx, ctx);
|
|
553
553
|
const result = singleResult ? rows[0] ?? null : rows;
|
|
554
554
|
if (result)
|
|
555
555
|
await this.post({ linkResolver }, result, query);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { InferProjection, Projection } from 'alinea/core/Graph';
|
|
2
|
-
import { Status } from 'alinea/core/Graph';
|
|
3
2
|
import DataLoader from 'dataloader';
|
|
4
3
|
import { Store } from '../Store.js';
|
|
5
4
|
import type { EntryResolver } from './EntryResolver.js';
|
|
5
|
+
import { ResolveContext } from './ResolveContext.js';
|
|
6
6
|
export declare class LinkResolver {
|
|
7
7
|
resolver: EntryResolver;
|
|
8
8
|
store: Store;
|
|
9
|
-
|
|
9
|
+
private ctx;
|
|
10
10
|
loaders: Map<Projection, DataLoader<string, object, string>>;
|
|
11
|
-
constructor(resolver: EntryResolver, store: Store,
|
|
11
|
+
constructor(resolver: EntryResolver, store: Store, ctx: ResolveContext);
|
|
12
12
|
load(projection: Projection): DataLoader<string, object, string>;
|
|
13
13
|
resolveLinks<P extends Projection>(projection: P, entryIds: ReadonlyArray<string>): Promise<Array<InferProjection<P> | undefined>>;
|
|
14
14
|
}
|
|
@@ -10,17 +10,20 @@ var import_dataloader = __toESM(require_dataloader(), 1);
|
|
|
10
10
|
import { Entry } from "alinea/core/Entry";
|
|
11
11
|
import { ResolveContext } from "./ResolveContext.js";
|
|
12
12
|
var LinkResolver = class {
|
|
13
|
-
constructor(resolver, store,
|
|
13
|
+
constructor(resolver, store, ctx) {
|
|
14
14
|
this.resolver = resolver;
|
|
15
15
|
this.store = store;
|
|
16
|
-
this.
|
|
16
|
+
this.ctx = ctx;
|
|
17
17
|
}
|
|
18
18
|
loaders = /* @__PURE__ */ new Map();
|
|
19
19
|
load(projection) {
|
|
20
20
|
return new import_dataloader.default(
|
|
21
21
|
async (ids) => {
|
|
22
22
|
const query = this.resolver.query(
|
|
23
|
-
new ResolveContext({
|
|
23
|
+
new ResolveContext({
|
|
24
|
+
locale: this.ctx.locale,
|
|
25
|
+
status: this.ctx.status
|
|
26
|
+
}),
|
|
24
27
|
{
|
|
25
28
|
select: {
|
|
26
29
|
entryId: Entry.id,
|
|
@@ -46,8 +49,8 @@ var LinkResolver = class {
|
|
|
46
49
|
function skipErrors(results) {
|
|
47
50
|
return results.map((result) => {
|
|
48
51
|
if (result instanceof Error) {
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
Error.captureStackTrace(result);
|
|
53
|
+
throw result;
|
|
51
54
|
}
|
|
52
55
|
return result;
|
|
53
56
|
});
|
package/dist/cli/Serve.js
CHANGED
package/dist/cli/bin.js
CHANGED
|
@@ -22,7 +22,9 @@ function entry(label, options = {}) {
|
|
|
22
22
|
pickers: {
|
|
23
23
|
entry: entryPicker({
|
|
24
24
|
...options,
|
|
25
|
-
withNavigation: Boolean(
|
|
25
|
+
withNavigation: Boolean(
|
|
26
|
+
options.location || !options.condition && !options.pickChildren
|
|
27
|
+
),
|
|
26
28
|
title: "Select a page",
|
|
27
29
|
max: 1,
|
|
28
30
|
selection: EntryLink
|
|
@@ -37,7 +39,9 @@ function entry(label, options = {}) {
|
|
|
37
39
|
pickers: {
|
|
38
40
|
entry: entryPicker({
|
|
39
41
|
...options,
|
|
40
|
-
withNavigation:
|
|
42
|
+
withNavigation: Boolean(
|
|
43
|
+
options.location || !options.condition && !options.pickChildren
|
|
44
|
+
),
|
|
41
45
|
title: "Select a page",
|
|
42
46
|
selection: EntryLink
|
|
43
47
|
})
|
|
@@ -16,6 +16,7 @@ import { Workspace } from "alinea/core/Workspace";
|
|
|
16
16
|
import { workspaceMediaDir } from "alinea/core/util/EntryFilenames";
|
|
17
17
|
import { entries } from "alinea/core/util/Objects";
|
|
18
18
|
import { useConfig } from "alinea/dashboard/hook/UseConfig";
|
|
19
|
+
import { useEntryEditor } from "alinea/dashboard/hook/UseEntryEditor";
|
|
19
20
|
import { useFocusList } from "alinea/dashboard/hook/UseFocusList";
|
|
20
21
|
import { useGraph } from "alinea/dashboard/hook/UseGraph";
|
|
21
22
|
import { useLocale } from "alinea/dashboard/hook/UseLocale";
|
|
@@ -81,11 +82,13 @@ function EntryPickerModal({
|
|
|
81
82
|
}) {
|
|
82
83
|
const config = useConfig();
|
|
83
84
|
const graph = useGraph();
|
|
85
|
+
const editor = useEntryEditor();
|
|
84
86
|
const {
|
|
85
87
|
title,
|
|
86
88
|
defaultView,
|
|
87
89
|
location,
|
|
88
90
|
max,
|
|
91
|
+
pickChildren,
|
|
89
92
|
condition,
|
|
90
93
|
withNavigation = true,
|
|
91
94
|
showMedia
|
|
@@ -102,6 +105,7 @@ function EntryPickerModal({
|
|
|
102
105
|
const locale = useLocale();
|
|
103
106
|
const [destination, setDestination] = useState({
|
|
104
107
|
workspace: currentWorkspace,
|
|
108
|
+
parentId: pickChildren ? editor?.entryId : void 0,
|
|
105
109
|
root: showMedia ? Workspace.defaultMediaRoot(config.workspaces[currentWorkspace]) : currentRoot,
|
|
106
110
|
...location,
|
|
107
111
|
locale
|
|
@@ -145,7 +149,7 @@ function EntryPickerModal({
|
|
|
145
149
|
);
|
|
146
150
|
const query = useMemo(() => {
|
|
147
151
|
const terms = search.replace(/,/g, " ").split(" ").filter(Boolean);
|
|
148
|
-
if (!withNavigation && condition) {
|
|
152
|
+
if (!withNavigation && condition && !pickChildren) {
|
|
149
153
|
return {
|
|
150
154
|
select: Entry,
|
|
151
155
|
search: terms,
|
|
@@ -9,10 +9,14 @@ import { EntryReference } from './EntryReference.js';
|
|
|
9
9
|
export interface EntryPickerOptions<Definition = {}> {
|
|
10
10
|
selection: Projection;
|
|
11
11
|
defaultView?: 'row' | 'thumb';
|
|
12
|
+
/** Show entries from a specific workspace/root */
|
|
12
13
|
location?: {
|
|
13
14
|
workspace: string;
|
|
14
15
|
root: string;
|
|
15
16
|
};
|
|
17
|
+
/** Choose from direct children of the currently edited entry */
|
|
18
|
+
pickChildren?: boolean;
|
|
19
|
+
/** Filter entries by a condition */
|
|
16
20
|
condition?: Filter<EntryFields & Entry>;
|
|
17
21
|
withNavigation?: boolean;
|
|
18
22
|
showMedia?: boolean;
|