@frontera-sdk/blueprint 1.52.26 → 1.52.27
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/package.json +2 -2
- package/src/blueprint-client.ts +3 -2
- package/src/hooks.ts +3 -2
- package/src/types.ts +49 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontera-sdk/blueprint",
|
|
3
|
-
"version": "1.52.
|
|
3
|
+
"version": "1.52.27",
|
|
4
4
|
"description": "React hooks for reading Blueprint data and invoking governed Actions from inside a Frontera app.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"frontera",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"smoke": "bun run scripts/smoke.ts"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@frontera-sdk/core": "1.52.
|
|
59
|
+
"@frontera-sdk/core": "1.52.27"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@tanstack/react-query": "^5.90.21",
|
package/src/blueprint-client.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
BlueprintObjectName,
|
|
8
8
|
BlueprintRow,
|
|
9
9
|
MetricQueryRequest,
|
|
10
|
+
MetricQueryResponse,
|
|
10
11
|
ObjectInstance,
|
|
11
12
|
QueryRequest,
|
|
12
13
|
QueryResponse,
|
|
@@ -118,8 +119,8 @@ export class BlueprintClient {
|
|
|
118
119
|
}))
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
metricQuery(apiName: string, request: MetricQueryRequest = {}): Promise<
|
|
122
|
-
return this.client.request<
|
|
122
|
+
metricQuery(apiName: string, request: MetricQueryRequest = {}): Promise<MetricQueryResponse> {
|
|
123
|
+
return this.client.request<MetricQueryResponse>(
|
|
123
124
|
`/v1/blueprint/metrics/${encodeURIComponent(apiName)}/query`,
|
|
124
125
|
{ method: 'POST', body: request },
|
|
125
126
|
)
|
package/src/hooks.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
BlueprintRow,
|
|
13
13
|
BlueprintSortableProperty,
|
|
14
14
|
MetricQueryRequest,
|
|
15
|
+
MetricQueryResponse,
|
|
15
16
|
NearestRequest,
|
|
16
17
|
ObjectInstance,
|
|
17
18
|
QueryRequest,
|
|
@@ -207,8 +208,8 @@ export function useObjectInstance<
|
|
|
207
208
|
export function useMetric(
|
|
208
209
|
apiName: string,
|
|
209
210
|
request: MetricQueryRequest = {},
|
|
210
|
-
options: ReadOptions<
|
|
211
|
-
): UseQueryResult<
|
|
211
|
+
options: ReadOptions<MetricQueryResponse> = {},
|
|
212
|
+
): UseQueryResult<MetricQueryResponse, Error> {
|
|
212
213
|
const client = useBlueprintClient()
|
|
213
214
|
return useQuery({
|
|
214
215
|
queryKey: blueprintKeys.metric(apiName, request),
|
package/src/types.ts
CHANGED
|
@@ -308,11 +308,59 @@ export interface AggregateResponse {
|
|
|
308
308
|
rows: Array<Record<string, unknown>>
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
export interface MetricTimeRange {
|
|
312
|
+
/** ISO 8601 duration ending now, such as `P30D`. */
|
|
313
|
+
isoDuration?: string
|
|
314
|
+
start?: string
|
|
315
|
+
end?: string
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* `true` compares with the window just before `timeRange`; `{ start, end }`
|
|
320
|
+
* compares with that explicit window. `true` needs `timeRange.start` and
|
|
321
|
+
* `timeRange.end`: the service refuses it with `isoDuration`. Each measure
|
|
322
|
+
* then also returns `<measure>_prev`, `<measure>_delta` and `<measure>_pct`
|
|
323
|
+
* columns.
|
|
324
|
+
*/
|
|
325
|
+
export type MetricCompare = boolean | { start: string; end: string }
|
|
326
|
+
|
|
311
327
|
export interface MetricQueryRequest {
|
|
312
328
|
measures?: string[]
|
|
313
329
|
dimensions?: string[]
|
|
330
|
+
timeRange?: MetricTimeRange
|
|
331
|
+
compare?: MetricCompare
|
|
314
332
|
grain?: TimeGrain
|
|
315
|
-
|
|
333
|
+
/** Ask for `drill`, the objects behind each number. */
|
|
334
|
+
drill?: boolean
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Which reviewed revisions produced an answer. */
|
|
338
|
+
export interface QueryLineage {
|
|
339
|
+
objectTypes: string[]
|
|
340
|
+
linkTypes: string[]
|
|
341
|
+
datasetRevisionIds: string[]
|
|
342
|
+
sourceRevisionIds: string[]
|
|
343
|
+
editGenerations?: Array<{ objectType: string; generation: number }>
|
|
344
|
+
datasetNames?: Array<{ revisionId: string; name: string }>
|
|
345
|
+
sourceNames?: Array<{ revisionId: string; name: string }>
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* What the metric route answers. `lineage` and `drill` are absent for a metric
|
|
350
|
+
* the service cannot trace to Dataset revisions; `drill` also needs
|
|
351
|
+
* `drill: true` in the request. `drill[i]` describes `data[i]`, keyed by
|
|
352
|
+
* measure name. `drill` is also absent for a comparison, and a `share` or
|
|
353
|
+
* `ratio` measure has no entry, so a missing entry means the cell cannot name
|
|
354
|
+
* its rows, not that it has none.
|
|
355
|
+
*/
|
|
356
|
+
export interface MetricQueryResponse {
|
|
357
|
+
data: Array<Record<string, unknown>>
|
|
358
|
+
/** `true` when the rows stop at the row cap; narrow the window to see the rest. */
|
|
359
|
+
truncated?: boolean
|
|
360
|
+
/** The comparison window used, when the request set `compare`. */
|
|
361
|
+
compareWindow?: { start: string; end: string }
|
|
362
|
+
lineage?: QueryLineage
|
|
363
|
+
drill?: Array<Record<string, ObjectSetExpr>>
|
|
316
364
|
}
|
|
317
365
|
|
|
318
366
|
/**
|