@m6d/cortex 0.6.0 → 0.7.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 CHANGED
@@ -137,6 +137,8 @@ import { createManagementClient, ManagementClientError, type ManagementOutput }
137
137
  const cortex = createManagementClient({
138
138
  url: "https://cortex.example.com", // the console's origin
139
139
  key: process.env.CORTEX_MANAGEMENT_KEY!, // a management key, cortex_mgmt_…
140
+ locale: "ar", // optional: the language Cortex words its refusals in
141
+ timeZone: "Asia/Dubai", // optional: the zone a day range is read in, else UTC days
140
142
  });
141
143
 
142
144
  const agent: ManagementOutput<"agents.get"> = await cortex.agents.get({ id });
@@ -154,7 +156,7 @@ try {
154
156
  }
155
157
  ```
156
158
 
157
- Every procedure of [the management API](../../apps/cortex/docs/management-api.md) is a typed call, `cortex.<router>.<procedure>(input)`: a query is sent as a GET, a mutation as a POST, its input and output typed from the procedures of the Cortex release this package ships with (`ManagementInput<"…">` and `ManagementOutput<"…">` name them). A refusal throws `ManagementClientError`; a Cortex that cannot be reached rejects as `fetch` does. M6d.Cortex has the same client for .NET.
159
+ Every procedure of [the management API](../../apps/cortex/docs/management-api.md) is a typed call, `cortex.<router>.<procedure>(input)`: a query is sent as a GET, a mutation as a POST, its input and output typed from the procedures of the Cortex release this package ships with (`ManagementInput<"…">` and `ManagementOutput<"…">` name them). A refusal throws `ManagementClientError`; a Cortex that cannot be reached rejects as `fetch` does. A server acting for many users builds a client per request, with each caller's `locale` and `timeZone`. M6d.Cortex has the same client for .NET.
158
160
 
159
161
  ## Manifests
160
162
 
package/dist/drizzle.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
- CortexError,
3
- FUNCTION_SIGNATURES,
2
+ CortexError2,
4
3
  datasetColumnSchema,
5
- filterRefs,
6
4
  groupKeyName,
7
- isColumnValue
8
- } from "./index-969vtyhy.js";
5
+ filterRefs,
6
+ isColumnValue,
7
+ FUNCTION_SIGNATURES
8
+ } from "./index-j0kpmpfv.js";
9
9
 
10
10
  // src/datasets/drizzle.ts
11
11
  import {
@@ -231,7 +231,7 @@ function refuseOversized(statement) {
231
231
  let left = STATEMENT_MAX_PARTS;
232
232
  const walk = (chunk) => {
233
233
  if (--left < 0) {
234
- throw new CortexError("invalid_request", `The query writes out to more than ${STATEMENT_MAX_PARTS} parts of SQL; ask for fewer computed values or simpler ones`);
234
+ throw new CortexError2("invalid_request", `The query writes out to more than ${STATEMENT_MAX_PARTS} parts of SQL; ask for fewer computed values or simpler ones`);
235
235
  }
236
236
  for (const part of partsOf(chunk))
237
237
  walk(part);
@@ -254,7 +254,7 @@ function compile(root, options, query, user, clock) {
254
254
  const dot = ref.lastIndexOf(".");
255
255
  const table = joined.get(dot === -1 ? "" : ref.slice(0, dot));
256
256
  if (!table)
257
- throw new CortexError("unsupported", `"${ref}" is not reachable`);
257
+ throw new CortexError2("unsupported", `"${ref}" is not reachable`);
258
258
  const name = ref.slice(dot + 1);
259
259
  const column = columnOf(table, name);
260
260
  const type = table.types.get(name) ?? "string";
@@ -271,13 +271,13 @@ function compile(root, options, query, user, clock) {
271
271
  ...query.filter.map((filter) => filterSql(dialect, filter, resolve))
272
272
  ];
273
273
  const select = (fields) => {
274
- let chain2 = db.select(fields).from(root.table);
274
+ let chain = db.select(fields).from(root.table);
275
275
  for (const join of joins)
276
- chain2 = chain2.leftJoin(join.table, join.on);
277
- chain2 = chain2.where(and(...conditions));
276
+ chain = chain.leftJoin(join.table, join.on);
277
+ chain = chain.where(and(...conditions));
278
278
  if (shape.groupKeys.length)
279
- chain2 = chain2.groupBy(...shape.groupKeys);
280
- return shape.having ? chain2.having(shape.having) : chain2;
279
+ chain = chain.groupBy(...shape.groupKeys);
280
+ return shape.having ? chain.having(shape.having) : chain;
281
281
  };
282
282
  const { chain, target } = query.rank || query.qualify.length ? finished(dialect, db, select, shape, query) : { chain: select(shape.fields), target: (name) => sortTarget(shape, name) };
283
283
  const orderings = query.sort.map(({ col, dir }) => ordering(dialect, target(col), dir));
@@ -364,7 +364,7 @@ function joinRelations(root, join, user, db) {
364
364
  const name = path.slice(dot + 1);
365
365
  const relation = parent.relations[name];
366
366
  if (!relation)
367
- throw new CortexError("unsupported", `Relation "${path}" is not declared`);
367
+ throw new CortexError2("unsupported", `Relation "${path}" is not declared`);
368
368
  const { table: target, columns: targetColumns } = sourceOf(relation.dataset, `j${index}`);
369
369
  if (relation.through) {
370
370
  const { table: link, columns: linkColumns } = sourceOf(relation.through.dataset, `l${index}`);
@@ -441,8 +441,8 @@ function prefixes(path) {
441
441
  const segments = path.split(".");
442
442
  return segments.map((_, index) => segments.slice(0, index + 1).join("."));
443
443
  }
444
- function aliasColumns(columns, aliased2) {
445
- const aliasedColumns = getTableColumns(aliased2);
444
+ function aliasColumns(columns, aliased) {
445
+ const aliasedColumns = getTableColumns(aliased);
446
446
  return new Map([...columns.keys()].map((name) => [name, aliasedColumns[name]]));
447
447
  }
448
448
  function columnOf(table, name) {
@@ -451,7 +451,7 @@ function columnOf(table, name) {
451
451
  function columnIn(columns, name) {
452
452
  const column = columns.get(name);
453
453
  if (!column)
454
- throw new CortexError("unsupported", `Column "${name}" is not exposed`);
454
+ throw new CortexError2("unsupported", `Column "${name}" is not exposed`);
455
455
  return column;
456
456
  }
457
457
  var FLOAT = { postgres: "double precision", mssql: "float", sqlite: "real" };
@@ -528,12 +528,12 @@ function meeting(parts) {
528
528
  const dates = parts.filter((part) => part.type === "date");
529
529
  const clock = dates.find((part) => part.clock !== undefined)?.clock;
530
530
  if (clock !== undefined && dates.some((part) => part.clock === undefined)) {
531
- throw new CortexError("unsupported", "an instant cannot meet a calendar or truncated date; compare or combine like with like");
531
+ throw new CortexError2("unsupported", "an instant cannot meet a calendar or truncated date; compare or combine like with like");
532
532
  }
533
533
  const kept = dates.flatMap((part) => part.stored ? [part.stored] : []);
534
534
  const [stored] = kept;
535
535
  if (stored && kept.some((other) => storageOf(other) !== storageOf(stored))) {
536
- throw new CortexError("unsupported", "dates kept differently (in seconds and in milliseconds, say) cannot meet; compare or combine like with like");
536
+ throw new CortexError2("unsupported", "dates kept differently (in seconds and in milliseconds, say) cannot meet; compare or combine like with like");
537
537
  }
538
538
  return { stored, clock };
539
539
  }
@@ -587,7 +587,7 @@ function aggregateOf(dialect, aggregate, resolve, over) {
587
587
  };
588
588
  case "countDistinct":
589
589
  if (over) {
590
- throw new CortexError("unsupported", `window "${aggregate.as}": countDistinct cannot be a window; SQL allows no DISTINCT in OVER`);
590
+ throw new CortexError2("unsupported", `window "${aggregate.as}": countDistinct cannot be a window; SQL allows no DISTINCT in OVER`);
591
591
  }
592
592
  return { expression: countDistinct(filtered), type: "number" };
593
593
  case "sum":
@@ -611,7 +611,7 @@ function instantOf(text, clock) {
611
611
  const iso = text.replace(/^(\d{4}-\d\d-\d\d)[t ](?=\d)/, "$1T");
612
612
  const instant = OWN_OFFSET.test(iso) ? new Date(iso) : new Date(new Date(iso.includes("T") ? `${iso}Z` : iso).getTime() - clock * 60000);
613
613
  if (!/^[+-]?\d{4}/.test(iso) || Number.isNaN(instant.getTime())) {
614
- throw new CortexError("invalid_request", `"${text}" is not a date this host can read`);
614
+ throw new CortexError2("invalid_request", `"${text}" is not a date this host can read`);
615
615
  }
616
616
  return instant;
617
617
  }
@@ -1,7 +1,3 @@
1
- // src/cortex-error.ts
2
- import { createHash } from "node:crypto";
3
- import { bodyLimit } from "hono/body-limit";
4
-
5
1
  // ../../internal/contracts/src/errors/index.ts
6
2
  import { z } from "zod";
7
3
  var BACKEND_ERROR_KINDS = [
@@ -31,34 +27,6 @@ function errorEnvelope(kind, detail) {
31
27
  };
32
28
  }
33
29
 
34
- // src/cortex-error.ts
35
- class CortexError extends Error {
36
- kind;
37
- constructor(kind, detail) {
38
- super(detail);
39
- this.kind = kind;
40
- this.name = "CortexError";
41
- }
42
- }
43
- var malformedBody = errorEnvelope("invalid_request", "Malformed request body");
44
- function envelopeOf(error) {
45
- if (error instanceof CortexError)
46
- return errorEnvelope(error.kind, error.message);
47
- if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) {
48
- return errorEnvelope("timeout", "The call did not finish in time");
49
- }
50
- return errorEnvelope("internal", "The call failed");
51
- }
52
- function protocolBodyLimit(maxSize) {
53
- return bodyLimit({
54
- maxSize,
55
- onError: (c) => c.json(errorEnvelope("invalid_request", "Request body too large"), 413)
56
- });
57
- }
58
- function contentVersion(value) {
59
- return createHash("sha256").update(JSON.stringify(value)).digest("hex");
60
- }
61
-
62
30
  // ../../internal/contracts/src/json/index.ts
63
31
  function isRecord(value) {
64
32
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -94,6 +62,36 @@ function readJsonPointer(document, pointer) {
94
62
  return pointerTokens(pointer)?.reduce(pointerChild, document);
95
63
  }
96
64
 
65
+ // src/cortex-error.ts
66
+ import { createHash } from "node:crypto";
67
+ import { bodyLimit } from "hono/body-limit";
68
+ class CortexError2 extends Error {
69
+ kind;
70
+ constructor(kind, detail) {
71
+ super(detail);
72
+ this.kind = kind;
73
+ this.name = "CortexError";
74
+ }
75
+ }
76
+ var malformedBody = errorEnvelope("invalid_request", "Malformed request body");
77
+ function envelopeOf(error) {
78
+ if (error instanceof CortexError2)
79
+ return errorEnvelope(error.kind, error.message);
80
+ if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) {
81
+ return errorEnvelope("timeout", "The call did not finish in time");
82
+ }
83
+ return errorEnvelope("internal", "The call failed");
84
+ }
85
+ function protocolBodyLimit(maxSize) {
86
+ return bodyLimit({
87
+ maxSize,
88
+ onError: (c) => c.json(errorEnvelope("invalid_request", "Request body too large"), 413)
89
+ });
90
+ }
91
+ function contentVersion(value) {
92
+ return createHash("sha256").update(JSON.stringify(value)).digest("hex");
93
+ }
94
+
97
95
  // ../../internal/contracts/src/datasets/datasets.ts
98
96
  import { z as z2 } from "zod";
99
97
  var DATASET_IDENTIFIER_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]*$/;
@@ -932,8 +930,6 @@ function firstColumnOf(catalog, from, path) {
932
930
  return dataset?.columns[0]?.name ?? "";
933
931
  }
934
932
  // ../../internal/contracts/src/datasets/dataset-sql.ts
935
- class DatasetSqlError extends Error {
936
- }
937
933
  var AGGREGATE_WORDS = {
938
934
  COUNT: "count",
939
935
  SUM: "sum",
@@ -969,214 +965,6 @@ var FUNCTIONS = [
969
965
  "NOW()",
970
966
  "RANK() OVER (...)"
971
967
  ].join(", ");
972
- function datasetJoinSql(from, relation, alias) {
973
- const { through } = relation;
974
- const target = alias ?? relation.dataset;
975
- const as = alias ? ` AS ${alias}` : "";
976
- if (!through) {
977
- return `LEFT JOIN ${relation.dataset}${as} ON ${from}.${relation.on[0]} = ${target}.${relation.on[1]}`;
978
- }
979
- return [
980
- `LEFT JOIN ${through.dataset} ON ${from}.${relation.on[0]} = ${through.dataset}.${relation.on[1]}`,
981
- `LEFT JOIN ${relation.dataset}${as} ON ${through.dataset}.${through.on[0]} = ${target}.${through.on[1]}`
982
- ].join(" ");
983
- }
984
- function datasetJoinLines(definition) {
985
- const relations = Object.entries(definition.relations);
986
- const targets = relations.map(([, r]) => r.dataset);
987
- return relations.map(([name, relation]) => {
988
- const repeated = targets.filter((t) => t === relation.dataset).length > 1;
989
- return datasetJoinSql(definition.name, relation, repeated ? name : undefined);
990
- });
991
- }
992
- function unknownDataset(catalog, name) {
993
- for (const definition of catalog.values()) {
994
- for (const relation of Object.values(definition.relations)) {
995
- if (relation.through?.dataset === name) {
996
- return `"${name}" is the link table between "${definition.name}" and "${relation.dataset}"; start FROM one of those.`;
997
- }
998
- }
999
- }
1000
- return `Unknown dataset "${name}".`;
1001
- }
1002
- function isLink(entry) {
1003
- return "relation" in entry;
1004
- }
1005
- function keyOf(ref) {
1006
- const parts = ref.split(".");
1007
- if (parts.length !== 2) {
1008
- throw new DatasetSqlError(`ON needs dataset.column on both sides; "${ref}" is not that.`);
1009
- }
1010
- return parts;
1011
- }
1012
-
1013
- class Sources {
1014
- catalog;
1015
- byName = new Map;
1016
- root;
1017
- paths = [];
1018
- matched = [];
1019
- constructor(catalog, from, aliases) {
1020
- this.catalog = catalog;
1021
- const dataset = catalog.get(from);
1022
- if (!dataset)
1023
- throw new DatasetSqlError(unknownDataset(catalog, from));
1024
- this.root = { path: "", dataset };
1025
- for (const name of [from, ...aliases])
1026
- this.name(name, this.root);
1027
- }
1028
- join({ dataset, alias, left, right, inner }) {
1029
- const [leftQualifier, leftColumn] = keyOf(left);
1030
- const [rightQualifier, rightColumn] = keyOf(right);
1031
- const own = alias ?? dataset;
1032
- const isNew = (qualifier) => qualifier === own;
1033
- if (!isNew(leftQualifier) && !isNew(rightQualifier)) {
1034
- throw new DatasetSqlError(`JOIN ${dataset} ... ON must compare a column of ${own} with a column of a dataset already in the query.`);
1035
- }
1036
- const [parentQualifier, parentKey, targetKey] = isNew(rightQualifier) ? [leftQualifier, leftColumn, rightColumn] : [rightQualifier, rightColumn, leftColumn];
1037
- const parent = this.byName.get(parentQualifier);
1038
- if (parent === undefined || parent === "ambiguous") {
1039
- throw new DatasetSqlError(`"${parentQualifier}" is not in the query before JOIN ${dataset}.`);
1040
- }
1041
- const source = isLink(parent) ? this.completeLink(parent, dataset, parentKey, targetKey) : this.joinTo(parent, dataset, parentKey, targetKey, inner);
1042
- if (isLink(parent) && parent.inner !== inner) {
1043
- throw new DatasetSqlError(`JOIN ${parent.relation.through.dataset} and JOIN ${dataset} are one many-to-many join: write both as JOIN or both as LEFT JOIN.`);
1044
- }
1045
- this.name(own, source);
1046
- if ("path" in source && inner) {
1047
- this.matched.push({ col: `${source.path}.${targetKey}`, op: "isNotNull" });
1048
- }
1049
- }
1050
- assertComplete() {
1051
- for (const [qualifier, entry] of this.byName) {
1052
- if (entry === "ambiguous" || !isLink(entry) || entry.completed)
1053
- continue;
1054
- throw new DatasetSqlError(`"${qualifier}" is only the link to "${entry.relation.dataset}"; write ${datasetJoinSql(entry.from.dataset.name, entry.relation)}.`);
1055
- }
1056
- }
1057
- resolve(ref) {
1058
- const dot = ref.indexOf(".");
1059
- if (dot === -1)
1060
- return this.bareColumn(ref);
1061
- const qualifier = ref.slice(0, dot);
1062
- const column = ref.slice(dot + 1);
1063
- if (column.includes(".")) {
1064
- throw new DatasetSqlError(`"${ref}": write one JOIN per dataset and reference dataset.column.`);
1065
- }
1066
- const source = this.byName.get(qualifier);
1067
- if (source === undefined)
1068
- throw new DatasetSqlError(this.unknownQualifier(qualifier));
1069
- if (source === "ambiguous") {
1070
- throw new DatasetSqlError(`"${qualifier}" names more than one dataset in the query; give each JOIN its own alias.`);
1071
- }
1072
- if (isLink(source)) {
1073
- throw new DatasetSqlError(`"${qualifier}" is a link table; read its columns from the datasets it links.`);
1074
- }
1075
- if (!source.dataset.columns.some((c) => c.name === column)) {
1076
- throw new DatasetSqlError(unknownColumnError(source.dataset, column));
1077
- }
1078
- return source.path ? `${source.path}.${column}` : column;
1079
- }
1080
- name(qualifier, source) {
1081
- this.byName.set(qualifier, this.byName.has(qualifier) ? "ambiguous" : source);
1082
- }
1083
- get columnNames() {
1084
- return this.root.dataset.columns.map((column) => column.name);
1085
- }
1086
- placeOf(wireRef) {
1087
- const dot = wireRef.lastIndexOf(".");
1088
- if (dot === -1)
1089
- return [wireRef];
1090
- const path = wireRef.slice(0, dot);
1091
- for (const [qualifier, entry] of this.byName) {
1092
- if (entry !== "ambiguous" && !isLink(entry) && entry.path === path) {
1093
- return [qualifier, wireRef.slice(dot + 1)];
1094
- }
1095
- }
1096
- return [wireRef];
1097
- }
1098
- joinTo(parent, dataset, parentKey, targetKey, inner) {
1099
- const candidates = Object.entries(parent.dataset.relations).filter(([, r]) => (r.through?.dataset ?? r.dataset) === dataset);
1100
- if (candidates.length === 0) {
1101
- throw new DatasetSqlError(`"${parent.dataset.name}" declares no join to "${dataset}". ${this.inverseOf(parent, dataset) ?? this.joinsOf(parent)}`);
1102
- }
1103
- const found = candidates.find(([, r]) => r.on[0] === parentKey && r.on[1] === targetKey);
1104
- if (!found) {
1105
- const all = datasetJoinLines(parent.dataset);
1106
- const names = Object.keys(parent.dataset.relations);
1107
- const lines = candidates.map(([name]) => all[names.indexOf(name)]);
1108
- throw new DatasetSqlError(`"${parent.dataset.name}" reaches "${dataset}" as ${lines.join(", or ")}.`);
1109
- }
1110
- const [relationName, relation] = found;
1111
- if (!relation.through)
1112
- return this.source(parent, relationName, relation.dataset);
1113
- return { from: parent, relationName, relation, inner };
1114
- }
1115
- completeLink(link, dataset, linkKey, targetKey) {
1116
- const { relation } = link;
1117
- const through = relation.through;
1118
- const matches = relation.dataset === dataset && through.on[0] === linkKey && through.on[1] === targetKey;
1119
- if (!matches) {
1120
- throw new DatasetSqlError(`"${through.dataset}" is the link to "${relation.dataset}": ${datasetJoinSql(link.from.dataset.name, relation)}.`);
1121
- }
1122
- link.completed = true;
1123
- return this.source(link.from, link.relationName, dataset);
1124
- }
1125
- source(parent, relationName, datasetName) {
1126
- const dataset = this.catalog.get(datasetName);
1127
- if (!dataset)
1128
- throw new DatasetSqlError(`"${datasetName}" is not an exposed dataset.`);
1129
- const path = parent.path ? `${parent.path}.${relationName}` : relationName;
1130
- this.paths.push(path);
1131
- return { path, dataset };
1132
- }
1133
- bareColumn(column) {
1134
- const has = (source) => source.dataset.columns.some((c) => c.name === column);
1135
- if (has(this.root))
1136
- return column;
1137
- const owners = this.sources().filter((source) => source.path && has(source));
1138
- if (owners.length === 1)
1139
- return `${owners[0].path}.${column}`;
1140
- if (owners.length > 1) {
1141
- throw new DatasetSqlError(`"${column}" is a column of ${owners.map((o) => o.dataset.name).join(" and ")}; qualify it as dataset.column.`);
1142
- }
1143
- const joined = this.paths.length ? " Nor does any joined dataset." : "";
1144
- throw new DatasetSqlError(unknownColumnError(this.root.dataset, column) + joined);
1145
- }
1146
- sources() {
1147
- const seen = new Set;
1148
- for (const entry of this.byName.values()) {
1149
- if (entry !== "ambiguous" && !isLink(entry))
1150
- seen.add(entry);
1151
- }
1152
- return [...seen];
1153
- }
1154
- unknownQualifier(qualifier) {
1155
- for (const source of this.sources()) {
1156
- const relations = Object.entries(source.dataset.relations);
1157
- const index = relations.findIndex(([name, r]) => name === qualifier || r.dataset === qualifier);
1158
- if (index === -1)
1159
- continue;
1160
- const [, relation] = relations[index];
1161
- const line = datasetJoinLines(source.dataset)[index];
1162
- return this.byName.has(relation.dataset) ? `"${qualifier}" is the relation's name; reference ${relation.dataset}.column.` : `"${qualifier}" is not joined. Add ${line} and reference ${relation.dataset}.column.`;
1163
- }
1164
- return `"${qualifier}" is neither the dataset, a joined dataset nor an alias. ${this.joinsOf(this.root)}`;
1165
- }
1166
- inverseOf(parent, dataset) {
1167
- const child = this.catalog.get(dataset);
1168
- if (!child)
1169
- return;
1170
- const index = Object.values(child.relations).findIndex((r) => r.dataset === parent.dataset.name && !r.through);
1171
- if (index === -1)
1172
- return;
1173
- return `"${dataset}" joins "${parent.dataset.name}", so start there: FROM ${dataset} ${datasetJoinLines(child)[index]}.`;
1174
- }
1175
- joinsOf(source) {
1176
- const lines = datasetJoinLines(source.dataset);
1177
- return lines.length ? `Joins "${source.dataset.name}" declares: ${lines.join("; ")}.` : `"${source.dataset.name}" declares no joins.`;
1178
- }
1179
- }
1180
968
  // ../../internal/contracts/src/datasets/dataset-sql-guide.ts
