@xpert-ai/plugin-analytics-data-xpert 0.2.0 → 0.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/dist/lib/client.d.ts +5 -0
- package/dist/lib/client.js +13 -1
- package/dist/lib/discovery.js +2 -2
- package/dist/lib/provider.d.ts +2 -0
- package/dist/lib/provider.js +2 -0
- package/docs/index.mdx +12 -0
- package/package.json +1 -1
package/dist/lib/client.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export type DataXpertClientContext = Pick<AnalyticsProviderContext, 'actor' | 'o
|
|
|
5
5
|
export declare class DataXpertAnalyticsClient {
|
|
6
6
|
private readonly runtime;
|
|
7
7
|
constructor(runtime: RuntimeCapabilityRegistry);
|
|
8
|
+
/**
|
|
9
|
+
* Ask Data Xpert to validate disclosure authority using the current human's scoped token.
|
|
10
|
+
* This metadata-only check neither executes the binding nor grants future query access.
|
|
11
|
+
*/
|
|
12
|
+
authorizeGroupSharing(binding: AnalyticsBinding, context: DataXpertClientContext): Promise<void>;
|
|
8
13
|
discover(request: JSONValue, context: DataXpertClientContext): Promise<AnalyticsDiscoveryResult>;
|
|
9
14
|
private request;
|
|
10
15
|
execute(binding: AnalyticsBinding, parameters: Record<string, AnalyticsValue>, context: DataXpertClientContext): Promise<AnalyticsProviderResult>;
|
package/dist/lib/client.js
CHANGED
|
@@ -46,6 +46,18 @@ let DataXpertAnalyticsClient = class DataXpertAnalyticsClient {
|
|
|
46
46
|
constructor(runtime) {
|
|
47
47
|
this.runtime = runtime;
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Ask Data Xpert to validate disclosure authority using the current human's scoped token.
|
|
51
|
+
* This metadata-only check neither executes the binding nor grants future query access.
|
|
52
|
+
*/
|
|
53
|
+
async authorizeGroupSharing(binding, context) {
|
|
54
|
+
const payload = payload_1.dataXpertPayloadSchema.parse(binding.payload);
|
|
55
|
+
const response = await this.request('authorize-group-sharing', context, {
|
|
56
|
+
binding: { id: binding.id, resourceId: payload.resourceId, actionTypeCode: payload.actionTypeCode,
|
|
57
|
+
target: payload.target, params: payload.params }, maxRows: 1
|
|
58
|
+
});
|
|
59
|
+
v3_1.z.object({ authorized: v3_1.z.literal(true) }).strict().parse(await boundedJson(response));
|
|
60
|
+
}
|
|
49
61
|
async discover(request, context) {
|
|
50
62
|
const importing = import_targets_1.importTargetRequest.safeParse(request);
|
|
51
63
|
if (importing.success)
|
|
@@ -56,7 +68,7 @@ let DataXpertAnalyticsClient = class DataXpertAnalyticsClient {
|
|
|
56
68
|
const result = await this.query(datasetId, parsed.payload, parsed.parameters, context);
|
|
57
69
|
return plugin_sdk_1.analyticsDiscoveryResultSchema.parse({
|
|
58
70
|
items: [{ id: datasetId, name: datasetId, kind: 'dataset',
|
|
59
|
-
metadata: { output: (0, result_schema_1.createDataXpertOutput)(datasetId, result.effect.columns) } }],
|
|
71
|
+
metadata: { payload: parsed.payload, output: (0, result_schema_1.createDataXpertOutput)(datasetId, result.effect.columns) } }],
|
|
60
72
|
queryContract: discovery_1.dataXpertQueryContract
|
|
61
73
|
});
|
|
62
74
|
}
|
package/dist/lib/discovery.js
CHANGED
|
@@ -48,7 +48,7 @@ exports.dataXpertQueryContract = {
|
|
|
48
48
|
'Entity metadata.definition contains adapterId, contractVersion, metadata and instructions. Follow that adapter-specific definition and the discovered Action inputSchema/inputHint. Preserve canonical targets, resource IDs and exact field names. Do not infer adapter types from names or apply one adapter\'s query, filter or time rules to another.',
|
|
49
49
|
'Use only published metadata and authorized previews to establish business metrics, time axes, supported filters and complete aggregation. Missing metadata does not authorize guessing; obtain sufficient evidence before generating a time filter.',
|
|
50
50
|
'Use parameterPaths relative to params to replace an existing scalar value, for example {region:["filters","0","value"]}. Paths must be unique. Never interpolate values into query text. Controls supply scalar values; arrays remain static unless the native Action explicitly supports another declared scalar mapping. Null handling and filter operators are defined by the Action schema and adapter instructions.',
|
|
51
|
-
'Before authoring a binding, use dashboard_discover with the same source/providerId and requestJson encoding {kind:"query-schema",payload:<native Action envelope>,parameters:<mapped scalar values, or {}>}. This runs that bounded read-only Action under the current viewer policy; respect the native Action limits and filters. It returns items[0].metadata.output without business rows. Omit datasetId to let the provider generate a valid output key. Copy this output into the dashboard_preview binding, preserving datasetId, field IDs, sourceField, logicalType, role and nullable. Decimal/int64 remain exact strings; do not infer types from sample cells or names. If declarations are missing, obtain source metadata instead of guessing.',
|
|
52
|
-
'The discovered output has empty grain because column roles alone do not prove uniqueness. Declare grain only when supported by query semantics. Always run dashboard_preview with the same payload and parameter values to validate the binding and obtain a preview receipt before saving; schema discovery is not a preview receipt. Re-discover after changing the query projection. A partial page is not a complete business aggregate.'
|
|
51
|
+
'Before authoring a binding, use dashboard_discover with the same source/providerId and requestJson encoding {kind:"query-schema",payload:<native Action envelope>,parameters:<mapped scalar values, or {}>}. This runs that bounded read-only Action under the current viewer policy; respect the native Action limits and filters. It returns items[0].metadata.payload (the validated native envelope, including parameterPaths) and metadata.output without business rows. Copy both into the preview binding; do not reconstruct or omit required payload fields. Omit datasetId to let the provider generate a valid output key. Copy this output into the dashboard_preview binding, preserving datasetId, field IDs, sourceField, logicalType, role and nullable. Decimal/int64 remain exact strings; do not infer types from sample cells or names. If declarations are missing, obtain source metadata instead of guessing.',
|
|
52
|
+
'The discovered output has empty grain because column roles alone do not prove uniqueness. Declare grain only when supported by query semantics, using IDs from output.fields rather than source dimension names. Always run dashboard_preview with the same payload and parameter values to validate the binding and obtain a preview receipt before saving; schema discovery is not a preview receipt. Re-discover after changing the query projection. A partial page is not a complete business aggregate.'
|
|
53
53
|
].join(' ')
|
|
54
54
|
};
|
package/dist/lib/provider.d.ts
CHANGED
|
@@ -57,5 +57,7 @@ export declare class DataXpertAnalyticsProvider implements AnalyticsQueryProvide
|
|
|
57
57
|
private connection;
|
|
58
58
|
private run;
|
|
59
59
|
discover(request: JSONValue, context: AnalyticsProviderContext): Promise<import("@xpert-ai/contracts").AnalyticsDiscoveryResult>;
|
|
60
|
+
/** Keep source-sharing checks under the same actor and integration revalidation as ordinary queries. */
|
|
61
|
+
authorizeGroupSharing(binding: AnalyticsBinding, context: AnalyticsProviderContext): Promise<void>;
|
|
60
62
|
execute(binding: AnalyticsBinding, parameters: Record<string, AnalyticsValue>, context: AnalyticsProviderContext): Promise<import("@xpert-ai/plugin-sdk").AnalyticsProviderResult>;
|
|
61
63
|
}
|
package/dist/lib/provider.js
CHANGED
|
@@ -68,6 +68,8 @@ let DataXpertAnalyticsProvider = class DataXpertAnalyticsProvider {
|
|
|
68
68
|
return result;
|
|
69
69
|
}
|
|
70
70
|
discover(request, context) { return this.run(context, resolved => this.engine.discover(request, resolved)); }
|
|
71
|
+
/** Keep source-sharing checks under the same actor and integration revalidation as ordinary queries. */
|
|
72
|
+
authorizeGroupSharing(binding, context) { return this.run(context, resolved => this.engine.authorizeGroupSharing(binding, resolved)); }
|
|
71
73
|
execute(binding, parameters, context) { return this.run(context, resolved => this.engine.execute(binding, parameters, resolved)); }
|
|
72
74
|
};
|
|
73
75
|
exports.DataXpertAnalyticsProvider = DataXpertAnalyticsProvider;
|
package/docs/index.mdx
CHANGED
|
@@ -96,3 +96,15 @@ the host's declared Binding bridge. They do not call data-xpert directly. Filter
|
|
|
96
96
|
new declared parameters; refreshing performs another request. Responses must declare
|
|
97
97
|
`fromCache: false`, meaning the data-xpert Action result cache was bypassed. Upstream source
|
|
98
98
|
caches and business-data freshness are separate concerns.
|
|
99
|
+
|
|
100
|
+
## Reuse a discovered query
|
|
101
|
+
|
|
102
|
+
`query-schema` returns both `items[0].metadata.payload` and
|
|
103
|
+
`items[0].metadata.output`. Copy both into the preview binding. The payload is
|
|
104
|
+
the validated native Action envelope, including an empty `parameterPaths` when
|
|
105
|
+
no controls are mapped; it contains no trusted connection options or actor
|
|
106
|
+
credentials. Output contains declared field metadata, not business rows.
|
|
107
|
+
Use output field IDs for `grain`, and declare uniqueness only when the query
|
|
108
|
+
semantics prove it. A successful schema discovery still requires a separate
|
|
109
|
+
binding preview. Adapter-owned time validation errors require correcting the
|
|
110
|
+
query against published metadata; they do not establish missing source data.
|