@xpert-ai/plugin-live-dashboard 0.5.0 → 0.6.1
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/.xpertai-plugin/plugin.json +1 -1
- package/README.md +4 -2
- package/dist/index.js +3 -1
- package/dist/lib/agent.schema.d.ts +9 -9
- package/dist/lib/agent.schema.js +2 -1
- package/dist/lib/archive.service.d.ts +26 -2
- package/dist/lib/archive.service.js +17 -3
- package/dist/lib/bounded-map.d.ts +2 -0
- package/dist/lib/bounded-map.js +25 -0
- package/dist/lib/capacity.d.ts +14 -0
- package/dist/lib/capacity.js +16 -0
- package/dist/lib/dashboard-archive.d.ts +1 -1
- package/dist/lib/dashboard-queries.d.ts +1 -1
- package/dist/lib/dashboard-queries.js +11 -6
- package/dist/lib/dashboard-receipt.js +1 -1
- package/dist/lib/dashboard-sources.js +3 -2
- package/dist/lib/dashboard-view.schema.d.ts +59 -20
- package/dist/lib/dashboard-view.schema.js +1 -1
- package/dist/lib/dashboard.schema.d.ts +18 -18
- package/dist/lib/dashboard.schema.js +2 -1
- package/dist/lib/dashboard.service.d.ts +34 -6
- package/dist/lib/dashboard.service.js +67 -15
- package/dist/lib/definition-tools.d.ts +4 -4
- package/dist/lib/document-host.js +1 -1
- package/dist/lib/document-package.d.ts +1 -1
- package/dist/lib/editing-patch.js +2 -1
- package/dist/lib/editing.d.ts +11 -10
- package/dist/lib/editing.js +5 -1
- package/dist/lib/filter-evidence.d.ts +28 -0
- package/dist/lib/filter-evidence.js +3 -2
- package/dist/lib/html-guidance.d.ts +1 -0
- package/dist/lib/html-guidance.js +2 -1
- package/dist/lib/html-validation.js +1 -1
- package/dist/lib/middleware.d.ts +3 -1
- package/dist/lib/middleware.js +89 -11
- package/dist/lib/plugin.js +2 -1
- package/dist/lib/presentation.provider.d.ts +1 -1
- package/dist/lib/preview-retry.d.ts +4 -3
- package/dist/lib/preview-retry.js +13 -7
- package/dist/lib/prompt-workflows.js +1 -1
- package/dist/lib/query-session.d.ts +9 -0
- package/dist/lib/query-session.js +64 -0
- package/dist/lib/save-requests.d.ts +118 -0
- package/dist/lib/save-requests.js +199 -0
- package/dist/lib/source-executions.d.ts +243 -2
- package/dist/lib/source-executions.js +29 -5
- package/dist/lib/view.provider.d.ts +52 -3
- package/dist/lib/view.provider.js +20 -4
- package/dist/remote/app.js +114 -65
- package/dist/remote/build-manifest.json +40 -35
- package/dist/sandbox-actions/action.json +1 -1
- package/dist/sandbox-actions/bundle/host.js +63 -14
- package/dist/sandbox-actions/bundle/validate.mjs +2 -2
- package/dist/validation/host-entry.d.ts +5 -1
- package/dist/validation/host-entry.js +21 -4
- package/docs/docs.json +2 -0
- package/docs/large-dashboards-acceptance.mdx +74 -0
- package/docs/large-dashboards.mdx +80 -0
- package/package.json +5 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.queryBindingSchema = exports.querySchema = exports.saveSchema = exports.controlsSchema = exports.dashboardChangesSchema = exports.dashboardSchema = void 0;
|
|
4
|
+
const capacity_1 = require("./capacity");
|
|
4
5
|
const v3_1 = require("zod/v3");
|
|
5
6
|
const analytics_1 = require("@xpert-ai/plugin-sdk/analytics");
|
|
6
7
|
const artifact_document_1 = require("@xpert-ai/plugin-sdk/artifact-document");
|
|
@@ -8,7 +9,7 @@ const dashboard_sources_1 = require("./dashboard-sources");
|
|
|
8
9
|
const id = v3_1.z.string().regex(/^[A-Za-z][A-Za-z0-9_.-]{0,79}$/);
|
|
9
10
|
exports.dashboardSchema = v3_1.z.object({
|
|
10
11
|
schema: v3_1.z.literal('xpert.live-dashboard'), id: v3_1.z.string().uuid(), title: v3_1.z.string().min(1).max(160),
|
|
11
|
-
bindings: v3_1.z.array(analytics_1.analyticsBindingSchema).max(
|
|
12
|
+
bindings: v3_1.z.array(analytics_1.analyticsBindingSchema).max(capacity_1.MAX_DASHBOARD_BINDINGS),
|
|
12
13
|
sourceMetadata: dashboard_sources_1.sourceMetadataSchema.optional(),
|
|
13
14
|
components: dashboard_sources_1.dashboardComponentsSchema.optional(),
|
|
14
15
|
presentation: v3_1.z.object({ type: v3_1.z.literal('html'), html: artifact_document_1.artifactDocumentHtml, dependencies: artifact_document_1.artifactDocumentDependencyLocks.optional() }).strict().optional(),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DashboardConfig } from './capacity';
|
|
1
2
|
import type { AnalyticsValue, AnalyticsDiscoveryRequest, AnalyticsQueryRequest, XpertResolvedViewHostContext } from '@xpert-ai/contracts';
|
|
2
3
|
import { type RuntimeCapabilityRegistry } from '@xpert-ai/plugin-sdk';
|
|
3
4
|
import { type DashboardManifest, type DashboardChanges } from './dashboard.schema';
|
|
@@ -5,10 +6,18 @@ import { type ArtifactDocumentDependencyAsset } from '@xpert-ai/plugin-sdk/artif
|
|
|
5
6
|
import { HtmlDashboardValidation } from './html-validation';
|
|
6
7
|
import type { DashboardAccess, DashboardMode } from './project';
|
|
7
8
|
export declare const PLUGIN_NAME = "@xpert-ai/plugin-live-dashboard";
|
|
9
|
+
export type SaveProgress = (stage: string, completed: number, total: number) => Promise<void>;
|
|
10
|
+
export type SaveOptions = {
|
|
11
|
+
requestId: string;
|
|
12
|
+
progress: SaveProgress;
|
|
13
|
+
};
|
|
8
14
|
export declare class DashboardService {
|
|
9
15
|
private readonly runtime;
|
|
10
16
|
private readonly htmlValidation;
|
|
11
|
-
|
|
17
|
+
private readonly config?;
|
|
18
|
+
constructor(runtime: RuntimeCapabilityRegistry, htmlValidation: HtmlDashboardValidation, config?: DashboardConfig | undefined);
|
|
19
|
+
get maxBindings(): number;
|
|
20
|
+
assertCapacity(count: number, previousCount?: number): void;
|
|
12
21
|
sources(context: XpertResolvedViewHostContext): Promise<import("@xpert-ai/contracts").AnalyticsSourceSummary[]>;
|
|
13
22
|
discover(context: XpertResolvedViewHostContext, input: AnalyticsDiscoveryRequest): Promise<import("@xpert-ai/contracts").AnalyticsDiscoveryResult>;
|
|
14
23
|
preview(context: XpertResolvedViewHostContext, input: AnalyticsQueryRequest): Promise<import("@xpert-ai/contracts").AnalyticalDataset>;
|
|
@@ -16,7 +25,9 @@ export declare class DashboardService {
|
|
|
16
25
|
title: string | null | undefined;
|
|
17
26
|
draftRevision?: number | undefined;
|
|
18
27
|
updatedAt: string | Date | undefined;
|
|
28
|
+
isEmpty: boolean;
|
|
19
29
|
canDelete: boolean;
|
|
30
|
+
isDraft: boolean;
|
|
20
31
|
artifactId: string;
|
|
21
32
|
versionId: string | null | undefined;
|
|
22
33
|
versionNumber: number | undefined;
|
|
@@ -30,7 +41,9 @@ export declare class DashboardService {
|
|
|
30
41
|
title: string | null | undefined;
|
|
31
42
|
draftRevision?: number | undefined;
|
|
32
43
|
updatedAt: string | Date | undefined;
|
|
44
|
+
isEmpty: boolean;
|
|
33
45
|
canDelete: boolean;
|
|
46
|
+
isDraft: boolean;
|
|
34
47
|
artifactId: string;
|
|
35
48
|
versionId: string | null | undefined;
|
|
36
49
|
versionNumber: number | undefined;
|
|
@@ -44,7 +57,9 @@ export declare class DashboardService {
|
|
|
44
57
|
title: string | null | undefined;
|
|
45
58
|
draftRevision?: number | undefined;
|
|
46
59
|
updatedAt: string | Date | undefined;
|
|
60
|
+
isEmpty: boolean;
|
|
47
61
|
canDelete: boolean;
|
|
62
|
+
isDraft: boolean;
|
|
48
63
|
artifactId: string;
|
|
49
64
|
versionId: string | null | undefined;
|
|
50
65
|
versionNumber: number | undefined;
|
|
@@ -55,16 +70,29 @@ export declare class DashboardService {
|
|
|
55
70
|
selectedSummary(context: XpertResolvedViewHostContext, artifactId: string): Promise<{
|
|
56
71
|
title: string | null | undefined;
|
|
57
72
|
draftRevision?: number | undefined;
|
|
73
|
+
updatedAt: string | Date | undefined;
|
|
74
|
+
isEmpty: boolean;
|
|
58
75
|
canDelete: boolean;
|
|
76
|
+
isDraft: boolean;
|
|
59
77
|
artifactId: string;
|
|
60
78
|
versionId: string | null | undefined;
|
|
61
79
|
versionNumber: number | undefined;
|
|
62
|
-
updatedAt: string | Date | undefined;
|
|
63
80
|
} | undefined>;
|
|
81
|
+
private pickerSummary;
|
|
64
82
|
trash(context: XpertResolvedViewHostContext, artifactId: string, expectedRevision: number): Promise<{
|
|
65
83
|
artifactId: string;
|
|
66
84
|
}>;
|
|
67
|
-
|
|
85
|
+
previousBindingCount(context: XpertResolvedViewHostContext, manifest: DashboardManifest): Promise<number>;
|
|
86
|
+
/** Read-only reconciliation of a completed CAS after a worker/status-store interruption. */
|
|
87
|
+
savedRequestReceipt(context: XpertResolvedViewHostContext, manifestId: string, requestId: string, expectedRevision: number): Promise<{
|
|
88
|
+
artifactId: string;
|
|
89
|
+
draftId: string;
|
|
90
|
+
draftRevision: number;
|
|
91
|
+
baseVersionId: string | null;
|
|
92
|
+
status: "draft";
|
|
93
|
+
title: string;
|
|
94
|
+
} | null>;
|
|
95
|
+
save(context: XpertResolvedViewHostContext, manifest: DashboardManifest, expectedVersionId: string | null, expectedRevision?: number, importedDependencies?: ArtifactDocumentDependencyAsset[], task?: SaveOptions): Promise<{
|
|
68
96
|
artifactId: string;
|
|
69
97
|
draftId: string;
|
|
70
98
|
draftRevision: number;
|
|
@@ -86,8 +114,8 @@ export declare class DashboardService {
|
|
|
86
114
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
87
115
|
}[];
|
|
88
116
|
charts: {
|
|
89
|
-
title: string;
|
|
90
117
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
118
|
+
title: string;
|
|
91
119
|
id: string;
|
|
92
120
|
datasetId: string;
|
|
93
121
|
x: string;
|
|
@@ -147,8 +175,8 @@ export declare class DashboardService {
|
|
|
147
175
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
148
176
|
}[];
|
|
149
177
|
charts: {
|
|
150
|
-
title: string;
|
|
151
178
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
179
|
+
title: string;
|
|
152
180
|
id: string;
|
|
153
181
|
datasetId: string;
|
|
154
182
|
x: string;
|
|
@@ -293,8 +321,8 @@ export declare class DashboardService {
|
|
|
293
321
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
294
322
|
}[];
|
|
295
323
|
charts: {
|
|
296
|
-
title: string;
|
|
297
324
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
325
|
+
title: string;
|
|
298
326
|
id: string;
|
|
299
327
|
datasetId: string;
|
|
300
328
|
x: string;
|
|
@@ -14,6 +14,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.DashboardService = exports.PLUGIN_NAME = void 0;
|
|
16
16
|
exports.projectId = projectId;
|
|
17
|
+
const capacity_1 = require("./capacity");
|
|
18
|
+
const bounded_map_1 = require("./bounded-map");
|
|
17
19
|
const common_1 = require("@nestjs/common");
|
|
18
20
|
const node_crypto_1 = require("node:crypto");
|
|
19
21
|
const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
|
|
@@ -30,9 +32,19 @@ exports.PLUGIN_NAME = '@xpert-ai/plugin-live-dashboard';
|
|
|
30
32
|
const RESOURCE_TYPE = 'live-dashboard';
|
|
31
33
|
const MIME_TYPE = 'application/json';
|
|
32
34
|
let DashboardService = class DashboardService {
|
|
33
|
-
constructor(runtime, htmlValidation) {
|
|
35
|
+
constructor(runtime, htmlValidation, config) {
|
|
34
36
|
this.runtime = runtime;
|
|
35
37
|
this.htmlValidation = htmlValidation;
|
|
38
|
+
this.config = config;
|
|
39
|
+
}
|
|
40
|
+
get maxBindings() { return this.config?.maxBindings ?? capacity_1.DEFAULT_DASHBOARD_BINDINGS; }
|
|
41
|
+
assertCapacity(count, previousCount = 0) {
|
|
42
|
+
try {
|
|
43
|
+
(0, capacity_1.assertBindingCapacity)(count, previousCount, this.maxBindings);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new common_1.BadRequestException(error instanceof Error ? error.message : 'DASHBOARD_BINDING_CAPACITY');
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
49
|
async sources(context) { await this.authorizeProject(context); return this.runtime.require(plugin_sdk_1.AnalyticsRuntimeCapability).list(actor(context)); }
|
|
38
50
|
async discover(context, input) { await this.authorizeProject(context); return this.runtime.require(plugin_sdk_1.AnalyticsRuntimeCapability).discover(actor(context), input); }
|
|
@@ -58,11 +70,7 @@ let DashboardService = class DashboardService {
|
|
|
58
70
|
const result = await this.runtime.require(plugin_sdk_1.ArtifactsRuntimeCapability).listArtifacts({ pluginName: exports.PLUGIN_NAME, resourceType: RESOURCE_TYPE, resourceIdPrefix: hostPrefix(context), status: 'active', page, pageSize, includeCurrentVersion: true });
|
|
59
71
|
const items = result.items.filter((item) => item.resourceId.startsWith(hostPrefix(context)) && (item.userId === context.userId || !item.userId && item.projectId === projectId(context)));
|
|
60
72
|
const drafts = new Map((access.canReadDraft ? await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).list(items.map(item => item.id)) : []).map(draft => [draft.artifactId, draft]));
|
|
61
|
-
return { page, pageSize, hasMore: page * pageSize < result.total, items: items.filter(item => access.canReadDraft || !!item.currentVersionId).map(item =>
|
|
62
|
-
const draft = drafts.get(item.id);
|
|
63
|
-
return { ...summary(item), canDelete: !!draft && access.canManage,
|
|
64
|
-
...(draft ? { title: draft.title ?? item.title, draftRevision: draft.revision, updatedAt: draft.updatedAt ?? item.updatedAt } : {}) };
|
|
65
|
-
}) };
|
|
73
|
+
return { page, pageSize, hasMore: page * pageSize < result.total, items: await Promise.all(items.filter(item => access.canReadDraft || !!item.currentVersionId).map(item => this.pickerSummary(item, drafts.get(item.id), access))) };
|
|
66
74
|
}
|
|
67
75
|
async searchPage(context, input) {
|
|
68
76
|
// Search the authorized display titles, including editor drafts. Filtering a stored
|
|
@@ -87,8 +95,14 @@ let DashboardService = class DashboardService {
|
|
|
87
95
|
if (!access.canReadDraft && !artifact.currentVersionId)
|
|
88
96
|
return undefined;
|
|
89
97
|
const draft = access.canReadDraft ? (await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).list([artifactId]))[0] : undefined;
|
|
90
|
-
return
|
|
91
|
-
|
|
98
|
+
return this.pickerSummary(artifact, draft, access);
|
|
99
|
+
}
|
|
100
|
+
async pickerSummary(artifact, draft, access) {
|
|
101
|
+
const isEmpty = access.canReadDraft && !draft && !artifact.currentVersionId &&
|
|
102
|
+
!(await this.runtime.require(plugin_sdk_1.ArtifactsRuntimeCapability).listArtifactVersions({ artifactId: artifact.id })).length;
|
|
103
|
+
return { ...summary(artifact), isEmpty, canDelete: access.canManage && !!draft,
|
|
104
|
+
isDraft: !!draft && draft.revision !== draft.publishedRevision,
|
|
105
|
+
...(draft ? { title: draft.title ?? artifact.title, draftRevision: draft.revision, updatedAt: draft.updatedAt ?? artifact.updatedAt } : {}) };
|
|
92
106
|
}
|
|
93
107
|
async trash(context, artifactId, expectedRevision) {
|
|
94
108
|
await this.authorizeProject(context, 'manage');
|
|
@@ -100,7 +114,31 @@ let DashboardService = class DashboardService {
|
|
|
100
114
|
await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).setRecycled({ artifactId, expectedRevision, recycled: true });
|
|
101
115
|
return { artifactId };
|
|
102
116
|
}
|
|
103
|
-
async
|
|
117
|
+
async previousBindingCount(context, manifest) {
|
|
118
|
+
await this.authorizeProject(context, 'write');
|
|
119
|
+
const existing = await this.runtime.require(plugin_sdk_1.ArtifactsRuntimeCapability).findArtifactBySource({ pluginName: exports.PLUGIN_NAME, resourceType: RESOURCE_TYPE, resourceId: `${hostPrefix(context)}${manifest.id}` });
|
|
120
|
+
if (!existing)
|
|
121
|
+
return 0;
|
|
122
|
+
assertOwned(context, existing);
|
|
123
|
+
const draft = (await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).list([existing.id]))[0];
|
|
124
|
+
return existing.currentVersionId || draft ? (await this.open(context, existing.id)).manifest.bindings.length : 0;
|
|
125
|
+
}
|
|
126
|
+
/** Read-only reconciliation of a completed CAS after a worker/status-store interruption. */
|
|
127
|
+
async savedRequestReceipt(context, manifestId, requestId, expectedRevision) {
|
|
128
|
+
await this.authorizeProject(context, 'write');
|
|
129
|
+
const artifact = await this.runtime.require(plugin_sdk_1.ArtifactsRuntimeCapability).findArtifactBySource({ pluginName: exports.PLUGIN_NAME, resourceType: RESOURCE_TYPE, resourceId: `${hostPrefix(context)}${manifestId}` });
|
|
130
|
+
if (!artifact)
|
|
131
|
+
return null;
|
|
132
|
+
assertOwned(context, artifact);
|
|
133
|
+
if (artifact.status !== 'active')
|
|
134
|
+
throw new common_1.ForbiddenException('DASHBOARD_ARCHIVED');
|
|
135
|
+
const draft = await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).get(artifact.id);
|
|
136
|
+
if (draft?.metadata?.saveRequestId !== requestId || draft.revision !== expectedRevision + 1)
|
|
137
|
+
return null;
|
|
138
|
+
return { artifactId: artifact.id, draftId: draft.id, draftRevision: draft.revision, baseVersionId: draft.baseVersionId, status: 'draft', title: draft.title ?? artifact.title ?? '' };
|
|
139
|
+
}
|
|
140
|
+
async save(context, manifest, expectedVersionId, expectedRevision = 0, importedDependencies, task) {
|
|
141
|
+
await task?.progress('authorization', 0, manifest.bindings.length);
|
|
104
142
|
await this.authorizeProject(context, 'write');
|
|
105
143
|
const scopedActor = actor(context);
|
|
106
144
|
const parsed = dashboard_schema_1.dashboardSchema.parse(manifest);
|
|
@@ -115,6 +153,7 @@ let DashboardService = class DashboardService {
|
|
|
115
153
|
}
|
|
116
154
|
// A failed first upload can leave an Artifact with no saved content; revision 0 initializes it.
|
|
117
155
|
const previous = existing && (existing.currentVersionId || expectedRevision > 0) ? await this.openDocument(context, existing.id) : null;
|
|
156
|
+
this.assertCapacity(parsed.bindings.length, previous?.manifest.bindings.length ?? 0);
|
|
118
157
|
if (importedDependencies && existing)
|
|
119
158
|
throw new common_1.BadRequestException('DASHBOARD_IMPORT_NEW_ID_REQUIRED');
|
|
120
159
|
const dependencies = importedDependencies ? (0, artifact_document_1.verifyArtifactDocumentDependencies)(importedDependencies, parsed.presentation?.dependencies ?? [])
|
|
@@ -123,21 +162,31 @@ let DashboardService = class DashboardService {
|
|
|
123
162
|
if (buffer.byteLength > document_package_1.MAX_DASHBOARD_PACKAGE_BYTES)
|
|
124
163
|
throw new common_1.BadRequestException('DASHBOARD_MANIFEST_TOO_LARGE');
|
|
125
164
|
const digest = (0, node_crypto_1.createHash)('sha256').update(buffer).digest('hex');
|
|
165
|
+
if (existing && task) {
|
|
166
|
+
const draft = await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).get(existing.id);
|
|
167
|
+
if (draft?.metadata?.saveRequestId === task.requestId && draft.sha256 === digest && draft.revision === expectedRevision + 1)
|
|
168
|
+
return { artifactId: existing.id, draftId: draft.id, draftRevision: draft.revision, baseVersionId: draft.baseVersionId, status: 'draft', title: parsed.title };
|
|
169
|
+
}
|
|
126
170
|
if ((existing?.currentVersionId ?? null) !== expectedVersionId)
|
|
127
171
|
throw new common_1.ConflictException('DASHBOARD_VERSION_CONFLICT');
|
|
128
172
|
// Recheck current data access even for an idempotent retry; the platform enforces the final CAS under a row lock.
|
|
129
|
-
const preview = await this.
|
|
173
|
+
const preview = await (0, dashboard_queries_1.queryDashboard)(this.runtime, actor(context), parsed, Object.fromEntries(parsed.controls.filter((control) => control.defaultValue !== undefined).map((control) => [control.controlId, control.defaultValue ?? null])), task ? completed => task.progress('queries', completed, parsed.bindings.length) : undefined);
|
|
130
174
|
if (!parsed.presentation)
|
|
131
175
|
(0, renderer_1.toDataAnalyticsPayload)(parsed, preview);
|
|
132
|
-
|
|
133
|
-
|
|
176
|
+
let completedFilters = 0;
|
|
177
|
+
await (0, bounded_map_1.boundedMap)(parsed.bindings, async (binding) => {
|
|
178
|
+
await this.probeControls(context, binding, Object.fromEntries(parsed.controls.filter((control) => control.defaultValue !== undefined).map((control) => [control.controlId, control.defaultValue ?? null])), task ? () => task.progress('filters', completedFilters, parsed.bindings.length) : undefined);
|
|
179
|
+
await task?.progress('filters', ++completedFilters, parsed.bindings.length);
|
|
180
|
+
});
|
|
181
|
+
await task?.progress('html', 0, 1);
|
|
134
182
|
const htmlValidation = await this.htmlValidation.validate(context, parsed, preview, dependencies);
|
|
183
|
+
await task?.progress('save', 0, 1);
|
|
135
184
|
const artifact = existing ?? await artifacts.createArtifact({ source, type: { pluginName: exports.PLUGIN_NAME, resourceType: RESOURCE_TYPE }, kind: 'file', title: parsed.title,
|
|
136
185
|
scope: { ...scopedActor, ...(projectId(context) ? { projectId: projectId(context), userId: null } : { xpertId: context.hostId }) } });
|
|
137
186
|
const reference = await this.runtime.require(plugin_sdk_1.ArtifactContentRuntimeCapability).write({ artifactId: artifact.id, buffer });
|
|
138
187
|
const result = await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).save({ artifactId: artifact.id, expectedRevision,
|
|
139
188
|
expectedCurrentVersionId: expectedVersionId, mimeType: MIME_TYPE, title: parsed.title, fileName: 'dashboard.json', sha256: digest,
|
|
140
|
-
...(htmlValidation ? { metadata: { htmlValidation } } : {}), workspaceFileRef: reference });
|
|
189
|
+
...((htmlValidation || task) ? { metadata: { ...(htmlValidation ? { htmlValidation } : {}), ...(task ? { saveRequestId: task.requestId } : {}) } } : {}), workspaceFileRef: reference });
|
|
141
190
|
return { artifactId: artifact.id, draftId: result.id, draftRevision: result.revision, baseVersionId: result.baseVersionId, status: 'draft', title: parsed.title };
|
|
142
191
|
}
|
|
143
192
|
async open(context, artifactId, versionId, draftRevision, mode = 'draft') {
|
|
@@ -242,7 +291,7 @@ let DashboardService = class DashboardService {
|
|
|
242
291
|
execute(context, manifest, input) {
|
|
243
292
|
return (0, dashboard_queries_1.queryDashboard)(this.runtime, actor(context), manifest, input);
|
|
244
293
|
}
|
|
245
|
-
async probeControls(context, binding, input) {
|
|
294
|
+
async probeControls(context, binding, input, checkpoint) {
|
|
246
295
|
const controls = Object.fromEntries(binding.parameters.map((parameter) => [parameter.controlId,
|
|
247
296
|
Object.hasOwn(input, parameter.controlId) ? input[parameter.controlId] : parameter.defaultValue ?? null]));
|
|
248
297
|
// A null default can bypass a native predicate entirely. Verify a real selection too,
|
|
@@ -253,6 +302,7 @@ let DashboardService = class DashboardService {
|
|
|
253
302
|
const samples = [...(alternative !== undefined ? [alternative] : []),
|
|
254
303
|
...(current !== null && parameter.allowedValues?.includes(null) ? [null] : [])];
|
|
255
304
|
for (const value of samples) {
|
|
305
|
+
await checkpoint?.();
|
|
256
306
|
// Analytics already redacts provider failures. Preserve its actionable validation
|
|
257
307
|
// errors: a duplicate grain is not a malformed filter and needs a different repair.
|
|
258
308
|
await this.runtime.require(plugin_sdk_1.AnalyticsRuntimeCapability).query(actor(context), { binding, controls: { ...controls, [parameter.controlId]: value } });
|
|
@@ -264,7 +314,9 @@ exports.DashboardService = DashboardService;
|
|
|
264
314
|
exports.DashboardService = DashboardService = __decorate([
|
|
265
315
|
(0, common_1.Injectable)(),
|
|
266
316
|
__param(0, (0, common_1.Inject)(plugin_sdk_1.XPERT_RUNTIME_CAPABILITIES_TOKEN)),
|
|
267
|
-
|
|
317
|
+
__param(2, (0, common_1.Optional)()),
|
|
318
|
+
__param(2, (0, common_1.Inject)(capacity_1.DASHBOARD_CONFIG)),
|
|
319
|
+
__metadata("design:paramtypes", [Object, html_validation_1.HtmlDashboardValidation, Object])
|
|
268
320
|
], DashboardService);
|
|
269
321
|
function actor(context) {
|
|
270
322
|
if (!context.tenantId || !context.organizationId || !context.userId || !['agent', 'project'].includes(context.hostType))
|
|
@@ -31,26 +31,26 @@ export declare function createDefinitionTools(context: IAgentMiddlewareContext,
|
|
|
31
31
|
definitionJson: z.ZodString;
|
|
32
32
|
}, "strict", z.ZodTypeAny, {
|
|
33
33
|
name: string;
|
|
34
|
+
requestId: string;
|
|
34
35
|
providerId: string;
|
|
35
36
|
connectionKey: string;
|
|
36
|
-
requestId: string;
|
|
37
37
|
definitionJson: string;
|
|
38
38
|
}, {
|
|
39
39
|
name: string;
|
|
40
|
+
requestId: string;
|
|
40
41
|
providerId: string;
|
|
41
42
|
connectionKey: string;
|
|
42
|
-
requestId: string;
|
|
43
43
|
definitionJson: string;
|
|
44
44
|
}>, {
|
|
45
45
|
name: string;
|
|
46
|
+
requestId: string;
|
|
46
47
|
providerId: string;
|
|
47
48
|
connectionKey: string;
|
|
48
|
-
requestId: string;
|
|
49
49
|
definitionJson: string;
|
|
50
50
|
}, {
|
|
51
51
|
name: string;
|
|
52
|
+
requestId: string;
|
|
52
53
|
providerId: string;
|
|
53
54
|
connectionKey: string;
|
|
54
|
-
requestId: string;
|
|
55
55
|
definitionJson: string;
|
|
56
56
|
}, string>)[];
|
|
@@ -6,7 +6,7 @@ const artifact_document_1 = require("@xpert-ai/plugin-sdk/artifact-document");
|
|
|
6
6
|
const document_network_1 = require("./document-network");
|
|
7
7
|
/** The HTML never supplies or overrides its network permissions. */
|
|
8
8
|
function mountDashboardDocument(frame, options) {
|
|
9
|
-
return (0, artifact_document_1.mountArtifactDocument)(frame, { ...options, networkPolicy: document_network_1.DASHBOARD_NETWORK_POLICY });
|
|
9
|
+
return (0, artifact_document_1.mountArtifactDocument)(frame, { ...options, dispatchesPerMinute: 60, networkPolicy: document_network_1.DASHBOARD_NETWORK_POLICY });
|
|
10
10
|
}
|
|
11
11
|
function isDashboardResourceAllowed(resourceType, url) {
|
|
12
12
|
return (0, artifact_document_1.isArtifactDocumentResourceAllowed)(document_network_1.DASHBOARD_NETWORK_POLICY, resourceType, url);
|
|
@@ -17,8 +17,8 @@ export declare function decodeDashboardPackage(bytes: Buffer): {
|
|
|
17
17
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
18
18
|
}[];
|
|
19
19
|
charts: {
|
|
20
|
-
title: string;
|
|
21
20
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
21
|
+
title: string;
|
|
22
22
|
id: string;
|
|
23
23
|
datasetId: string;
|
|
24
24
|
x: string;
|
|
@@ -4,10 +4,11 @@ exports.removalsSchema = void 0;
|
|
|
4
4
|
exports.upsertComponents = upsertComponents;
|
|
5
5
|
exports.htmlElementIds = htmlElementIds;
|
|
6
6
|
exports.assertHtmlPreserved = assertHtmlPreserved;
|
|
7
|
+
const capacity_1 = require("./capacity");
|
|
7
8
|
const parse5_1 = require("parse5");
|
|
8
9
|
const v3_1 = require("zod/v3");
|
|
9
10
|
exports.removalsSchema = v3_1.z.object({
|
|
10
|
-
bindingIds: v3_1.z.array(v3_1.z.string()).max(
|
|
11
|
+
bindingIds: v3_1.z.array(v3_1.z.string()).max(capacity_1.MAX_DASHBOARD_BINDINGS).default([]), controlIds: v3_1.z.array(v3_1.z.string()).max(24).default([]),
|
|
11
12
|
viewIds: v3_1.z.array(v3_1.z.string()).max(40).default([]), htmlElementIds: v3_1.z.array(v3_1.z.string()).max(500).default([]),
|
|
12
13
|
componentIds: v3_1.z.array(v3_1.z.string()).max(160).default([])
|
|
13
14
|
}).strict().optional().describe('Only explicitly requested removals. Arrays of changed components otherwise upsert by stable ID and preserve omitted components.');
|
package/dist/lib/editing.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DashboardSaveRequests } from './save-requests';
|
|
1
2
|
import { z } from 'zod/v3';
|
|
2
3
|
import type { AnalyticsBinding, XpertResolvedViewHostContext } from '@xpert-ai/contracts';
|
|
3
4
|
import { type IAgentMiddlewareContext } from '@xpert-ai/plugin-sdk';
|
|
@@ -101,24 +102,24 @@ export declare const updateToolSchema: z.ZodObject<{
|
|
|
101
102
|
y: z.ZodString;
|
|
102
103
|
color: z.ZodOptional<z.ZodString>;
|
|
103
104
|
}, "strict", z.ZodTypeAny, {
|
|
104
|
-
title: string;
|
|
105
105
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
106
|
+
title: string;
|
|
106
107
|
id: string;
|
|
107
108
|
datasetId: string;
|
|
108
109
|
x: string;
|
|
109
110
|
y: string;
|
|
110
111
|
color?: string | undefined;
|
|
111
112
|
}, {
|
|
112
|
-
title: string;
|
|
113
113
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
114
|
+
title: string;
|
|
114
115
|
id: string;
|
|
115
116
|
datasetId: string;
|
|
116
117
|
x: string;
|
|
117
118
|
y: string;
|
|
118
119
|
color?: string | undefined;
|
|
119
120
|
}>, "many">, {
|
|
120
|
-
title: string;
|
|
121
121
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
122
|
+
title: string;
|
|
122
123
|
id: string;
|
|
123
124
|
datasetId: string;
|
|
124
125
|
x: string;
|
|
@@ -202,8 +203,8 @@ export declare const updateToolSchema: z.ZodObject<{
|
|
|
202
203
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
203
204
|
}[] | undefined;
|
|
204
205
|
charts?: {
|
|
205
|
-
title: string;
|
|
206
206
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
207
|
+
title: string;
|
|
207
208
|
id: string;
|
|
208
209
|
datasetId: string;
|
|
209
210
|
x: string;
|
|
@@ -251,7 +252,7 @@ export declare const updateToolSchema: z.ZodObject<{
|
|
|
251
252
|
}>;
|
|
252
253
|
export declare const EDITING_GUIDANCE = "Opening or reading a dashboard does not modify it. A selection_required result is normal: show its message to the user and wait for an explicit selection; do not retry, infer a target from history, or create a replacement. Do not save an unchanged editing copy or reopen/update merely to confirm a successful save; use the mutation receipt. For existing dashboards, call dashboard_open first and inspect presentation.type. For standard dashboards, update definition fields directly: a rename needs only title, editId, expectedRevision and expectedCurrentVersionId. No HTML file exists; omit htmlPath and libraries. For HTML dashboards only, open prepares a unique editing copy at htmlPath. Read with sandbox_read_file. If a long HTML line is truncated, do not repeat the same read: use dashboard_read_html with editId and follow nextOffset until null to inspect the saved source, then apply exact replacements to htmlPath. Never replace a file with a truncated preview. Edit with sandbox_edit_file/multi_edit_file (sandbox_write_file is create-only), then call dashboard_update with that exact htmlPath and read revisions. If the user requests a rename, include the new title in this same update; editing the HTML heading alone does not rename the Artifact. Save each batch automatically without human confirmation. Files are not dashboard saves. Preserve Binding semantics, stable component IDs and dependency locks unless requested. To add filters to an existing Binding, copy its complete dashboard_open.bindings[] entry, retain binding.id and existing parameters[].controlId, and call dashboard_preview_binding after changing payload/parameters/defaults. Binding ID is independent of output.datasetId; simplified dashboard_preview derives the ID from datasetId and can accidentally add a new Binding instead of updating the old one. Use the stable Binding ID in HTML query/subscribe calls. Submit every intended changed/new Binding previewId and matching controls with htmlPath in the same dashboard_update. Update arrays upsert by ID, preserving omitted components; removals must name explicitly requested deletions. On preflight failure, compare expected/requested Binding IDs, repair the HTML or previews, and retain all intended previewIds, controls, title and htmlPath when retrying. Dropping previewIds does not register new HTML queries. Do not remove an existing Binding merely to suppress validation. HTML updates retain existing element IDs. For new HTML, assign stable IDs to every KPI, chart, detail table and filter. Read and patch the current file instead of rebuilding unrelated sections. On conflict retain the editing file, open the latest draft and reconcile; never silently overwrite. Historical versions are read-only references. All Agent saves are drafts; only the Workbench human publish action creates formal versions. Read the live-dashboard skill for the complete workflow.";
|
|
253
254
|
/** Run-local read receipts carry planning versions; authorization and CAS remain in the domain service. */
|
|
254
|
-
export declare function createEditingTools(service: DashboardService, scope: XpertResolvedViewHostContext, context: IAgentMiddlewareContext, resolvePreviews: (ids: string[]) => AnalyticsBinding[], validateFinal: (manifest: DashboardManifest, requirePreviews: boolean, changedBindingIds?: string[]) => void, onOpen?: (path: string, artifactId: string) => void, currentTarget?: (config: unknown) => DashboardSelection | null | undefined): (import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
255
|
+
export declare function createEditingTools(service: DashboardService, scope: XpertResolvedViewHostContext, context: IAgentMiddlewareContext, resolvePreviews: (ids: string[]) => AnalyticsBinding[], validateFinal: (manifest: DashboardManifest, requirePreviews: boolean, changedBindingIds?: string[]) => void, onOpen?: (path: string, artifactId: string) => void, currentTarget?: (config: unknown) => DashboardSelection | null | undefined, saveRequests?: DashboardSaveRequests): (import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
255
256
|
page: z.ZodDefault<z.ZodNumber>;
|
|
256
257
|
}, "strict", z.ZodTypeAny, {
|
|
257
258
|
page: number;
|
|
@@ -394,24 +395,24 @@ export declare function createEditingTools(service: DashboardService, scope: Xpe
|
|
|
394
395
|
y: z.ZodString;
|
|
395
396
|
color: z.ZodOptional<z.ZodString>;
|
|
396
397
|
}, "strict", z.ZodTypeAny, {
|
|
397
|
-
title: string;
|
|
398
398
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
399
|
+
title: string;
|
|
399
400
|
id: string;
|
|
400
401
|
datasetId: string;
|
|
401
402
|
x: string;
|
|
402
403
|
y: string;
|
|
403
404
|
color?: string | undefined;
|
|
404
405
|
}, {
|
|
405
|
-
title: string;
|
|
406
406
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
407
|
+
title: string;
|
|
407
408
|
id: string;
|
|
408
409
|
datasetId: string;
|
|
409
410
|
x: string;
|
|
410
411
|
y: string;
|
|
411
412
|
color?: string | undefined;
|
|
412
413
|
}>, "many">, {
|
|
413
|
-
title: string;
|
|
414
414
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
415
|
+
title: string;
|
|
415
416
|
id: string;
|
|
416
417
|
datasetId: string;
|
|
417
418
|
x: string;
|
|
@@ -495,8 +496,8 @@ export declare function createEditingTools(service: DashboardService, scope: Xpe
|
|
|
495
496
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
496
497
|
}[] | undefined;
|
|
497
498
|
charts?: {
|
|
498
|
-
title: string;
|
|
499
499
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
500
|
+
title: string;
|
|
500
501
|
id: string;
|
|
501
502
|
datasetId: string;
|
|
502
503
|
x: string;
|
|
@@ -569,8 +570,8 @@ export declare function createEditingTools(service: DashboardService, scope: Xpe
|
|
|
569
570
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
570
571
|
}[] | undefined;
|
|
571
572
|
charts?: {
|
|
572
|
-
title: string;
|
|
573
573
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
574
|
+
title: string;
|
|
574
575
|
id: string;
|
|
575
576
|
datasetId: string;
|
|
576
577
|
x: string;
|
package/dist/lib/editing.js
CHANGED
|
@@ -25,7 +25,7 @@ const readHtmlSchema = v3_1.z.object({ editId: v3_1.z.string().uuid(), versionId
|
|
|
25
25
|
length: v3_1.z.number().int().min(1).max(24000).default(16000) }).strict();
|
|
26
26
|
exports.EDITING_GUIDANCE = `Opening or reading a dashboard does not modify it. A selection_required result is normal: show its message to the user and wait for an explicit selection; do not retry, infer a target from history, or create a replacement. Do not save an unchanged editing copy or reopen/update merely to confirm a successful save; use the mutation receipt. For existing dashboards, call dashboard_open first and inspect presentation.type. For standard dashboards, update definition fields directly: a rename needs only title, editId, expectedRevision and expectedCurrentVersionId. No HTML file exists; omit htmlPath and libraries. For HTML dashboards only, open prepares a unique editing copy at htmlPath. Read with sandbox_read_file. If a long HTML line is truncated, do not repeat the same read: use dashboard_read_html with editId and follow nextOffset until null to inspect the saved source, then apply exact replacements to htmlPath. Never replace a file with a truncated preview. Edit with sandbox_edit_file/multi_edit_file (sandbox_write_file is create-only), then call dashboard_update with that exact htmlPath and read revisions. If the user requests a rename, include the new title in this same update; editing the HTML heading alone does not rename the Artifact. Save each batch automatically without human confirmation. Files are not dashboard saves. Preserve Binding semantics, stable component IDs and dependency locks unless requested. To add filters to an existing Binding, copy its complete dashboard_open.bindings[] entry, retain binding.id and existing parameters[].controlId, and call dashboard_preview_binding after changing payload/parameters/defaults. Binding ID is independent of output.datasetId; simplified dashboard_preview derives the ID from datasetId and can accidentally add a new Binding instead of updating the old one. Use the stable Binding ID in HTML query/subscribe calls. Submit every intended changed/new Binding previewId and matching controls with htmlPath in the same dashboard_update. Update arrays upsert by ID, preserving omitted components; removals must name explicitly requested deletions. On preflight failure, compare expected/requested Binding IDs, repair the HTML or previews, and retain all intended previewIds, controls, title and htmlPath when retrying. Dropping previewIds does not register new HTML queries. Do not remove an existing Binding merely to suppress validation. HTML updates retain existing element IDs. For new HTML, assign stable IDs to every KPI, chart, detail table and filter. Read and patch the current file instead of rebuilding unrelated sections. On conflict retain the editing file, open the latest draft and reconcile; never silently overwrite. Historical versions are read-only references. All Agent saves are drafts; only the Workbench human publish action creates formal versions. Read the live-dashboard skill for the complete workflow.`;
|
|
27
27
|
/** Run-local read receipts carry planning versions; authorization and CAS remain in the domain service. */
|
|
28
|
-
function createEditingTools(service, scope, context, resolvePreviews, validateFinal, onOpen = () => undefined, currentTarget = editing_session_1.selectionFromConfig) {
|
|
28
|
+
function createEditingTools(service, scope, context, resolvePreviews, validateFinal, onOpen = () => undefined, currentTarget = editing_session_1.selectionFromConfig, saveRequests) {
|
|
29
29
|
const target = (input, config) => {
|
|
30
30
|
const selected = currentTarget(config);
|
|
31
31
|
if (input.artifactId)
|
|
@@ -119,6 +119,10 @@ function createEditingTools(service, scope, context, resolvePreviews, validateFi
|
|
|
119
119
|
...(sourceMetadata.length || saved.manifest.sourceMetadata ? { sourceMetadata } : {}), ...(components.length || saved.manifest.components ? { components } : {}),
|
|
120
120
|
...(presentation ? { presentation } : {}) });
|
|
121
121
|
validateFinal(manifest, previewIds !== undefined, changedBindings?.map(item => item.id));
|
|
122
|
+
if (saveRequests && manifest.bindings.length > 8) {
|
|
123
|
+
const key = (0, node_crypto_1.createHash)('sha256').update(JSON.stringify([editId, expectedRevision, expectedCurrentVersionId, manifest, sourceFile])).digest('hex');
|
|
124
|
+
return JSON.stringify(await saveRequests.submit(scope, manifest, expectedCurrentVersionId, expectedRevision, key, sourceFile));
|
|
125
|
+
}
|
|
122
126
|
const { schema, id, ...update } = manifest;
|
|
123
127
|
const result = await service.update(scope, editId, expectedRevision, update, expectedCurrentVersionId);
|
|
124
128
|
const resourceCard = await (0, resource_card_1.emitDashboardCard)(scope, { ...result, state: 'draft', revision: result.draftRevision }, config);
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { z } from 'zod/v3';
|
|
2
2
|
import type { AnalyticsBinding, AnalyticsValue, XpertResolvedViewHostContext } from '@xpert-ai/contracts';
|
|
3
3
|
import type { DashboardService } from './dashboard.service';
|
|
4
|
+
export declare const filterTestSchema: z.ZodObject<{
|
|
5
|
+
previewId: z.ZodString;
|
|
6
|
+
controls: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, unknown>;
|
|
7
|
+
expectations: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
8
|
+
fieldId: z.ZodString;
|
|
9
|
+
oneOf: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, "many">;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
fieldId: string;
|
|
12
|
+
oneOf: (string | number | boolean | null)[];
|
|
13
|
+
}, {
|
|
14
|
+
fieldId: string;
|
|
15
|
+
oneOf: (string | number | boolean | null)[];
|
|
16
|
+
}>, "many">, {
|
|
17
|
+
fieldId: string;
|
|
18
|
+
oneOf: (string | number | boolean | null)[];
|
|
19
|
+
}[], unknown>;
|
|
20
|
+
}, "strict", z.ZodTypeAny, {
|
|
21
|
+
controls: Record<string, string | number | boolean | null>;
|
|
22
|
+
previewId: string;
|
|
23
|
+
expectations: {
|
|
24
|
+
fieldId: string;
|
|
25
|
+
oneOf: (string | number | boolean | null)[];
|
|
26
|
+
}[];
|
|
27
|
+
}, {
|
|
28
|
+
previewId: string;
|
|
29
|
+
controls?: unknown;
|
|
30
|
+
expectations?: unknown;
|
|
31
|
+
}>;
|
|
4
32
|
/** Model quality evidence, not authorization: every query still goes through Analytics. */
|
|
5
33
|
export declare function createFilterEvidence(service: DashboardService, scope: XpertResolvedViewHostContext, previews: Map<string, AnalyticsBinding>): {
|
|
6
34
|
requirements(binding: AnalyticsBinding, previewId: string, rows: Record<string, AnalyticsValue>[]): {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterTestSchema = void 0;
|
|
3
4
|
exports.createFilterEvidence = createFilterEvidence;
|
|
4
5
|
const tools_1 = require("@langchain/core/tools");
|
|
5
6
|
const v3_1 = require("zod/v3");
|
|
6
7
|
const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
|
|
7
8
|
const scalar = v3_1.z.union([v3_1.z.string().max(4000), v3_1.z.number().finite(), v3_1.z.boolean(), v3_1.z.null()]);
|
|
8
|
-
|
|
9
|
+
exports.filterTestSchema = v3_1.z.object({ previewId: v3_1.z.string().min(1),
|
|
9
10
|
controls: (0, plugin_sdk_1.jsonEncodedSchema)(v3_1.z.record(scalar)),
|
|
10
11
|
expectations: (0, plugin_sdk_1.jsonEncodedSchema)(v3_1.z.array(v3_1.z.object({ fieldId: v3_1.z.string().min(1), oneOf: v3_1.z.array(scalar).min(1).max(100) }).strict()).min(1).max(24))
|
|
11
12
|
}).strict();
|
|
@@ -55,6 +56,6 @@ function createFilterEvidence(service, scope, previews) {
|
|
|
55
56
|
checked.set(input.previewId, controls);
|
|
56
57
|
return JSON.stringify({ previewId: input.previewId, passed: true, checkedControls: [...controls], remainingControls: required(binding, input.previewId).map(parameter => parameter.controlId), rows: dataset.rows.slice(0, 20), completeness: dataset.completeness });
|
|
57
58
|
}, { name: 'dashboard_test_filter', description: 'Verify a previewed Binding with concrete filter values and expected field values. For a nullable dimension selector, test a real non-null value and expect every row of the matching field to equal it before saving. Does not change defaults. A failed check must be repaired before create/update.',
|
|
58
|
-
schema, verboseParsingErrors: true, metadata: { toolName: { en_US: 'Verify filter results', zh_Hans: '验证筛选结果' } } })
|
|
59
|
+
schema: exports.filterTestSchema, verboseParsingErrors: true, metadata: { toolName: { en_US: 'Verify filter results', zh_Hans: '验证筛选结果' } } })
|
|
59
60
|
};
|
|
60
61
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export declare const HTML_DASHBOARD_GUIDANCE = "For free-layout HTML dashboards, read the installed live-dashboard skill's references/html-runtime.md through read_skill_file, relative to its SKILL.md path in the skill catalog. Create/edit the HTML with SandboxFile; then dashboard_create_html or dashboard_update validates and saves it. Do not use generic present_files to save or preview a live dashboard. Its preview belongs to the Live dashboards Workbench. Call dashboard_libraries for packaged ECharts/Three.js. Network access is temporarily unrestricted for functional acceptance. CDN scripts/styles/fonts, CSS imports, external images and fetch/XHR are available under browser CORS and mixed-content rules. Tailwind CDN is supported; do not remove styling to avoid network validation. Platform business data remains declarative Binding queries through window.xpertLiveArtifact; never embed credentials. The page MUST declare const live = window.xpertLiveArtifact in its script (live is not a host global), register live.subscribe(bindingId, render), await live.ready(), and invoke live.query(bindingId, typedControls) for initial data and filter changes. window.__datasets and window.__refresh are not platform APIs and are never populated by the host. Read the runtime reference and its html-lifecycle.md example before writing HTML; preserve that lifecycle while freely changing the layout. Use one complete Dataset for KPI, trend and details when they share the same metric and filters; do not create a redundant unfiltered total Binding. Never let filtered and unfiltered subscriptions both write the same KPI: a refresh would race and overwrite the selected-region total. Distinct global totals need distinct, clearly labeled elements. Native data selects require data-dashboard-control=\"<controlId>\"; purely visual selects use data-dashboard-presentation. A data filter must query, not only filter cached browser rows. bindSelect controls ONE binding only. For a shared dimension filter across multiple bindings, follow the skill custom-select example and query every affected binding with the same typed controls; matching control IDs do not broadcast automatically. bindSelect derives options from Dataset fields and is only for dimension filters. Fixed query enums (days, page size, granularity) need options from parameter.allowedValues and a typed change listener calling live.query; never use date rows as numeric day-count options.";
|
|
2
|
+
export declare const HTML_QUERY_ROUNDS = "For a filter shared by multiple Bindings use await live.queryMany(affectedBindingIds, typedControls); render explicit failures from the returned {datasets, failures}. Successful subscriptions are delivered together after that round settles. Individual live.query calls retain independent delivery for legacy pages.";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HTML_DASHBOARD_GUIDANCE = void 0;
|
|
3
|
+
exports.HTML_QUERY_ROUNDS = exports.HTML_DASHBOARD_GUIDANCE = void 0;
|
|
4
4
|
exports.HTML_DASHBOARD_GUIDANCE = `For free-layout HTML dashboards, read the installed live-dashboard skill's references/html-runtime.md through read_skill_file, relative to its SKILL.md path in the skill catalog. Create/edit the HTML with SandboxFile; then dashboard_create_html or dashboard_update validates and saves it. Do not use generic present_files to save or preview a live dashboard. Its preview belongs to the Live dashboards Workbench. Call dashboard_libraries for packaged ECharts/Three.js. Network access is temporarily unrestricted for functional acceptance. CDN scripts/styles/fonts, CSS imports, external images and fetch/XHR are available under browser CORS and mixed-content rules. Tailwind CDN is supported; do not remove styling to avoid network validation. Platform business data remains declarative Binding queries through window.xpertLiveArtifact; never embed credentials. The page MUST declare const live = window.xpertLiveArtifact in its script (live is not a host global), register live.subscribe(bindingId, render), await live.ready(), and invoke live.query(bindingId, typedControls) for initial data and filter changes. window.__datasets and window.__refresh are not platform APIs and are never populated by the host. Read the runtime reference and its html-lifecycle.md example before writing HTML; preserve that lifecycle while freely changing the layout. Use one complete Dataset for KPI, trend and details when they share the same metric and filters; do not create a redundant unfiltered total Binding. Never let filtered and unfiltered subscriptions both write the same KPI: a refresh would race and overwrite the selected-region total. Distinct global totals need distinct, clearly labeled elements. Native data selects require data-dashboard-control="<controlId>"; purely visual selects use data-dashboard-presentation. A data filter must query, not only filter cached browser rows. bindSelect controls ONE binding only. For a shared dimension filter across multiple bindings, follow the skill custom-select example and query every affected binding with the same typed controls; matching control IDs do not broadcast automatically. bindSelect derives options from Dataset fields and is only for dimension filters. Fixed query enums (days, page size, granularity) need options from parameter.allowedValues and a typed change listener calling live.query; never use date rows as numeric day-count options.`;
|
|
5
|
+
exports.HTML_QUERY_ROUNDS = 'For a filter shared by multiple Bindings use await live.queryMany(affectedBindingIds, typedControls); render explicit failures from the returned {datasets, failures}. Successful subscriptions are delivered together after that round settles. Individual live.query calls retain independent delivery for legacy pages.';
|
|
@@ -22,7 +22,7 @@ const artifact_document_1 = require("@xpert-ai/plugin-sdk/artifact-document");
|
|
|
22
22
|
const html_validation_feedback_1 = require("./html-validation-feedback");
|
|
23
23
|
const PLUGIN = '@xpert-ai/plugin-live-dashboard', ACTION = 'live_dashboard.validate-html', POOL = 'sandbox-browser';
|
|
24
24
|
const reportSchema = v3_1.z.object({ ok: v3_1.z.boolean(), errors: v3_1.z.array(v3_1.z.string().max(300)).max(16),
|
|
25
|
-
requestedBindings: v3_1.z.array(v3_1.z.string().max(80)).max(
|
|
25
|
+
requestedBindings: v3_1.z.array(v3_1.z.string().max(80)).max(64), renderedTextLength: v3_1.z.number().int().nonnegative() }).strict();
|
|
26
26
|
const recordSchema = v3_1.z.object({ tenantId: v3_1.z.string(), organizationId: v3_1.z.string(), userId: v3_1.z.string(), manifestId: v3_1.z.string(), deadline: v3_1.z.number(),
|
|
27
27
|
filePath: v3_1.z.string(), workspacePath: v3_1.z.string(), size: v3_1.z.number(), sha256: v3_1.z.string() }).strict();
|
|
28
28
|
const digest = (buffer) => (0, node_crypto_1.createHash)('sha256').update(buffer).digest('hex');
|
package/dist/lib/middleware.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { DashboardSaveRequests } from './save-requests';
|
|
1
2
|
import type { TAgentMiddlewareMeta } from '@xpert-ai/contracts';
|
|
2
3
|
import { type AgentMiddleware, type IAgentMiddlewareStrategy, type IAgentMiddlewareContext } from '@xpert-ai/plugin-sdk';
|
|
3
4
|
import { DashboardService } from './dashboard.service';
|
|
4
5
|
export declare const DASHBOARD_GUIDANCE = "For a new independent dashboard, use a new unused HTML file path. An existing filename or matching title is not authorization to edit another Artifact; do not switch from creation to dashboard_open/update because a file already exists. For a new dashboard, call dashboard_list_sources before searching raw files, reading old scripts or creating transformations. Named governed sources may already provide the required query; inspect their provider contracts first. File-backed sources do not imply that a script must be written. For creating or editing live dashboards, first read the installed live-dashboard skill using read_skill_file and follow only the references relevant to the task. Use SandboxFile tools for all source-file authoring; HTML alone is not a saved dashboard. Follow preview.validation.checks immediately before authoring HTML; each suggestedCall must actually succeed. Business definitions, real data previews and nullable-filter tests are required before saving new or changed Bindings. Do not invent business data or substitute a different metric without agreement. Report completion only from a successful dashboard_create/dashboard_create_html/dashboard_update draft receipt. Human publication is separate. Successful create, update and open tools emit a chat resource card automatically; resourceCard.status reports emission. Its Open button selects the exact dashboard in Workbench. Never fabricate a link, call present_files for dashboard HTML, or output card JSON as text. If card delivery is unavailable, report the saved receipt and use the Workbench picker.";
|
|
5
6
|
export declare class DashboardMiddleware implements IAgentMiddlewareStrategy {
|
|
6
7
|
private readonly service;
|
|
8
|
+
private readonly saveRequests?;
|
|
7
9
|
readonly meta: TAgentMiddlewareMeta;
|
|
8
|
-
constructor(service: DashboardService);
|
|
10
|
+
constructor(service: DashboardService, saveRequests?: DashboardSaveRequests | undefined);
|
|
9
11
|
createMiddleware(_options: unknown, context: IAgentMiddlewareContext): AgentMiddleware;
|
|
10
12
|
}
|