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.
@@ -622,8 +622,8 @@ ${JSON.stringify(mutation)}`
622
622
  }
623
623
  }
624
624
  if (fix && v0Ids.size > 0) {
625
- const entries3 = await tx.select().from(EntryRow);
626
- for (const entry of entries3) {
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
- const isInserted = sql`(${EntryRow.id}, ${coalesce(
708
- EntryRow.locale,
709
- sql`'null'`
710
- )}, ${EntryRow.status}) in ${values(...inserted)}`;
711
- const entries2 = await tx.select().from(EntryRow).where(isInserted);
712
- for (const entry of entries2) {
713
- const rowHash = await createRowHash(entry);
714
- await tx.update(EntryRow).set({
715
- rowHash
716
- }).where(
717
- eq(EntryRow.id, entry.id),
718
- is(EntryRow.locale, entry.locale),
719
- eq(EntryRow.status, entry.status)
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.status);
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
- status: Status;
9
+ private ctx;
10
10
  loaders: Map<Projection, DataLoader<string, object, string>>;
11
- constructor(resolver: EntryResolver, store: Store, status: Status);
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, status) {
13
+ constructor(resolver, store, ctx) {
14
14
  this.resolver = resolver;
15
15
  this.store = store;
16
- this.status = status;
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({ status: this.status }),
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
- console.error(result);
50
- return void 0;
52
+ Error.captureStackTrace(result);
53
+ throw result;
51
54
  }
52
55
  return result;
53
56
  });
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "1.0.4",
5
+ version: "1.0.6",
6
6
  description: "Headless git-based CMS",
7
7
  repository: {
8
8
  type: "git",
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-MCCVEGL3.js";
3
+ } from "../chunks/chunk-MAYW4CMH.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // src/cli/Serve.ts
package/dist/cli/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-MCCVEGL3.js";
3
+ } from "../chunks/chunk-MAYW4CMH.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-MCCVEGL3.js";
3
+ } from "../chunks/chunk-MAYW4CMH.js";
4
4
  import {
5
5
  PLazy
6
6
  } from "../chunks/chunk-IKINPSS5.js";
@@ -409,7 +409,7 @@ var RichTextShape = class {
409
409
  if (mark[Mark.type] !== "link")
410
410
  return;
411
411
  const entryId = mark[LinkMark.entry];
412
- if (entryId)
412
+ if (typeof entryId === "string")
413
413
  links.set(mark, entryId);
414
414
  });
415
415
  async function loadLinks() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../../chunks/chunk-MCCVEGL3.js";
3
+ } from "../../chunks/chunk-MAYW4CMH.js";
4
4
  import {
5
5
  create as create2
6
6
  } from "../../chunks/chunk-IOTY7UTU.js";
@@ -22,7 +22,9 @@ function entry(label, options = {}) {
22
22
  pickers: {
23
23
  entry: entryPicker({
24
24
  ...options,
25
- withNavigation: Boolean(options.location || !options.condition),
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: !options.condition,
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "bin": "./dist/cli.js",
3
3
  "name": "alinea",
4
- "version": "1.0.4",
4
+ "version": "1.0.6",
5
5
  "description": "Headless git-based CMS",
6
6
  "repository": {
7
7
  "type": "git",