1181
969
  var DATASET_SQL_GRAMMAR = "One SELECT over one dataset. LEFT JOIN related datasets exactly as the dataset's description lists them (LEFT JOIN keeps rows without a match; JOIN or INNER JOIN drops them); reference dataset.column. " + "SELECT: columns, DATE_TRUNC('unit', column), EXTRACT(part FROM column), CASE WHEN ... END, LOWER/UPPER/TRIM/LENGTH/ABS/ROUND/COALESCE, COUNT/SUM/AVG/MIN/MAX over a column or arithmetic each with an optional FILTER (WHERE ...), and named arithmetic between aggregates (SUM(a) / COUNT(*) AS avg). " + "WHERE and HAVING: AND, OR, NOT, parentheses, comparisons with literals or other columns, IN, BETWEEN, LIKE, IS NULL; CURRENT_DATE and INTERVAL arithmetic on it. " + "GROUP BY columns or select aliases. An aggregate with OVER () or OVER (PARTITION BY ...) is a window: that aggregate over the rows sharing the partition, on every row (SUM(COUNT(*)) OVER () is the grand total); name it AS, use it in arithmetic, and QUALIFY filters the finished rows. " + "QUALIFY RANK() OVER (PARTITION BY ... ORDER BY ...) <= n for the top n per group (rows tied on every ORDER BY key share a rank and all stay); ORDER BY; LIMIT; OFFSET. " + "Rows nest qualified columns under the qualifier as written (pets.name comes back as row.pets.name); aliases and aggregates are top-level.";
1182
- export { BACKEND_ERROR_STATUS, backendErrorSchema, errorEnvelope, isRecord, readJsonPointer, CortexError, malformedBody, envelopeOf, protocolBodyLimit, contentVersion, datasetIdentifierSchema, datasetColumnSchema, datasetDefinitionSchema, DATASET_REQUEST_MAX_BYTES, datasetRequestSchema, datasetCatalogOf, groupKeyName, filterRefs, isColumnValue, checkDatasetQuery, boundDatasetResult, FUNCTION_SIGNATURES };
970
+ export { BACKEND_ERROR_STATUS, backendErrorSchema, errorEnvelope, isRecord, readJsonPointer, CortexError2, malformedBody, envelopeOf, protocolBodyLimit, contentVersion, datasetIdentifierSchema, datasetColumnSchema, datasetDefinitionSchema, DATASET_REQUEST_MAX_BYTES, datasetRequestSchema, datasetCatalogOf, groupKeyName, filterRefs, isColumnValue, checkDatasetQuery, boundDatasetResult, FUNCTION_SIGNATURES };