@object-ui/data-objectstack 4.0.12 → 4.3.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/CHANGELOG.md +28 -0
- package/dist/index.cjs +13 -0
- package/dist/index.d.cts +1 -6
- package/dist/index.d.ts +1 -6
- package/dist/index.js +13 -0
- package/package.json +3 -3
- package/src/index.ts +24 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @object-ui/data-objectstack
|
|
2
2
|
|
|
3
|
+
## 4.3.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @object-ui/types@4.3.0
|
|
8
|
+
- @object-ui/core@4.3.0
|
|
9
|
+
|
|
10
|
+
## 4.2.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- @object-ui/types@4.2.1
|
|
15
|
+
- @object-ui/core@4.2.1
|
|
16
|
+
|
|
17
|
+
## 4.2.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- @object-ui/types@4.2.0
|
|
22
|
+
- @object-ui/core@4.2.0
|
|
23
|
+
|
|
24
|
+
## 4.1.0
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- @object-ui/types@4.1.0
|
|
29
|
+
- @object-ui/core@4.1.0
|
|
30
|
+
|
|
3
31
|
## 4.0.12
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1822,6 +1822,19 @@ var ObjectStackAdapter = class {
|
|
|
1822
1822
|
*/
|
|
1823
1823
|
async aggregate(resource, params) {
|
|
1824
1824
|
await this.connect();
|
|
1825
|
+
const looksLikeSpecShape = params != null && (Array.isArray(params.groupBy) || Array.isArray(params.aggregations) || params.where !== void 0);
|
|
1826
|
+
if (looksLikeSpecShape) {
|
|
1827
|
+
const queryAst = {};
|
|
1828
|
+
if (Array.isArray(params.groupBy)) queryAst.groupBy = params.groupBy;
|
|
1829
|
+
if (Array.isArray(params.aggregations)) queryAst.aggregations = params.aggregations;
|
|
1830
|
+
if (params.where !== void 0) queryAst.where = params.where;
|
|
1831
|
+
if (typeof params.limit === "number") queryAst.limit = params.limit;
|
|
1832
|
+
const result = await this.client.data.query(resource, queryAst);
|
|
1833
|
+
if (Array.isArray(result)) return result;
|
|
1834
|
+
if (Array.isArray(result?.records)) return result.records;
|
|
1835
|
+
if (Array.isArray(result?.data)) return result.data;
|
|
1836
|
+
return [];
|
|
1837
|
+
}
|
|
1825
1838
|
try {
|
|
1826
1839
|
const measureName = params.function === "count" ? "count" : `${params.field}_${params.function}`;
|
|
1827
1840
|
const payload = {
|
package/dist/index.d.cts
CHANGED
|
@@ -968,12 +968,7 @@ declare class ObjectStackAdapter<T = unknown> implements DataSource<T> {
|
|
|
968
968
|
* Falls back to client-side aggregation via find() if the analytics endpoint
|
|
969
969
|
* is not available.
|
|
970
970
|
*/
|
|
971
|
-
aggregate(resource: string, params:
|
|
972
|
-
field: string;
|
|
973
|
-
function: string;
|
|
974
|
-
groupBy: string;
|
|
975
|
-
filter?: any;
|
|
976
|
-
}): Promise<any[]>;
|
|
971
|
+
aggregate(resource: string, params: any): Promise<any[]>;
|
|
977
972
|
/** Client-side aggregation fallback */
|
|
978
973
|
private aggregateClientSide;
|
|
979
974
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -968,12 +968,7 @@ declare class ObjectStackAdapter<T = unknown> implements DataSource<T> {
|
|
|
968
968
|
* Falls back to client-side aggregation via find() if the analytics endpoint
|
|
969
969
|
* is not available.
|
|
970
970
|
*/
|
|
971
|
-
aggregate(resource: string, params:
|
|
972
|
-
field: string;
|
|
973
|
-
function: string;
|
|
974
|
-
groupBy: string;
|
|
975
|
-
filter?: any;
|
|
976
|
-
}): Promise<any[]>;
|
|
971
|
+
aggregate(resource: string, params: any): Promise<any[]>;
|
|
977
972
|
/** Client-side aggregation fallback */
|
|
978
973
|
private aggregateClientSide;
|
|
979
974
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1779,6 +1779,19 @@ var ObjectStackAdapter = class {
|
|
|
1779
1779
|
*/
|
|
1780
1780
|
async aggregate(resource, params) {
|
|
1781
1781
|
await this.connect();
|
|
1782
|
+
const looksLikeSpecShape = params != null && (Array.isArray(params.groupBy) || Array.isArray(params.aggregations) || params.where !== void 0);
|
|
1783
|
+
if (looksLikeSpecShape) {
|
|
1784
|
+
const queryAst = {};
|
|
1785
|
+
if (Array.isArray(params.groupBy)) queryAst.groupBy = params.groupBy;
|
|
1786
|
+
if (Array.isArray(params.aggregations)) queryAst.aggregations = params.aggregations;
|
|
1787
|
+
if (params.where !== void 0) queryAst.where = params.where;
|
|
1788
|
+
if (typeof params.limit === "number") queryAst.limit = params.limit;
|
|
1789
|
+
const result = await this.client.data.query(resource, queryAst);
|
|
1790
|
+
if (Array.isArray(result)) return result;
|
|
1791
|
+
if (Array.isArray(result?.records)) return result.records;
|
|
1792
|
+
if (Array.isArray(result?.data)) return result.data;
|
|
1793
|
+
return [];
|
|
1794
|
+
}
|
|
1782
1795
|
try {
|
|
1783
1796
|
const measureName = params.function === "count" ? "count" : `${params.field}_${params.function}`;
|
|
1784
1797
|
const payload = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/data-objectstack",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "ObjectStack Data Adapter for Object UI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@objectstack/client": "^4.0.5",
|
|
26
|
-
"@object-ui/core": "4.0
|
|
27
|
-
"@object-ui/types": "4.0
|
|
26
|
+
"@object-ui/core": "4.3.0",
|
|
27
|
+
"@object-ui/types": "4.3.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"tsup": "^8.5.1",
|
package/src/index.ts
CHANGED
|
@@ -1434,9 +1434,32 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
|
|
|
1434
1434
|
* Falls back to client-side aggregation via find() if the analytics endpoint
|
|
1435
1435
|
* is not available.
|
|
1436
1436
|
*/
|
|
1437
|
-
async aggregate(resource: string, params:
|
|
1437
|
+
async aggregate(resource: string, params: any): Promise<any[]> {
|
|
1438
1438
|
await this.connect();
|
|
1439
1439
|
|
|
1440
|
+
// Spec-shape aggregation: `{ groupBy: GroupByNode[], aggregations: AggregationNode[], where?, limit? }`
|
|
1441
|
+
// per spec/data/query.zod.ts. Sent directly to the server's POST
|
|
1442
|
+
// /data/:object/query endpoint, which routes through engine.aggregate
|
|
1443
|
+
// and returns bucketed rows with the requested aliases.
|
|
1444
|
+
const looksLikeSpecShape =
|
|
1445
|
+
params != null &&
|
|
1446
|
+
(Array.isArray((params as any).groupBy) ||
|
|
1447
|
+
Array.isArray((params as any).aggregations) ||
|
|
1448
|
+
(params as any).where !== undefined);
|
|
1449
|
+
if (looksLikeSpecShape) {
|
|
1450
|
+
const queryAst: Record<string, unknown> = {};
|
|
1451
|
+
if (Array.isArray(params.groupBy)) queryAst.groupBy = params.groupBy;
|
|
1452
|
+
if (Array.isArray(params.aggregations)) queryAst.aggregations = params.aggregations;
|
|
1453
|
+
if (params.where !== undefined) queryAst.where = params.where;
|
|
1454
|
+
if (typeof params.limit === 'number') queryAst.limit = params.limit;
|
|
1455
|
+
const result: any = await this.client.data.query(resource, queryAst as any);
|
|
1456
|
+
// client.data.query returns { object, records, total, hasMore }
|
|
1457
|
+
if (Array.isArray(result)) return result;
|
|
1458
|
+
if (Array.isArray(result?.records)) return result.records;
|
|
1459
|
+
if (Array.isArray(result?.data)) return result.data;
|
|
1460
|
+
return [];
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1440
1463
|
try {
|
|
1441
1464
|
// Build measure name in the format expected by the backend analytics
|
|
1442
1465
|
// service (memory-analytics / cube). For 'count' the measure key is
|