@atscript/db 0.1.133 → 0.1.135
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/agg-BtlGeRfj.d.mts +43 -0
- package/dist/agg-CvXDGnKi.mjs +61 -0
- package/dist/agg-DKuf_v2L.d.cts +43 -0
- package/dist/agg-EcIbAFnJ.cjs +78 -0
- package/dist/agg.cjs +3 -33
- package/dist/agg.d.cts +3 -35
- package/dist/agg.d.mts +3 -35
- package/dist/agg.mjs +2 -34
- package/dist/{buckets-CTWy7Y1k.d.cts → buckets-D6PBXKRJ.d.cts} +58 -10
- package/dist/{buckets-BENuu_tK.d.mts → buckets-GruoVxH5.d.mts} +58 -10
- package/dist/{db-space-Bv3Ar_Xd.d.mts → db-space-9CH5neN7.d.mts} +5 -3
- package/dist/{db-space-DROLifb-.d.cts → db-space-BdtBNTeH.d.cts} +5 -3
- package/dist/{db-view-B5-bQ5AV.cjs → db-view-Dm7MpUGB.cjs} +75 -29
- package/dist/{db-view-caPATLmX.mjs → db-view-Doh8vPg3.mjs} +75 -29
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/rel.d.cts +1 -1
- package/dist/rel.d.mts +1 -1
- package/dist/sync.cjs +1 -1
- package/dist/sync.d.cts +2 -2
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AggregateControls, AggregateExpr as AggregateExpr$1, AggregateFn, AggregateFn as AggregateFn$1, AggregateQuery as AggregateQuery$1, AggregateResult, BucketExpr, BucketUnit as BucketUnit$1, CalendarBucketLabel, ComputedExpr, ResolvedBucket as ResolvedBucket$1, WeekStart, isAggregateExpr as isAggregateExpr$1, isBucketExpr as isBucketExpr$1, resolveAlias } from "@uniqu/core";
|
|
2
|
+
|
|
3
|
+
//#region src/query/aggregate-fns.d.ts
|
|
4
|
+
/** The aggregate functions atscript-db adapters implement — uniqu's set minus `countDistinct`. */
|
|
5
|
+
type TDbAggregateFn = Exclude<AggregateFn, "countDistinct">;
|
|
6
|
+
/**
|
|
7
|
+
* Throws `DbError` `INVALID_QUERY` (uniqu's wording) unless `fn` is in
|
|
8
|
+
* `SUPPORTED_AGGREGATE_FNS` — for adapters to re-assert before rendering.
|
|
9
|
+
*/
|
|
10
|
+
declare function assertAggregateFn(fn: unknown, path?: string): asserts fn is TDbAggregateFn;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/agg.d.ts
|
|
13
|
+
/** The text-search request a grouped query carries, once normalised. */
|
|
14
|
+
interface TAggregateSearch {
|
|
15
|
+
/** Non-empty, trimmed search term. */
|
|
16
|
+
text: string;
|
|
17
|
+
/** Named search index to target, when the caller picked one. */
|
|
18
|
+
indexName?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
22
|
+
*
|
|
23
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
24
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
25
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
26
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
27
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
28
|
+
*
|
|
29
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
30
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
31
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
32
|
+
* Grouped results order by `$sort` or not at all.
|
|
33
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
34
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
35
|
+
*
|
|
36
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
37
|
+
* straight through to the plain grouped path.
|
|
38
|
+
*/
|
|
39
|
+
declare function resolveAggregateSearch(controls: {
|
|
40
|
+
[key: `$${string}`]: unknown;
|
|
41
|
+
} | undefined): TAggregateSearch | undefined;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { assertAggregateFn as _, AggregateResult as a, CalendarBucketLabel as c, WeekStart as d, isAggregateExpr$1 as f, TDbAggregateFn as g, resolveAlias as h, AggregateQuery$1 as i, ComputedExpr as l, resolveAggregateSearch as m, AggregateExpr$1 as n, BucketExpr as o, isBucketExpr$1 as p, AggregateFn$1 as r, BucketUnit$1 as s, AggregateControls as t, ResolvedBucket$1 as u };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { r as DbError } from "./db-error-D5uilS_A.mjs";
|
|
2
|
+
import { isAggregateExpr as isAggregateExpr$1, isBucketExpr as isBucketExpr$1, resolveAlias } from "@uniqu/core";
|
|
3
|
+
//#region src/query/aggregate-fns.ts
|
|
4
|
+
/**
|
|
5
|
+
* The only `$fn` names a `$select` aggregate may use (since 0.1.135). Any
|
|
6
|
+
* other name is rejected with `INVALID_QUERY` (HTTP 400 through moost-db)
|
|
7
|
+
* before a query reaches an adapter, so no adapter ever renders an unchecked
|
|
8
|
+
* function name into SQL or a pipeline.
|
|
9
|
+
*/
|
|
10
|
+
const SUPPORTED_AGGREGATE_FNS = [
|
|
11
|
+
"sum",
|
|
12
|
+
"count",
|
|
13
|
+
"avg",
|
|
14
|
+
"min",
|
|
15
|
+
"max"
|
|
16
|
+
];
|
|
17
|
+
const SUPPORTED_LIST = `${SUPPORTED_AGGREGATE_FNS.slice(0, -1).join(", ")} or ${SUPPORTED_AGGREGATE_FNS.at(-1)}`;
|
|
18
|
+
/**
|
|
19
|
+
* Throws `DbError` `INVALID_QUERY` (uniqu's wording) unless `fn` is in
|
|
20
|
+
* `SUPPORTED_AGGREGATE_FNS` — for adapters to re-assert before rendering.
|
|
21
|
+
*/
|
|
22
|
+
function assertAggregateFn(fn, path = "$select") {
|
|
23
|
+
if (!SUPPORTED_AGGREGATE_FNS.includes(fn)) throw new DbError("INVALID_QUERY", [{
|
|
24
|
+
path,
|
|
25
|
+
message: `Unknown aggregate function "${String(fn)}" — use ${SUPPORTED_LIST}`
|
|
26
|
+
}]);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/agg.ts
|
|
30
|
+
/**
|
|
31
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
32
|
+
*
|
|
33
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
34
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
35
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
36
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
37
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
38
|
+
*
|
|
39
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
40
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
41
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
42
|
+
* Grouped results order by `$sort` or not at all.
|
|
43
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
44
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
45
|
+
*
|
|
46
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
47
|
+
* straight through to the plain grouped path.
|
|
48
|
+
*/
|
|
49
|
+
function resolveAggregateSearch(controls) {
|
|
50
|
+
const raw = controls?.$search;
|
|
51
|
+
if (typeof raw !== "string") return;
|
|
52
|
+
const text = raw.trim();
|
|
53
|
+
if (!text) return;
|
|
54
|
+
const index = controls?.$index;
|
|
55
|
+
return {
|
|
56
|
+
text,
|
|
57
|
+
indexName: typeof index === "string" && index ? index : void 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { SUPPORTED_AGGREGATE_FNS as a, resolveAlias as i, isBucketExpr$1 as n, assertAggregateFn as o, resolveAggregateSearch as r, isAggregateExpr$1 as t };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AggregateControls, AggregateExpr as AggregateExpr$1, AggregateFn, AggregateFn as AggregateFn$1, AggregateQuery as AggregateQuery$1, AggregateResult, BucketExpr, BucketUnit as BucketUnit$1, CalendarBucketLabel, ComputedExpr, ResolvedBucket as ResolvedBucket$1, WeekStart, isAggregateExpr, isBucketExpr, resolveAlias } from "@uniqu/core";
|
|
2
|
+
|
|
3
|
+
//#region src/query/aggregate-fns.d.ts
|
|
4
|
+
/** The aggregate functions atscript-db adapters implement — uniqu's set minus `countDistinct`. */
|
|
5
|
+
type TDbAggregateFn = Exclude<AggregateFn, "countDistinct">;
|
|
6
|
+
/**
|
|
7
|
+
* Throws `DbError` `INVALID_QUERY` (uniqu's wording) unless `fn` is in
|
|
8
|
+
* `SUPPORTED_AGGREGATE_FNS` — for adapters to re-assert before rendering.
|
|
9
|
+
*/
|
|
10
|
+
declare function assertAggregateFn(fn: unknown, path?: string): asserts fn is TDbAggregateFn;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/agg.d.ts
|
|
13
|
+
/** The text-search request a grouped query carries, once normalised. */
|
|
14
|
+
interface TAggregateSearch {
|
|
15
|
+
/** Non-empty, trimmed search term. */
|
|
16
|
+
text: string;
|
|
17
|
+
/** Named search index to target, when the caller picked one. */
|
|
18
|
+
indexName?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
22
|
+
*
|
|
23
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
24
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
25
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
26
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
27
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
28
|
+
*
|
|
29
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
30
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
31
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
32
|
+
* Grouped results order by `$sort` or not at all.
|
|
33
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
34
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
35
|
+
*
|
|
36
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
37
|
+
* straight through to the plain grouped path.
|
|
38
|
+
*/
|
|
39
|
+
declare function resolveAggregateSearch(controls: {
|
|
40
|
+
[key: `$${string}`]: unknown;
|
|
41
|
+
} | undefined): TAggregateSearch | undefined;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { assertAggregateFn as _, AggregateResult as a, CalendarBucketLabel as c, WeekStart as d, isAggregateExpr as f, TDbAggregateFn as g, resolveAlias as h, AggregateQuery$1 as i, ComputedExpr as l, resolveAggregateSearch as m, AggregateExpr$1 as n, BucketExpr as o, isBucketExpr as p, AggregateFn$1 as r, BucketUnit$1 as s, AggregateControls as t, ResolvedBucket$1 as u };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const require_db_error = require("./db-error-DTkkeu5b.cjs");
|
|
2
|
+
require("@uniqu/core");
|
|
3
|
+
//#region src/query/aggregate-fns.ts
|
|
4
|
+
/**
|
|
5
|
+
* The only `$fn` names a `$select` aggregate may use (since 0.1.135). Any
|
|
6
|
+
* other name is rejected with `INVALID_QUERY` (HTTP 400 through moost-db)
|
|
7
|
+
* before a query reaches an adapter, so no adapter ever renders an unchecked
|
|
8
|
+
* function name into SQL or a pipeline.
|
|
9
|
+
*/
|
|
10
|
+
const SUPPORTED_AGGREGATE_FNS = [
|
|
11
|
+
"sum",
|
|
12
|
+
"count",
|
|
13
|
+
"avg",
|
|
14
|
+
"min",
|
|
15
|
+
"max"
|
|
16
|
+
];
|
|
17
|
+
const SUPPORTED_LIST = `${SUPPORTED_AGGREGATE_FNS.slice(0, -1).join(", ")} or ${SUPPORTED_AGGREGATE_FNS.at(-1)}`;
|
|
18
|
+
/**
|
|
19
|
+
* Throws `DbError` `INVALID_QUERY` (uniqu's wording) unless `fn` is in
|
|
20
|
+
* `SUPPORTED_AGGREGATE_FNS` — for adapters to re-assert before rendering.
|
|
21
|
+
*/
|
|
22
|
+
function assertAggregateFn(fn, path = "$select") {
|
|
23
|
+
if (!SUPPORTED_AGGREGATE_FNS.includes(fn)) throw new require_db_error.DbError("INVALID_QUERY", [{
|
|
24
|
+
path,
|
|
25
|
+
message: `Unknown aggregate function "${String(fn)}" — use ${SUPPORTED_LIST}`
|
|
26
|
+
}]);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/agg.ts
|
|
30
|
+
/**
|
|
31
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
32
|
+
*
|
|
33
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
34
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
35
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
36
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
37
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
38
|
+
*
|
|
39
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
40
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
41
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
42
|
+
* Grouped results order by `$sort` or not at all.
|
|
43
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
44
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
45
|
+
*
|
|
46
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
47
|
+
* straight through to the plain grouped path.
|
|
48
|
+
*/
|
|
49
|
+
function resolveAggregateSearch(controls) {
|
|
50
|
+
const raw = controls?.$search;
|
|
51
|
+
if (typeof raw !== "string") return;
|
|
52
|
+
const text = raw.trim();
|
|
53
|
+
if (!text) return;
|
|
54
|
+
const index = controls?.$index;
|
|
55
|
+
return {
|
|
56
|
+
text,
|
|
57
|
+
indexName: typeof index === "string" && index ? index : void 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
Object.defineProperty(exports, "SUPPORTED_AGGREGATE_FNS", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function() {
|
|
64
|
+
return SUPPORTED_AGGREGATE_FNS;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "assertAggregateFn", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function() {
|
|
70
|
+
return assertAggregateFn;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "resolveAggregateSearch", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function() {
|
|
76
|
+
return resolveAggregateSearch;
|
|
77
|
+
}
|
|
78
|
+
});
|
package/dist/agg.cjs
CHANGED
|
@@ -1,37 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_agg = require("./agg-EcIbAFnJ.cjs");
|
|
2
3
|
let _uniqu_core = require("@uniqu/core");
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
6
|
-
*
|
|
7
|
-
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
8
|
-
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
9
|
-
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
10
|
-
* describe rows that matched. An adapter that silently ignored the term would
|
|
11
|
-
* report totals for rows the same search excludes from the leaf list.
|
|
12
|
-
*
|
|
13
|
-
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
14
|
-
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
15
|
-
* of a group; after `$group` there is no per-row score left to sort on.
|
|
16
|
-
* Grouped results order by `$sort` or not at all.
|
|
17
|
-
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
18
|
-
* rows; applying that before `$group` would silently truncate group counts.
|
|
19
|
-
*
|
|
20
|
-
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
21
|
-
* straight through to the plain grouped path.
|
|
22
|
-
*/
|
|
23
|
-
function resolveAggregateSearch(controls) {
|
|
24
|
-
const raw = controls?.$search;
|
|
25
|
-
if (typeof raw !== "string") return;
|
|
26
|
-
const text = raw.trim();
|
|
27
|
-
if (!text) return;
|
|
28
|
-
const index = controls?.$index;
|
|
29
|
-
return {
|
|
30
|
-
text,
|
|
31
|
-
indexName: typeof index === "string" && index ? index : void 0
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
4
|
+
exports.assertAggregateFn = require_agg.assertAggregateFn;
|
|
35
5
|
Object.defineProperty(exports, "isAggregateExpr", {
|
|
36
6
|
enumerable: true,
|
|
37
7
|
get: function() {
|
|
@@ -44,7 +14,7 @@ Object.defineProperty(exports, "isBucketExpr", {
|
|
|
44
14
|
return _uniqu_core.isBucketExpr;
|
|
45
15
|
}
|
|
46
16
|
});
|
|
47
|
-
exports.resolveAggregateSearch = resolveAggregateSearch;
|
|
17
|
+
exports.resolveAggregateSearch = require_agg.resolveAggregateSearch;
|
|
48
18
|
Object.defineProperty(exports, "resolveAlias", {
|
|
49
19
|
enumerable: true,
|
|
50
20
|
get: function() {
|
package/dist/agg.d.cts
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
import { n as TResolvedBucket } from "./buckets-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/agg.d.ts
|
|
5
|
-
/** The text-search request a grouped query carries, once normalised. */
|
|
6
|
-
interface TAggregateSearch {
|
|
7
|
-
/** Non-empty, trimmed search term. */
|
|
8
|
-
text: string;
|
|
9
|
-
/** Named search index to target, when the caller picked one. */
|
|
10
|
-
indexName?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
14
|
-
*
|
|
15
|
-
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
16
|
-
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
17
|
-
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
18
|
-
* describe rows that matched. An adapter that silently ignored the term would
|
|
19
|
-
* report totals for rows the same search excludes from the leaf list.
|
|
20
|
-
*
|
|
21
|
-
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
22
|
-
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
23
|
-
* of a group; after `$group` there is no per-row score left to sort on.
|
|
24
|
-
* Grouped results order by `$sort` or not at all.
|
|
25
|
-
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
26
|
-
* rows; applying that before `$group` would silently truncate group counts.
|
|
27
|
-
*
|
|
28
|
-
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
29
|
-
* straight through to the plain grouped path.
|
|
30
|
-
*/
|
|
31
|
-
declare function resolveAggregateSearch(controls: {
|
|
32
|
-
[key: `$${string}`]: unknown;
|
|
33
|
-
} | undefined): TAggregateSearch | undefined;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, type BucketExpr, type BucketUnit, type CalendarBucketLabel, type ComputedExpr, type ResolvedBucket, type TResolvedBucket, type WeekStart, isAggregateExpr, isBucketExpr, resolveAggregateSearch, resolveAlias };
|
|
1
|
+
import { n as TResolvedBucket } from "./buckets-D6PBXKRJ.cjs";
|
|
2
|
+
import { _ as assertAggregateFn, a as AggregateResult, c as CalendarBucketLabel, d as WeekStart, f as isAggregateExpr, g as TDbAggregateFn, h as resolveAlias, i as AggregateQuery, l as ComputedExpr, m as resolveAggregateSearch, n as AggregateExpr, o as BucketExpr, p as isBucketExpr, r as AggregateFn, s as BucketUnit, t as AggregateControls, u as ResolvedBucket } from "./agg-DKuf_v2L.cjs";
|
|
3
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, type BucketExpr, type BucketUnit, type CalendarBucketLabel, type ComputedExpr, type ResolvedBucket, type TDbAggregateFn, type TResolvedBucket, type WeekStart, assertAggregateFn, isAggregateExpr, isBucketExpr, resolveAggregateSearch, resolveAlias };
|
package/dist/agg.d.mts
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
import { n as TResolvedBucket } from "./buckets-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/agg.d.ts
|
|
5
|
-
/** The text-search request a grouped query carries, once normalised. */
|
|
6
|
-
interface TAggregateSearch {
|
|
7
|
-
/** Non-empty, trimmed search term. */
|
|
8
|
-
text: string;
|
|
9
|
-
/** Named search index to target, when the caller picked one. */
|
|
10
|
-
indexName?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
14
|
-
*
|
|
15
|
-
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
16
|
-
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
17
|
-
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
18
|
-
* describe rows that matched. An adapter that silently ignored the term would
|
|
19
|
-
* report totals for rows the same search excludes from the leaf list.
|
|
20
|
-
*
|
|
21
|
-
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
22
|
-
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
23
|
-
* of a group; after `$group` there is no per-row score left to sort on.
|
|
24
|
-
* Grouped results order by `$sort` or not at all.
|
|
25
|
-
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
26
|
-
* rows; applying that before `$group` would silently truncate group counts.
|
|
27
|
-
*
|
|
28
|
-
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
29
|
-
* straight through to the plain grouped path.
|
|
30
|
-
*/
|
|
31
|
-
declare function resolveAggregateSearch(controls: {
|
|
32
|
-
[key: `$${string}`]: unknown;
|
|
33
|
-
} | undefined): TAggregateSearch | undefined;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, type BucketExpr, type BucketUnit, type CalendarBucketLabel, type ComputedExpr, type ResolvedBucket, type TResolvedBucket, type WeekStart, isAggregateExpr, isBucketExpr, resolveAggregateSearch, resolveAlias };
|
|
1
|
+
import { n as TResolvedBucket } from "./buckets-GruoVxH5.mjs";
|
|
2
|
+
import { _ as assertAggregateFn, a as AggregateResult, c as CalendarBucketLabel, d as WeekStart, f as isAggregateExpr, g as TDbAggregateFn, h as resolveAlias, i as AggregateQuery, l as ComputedExpr, m as resolveAggregateSearch, n as AggregateExpr, o as BucketExpr, p as isBucketExpr, r as AggregateFn, s as BucketUnit, t as AggregateControls, u as ResolvedBucket } from "./agg-BtlGeRfj.mjs";
|
|
3
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, type BucketExpr, type BucketUnit, type CalendarBucketLabel, type ComputedExpr, type ResolvedBucket, type TDbAggregateFn, type TResolvedBucket, type WeekStart, assertAggregateFn, isAggregateExpr, isBucketExpr, resolveAggregateSearch, resolveAlias };
|
package/dist/agg.mjs
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
5
|
-
*
|
|
6
|
-
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
7
|
-
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
8
|
-
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
9
|
-
* describe rows that matched. An adapter that silently ignored the term would
|
|
10
|
-
* report totals for rows the same search excludes from the leaf list.
|
|
11
|
-
*
|
|
12
|
-
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
13
|
-
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
14
|
-
* of a group; after `$group` there is no per-row score left to sort on.
|
|
15
|
-
* Grouped results order by `$sort` or not at all.
|
|
16
|
-
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
17
|
-
* rows; applying that before `$group` would silently truncate group counts.
|
|
18
|
-
*
|
|
19
|
-
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
20
|
-
* straight through to the plain grouped path.
|
|
21
|
-
*/
|
|
22
|
-
function resolveAggregateSearch(controls) {
|
|
23
|
-
const raw = controls?.$search;
|
|
24
|
-
if (typeof raw !== "string") return;
|
|
25
|
-
const text = raw.trim();
|
|
26
|
-
if (!text) return;
|
|
27
|
-
const index = controls?.$index;
|
|
28
|
-
return {
|
|
29
|
-
text,
|
|
30
|
-
indexName: typeof index === "string" && index ? index : void 0
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { isAggregateExpr, isBucketExpr, resolveAggregateSearch, resolveAlias };
|
|
1
|
+
import { i as resolveAlias, n as isBucketExpr, o as assertAggregateFn, r as resolveAggregateSearch, t as isAggregateExpr } from "./agg-CvXDGnKi.mjs";
|
|
2
|
+
export { assertAggregateFn, isAggregateExpr, isBucketExpr, resolveAggregateSearch, resolveAlias };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { f as TFieldOps } from "./ops-AqhV7s9o.cjs";
|
|
2
|
-
import { AggregateControls, AggregateExpr, AggregateExpr as AggregateExpr$1, AggregateFn, AggregateQuery, AggregateQuery as AggregateQuery$1, AggregateResult, BucketUnit, FieldOpsFor, FilterExpr, FilterExpr as FilterExpr$1, ResolvedBucket, TypedWithRelation, Uniquery, Uniquery as Uniquery$1, UniqueryControls, UniqueryControls as UniqueryControls$1, UniqueryInsights, WithRelation, WithRelation as WithRelation$1 } from "@uniqu/core";
|
|
2
|
+
import { AggregateControls, AggregateExpr, AggregateExpr as AggregateExpr$1, AggregateFn as AggregateFn$1, AggregateQuery, AggregateQuery as AggregateQuery$1, AggregateResult, BucketUnit, FieldOpsFor, FilterExpr, FilterExpr as FilterExpr$1, ResolvedBucket, TypedWithRelation, Uniquery, Uniquery as Uniquery$1, UniqueryControls, UniqueryControls as UniqueryControls$1, UniqueryInsights, WithRelation, WithRelation as WithRelation$1 } from "@uniqu/core";
|
|
3
3
|
import { FlatOf, FlatOf as FlatOf$1, NavPropsOf, NavPropsOf as NavPropsOf$1, OwnPropsOf, OwnPropsOf as OwnPropsOf$1, PrimaryKeyOf, PrimaryKeyOf as PrimaryKeyOf$1, TAtscriptAnnotatedType, TAtscriptDataType, TAtscriptTypeObject, TMetadataMap, TSerializedAnnotatedType, TValidatorOptions, TValidatorPlugin, Validator } from "@atscript/typescript/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/query/uniqu-select.d.ts
|
|
@@ -361,6 +361,14 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
361
361
|
get preferredId(): readonly string[];
|
|
362
362
|
/** Legitimate row-identifier shapes (primary key + every unique index). */
|
|
363
363
|
get identifications(): readonly TIdentification[];
|
|
364
|
+
/**
|
|
365
|
+
* The {@link identifications} an id may resolve through when fields are
|
|
366
|
+
* hidden per request (since 0.1.134): a unique index with a field that
|
|
367
|
+
* fails `isFieldVisible` is dropped, as if it did not exist. Primary-key,
|
|
368
|
+
* `preferredId` and `@meta.id` fields always count as visible. Without a
|
|
369
|
+
* predicate, every identification.
|
|
370
|
+
*/
|
|
371
|
+
identificationsVisibleTo(isFieldVisible?: TIdResolveOptions["isFieldVisible"]): readonly TIdentification[];
|
|
364
372
|
/**
|
|
365
373
|
* Physical column name of the single `@meta.id` field, or `null` when the
|
|
366
374
|
* schema has zero or multiple `@meta.id` fields. Used by adapters to return
|
|
@@ -414,6 +422,19 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
414
422
|
* Pre-computed field metadata for adapter use.
|
|
415
423
|
*/
|
|
416
424
|
get fieldDescriptors(): readonly TDbFieldMeta[];
|
|
425
|
+
/**
|
|
426
|
+
* The target table of the navigation relation `navField` (since 0.1.134),
|
|
427
|
+
* resolved through the table resolver this readable was built with (the
|
|
428
|
+
* `DbSpace`'s). `undefined` when `navField` is not a relation of this table
|
|
429
|
+
* or no resolver is available (a table constructed without a `DbSpace`).
|
|
430
|
+
* Top-level relation names only — no dotted paths.
|
|
431
|
+
*
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const users = posts.relatedTable('author')
|
|
434
|
+
* users?.primaryKeys // ['id']
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
relatedTable(navField: string): ReturnType<TTableResolver>;
|
|
417
438
|
/**
|
|
418
439
|
* Resolves whether `path` references a real field — directly via `flatMap`
|
|
419
440
|
* or transitively through a nav relation by recursing into the target
|
|
@@ -567,17 +588,20 @@ declare class AtscriptDbReadable<T extends TAtscriptAnnotatedType = TAtscriptAnn
|
|
|
567
588
|
* same identification resolution as {@link findById}. Public so callers can
|
|
568
589
|
* AND-combine the id-filter with a row-level read overlay before issuing
|
|
569
590
|
* `findOne` (avoiding the existence leak that `findById` would cause).
|
|
591
|
+
* `opts.isFieldVisible` (since 0.1.134) drops unique indexes over hidden
|
|
592
|
+
* fields — see {@link identificationsVisibleTo}.
|
|
570
593
|
*/
|
|
571
|
-
resolveIdFilter(id: unknown): FilterExpr | null;
|
|
594
|
+
resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
572
595
|
/**
|
|
573
596
|
* Resolve an id value into a filter expression.
|
|
574
597
|
*
|
|
575
598
|
* When `preferredId` differs from the PK, scalar ids resolve only against
|
|
576
599
|
* the preferred field (deterministic addressing). Otherwise scalars try PK
|
|
577
600
|
* + every single-field unique index; objects try PK + compound unique
|
|
578
|
-
* indexes.
|
|
601
|
+
* indexes. With `opts.isFieldVisible`, only the identifications
|
|
602
|
+
* {@link identificationsVisibleTo} keeps are tried.
|
|
579
603
|
*/
|
|
580
|
-
protected _resolveIdFilter(id: unknown): FilterExpr | null;
|
|
604
|
+
protected _resolveIdFilter(id: unknown, opts?: TIdResolveOptions): FilterExpr | null;
|
|
581
605
|
/** Build a single-key filter from `idObj` over `fields`, or null if any field is missing/incompatible. */
|
|
582
606
|
private _tryCompoundFilter;
|
|
583
607
|
/**
|
|
@@ -1391,6 +1415,7 @@ declare class TableMetadata {
|
|
|
1391
1415
|
physicalNames: ReadonlySet<string>;
|
|
1392
1416
|
private _built;
|
|
1393
1417
|
private _identifications?;
|
|
1418
|
+
private _alwaysAddressable?;
|
|
1394
1419
|
private _collateMap;
|
|
1395
1420
|
private _columnFromMap;
|
|
1396
1421
|
constructor(nestedObjects: boolean);
|
|
@@ -1487,6 +1512,12 @@ declare class TableMetadata {
|
|
|
1487
1512
|
private _buildIdentifications;
|
|
1488
1513
|
/** Legitimate row-identifier shapes — primary key first, then each unique index. */
|
|
1489
1514
|
getIdentifications(): readonly TIdentification[];
|
|
1515
|
+
/**
|
|
1516
|
+
* Fields that always count as visible for row identification (since
|
|
1517
|
+
* 0.1.134): primary key, `preferredId` and `@meta.id` fields — see
|
|
1518
|
+
* `AtscriptDbReadable.identificationsVisibleTo`.
|
|
1519
|
+
*/
|
|
1520
|
+
getAlwaysAddressable(): ReadonlySet<string>;
|
|
1490
1521
|
private _resolvePreferredId;
|
|
1491
1522
|
}
|
|
1492
1523
|
//#endregion
|
|
@@ -2114,8 +2145,13 @@ interface TTouchManyOptions {
|
|
|
2114
2145
|
*/
|
|
2115
2146
|
require?: "all" | "any";
|
|
2116
2147
|
}
|
|
2117
|
-
/**
|
|
2118
|
-
|
|
2148
|
+
/**
|
|
2149
|
+
* Options of `insertOne/Many`, `replaceOne` / `bulkReplace`, `updateOne` / `bulkUpdate`.
|
|
2150
|
+
* `isFieldVisible` (since 0.1.134, see {@link TIdResolveOptions}) applies to the
|
|
2151
|
+
* top-level rows only — a payload without its primary key identifies through
|
|
2152
|
+
* a unique index; nested-relation writes ignore it.
|
|
2153
|
+
*/
|
|
2154
|
+
interface TWriteOptions<Row = Record<string, unknown>> extends TIdResolveOptions {
|
|
2119
2155
|
/** Nested-relation write recursion limit (default 3). */
|
|
2120
2156
|
maxDepth?: number;
|
|
2121
2157
|
/**
|
|
@@ -2128,8 +2164,8 @@ interface TWriteOptions<Row = Record<string, unknown>> {
|
|
|
2128
2164
|
*/
|
|
2129
2165
|
guard?: TDbWriteGuard<Row>;
|
|
2130
2166
|
}
|
|
2131
|
-
/** Options of `deleteOne`. */
|
|
2132
|
-
interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
2167
|
+
/** Options of `deleteOne`. `isFieldVisible` since 0.1.134 — see {@link TIdResolveOptions}. */
|
|
2168
|
+
interface TDeleteOptions<Row = Record<string, unknown>> extends TIdResolveOptions {
|
|
2133
2169
|
/**
|
|
2134
2170
|
* Validated-stage guard (since 0.1.128): invoked inside the table's
|
|
2135
2171
|
* transaction after the id resolved to a filter and before cascade /
|
|
@@ -2137,6 +2173,17 @@ interface TDeleteOptions<Row = Record<string, unknown>> {
|
|
|
2137
2173
|
*/
|
|
2138
2174
|
guard?: TDbRemoveGuard<Row>;
|
|
2139
2175
|
}
|
|
2176
|
+
/** Options of `resolveIdFilter` / `identificationsVisibleTo` (since 0.1.134). */
|
|
2177
|
+
interface TIdResolveOptions {
|
|
2178
|
+
/**
|
|
2179
|
+
* Field-visibility predicate (e.g. a per-request read scope). A unique-index
|
|
2180
|
+
* identification with a field that fails it is ignored — the id resolves
|
|
2181
|
+
* exactly as if that index did not exist, so a hidden unique key can never
|
|
2182
|
+
* answer "a row with this value exists". Primary-key, `preferredId` and
|
|
2183
|
+
* `@meta.id` fields always count as visible.
|
|
2184
|
+
*/
|
|
2185
|
+
isFieldVisible?: (path: string) => boolean;
|
|
2186
|
+
}
|
|
2140
2187
|
/**
|
|
2141
2188
|
* Adds `null` to every optional property of `O`. Optional columns store SQL
|
|
2142
2189
|
* NULL / Mongo null, and the runtime validator accepts `null` for optional
|
|
@@ -2176,7 +2223,8 @@ interface TBucketFieldSource {
|
|
|
2176
2223
|
* appear in $groupBy", string `$groupBy` entries) with the table's names as
|
|
2177
2224
|
* the collision set: a bucket alias may not equal a logical path, a physical
|
|
2178
2225
|
* column or a navigation field, so a label is never reverse-mapped as a
|
|
2179
|
-
* column.
|
|
2226
|
+
* column. Aggregate entries are checked against `SUPPORTED_AGGREGATE_FNS`
|
|
2227
|
+
* (and `'*'` is `count`'s only).
|
|
2180
2228
|
*
|
|
2181
2229
|
* Which layer validates what:
|
|
2182
2230
|
* - **Shapes** (this normalizer) run FIRST at every entry point — the core's
|
|
@@ -2227,4 +2275,4 @@ declare function isJsonValueField(fd: TDbFieldMeta): boolean;
|
|
|
2227
2275
|
*/
|
|
2228
2276
|
declare function jsonValueAncestor(path: string, jsonValueParents: ReadonlySet<string>): string | undefined;
|
|
2229
2277
|
//#endregion
|
|
2230
|
-
export { TDbWriteGuardContext as $, TDbActionIntent as A,
|
|
2278
|
+
export { TDbWriteGuardContext as $, TDbActionIntent as A, isGeoIndexableType as At, TDbIndexField as B, FieldMappingStrategy as Bt, PrimaryKeyOf$1 as C, TWriteTableResolver as Ct, TCrudOp as D, WithRelation$1 as Dt, TColumnDiff as E, UniqueryControls$1 as Et, TDbDefaultValue as F, DbResponse as Ft, TDbReferentialAction as G, TDbInsertManyResult as H, TGenericLogger as Ht, TDbDeleteResult as I, resolveDesignType as It, TDbRemoveGuardContext as J, TDbRelation as K, TDbFieldMeta as L, DbEncryption as Lt, TDbActionProcessor as M, ALL_BUCKET_UNITS as Mt, TDbCollation as N, BaseDbAdapter as Nt, TCrudPermissions as O, TableMetadata as Ot, TDbDefaultFn as P, AtscriptDbReadable as Pt, TDbWriteGuard as Q, TDbForeignKey as R, TDbEncryptionOptions as Rt, OwnPropsOf$1 as S, TWriteOptions as St, TCascadeTarget as T, Uniquery$1 as Tt, TDbInsertResult as U, UniquSelect as Ut, TDbIndexType as V, NoopLogger as Vt, TDbObjectKind as W, TDbUpdateResult as X, TDbStorageType as Y, TDbWriteAction as Z, FieldOpsFor as _, TSyncColumnResult as _t, jsonValueAncestor as a, TFieldMeta as at, NavPropsOf$1 as b, TTouchManyOptions as bt, AggregateExpr$1 as c, TIdDescriptor as ct, AggregateResult as d, TMetaResponse as dt, TDeleteOptions as et, AtscriptDbWritable as f, TMetadataOverrides as ft, DbRow as g, TSearchIndexInfo as gt, DbQuery as h, TRelationInfo as ht, isJsonValueField as i, TExistingTableOption as it, TDbActionLevel as j, isGeoPointType as jt, TDbActionInfo as k, findAncestorInSet as kt, AggregateFn$1 as l, TIdResolveOptions as lt, DbPatch as m, TReferencingForeignKey as mt, TResolvedBucket as n, TExistingColumn as nt, resolveCalendarBuckets as o, TFkLookupResolver as ot, DbControls as p, TPrimaryKeyChange as pt, TDbRemoveGuard as q, isBucketableField as r, TExistingForeignKey as rt, AggregateControls as s, TFkLookupTarget as st, TBucketFieldSource as t, TEnsureTableOptions as tt, AggregateQuery$1 as u, TIdentification as ut, FilterExpr$1 as v, TTableOptionDiff as vt, TCascadeResolver as w, TypedWithRelation as wt, NullableOptional as x, TValueFormatterPair as xt, FlatOf$1 as y, TTableResolver as yt, TDbIndex as z, DocumentFieldMapper as zt };
|