alinea 1.0.0-preview.7 → 1.0.0
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 +3 -3
- package/dist/backend/api/CreateBackend.js +3 -3
- package/dist/backend/api/DatabaseApi.js +1 -1
- package/dist/backend/db/AlineaMeta.js +1 -1
- package/dist/backend/resolver/EntryResolver.d.ts +2 -1
- package/dist/backend/resolver/EntryResolver.js +49 -24
- package/dist/backend/resolver/ResolveContext.js +1 -1
- package/dist/backend/store/CreateStore.js +3 -3
- package/dist/backend/test/Example.d.ts +15 -3
- package/dist/backend/test/Example.js +11 -1
- package/dist/chunks/{chunk-YZAKZYR7.js → chunk-B2RMSUW7.js} +1 -1
- package/dist/chunks/{chunk-JUAFAVQT.js → chunk-BRXE6PQG.js} +1 -1
- package/dist/chunks/{chunk-R7QXZRY5.js → chunk-COTVTUVE.js} +1 -1
- package/dist/chunks/{chunk-74QQ64O4.js → chunk-RY572IJL.js} +13 -12
- package/dist/chunks/{chunk-XENGTWCT.js → chunk-SGEH5FCM.js} +2 -2
- package/dist/chunks/{sql.js-JXAW5YFN.js → sql.js-MYDVXO2C.js} +3 -3
- package/dist/cli/Generate.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/EntryRow.js +1 -1
- package/dist/core/EntrySearch.js +1 -1
- package/dist/core/Filter.d.ts +22 -17
- package/dist/core/Graph.d.ts +9 -12
- package/dist/core/Infer.d.ts +3 -5
- package/dist/dashboard/util/PersistentStore.js +4 -4
- package/dist/field/link/Link.d.ts +6 -3
- package/dist/query.d.ts +7 -7
- package/package.json +1 -1
package/dist/backend/Database.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
coalesce,
|
|
3
3
|
count
|
|
4
|
-
} from "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-BRXE6PQG.js";
|
|
5
5
|
import {
|
|
6
6
|
Builder
|
|
7
|
-
} from "../chunks/chunk-
|
|
7
|
+
} from "../chunks/chunk-B2RMSUW7.js";
|
|
8
8
|
import {
|
|
9
9
|
and,
|
|
10
10
|
asc,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "../chunks/chunk-LCBVZEPF.js";
|
|
19
19
|
import {
|
|
20
20
|
alias
|
|
21
|
-
} from "../chunks/chunk-
|
|
21
|
+
} from "../chunks/chunk-RY572IJL.js";
|
|
22
22
|
import "../chunks/chunk-6YSLV4QG.js";
|
|
23
23
|
import {
|
|
24
24
|
sql
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
sqliteDialect,
|
|
11
11
|
sqliteDiff,
|
|
12
12
|
txGenerator
|
|
13
|
-
} from "../../chunks/chunk-
|
|
14
|
-
import "../../chunks/chunk-
|
|
13
|
+
} from "../../chunks/chunk-SGEH5FCM.js";
|
|
14
|
+
import "../../chunks/chunk-B2RMSUW7.js";
|
|
15
15
|
import {
|
|
16
16
|
and,
|
|
17
17
|
asc,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
import {
|
|
31
31
|
Functions,
|
|
32
32
|
table
|
|
33
|
-
} from "../../chunks/chunk-
|
|
33
|
+
} from "../../chunks/chunk-RY572IJL.js";
|
|
34
34
|
import {
|
|
35
35
|
input
|
|
36
36
|
} from "../../chunks/chunk-6YSLV4QG.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import "../../chunks/chunk-U7HSJRGD.js";
|
|
13
13
|
import {
|
|
14
14
|
table
|
|
15
|
-
} from "../../chunks/chunk-
|
|
15
|
+
} from "../../chunks/chunk-RY572IJL.js";
|
|
16
16
|
import "../../chunks/chunk-6YSLV4QG.js";
|
|
17
17
|
import "../../chunks/chunk-NXCD6SNE.js";
|
|
18
18
|
import {
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import "../../chunks/chunk-U7HSJRGD.js";
|
|
5
5
|
import {
|
|
6
6
|
table
|
|
7
|
-
} from "../../chunks/chunk-
|
|
7
|
+
} from "../../chunks/chunk-RY572IJL.js";
|
|
8
8
|
import "../../chunks/chunk-6YSLV4QG.js";
|
|
9
9
|
import "../../chunks/chunk-NXCD6SNE.js";
|
|
10
10
|
import "../../chunks/chunk-U5RRZUYZ.js";
|
|
@@ -40,7 +40,8 @@ export declare class EntryResolver {
|
|
|
40
40
|
conditionEntryFields(ctx: ResolveContext, query: QuerySettings): Sql<boolean>;
|
|
41
41
|
conditionSearch(Table: typeof EntryRow, searchTerms: string | Array<string> | undefined): Sql<boolean>;
|
|
42
42
|
conditionTypes(ctx: ResolveContext, types: Type | Array<Type>): Sql<boolean>;
|
|
43
|
-
conditionFilter(ctx: ResolveContext, filter: Filter): Sql<boolean>;
|
|
43
|
+
conditionFilter(ctx: ResolveContext, getField: (ctx: ResolveContext, name: string) => Sql, filter: Filter): Sql<boolean>;
|
|
44
|
+
getField(ctx: ResolveContext, name: string): any;
|
|
44
45
|
query(ctx: ResolveContext, query: RelatedQuery<Projection>): Select<any>;
|
|
45
46
|
isSingleResult(query: RelatedQuery): boolean;
|
|
46
47
|
postField(ctx: PostContext, interim: Interim, field: Field): Promise<void>;
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
bm25,
|
|
3
3
|
count,
|
|
4
4
|
snippet
|
|
5
|
-
} from "../../chunks/chunk-
|
|
5
|
+
} from "../../chunks/chunk-BRXE6PQG.js";
|
|
6
6
|
import {
|
|
7
7
|
any,
|
|
8
8
|
array,
|
|
@@ -12,12 +12,13 @@ import {
|
|
|
12
12
|
Builder,
|
|
13
13
|
Select,
|
|
14
14
|
selection
|
|
15
|
-
} from "../../chunks/chunk-
|
|
15
|
+
} from "../../chunks/chunk-B2RMSUW7.js";
|
|
16
16
|
import {
|
|
17
17
|
and,
|
|
18
18
|
asc,
|
|
19
19
|
desc,
|
|
20
20
|
eq,
|
|
21
|
+
exists,
|
|
21
22
|
gt,
|
|
22
23
|
gte,
|
|
23
24
|
inArray,
|
|
@@ -31,8 +32,10 @@ import {
|
|
|
31
32
|
or
|
|
32
33
|
} from "../../chunks/chunk-LCBVZEPF.js";
|
|
33
34
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
Functions,
|
|
36
|
+
alias,
|
|
37
|
+
jsonExpr
|
|
38
|
+
} from "../../chunks/chunk-RY572IJL.js";
|
|
36
39
|
import {
|
|
37
40
|
input
|
|
38
41
|
} from "../../chunks/chunk-6YSLV4QG.js";
|
|
@@ -352,7 +355,7 @@ var EntryResolver = class {
|
|
|
352
355
|
conditionEntryFields(ctx, query) {
|
|
353
356
|
const workspace = query.workspace && typeof query.workspace === "object" && hasWorkspace(query.workspace) ? this.scope.nameOf(query.workspace) : query.workspace;
|
|
354
357
|
const root = query.root && typeof query.root === "object" && hasRoot(query.root) ? this.scope.nameOf(query.root) : query.root;
|
|
355
|
-
return this.conditionFilter(ctx, {
|
|
358
|
+
return this.conditionFilter(ctx, this.getField.bind(this), {
|
|
356
359
|
_id: query.id,
|
|
357
360
|
_parentId: query.parentId,
|
|
358
361
|
_path: query.path,
|
|
@@ -374,29 +377,18 @@ var EntryResolver = class {
|
|
|
374
377
|
}
|
|
375
378
|
return eq(ctx.Table.type, this.scope.nameOf(types));
|
|
376
379
|
}
|
|
377
|
-
conditionFilter(ctx, filter) {
|
|
380
|
+
conditionFilter(ctx, getField, filter) {
|
|
378
381
|
const isOrFilter = orFilter.check(filter);
|
|
379
382
|
if (isOrFilter)
|
|
380
383
|
return or(
|
|
381
|
-
...filter.or.filter(Boolean).map((filter2) => this.conditionFilter(ctx, filter2))
|
|
384
|
+
...filter.or.filter(Boolean).map((filter2) => this.conditionFilter(ctx, getField, filter2))
|
|
382
385
|
);
|
|
383
386
|
const isAndFilter = andFilter.check(filter);
|
|
384
387
|
if (isAndFilter)
|
|
385
388
|
return and(
|
|
386
|
-
...filter.and.filter(Boolean).map((filter2) => this.conditionFilter(ctx, filter2))
|
|
389
|
+
...filter.and.filter(Boolean).map((filter2) => this.conditionFilter(ctx, getField, filter2))
|
|
387
390
|
);
|
|
388
|
-
|
|
389
|
-
if (name.startsWith("_")) {
|
|
390
|
-
const entryProp = name.slice(1);
|
|
391
|
-
const key = entryProp;
|
|
392
|
-
if (!(key in ctx2.Table))
|
|
393
|
-
throw new Error(`Unknown field: "${name}"`);
|
|
394
|
-
return ctx2.Table[key];
|
|
395
|
-
}
|
|
396
|
-
return ctx2.Table.data[name];
|
|
397
|
-
}
|
|
398
|
-
const conditions = entries(filter).flatMap(function mapCondition([key, value]) {
|
|
399
|
-
const field = filterField(ctx, key);
|
|
391
|
+
const mapCondition = ([field, value]) => {
|
|
400
392
|
if (typeof value !== "object" || !value)
|
|
401
393
|
return value === void 0 ? [] : [value === null ? isNull(field) : eq(field, value)];
|
|
402
394
|
return entries(value).map(([op, value2]) => {
|
|
@@ -423,21 +415,54 @@ var EntryResolver = class {
|
|
|
423
415
|
if (Array.isArray(value2))
|
|
424
416
|
return or(
|
|
425
417
|
...value2.map((c) => {
|
|
426
|
-
return and(...mapCondition([
|
|
418
|
+
return and(...mapCondition([field, c]));
|
|
427
419
|
})
|
|
428
420
|
);
|
|
429
|
-
return and(...mapCondition([
|
|
421
|
+
return and(...mapCondition([field, value2]));
|
|
430
422
|
case "in":
|
|
431
423
|
return inArray(field, value2);
|
|
432
424
|
case "notIn":
|
|
433
425
|
return not(inArray(field, value2));
|
|
426
|
+
case "has":
|
|
427
|
+
return this.conditionFilter(
|
|
428
|
+
ctx,
|
|
429
|
+
(_, name) => {
|
|
430
|
+
return field[name];
|
|
431
|
+
},
|
|
432
|
+
value2
|
|
433
|
+
);
|
|
434
|
+
case "includes":
|
|
435
|
+
const expr = jsonExpr(sql`value`);
|
|
436
|
+
const condition = this.conditionFilter(
|
|
437
|
+
ctx,
|
|
438
|
+
(_, name) => {
|
|
439
|
+
return expr[name];
|
|
440
|
+
},
|
|
441
|
+
value2
|
|
442
|
+
);
|
|
443
|
+
return exists(
|
|
444
|
+
builder.select(sql`1`).from(Functions.json_each(field)).where(condition)
|
|
445
|
+
);
|
|
434
446
|
default:
|
|
435
447
|
throw new Error(`Unknown filter operator: "${op}"`);
|
|
436
448
|
}
|
|
437
449
|
});
|
|
438
|
-
}
|
|
450
|
+
};
|
|
451
|
+
const conditions = entries(filter).map(([key, value]) => {
|
|
452
|
+
return [getField(ctx, key), value];
|
|
453
|
+
}).flatMap(mapCondition);
|
|
439
454
|
return and(...conditions);
|
|
440
455
|
}
|
|
456
|
+
getField(ctx, name) {
|
|
457
|
+
if (name.startsWith("_")) {
|
|
458
|
+
const entryProp = name.slice(1);
|
|
459
|
+
const key = entryProp;
|
|
460
|
+
if (!(key in ctx.Table))
|
|
461
|
+
throw new Error(`Unknown field: "${name}"`);
|
|
462
|
+
return ctx.Table[key];
|
|
463
|
+
}
|
|
464
|
+
return ctx.Table.data[name];
|
|
465
|
+
}
|
|
441
466
|
query(ctx, query) {
|
|
442
467
|
const { type, filter, skip, take, orderBy, groupBy, first, search } = query;
|
|
443
468
|
ctx = ctx.increaseDepth().none;
|
|
@@ -452,7 +477,7 @@ var EntryResolver = class {
|
|
|
452
477
|
this.conditionStatus(ctx.Table, ctx.status),
|
|
453
478
|
querySource(query) === "translations" ? void 0 : this.conditionLocale(ctx.Table, ctx.locale),
|
|
454
479
|
this.conditionSearch(ctx.Table, search),
|
|
455
|
-
filter && this.conditionFilter(ctx, filter)
|
|
480
|
+
filter && this.conditionFilter(ctx, this.getField.bind(this), filter)
|
|
456
481
|
);
|
|
457
482
|
if (skip)
|
|
458
483
|
q = q.offset(skip);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
connect
|
|
3
|
-
} from "../../chunks/chunk-
|
|
4
|
-
import "../../chunks/chunk-
|
|
3
|
+
} from "../../chunks/chunk-SGEH5FCM.js";
|
|
4
|
+
import "../../chunks/chunk-B2RMSUW7.js";
|
|
5
5
|
import "../../chunks/chunk-LCBVZEPF.js";
|
|
6
6
|
import "../../chunks/chunk-U7HSJRGD.js";
|
|
7
|
-
import "../../chunks/chunk-
|
|
7
|
+
import "../../chunks/chunk-RY572IJL.js";
|
|
8
8
|
import "../../chunks/chunk-6YSLV4QG.js";
|
|
9
9
|
import "../../chunks/chunk-NXCD6SNE.js";
|
|
10
10
|
import "../../chunks/chunk-U5RRZUYZ.js";
|
|
@@ -12,15 +12,15 @@ export declare function createExample(): import("alinea/core/CMS").CMS<{
|
|
|
12
12
|
externalLink: import("alinea/field/link/LinkField").LinkField<import("alinea/types").UrlReference, import("alinea/types").UrlLink<{}>>;
|
|
13
13
|
entry: import("alinea/field/link/LinkField").LinkField<import("alinea/types").EntryReference, import("alinea/types").EntryLink<undefined>>;
|
|
14
14
|
entryWithCondition: import("alinea/field/link/LinkField").LinkField<import("alinea/types").EntryReference, import("alinea/types").EntryLink<undefined>>;
|
|
15
|
-
linkMultiple: import("alinea/field/link/LinkField").LinksField<import("alinea/core/shape/ListShape").ListRow, import("alinea/types").Link<{}>>;
|
|
15
|
+
linkMultiple: import("alinea/field/link/LinkField").LinksField<(import("alinea/types").EntryReference | import("alinea/types").UrlReference) & import("alinea/core/shape/ListShape").ListRow, import("alinea/types").Link<{}>>;
|
|
16
16
|
image: import("alinea/field/link").ImageField<undefined>;
|
|
17
17
|
images: import("alinea/field/link").ImagesField<undefined>;
|
|
18
18
|
file: import("alinea/field/link/LinkField").LinkField<import("alinea/types").EntryReference, import("alinea/types").EntryLink<undefined>>;
|
|
19
|
-
withFields: import("alinea/field/link/LinkField").LinkField<import("alinea/core/
|
|
19
|
+
withFields: import("alinea/field/link/LinkField").LinkField<(import("alinea/types").EntryReference | import("alinea/types").UrlReference) & import("alinea/core/shape/ListShape").ListRow, import("alinea/types").Link<{
|
|
20
20
|
fieldA: string;
|
|
21
21
|
fieldB: string;
|
|
22
22
|
}>>;
|
|
23
|
-
multipleWithFields: import("alinea/field/link/LinkField").LinksField<import("alinea/core/shape/ListShape").ListRow, import("alinea/types").Link<{
|
|
23
|
+
multipleWithFields: import("alinea/field/link/LinkField").LinksField<(import("alinea/types").EntryReference | import("alinea/types").UrlReference) & import("alinea/core/shape/ListShape").ListRow, import("alinea/types").Link<{
|
|
24
24
|
fieldA: string;
|
|
25
25
|
fieldB: string;
|
|
26
26
|
}>>;
|
|
@@ -88,6 +88,18 @@ export declare function createExample(): import("alinea/core/CMS").CMS<{
|
|
|
88
88
|
}>;
|
|
89
89
|
Page: import("alinea/core/Type").Type<import("alinea/core/Document").Document & {
|
|
90
90
|
name: import("alinea/field/path").PathField & import("alinea/field/text").TextField;
|
|
91
|
+
entryLink: import("alinea/field/link/LinkField").LinksField<(import("alinea/types").EntryReference | import("alinea/types").UrlReference) & import("alinea/core/shape/ListShape").ListRow, import("alinea/types").Link<{}>>;
|
|
92
|
+
list: import("alinea/core").ListField<{
|
|
93
|
+
_type: "item";
|
|
94
|
+
itemId: string;
|
|
95
|
+
} & import("alinea/core/shape/ListShape").ListRow, {
|
|
96
|
+
_type: "item";
|
|
97
|
+
itemId: string;
|
|
98
|
+
} & import("alinea/core/shape/ListShape").ListRow, import("alinea/field/list").ListOptions<{
|
|
99
|
+
item: import("alinea/core/Type").Type<{
|
|
100
|
+
itemId: import("alinea/field/text").TextField;
|
|
101
|
+
}>;
|
|
102
|
+
}>>;
|
|
91
103
|
name2: import("alinea/field/text").TextField;
|
|
92
104
|
title: import("alinea/field/text").TextField;
|
|
93
105
|
path: import("alinea/field/path").PathField;
|
|
@@ -36,7 +36,17 @@ function createExample() {
|
|
|
36
36
|
...tabs(
|
|
37
37
|
tab("Tab 1", {
|
|
38
38
|
fields: {
|
|
39
|
-
name: path("Name")
|
|
39
|
+
name: path("Name"),
|
|
40
|
+
entryLink: link.multiple("Entry link"),
|
|
41
|
+
list: list("List field", {
|
|
42
|
+
schema: {
|
|
43
|
+
item: type("Item", {
|
|
44
|
+
fields: {
|
|
45
|
+
itemId: text("Item id")
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
})
|
|
40
50
|
}
|
|
41
51
|
}),
|
|
42
52
|
tab("Tab 2", {
|
|
@@ -88,18 +88,6 @@ function index() {
|
|
|
88
88
|
return new Index({ fields: [] });
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// node_modules/rado/dist/core/expr/Field.js
|
|
92
|
-
var Field = class {
|
|
93
|
-
[internalField];
|
|
94
|
-
[internalSql];
|
|
95
|
-
constructor(targetName, fieldName, options = {}) {
|
|
96
|
-
const field = { targetName, fieldName };
|
|
97
|
-
this[internalField] = field;
|
|
98
|
-
const expr = sql.field(field).as(fieldName).mapWith(options);
|
|
99
|
-
this[internalSql] = expr;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
91
|
// node_modules/rado/dist/core/expr/Json.js
|
|
104
92
|
var INDEX_PROPERTY = /^\d+$/;
|
|
105
93
|
function jsonExpr(e) {
|
|
@@ -143,6 +131,18 @@ function jsonArray(...args) {
|
|
|
143
131
|
);
|
|
144
132
|
}
|
|
145
133
|
|
|
134
|
+
// node_modules/rado/dist/core/expr/Field.js
|
|
135
|
+
var Field = class {
|
|
136
|
+
[internalField];
|
|
137
|
+
[internalSql];
|
|
138
|
+
constructor(targetName, fieldName, options = {}) {
|
|
139
|
+
const field = { targetName, fieldName };
|
|
140
|
+
this[internalField] = field;
|
|
141
|
+
const expr = sql.field(field).as(fieldName).mapWith(options);
|
|
142
|
+
this[internalSql] = expr;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
146
|
// node_modules/rado/dist/core/Table.js
|
|
147
147
|
var { assign, fromEntries, entries, keys } = Object;
|
|
148
148
|
var TableData = class {
|
|
@@ -268,6 +268,7 @@ export {
|
|
|
268
268
|
Functions,
|
|
269
269
|
Field,
|
|
270
270
|
index,
|
|
271
|
+
jsonExpr,
|
|
271
272
|
jsonAggregateArray,
|
|
272
273
|
jsonArray,
|
|
273
274
|
table,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Builder,
|
|
3
3
|
QueryBatch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-B2RMSUW7.js";
|
|
5
5
|
import {
|
|
6
6
|
eq
|
|
7
7
|
} from "./chunk-LCBVZEPF.js";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
jsonAggregateArray,
|
|
14
14
|
jsonArray,
|
|
15
15
|
table
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RY572IJL.js";
|
|
17
17
|
import {
|
|
18
18
|
Sql,
|
|
19
19
|
getData,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
connect
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-SGEH5FCM.js";
|
|
4
|
+
import "./chunk-B2RMSUW7.js";
|
|
5
5
|
import "./chunk-LCBVZEPF.js";
|
|
6
6
|
import "./chunk-U7HSJRGD.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-RY572IJL.js";
|
|
8
8
|
import "./chunk-6YSLV4QG.js";
|
|
9
9
|
import "./chunk-NXCD6SNE.js";
|
|
10
10
|
import "./chunk-U5RRZUYZ.js";
|
package/dist/cli/Generate.js
CHANGED
|
@@ -40,7 +40,7 @@ async function generatePackage(context, cms) {
|
|
|
40
40
|
async function createDb() {
|
|
41
41
|
const { default: sqlite } = await import("@alinea/sqlite-wasm");
|
|
42
42
|
const { Database } = await sqlite();
|
|
43
|
-
const { connect } = await import("../chunks/sql.js-
|
|
43
|
+
const { connect } = await import("../chunks/sql.js-MYDVXO2C.js");
|
|
44
44
|
const db = new Database();
|
|
45
45
|
const store = connect(db);
|
|
46
46
|
return [store, () => db.export()];
|
package/dist/cli/Serve.js
CHANGED
package/dist/cli/bin.js
CHANGED
package/dist/core/EntryRow.js
CHANGED
package/dist/core/EntrySearch.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import "../chunks/chunk-U7HSJRGD.js";
|
|
6
6
|
import {
|
|
7
7
|
table
|
|
8
|
-
} from "../chunks/chunk-
|
|
8
|
+
} from "../chunks/chunk-RY572IJL.js";
|
|
9
9
|
import "../chunks/chunk-6YSLV4QG.js";
|
|
10
10
|
import "../chunks/chunk-NXCD6SNE.js";
|
|
11
11
|
import "../chunks/chunk-U5RRZUYZ.js";
|
package/dist/core/Filter.d.ts
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import { Expr } from './Expr.js';
|
|
2
1
|
type Primitive = string | number | boolean | null;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
lte?: V;
|
|
2
|
+
interface Ops<Value> {
|
|
3
|
+
is?: Value;
|
|
4
|
+
isNot?: Value;
|
|
5
|
+
in?: ReadonlyArray<Value>;
|
|
6
|
+
notIn?: ReadonlyArray<Value>;
|
|
7
|
+
gt?: Value;
|
|
8
|
+
gte?: Value;
|
|
9
|
+
lt?: Value;
|
|
10
|
+
lte?: Value;
|
|
13
11
|
startsWith?: string;
|
|
14
|
-
or?: Condition<
|
|
15
|
-
}
|
|
12
|
+
or?: Condition<Value>;
|
|
13
|
+
}
|
|
14
|
+
interface ObjectOps<Fields> {
|
|
15
|
+
has?: Filter<Fields>;
|
|
16
|
+
}
|
|
17
|
+
interface ArrayOps<Fields> {
|
|
18
|
+
includes?: Filter<Fields>;
|
|
19
|
+
}
|
|
20
|
+
type FieldOps<Fields> = {
|
|
21
|
+
[K in keyof Fields]?: Condition<Fields[K]>;
|
|
22
|
+
};
|
|
23
|
+
export type Condition<Value> = Value extends Primitive ? Ops<Value> | Value : Value extends Array<any> ? ArrayOps<Value[0]> : ObjectOps<Value>;
|
|
16
24
|
type AndCondition<Fields> = {
|
|
17
25
|
and: Array<Filter<Fields> | undefined>;
|
|
18
26
|
};
|
|
19
27
|
type OrCondition<Fields> = {
|
|
20
28
|
or: Array<Filter<Fields> | undefined>;
|
|
21
29
|
};
|
|
22
|
-
type
|
|
23
|
-
[K in keyof Fields as InferValue<Fields[K]> extends Primitive ? K : never]?: Condition<InferValue<Fields[K]>>;
|
|
24
|
-
};
|
|
25
|
-
export type Filter<Fields = unknown> = AndCondition<Fields> | OrCondition<Fields> | FieldCondition<Fields>;
|
|
30
|
+
export type Filter<Fields = unknown> = AndCondition<Fields> | OrCondition<Fields> | FieldOps<Fields>;
|
|
26
31
|
export {};
|
package/dist/core/Graph.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Config } from './Config.js';
|
|
|
3
3
|
import { EntryFields } from './EntryFields.js';
|
|
4
4
|
import { Expr } from './Expr.js';
|
|
5
5
|
import { Condition, Filter } from './Filter.js';
|
|
6
|
-
import { Infer } from './Infer.js';
|
|
6
|
+
import { Infer, StoredRow } from './Infer.js';
|
|
7
7
|
import { Page } from './Page.js';
|
|
8
8
|
import { PreviewRequest } from './Preview.js';
|
|
9
9
|
import { Resolver } from './Resolver.js';
|
|
@@ -11,7 +11,7 @@ import { Type } from './Type.js';
|
|
|
11
11
|
import { Expand } from './util/Types.js';
|
|
12
12
|
export type Location = Root | Workspace | Page | Array<string>;
|
|
13
13
|
type EmptyObject = Record<PropertyKey, never>;
|
|
14
|
-
type FieldsOf<Types> = Types extends Type<infer V> ? V : Types extends Array<any> ? Types[number] : unknown
|
|
14
|
+
type FieldsOf<Types> = StoredRow<Types extends Type<infer V> ? V : Types extends Array<any> ? Types[number] : unknown>;
|
|
15
15
|
export interface RelatedQuery<Selection = unknown, Types = unknown> extends GraphQuery<Selection, Types> {
|
|
16
16
|
translations?: EmptyObject | {
|
|
17
17
|
includeSelf: boolean | undefined;
|
|
@@ -65,11 +65,8 @@ export interface Order {
|
|
|
65
65
|
type InferSelection<Selection> = Selection extends Expr<infer V> ? V : {
|
|
66
66
|
[K in keyof Selection]: Selection[K] extends Type<infer V> ? Type.Infer<V> : Selection[K] extends Expr<infer V> ? V : Selection[K] extends GraphQuery & IsRelated ? Expand<AnyQueryResult<Selection[K]>> : InferSelection<Selection[K]>;
|
|
67
67
|
};
|
|
68
|
-
type InferResult<Selection, Types, Include> = Selection extends Expr<infer Value> ? Value : Selection extends undefined ? Types extends undefined ? EntryFields & (Include extends undefined ? {} : InferSelection<Include>) : Infer<Types> &
|
|
69
|
-
type
|
|
70
|
-
type GetQueryResult<Selection, Types, Include> = Expand<InferResult<Selection, Types, Include>>;
|
|
71
|
-
type FirstQueryResult<Selection, Types, Include> = Expand<InferResult<Selection, Types, Include>> | null;
|
|
72
|
-
type FindQueryResult<Selection, Types, Include> = Expand<Array<InferResult<Selection, Types, Include>>>;
|
|
68
|
+
type InferResult<Selection, Types, Include> = Selection extends Expr<infer Value> ? Value : Selection extends undefined ? Types extends undefined ? EntryFields & (Include extends undefined ? {} : InferSelection<Include>) : Infer<Types> & (Include extends undefined ? {} : InferSelection<Include>) : InferSelection<Selection>;
|
|
69
|
+
type QueryResult<Selection, Types, Include> = Expand<InferResult<Selection, Types, Include>>;
|
|
73
70
|
interface CountQuery<Selection, Types, Include> extends GraphQuery<Selection, Types, Include> {
|
|
74
71
|
count: true;
|
|
75
72
|
}
|
|
@@ -85,7 +82,7 @@ type FirstQuery<Selection, Types, Include> = (GraphQuery<Selection, Types, Inclu
|
|
|
85
82
|
interface GetQuery<Selection, Types, Include> extends GraphQuery<Selection, Types, Include> {
|
|
86
83
|
get: true;
|
|
87
84
|
}
|
|
88
|
-
export type AnyQueryResult<Query extends GraphQuery> = Query extends CountQuery<
|
|
85
|
+
export type AnyQueryResult<Query extends GraphQuery> = Query extends CountQuery<any, any, any> ? number : Query extends FirstQuery<infer S, infer T, infer I> ? QueryResult<S, T, I> | null : Query extends GetQuery<infer S, infer T, infer I> ? QueryResult<S, T, I> : Query extends GraphQuery<infer S, infer T, infer I> ? Array<QueryResult<S, T, I>> : unknown;
|
|
89
86
|
export type Status =
|
|
90
87
|
/** Only published entries */
|
|
91
88
|
'published'
|
|
@@ -167,10 +164,10 @@ export declare class Graph {
|
|
|
167
164
|
#private;
|
|
168
165
|
config: Config;
|
|
169
166
|
constructor(config: Config, resolver: Resolver);
|
|
170
|
-
find<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<
|
|
171
|
-
first<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<
|
|
172
|
-
get<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<
|
|
173
|
-
count<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<
|
|
167
|
+
find<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<Array<QueryResult<Selection, Type, Include>>>;
|
|
168
|
+
first<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<QueryResult<Selection, Type, Include> | null>;
|
|
169
|
+
get<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<QueryResult<Selection, Type, Include>>;
|
|
170
|
+
count<Selection extends SelectionGuard = undefined, const Type extends TypeGuard = undefined, Include extends IncludeGuard = undefined>(query: GraphQuery<Selection, Type, Include>): Promise<number>;
|
|
174
171
|
}
|
|
175
172
|
export declare function querySource(query: unknown): "translations" | "children" | "parents" | "siblings" | "parent" | "next" | "previous" | undefined;
|
|
176
173
|
export {};
|
package/dist/core/Infer.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Expand, UnionOfValues } from 'alinea/core/util/Types';
|
|
2
|
+
import { EntryFields } from './EntryFields.js';
|
|
2
3
|
import { Expr } from './Expr.js';
|
|
3
4
|
import { Field } from './Field.js';
|
|
4
5
|
import { Type } from './Type.js';
|
|
5
6
|
type QueryList<T> = Expand<UnionOfValues<{
|
|
6
7
|
[K in keyof T]: {
|
|
7
8
|
_type: K;
|
|
8
|
-
} &
|
|
9
|
+
} & Type.Infer<T[K]>;
|
|
9
10
|
}>>;
|
|
10
|
-
export type
|
|
11
|
-
[K in keyof Definition as Definition[K] extends Expr<any> ? K : never]: Definition[K] extends Expr<infer T> ? T : never;
|
|
12
|
-
};
|
|
13
|
-
export type InferQueryValue<T> = T extends Array<Type<infer X>> ? InferQueryValue<X> : T extends Type<infer Fields> ? QueryRow<Fields> : T extends Expr<infer QueryValue> ? QueryValue : T extends Record<string, Type> ? QueryList<T> : never;
|
|
11
|
+
export type InferQueryValue<T> = T extends Array<Type<infer X>> ? InferQueryValue<X> : T extends Type<infer Fields> ? Type.Infer<Fields> & EntryFields : T extends Expr<infer QueryValue> ? QueryValue : T extends Record<string, Type> ? QueryList<T> : never;
|
|
14
12
|
type StoredList<T> = Expand<UnionOfValues<{
|
|
15
13
|
[K in keyof T]: {
|
|
16
14
|
_type: K;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
package_default
|
|
3
|
-
} from "../../chunks/chunk-
|
|
3
|
+
} from "../../chunks/chunk-COTVTUVE.js";
|
|
4
4
|
import {
|
|
5
5
|
create as create2
|
|
6
6
|
} from "../../chunks/chunk-IOTY7UTU.js";
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from "../../chunks/chunk-BRTZLYIM.js";
|
|
10
10
|
import {
|
|
11
11
|
connect
|
|
12
|
-
} from "../../chunks/chunk-
|
|
13
|
-
import "../../chunks/chunk-
|
|
12
|
+
} from "../../chunks/chunk-SGEH5FCM.js";
|
|
13
|
+
import "../../chunks/chunk-B2RMSUW7.js";
|
|
14
14
|
import "../../chunks/chunk-LCBVZEPF.js";
|
|
15
15
|
import "../../chunks/chunk-U7HSJRGD.js";
|
|
16
|
-
import "../../chunks/chunk-
|
|
16
|
+
import "../../chunks/chunk-RY572IJL.js";
|
|
17
17
|
import "../../chunks/chunk-6YSLV4QG.js";
|
|
18
18
|
import "../../chunks/chunk-NXCD6SNE.js";
|
|
19
19
|
import "../../chunks/chunk-U5RRZUYZ.js";
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { WithoutLabel } from 'alinea/core/Field';
|
|
2
2
|
import { Label } from 'alinea/core/Label';
|
|
3
|
-
import { Reference } from 'alinea/core/Reference';
|
|
4
3
|
import { Type } from 'alinea/core/Type';
|
|
5
4
|
import type { ListRow } from 'alinea/core/shape/ListShape';
|
|
6
5
|
import { FileLink } from 'alinea/field/link/FileLink';
|
|
7
6
|
import { LinkField, LinkFieldOptions } from 'alinea/field/link/LinkField';
|
|
7
|
+
import { EntryReference } from 'alinea/picker/entry/EntryReference';
|
|
8
|
+
import { UrlReference } from 'alinea/picker/url';
|
|
8
9
|
import { EntryLink } from './EntryLink.js';
|
|
9
10
|
import { UrlLink } from './UrlLink.js';
|
|
10
11
|
export type Link<InferredFields> = EntryLink<InferredFields> | UrlLink<InferredFields> | FileLink<InferredFields>;
|
|
11
12
|
export interface LinkOptions<Definition, Row> extends LinkFieldOptions<Row> {
|
|
12
13
|
fields?: Definition | Type<Definition>;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
type LinkRow = (EntryReference | UrlReference) & ListRow;
|
|
16
|
+
export declare function link<Fields>(label: Label, options?: WithoutLabel<LinkOptions<Fields, LinkRow>>): LinkField<LinkRow, Link<Type.Infer<Fields>>>;
|
|
15
17
|
export declare namespace link {
|
|
16
|
-
function multiple<Fields>(label: Label, options?: WithoutLabel<LinkOptions<Fields, Array<
|
|
18
|
+
function multiple<Fields>(label: Label, options?: WithoutLabel<LinkOptions<Fields, Array<LinkRow>>>): import("alinea/field/link/LinkField").LinksField<LinkRow, Link<{ [K_1 in keyof Fields as Fields[K_1] extends import("alinea/core/Expr").Expr<any> ? K_1 : never]: Fields[K_1] extends import("alinea/core/Expr").Expr<infer T_1> ? T_1 : never; } extends infer T ? { [K in keyof T]: { [K_1 in keyof Fields as Fields[K_1] extends import("alinea/core/Expr").Expr<any> ? K_1 : never]: Fields[K_1] extends import("alinea/core/Expr").Expr<infer T_1> ? T_1 : never; }[K]; } : never>>;
|
|
17
19
|
}
|
|
20
|
+
export {};
|
package/dist/query.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function children<Selection extends SelectionGuard = undefined, T
|
|
|
17
17
|
type?: Type | undefined;
|
|
18
18
|
select?: Selection | undefined;
|
|
19
19
|
include?: Include | undefined;
|
|
20
|
-
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & (Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown
|
|
20
|
+
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & import("alinea/core/Infer").StoredRow<Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown>> | undefined;
|
|
21
21
|
first?: true;
|
|
22
22
|
get?: true;
|
|
23
23
|
count?: true;
|
|
@@ -48,7 +48,7 @@ export declare function parents<Selection extends SelectionGuard = undefined, Ty
|
|
|
48
48
|
type?: Type | undefined;
|
|
49
49
|
select?: Selection | undefined;
|
|
50
50
|
include?: Include | undefined;
|
|
51
|
-
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & (Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown
|
|
51
|
+
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & import("alinea/core/Infer").StoredRow<Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown>> | undefined;
|
|
52
52
|
first?: true;
|
|
53
53
|
get?: true;
|
|
54
54
|
count?: true;
|
|
@@ -79,7 +79,7 @@ export declare function translations<Selection extends SelectionGuard = undefine
|
|
|
79
79
|
type?: Type | undefined;
|
|
80
80
|
select?: Selection | undefined;
|
|
81
81
|
include?: Include | undefined;
|
|
82
|
-
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & (Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown
|
|
82
|
+
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & import("alinea/core/Infer").StoredRow<Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown>> | undefined;
|
|
83
83
|
first?: true;
|
|
84
84
|
get?: true;
|
|
85
85
|
count?: true;
|
|
@@ -108,7 +108,7 @@ export declare function parent<Selection extends SelectionGuard = undefined, Typ
|
|
|
108
108
|
type?: Type | undefined;
|
|
109
109
|
select?: Selection | undefined;
|
|
110
110
|
include?: Include | undefined;
|
|
111
|
-
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & (Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown
|
|
111
|
+
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & import("alinea/core/Infer").StoredRow<Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown>> | undefined;
|
|
112
112
|
first?: true;
|
|
113
113
|
get?: true;
|
|
114
114
|
count?: true;
|
|
@@ -135,7 +135,7 @@ export declare function next<Selection extends SelectionGuard = undefined, Type
|
|
|
135
135
|
type?: Type | undefined;
|
|
136
136
|
select?: Selection | undefined;
|
|
137
137
|
include?: Include | undefined;
|
|
138
|
-
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & (Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown
|
|
138
|
+
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & import("alinea/core/Infer").StoredRow<Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown>> | undefined;
|
|
139
139
|
first?: true;
|
|
140
140
|
get?: true;
|
|
141
141
|
count?: true;
|
|
@@ -162,7 +162,7 @@ export declare function previous<Selection extends SelectionGuard = undefined, T
|
|
|
162
162
|
type?: Type | undefined;
|
|
163
163
|
select?: Selection | undefined;
|
|
164
164
|
include?: Include | undefined;
|
|
165
|
-
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & (Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown
|
|
165
|
+
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & import("alinea/core/Infer").StoredRow<Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown>> | undefined;
|
|
166
166
|
first?: true;
|
|
167
167
|
get?: true;
|
|
168
168
|
count?: true;
|
|
@@ -191,7 +191,7 @@ export declare function siblings<Selection extends SelectionGuard = undefined, T
|
|
|
191
191
|
type?: Type | undefined;
|
|
192
192
|
select?: Selection | undefined;
|
|
193
193
|
include?: Include | undefined;
|
|
194
|
-
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & (Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown
|
|
194
|
+
filter?: import("alinea/core/Filter").Filter<import("alinea/core/EntryFields").EntryFields & import("alinea/core/Infer").StoredRow<Type extends import("alinea/core/Type").Type<infer V> ? V : Type extends any[] ? Type[number] : unknown>> | undefined;
|
|
195
195
|
first?: true;
|
|
196
196
|
get?: true;
|
|
197
197
|
count?: true;
|