alinea 0.4.0 → 0.4.2

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 (92) hide show
  1. package/LICENSE +21 -21
  2. package/dist/alinea.d.ts +1 -1
  3. package/dist/alinea.js +1 -10
  4. package/dist/backend/Handler.js +2 -1
  5. package/dist/backend/resolver/EntryResolver.d.ts +3 -36
  6. package/dist/backend/resolver/EntryResolver.js +31 -105
  7. package/dist/backend/resolver/LinkResolver.d.ts +1 -1
  8. package/dist/backend/resolver/LinkResolver.js +3 -3
  9. package/dist/backend/resolver/ResolveContext.d.ts +38 -0
  10. package/dist/backend/resolver/ResolveContext.js +83 -0
  11. package/dist/chunks/{chunk-KDSPNPHI.js → chunk-LRUUF55J.js} +2 -2
  12. package/dist/cli/Serve.js +1 -1
  13. package/dist/cli/bin.js +1 -1
  14. package/dist/cli/generate/GenerateDashboard.js +1 -1
  15. package/dist/cli.js +0 -0
  16. package/dist/cloud/server/CloudAuthServer.js +1 -1
  17. package/dist/core/Field.d.ts +0 -26
  18. package/dist/core/Field.js +0 -56
  19. package/dist/core/Graph.js +4 -4
  20. package/dist/core/Type.js +9 -3
  21. package/dist/core/View.js +2 -2
  22. package/dist/core/driver/NextDriver.server.js +2 -2
  23. package/dist/core/field/ListField.d.ts +8 -0
  24. package/dist/core/field/ListField.js +21 -0
  25. package/dist/core/field/RecordField.d.ts +5 -0
  26. package/dist/core/field/RecordField.js +12 -0
  27. package/dist/core/field/RichTextField.d.ts +9 -0
  28. package/dist/core/field/RichTextField.js +16 -0
  29. package/dist/core/field/ScalarField.d.ts +4 -0
  30. package/dist/core/field/ScalarField.js +16 -0
  31. package/dist/core/field/UnionField.d.ts +8 -0
  32. package/dist/core/field/UnionField.js +21 -0
  33. package/dist/core/pages/CreateExprData.d.ts +2 -0
  34. package/dist/core/pages/CreateExprData.js +24 -0
  35. package/dist/core/pages/CreateSelection.d.ts +2 -0
  36. package/dist/core/pages/CreateSelection.js +54 -0
  37. package/dist/core/pages/Cursor.d.ts +2 -1
  38. package/dist/core/pages/Cursor.js +14 -7
  39. package/dist/core/pages/Expr.d.ts +2 -95
  40. package/dist/core/pages/Expr.js +51 -160
  41. package/dist/core/pages/ExprData.d.ts +94 -0
  42. package/dist/core/pages/ExprData.js +130 -0
  43. package/dist/core/pages/Selection.d.ts +3 -4
  44. package/dist/core/pages/Selection.js +11 -55
  45. package/dist/core/pages/Target.d.ts +3 -7
  46. package/dist/core/pages/Target.js +10 -20
  47. package/dist/core/pages/TargetData.d.ts +6 -0
  48. package/dist/core/pages/TargetData.js +21 -0
  49. package/dist/core/pages/index.d.ts +4 -0
  50. package/dist/core/pages/index.js +4 -0
  51. package/dist/core.d.ts +6 -1
  52. package/dist/core.js +6 -1
  53. package/dist/dashboard/App.js +2 -1
  54. package/dist/dashboard/atoms/DashboardAtoms.js +1 -1
  55. package/dist/dashboard/atoms/DbAtoms.js +3 -3
  56. package/dist/dashboard/atoms/LocationAtoms.js +20 -12
  57. package/dist/dashboard/atoms/NavigationAtoms.js +3 -3
  58. package/dist/dashboard/view/entry/NewEntry.js +10 -9
  59. package/dist/index.d.ts +0 -1
  60. package/dist/index.js +0 -2
  61. package/dist/input/check/CheckField.d.ts +3 -2
  62. package/dist/input/check/CheckField.js +3 -2
  63. package/dist/input/code/CodeField.d.ts +3 -2
  64. package/dist/input/code/CodeField.js +3 -2
  65. package/dist/input/date/DateField.d.ts +3 -2
  66. package/dist/input/date/DateField.js +3 -2
  67. package/dist/input/hidden/HiddenField.d.ts +2 -2
  68. package/dist/input/hidden/HiddenField.js +2 -2
  69. package/dist/input/json/JsonField.d.ts +3 -2
  70. package/dist/input/json/JsonField.js +3 -2
  71. package/dist/input/link/LinkConstructors.js +2 -1
  72. package/dist/input/link/LinkField.d.ts +5 -3
  73. package/dist/input/link/LinkField.js +5 -3
  74. package/dist/input/list/ListField.browser.d.ts +4 -3
  75. package/dist/input/list/ListField.d.ts +3 -5
  76. package/dist/input/list/ListField.js +2 -4
  77. package/dist/input/metadata/MetadataField.d.ts +3 -2
  78. package/dist/input/metadata/MetadataField.js +3 -2
  79. package/dist/input/number/NumberField.d.ts +3 -2
  80. package/dist/input/number/NumberField.js +3 -2
  81. package/dist/input/object/ObjectField.d.ts +3 -2
  82. package/dist/input/object/ObjectField.js +3 -2
  83. package/dist/input/path/PathField.d.ts +3 -2
  84. package/dist/input/path/PathField.js +2 -2
  85. package/dist/input/richtext/RichTextField.browser.d.ts +3 -2
  86. package/dist/input/richtext/RichTextField.d.ts +3 -5
  87. package/dist/input/richtext/RichTextField.js +2 -4
  88. package/dist/input/select/SelectField.d.ts +3 -2
  89. package/dist/input/select/SelectField.js +2 -2
  90. package/dist/input/text/TextField.d.ts +3 -2
  91. package/dist/input/text/TextField.js +2 -2
  92. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 alineacms
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 alineacms
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/alinea.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { createConfig, Meta as meta, page, root, schema, type, workspace } from 'alinea/core';
1
+ export { Meta as meta, page, root, schema, type, workspace } from 'alinea/core';
2
2
  export type { Infer as infer } from 'alinea/core';
