alinea 1.0.9 → 1.0.11

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.
Files changed (32) hide show
  1. package/dist/backend/Database.js +9 -5
  2. package/dist/backend/Handler.js +4 -3
  3. package/dist/backend/api/CreateBackend.js +6 -4
  4. package/dist/backend/api/DatabaseApi.js +2 -1
  5. package/dist/backend/db/AlineaMeta.js +2 -1
  6. package/dist/backend/resolver/EntryResolver.js +10 -6
  7. package/dist/backend/resolver/ResolveContext.js +2 -1
  8. package/dist/backend/store/CreateStore.js +4 -3
  9. package/dist/chunks/{chunk-2SN4RMLB.js → chunk-HU44ASGU.js} +1 -1
  10. package/dist/chunks/{chunk-7QAWWRC2.js → chunk-ISD22PQJ.js} +1 -1
  11. package/dist/chunks/{chunk-GJVBDW34.js → chunk-JIO2R3P5.js} +5 -3
  12. package/dist/chunks/{chunk-FJQPWG45.js → chunk-JP5I7Q2C.js} +2 -15
  13. package/dist/chunks/chunk-PP4WBJ5A.js +22 -0
  14. package/dist/chunks/{chunk-P7DW7K2S.js → chunk-SL23EYVY.js} +2 -11
  15. package/dist/chunks/chunk-TY4DZG7T.js +15 -0
  16. package/dist/chunks/{sql.js-JLSQSBB5.js → sql.js-D7OQZ4PN.js} +4 -3
  17. package/dist/cli/Generate.js +17 -5
  18. package/dist/cli/Serve.js +1 -1
  19. package/dist/cli/bin.js +1 -1
  20. package/dist/cloud/CloudBackend.js +1 -1
  21. package/dist/core/EntryRow.js +4 -2
  22. package/dist/core/EntrySearch.js +2 -1
  23. package/dist/core/Transaction.js +27 -31
  24. package/dist/dashboard/atoms/EntryEditorAtoms.js +1 -1
  25. package/dist/dashboard/util/PersistentStore.js +5 -4
  26. package/dist/dashboard/view/EntryEdit.js +2 -6
  27. package/dist/dashboard/view/entry/NewEntry.js +2 -5
  28. package/dist/field/link/EntryLink.js +0 -2
  29. package/dist/field/link/Link.d.ts +2 -1
  30. package/dist/picker/entry/EntryPicker.browser.js +16 -16
  31. package/dist/picker/entry/EntryPicker.d.ts +7 -4
  32. package/package.json +1 -1
@@ -1,10 +1,12 @@
1
1
  import {
2
- coalesce,
2
+ coalesce
3
+ } from "../chunks/chunk-SL23EYVY.js";
4
+ import {
3
5
  count
4
- } from "../chunks/chunk-P7DW7K2S.js";
6
+ } from "../chunks/chunk-TY4DZG7T.js";
5
7
  import {
6
8
  Builder
7
- } from "../chunks/chunk-2SN4RMLB.js";
9
+ } from "../chunks/chunk-HU44ASGU.js";
8
10
  import {
9
11
  and,
10
12
  asc,
@@ -17,9 +19,11 @@ import {
17
19
  or
18
20
  } from "../chunks/chunk-VIUJF6GZ.js";
19
21
  import {
20
- Functions,
21
22
  alias
22
- } from "../chunks/chunk-FJQPWG45.js";
23
+ } from "../chunks/chunk-JP5I7Q2C.js";
24
+ import {
25
+ Functions
26
+ } from "../chunks/chunk-PP4WBJ5A.js";
23
27
  import "../chunks/chunk-TA6APWUQ.js";
