@atscript/db 0.1.147 → 0.1.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{agg-CV7y8nC6.d.cts → agg-42CSpGDR.d.cts} +2 -2
  2. package/dist/{agg-D5DHsAby.d.mts → agg-Wo-smrYV.d.mts} +3 -3
  3. package/dist/agg.cjs +1 -1
  4. package/dist/agg.d.cts +2 -2
  5. package/dist/agg.d.mts +2 -2
  6. package/dist/agg.mjs +1 -1
  7. package/dist/{aggregate-fns-CtsRbZn9.cjs → aggregate-fns-C-UJRobm.cjs} +46 -7
  8. package/dist/{aggregate-fns-C0BymEqa.mjs → aggregate-fns-CyaZyb9I.mjs} +35 -8
  9. package/dist/aggregate-rules-D_bsCpUI.cjs +26 -0
  10. package/dist/aggregate-rules-jdPrxqWa.mjs +15 -0
  11. package/dist/{buckets-DYopfd2Y.d.mts → buckets-CNdTOnei.d.mts} +312 -18
  12. package/dist/{buckets-CjdPipCC.d.cts → buckets-DJiYlMXc.d.cts} +312 -18
  13. package/dist/{column-diff-Dt7EDJsA.cjs → column-diff-CUU4GvYg.cjs} +681 -87
  14. package/dist/{column-diff-CO06iQvI.mjs → column-diff-Cp6ZoyRE.mjs} +678 -96
  15. package/dist/{db-error-D5uilS_A.mjs → db-error-Az85UhTX.mjs} +32 -1
  16. package/dist/{db-error-DTkkeu5b.cjs → db-error-DRQH4sLY.cjs} +55 -0
  17. package/dist/{fk-diff-BtOmL4OW.d.mts → fk-diff-BQ4krij8.d.cts} +1 -1
  18. package/dist/{fk-diff-DLqwVkKG.d.cts → fk-diff-DsaIijVX.d.mts} +1 -1
  19. package/dist/index.cjs +70 -5
  20. package/dist/index.d.cts +58 -13
  21. package/dist/index.d.mts +58 -13
  22. package/dist/index.mjs +64 -6
  23. package/dist/{nested-writer-SqtYJHF0.cjs → nested-writer-BUQvk6QT.cjs} +68 -2
  24. package/dist/{nested-writer-D35UsDBT.mjs → nested-writer-CUBoq1ZO.mjs} +57 -3
  25. package/dist/numeric-operand-B1jKH7x5.mjs +21 -0
  26. package/dist/numeric-operand-DKfiRLYp.cjs +26 -0
  27. package/dist/ops.cjs +1 -1
  28. package/dist/ops.mjs +1 -1
  29. package/dist/plugin.cjs +36 -9
  30. package/dist/plugin.mjs +36 -9
  31. package/dist/rel.cjs +2 -2
  32. package/dist/rel.d.cts +2 -2
  33. package/dist/rel.d.mts +2 -2
  34. package/dist/rel.mjs +2 -2
  35. package/dist/{relation-helpers-C2bLtE-t.d.mts → relation-helpers-Ba0v49sn.d.mts} +1 -1
  36. package/dist/{relation-helpers-DH3LvwLV.d.cts → relation-helpers-kX7jjgME.d.cts} +1 -1
  37. package/dist/{relation-loader-C0qE8xgR.mjs → relation-loader-ByY1Byrl.mjs} +1 -1
  38. package/dist/{relation-loader-BFhVuJ-B.cjs → relation-loader-D8OrdH-r.cjs} +1 -1
  39. package/dist/shared.cjs +3 -0
  40. package/dist/shared.d.cts +12 -1
  41. package/dist/shared.d.mts +12 -1
  42. package/dist/shared.mjs +2 -1
  43. package/dist/sync.cjs +2 -2
  44. package/dist/sync.d.cts +2 -2
  45. package/dist/sync.d.mts +2 -2
  46. package/dist/sync.mjs +2 -2
  47. package/dist/{validator-Clu2q_7z.mjs → validator-BTiIOTKP.mjs} +9 -3
  48. package/dist/{validator-CVS-onRg.cjs → validator-UcuJxHNT.cjs} +8 -2
  49. package/dist/{validator-CMnTI6r7.d.cts → validator-tBNvM1qc.d.cts} +23 -2
  50. package/dist/{validator-CMnTI6r7.d.mts → validator-tBNvM1qc.d.mts} +23 -2
  51. package/dist/validator.cjs +2 -2
  52. package/dist/validator.d.cts +1 -1
  53. package/dist/validator.d.mts +1 -1
  54. package/dist/validator.mjs +2 -2
  55. package/package.json +8 -8
