content-query 0.2.0 → 0.4.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/README.md +28 -3
- package/dist/{build-Dxz7P1ur.mjs → build-CcqIpkes.mjs} +763 -39
- package/dist/build-DL1GzmRy.d.mts +55 -0
- package/dist/build.d.mts +2 -2
- package/dist/build.mjs +1 -1
- package/dist/cli.mjs +14 -8
- package/dist/computed.d.mts +2 -2
- package/dist/{content-N1gYshjg.mjs → content-BXrgP7nL.mjs} +271 -81
- package/dist/{content-G69dPPuo.d.mts → content-CwTKqRs9.d.mts} +49 -24
- package/dist/{types-ChaNhj42.d.mts → descriptor-bcPa6XLk.d.mts} +26 -1
- package/dist/{diagnostics-Cu94mZhl.mjs → diagnostics-DmUZtrJ6.mjs} +3 -1
- package/dist/{errors-C2iuBM0G.mjs → errors-Bfd0R4_P.mjs} +16 -1
- package/dist/file-DSOcdFj0.mjs +81 -0
- package/dist/{glob-Bv0dpvCQ.mjs → glob-BXJuwy_p.mjs} +94 -6
- package/dist/index.d.mts +61 -17
- package/dist/index.mjs +1 -1
- package/dist/internal.d.mts +11 -4
- package/dist/internal.mjs +29 -5
- package/dist/loaders.d.mts +2 -3
- package/dist/loaders.mjs +2 -81
- package/dist/next.d.mts +1 -1
- package/dist/next.mjs +2 -2
- package/dist/{operators-UqWUhKQJ.mjs → operators-Cwy8Kx4o.mjs} +88 -2
- package/dist/query-style-eXENQJ0O.d.mts +22 -0
- package/dist/query.d.mts +25 -2
- package/dist/query.mjs +1 -1
- package/dist/{relational-types-DgK3rLuw.d.mts → relational-types-C8xJtLG5.d.mts} +113 -38
- package/dist/runtime.d.mts +3 -2
- package/dist/runtime.mjs +1 -1
- package/dist/types-DbFfF6JE.d.mts +181 -0
- package/dist/vite.d.mts +15 -3
- package/dist/vite.mjs +25 -2
- package/package.json +2 -2
- package/dist/build-DfKd2bpf.d.mts +0 -25
- package/dist/descriptor-D9Th5hzk.d.mts +0 -18
- package/dist/types-C-kdMblM.d.mts +0 -69
- package/dist/validation-D_XdE1pF.mjs +0 -84
package/dist/internal.mjs
CHANGED
|
@@ -1,13 +1,35 @@
|
|
|
1
|
-
import { t as ContentError } from "./errors-
|
|
1
|
+
import { t as ContentError } from "./errors-Bfd0R4_P.mjs";
|
|
2
2
|
import { r as decode } from "./values-BbTV4QT-.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as restoreContentError } from "./diagnostics-
|
|
3
|
+
import { n as createRuntime, o as prepareRelationships, r as isQueryStyle, t as createLiveRuntime } from "./content-BXrgP7nL.mjs";
|
|
4
|
+
import { t as restoreContentError } from "./diagnostics-DmUZtrJ6.mjs";
|
|
5
5
|
import { gunzipSync } from "fflate/browser";
|
|
6
6
|
//#region src/artifacts/runtime.ts
|
|
7
|
+
/** Checks that a value is a plain record before reading generated payload tables from it. */
|
|
8
|
+
function isTable(value) {
|
|
9
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Restores lazy custom payload loaders from a generated payload table.
|
|
13
|
+
*
|
|
14
|
+
* @param collection - The collection name, for error messages.
|
|
15
|
+
* @param payloads - Encoded loaders by payload name, entry ID, and canonical variant key.
|
|
16
|
+
* @returns Decoding loaders with the same keys.
|
|
17
|
+
*/
|
|
18
|
+
function customPayloadTable(collection, payloads) {
|
|
19
|
+
if (!isTable(payloads)) throw new Error(`Invalid payload table for collection "${collection}".`);
|
|
20
|
+
return new Map(Object.entries(payloads).map(([payload, entries]) => {
|
|
21
|
+
if (!isTable(entries)) throw new Error(`Invalid payload table for collection "${collection}".`);
|
|
22
|
+
return [payload, new Map(Object.entries(entries).map(([id, variants]) => {
|
|
23
|
+
if (!isTable(variants) || Object.values(variants).some((load) => typeof load !== "function")) throw new Error(`Invalid payload table for collection "${collection}".`);
|
|
24
|
+
return [id, new Map(Object.entries(variants).map(([variant, load]) => [variant, async () => decode((await load()).default)]))];
|
|
25
|
+
}))];
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
7
28
|
/** Initializes generated/embedded prepared content. This versioned wiring is internal. */
|
|
8
29
|
function createArtifactRevision(manifest, collections, renderMarkdown) {
|
|
9
30
|
try {
|
|
10
31
|
if (manifest.version !== 2 || manifest.codec !== "devalue-6.0.2") throw new Error("Incompatible content artifact or codec version; regenerate content.");
|
|
32
|
+
if (manifest.queryStyle !== void 0 && !isQueryStyle(manifest.queryStyle)) throw new Error("Invalid query style in content artifact; regenerate content.");
|
|
11
33
|
const revision = {
|
|
12
34
|
registry: manifest.collections,
|
|
13
35
|
collections: Object.create(null),
|
|
@@ -15,7 +37,8 @@ function createArtifactRevision(manifest, collections, renderMarkdown) {
|
|
|
15
37
|
active: 0,
|
|
16
38
|
payloadCache: /* @__PURE__ */ new Map(),
|
|
17
39
|
renderCache: /* @__PURE__ */ new Map(),
|
|
18
|
-
renderMarkdown
|
|
40
|
+
renderMarkdown,
|
|
41
|
+
...manifest.queryStyle ? { queryStyle: manifest.queryStyle } : {}
|
|
19
42
|
};
|
|
20
43
|
for (const [name, descriptor] of Object.entries(manifest.collections)) {
|
|
21
44
|
const encoded = collections[name];
|
|
@@ -25,7 +48,8 @@ function createArtifactRevision(manifest, collections, renderMarkdown) {
|
|
|
25
48
|
revision.collections[name] = {
|
|
26
49
|
records,
|
|
27
50
|
relationships: descriptor.relationships,
|
|
28
|
-
builtins: new Map(Object.entries(encoded.builtins ?? {}).map(([id, load]) => [id, async () => decode((await load()).default)]))
|
|
51
|
+
builtins: new Map(Object.entries(encoded.builtins ?? {}).map(([id, load]) => [id, async () => decode((await load()).default)])),
|
|
52
|
+
...encoded.payloads ? { payloads: customPayloadTable(name, encoded.payloads) } : {}
|
|
29
53
|
};
|
|
30
54
|
}
|
|
31
55
|
const errors = prepareRelationships(revision);
|
package/dist/loaders.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as GlobOptions, t as FileOptions } from "./descriptor-D9Th5hzk.mjs";
|
|
1
|
+
import { a as DataStore, c as Loader, d as LoaderLogger, f as LoaderSource, h as RecordLoader, i as DataEntry, l as LoaderConfig, m as MetaStore, n as GlobOptions, o as FileEntrySource, p as LoaderWatcher, r as BodyLoader, s as FileSource, t as FileOptions, u as LoaderContext } from "./descriptor-bcPa6XLk.mjs";
|
|
3
2
|
//#region src/loaders/file.d.ts
|
|
4
3
|
/** Declares a multi-entry data file with typed source paths and record keys, plus an optional parser. */
|
|
5
4
|
export declare function file(filename: string, options?: FileOptions): RecordLoader<FileEntrySource>;
|
|
@@ -8,4 +7,4 @@ export declare function file(filename: string, options?: FileOptions): RecordLoa
|
|
|
8
7
|
/** Declares local files with Astro-style IDs and typed, project-relative source paths. */
|
|
9
8
|
export declare function glob(options: GlobOptions): Loader<FileSource>;
|
|
10
9
|
//#endregion
|
|
11
|
-
export type { DataEntry, DataStore, FileEntrySource, FileOptions, FileSource, GlobOptions, Loader, LoaderConfig, LoaderContext, LoaderLogger, LoaderSource, LoaderWatcher, MetaStore, RecordLoader };
|
|
10
|
+
export type { BodyLoader, DataEntry, DataStore, FileEntrySource, FileOptions, FileSource, GlobOptions, Loader, LoaderConfig, LoaderContext, LoaderLogger, LoaderSource, LoaderWatcher, MetaStore, RecordLoader };
|
package/dist/loaders.mjs
CHANGED
|
@@ -1,85 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as groupDiagnostics, n as contentError, r as describeCause, t as ContentError } from "./errors-C2iuBM0G.mjs";
|
|
3
|
-
import { a as populateStore, i as recordData, n as coerceIdentity, r as parseData, t as glob } from "./glob-Bv0dpvCQ.mjs";
|
|
1
|
+
import { t as glob } from "./glob-BXJuwy_p.mjs";
|
|
4
2
|
import { t as assertServerOnly } from "./server-only-CIJUlyL-.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
//#region src/loaders/file.ts
|
|
9
|
-
/** Declares a multi-entry data file with typed source paths and record keys, plus an optional parser. */
|
|
10
|
-
function file(filename, options = {}) {
|
|
11
|
-
if (typeof filename !== "string" || !filename) throw new TypeError("file() requires a filename.");
|
|
12
|
-
const descriptor = {
|
|
13
|
-
kind: "file",
|
|
14
|
-
filename,
|
|
15
|
-
options
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
[builtinSymbol]: descriptor,
|
|
19
|
-
name: "content-query/file",
|
|
20
|
-
async load(context) {
|
|
21
|
-
const entries = await loadFile(descriptor, fileURLToPath(context.config.root), context.signal ?? new AbortController().signal);
|
|
22
|
-
await populateStore(context, entries);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/** Captures a complete multi-entry data source without applying collection validation. */
|
|
27
|
-
async function loadFile(descriptor, root, signal) {
|
|
28
|
-
const resolved = builtinPath(descriptor, root);
|
|
29
|
-
let parsed;
|
|
30
|
-
try {
|
|
31
|
-
const text = await readFile(resolved, {
|
|
32
|
-
encoding: "utf8",
|
|
33
|
-
signal
|
|
34
|
-
});
|
|
35
|
-
parsed = descriptor.options.parser ? await descriptor.options.parser(text) : parseData(text, resolved);
|
|
36
|
-
} catch (cause) {
|
|
37
|
-
signal.throwIfAborted();
|
|
38
|
-
throw contentError(cause, {
|
|
39
|
-
code: "source-error",
|
|
40
|
-
source: resolved,
|
|
41
|
-
message: `Could not load "${descriptor.filename}": ${describeCause(cause)}`,
|
|
42
|
-
cause
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const array = Array.isArray(parsed);
|
|
46
|
-
if (!array && (!parsed || typeof parsed !== "object")) throw new ContentError({
|
|
47
|
-
code: "source-error",
|
|
48
|
-
source: resolved,
|
|
49
|
-
message: `"${descriptor.filename}" must parse to an array or keyed record.`
|
|
50
|
-
});
|
|
51
|
-
const diagnostics = [];
|
|
52
|
-
const entries = Object.entries(parsed).flatMap(([key, value]) => {
|
|
53
|
-
if (!array && key === "$schema" && typeof value === "string") return [];
|
|
54
|
-
const source = `${resolved}#${key}`;
|
|
55
|
-
try {
|
|
56
|
-
const data = recordData(value);
|
|
57
|
-
const identity = array ? data.id ?? data.slug : key;
|
|
58
|
-
if (identity == null || coerceIdentity(identity) === "") throw new Error("Array entries require a nonempty id or slug.");
|
|
59
|
-
const { id: _transportId, ...metadata } = data;
|
|
60
|
-
return [{
|
|
61
|
-
id: coerceIdentity(identity),
|
|
62
|
-
data: metadata,
|
|
63
|
-
source: array ? source : `${resolved}#${coerceIdentity(identity)}`,
|
|
64
|
-
sourceData: {
|
|
65
|
-
filePath: path.relative(root, resolved).split(path.sep).join("/"),
|
|
66
|
-
key
|
|
67
|
-
}
|
|
68
|
-
}];
|
|
69
|
-
} catch (cause) {
|
|
70
|
-
diagnostics.push({
|
|
71
|
-
code: "source-error",
|
|
72
|
-
source,
|
|
73
|
-
message: `Invalid entry "${key}" in "${descriptor.filename}": ${describeCause(cause)}`,
|
|
74
|
-
cause
|
|
75
|
-
});
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (diagnostics.length) throw groupDiagnostics(diagnostics);
|
|
80
|
-
return entries;
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
3
|
+
import { t as file } from "./file-DSOcdFj0.mjs";
|
|
83
4
|
//#region src/loaders.ts
|
|
84
5
|
assertServerOnly();
|
|
85
6
|
//#endregion
|
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as BuildContentOptions } from "./build-
|
|
1
|
+
import { t as BuildContentOptions } from "./build-DL1GzmRy.mjs";
|
|
2
2
|
import { NextConfig } from "next";
|
|
3
3
|
//#region src/integrations/next/plugin.d.ts
|
|
4
4
|
/** Content locations for Next.js; the adapter chooses generated storage and the watch lifecycle. */
|
package/dist/next.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as contentDeclarations, i as resolveConfigPath, t as buildAtRoot } from "./build-
|
|
2
|
-
import { n as serializeContentError } from "./diagnostics-
|
|
1
|
+
import { c as contentDeclarations, i as resolveConfigPath, t as buildAtRoot } from "./build-CcqIpkes.mjs";
|
|
2
|
+
import { n as serializeContentError } from "./diagnostics-DmUZtrJ6.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as invalidQuery } from "./errors-
|
|
1
|
+
import { a as invalidQuery } from "./errors-Bfd0R4_P.mjs";
|
|
2
2
|
import { c as isScalar, i as detach } from "./values-BbTV4QT-.mjs";
|
|
3
3
|
//#region src/query/operators.ts
|
|
4
4
|
/** Builds a checked, backend-independent predicate instead of a per-entry callback. */
|
|
@@ -78,6 +78,89 @@ function startsWith(field, value) {
|
|
|
78
78
|
function endsWith(field, value) {
|
|
79
79
|
return predicate("ends-with", field, value);
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Matches a SQL-style pattern: `%` matches any run of characters and `_` matches one character.
|
|
83
|
+
* A backslash escapes a wildcard. Matching is case-sensitive.
|
|
84
|
+
*/
|
|
85
|
+
function like(field, pattern) {
|
|
86
|
+
return predicate("like", field, pattern);
|
|
87
|
+
}
|
|
88
|
+
/** Matches a SQL-style pattern like {@link like}, ignoring case. */
|
|
89
|
+
function ilike(field, pattern) {
|
|
90
|
+
return predicate("ilike", field, pattern);
|
|
91
|
+
}
|
|
92
|
+
/** Negates {@link like}; entries without a matching string, including absent values, match. */
|
|
93
|
+
function notLike(field, pattern) {
|
|
94
|
+
return not(like(field, pattern));
|
|
95
|
+
}
|
|
96
|
+
/** Negates {@link ilike}; entries without a matching string, including absent values, match. */
|
|
97
|
+
function notIlike(field, pattern) {
|
|
98
|
+
return not(ilike(field, pattern));
|
|
99
|
+
}
|
|
100
|
+
/** Tests whether every item of an existing scalar array belongs to the candidates. */
|
|
101
|
+
function arrayContained(field, values) {
|
|
102
|
+
return predicate("array-contained", field, values);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Matches entries with at least one related entry. With a filter, a related entry must also match
|
|
106
|
+
* it, for example `has(fields.author, (author) => eq(author.name, "Ada"))`. Wrap the result in
|
|
107
|
+
* {@link not} to match entries without such a related entry.
|
|
108
|
+
*
|
|
109
|
+
* @param relation - A relationship from the `where()` callback's fields.
|
|
110
|
+
* @param filter - Optional filter over the related entry's fields and relationships.
|
|
111
|
+
* @returns An expression that the query resolves against the relationship's target collection.
|
|
112
|
+
*/
|
|
113
|
+
function has(relation, filter) {
|
|
114
|
+
if (!relation || typeof relation.name !== "string" || !relation.name) invalidQuery("has() requires a relationship from the where() fields.");
|
|
115
|
+
if (filter !== void 0 && typeof filter !== "function") invalidQuery("has() filters must be callbacks over the related entry's fields.");
|
|
116
|
+
const expression = filter === void 0 ? and() : filter(fieldProxy());
|
|
117
|
+
validateExpression(expression);
|
|
118
|
+
return {
|
|
119
|
+
kind: "has",
|
|
120
|
+
field: relation.name,
|
|
121
|
+
expression
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** Creates the field and relationship accessors passed to filter callbacks. */
|
|
125
|
+
function fieldProxy() {
|
|
126
|
+
return new Proxy(Object.create(null), { get: (_target, name) => ({ name }) });
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Resolves fluent `has()` filters against a scope's declared relationships, producing portable
|
|
130
|
+
* `relation` expressions that both runtime backends evaluate.
|
|
131
|
+
*
|
|
132
|
+
* @param registry - The query registry with each collection's relationships.
|
|
133
|
+
* @param collection - The collection the expression filters.
|
|
134
|
+
* @param expression - A validated expression that may contain `has()` filters.
|
|
135
|
+
* @returns The expression with every `has()` filter resolved.
|
|
136
|
+
*/
|
|
137
|
+
function resolveRelations(registry, collection, expression) {
|
|
138
|
+
switch (expression.kind) {
|
|
139
|
+
case "has": {
|
|
140
|
+
const relationships = registry[collection]?.relationships ?? {};
|
|
141
|
+
const relation = Object.hasOwn(relationships, expression.field) ? relationships[expression.field] : void 0;
|
|
142
|
+
if (!relation) invalidQuery(`Unknown relationship "${expression.field}" in has().`);
|
|
143
|
+
return {
|
|
144
|
+
kind: "relation",
|
|
145
|
+
collection,
|
|
146
|
+
field: expression.field,
|
|
147
|
+
target: relation.collection,
|
|
148
|
+
expression: resolveRelations(registry, relation.collection, expression.expression)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
case "relation": return {
|
|
152
|
+
...expression,
|
|
153
|
+
expression: resolveRelations(registry, expression.target, expression.expression)
|
|
154
|
+
};
|
|
155
|
+
case "and":
|
|
156
|
+
case "or":
|
|
157
|
+
case "not": return {
|
|
158
|
+
...expression,
|
|
159
|
+
expressions: expression.expressions.map((child) => resolveRelations(registry, collection, child))
|
|
160
|
+
};
|
|
161
|
+
default: return expression;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
81
164
|
/** Tests scalar membership in an array, ignoring holes. */
|
|
82
165
|
function arrayContains(field, value) {
|
|
83
166
|
return predicate("array-contains", field, value);
|
|
@@ -160,6 +243,9 @@ function validateExpression(expression) {
|
|
|
160
243
|
expression.target
|
|
161
244
|
].some((name) => typeof name !== "string" || !name)) invalidQuery("Relationship filters require registered collection and relationship names.");
|
|
162
245
|
validateExpression(expression.expression);
|
|
246
|
+
} else if (expression.kind === "has") {
|
|
247
|
+
if (typeof expression.field !== "string" || !expression.field) invalidQuery("has() requires a relationship from the where() fields.");
|
|
248
|
+
validateExpression(expression.expression);
|
|
163
249
|
} else if ([
|
|
164
250
|
"and",
|
|
165
251
|
"or",
|
|
@@ -170,4 +256,4 @@ function validateExpression(expression) {
|
|
|
170
256
|
} else invalidQuery("Invalid expression structure.");
|
|
171
257
|
}
|
|
172
258
|
//#endregion
|
|
173
|
-
export { not as _,
|
|
259
|
+
export { notIlike as C, resolveRelations as D, or as E, startsWith as O, not as S, notLike as T, isUndefined as _, arrayContainsAny as a, lte as b, eq as c, gte as d, has as f, isNull as g, isMissing as h, arrayContainsAll as i, validateExpression as k, fieldProxy as l, inArray as m, arrayContained as n, contains as o, ilike as p, arrayContains as r, endsWith as s, and as t, gt as u, like as v, notInArray as w, ne as x, lt as y };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/runtime/query-style.d.ts
|
|
2
|
+
/** Query APIs an application can allow through `queryStyle` in content-query.config. */
|
|
3
|
+
type QueryStyle = "fluent" | "relational";
|
|
4
|
+
/**
|
|
5
|
+
* Root `content` members that start each query style. Every other query API hangs off these
|
|
6
|
+
* members, so gating them gates payloads, relationships, and adjacency as well.
|
|
7
|
+
*/
|
|
8
|
+
declare const queryStyleMembers: {
|
|
9
|
+
readonly fluent: readonly ["from"];
|
|
10
|
+
readonly relational: readonly ["query", "count"];
|
|
11
|
+
};
|
|
12
|
+
/** A root `content` member that belongs to exactly one query style. */
|
|
13
|
+
type QueryStyleMember = (typeof queryStyleMembers)[QueryStyle][number];
|
|
14
|
+
/** Root members that start a query in the given style. */
|
|
15
|
+
type MembersOf<Style extends QueryStyle> = (typeof queryStyleMembers)[Style][number];
|
|
16
|
+
/**
|
|
17
|
+
* Describes a disabled root member in the type error itself, for example:
|
|
18
|
+
* `content.from is unavailable because content-query.config sets queryStyle to "relational".`
|
|
19
|
+
*/
|
|
20
|
+
type QueryStyleDisabled<Member extends QueryStyleMember, Style extends QueryStyle> = `content.${Member} is unavailable because content-query.config sets queryStyle to "${Style}".`;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { QueryStyleMember as i, QueryStyle as n, QueryStyleDisabled as r, MembersOf as t };
|
package/dist/query.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as RelationalWhere, c as Fields, d as
|
|
1
|
+
import { _ as Where, a as RelationalWhere, c as Fields, d as QueryFields, f as RelationField, g as SelectionResult, h as Selection, i as RelationalQueryResult, l as Ordered, m as ScalarField, n as RelationalQueries, o as Adjacent, p as Scalar, r as RelationalQueryOptions, s as Field, t as RelationalCountOptions, v as Expression } from "./relational-types-C8xJtLG5.mjs";
|
|
2
2
|
//#region src/query/operators.d.ts
|
|
3
3
|
/** Matches a scalar using strict value/date equality. */
|
|
4
4
|
export declare function eq<Value>(field: ScalarField<Value>, value: NoInfer<Value>): Expression;
|
|
@@ -22,6 +22,29 @@ export declare function contains<Value>(field: Field<Value> & (NonNullable<Value
|
|
|
22
22
|
export declare function startsWith<Value>(field: Field<Value> & (NonNullable<Value> extends string ? unknown : never), value: string): Expression;
|
|
23
23
|
/** Matches a literal string suffix. */
|
|
24
24
|
export declare function endsWith<Value>(field: Field<Value> & (NonNullable<Value> extends string ? unknown : never), value: string): Expression;
|
|
25
|
+
/**
|
|
26
|
+
* Matches a SQL-style pattern: `%` matches any run of characters and `_` matches one character.
|
|
27
|
+
* A backslash escapes a wildcard. Matching is case-sensitive.
|
|
28
|
+
*/
|
|
29
|
+
export declare function like<Value>(field: Field<Value> & (NonNullable<Value> extends string ? unknown : never), pattern: string): Expression;
|
|
30
|
+
/** Matches a SQL-style pattern like {@link like}, ignoring case. */
|
|
31
|
+
export declare function ilike<Value>(field: Field<Value> & (NonNullable<Value> extends string ? unknown : never), pattern: string): Expression;
|
|
32
|
+
/** Negates {@link like}; entries without a matching string, including absent values, match. */
|
|
33
|
+
export declare function notLike<Value>(field: Field<Value> & (NonNullable<Value> extends string ? unknown : never), pattern: string): Expression;
|
|
34
|
+
/** Negates {@link ilike}; entries without a matching string, including absent values, match. */
|
|
35
|
+
export declare function notIlike<Value>(field: Field<Value> & (NonNullable<Value> extends string ? unknown : never), pattern: string): Expression;
|
|
36
|
+
/** Tests whether every item of an existing scalar array belongs to the candidates. */
|
|
37
|
+
export declare function arrayContained<Value extends Scalar>(field: Field<readonly Value[] | null | undefined>, values: readonly NoInfer<Value>[]): Expression;
|
|
38
|
+
/**
|
|
39
|
+
* Matches entries with at least one related entry. With a filter, a related entry must also match
|
|
40
|
+
* it, for example `has(fields.author, (author) => eq(author.name, "Ada"))`. Wrap the result in
|
|
41
|
+
* {@link not} to match entries without such a related entry.
|
|
42
|
+
*
|
|
43
|
+
* @param relation - A relationship from the `where()` callback's fields.
|
|
44
|
+
* @param filter - Optional filter over the related entry's fields and relationships.
|
|
45
|
+
* @returns An expression that the query resolves against the relationship's target collection.
|
|
46
|
+
*/
|
|
47
|
+
export declare function has<TargetFields>(relation: RelationField<TargetFields>, filter?: (fields: TargetFields) => Expression): Expression;
|
|
25
48
|
/** Tests scalar membership in an array, ignoring holes. */
|
|
26
49
|
export declare function arrayContains<Value extends Scalar>(field: Field<readonly Value[] | null | undefined>, value: NoInfer<Value>): Expression;
|
|
27
50
|
/** Tests whether any candidate belongs to an existing scalar array. */
|
|
@@ -41,4 +64,4 @@ export declare function or(...expressions: Expression[]): Expression;
|
|
|
41
64
|
/** Negates a predicate's boolean result. */
|
|
42
65
|
export declare function not(expression: Expression): Expression;
|
|
43
66
|
//#endregion
|
|
44
|
-
export type { Adjacent, RelationalCountOptions as CountOptions, Expression, Field, Fields, RelationalQueryOptions as QueryOptions, RelationalQueryOptions, RelationalQueries, RelationalQueryResult, RelationalWhere, Selection, SelectionResult, Where };
|
|
67
|
+
export type { Adjacent, RelationalCountOptions as CountOptions, Expression, Field, Fields, QueryFields, RelationalQueryOptions as QueryOptions, RelationalQueryOptions, RelationField, RelationalQueries, RelationalQueryResult, RelationalWhere, Selection, SelectionResult, Where };
|
package/dist/query.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as and, n as
|
|
1
|
+
export { t as and, n as arrayContained, r as arrayContains, i as arrayContainsAll, a as arrayContainsAny, o as contains, s as endsWith, c as eq, u as gt, d as gte, f as has, p as ilike, m as inArray, h as isMissing, g as isNull, _ as isUndefined, v as like, y as lt, b as lte, x as ne, S as not, C as notIlike, w as notInArray, T as notLike, E as or, O as startsWith } from "./operators-Cwy8Kx4o.mjs";
|