24
28
  import {
25
29
  sql
@@ -23,6 +23,7 @@ import { JWTPreviews } from "alinea/backend/util/JWTPreviews";
23
23
  import { cloudBackend } from "alinea/cloud/CloudBackend";
24
24
  import { formatDraftKey } from "alinea/core/Draft";
25
25
  import { Graph } from "alinea/core/Graph";
26
+ import { HttpError } from "alinea/core/HttpError";
26
27
  import { MutationType } from "alinea/core/Mutation";
27
28
  import { getScope } from "alinea/core/Scope";
28
29
  import { decode } from "alinea/core/util/BufferToBase64";
@@ -115,9 +116,9 @@ function createHandler(cms, backend = cloudBackend(cms.config), database = gener
115
116
  await Promise.all(tasks);
116
117
  return { commitHash: result.commitHash };
117
118
  } catch (error) {
118
- if ("expectedCommitHash" in error) {
119
- if (retry)
120
- throw error;
119
+ if (retry)
120
+ throw error;
121
+ if (error instanceof HttpError && error.code === 409) {
121
122
  await syncPending(ctx);
122
123
  return mutate(ctx, mutations, true);
123
124
  }
@@ -10,8 +10,8 @@ import {
10
10
  sqliteDialect,
11
11
  sqliteDiff,
12
12
  txGenerator
13
- } from "../../chunks/chunk-GJVBDW34.js";
14
- import "../../chunks/chunk-2SN4RMLB.js";
13
+ } from "../../chunks/chunk-JIO2R3P5.js";
14
+ import "../../chunks/chunk-HU44ASGU.js";
15
15
  import {
16
16
  and,
17
17
  asc,
@@ -28,9 +28,11 @@ import {
28
28
  column
29
29
  } from "../../chunks/chunk-32G2RF2U.js";
30
30
  import {
31
- Functions,
32
31
  table
33
- } from "../../chunks/chunk-FJQPWG45.js";
32
+ } from "../../chunks/chunk-JP5I7Q2C.js";
33
+ import {
34
+ Functions
35
+ } from "../../chunks/chunk-PP4WBJ5A.js";
34
36
  import {
35
37
  input
36
38
  } from "../../chunks/chunk-TA6APWUQ.js";
@@ -15,7 +15,8 @@ import {
15
15
  import "../../chunks/chunk-32G2RF2U.js";
16
16
  import {
17
17
  table
18
- } from "../../chunks/chunk-FJQPWG45.js";
18
+ } from "../../chunks/chunk-JP5I7Q2C.js";
19
+ import "../../chunks/chunk-PP4WBJ5A.js";
19
20
  import "../../chunks/chunk-TA6APWUQ.js";
20
21
  import "../../chunks/chunk-BSPPZNS4.js";
21
22
  import {
@@ -4,7 +4,8 @@ import {
4
4
  import "../../chunks/chunk-32G2RF2U.js";
5
5
  import {
6
6
  table
7
- } from "../../chunks/chunk-FJQPWG45.js";
7
+ } from "../../chunks/chunk-JP5I7Q2C.js";
8
+ import "../../chunks/chunk-PP4WBJ5A.js";
8
9
  import "../../chunks/chunk-TA6APWUQ.js";
9
10
  import "../../chunks/chunk-BSPPZNS4.js";
10
11
  import "../../chunks/chunk-U5RRZUYZ.js";
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  bm25,
3
- count,
4
3
  snippet
5
- } from "../../chunks/chunk-P7DW7K2S.js";
4
+ } from "../../chunks/chunk-SL23EYVY.js";
5
+ import {
6
+ count
7
+ } from "../../chunks/chunk-TY4DZG7T.js";
6
8
  import {
7
9
  any,
8
10
  array,
@@ -12,7 +14,7 @@ import {
12
14
  Builder,
13
15
  Select,
14
16
  selection
15
- } from "../../chunks/chunk-2SN4RMLB.js";
17
+ } from "../../chunks/chunk-HU44ASGU.js";
16
18
  import {
17
19
  and,
18
20
  asc,
@@ -32,10 +34,12 @@ import {
32
34
  or
33
35
  } from "../../chunks/chunk-VIUJF6GZ.js";
34
36
  import {
35
- Functions,
36
37
  alias,
37
38
  jsonExpr
38
- } from "../../chunks/chunk-FJQPWG45.js";
39
+ } from "../../chunks/chunk-JP5I7Q2C.js";
40
+ import {
41
+ Functions
42
+ } from "../../chunks/chunk-PP4WBJ5A.js";
39
43
  import {
40
44
  input
41
45
  } from "../../chunks/chunk-TA6APWUQ.js";
@@ -252,7 +256,7 @@ var EntryResolver = class {
252
256
  this.conditionStatus(Child, ctx.status),
253
257
  lt(
254
258
  self.level,
255
- Math.min(query.children?.depth ?? MAX_DEPTH, MAX_DEPTH)
259
+ Math.min(query.children?.depth ?? 1, MAX_DEPTH)
256
260
  )
257
261
  )
258
262
  )
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  alias
3
- } from "../../chunks/chunk-FJQPWG45.js";
3
+ } from "../../chunks/chunk-JP5I7Q2C.js";
4
+ import "../../chunks/chunk-PP4WBJ5A.js";
4
5
  import "../../chunks/chunk-TA6APWUQ.js";
