@atscript/db 0.1.129 → 0.1.130
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.cjs +31 -0
- package/dist/agg.d.cts +30 -1
- package/dist/agg.d.mts +30 -1
- package/dist/agg.mjs +31 -1
- package/dist/{db-view-Dl0aDTiT.mjs → db-view-BkF2xEGd.mjs} +7 -4
- package/dist/{db-view-CRBgkEp0.cjs → db-view-hkwQ-fHJ.cjs} +7 -4
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/sync.cjs +1 -1
- package/dist/sync.mjs +1 -1
- package/package.json +1 -1
package/dist/agg.cjs
CHANGED
|
@@ -4,5 +4,36 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
function resolveAlias(expr) {
|
|
5
5
|
return expr.$as ?? `${expr.$fn}_${expr.$field}`;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
9
|
+
*
|
|
10
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
11
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
12
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
13
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
14
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
15
|
+
*
|
|
16
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
17
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
18
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
19
|
+
* Grouped results order by `$sort` or not at all.
|
|
20
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
21
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
22
|
+
*
|
|
23
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
24
|
+
* straight through to the plain grouped path.
|
|
25
|
+
*/
|
|
26
|
+
function resolveAggregateSearch(controls) {
|
|
27
|
+
const raw = controls?.$search;
|
|
28
|
+
if (typeof raw !== "string") return;
|
|
29
|
+
const text = raw.trim();
|
|
30
|
+
if (!text) return;
|
|
31
|
+
const index = controls?.$index;
|
|
32
|
+
return {
|
|
33
|
+
text,
|
|
34
|
+
indexName: typeof index === "string" && index ? index : void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
7
37
|
//#endregion
|
|
38
|
+
exports.resolveAggregateSearch = resolveAggregateSearch;
|
|
8
39
|
exports.resolveAlias = resolveAlias;
|
package/dist/agg.d.cts
CHANGED
|
@@ -3,5 +3,34 @@ import { AggregateControls, AggregateExpr, AggregateExpr as AggregateExpr$1, Agg
|
|
|
3
3
|
//#region src/agg.d.ts
|
|
4
4
|
/** Resolves output alias: $as if provided, otherwise `{fn}_{field}`. */
|
|
5
5
|
declare function resolveAlias(expr: AggregateExpr$1): string;
|
|
6
|
+
/** The text-search request a grouped query carries, once normalised. */
|
|
7
|
+
interface TAggregateSearch {
|
|
8
|
+
/** Non-empty, trimmed search term. */
|
|
9
|
+
text: string;
|
|
10
|
+
/** Named search index to target, when the caller picked one. */
|
|
11
|
+
indexName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
15
|
+
*
|
|
16
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
17
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
18
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
19
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
20
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
21
|
+
*
|
|
22
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
23
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
24
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
25
|
+
* Grouped results order by `$sort` or not at all.
|
|
26
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
27
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
28
|
+
*
|
|
29
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
30
|
+
* straight through to the plain grouped path.
|
|
31
|
+
*/
|
|
32
|
+
declare function resolveAggregateSearch(controls: {
|
|
33
|
+
[key: `$${string}`]: unknown;
|
|
34
|
+
} | undefined): TAggregateSearch | undefined;
|
|
6
35
|
//#endregion
|
|
7
|
-
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, resolveAlias };
|
|
36
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, resolveAggregateSearch, resolveAlias };
|
package/dist/agg.d.mts
CHANGED
|
@@ -3,5 +3,34 @@ import { AggregateControls, AggregateExpr, AggregateExpr as AggregateExpr$1, Agg
|
|
|
3
3
|
//#region src/agg.d.ts
|
|
4
4
|
/** Resolves output alias: $as if provided, otherwise `{fn}_{field}`. */
|
|
5
5
|
declare function resolveAlias(expr: AggregateExpr$1): string;
|
|
6
|
+
/** The text-search request a grouped query carries, once normalised. */
|
|
7
|
+
interface TAggregateSearch {
|
|
8
|
+
/** Non-empty, trimmed search term. */
|
|
9
|
+
text: string;
|
|
10
|
+
/** Named search index to target, when the caller picked one. */
|
|
11
|
+
indexName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
15
|
+
*
|
|
16
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
17
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
18
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
19
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
20
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
21
|
+
*
|
|
22
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
23
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
24
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
25
|
+
* Grouped results order by `$sort` or not at all.
|
|
26
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
27
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
28
|
+
*
|
|
29
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
30
|
+
* straight through to the plain grouped path.
|
|
31
|
+
*/
|
|
32
|
+
declare function resolveAggregateSearch(controls: {
|
|
33
|
+
[key: `$${string}`]: unknown;
|
|
34
|
+
} | undefined): TAggregateSearch | undefined;
|
|
6
35
|
//#endregion
|
|
7
|
-
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, resolveAlias };
|
|
36
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, resolveAggregateSearch, resolveAlias };
|
package/dist/agg.mjs
CHANGED
|
@@ -3,5 +3,35 @@
|
|
|
3
3
|
function resolveAlias(expr) {
|
|
4
4
|
return expr.$as ?? `${expr.$fn}_${expr.$field}`;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads the `$search` / `$index` controls of an aggregate query.
|
|
8
|
+
*
|
|
9
|
+
* Search and grouping are orthogonal: `$search` narrows the ROWS, `$groupBy`
|
|
10
|
+
* shapes what is left. Every adapter must therefore apply the search predicate
|
|
11
|
+
* BEFORE grouping, so the groups — and `$count`, which counts them — only ever
|
|
12
|
+
* describe rows that matched. An adapter that silently ignored the term would
|
|
13
|
+
* report totals for rows the same search excludes from the leaf list.
|
|
14
|
+
*
|
|
15
|
+
* Two rules the leaf search path applies and the grouped path must NOT:
|
|
16
|
+
* - **No implicit relevance ordering.** Relevance is a property of a row, not
|
|
17
|
+
* of a group; after `$group` there is no per-row score left to sort on.
|
|
18
|
+
* Grouped results order by `$sort` or not at all.
|
|
19
|
+
* - **No implicit row cap.** The leaf runners cap an unbounded search at 1000
|
|
20
|
+
* rows; applying that before `$group` would silently truncate group counts.
|
|
21
|
+
*
|
|
22
|
+
* Returns `undefined` when there is nothing to search for, so callers fall
|
|
23
|
+
* straight through to the plain grouped path.
|
|
24
|
+
*/
|
|
25
|
+
function resolveAggregateSearch(controls) {
|
|
26
|
+
const raw = controls?.$search;
|
|
27
|
+
if (typeof raw !== "string") return;
|
|
28
|
+
const text = raw.trim();
|
|
29
|
+
if (!text) return;
|
|
30
|
+
const index = controls?.$index;
|
|
31
|
+
return {
|
|
32
|
+
text,
|
|
33
|
+
indexName: typeof index === "string" && index ? index : void 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
6
36
|
//#endregion
|
|
7
|
-
export { resolveAlias };
|
|
37
|
+
export { resolveAggregateSearch, resolveAlias };
|
|
@@ -1027,13 +1027,11 @@ var RelationalFieldMapper = class extends FieldMappingStrategy {
|
|
|
1027
1027
|
return {
|
|
1028
1028
|
filter,
|
|
1029
1029
|
controls: {
|
|
1030
|
+
...controls,
|
|
1030
1031
|
$groupBy: groupBy,
|
|
1031
1032
|
$select: select ? new UniquSelect(select, meta.allPhysicalFields) : void 0,
|
|
1032
1033
|
$sort: sort,
|
|
1033
|
-
$having: having
|
|
1034
|
-
$skip: controls.$skip,
|
|
1035
|
-
$limit: controls.$limit,
|
|
1036
|
-
$count: controls.$count
|
|
1034
|
+
$having: having
|
|
1037
1035
|
},
|
|
1038
1036
|
insights: query.insights
|
|
1039
1037
|
};
|
|
@@ -2047,6 +2045,11 @@ var AtscriptDbReadable = class {
|
|
|
2047
2045
|
}]);
|
|
2048
2046
|
}
|
|
2049
2047
|
}
|
|
2048
|
+
const searchTerm = query.controls.$search;
|
|
2049
|
+
if (typeof searchTerm === "string" && searchTerm) {
|
|
2050
|
+
this._ensureSearchable();
|
|
2051
|
+
if (!searchTerm.trim()) return query.controls.$count ? [{ count: 0 }] : [];
|
|
2052
|
+
}
|
|
2050
2053
|
guardAggregate(this._meta, this.adapter, query);
|
|
2051
2054
|
const dbQuery = this._fieldMapper.translateAggregateQuery(query, this._meta);
|
|
2052
2055
|
return (await this.adapter.aggregate(dbQuery)).map((row) => this._fieldMapper.reconstructFromRead(row, this._meta));
|
|
@@ -1027,13 +1027,11 @@ var RelationalFieldMapper = class extends FieldMappingStrategy {
|
|
|
1027
1027
|
return {
|
|
1028
1028
|
filter,
|
|
1029
1029
|
controls: {
|
|
1030
|
+
...controls,
|
|
1030
1031
|
$groupBy: groupBy,
|
|
1031
1032
|
$select: select ? new UniquSelect(select, meta.allPhysicalFields) : void 0,
|
|
1032
1033
|
$sort: sort,
|
|
1033
|
-
$having: having
|
|
1034
|
-
$skip: controls.$skip,
|
|
1035
|
-
$limit: controls.$limit,
|
|
1036
|
-
$count: controls.$count
|
|
1034
|
+
$having: having
|
|
1037
1035
|
},
|
|
1038
1036
|
insights: query.insights
|
|
1039
1037
|
};
|
|
@@ -2047,6 +2045,11 @@ var AtscriptDbReadable = class {
|
|
|
2047
2045
|
}]);
|
|
2048
2046
|
}
|
|
2049
2047
|
}
|
|
2048
|
+
const searchTerm = query.controls.$search;
|
|
2049
|
+
if (typeof searchTerm === "string" && searchTerm) {
|
|
2050
|
+
this._ensureSearchable();
|
|
2051
|
+
if (!searchTerm.trim()) return query.controls.$count ? [{ count: 0 }] : [];
|
|
2052
|
+
}
|
|
2050
2053
|
guardAggregate(this._meta, this.adapter, query);
|
|
2051
2054
|
const dbQuery = this._fieldMapper.translateAggregateQuery(query, this._meta);
|
|
2052
2055
|
return (await this.adapter.aggregate(dbQuery)).map((row) => this._fieldMapper.reconstructFromRead(row, this._meta));
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_db_error = require("./db-error-C4JuLcvb.cjs");
|
|
3
|
-
const require_db_view = require("./db-view-
|
|
3
|
+
const require_db_view = require("./db-view-hkwQ-fHJ.cjs");
|
|
4
4
|
const require_validator = require("./validator-lkCJKuoo.cjs");
|
|
5
5
|
const require_consts = require("./consts-BzRfCcH2.cjs");
|
|
6
6
|
const require_ops = require("./ops.cjs");
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as CasMismatchError, r as DbError, t as CasExhaustedError } from "./db-error-COrO58t5.mjs";
|
|
2
|
-
import { A as isGeoIndexableType, C as unsupportedOperatorMessage, D as UniquSelect, E as FieldMappingStrategy, M as NoopLogger, O as TableMetadata, S as sortFieldNames, T as DocumentFieldMapper, _ as guardAggregate, a as decomposePatch, b as guardPaths, c as createFailureCollector, d as AtscriptDbReadable, f as resolveDesignType, g as collectQueryPaths, h as classifyQueryPath, i as assertNoVersionWrites, j as isGeoPointType, k as findAncestorInSet, l as IntegrityStrategy, m as checkHavingKeys, n as isAtscriptDbView, o as ApplicationIntegrity, p as assertGeoPoint, r as AtscriptDbTable, s as BaseDbAdapter, t as AtscriptDbView, u as NativeIntegrity, v as guardFilter, w as RelationalFieldMapper, x as guardQuery, y as guardPath } from "./db-view-
|
|
2
|
+
import { A as isGeoIndexableType, C as unsupportedOperatorMessage, D as UniquSelect, E as FieldMappingStrategy, M as NoopLogger, O as TableMetadata, S as sortFieldNames, T as DocumentFieldMapper, _ as guardAggregate, a as decomposePatch, b as guardPaths, c as createFailureCollector, d as AtscriptDbReadable, f as resolveDesignType, g as collectQueryPaths, h as classifyQueryPath, i as assertNoVersionWrites, j as isGeoPointType, k as findAncestorInSet, l as IntegrityStrategy, m as checkHavingKeys, n as isAtscriptDbView, o as ApplicationIntegrity, p as assertGeoPoint, r as AtscriptDbTable, s as BaseDbAdapter, t as AtscriptDbView, u as NativeIntegrity, v as guardFilter, w as RelationalFieldMapper, x as guardQuery, y as guardPath } from "./db-view-BkF2xEGd.mjs";
|
|
3
3
|
import { a as forceNavNonOptional, c as getKeyProps, l as isEmptyObject, o as isNavRelation, r as buildValidationContext, s as createDbValidatorPlugin, t as buildDbValidator, u as isPlainObject } from "./validator-CeD_fqyW.mjs";
|
|
4
4
|
import { t as DEFAULT_DB_SPACE } from "./consts-C_-5_pFq.mjs";
|
|
5
5
|
import { $cas, $dec, $inc, $insert, $mul, $remove, $replace, $update, $upsert, getDbFieldOp, isDbFieldOp, reconcileCas, separateCas, separateFieldOps } from "./ops.mjs";
|
package/dist/sync.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_db_view = require("./db-view-
|
|
2
|
+
const require_db_view = require("./db-view-hkwQ-fHJ.cjs");
|
|
3
3
|
//#region src/schema/schema-hash.ts
|
|
4
4
|
/** Extracts sorted field snapshots from a readable's field descriptors. */
|
|
5
5
|
function extractFieldSnapshots(fields, typeMapper) {
|
package/dist/sync.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as NoopLogger } from "./db-view-
|
|
1
|
+
import { M as NoopLogger } from "./db-view-BkF2xEGd.mjs";
|
|
2
2
|
//#region src/schema/schema-hash.ts
|
|
3
3
|
/** Extracts sorted field snapshots from a readable's field descriptors. */
|
|
4
4
|
function extractFieldSnapshots(fields, typeMapper) {
|