@sisense/sdk-ai-core 0.17.0 → 0.60.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/dist/__vite-browser-external-l0sNRNKZ.js +1 -0
- package/dist/constants.d.ts +35 -0
- package/dist/engines/atomic-handle-args.d.ts +45 -0
- package/dist/engines/atomic-tool-requirements.d.ts +38 -0
- package/dist/engines/author-pulse/actions/create.d.ts +9 -0
- package/dist/engines/author-pulse/actions/define.d.ts +9 -0
- package/dist/engines/author-pulse/actions/load-existing.d.ts +9 -0
- package/dist/engines/author-pulse/actions/redefine.d.ts +9 -0
- package/dist/engines/author-pulse/actions/set-receive-notifications.d.ts +8 -0
- package/dist/engines/author-pulse/actions/update-spec.d.ts +11 -0
- package/dist/engines/author-pulse/actions/update-workflow.d.ts +9 -0
- package/dist/engines/author-pulse/atomic-adapter.d.ts +10 -0
- package/dist/engines/author-pulse/atomic-tools.d.ts +362 -0
- package/dist/engines/author-pulse/author-pulse-engine.d.ts +21 -0
- package/dist/engines/author-pulse/index.d.ts +9 -0
- package/dist/engines/author-pulse/shared/adjustment-error.d.ts +15 -0
- package/dist/engines/author-pulse/shared/assemble-create-workflow-payload.d.ts +36 -0
- package/dist/engines/author-pulse/shared/assert-agentic-workflow.d.ts +12 -0
- package/dist/engines/author-pulse/shared/compile-query-from-prompt.d.ts +95 -0
- package/dist/engines/author-pulse/shared/decision-spec-validation.d.ts +84 -0
- package/dist/engines/author-pulse/shared/notification-urls.d.ts +52 -0
- package/dist/engines/author-pulse/shared/pulse-knowledge.d.ts +36 -0
- package/dist/engines/author-pulse/shared/pulse-signature.d.ts +39 -0
- package/dist/engines/author-pulse/shared/resolve-frequency.d.ts +18 -0
- package/dist/engines/author-pulse/shared/staging.d.ts +65 -0
- package/dist/engines/author-pulse/shared/workflow-ownership.d.ts +14 -0
- package/dist/engines/author-pulse/types.d.ts +1385 -0
- package/dist/engines/build-chart/atomic-adapter.d.ts +20 -0
- package/dist/engines/build-chart/atomic-tools.d.ts +214 -0
- package/dist/engines/build-chart/build-chart-engine.d.ts +1 -1
- package/dist/engines/build-chart/chart-tool-name.d.ts +3 -0
- package/dist/engines/build-chart/create-chart/assemble-chart-widget.d.ts +1 -1
- package/dist/engines/build-chart/create-chart/chart-json-axes-mapping.d.ts +1 -1
- package/dist/engines/build-chart/create-chart/create-chart.d.ts +1 -1
- package/dist/engines/build-chart/create-chart/derive-chart-title.d.ts +7 -0
- package/dist/engines/build-chart/create-chart/generate-chart-recommendations.d.ts +2 -2
- package/dist/engines/build-chart/create-chart/resolve-chart-query.d.ts +4 -0
- package/dist/engines/build-chart/shared/normalize-cartesian-axes-mapping.d.ts +1 -1
- package/dist/engines/build-chart/shared/sync-chart-state-measure-flags.d.ts +3 -0
- package/dist/engines/build-chart/types.d.ts +38 -19
- package/dist/engines/build-chart/update-chart/apply-prior-chart-style.d.ts +8 -5
- package/dist/engines/build-chart/update-chart/chart-options-schemas.d.ts +18 -18
- package/dist/engines/build-chart/update-chart/schemas.d.ts +2 -2
- package/dist/engines/build-chart/update-chart/update-chart-data-options.d.ts +7 -2
- package/dist/engines/build-chart/update-chart/update-chart-query.d.ts +1 -1
- package/dist/engines/build-chart/update-chart/update-chart-style-options.d.ts +7 -2
- package/dist/engines/build-chart/update-chart/update-chart-title.d.ts +1 -1
- package/dist/engines/build-chart/update-chart/update-chart-type.d.ts +7 -2
- package/dist/engines/build-csv-model/build-csv-model-engine.d.ts +1 -1
- package/dist/engines/build-csv-model/types.d.ts +1 -1
- package/dist/engines/build-dashboard/add-dashboard-narration.d.ts +50 -0
- package/dist/engines/build-dashboard/add-dashboard-widgets.d.ts +1 -1
- package/dist/engines/build-dashboard/atomic-adapter.d.ts +21 -0
- package/dist/engines/build-dashboard/atomic-tools.d.ts +231 -0
- package/dist/engines/build-dashboard/build-dashboard-engine.d.ts +1 -1
- package/dist/engines/build-dashboard/build-dashboard-service.d.ts +2 -1
- package/dist/engines/build-dashboard/create-dashboard.d.ts +3 -4
- package/dist/engines/build-dashboard/dashboard-filters/manipulate-dashboard-filters.d.ts +2 -1
- package/dist/engines/build-dashboard/dashboard-filters/translate-filters.d.ts +17 -1
- package/dist/engines/build-dashboard/index.d.ts +2 -0
- package/dist/engines/build-dashboard/layout/place-widget.d.ts +53 -0
- package/dist/engines/build-dashboard/load-existing-fusion-dashboard.d.ts +1 -1
- package/dist/engines/build-dashboard/remove-dashboard-widgets.d.ts +4 -0
- package/dist/engines/build-dashboard/resolve-chart-widgets.d.ts +16 -0
- package/dist/engines/build-dashboard/types.d.ts +180 -18
- package/dist/engines/build-data-model/build-data-model-engine.d.ts +1 -1
- package/dist/engines/build-data-model/types.d.ts +1 -1
- package/dist/engines/build-query/build-query-engine.d.ts +33 -5
- package/dist/engines/build-query/index.d.ts +1 -1
- package/dist/engines/build-query/types.d.ts +216 -3
- package/dist/engines/build-status/build-status-engine.d.ts +8 -0
- package/dist/engines/build-status/builds-client.d.ts +44 -0
- package/dist/engines/build-status/index.d.ts +2 -0
- package/dist/engines/build-status/types.d.ts +177 -0
- package/dist/engines/datamodel-graph/data-model-map-text.d.ts +28 -0
- package/dist/engines/datamodel-graph/datamodel-graph-engine.d.ts +31 -0
- package/dist/engines/datamodel-graph/index.d.ts +4 -0
- package/dist/engines/datamodel-graph/summaries.d.ts +97 -0
- package/dist/engines/datamodel-graph/test-fixtures.d.ts +42 -0
- package/dist/engines/datamodel-graph/types.d.ts +190 -0
- package/dist/engines/evaluate-pulse/evaluate-pulse-engine.d.ts +10 -0
- package/dist/engines/evaluate-pulse/index.d.ts +2 -0
- package/dist/engines/evaluate-pulse/types.d.ts +85 -0
- package/dist/engines/get-dashboard-narration/get-dashboard-narration-engine.d.ts +23 -0
- package/dist/engines/get-dashboard-narration/index.d.ts +2 -0
- package/dist/engines/get-dashboard-narration/types.d.ts +64 -0
- package/dist/engines/get-dashboards/get-dashboards-engine.d.ts +1 -1
- package/dist/engines/get-dashboards/types.d.ts +16 -4
- package/dist/engines/get-data-preview/get-data-preview-engine.d.ts +18 -0
- package/dist/engines/get-data-preview/index.d.ts +2 -0
- package/dist/engines/get-data-preview/types.d.ts +35 -0
- package/dist/engines/get-data-source-fields/get-data-source-fields-engine.d.ts +12 -6
- package/dist/engines/get-data-source-fields/index.d.ts +1 -0
- package/dist/engines/get-data-source-fields/model-relations.d.ts +38 -0
- package/dist/engines/get-data-source-fields/types.d.ts +49 -3
- package/dist/engines/get-data-sources/get-data-sources-engine.d.ts +1 -1
- package/dist/engines/get-data-sources/types.d.ts +2 -2
- package/dist/engines/index.d.ts +17 -0
- package/dist/engines/inspect-pulse/atomic-adapter.d.ts +8 -0
- package/dist/engines/inspect-pulse/atomic-tools.d.ts +60 -0
- package/dist/engines/inspect-pulse/index.d.ts +4 -0
- package/dist/engines/inspect-pulse/inspect-pulse-engine.d.ts +7 -0
- package/dist/engines/inspect-pulse/types.d.ts +209 -0
- package/dist/engines/manage-perspectives/manage-perspectives-engine.d.ts +5 -1
- package/dist/engines/manage-perspectives/types.d.ts +13 -8
- package/dist/engines/pulse-tool-words.d.ts +62 -0
- package/dist/engines/recommend-queries/recommend-queries-engine.d.ts +1 -1
- package/dist/engines/recommend-queries/types.d.ts +1 -1
- package/dist/engines/shared/existing-answer-cascade.d.ts +52 -0
- package/dist/engines/shared/get-filters-json-for-llm-summary.d.ts +2 -2
- package/dist/engines/shared/nlq-query-helpers.d.ts +2 -2
- package/dist/engines/shared/project-dashboard-json.d.ts +151 -0
- package/dist/engines/shared/project-widget-json.d.ts +67 -0
- package/dist/engines/shared/projection-helpers.d.ts +19 -0
- package/dist/engines/shared/redact-data-models-closed-to-ai.d.ts +55 -0
- package/dist/engines/shared/redact-hidden-columns-from-ai.d.ts +55 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +57916 -30543
- package/dist/services/ai-access/ai-access-service.d.ts +68 -0
- package/dist/services/dashboards/dashboards-service.d.ts +9 -3
- package/dist/services/dashboards/fusion-dashboards-service.d.ts +34 -4
- package/dist/services/data-sources/data-sources-service.d.ts +131 -2
- package/dist/services/data-sources/find-data-source-by-title.d.ts +8 -0
- package/dist/services/datamodel-graph/datamodel-graph-service.d.ts +457 -0
- package/dist/services/existing-answer/existing-answer-query-service.d.ts +31 -0
- package/dist/services/formulas/formulas-service.d.ts +19 -0
- package/dist/services/hide-from-ai/hide-from-ai.d.ts +31 -0
- package/dist/services/knowledge-graph/knowledge-graph-service.d.ts +96 -0
- package/dist/services/llm/llm-consumption-service.d.ts +7 -2
- package/dist/services/llm/llm-settings-service.d.ts +49 -5
- package/dist/services/nlq/nlq-preview-dataset.d.ts +34 -0
- package/dist/services/nlq/nlq-service.d.ts +138 -3
- package/dist/services/pulse/evaluate-pulse-client.d.ts +78 -0
- package/dist/services/pulse/pulse-alerts-service.d.ts +264 -0
- package/dist/services/pulse/pulse-events-service.d.ts +217 -0
- package/dist/services/semantic-search/semantic-search-service.d.ts +43 -0
- package/dist/services/tool-store/tool-store-service.d.ts +32 -0
- package/dist/services/users-groups-service.d.ts +37 -0
- package/dist/skills/index.d.ts +127 -0
- package/dist/tool-availability/controlled-tools.d.ts +56 -0
- package/dist/tool-availability/index.d.ts +4 -0
- package/dist/tool-availability/offer-tools.d.ts +44 -0
- package/dist/tool-availability/resolve-tool-availability.d.ts +68 -0
- package/dist/tool-availability/withdrawn-text.d.ts +33 -0
- package/dist/tool-catalog/catalog.d.ts +387 -0
- package/dist/tool-catalog/index.d.ts +3 -0
- package/dist/tool-catalog/manifest.d.ts +5 -0
- package/dist/tool-catalog/prototype-lookup.d.ts +10 -0
- package/dist/tool-catalog/types.d.ts +67 -0
- package/dist/tools.manifest.json +826 -0
- package/dist/utils/chat-stream-errors.d.ts +42 -0
- package/dist/utils/create-custom-fetch.d.ts +19 -1
- package/dist/utils/create-stream-completion.d.ts +84 -6
- package/dist/utils/create-structured-completion.d.ts +29 -2
- package/dist/utils/create-tools-completion.d.ts +9 -0
- package/dist/utils/deferred-tools.d.ts +45 -0
- package/dist/utils/dev-debug.d.ts +5 -0
- package/dist/utils/generate-suggestions.d.ts +32 -0
- package/dist/utils/http-client.d.ts +3 -1
- package/dist/utils/llm-call-observer.d.ts +83 -0
- package/dist/utils/llm-client.d.ts +11 -1
- package/dist/utils/quoted-text.d.ts +6 -0
- package/dist/utils/server-error-body.d.ts +23 -0
- package/dist/utils/text-tokens.d.ts +35 -0
- package/dist/utils/user-action-tracking.d.ts +48 -5
- package/dist/utils/zod-utils.d.ts +9 -1
- package/package.json +28 -19
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An `authorPulse` action the model must adjust before it can be applied — a validation failure
|
|
3
|
+
* on the model's own input or plan (a forecast query with too few points, a `decisionSpec` path
|
|
4
|
+
* that doesn't resolve, a query staged under the wrong workflow), not a failure of the system. A
|
|
5
|
+
* host can render it as a normal step of the assistant working out the request instead of an
|
|
6
|
+
* error; its message still tells the model what to change.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AuthorPulseAdjustmentError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @param error - anything caught from `authorPulseEngine`
|
|
13
|
+
* @returns whether it asks the model to adjust its action, rather than reporting a failure
|
|
14
|
+
*/
|
|
15
|
+
export declare function isAuthorPulseAdjustmentError(error: unknown): error is AuthorPulseAdjustmentError;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getDataSources } from '../../../services/data-sources/data-sources-service';
|
|
2
|
+
import { PulseAlertCreateDto } from '../../../services/pulse/pulse-alerts-service';
|
|
3
|
+
import { AgenticQuery, AuthorPulseContext, CrossQueryTransform, WorkflowFrequency } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Assembles a fully-populated `POST /api/v1/alerts` body for a brand-new
|
|
6
|
+
* `agentic` workflow — `type: 'agentic'`, `category: 'judgment'`, its own
|
|
7
|
+
* top-level type (no more `context.kpi` workaround: that only existed while
|
|
8
|
+
* agentic workflows were nested under the legacy `type: 'kpi'` shape, which
|
|
9
|
+
* carried an unrelated mandatory-KPI guard). `parties: []` is intentional
|
|
10
|
+
* (vnext auto-injects the requesting user as owner server-side); notification
|
|
11
|
+
* defaults (`feed`/`email`/`mobile` all on) match the KPI workflow dialog's own
|
|
12
|
+
* defaults — the user can adjust channels afterward in the Sisense Pulse
|
|
13
|
+
* interface. `context.sources[]`
|
|
14
|
+
* deliberately omits `oid` — vnext's real Joi validator forbids it for both
|
|
15
|
+
* `cube` and `live` sources (sending it 400s the request). `scheduler` is
|
|
16
|
+
* top-level (a sibling of `context`), matching vnext's shared `addAlert`
|
|
17
|
+
* schema — NOT nested under `context`, whose per-type Joi schema rejects
|
|
18
|
+
* unknown keys and would 400 a `context.scheduler`.
|
|
19
|
+
*/
|
|
20
|
+
/** The data source a workflow's queries run on, as `getDataSources` reports it. */
|
|
21
|
+
export type WorkflowDataSource = Awaited<ReturnType<typeof getDataSources>>[number];
|
|
22
|
+
/** Resolves `sourceId` to its data source, or throws the same error the create path has always thrown. */
|
|
23
|
+
export declare function findWorkflowDataSource(sourceId: string, context: AuthorPulseContext): Promise<WorkflowDataSource>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a cadence is required/allowed for this source. A live workflow has no build event to
|
|
26
|
+
* trigger on, so it must have one; a cube workflow evaluates on every build and never reads one, so
|
|
27
|
+
* it must not (symmetric with `update-workflow`'s rejection on an existing workflow). Runs BEFORE
|
|
28
|
+
* the cadence is resolved, so a cube workflow given a cron cadence hears "cube workflows have no
|
|
29
|
+
* frequency" rather than a question about its time zone.
|
|
30
|
+
*/
|
|
31
|
+
export declare function assertFrequencyMatchesSource(sourceId: string, source: WorkflowDataSource, hasFrequency: boolean): void;
|
|
32
|
+
export declare function assembleCreateWorkflowPayload(name: string, sourceId: string, skill: string, queries: AgenticQuery[],
|
|
33
|
+
/** Already resolved (`resolveFrequency`): a cron cadence arrives with its zone settled and its expression validated. */
|
|
34
|
+
frequency: WorkflowFrequency | undefined, context: AuthorPulseContext, decisionSpec: Record<string, unknown>, crossQueryTransforms?: CrossQueryTransform[],
|
|
35
|
+
/** The source already resolved by the caller (saves the second `getDataSources` round-trip). */
|
|
36
|
+
resolvedSource?: WorkflowDataSource): Promise<PulseAlertCreateDto>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PulseAlertDto, PulseReadClient } from '../../../services/pulse/pulse-events-service';
|
|
2
|
+
/**
|
|
3
|
+
* Confirms an workflowId resolves to an `agentic` workflow before an action touches it — shared by both
|
|
4
|
+
* `authorPulse` (`load-existing`/`update-workflow`) and `inspectPulse` (every read action),
|
|
5
|
+
* which used to each carry their own verbatim copy (MR !1027 cleanup finding) before this file
|
|
6
|
+
* moved here. `PulseReadClient` (not the fuller `HttpClient`) since this only ever reads — either
|
|
7
|
+
* context's own `httpClient` (a full `HttpClient`) satisfies it structurally.
|
|
8
|
+
* @param errorSuffix - the caller-specific tail of the thrown message, e.g. "Only agentic workflows
|
|
9
|
+
* can be authored or updated." — it names no tool, because the composite and the atomic Pulse
|
|
10
|
+
* tools (SNS-136028) both reach this check.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assertAgenticWorkflow(workflowId: string, httpClient: PulseReadClient | undefined, errorSuffix: string): Promise<PulseAlertDto>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { QueryJSON } from '@sisense/sdk-ui/analytics-composer';
|
|
2
|
+
import { ExecuteQueryParams, StyledMeasureColumn } from '@sisense/sdk-ui';
|
|
3
|
+
import { Attribute, LevelAttribute } from '@sisense/sdk-data';
|
|
4
|
+
import { AgenticQueryPreview, AuthorPulseContext, CompiledQueryWithJSON, EvaluationWindow, QueryTransform, QueryTransformInput } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Redefine's carry-forward when `action.transforms` is omitted: turns each staged transform back
|
|
7
|
+
* into the declaration it came from, so the fresh compile resolves it again from scratch.
|
|
8
|
+
*
|
|
9
|
+
* Uniform across every type, because a staged entry carries its own declaration: for a
|
|
10
|
+
* compile-resolved type, dropping `valueField`/`dateField` (which point at the OLD compiled column)
|
|
11
|
+
* leaves exactly the formula options it was declared with; every other type is already its own
|
|
12
|
+
* declaration and passes through untouched. `compileQueryFromPrompt` then re-validates field
|
|
13
|
+
* references against the newly compiled query (`validateTransformFieldReferences`).
|
|
14
|
+
*
|
|
15
|
+
* A transform staged before its formula options were persisted simply has none and recompiles on
|
|
16
|
+
* the defaults, which is the same thing absence has always meant here — see the note above
|
|
17
|
+
* `trendCheckInputField` in `types.ts`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function carryForwardTransforms(transforms: QueryTransform[] | undefined): QueryTransformInput[] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* `compileQueryFromPrompt`'s full result. `compiledQuery` is the live CSDK object (with its own
|
|
22
|
+
* `queryJSON` translation attached — see `CompiledQueryWithJSON`'s doc) that every downstream
|
|
23
|
+
* derivation (persisted `jaql`/`csdkJSON` at the `staging.ts` boundary, agent-facing `queryJSON`,
|
|
24
|
+
* and `redefine`'s own change classification via a `queryJSON` deep-equal) comes from directly —
|
|
25
|
+
* no `jaql` is resolved or returned here at all (SNS-133319: classification and trend/forecast
|
|
26
|
+
* field resolution both moved to operating on this live object instead). `preview` is sibling,
|
|
27
|
+
* review-only data — internal to the engine; callers (`define.ts`/`redefine.ts`) hand it to
|
|
28
|
+
* `context.onQueryPreview`, never to `AuthorPulseResult` (see that type's own doc for why).
|
|
29
|
+
*/
|
|
30
|
+
export interface CompiledQuery {
|
|
31
|
+
compiledQuery: CompiledQueryWithJSON;
|
|
32
|
+
preview: AgenticQueryPreview;
|
|
33
|
+
/** This query's complete transform set: each entry as declared, with `valueField`/`dateField` added to the compile-resolved ones — resolved from the actual compiled query, never guessed. See `applyTrendForecastConfig`/`resolveAnomalyCheckTransform`. */
|
|
34
|
+
transforms?: QueryTransform[];
|
|
35
|
+
/** Set when a trend/forecast series has more points than one evaluation reads — see `timeSeriesEvaluationWindow`. */
|
|
36
|
+
evaluationWindow?: EvaluationWindow;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Finds the query's date-level grouping dimension, if any. CSDK dropped its own
|
|
40
|
+
* `getDateLevelDimension` export (SNS-133319 — the finished design keeps only the underlying
|
|
41
|
+
* `isLevelAttribute` predicate public, not a Pulse-specific wrapper), so this is now a thin local
|
|
42
|
+
* wrapper rather than an import — one `.find()` over the already-public predicate.
|
|
43
|
+
*
|
|
44
|
+
* Exported (via `author-pulse/index.ts`) so `author-pulse-renderer.tsx` (sdk-assistant)
|
|
45
|
+
* can reuse the same date-level check it needs for chart-type selection, instead of a second,
|
|
46
|
+
* divergent copy of this one-liner in another package.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getDateLevelDimension(dimensions: Attribute[]): LevelAttribute | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Rebuilds the single measure's trend/forecast STYLING (`{column, trend, forecast}`) — the shape
|
|
51
|
+
* `@sisense/sdk-ui`'s `Chart` needs as a `dataOptions.value` entry to render the dashed
|
|
52
|
+
* continuation/confidence band (`isAdvancedChart` keys off `.trend`/`.forecast` there), not the
|
|
53
|
+
* *expanded* `[base, $trend_X?, $forecast_X?]` array `adaptMeasuresForQuery` produces for query
|
|
54
|
+
* execution, where no single entry carries a `.trend`/`.forecast` tag. `measures` is that live,
|
|
55
|
+
* expanded array (e.g. `AgenticQueryPreview.queryDescription.measures`); `queryJSON` is the SAME
|
|
56
|
+
* compiled query's collapsed JSON translation (e.g. the `queryJSON` already on `StagedQuerySummary`)
|
|
57
|
+
* — its `measures[0]` already carries `.trend`/`.forecast` as plain option bags (typed identically
|
|
58
|
+
* to `StyledMeasureColumn`'s own, both extending CSDK's `ValueStyle`), reused directly here, not
|
|
59
|
+
* re-parsed from `composeCode`. The live `column` itself still has to come from `measures` (a
|
|
60
|
+
* `StyledMeasureColumn.column` is a real CSDK `Measure` instance, not JSON) — found by title via
|
|
61
|
+
* `getTrendForecastCompanionTitles`, not assumed to be array index 0.
|
|
62
|
+
*
|
|
63
|
+
* Exported for hosts to call on demand at render time against whatever live query they're
|
|
64
|
+
* showing (e.g. sdk-assistant, from the `queryDescription` its own `onQueryPreview` handler
|
|
65
|
+
* received) — a cheap, pure derivation, deliberately NOT computed or stored inside
|
|
66
|
+
* `AuthorPulseResult`/`AgenticQueryPreview` themselves (both must stay free of live CSDK
|
|
67
|
+
* objects — see their own docs).
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildTrendForecastChartValue(measures: ExecuteQueryParams['measures'], queryJSON: QueryJSON): StyledMeasureColumn[] | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Resolves the compiled live query chain from a prior `buildQuery` result: `queryId` →
|
|
72
|
+
* `context.retrieveQuery` (cache lookup, no NLQ call — SNS-133117) → CSDK params
|
|
73
|
+
* (`translateQueryFromJSON`). `define`/`redefine` never run NLQ themselves; mirrors buildChart's own
|
|
74
|
+
* `queryId`-only `create`/`rebind-query` actions (`resolveChartQuery`'s cache-lookup branch). JAQL is
|
|
75
|
+
* not compiled here at all (SNS-133319) — only `shared/staging.ts`, at the actual persistence
|
|
76
|
+
* boundary, ever calls `translateQueryToJaql` now.
|
|
77
|
+
*
|
|
78
|
+
* The preview shown to the user is built from `translated.data` (the structural
|
|
79
|
+
* measures/dimensions/filters `QueryDefinition` renders as pills) — no second query execution.
|
|
80
|
+
* `nlqResult.dataset` (buildQuery's own sample rows) is deliberately NOT forwarded into the preview:
|
|
81
|
+
* the renderer live-executes the compiled query itself now (`ChartWidget`, since the Gap-4
|
|
82
|
+
* chart↔table rewrite), so nothing reads it — forwarding it would just inflate every preview
|
|
83
|
+
* write/PATCH to the sessions API for no reason (MR !1027 cleanup finding).
|
|
84
|
+
* @param queryId - queryId from a prior `buildQuery` result (`define`/`redefine`'s own `queryId`
|
|
85
|
+
* action field) — resolved via `context.retrieveQuery`, the same lookup `BuildChartContext`
|
|
86
|
+
* uses.
|
|
87
|
+
* @param sourceId - the `define`/`redefine` action's own declared `sourceId`, cross-checked against
|
|
88
|
+
* the retrieved query's actual source (`dataSchema.dataSource.title`) — see the check below.
|
|
89
|
+
* @param transforms - this query's full transform declaration from the `define`/`redefine` action
|
|
90
|
+
* (`transformsField`) — `trendCheck`/`forecastCheck` entries are extracted and resolved here
|
|
91
|
+
* (see `applyTrendForecastConfig`), `anomalyCheck` likewise (see
|
|
92
|
+
* `resolveAnomalyCheckTransform`); every other entry passes through as-is, re-validated against
|
|
93
|
+
* the freshly compiled query (`validateTransformFieldReferences`)
|
|
94
|
+
*/
|
|
95
|
+
export declare function compileQueryFromPrompt(queryId: string, sourceId: string, context: AuthorPulseContext, transforms?: QueryTransformInput[]): Promise<CompiledQuery>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { AgenticQuery, CrossQueryTransform, StagedAgenticQuery } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Whether ANY decisionSpec leaf's path resolves against a `previous`/`delta`/`percentChange`
|
|
4
|
+
* container — i.e. whether the skill actually needs a diff baseline to have a chance of firing.
|
|
5
|
+
* Used to scope the "captured today's baseline, couldn't have fired regardless of the skill"
|
|
6
|
+
* message: a decisionSpec built entirely on `current` (or on `topN`/`trend`/`forecast`/`anomaly`,
|
|
7
|
+
* none of which need a cross-cycle baseline) genuinely CAN fire on cycle 1, so claiming otherwise
|
|
8
|
+
* would be wrong for those specs even though `hasPriorData` is still `false` on a first cycle.
|
|
9
|
+
*/
|
|
10
|
+
export declare function decisionSpecReferencesDiffFacts(decisionSpec: Record<string, unknown>): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Authoring-time dry-run: constructing a `Rule` with the LLM-provided `decisionSpec` exercises
|
|
13
|
+
* json-rules-engine's own shape validation (a malformed `conditions` root throws synchronously
|
|
14
|
+
* from the constructor, confirmed empirically against the real package), then
|
|
15
|
+
* `validateDecisionSpecPaths` cross-checks every leaf's `fact`+`path` against what the declared
|
|
16
|
+
* queries/crossQueryTransforms would actually produce — both before the workflow is ever persisted,
|
|
17
|
+
* so a bad spec surfaces as a tool-call error the LLM can react to, instead of silently shipping
|
|
18
|
+
* a workflow that will just never fire (ai-integration's evaluator fails closed on an unresolvable
|
|
19
|
+
* path at evaluation time — resolves the comparison to `false` rather than throwing — which means
|
|
20
|
+
* "quietly broken," not an error anyone sees).
|
|
21
|
+
* `{ always: true }` is a deliberate exception to all of this: it is not a json-rules-engine
|
|
22
|
+
* `conditions` tree at all (it's short-circuited before the rules engine runs at evaluation
|
|
23
|
+
* time), and `new Rule()` rejects it
|
|
24
|
+
* ("conditions root must contain a single instance of all/any/not/condition", confirmed
|
|
25
|
+
* empirically) — so it's recognized and passed through here rather than dry-run at all.
|
|
26
|
+
* `assertRulesTree` runs before the dry-run to reject what `Rule` accepts but Pulse cannot
|
|
27
|
+
* evaluate (a named-condition reference), see its own doc.
|
|
28
|
+
* @param decisionSpec - the candidate `context.decisionSpec` — a json-rules-engine `conditions` tree, or `{ always: true }`
|
|
29
|
+
* @param queries - the workflow's resolved query set (after this action's own additions/edits) — what `fact` names may legally reference
|
|
30
|
+
* @param crossQueryTransforms - the workflow's resolved cross-query transforms, if any — what a `crossQueryOutputs` fact's path may legally reference
|
|
31
|
+
* @throws if json-rules-engine rejects the shape, or a leaf's fact/path doesn't resolve against the declared queries/crossQueryTransforms
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateDecisionSpec(decisionSpec: Record<string, unknown>, queries: AgenticQuery[], crossQueryTransforms?: CrossQueryTransform[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* Cross-checks every decisionSpec leaf that addresses a `MEASURE_KEYED_DOT_PATH_CONTAINERS`
|
|
36
|
+
* container (`current`/`previous`/`delta`/`percentChange`) by a bracket-quoted measure title
|
|
37
|
+
* (`$.percentChange["Total Revenue"]`) against whether the query it names is actually scalar.
|
|
38
|
+
* ai-integration's `buildDecisionContext` only produces that flat, column-keyed shape for a
|
|
39
|
+
* SCALAR query (no dimension grouping) — for any grouped query (required by `trendCheck`/
|
|
40
|
+
* `forecastCheck`, always grouped by a date dimension) these containers are keyed by row identity
|
|
41
|
+
* FIRST, then column name, so a flat path can never resolve. `validateDecisionSpecPaths` above
|
|
42
|
+
* doesn't catch this: it only checks the container/field NAMES exist, not whether this query's
|
|
43
|
+
* actual result shape supports addressing them flatly at all. Confirmed real, not hypothetical — a
|
|
44
|
+
* live workflow paired `trendCheck` with `diff` and referenced `$.percentChange["Total Revenue"]`
|
|
45
|
+
* exactly this way; permanently unsatisfiable, `lastEvalOutcome` stuck on `noData`.
|
|
46
|
+
*
|
|
47
|
+
* A SEPARATE function from `validateDecisionSpecPaths` (rather than folding this in) because it
|
|
48
|
+
* needs the live compiled dimension count, which only `StagedAgenticQuery.compiledQuery` carries —
|
|
49
|
+
* `validateDecisionSpecPaths` runs against the already-persisted-shape `AgenticQuery[]`, which
|
|
50
|
+
* doesn't. Same staged-vs-persisted split `validateCrossQueryTransformFieldReferences` already
|
|
51
|
+
* uses, and called from the same two sites, before `toAgenticQuery` conversion.
|
|
52
|
+
*
|
|
53
|
+
* For a genuinely scalar query, also checks the referenced title against its compiled measures —
|
|
54
|
+
* `$.percentChange["Unknown Measure"]` is exactly as permanently unresolvable as the grouped-query
|
|
55
|
+
* case above, the same "looks right, isn't" bug class SNS-133294 already fixed for
|
|
56
|
+
* `anomalyCheck.valueField`/`topNCheck.rankField`.
|
|
57
|
+
*
|
|
58
|
+
* Conservative like the two functions above: skipped when the referenced query has no live
|
|
59
|
+
* `compiledQuery` (a `persistedFallback`-only query, not touched this session) — a false negative
|
|
60
|
+
* here is the safe failure mode.
|
|
61
|
+
* @throws if a leaf addresses one of these containers by measure title on a query that is grouped
|
|
62
|
+
* by any dimension, or by a title that doesn't match any compiled measure on a scalar query
|
|
63
|
+
*/
|
|
64
|
+
export declare function validateDecisionSpecQueryShapes(decisionSpec: Record<string, unknown>, stagedQueries: StagedAgenticQuery[]): void;
|
|
65
|
+
/**
|
|
66
|
+
* Cross-checks each cross-query transform's OWN field references — `arithmetic`'s `left`/`right`
|
|
67
|
+
* dot-paths, `rankCompare`/`valueCompare`'s `keyField`/`valueField`/`rightKeyField`/
|
|
68
|
+
* `rightValueField` — against the queries they actually name. A different gap than
|
|
69
|
+
* `validateDecisionSpecPaths` above: that function checks a decisionSpec leaf reading a
|
|
70
|
+
* transform's OUTPUT; this checks the transform's own INPUT, declared on `create`/`update-spec`,
|
|
71
|
+
* by which point every prior query is already staged. Same failure class as SNS-133294's
|
|
72
|
+
* `anomalyCheck.valueField`/`topNCheck.rankField` bugs (an agent-typed field name only has to look
|
|
73
|
+
* right, not match the actual compiled title) — except left unvalidated here would surface even
|
|
74
|
+
* later: not at `define`/`redefine`, but at the workflow's first synchronous evaluation, after it
|
|
75
|
+
* already exists (`arithmeticTool`/`rankCompareTool`/`valueCompareTool` in ai-integration all throw
|
|
76
|
+
* clearly on a mismatch, just too late to stop `create` from persisting first).
|
|
77
|
+
*
|
|
78
|
+
* Conservative like `validateDecisionSpecPaths`: only checked when the referenced query has a live
|
|
79
|
+
* `compiledQuery` to check against — a `persistedFallback`-only query (not touched this session) is
|
|
80
|
+
* skipped, not rejected. A false negative here is the safe failure mode.
|
|
81
|
+
* @throws if a transform names a query not currently staged under this workflow, or a field that
|
|
82
|
+
* doesn't match that query's compiled dimension/measure titles
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateCrossQueryTransformFieldReferences(crossQueryTransforms: CrossQueryTransform[] | undefined, stagedQueries: StagedAgenticQuery[]): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { PulseAlertAction } from '../../../services/pulse/pulse-alerts-service';
|
|
2
|
+
/**
|
|
3
|
+
* A workflow's notification channels as a tool result shows them (SNS-136699): the Slack, Zapier and
|
|
4
|
+
* webhook URLs are bearer secrets (whoever holds one can post to the channel), so a result never
|
|
5
|
+
* carries them. `hasUrl` says whether one is stored.
|
|
6
|
+
*/
|
|
7
|
+
export interface VisiblePulseAlertAction {
|
|
8
|
+
feed?: boolean;
|
|
9
|
+
email?: boolean;
|
|
10
|
+
mobile?: boolean;
|
|
11
|
+
slack?: {
|
|
12
|
+
active: boolean;
|
|
13
|
+
channels: string;
|
|
14
|
+
hasUrl: boolean;
|
|
15
|
+
};
|
|
16
|
+
zapier?: {
|
|
17
|
+
active: boolean;
|
|
18
|
+
hasUrl: boolean;
|
|
19
|
+
};
|
|
20
|
+
webhooks?: Array<{
|
|
21
|
+
name: string;
|
|
22
|
+
active: boolean;
|
|
23
|
+
hasUrl: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/** Drops every webhook URL from a workflow's `action` before it goes into a tool result. */
|
|
27
|
+
export declare function redactNotificationUrls(action: PulseAlertAction): VisiblePulseAlertAction;
|
|
28
|
+
/** The URL-bearing channel changes `update-workflow` takes; `url` is optional since results hide it. */
|
|
29
|
+
export interface NotificationUrlChanges {
|
|
30
|
+
slack?: {
|
|
31
|
+
active: boolean;
|
|
32
|
+
url?: string;
|
|
33
|
+
channels?: string;
|
|
34
|
+
};
|
|
35
|
+
zapier?: {
|
|
36
|
+
active: boolean;
|
|
37
|
+
url?: string;
|
|
38
|
+
};
|
|
39
|
+
webhooks?: Array<{
|
|
40
|
+
name: string;
|
|
41
|
+
url?: string;
|
|
42
|
+
active: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Fills each omitted or empty `url` from the stored workflow, so the model can toggle a channel or keep a
|
|
47
|
+
* webhook without ever seeing its URL. vnext needs `slack`/`zapier` as whole objects (see
|
|
48
|
+
* `PulseAlertAction`), so this returns them complete. An active channel with no URL either way is
|
|
49
|
+
* an adjustment error: only the user can supply it. So is a webhook sent without a URL whose name
|
|
50
|
+
* more than one stored webhook shares, since vnext does not keep names unique.
|
|
51
|
+
*/
|
|
52
|
+
export declare function mergeNotificationUrls(changes: NotificationUrlChanges, current: PulseAlertAction | undefined): Pick<PulseAlertAction, 'slack' | 'zapier' | 'webhooks'>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AuthorPulseContext, CompiledQueryWithJSON, QueryTransform } from '../types';
|
|
2
|
+
import { PulseRangeSuggestion } from './pulse-signature';
|
|
3
|
+
export declare const PULSE_KNOWLEDGE_TIMEOUT_MS = 3000;
|
|
4
|
+
export declare const PULSE_KNOWLEDGE_MAX_MEASURES = 3;
|
|
5
|
+
export declare const PULSE_KNOWLEDGE_MAX_CANDIDATES = 3;
|
|
6
|
+
/** What the knowledge layer knows about one measure of the alert's query. Anonymous by construction. */
|
|
7
|
+
export interface PulseMeasureKnowledge {
|
|
8
|
+
measure: string;
|
|
9
|
+
watched?: {
|
|
10
|
+
alertCount: number;
|
|
11
|
+
};
|
|
12
|
+
columnKpi?: {
|
|
13
|
+
column: string;
|
|
14
|
+
agg: string;
|
|
15
|
+
};
|
|
16
|
+
kpiCandidates?: Array<{
|
|
17
|
+
title: string;
|
|
18
|
+
alertCount: number;
|
|
19
|
+
}>;
|
|
20
|
+
suggestedRanges?: PulseRangeSuggestion[];
|
|
21
|
+
filteredBy?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface PulseKnowledge {
|
|
24
|
+
measures: PulseMeasureKnowledge[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pulse authoring hook (SNS-131459 §6.3): what the knowledge layer's Pulse layer knows about the
|
|
28
|
+
* query's measures — watched formulas, plain-aggregate column KPIs, and company ranges that match
|
|
29
|
+
* the query's period and baseline. Measures are looked up in parallel and a failing one drops
|
|
30
|
+
* only itself. Never rejects: a 3 s timeout, or no measure with knowledge, gives `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function lookupPulseKnowledge(input: {
|
|
33
|
+
sourceId: string;
|
|
34
|
+
compiledQuery: CompiledQueryWithJSON;
|
|
35
|
+
transforms?: QueryTransform[];
|
|
36
|
+
}, context: Pick<AuthorPulseContext, 'httpClient'>): Promise<PulseKnowledge | undefined>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { JaqlQueryPayload } from '@sisense/sdk-query-client';
|
|
2
|
+
import { DmKpi, DmWatched } from '../../../services/datamodel-graph/datamodel-graph-service';
|
|
3
|
+
/**
|
|
4
|
+
* What a query measures, as far as Pulse watch matching needs (SNS-131459 Pulse layer §4):
|
|
5
|
+
* its non-date filter columns and the period one value covers. `period` is computed exactly as
|
|
6
|
+
* ai-integration's `pulseJaql.periodOf` computes it for an alert's watched query, so a query and a
|
|
7
|
+
* watch on the same JAQL always agree.
|
|
8
|
+
*/
|
|
9
|
+
export interface QuerySignature {
|
|
10
|
+
filterColumns: string[];
|
|
11
|
+
period: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PlainAggregate {
|
|
14
|
+
column: string;
|
|
15
|
+
agg: string;
|
|
16
|
+
}
|
|
17
|
+
/** A company range offered while authoring (an offer, never applied silently). */
|
|
18
|
+
export interface PulseRangeSuggestion {
|
|
19
|
+
thresholdKind: 'level' | 'change_pct';
|
|
20
|
+
direction: 'above' | 'below';
|
|
21
|
+
period: string;
|
|
22
|
+
baseline: string | null;
|
|
23
|
+
alertCount: number;
|
|
24
|
+
min: number;
|
|
25
|
+
max: number;
|
|
26
|
+
median: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function deriveQuerySignature(jaql: JaqlQueryPayload): QuerySignature;
|
|
29
|
+
/** Equal periods match, and a "7 days" total matches a `week` watch (§4); `custom` never matches. */
|
|
30
|
+
export declare function samePeriod(a: string, b: string): boolean;
|
|
31
|
+
/** `{ column: "Table.column", agg }` for a plain aggregate measure item; null for a formula. */
|
|
32
|
+
export declare function plainAggregateOf(measureItem: unknown): PlainAggregate | null;
|
|
33
|
+
export declare function matchesColumnKpi(kpi: DmKpi, aggregate: PlainAggregate): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The watches that may be offered for a query with this signature: unfiltered `level` watches, or
|
|
36
|
+
* `change_pct` watches whose baseline equals the query's `diff` baseline, of the same period, only
|
|
37
|
+
* when the query itself has no non-date filter (§4, §6.2). Server order (most alerts first) is kept.
|
|
38
|
+
*/
|
|
39
|
+
export declare function matchWatches(watched: DmWatched, signature: QuerySignature, diffBaseline: string | null): PulseRangeSuggestion[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AuthorPulseContext, WorkflowFrequency, WorkflowFrequencyInput } from '../types';
|
|
2
|
+
/** A frequency the engine can persist: interval as given, or cron with its zone settled and the expression validated. */
|
|
3
|
+
export interface ResolvedFrequency {
|
|
4
|
+
frequency: WorkflowFrequency;
|
|
5
|
+
/** Calendar schedule only (always set for one — the preview contract requires it): the scheduler's own first upcoming occurrence (ISO). */
|
|
6
|
+
nextCheck?: string;
|
|
7
|
+
/** `nextCheck` spelled out in the schedule's zone (see `describeNextCheck`). */
|
|
8
|
+
nextCheckText?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A calendar schedule's next check as the model should say it: weekday, date and 24h time in the
|
|
12
|
+
* schedule's `timeZone`, e.g. "Wednesday, October 14, 2026 at 08:00 (Europe/Kyiv)". Given only the
|
|
13
|
+
* ISO instant, the model kept naming the wrong weekday (SNS-134939). `undefined` for an unparsable
|
|
14
|
+
* instant; an unknown zone falls back to UTC rather than dropping the text.
|
|
15
|
+
*/
|
|
16
|
+
export declare function describeNextCheck(nextCheck: string, timeZone: string): string | undefined;
|
|
17
|
+
/** Turns the model's `frequency` into what gets persisted: interval checked against the administrator floor; cron zone-resolved and validated against vnext's preview route. */
|
|
18
|
+
export declare function resolveFrequency(frequency: WorkflowFrequencyInput, context: Pick<AuthorPulseContext, 'httpClient' | 'defaultTimeZone'>): Promise<ResolvedFrequency>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AgenticQuery, AgenticQueryDefinition, AuthorPulseContext, StagedAgenticWorkflow, StagedAgenticQuery, StagedQuerySummary } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Rebuilds one `StagedAgenticQuery` from a query exactly as persisted on vnext — the one place a
|
|
4
|
+
* `load-existing`d workflow's queries get staged. New-format `csdkJSON` deserializes to a live
|
|
5
|
+
* `ExecuteQueryParams` object; `queryJSON` is then re-derived fresh via `translateQueryToJSON`
|
|
6
|
+
* rather than trusted from storage — `csdkJSON` itself never carries a `queryJSON` copy (see
|
|
7
|
+
* `toAgenticQuery`'s own doc for why: it's cheap to recompute, and storing it risks a stale/buggy
|
|
8
|
+
* snapshot outliving the bug that produced it, as `collapseMeasuresForJSON`'s SNS-133319
|
|
9
|
+
* trend/forecast-dropping bug did). A missing `csdkJSON`, or a deserialization or re-translation
|
|
10
|
+
* failure (an incompatible/corrupted blob, or a live object `translateQueryToJSON` can't
|
|
11
|
+
* translate), degrades to `persistedFallback` — carried through unchanged — rather than failing
|
|
12
|
+
* `load-existing` outright for the whole workflow.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stageQueryFromPersisted(query: AgenticQuery): StagedAgenticQuery;
|
|
15
|
+
/**
|
|
16
|
+
* Derives the persistence shape (`jaql`+`csdkJSON`) for one staged query — freshly, from its live
|
|
17
|
+
* `compiledQuery` when this session compiled/recompiled it (`translateQueryToJaql` is the exact
|
|
18
|
+
* function real query execution already calls to produce jaql, and `CustomSuperJSON.serialize()`
|
|
19
|
+
* needs no external schema either — see the SNS-133294 design doc), or carried through verbatim
|
|
20
|
+
* from `persistedFallback` when it wasn't touched this session. `queryJSON` is deliberately
|
|
21
|
+
* stripped before serializing — it's cheap to recompute (`stageQueryFromPersisted` re-derives it
|
|
22
|
+
* via `translateQueryToJSON` on the way back in), so persisting it too would just duplicate the
|
|
23
|
+
* same structure inside `csdkJSON` for no functional gain, and let a stale/buggy snapshot survive
|
|
24
|
+
* a downstream fix instead of self-healing on next read.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toAgenticQuery(staged: StagedAgenticQuery): AgenticQuery;
|
|
27
|
+
/**
|
|
28
|
+
* Agent-facing view of one staged query — `queryJSON`, never `jaql`/raw `csdkJSON`. When
|
|
29
|
+
* `queryJSON` can't be resolved (no compiled query: `stageQueryFromPersisted` couldn't rebuild
|
|
30
|
+
* one), `queryJSONUnavailableReason` is `'corrupted'` — see `StagedQuerySummary`'s own doc.
|
|
31
|
+
*/
|
|
32
|
+
export declare function toStagedQuerySummary(staged: StagedAgenticQuery): StagedQuerySummary;
|
|
33
|
+
/**
|
|
34
|
+
* Host-facing live definitions of the staged queries that have one (`compiledQuery`); a query
|
|
35
|
+
* that couldn't be rebuilt is left out, so a host shows it by name and purpose alone. `queryJSON`
|
|
36
|
+
* is stripped: it's plain JSON the summary already carries, not part of the live definition.
|
|
37
|
+
*/
|
|
38
|
+
export declare function toQueryDefinitions(staged: StagedAgenticQuery[]): AgenticQueryDefinition[];
|
|
39
|
+
/**
|
|
40
|
+
* `retrieveAgenticWorkflow` for an `workflowId` that must already be staged — `define`/`redefine`/
|
|
41
|
+
* `create`/`update-spec` all read exclusively from staging, never the live workflow (only
|
|
42
|
+
* `load-existing`/`update-workflow` do that). Mirrors `buildDashboard`'s `add-charts`/`replace-charts`
|
|
43
|
+
* refusing to silently fall back to Fusion — a missing staging entry is always a real error here,
|
|
44
|
+
* not something to paper over.
|
|
45
|
+
*
|
|
46
|
+
* Transparently follows a `redirectTo` (the stale draft key `create` leaves behind pointing at the
|
|
47
|
+
* real `workflowId` it re-staged under, MR !1027 finding #2d) — always exactly one hop, see
|
|
48
|
+
* `StagedAgenticWorkflow.redirectTo`'s own doc. Callers that mutate/re-save staged state MUST save
|
|
49
|
+
* (and return) under the RESOLVED `StagedAgenticWorkflow.workflowId`, not the `workflowId` parameter passed
|
|
50
|
+
* in here, or a subsequent write through the stale id defeats the redirect.
|
|
51
|
+
*
|
|
52
|
+
* `expectedKind`, when given, rejects a `kind` mismatch: `'draft'` for `create` (already-persisted
|
|
53
|
+
* would duplicate the workflow, findings #2a/#2b), `'persisted'` for `update-spec` (a PATCH against a
|
|
54
|
+
* never-`create`d draft id would otherwise 404 on vnext with a confusing "not found" error, finding
|
|
55
|
+
* #2c). `define`/`redefine` pass no `expectedKind` — both are valid on either kind.
|
|
56
|
+
* @throws if nothing is staged under `workflowId` (after following any redirect), or if `expectedKind`
|
|
57
|
+
* is given and doesn't match the resolved entry's `kind`
|
|
58
|
+
*/
|
|
59
|
+
export declare function requireStagedWorkflow(context: AuthorPulseContext, workflowId: string, actionType: string, expectedKind?: 'draft' | 'persisted'): StagedAgenticWorkflow;
|
|
60
|
+
/**
|
|
61
|
+
* The staged queries left after dropping `removedQueryNames` — `create`'s and `update-spec`'s one
|
|
62
|
+
* lever on the query set (SNS-134369).
|
|
63
|
+
* @throws if a name isn't staged, or if removing them would leave no query
|
|
64
|
+
*/
|
|
65
|
+
export declare function withoutRemovedQueries(staged: StagedAgenticWorkflow, removedQueryNames: string[] | undefined, actionType: 'create' | 'update-spec'): StagedAgenticQuery[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PulseAlertDto } from '../../../services/pulse/pulse-events-service';
|
|
2
|
+
/**
|
|
3
|
+
* Whether `currentUserId` owns `workflow` — `undefined` when either side is unknown (a host that
|
|
4
|
+
* doesn't supply the caller's id, or a workflow doc without `owner`), so callers never treat
|
|
5
|
+
* "can't tell" as "not the owner". Shared by `authorPulse` (write pre-checks) and `inspectPulse`
|
|
6
|
+
* (`isOwner` on every workflow it returns).
|
|
7
|
+
*/
|
|
8
|
+
export declare function isWorkflowOwner(workflow: Pick<PulseAlertDto, 'owner'>, currentUserId: string | undefined): boolean | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Fails an owner-only write BEFORE it reaches vnext, which would otherwise answer a non-owner with
|
|
11
|
+
* the same bare 404 it uses for a deleted alert. Points at the one change a non-owner recipient
|
|
12
|
+
* can still make.
|
|
13
|
+
*/
|
|
14
|
+
export declare function assertCallerOwnsWorkflow(workflow: Pick<PulseAlertDto, 'owner' | 'name'>, currentUserId: string | undefined): void;
|