5
6
  import "../../chunks/chunk-BSPPZNS4.js";
6
7
  import "../../chunks/chunk-U5RRZUYZ.js";
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  connect
3
- } from "../../chunks/chunk-GJVBDW34.js";
4
- import "../../chunks/chunk-2SN4RMLB.js";
3
+ } from "../../chunks/chunk-JIO2R3P5.js";
4
+ import "../../chunks/chunk-HU44ASGU.js";
5
5
  import "../../chunks/chunk-VIUJF6GZ.js";
6
6
  import "../../chunks/chunk-32G2RF2U.js";
7
- import "../../chunks/chunk-FJQPWG45.js";
7
+ import "../../chunks/chunk-JP5I7Q2C.js";
8
+ import "../../chunks/chunk-PP4WBJ5A.js";
8
9
  import "../../chunks/chunk-TA6APWUQ.js";
9
10
  import "../../chunks/chunk-BSPPZNS4.js";
10
11
  import "../../chunks/chunk-U5RRZUYZ.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-VIUJF6GZ.js";
4
4
  import {
5
5
  Field
6
- } from "./chunk-FJQPWG45.js";
6
+ } from "./chunk-JP5I7Q2C.js";
7
7
  import {
8
8
  input
9
9
  } from "./chunk-TA6APWUQ.js";
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "1.0.9",
5
+ version: "1.0.11",
6
6
  description: "Headless git-based CMS",
7
7
  repository: {
8
8
  type: "git",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Builder,
3
3
  QueryBatch
4
- } from "./chunk-2SN4RMLB.js";
4
+ } from "./chunk-HU44ASGU.js";
5
5
  import {
6
6
  eq
7
7
  } from "./chunk-VIUJF6GZ.js";
@@ -9,11 +9,13 @@ import {
9
9
  column
10
10
  } from "./chunk-32G2RF2U.js";