3
3
  export { createMediaRoot as media } from 'alinea/core/media/MediaRoot';
4
4
  export * from './input.js';
package/dist/alinea.js CHANGED
@@ -1,19 +1,10 @@
1
1
  import "./chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/alinea.ts
4
- import {
5
- createConfig,
6
- Meta,
7
- page,
8
- root,
9
- schema,
10
- type,
11
- workspace
12
- } from "alinea/core";
4
+ import { Meta, page, root, schema, type, workspace } from "alinea/core";
13
5
  import { createMediaRoot } from "alinea/core/media/MediaRoot";
14
6
  export * from "./input.js";
15
7
  export {
16
- createConfig,
17
8
  createMediaRoot as media,
18
9
  Meta as meta,
19
10
  page,
@@ -24,6 +24,7 @@ import {
24
24
  parseYDoc
25
25
  } from "alinea/core";
26
26
  import { MutationType } from "alinea/core/Mutation";
27
+ import { createSelection } from "alinea/core/pages/CreateSelection";
27
28
  import { Realm } from "alinea/core/pages/Realm";
28
29
  import { Selection } from "alinea/core/pages/Selection";
29
30
  import { base64, base64url } from "alinea/core/util/Encoding";
@@ -67,7 +68,7 @@ var Handler = class {
67
68
  await this.periodicSync();
68
69
  const update = unzlibSync(base64url.parse(preview.update));
69
70
  const entry = await this.resolver.resolve({
70
- selection: Selection.create(
71
+ selection: createSelection(
71
72
  Entry({ entryId: preview.entryId }).maybeFirst()
72
73
  ),
73
74
  realm: Realm.PreferDraft
@@ -1,48 +1,15 @@
1
1
  import { Connection, PreviewUpdate, ResolveDefaults, Schema } from 'alinea/core';
2
+ import { EntryRow, EntryTable } from 'alinea/core/EntryRow';
3
+ import type * as pages from 'alinea/core/pages';
2
4
  import { Realm } from 'alinea/core/pages/Realm';
3
5
  import { Expr, ExprData, OrderBy, QueryData, Select, Table } from 'rado';
4
- import { EntryRow, EntryTable } from '../../core/EntryRow.js';
5
- import * as pages from '../../core/pages/index.js';
6
6
  import { Database } from '../Database.js';
7
7
  import { LinkResolver } from './LinkResolver.js';
8
+ import { ResolveContext } from './ResolveContext.js';
8
9
  type Interim = any;
9
- interface ResolveContextData {
10
- realm: Realm;
11
- location: Array<string>;
12
- locale: string | undefined;
13
- depth: number;
14
- expr: ExprContext;
15
- }
16
- export declare class ResolveContext {
17
- private data;
18
- table: Table<EntryTable>;
19
- constructor(data: Partial<ResolveContextData>);
20
- linkContext(): ResolveContext;
21
- get depth(): number;
22
- get location(): string[];
23
- get realm(): Realm;
24
- get locale(): string | undefined;
25
- get expr(): ExprContext;
26
- get Table(): Table<EntryTable>;
27
- increaseDepth(): ResolveContext;
28
- decreaseDepth(): ResolveContext;
29
- get isInSelect(): number;
30
- get isInCondition(): number;
31
- get isInAccess(): number;
32
- get select(): ResolveContext;
33
- get condition(): ResolveContext;
34
- get access(): ResolveContext;
35
- get none(): ResolveContext;
36
- }
37
10
  export interface PostContext {
38
11
  linkResolver: LinkResolver;
39
12
  }
40
- declare enum ExprContext {
41
- InNone = 0,
42
- InSelect = 1,
43
- InCondition = 2,
44
- InAccess = 4
45
- }
46
13
  export declare class EntryResolver {
47
14
  db: Database;
48
15
  schema: Schema;
@@ -23,113 +23,40 @@ import {
23
23
  Type,
24
24
  unreachable
25
25
  } from "alinea/core";
26
+ import { EntryPhase, EntryRow } from "alinea/core/EntryRow";
26
27
  import { EntrySearch } from "alinea/core/EntrySearch";
28
+ import { SourceType } from "alinea/core/pages/Cursor";
29
+ import { BinaryOp, UnaryOp } from "alinea/core/pages/ExprData";
27
30
  import { Realm } from "alinea/core/pages/Realm";
28
31
  import { entries, fromEntries, keys } from "alinea/core/util/Objects";
29
- import { EntryPhase, EntryRow } from "../../core/EntryRow.js";
30
- import * as pages from "../../core/pages/index.js";
31
32
  import { Database } from "../Database.js";
32
33
  import { LinkResolver } from "./LinkResolver.js";
34
+ import { ResolveContext } from "./ResolveContext.js";
33
35
  var unOps = {
34
- [pages.UnaryOp.Not]: UnOpType.Not,
35
- [pages.UnaryOp.IsNull]: UnOpType.IsNull
36
+ [UnaryOp.Not]: UnOpType.Not,
37
+ [UnaryOp.IsNull]: UnOpType.IsNull
36
38
  };
37
39
  var binOps = {
38
- [pages.BinaryOp.Add]: BinOpType.Add,
39
- [pages.BinaryOp.Subt]: BinOpType.Subt,
40
- [pages.BinaryOp.Mult]: BinOpType.Mult,
41
- [pages.BinaryOp.Mod]: BinOpType.Mod,
42
- [pages.BinaryOp.Div]: BinOpType.Div,
43
- [pages.BinaryOp.Greater]: BinOpType.Greater,
44
- [pages.BinaryOp.GreaterOrEqual]: BinOpType.GreaterOrEqual,
45
- [pages.BinaryOp.Less]: BinOpType.Less,
46
- [pages.BinaryOp.LessOrEqual]: BinOpType.LessOrEqual,
47
- [pages.BinaryOp.Equals]: BinOpType.Equals,
48
- [pages.BinaryOp.NotEquals]: BinOpType.NotEquals,
49
- [pages.BinaryOp.And]: BinOpType.And,
50
- [pages.BinaryOp.Or]: BinOpType.Or,
51
- [pages.BinaryOp.Like]: BinOpType.Like,
52
- [pages.BinaryOp.In]: BinOpType.In,
53
- [pages.BinaryOp.NotIn]: BinOpType.NotIn,
54
- [pages.BinaryOp.Concat]: BinOpType.Concat
40
+ [BinaryOp.Add]: BinOpType.Add,
41
+ [BinaryOp.Subt]: BinOpType.Subt,
42
+ [BinaryOp.Mult]: BinOpType.Mult,
43
+ [BinaryOp.Mod]: BinOpType.Mod,
44
+ [BinaryOp.Div]: BinOpType.Div,
45
+ [BinaryOp.Greater]: BinOpType.Greater,
46
+ [BinaryOp.GreaterOrEqual]: BinOpType.GreaterOrEqual,
47
+ [BinaryOp.Less]: BinOpType.Less,
48
+ [BinaryOp.LessOrEqual]: BinOpType.LessOrEqual,
49
+ [BinaryOp.Equals]: BinOpType.Equals,
50
+ [BinaryOp.NotEquals]: BinOpType.NotEquals,
51
+ [BinaryOp.And]: BinOpType.And,
52
+ [BinaryOp.Or]: BinOpType.Or,
53
+ [BinaryOp.Like]: BinOpType.Like,
54
+ [BinaryOp.In]: BinOpType.In,
55
+ [BinaryOp.NotIn]: BinOpType.NotIn,
56
+ [BinaryOp.Concat]: BinOpType.Concat
55
57
  };
56
58
  var MAX_DEPTH = 999;
57
59
  var pageFields = keys(EntryRow);
58
- var ResolveContext = class _ResolveContext {
59
- constructor(data) {
60
- this.data = data;
61
- this.table = EntryRow().as(`E${this.depth}`);
62
- }
63
- table;
64
- linkContext() {
65
- return new _ResolveContext({
66
- realm: this.realm
67
- });
68
- }
69
- get depth() {
70
- return this.data.depth ?? 0;
71
- }
72
- get location() {
73
- return this.data.location ?? [];
74
- }
75
- get realm() {
76
- return this.data.realm ?? Realm.Published;
77
- }
78
- get locale() {
79
- return this.data.locale;
80
- }
81
- get expr() {
82
- return this.data.expr ?? 0 /* InNone */;
83
- }
84
- get Table() {
85
- return this.table;
86
- }
87
- increaseDepth() {
88
- return new _ResolveContext({ ...this.data, depth: this.depth + 1 });
89
- }
90
- decreaseDepth() {
91
- return new _ResolveContext({ ...this.data, depth: this.depth - 1 });
92
- }
93
- get isInSelect() {
94
- return this.expr & 1 /* InSelect */;
95
- }
96
- get isInCondition() {
97
- return this.expr & 2 /* InCondition */;
98
- }
99
- get isInAccess() {
100
- return this.expr & 4 /* InAccess */;
101
- }
102
- get select() {
103
- if (this.isInSelect)
104
- return this;
105
- return new _ResolveContext({
106
- ...this.data,
107
- expr: this.expr | 1 /* InSelect */
108
- });
109
- }
110
- get condition() {
111
- if (this.isInCondition)
112
- return this;
113
- return new _ResolveContext({
114
- ...this.data,
115
- expr: this.expr | 2 /* InCondition */
116
- });
117
- }
118
- get access() {
119
- if (this.isInAccess)
120
- return this;
121
- return new _ResolveContext({
122
- ...this.data,
123
- expr: this.expr | 4 /* InAccess */
124
- });
125
- }
126
- get none() {
127
- return new _ResolveContext({
128
- ...this.data,
129
- expr: this.expr | 0 /* InNone */
130
- });
131
- }
132
- };
133
60
  var EntryResolver = class {
134
61
  constructor(db, schema, parsePreview, defaults) {
135
62
  this.db = db;
@@ -286,17 +213,17 @@ var EntryResolver = class {
286
213
  return cursor.orderBy(ctx.Table.index.asc());
287
214
  const from = EntryRow().as(`E${ctx.depth - 1}`);
288
215
  switch (source.type) {
289
- case pages.SourceType.Parent:
216
+ case SourceType.Parent:
290
217
  return cursor.where(ctx.Table.entryId.is(from.parent)).take(1);
291
- case pages.SourceType.Next:
218
+ case SourceType.Next:
292
219
  return cursor.where(ctx.Table.parent.is(from.parent)).where(ctx.Table.index.isGreater(from.index)).take(1);
293
- case pages.SourceType.Previous:
220
+ case SourceType.Previous:
294
221
  return cursor.where(ctx.Table.parent.is(from.parent)).where(ctx.Table.index.isLess(from.index)).take(1);
295
- case pages.SourceType.Siblings:
222
+ case SourceType.Siblings:
296
223
  return cursor.where(ctx.Table.parent.is(from.parent)).where(ctx.Table.entryId.isNot(from.entryId));
297
- case pages.SourceType.Translations:
224
+ case SourceType.Translations:
298
225
  return cursor.where(ctx.Table.i18nId.is(from.i18nId)).where(ctx.Table.entryId.isNot(from.entryId));
299
- case pages.SourceType.Children:
226
+ case SourceType.Children:
300
227
  const Child = EntryRow().as("Child");
301
228
  const children = withRecursive(
302
229
  Child({ entryId: from.entryId }).where(
@@ -322,7 +249,7 @@ var EntryResolver = class {
322
249
  );
323
250
  const childrenIds = children().select(children.entryId).skip(1);
324
251
  return cursor.where(ctx.Table.entryId.isIn(childrenIds)).orderBy(ctx.Table.index.asc());
325
- case pages.SourceType.Parents:
252
+ case SourceType.Parents:
326
253
  const Parent = EntryRow().as("Parent");
327
254
  const parents = withRecursive(
328
255
  Parent({ entryId: from.entryId }).where(
@@ -581,6 +508,5 @@ var EntryResolver = class {
581
508
  };
582
509
  };
583
510
  export {
584
- EntryResolver,
585
- ResolveContext
511
+ EntryResolver
586
512
  };
@@ -2,7 +2,7 @@ import { Projection } from 'alinea/core/pages/Projection';
2
2
  import { Realm } from 'alinea/core/pages/Realm';
3
3
  import DataLoader from 'dataloader';
4
4
  import { Store } from '../Store.js';
5
- import { EntryResolver } from './EntryResolver.js';
5
+ import type { EntryResolver } from './EntryResolver.js';
6
6
  export declare class LinkResolver {
7
7
  resolver: EntryResolver;
8
8
  store: Store;
@@ -11,9 +11,9 @@ import {
11
11
  // src/backend/resolver/LinkResolver.ts
12
12
  var import_dataloader = __toESM(require_dataloader(), 1);
13
13
  import { Entry } from "alinea/core";
14
- import { Selection } from "alinea/core/pages/Selection";
14
+ import { createSelection } from "alinea/core/pages/CreateSelection";
15
15
  import { serializeSelection } from "alinea/core/pages/Serialize";
16
- import { ResolveContext } from "./EntryResolver.js";
16
+ import { ResolveContext } from "./ResolveContext.js";
17
17
  var LinkResolver = class {
18
18
  constructor(resolver, store, realm) {
19
19
  this.resolver = resolver;
@@ -24,7 +24,7 @@ var LinkResolver = class {
24
24
  load(projection) {
25
25
  return new import_dataloader.default(
26
26
  async (ids) => {
27
- const selection = Selection.create(
27
+ const selection = createSelection(
28
28
  Entry().where(Entry.entryId.isIn(ids)).select({
29
29
  entryId: Entry.entryId,
30
30
  projection
@@ -0,0 +1,38 @@
1
+ import { EntryTable } from 'alinea/core/EntryRow';
2
+ import { Realm } from 'alinea/core/pages/Realm';
3
+ import { Table } from 'rado';
4
+ interface ResolveContextData {
5
+ realm: Realm;
6
+ location: Array<string>;
7
+ locale: string | undefined;
8
+ depth: number;
9
+ expr: ExprContext;
10
+ }
11
+ declare enum ExprContext {
12
+ InNone = 0,
13
+ InSelect = 1,
14
+ InCondition = 2,
15
+ InAccess = 4
16
+ }
17
+ export declare class ResolveContext {
18
+ private data;
19
+ table: Table<EntryTable>;
20
+ constructor(data: Partial<ResolveContextData>);
21
+ linkContext(): ResolveContext;
22
+ get depth(): number;
23
+ get location(): string[];
24
+ get realm(): Realm;
25
+ get locale(): string | undefined;
26
+ get expr(): ExprContext;
27
+ get Table(): Table<EntryTable>;
28
+ increaseDepth(): ResolveContext;
29
+ decreaseDepth(): ResolveContext;
30
+ get isInSelect(): number;
31
+ get isInCondition(): number;
32
+ get isInAccess(): number;
33
+ get select(): ResolveContext;
34
+ get condition(): ResolveContext;
35
+ get access(): ResolveContext;
36
+ get none(): ResolveContext;
37
+ }
38
+ export {};
@@ -0,0 +1,83 @@
1
+ import "../../chunks/chunk-U5RRZUYZ.js";
2
+
3
+ // src/backend/resolver/ResolveContext.ts
4
+ import { EntryRow } from "alinea/core/EntryRow";
5
+ import { Realm } from "alinea/core/pages/Realm";
6
+ var ResolveContext = class _ResolveContext {
7
+ constructor(data) {
8
+ this.data = data;
9
+ this.table = EntryRow().as(`E${this.depth}`);
10
+ }
11
+ table;
12
+ linkContext() {
13
+ return new _ResolveContext({
14
+ realm: this.realm
15
+ });
16
+ }
17
+ get depth() {
18
+ return this.data.depth ?? 0;
19
+ }
20
+ get location() {
21
+ return this.data.location ?? [];
22
+ }
23
+ get realm() {
24
+ return this.data.realm ?? Realm.Published;
25
+ }
26
+ get locale() {
27
+ return this.data.locale;
28
+ }
29
+ get expr() {
30
+ return this.data.expr ?? 0 /* InNone */;
31
+ }
32
+ get Table() {
33
+ return this.table;
34
+ }
35
+ increaseDepth() {
36
+ return new _ResolveContext({ ...this.data, depth: this.depth + 1 });
37
+ }
38
+ decreaseDepth() {
39
+ return new _ResolveContext({ ...this.data, depth: this.depth - 1 });
40
+ }
41
+ get isInSelect() {
42
+ return this.expr & 1 /* InSelect */;
43
+ }
44
+ get isInCondition() {
45
+ return this.expr & 2 /* InCondition */;
46
+ }
47
+ get isInAccess() {
48
+ return this.expr & 4 /* InAccess */;
49
+ }
50
+ get select() {
51
+ if (this.isInSelect)
52
+ return this;
53
+ return new _ResolveContext({
54
+ ...this.data,
55
+ expr: this.expr | 1 /* InSelect */
56
+ });
57
+ }
58
+ get condition() {
59
+ if (this.isInCondition)
60
+ return this;
61
+ return new _ResolveContext({
62
+ ...this.data,
63
+ expr: this.expr | 2 /* InCondition */
64
+ });
65
+ }
66
+ get access() {
67
+ if (this.isInAccess)
68
+ return this;
69
+ return new _ResolveContext({
70
+ ...this.data,
71
+ expr: this.expr | 4 /* InAccess */
72
+ });
73
+ }
74
+ get none() {
75
+ return new _ResolveContext({
76
+ ...this.data,
77
+ expr: this.expr | 0 /* InNone */
78
+ });
79
+ }
80
+ };
81
+ export {
82
+ ResolveContext
83
+ };
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "v0.4.0",
5
+ version: "0.4.2",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
@@ -26,7 +26,7 @@ var package_default = {
26
26
  "build:stories": 'ladle build --base /stories --stories "packages/**/*.stories.tsx" --outDir apps/web/public/stories',
27
27
  trace: "tsc --noEmit --incremental false --emitDeclarationOnly false --diagnostics --generateTrace private/trace && analyze-trace private/trace & speedscope private/trace/trace.json",
28
28
  bump: "esbx version",
29
- prepare: "yarn build"
29
+ prepublishOnly: "yarn build"
30
30
  },
31
31
  sideEffects: false,
32
32
  typesVersions: {
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-KDSPNPHI.js";
3
+ } from "../chunks/chunk-LRUUF55J.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-KDSPNPHI.js";
3
+ } from "../chunks/chunk-LRUUF55J.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-KDSPNPHI.js";
3
+ } from "../../chunks/chunk-LRUUF55J.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __toESM
package/dist/cli.js CHANGED
File without changes
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-IKINPSS5.js";
4
4
  import {
5
5
  package_default
6
- } from "../../chunks/chunk-KDSPNPHI.js";
6
+ } from "../../chunks/chunk-LRUUF55J.js";
7
7
  import "../../chunks/chunk-U5RRZUYZ.js";
8
8
 
9
9
  // src/cloud/server/CloudAuthServer.ts
@@ -5,11 +5,6 @@ import type { ComponentType } from 'react';
5
5
  import { Hint } from './Hint.js';
6
6
  import { Label } from './Label.js';
7
7
  import { Shape } from './Shape.js';
8
- import { TextDoc } from './TextDoc.js';
9
- import { ListMutator, ListRow } from './shape/ListShape.js';
10
- import { RecordMutator, RecordShape } from './shape/RecordShape.js';
11
- import { RichTextMutator } from './shape/RichTextShape.js';
12
- import { UnionMutator, UnionRow } from './shape/UnionShape.js';
13
8
  export interface FieldOptions {
14
9
  hidden?: boolean;
15
10
  readOnly?: boolean;
@@ -37,27 +32,6 @@ export declare class Field<Value = unknown, OnChange = unknown, Options = {}> {
37
32
  }
38
33
  export declare namespace Field {
39
34
  const Data: unique symbol;
40
- class Scalar<Value, Options> extends Field<Value, (value: Value) => void, Options> {
41
- constructor(meta: FieldMeta<Value, (value: Value) => void, Options>);
42
- }
43
- class List<Schema, Options> extends Field<Array<ListRow & Schema>, ListMutator<ListRow & Schema>, Options> {
44
- constructor(shape: {
45
- [key: string]: RecordShape<any>;
46
- }, meta: FieldMeta<Array<ListRow & Schema>, ListMutator<ListRow & Schema>, Options>);
47
- }
48
- class Union<Row, Options> extends Field<UnionRow & Row, UnionMutator<Row>, Options> {
49
- constructor(shapes: {
50
- [key: string]: RecordShape<any>;
51
- }, meta: FieldMeta<UnionRow & Row, UnionMutator<Row>, Options>);
52
- }
53
- class Record<Row, Options> extends Field<Row, RecordMutator<Row>, Options> {
54
- constructor(shape: RecordShape<any>, meta: FieldMeta<Row, RecordMutator<Row>, Options>);
55
- }
56
- class RichText<Blocks, Options> extends Field<TextDoc<Blocks>, RichTextMutator<Blocks>, Options> {
57
- constructor(shape: {
58
- [key: string]: RecordShape<any>;
59
- } | undefined, meta: FieldMeta<TextDoc<Blocks>, RichTextMutator<Blocks>, Options>);
60
- }
61
35
  function provideView<Value, OnChange, Options, Factory extends (...args: Array<any>) => Field<Value, OnChange, Options>>(view: FieldView<Value, OnChange, Options>, factory: Factory): Factory;
62
36
  function shape(field: Field<any, any>): Shape;
63
37
  function hint(field: Field): Hint;
@@ -1,10 +1,6 @@
1
1
  import "../chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/core/Field.ts
4
- import { ListShape } from "./shape/ListShape.js";
5
- import { RichTextShape } from "./shape/RichTextShape.js";
6
- import { ScalarShape } from "./shape/ScalarShape.js";
7
- import { UnionShape } from "./shape/UnionShape.js";
8
4
  var Field = class _Field {
9
5
  constructor(data) {
10
6
  this[_Field.Data] = data;
@@ -12,58 +8,6 @@ var Field = class _Field {
12
8
  };
13
9
  ((Field2) => {
14
10
  Field2.Data = Symbol.for("@alinea/Field.Data");
15
- class Scalar extends Field2 {
16
- constructor(meta) {
17
- super({
18
- shape: new ScalarShape(meta.label, meta.initialValue),
19
- ...meta
20
- });
21
- }
22
- }
23
- Field2.Scalar = Scalar;
24
- class List extends Field2 {
25
- constructor(shape2, meta) {
26
- super({
27
- shape: new ListShape(
28
- meta.label,
29
- shape2,
30
- meta.initialValue,
31
- meta.postProcess
32
- ),
33
- ...meta
34
- });
35
- }
36
- }
37
- Field2.List = List;
38
- class Union extends Field2 {
39
- constructor(shapes, meta) {
40
- super({
41
- shape: new UnionShape(
42
- meta.label,
43
- shapes,
44
- meta.initialValue,
45
- meta.postProcess
46
- ),
47
- ...meta
48
- });
49
- }
50
- }
51
- Field2.Union = Union;
52
- class Record extends Field2 {
53
- constructor(shape2, meta) {
54
- super({ shape: shape2, ...meta });
55
- }
56
- }
57
- Field2.Record = Record;
58
- class RichText extends Field2 {
59
- constructor(shape2, meta) {
60
- super({
61
- shape: new RichTextShape(meta.label, shape2, meta.initialValue),
62
- ...meta
63
- });
64
- }
65
- }
66
- Field2.RichText = RichText;
67
11
  function provideView(view2, factory) {
68
12
  return (...args) => new Field2({ ...factory(...args)[Field2.Data], view: view2 });
69
13
  }
@@ -3,9 +3,9 @@ import "../chunks/chunk-U5RRZUYZ.js";
3
3
  // src/core/Graph.ts
4
4
  import { Schema } from "./Schema.js";
5
5
  import { Type } from "./Type.js";
6
+ import { createSelection } from "./pages/CreateSelection.js";
6
7
  import { Cursor } from "./pages/Cursor.js";
7
8
  import { Realm } from "./pages/Realm.js";
8
- import { Selection } from "./pages/Selection.js";
9
9
  import { seralizeLocation, serializeSelection } from "./pages/Serialize.js";
10
10
  var GraphRealm = class _GraphRealm {
11
11
  constructor(config, resolve, origin = {}) {
@@ -29,7 +29,7 @@ var GraphRealm = class _GraphRealm {
29
29
  select = select.first();
30
30
  if (Type.isType(select))
31
31
  select = select().first();
32
- const selection = Selection.create(select);
32
+ const selection = createSelection(select);
33
33
  serializeSelection(this.targets, selection);
34
34
  return this.resolve({
35
35
  selection,
@@ -44,7 +44,7 @@ var GraphRealm = class _GraphRealm {
44
44
  return result;
45
45
  }
46
46
  async find(select) {
47
- const selection = Selection.create(select);
47
+ const selection = createSelection(select);
48
48
  serializeSelection(this.targets, selection);
49
49
  return this.resolve({
50
50
  selection,
@@ -53,7 +53,7 @@ var GraphRealm = class _GraphRealm {
53
53
  });
54
54
  }
55
55
  async count(cursor) {
56
- const selection = Selection.create(cursor.count());
56
+ const selection = createSelection(cursor.count());
57
57
  serializeSelection(this.targets, selection);
58
58
  return this.resolve({
59
59
  selection,