@@ -1,4 +1,4 @@
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";
1
+ import { AggregateControls, AggregateExpr, 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
2
 
3
3
  //#region src/query/aggregate-fns.d.ts
4
4
  /**
@@ -8,7 +8,7 @@ import { AggregateControls, AggregateExpr as AggregateExpr$1, AggregateFn, Aggre
8
8
  type TDbAggregateFn = AggregateFn;
9
9
  /**
10
10
  * Every aggregate function — what an adapter that renders them all returns
11
- * from `aggregateFns()`.
11
+ * from `aggregateFns()` (`first` / `last` since 0.1.148).
12
12
  *
13
13
  * @since 0.1.136
14
14
  */
@@ -1,4 +1,4 @@
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";
1
+ import { AggregateControls, AggregateExpr, 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 as resolveAlias$1 } from "@uniqu/core";
2
2
 
3
3
  //#region src/query/aggregate-fns.d.ts
4
4
  /**
@@ -8,7 +8,7 @@ import { AggregateControls, AggregateExpr as AggregateExpr$1, AggregateFn, Aggre
8
8
  type TDbAggregateFn = AggregateFn;
9
9
  /**
10
10
  * Every aggregate function — what an adapter that renders them all returns
11
- * from `aggregateFns()`.
11
+ * from `aggregateFns()` (`first` / `last` since 0.1.148).
12
12
  *
13
13
  * @since 0.1.136
14
14
  */
@@ -50,4 +50,4 @@ declare function resolveAggregateSearch(controls: {
50
50
  [key: `$${string}`]: unknown;
51
51
  } | undefined): TAggregateSearch | undefined;
52
52
  //#endregion
53
- export { TDbAggregateFn as _, AggregateResult as a, CalendarBucketLabel as c, WeekStart as d, isAggregateExpr$1 as f, ALL_AGGREGATE_FNS 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, assertAggregateFn as v };
53
+ export { TDbAggregateFn as _, AggregateResult as a, CalendarBucketLabel as c, WeekStart as d, isAggregateExpr$1 as f, ALL_AGGREGATE_FNS as g, resolveAlias$1 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, assertAggregateFn as v };
package/dist/agg.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_aggregate_fns = require("./aggregate-fns-CtsRbZn9.cjs");
2
+ const require_aggregate_fns = require("./aggregate-fns-C-UJRobm.cjs");
3
3
  let _uniqu_core = require("@uniqu/core");
4
4
  //#region src/agg.ts
5
5
  /**
package/dist/agg.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { n as TResolvedBucket } from "./buckets-CjdPipCC.cjs";
2
- import { _ as TDbAggregateFn, a as AggregateResult, c as CalendarBucketLabel, d as WeekStart, f as isAggregateExpr, 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, v as assertAggregateFn } from "./agg-CV7y8nC6.cjs";
1
+ import { r as TResolvedBucket } from "./buckets-DJiYlMXc.cjs";
2
+ import { _ as TDbAggregateFn, a as AggregateResult, c as CalendarBucketLabel, d as WeekStart, f as isAggregateExpr, 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, v as assertAggregateFn } from "./agg-42CSpGDR.cjs";
3
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,3 +1,3 @@
1
- import { n as TResolvedBucket } from "./buckets-DYopfd2Y.mjs";
2
- import { _ as TDbAggregateFn, a as AggregateResult, c as CalendarBucketLabel, d as WeekStart, f as isAggregateExpr, 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, v as assertAggregateFn } from "./agg-D5DHsAby.mjs";
1
+ import { r as TResolvedBucket } from "./buckets-CNdTOnei.mjs";
2
+ import { _ as TDbAggregateFn, a as AggregateResult, c as CalendarBucketLabel, d as WeekStart, f as isAggregateExpr, 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, v as assertAggregateFn } from "./agg-Wo-smrYV.mjs";
3
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,4 +1,4 @@
1
- import { o as assertAggregateFn } from "./aggregate-fns-C0BymEqa.mjs";
1
+ import { s as assertAggregateFn } from "./aggregate-fns-CyaZyb9I.mjs";
2
2
  import { isAggregateExpr, isBucketExpr, resolveAlias } from "@uniqu/core";
3
3
  //#region src/agg.ts
4
4
  /**
@@ -1,4 +1,5 @@
1
- const require_db_error = require("./db-error-DTkkeu5b.cjs");
1
+ const require_db_error = require("./db-error-DRQH4sLY.cjs");
2
+ let _uniqu_core = require("@uniqu/core");
2
3
  //#region src/query/aggregate-fns.ts
3
4
  /**
4
5
  * The only `$fn` names a `$select` aggregate may use. Any other name is rejected with
@@ -13,8 +14,25 @@ const SUPPORTED_AGGREGATE_FNS = [
13
14
  "avg",
14
15
  "min",
15
16
  "max",
16
- "countDistinct"
17
+ "countDistinct",
18
+ "first",
19
+ "last"
17
20
  ];
21
+ /** Whether a `$select` entry is a `first` / `last` aggregate (uniqu's `ROW_ORDER_FNS`). */
22
+ function isFirstLast(item) {
23
+ return (0, _uniqu_core.isAggregateExpr)(item) && _uniqu_core.ROW_ORDER_FNS.includes(item.$fn);
24
+ }
25
+ /**
26
+ * The functions that return a value OF their source field (`min` / `max` /
27
+ * `first` / `last`), rather than a count or a number — their result takes the
28
+ * field's type.
29
+ */
30
+ const SOURCE_VALUE_FNS = new Set([
31
+ "min",
32
+ "max",
33
+ "first",
34
+ "last"
35
+ ]);
18
36
  /**
19
37
  * The aggregates that are NULL over no (non-null) value — every function but
20
38
  * the counts, which are 0. So a view field reading a left-joined table must be
@@ -26,11 +44,20 @@ const NULL_WHEN_EMPTY_AGGREGATE_FNS = new Set([
26
44
  "sum",
27
45
  "avg",
28
46
  "min",
29
- "max"
47
+ "max",
48
+ "first",
49
+ "last"
30
50
  ]);
31
- /** The `@db.agg.*` annotation names, one per supported aggregate function. */
32
- const AGG_ANNOTATIONS = SUPPORTED_AGGREGATE_FNS.map((fn) => `db.agg.${fn}`);
33
- /** `BaseDbAdapter.aggregateFns()` by default: every function except `countDistinct`. */
51
+ /**
52
+ * The `@db.agg.*` annotation names, one per aggregate function a managed view
53
+ * declares — every query-time function but `first` / `last` (a representative
54
+ * row needs a query's `$rowOrder`).
55
+ */
56
+ const AGG_ANNOTATIONS = SUPPORTED_AGGREGATE_FNS.filter((fn) => !_uniqu_core.ROW_ORDER_FNS.includes(fn)).map((fn) => `db.agg.${fn}`);
57
+ /**
58
+ * `BaseDbAdapter.aggregateFns()` by default: every function except
59
+ * `countDistinct`, `first` and `last`.
60
+ */
34
61
  const BASE_AGGREGATE_FNS = new Set([
35
62
  "sum",
36
63
  "count",
@@ -40,7 +67,7 @@ const BASE_AGGREGATE_FNS = new Set([
40
67
  ]);
41
68
  /**
42
69
  * Every aggregate function — what an adapter that renders them all returns
43
- * from `aggregateFns()`.
70
+ * from `aggregateFns()` (`first` / `last` since 0.1.148).
44
71
  *
45
72
  * @since 0.1.136
46
73
  */
@@ -81,6 +108,12 @@ Object.defineProperty(exports, "NULL_WHEN_EMPTY_AGGREGATE_FNS", {
81
108
  return NULL_WHEN_EMPTY_AGGREGATE_FNS;
82
109
  }
83
110
  });
111
+ Object.defineProperty(exports, "SOURCE_VALUE_FNS", {
112
+ enumerable: true,
113
+ get: function() {
114
+ return SOURCE_VALUE_FNS;
115
+ }
116
+ });
84
117
  Object.defineProperty(exports, "SUPPORTED_AGGREGATE_FNS", {
85
118
  enumerable: true,
86
119
  get: function() {
@@ -93,3 +126,9 @@ Object.defineProperty(exports, "assertAggregateFn", {
93
126
  return assertAggregateFn;
94
127
  }
95
128
  });
129
+ Object.defineProperty(exports, "isFirstLast", {
130
+ enumerable: true,
131
+ get: function() {
132
+ return isFirstLast;
133
+ }
134
+ });
@@ -1,4 +1,5 @@
1
- import { r as DbError } from "./db-error-D5uilS_A.mjs";
1
+ import { r as DbError } from "./db-error-Az85UhTX.mjs";
2
+ import { ROW_ORDER_FNS, isAggregateExpr } from "@uniqu/core";
2
3
  //#region src/query/aggregate-fns.ts
3
4
  /**
4
5
  * The only `$fn` names a `$select` aggregate may use. Any other name is rejected with
@@ -13,8 +14,25 @@ const SUPPORTED_AGGREGATE_FNS = [
13
14
  "avg",
14
15
  "min",
15
16
  "max",
16
- "countDistinct"
17
+ "countDistinct",
18
+ "first",
19
+ "last"
17
20
  ];
21
+ /** Whether a `$select` entry is a `first` / `last` aggregate (uniqu's `ROW_ORDER_FNS`). */
22
+ function isFirstLast(item) {
23
+ return isAggregateExpr(item) && ROW_ORDER_FNS.includes(item.$fn);
24
+ }
25
+ /**
26
+ * The functions that return a value OF their source field (`min` / `max` /
27
+ * `first` / `last`), rather than a count or a number — their result takes the
28
+ * field's type.
29
+ */
30
+ const SOURCE_VALUE_FNS = new Set([
31
+ "min",
32
+ "max",
33
+ "first",
34
+ "last"
35
+ ]);
18
36
  /**
19
37
  * The aggregates that are NULL over no (non-null) value — every function but
20
38
  * the counts, which are 0. So a view field reading a left-joined table must be
@@ -26,11 +44,20 @@ const NULL_WHEN_EMPTY_AGGREGATE_FNS = new Set([
26
44
  "sum",
27
45
  "avg",
28
46
  "min",
29
- "max"
47
+ "max",
48
+ "first",
49
+ "last"
30
50
  ]);
31
- /** The `@db.agg.*` annotation names, one per supported aggregate function. */
32
- const AGG_ANNOTATIONS = SUPPORTED_AGGREGATE_FNS.map((fn) => `db.agg.${fn}`);
33
- /** `BaseDbAdapter.aggregateFns()` by default: every function except `countDistinct`. */
51
+ /**
52
+ * The `@db.agg.*` annotation names, one per aggregate function a managed view
53
+ * declares — every query-time function but `first` / `last` (a representative
54
+ * row needs a query's `$rowOrder`).
55
+ */
56
+ const AGG_ANNOTATIONS = SUPPORTED_AGGREGATE_FNS.filter((fn) => !ROW_ORDER_FNS.includes(fn)).map((fn) => `db.agg.${fn}`);
57
+ /**
58
+ * `BaseDbAdapter.aggregateFns()` by default: every function except
59
+ * `countDistinct`, `first` and `last`.
60
+ */
34
61
  const BASE_AGGREGATE_FNS = new Set([
35
62
  "sum",
36
63
  "count",
@@ -40,7 +67,7 @@ const BASE_AGGREGATE_FNS = new Set([
40
67
  ]);
41
68
  /**
42
69
  * Every aggregate function — what an adapter that renders them all returns
43
- * from `aggregateFns()`.
70
+ * from `aggregateFns()` (`first` / `last` since 0.1.148).
44
71
  *
45
72
  * @since 0.1.136
46
73
  */
@@ -57,4 +84,4 @@ function assertAggregateFn(fn, path = "$select") {
57
84
  }]);
58
85
  }
59
86
  //#endregion
60
- export { SUPPORTED_AGGREGATE_FNS as a, NULL_WHEN_EMPTY_AGGREGATE_FNS as i, ALL_AGGREGATE_FNS as n, assertAggregateFn as o, BASE_AGGREGATE_FNS as r, AGG_ANNOTATIONS as t };
87
+ export { SOURCE_VALUE_FNS as a, isFirstLast as c, NULL_WHEN_EMPTY_AGGREGATE_FNS as i, ALL_AGGREGATE_FNS as n, SUPPORTED_AGGREGATE_FNS as o, BASE_AGGREGATE_FNS as r, assertAggregateFn as s, AGG_ANNOTATIONS as t };
@@ -0,0 +1,26 @@
1
+ //#region src/shared/aggregate-rules.ts
2
+ /** `reason` of a `$groupBy` / bucket rejection for a field outside a strict aggregate table's dimensions. */
3
+ const NOT_DIMENSION_REASON = "not a dimension";
4
+ /**
5
+ * Editor-time twin of the runtime `isStrictTable`: a table whose structure
6
+ * declares any `@db.column.dimension` or `@db.column.measure` is strict —
7
+ * only dimensions can be grouped by.
8
+ * @since 0.1.148
9
+ */
10
+ function isStrictAggregateStruct(struct) {
11
+ for (const prop of struct.props.values()) if (prop.countAnnotations("db.column.dimension") > 0 || prop.countAnnotations("db.column.measure") > 0) return true;
12
+ return false;
13
+ }
14
+ //#endregion
15
+ Object.defineProperty(exports, "NOT_DIMENSION_REASON", {
16
+ enumerable: true,
17
+ get: function() {
18
+ return NOT_DIMENSION_REASON;
19
+ }
20
+ });
21
+ Object.defineProperty(exports, "isStrictAggregateStruct", {
22
+ enumerable: true,
23
+ get: function() {
24
+ return isStrictAggregateStruct;
25
+ }
26
+ });
@@ -0,0 +1,15 @@
1
+ //#region src/shared/aggregate-rules.ts
2
+ /** `reason` of a `$groupBy` / bucket rejection for a field outside a strict aggregate table's dimensions. */
3
+ const NOT_DIMENSION_REASON = "not a dimension";
4
+ /**
5
+ * Editor-time twin of the runtime `isStrictTable`: a table whose structure
6
+ * declares any `@db.column.dimension` or `@db.column.measure` is strict —
7
+ * only dimensions can be grouped by.
8
+ * @since 0.1.148
9
+ */
10
+ function isStrictAggregateStruct(struct) {
11
+ for (const prop of struct.props.values()) if (prop.countAnnotations("db.column.dimension") > 0 || prop.countAnnotations("db.column.measure") > 0) return true;
12
+ return false;
13
+ }
14
+ //#endregion
15
+ export { isStrictAggregateStruct as n, NOT_DIMENSION_REASON as t };