11
11
  import {
12
- callFunction,
13
12
  jsonAggregateArray,
14
13
  jsonArray,
15
14
  table
16
- } from "./chunk-FJQPWG45.js";
15
+ } from "./chunk-JP5I7Q2C.js";
16
+ import {
17
+ callFunction
18
+ } from "./chunk-PP4WBJ5A.js";
17
19
  import {
18
20
  Sql,
19
21
  getData,
@@ -1,6 +1,6 @@
1
1
  import {
2
- input
3
- } from "./chunk-TA6APWUQ.js";
2
+ callFunction
3
+ } from "./chunk-PP4WBJ5A.js";
4
4
  import {
5
5
  getConstraint,
6
6
  getData,
@@ -15,17 +15,6 @@ import {
15
15
  sql
16
16
  } from "./chunk-BSPPZNS4.js";
17
17
 
18
- // node_modules/rado/dist/core/expr/Functions.js
19
- function callFunction(name, args) {
20
- return sql`${name}(${sql.join(args.map(input), sql`, `)})`;
21
- }
22
- function get(target, method) {
23
- return target[method] ??= (...args) => {
24
- return callFunction(sql.identifier(method), args);
25
- };
26
- }
27
- var Functions = new Proxy(/* @__PURE__ */ Object.create(null), { get });
28
-
29
18
  // node_modules/rado/dist/core/Index.js
30
19
  var IndexData = class {
31
20
  fields;
@@ -264,8 +253,6 @@ function alias(table2, alias2) {
264
253
  }
265
254
 
266
255
  export {
267
- callFunction,
268
- Functions,
269
256
  Field,
270
257
  index,
271
258
  jsonExpr,
@@ -0,0 +1,22 @@
1
+ import {
2
+ input
3
+ } from "./chunk-TA6APWUQ.js";
4
+ import {
5
+ sql
6
+ } from "./chunk-BSPPZNS4.js";
7
+
8
+ // node_modules/rado/dist/core/expr/Functions.js
9
+ function callFunction(name, args) {
10
+ return sql`${name}(${sql.join(args.map(input), sql`, `)})`;
11
+ }
12
+ function get(target, method) {
13
+ return target[method] ??= (...args) => {
14
+ return callFunction(sql.identifier(method), args);
15
+ };
16
+ }
17
+ var Functions = new Proxy(/* @__PURE__ */ Object.create(null), { get });
18
+
19
+ export {
20
+ callFunction,
21
+ Functions
22
+ };
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  Functions
3
- } from "./chunk-FJQPWG45.js";
4
- import {
5
- sql
6
- } from "./chunk-BSPPZNS4.js";
3
+ } from "./chunk-PP4WBJ5A.js";
7
4
 
8
5
  // node_modules/rado/dist/sqlite/functions.js
9
6
  var count = Functions.count;
@@ -79,14 +76,8 @@ var datetime = Functions.datetime;
79
76
  var julianday = Functions.julianday;
80
77
  var strftime = Functions.strftime;
81
78
 
82
- // node_modules/rado/dist/core/expr/Aggregate.js
83
- function count2(input) {
84
- return Functions.count(input ?? sql`*`).mapWith(Number);
85
- }
86
-
87
79
  export {
88
80
  bm25,
89
81
  snippet,
90
- coalesce,
91
- count2 as count
82
+ coalesce
92
83
  };
@@ -0,0 +1,15 @@
1
+ import {
2
+ Functions
3
+ } from "./chunk-PP4WBJ5A.js";
4
+ import {
5
+ sql
6
+ } from "./chunk-BSPPZNS4.js";
7
+
8
+ // node_modules/rado/dist/core/expr/Aggregate.js
9
+ function count(input) {
10
+ return Functions.count(input ?? sql`*`).mapWith(Number);
11
+ }
12
+
13
+ export {
14
+ count
15
+ };
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-GJVBDW34.js";
4
- import "./chunk-2SN4RMLB.js";
3
+ } from "./chunk-JIO2R3P5.js";
4
+ import "./chunk-HU44ASGU.js";
5
5
  import "./chunk-VIUJF6GZ.js";
6
6
  import "./chunk-32G2RF2U.js";
7
- import "./chunk-FJQPWG45.js";
7
+ import "./chunk-JP5I7Q2C.js";
8
+ import "./chunk-PP4WBJ5A.js";
8
9
  import "./chunk-TA6APWUQ.js";
9
10
  import "./chunk-BSPPZNS4.js";
10
11
  import "./chunk-U5RRZUYZ.js";
@@ -1,11 +1,19 @@
1
1
  import {
2
2
  prettyBytes
3
3
  } from "../chunks/chunk-VRNNS7VT.js";
4
+ import {
5
+ count
6
+ } from "../chunks/chunk-TY4DZG7T.js";
7
+ import "../chunks/chunk-VIUJF6GZ.js";
8
+ import "../chunks/chunk-PP4WBJ5A.js";
9
+ import "../chunks/chunk-TA6APWUQ.js";
10
+ import "../chunks/chunk-BSPPZNS4.js";
4
11
  import "../chunks/chunk-U5RRZUYZ.js";
5
12
 
6
13
  // src/cli/Generate.ts
7
14
  import { exportStore } from "alinea/cli/util/ExportStore.server";
8
15
  import { Config } from "alinea/core/Config";
16
+ import { EntryRow } from "alinea/core/EntryRow";
9
17
  import { genEffect } from "alinea/core/util/Async";
10
18
  import { basename, join } from "alinea/core/util/Paths";
11
19
  import fs from "node:fs";
@@ -40,7 +48,7 @@ async function generatePackage(context, cms) {
40
48
  async function createDb() {
41
49
  const { default: sqlite } = await import("@alinea/sqlite-wasm");
42
50
  const { Database } = await sqlite();
43
- const { connect } = await import("../chunks/sql.js-JLSQSBB5.js");
51
+ const { connect } = await import("../chunks/sql.js-D7OQZ4PN.js");
44
52
  const db = new Database();
45
53
  const store = connect(db);
46
54
  return [store, () => db.export()];
@@ -94,7 +102,7 @@ async function* generate(options) {
94
102
  process.exit(1);
95
103
  }
96
104
  }
97
- const write = async () => {
105
+ const write = async (recordCount) => {
98
106
  let dbSize = 0;
99
107
  if (cmd === "build") {
100
108
  ;
@@ -112,7 +120,9 @@ async function* generate(options) {
112
120
  else
113
121
  message += `${duration.toFixed(0)}ms`;
114
122
  if (dbSize > 0)
115
- message += ` (db ${prettyBytes(dbSize)})`;
123
+ message += ` (db ${prettyBytes(dbSize)}, ${recordCount} records)`;
124
+ else
125
+ message += ` (${recordCount} records)`;
116
126
  return message;
117
127
  };
118
128
  const fileData = new LocalData({
@@ -131,8 +141,9 @@ async function* generate(options) {
131
141
  }
132
142
  for await (const db of indexing) {
133
143
  yield { cms, db, localData: fileData };
134
- if (onAfterGenerate && !afterGenerateCalled)
135
- await write().then(
144
+ if (onAfterGenerate && !afterGenerateCalled) {
145
+ const recordCount = await db.store.select(count()).from(EntryRow).get();
146
+ await write(recordCount ?? 0).then(
136
147
  (message) => {
137
148
  afterGenerateCalled = true;
138
149
  onAfterGenerate(message);
@@ -143,6 +154,7 @@ async function* generate(options) {
143
154
  process.exit(1);
144
155
  }
145
156
  );
157
+ }
146
158
  }
147
159
  }
148
160
  }
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-7QAWWRC2.js";
3
+ } from "../chunks/chunk-ISD22PQJ.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-7QAWWRC2.js";
3
+ } from "../chunks/chunk-ISD22PQJ.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-7QAWWRC2.js";
3
+ } from "../chunks/chunk-ISD22PQJ.js";
4
4
  import {
5
5
  PLazy
6
6
  } from "../chunks/chunk-IKINPSS5.js";
@@ -11,10 +11,12 @@ import {
11
11
  column
12
12
  } from "../chunks/chunk-32G2RF2U.js";
13
13
  import {
14
- Functions,
15
14
  index,
16
15
  table
17
- } from "../chunks/chunk-FJQPWG45.js";
16
+ } from "../chunks/chunk-JP5I7Q2C.js";
17
+ import {
18
+ Functions
19
+ } from "../chunks/chunk-PP4WBJ5A.js";
18
20
  import {
19
21
  input
20
22
  } from "../chunks/chunk-TA6APWUQ.js";
@@ -5,7 +5,8 @@ import {
5
5
  import "../chunks/chunk-32G2RF2U.js";
6
6
  import {
7
7
  table
8
- } from "../chunks/chunk-FJQPWG45.js";
8
+ } from "../chunks/chunk-JP5I7Q2C.js";
9
+ import "../chunks/chunk-PP4WBJ5A.js";
9
10
  import "../chunks/chunk-TA6APWUQ.js";
10
11
  import "../chunks/chunk-BSPPZNS4.js";
11
12
  import "../chunks/chunk-U5RRZUYZ.js";
@@ -153,60 +153,56 @@ var UpdateOperation = class extends Operation {
153
153
  status = "preferDraft";
154
154
  else
155
155
  status = "preferPublished";
156
- const entry = await cms.get({
156
+ const current = await cms.get({
157
157
  select: Entry,
158
158
  id: entryId,
159
159
  locale: query.locale,
160
160
  status
161
161
  });
162
- const parent = entry.parentId ? await cms.get({
162
+ const parent = current.parentId ? await cms.get({
163
163
  select: Entry,
164
- id: entry.parentId,
164
+ id: current.parentId,
165
165
  locale: query.locale,
166
166
  status: "preferPublished"
167
167
  }) : void 0;
168
- const parentPaths = entryParentPaths(cms.config, entry);
168
+ const parentPaths = entryParentPaths(cms.config, current);
169
169
  const file = entryFileName(
170
170
  cms.config,
171
- { ...entry, status: entry.status },
171
+ { ...current, status: current.status },
172
172
  parentPaths
173
173
  );
174
- const type = cms.config.schema[entry.type];
174
+ const type = cms.config.schema[current.type];
175
175
  const mutations = [];
176
176
  const createDraft = changeStatus === EntryStatus.Draft;
177
- if (createDraft)
177
+ const fieldUpdates = set && fromEntries(
178
+ entries(set).map(([key, value]) => {
179
+ return [key, value ?? null];
180
+ })
181
+ );
182
+ const entry = await createEntry(
183
+ cms.config,
184
+ this.typeName(cms.config, type),
185
+ {
186
+ ...current,
187
+ status: createDraft ? EntryStatus.Draft : current.status,
188
+ data: { ...current.data, ...fieldUpdates }
189
+ },
190
+ parent
191
+ );
192
+ if (createDraft || set)
178
193
  mutations.push({
179
194
  type: MutationType.Edit,
180
195
  entryId,
181
- locale: entry.locale,
196
+ locale: current.locale,
182
197
  file,
183
- entry: await createEntry(
184
- cms.config,
185
- this.typeName(cms.config, type),
186
- {
187
- ...entry,
188
- status: EntryStatus.Draft,
189
- data: { ...entry.data, ...set }
190
- },
191
- parent
192
- )
193
- });
194
- else if (set)
195
- mutations.push({
196
- type: MutationType.Patch,
197
- entryId,
198
- locale: entry.locale,
199
- file,
200
- patch: fromEntries(
201
- entries(set).map(([key, value]) => [key, value ?? null])
202
- )
198
+ entry
203
199
  });
204
200
  switch (changeStatus) {
205
201
  case EntryStatus.Published:
206
202
  mutations.push({
207
203
  type: MutationType.Publish,
208
- locale: entry.locale,
209
- status: entry.status,
204
+ locale: current.locale,
205
+ status: current.status,
210
206
  entryId,
211
207
  file
212
208
  });
@@ -215,7 +211,7 @@ var UpdateOperation = class extends Operation {
215
211
  mutations.push({
216
212
  type: MutationType.Archive,
217
213
  entryId,
218
- locale: entry.locale,
214
+ locale: current.locale,
219
215
  file
220
216
  });
221
217
  break;
@@ -161,7 +161,7 @@ var entryEditorAtoms = atomFamily(
161
161
  const parentLink = entry.parentId && await graph.first({
162
162
  select: Entry.id,
163
163
  id: entry.parentId,
164
- locale,
164
+ locale: searchLocale,
165
165
  status: "preferDraft"
166
166
  });
167
167
  const parentNeedsTranslation = entry.parentId ? !parentLink : false;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../../chunks/chunk-7QAWWRC2.js";
3
+ } from "../../chunks/chunk-ISD22PQJ.js";
4
4
  import {
5
5
  create as create2
6
6
  } from "../../chunks/chunk-IOTY7UTU.js";
@@ -9,11 +9,12 @@ import {
9
9
  } from "../../chunks/chunk-BRTZLYIM.js";
10
10
  import {
11
11
  connect
12
- } from "../../chunks/chunk-GJVBDW34.js";
13
- import "../../chunks/chunk-2SN4RMLB.js";
12
+ } from "../../chunks/chunk-JIO2R3P5.js";
13
+ import "../../chunks/chunk-HU44ASGU.js";
14
14
  import "../../chunks/chunk-VIUJF6GZ.js";
15
15
  import "../../chunks/chunk-32G2RF2U.js";
16
- import "../../chunks/chunk-FJQPWG45.js";
16
+ import "../../chunks/chunk-JP5I7Q2C.js";
17
+ import "../../chunks/chunk-PP4WBJ5A.js";
17
18
  import "../../chunks/chunk-TA6APWUQ.js";
18
19
  import "../../chunks/chunk-BSPPZNS4.js";
19
20
  import "../../chunks/chunk-U5RRZUYZ.js";
@@ -201,17 +201,13 @@ function EntryEdit({ editor }) {
201
201
  }
202
202
  ),
203
203
  /* @__PURE__ */ jsxs(Main.Container, { children: [
204
- untranslated && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
204
+ untranslated && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
205
205
  EntryNotice,
206
206
  {
207
207
  icon: IcRoundTranslate,
208
208
  title: "Untranslated",
209
209
  variant: "untranslated",
210
- children: [
211
- "This page has not yet been translated to this language,",
212
- /* @__PURE__ */ jsx("br", {}),
213
- editor.parentNeedsTranslation ? "please translate the parent page first." : "please enter the details below and save to start translating."
214
- ]
210
+ children: editor.parentNeedsTranslation ? "Translate the parent page first." : "Enter the details below and save to start translating."
215
211
  }
216
212
  ) }),
217
213
  /* @__PURE__ */ jsx(EntryEditorProvider, { editor, children: /* @__PURE__ */ jsx(SuspenseBoundary, { name: "input form", children: mode === EditMode.Diff ? /* @__PURE__ */ jsx(ShowChanges, { editor }) : hasRootTabs && visibleTypes ? /* @__PURE__ */ jsx(Tabs.Panels, { children: visibleTypes.map((type, i) => {
@@ -114,11 +114,9 @@ function NewEntryForm({ parentId }) {
114
114
  const root = useRoot();
115
115
  const parentField = useMemo(() => {
116
116
  return entry("Parent", {
117
- location: {
118
- workspace,
119
- root: root.name
120
- },
117
+ location: { workspace, root: root.name },
121
118
  condition: { _type: { in: containerTypes } },
119
+ enableNavigation: true,
122
120
  initialValue: preselectedId ? {
123
121
  [Reference.id]: "parent",
124
122
  [Reference.type]: "entry",
@@ -169,7 +167,6 @@ function NewEntryForm({ parentId }) {
169
167
  pickers: {
170
168
  entry: entryPicker({
171
169
  condition: { _type: type2 },
172
- withNavigation: false,
173
170
  title: "Copy content from",
174
171
  max: 1,
175
172
  selection: EntryLink
@@ -22,7 +22,6 @@ function entry(label, options = {}) {
22
22
  pickers: {
23
23
  entry: entryPicker({
24
24
  ...options,
25
- withNavigation: Boolean(!options.condition && !options.pickChildren),
26
25
  title: "Select a page",
27
26
  max: 1,
28
27
  selection: EntryLink
@@ -37,7 +36,6 @@ function entry(label, options = {}) {
37
36
  pickers: {
38
37
  entry: entryPicker({
39
38
  ...options,
40
- withNavigation: Boolean(!options.condition && !options.pickChildren),
41
39
  title: "Select a page",
42
40
  selection: EntryLink
43
41
  })
@@ -4,12 +4,13 @@ import { Type } from 'alinea/core/Type';
4
4
  import type { ListRow } from 'alinea/core/shape/ListShape';
5
5
  import { FileLink } from 'alinea/field/link/FileLink';
6
6
  import { LinkField, LinkFieldOptions } from 'alinea/field/link/LinkField';
7
+ import { EntryPickerConditions } from 'alinea/picker/entry';
7
8
  import { EntryReference } from 'alinea/picker/entry/EntryReference';
8
9
  import { UrlReference } from 'alinea/picker/url';
9
10
  import { EntryLink } from './EntryLink.js';
10
11
  import { UrlLink } from './UrlLink.js';
11
12
  export type Link<InferredFields> = EntryLink<InferredFields> | UrlLink<InferredFields> | FileLink<InferredFields>;
12
- export interface LinkOptions<Definition, Row> extends LinkFieldOptions<Row> {
13
+ export interface LinkOptions<Definition, Row> extends LinkFieldOptions<Row>, EntryPickerConditions {
13
14
  fields?: Definition | Type<Definition>;
14
15
  }
15
16
  export type LinkRow = (EntryReference | UrlReference) & ListRow;
@@ -90,7 +90,6 @@ function EntryPickerModal({
90
90
  max,
91
91
  pickChildren,
92
92
  condition,
93
- withNavigation,
94
93
  showMedia
95
94
  } = options;
96
95
  const [search, setSearch] = useState("");
@@ -147,25 +146,26 @@ function EntryPickerModal({
147
146
  });
148
147
  }
149
148
  );
149
+ const withNavigation = options.enableNavigation || !options.condition && !options.pickChildren;
150
150
  const query = useMemo(() => {
151
151
  const terms = search.replace(/,/g, " ").split(" ").filter(Boolean);
152
- const showAll = terms.length === 0 || condition || pickChildren;
152
+ const filter = {
153
+ and: [
154
+ condition,
155
+ {
156
+ _workspace: destination.workspace,
157
+ _root: destination.root,
158
+ _parentId: withNavigation || pickChildren ? destination.parentId ?? null : void 0,
159
+ _locale: destinationLocale
160
+ }
161
+ ]
162
+ };
153
163
  return {
154
164
  select: Entry,
155
- filter: {
156
- and: [
157
- condition,
158
- {
159
- _workspace: destination.workspace,
160
- _root: destination.root,
161
- _parentId: showAll ? void 0 : destination.parentId ?? null,
162
- _locale: destinationLocale
163
- }
164
- ]
165
- },
165
+ filter,
166
166
  search: terms
167
167
  };
168
- }, [destination, destinationLocale, search, condition]);
168
+ }, [withNavigation, destination, destinationLocale, search, condition]);
169
169
  const [view, setView] = useState(defaultView || "row");
170
170
  const handleSelect = useCallback(
171
171
  (entry) => {
@@ -189,7 +189,7 @@ function EntryPickerModal({
189
189
  return res;
190
190
  });
191
191
  },
192
- [setSelected, max]
192
+ [onConfirm, type, max]
193
193
  );
194
194
  function handleConfirm() {
195
195
  onConfirm(selected);
@@ -255,7 +255,7 @@ function EntryPickerModal({
255
255
  }
256
256
  )
257
257
  ] }),
258
- !search && parentEntries?.map(({ id, title: title2 }) => {
258
+ parentEntries?.map(({ id, title: title2 }) => {
259
259
  return /* @__PURE__ */ jsx(BreadcrumbsItem, { children: /* @__PURE__ */ jsx(
260
260
  "button",
261
261
  {
@@ -6,9 +6,7 @@ import { Label } from 'alinea/core/Label';
6
6
  import { Picker } from 'alinea/core/Picker';
7
7
  import { Type } from 'alinea/core/Type';
8
8
  import { EntryReference } from './EntryReference.js';
9
- export interface EntryPickerOptions<Definition = {}> {
10
- selection: Projection;
11
- defaultView?: 'row' | 'thumb';
9
+ export interface EntryPickerConditions {
12
10
  /** Show entries from a specific workspace/root */
13
11
  location?: {
14
12
  workspace: string;
@@ -18,7 +16,12 @@ export interface EntryPickerOptions<Definition = {}> {
18
16
  pickChildren?: boolean;
19
17
  /** Filter entries by a condition */
20
18
  condition?: Filter<EntryFields & Entry>;
21
- withNavigation?: boolean;
19
+ /** Enable entry picker navigation */
20
+ enableNavigation?: boolean;
21
+ }
22
+ export interface EntryPickerOptions<Definition = {}> extends EntryPickerConditions {
23
+ selection: Projection;
24
+ defaultView?: 'row' | 'thumb';
22
25
  showMedia?: boolean;
23
26
  max?: number;
24
27
  label?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "bin": "./dist/cli.js",
3
3
  "name": "alinea",
4
- "version": "1.0.9",
4
+ "version": "1.0.11",
5
5
  "description": "Headless git-based CMS",
6
6
  "repository": {
7
7
  "type": "git",