@gooddata/sdk-ui-catalog 11.68.0-alpha.2 → 11.68.0-alpha.3
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/LICENSE +26 -4
- package/NOTICE +69386 -0
- package/README.md +1 -1
- package/esm/asCode/AsCodeDialog.d.ts.map +1 -1
- package/esm/asCode/AsCodeDialog.js +7 -5
- package/esm/asCode/AsCodeEditorBody.d.ts +6 -6
- package/esm/asCode/AsCodeEditorBody.d.ts.map +1 -1
- package/esm/asCode/AsCodeEditorBody.js +13 -6
- package/esm/asCode/descriptor.d.ts +23 -2
- package/esm/asCode/descriptor.d.ts.map +1 -1
- package/esm/asCode/descriptor.js +8 -0
- package/esm/asCode/keyCompletions.d.ts +12 -0
- package/esm/asCode/keyCompletions.d.ts.map +1 -0
- package/esm/asCode/keyCompletions.js +58 -0
- package/esm/asCode/schemaKeys.d.ts +13 -0
- package/esm/asCode/schemaKeys.d.ts.map +1 -0
- package/esm/asCode/schemaKeys.js +45 -0
- package/esm/asCode/validateYaml.d.ts +28 -25
- package/esm/asCode/validateYaml.d.ts.map +1 -1
- package/esm/asCode/validateYaml.js +34 -11
- package/esm/catalogDetail/hooks/useCatalogItemUpdate.d.ts.map +1 -1
- package/esm/catalogDetail/hooks/useCatalogItemUpdate.js +2 -2
- package/esm/computedAttribute/computedAttributeCompletions.d.ts +1 -7
- package/esm/computedAttribute/computedAttributeCompletions.d.ts.map +1 -1
- package/esm/computedAttribute/computedAttributeCompletions.js +2 -19
- package/esm/computedAttribute/computedAttributeDescriptor.d.ts.map +1 -1
- package/esm/computedAttribute/computedAttributeDescriptor.js +2 -2
- package/esm/computedAttribute/computedAttributeSchema.d.ts +2 -6
- package/esm/computedAttribute/computedAttributeSchema.d.ts.map +1 -1
- package/esm/computedAttribute/computedAttributeSchema.js +2 -8
- package/esm/computedAttribute/computedAttributeValidation.d.ts +3 -3
- package/esm/computedAttribute/computedAttributeValidation.d.ts.map +1 -1
- package/esm/computedAttribute/computedAttributeValidation.js +32 -44
- package/esm/filter/FilterContext.d.ts.map +1 -1
- package/esm/filter/FilterContext.js +9 -9
- package/esm/filter/StaticFilter.js +3 -3
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/localization/bundles/en-US.localization-bundle.js +4 -4
- package/esm/metric/metricCompletions.d.ts +1 -7
- package/esm/metric/metricCompletions.d.ts.map +1 -1
- package/esm/metric/metricCompletions.js +2 -16
- package/esm/metric/metricDescriptor.d.ts.map +1 -1
- package/esm/metric/metricDescriptor.js +2 -2
- package/esm/metric/metricSchema.d.ts +2 -6
- package/esm/metric/metricSchema.d.ts.map +1 -1
- package/esm/metric/metricSchema.js +2 -8
- package/esm/metric/metricValidation.d.ts +3 -3
- package/esm/metric/metricValidation.d.ts.map +1 -1
- package/esm/metric/metricValidation.js +12 -18
- package/esm/parameter/parameterCompletions.d.ts.map +1 -1
- package/esm/parameter/parameterCompletions.js +19 -6
- package/esm/parameter/parameterDescriptor.d.ts.map +1 -1
- package/esm/parameter/parameterDescriptor.js +5 -8
- package/esm/parameter/parameterSchema.d.ts +2 -7
- package/esm/parameter/parameterSchema.d.ts.map +1 -1
- package/esm/parameter/parameterSchema.js +1 -40
- package/esm/parameter/parameterValidation.d.ts +3 -2
- package/esm/parameter/parameterValidation.d.ts.map +1 -1
- package/esm/parameter/parameterValidation.js +26 -36
- package/esm/sdk-ui-catalog.d.ts +19 -2
- package/package.json +18 -17
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsCodeDialog.d.ts","sourceRoot":"","sources":["../../src/asCode/AsCodeDialog.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGR,iBAAiB,EAGpB,MAAM,iBAAiB,CAAC;AA8BzB,KAAK,UAAU,GAAG;IACd,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,WAAW,CAAC,EA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CAAC;IAAC,eAAe,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,UAAU,CAAC,GAC9D,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAAC,GACxD;IACI;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,CAAC;CACvB,CACN,CAAC;AAQF,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,2CA4OxC"}
|
|
@@ -3,7 +3,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { FormattedMessage, defineMessages, useIntl } from "react-intl";
|
|
5
5
|
import { LoadingComponent } from "@gooddata/sdk-ui";
|
|
6
|
-
import { ConfirmDialog, UiButton, UiIcon, UiLink, UiTooltip } from "@gooddata/sdk-ui-kit";
|
|
6
|
+
import { ConfirmDialog, UiButton, UiIcon, UiLink, UiTooltip, isApplePlatform } from "@gooddata/sdk-ui-kit";
|
|
7
7
|
import { useIsWhiteLabeled } from "../permission/PermissionsContext.js";
|
|
8
8
|
import { extractBackendErrorDetail } from "../utils/backendError.js";
|
|
9
9
|
import { useAsCodeLoadFailure } from "./useAsCodeLoadFailure.js";
|
|
@@ -80,6 +80,7 @@ export function AsCodeDialog(props) {
|
|
|
80
80
|
onClose();
|
|
81
81
|
}
|
|
82
82
|
}, [isSubmitting, onClose]);
|
|
83
|
+
const validationContext = useMemo(() => (mode === "edit" ? { intent: "edit", fixedIdentifier } : { intent: "create" }), [mode, fixedIdentifier]);
|
|
83
84
|
const handleChange = useCallback((nextValue) => {
|
|
84
85
|
yamlValue.current = nextValue;
|
|
85
86
|
setIsDirty(true);
|
|
@@ -94,8 +95,7 @@ export function AsCodeDialog(props) {
|
|
|
94
95
|
if (!editing || initialYaml === null || !onSubmit) {
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
|
-
const
|
|
98
|
-
const result = editing.validate(yamlValue.current ?? initialYaml, context);
|
|
98
|
+
const result = editing.validate(yamlValue.current ?? initialYaml, validationContext);
|
|
99
99
|
if (!result.isValid) {
|
|
100
100
|
setValidationError(result.error);
|
|
101
101
|
return;
|
|
@@ -112,7 +112,7 @@ export function AsCodeDialog(props) {
|
|
|
112
112
|
finally {
|
|
113
113
|
setIsSubmitting(false);
|
|
114
114
|
}
|
|
115
|
-
}, [descriptor, editing,
|
|
115
|
+
}, [descriptor, editing, initialYaml, intl, onSubmit, reconcileWithBase, validationContext]);
|
|
116
116
|
const handleDuplicate = useCallback(() => {
|
|
117
117
|
if (!onDuplicate || !editing || initialYaml === null) {
|
|
118
118
|
return;
|
|
@@ -141,5 +141,7 @@ export function AsCodeDialog(props) {
|
|
|
141
141
|
return (_jsx(ConfirmDialog, { className: "gd-ascode-dialog", containerClassName: "gd-ascode-dialog-overlay", headline: headlineMessage, cancelButtonText: cancelMessage, submitButtonText: submitMessage, isPositive: true, hideSubmitButton: isView, isSubmitDisabled: isSubmitting || loading || isBaseUnrepresentable || (isEdit && !isDirty), isCancelDisabled: isSubmitting, shouldCloseOnEscape: !isSubmitting,
|
|
142
142
|
// The body is a multi-line code editor, so Enter inserts a line break there. Without this
|
|
143
143
|
// the dialog treats the editor's contenteditable as a text input and saves on Enter.
|
|
144
|
-
submitOnEnterKey: false, onCancel: handleClose, onClose: handleClose, onSubmit: handleSubmit, displayCloseButton: !isSubmitting, footerLeftRenderer: isView ? undefined : footerLeftRenderer, children: _jsx("div", { className: "gd-ascode-dialog-content", children: _jsx(Suspense, { fallback: bodySpinner, children: loading ? (bodySpinner) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "gd-ascode-dialog-section-header", children: [intl.formatMessage(descriptor.messages.sectionHeader), _jsx(UiTooltip, { arrowPlacement: "top", optimalPlacement: true, triggerBy: ["hover", "click", "focus"], anchor: _jsx(UiIcon, { type: "question", size: 14, color: "complementary-6" }), content: intl.formatMessage(descriptor.messages.sectionHeaderTooltip
|
|
144
|
+
submitOnEnterKey: false, onCancel: handleClose, onClose: handleClose, onSubmit: handleSubmit, displayCloseButton: !isSubmitting, footerLeftRenderer: isView ? undefined : footerLeftRenderer, children: _jsx("div", { className: "gd-ascode-dialog-content", children: _jsx(Suspense, { fallback: bodySpinner, children: loading ? (bodySpinner) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "gd-ascode-dialog-section-header", children: [intl.formatMessage(descriptor.messages.sectionHeader), _jsx(UiTooltip, { arrowPlacement: "top", optimalPlacement: true, triggerBy: ["hover", "click", "focus"], anchor: _jsx(UiIcon, { type: "question", size: 14, color: "complementary-6" }), content: intl.formatMessage(descriptor.messages.sectionHeaderTooltip, {
|
|
145
|
+
platform: isApplePlatform() ? "apple" : "other",
|
|
146
|
+
}) })] }), isBaseUnrepresentable ? (_jsx("div", { className: "gd-ascode-dialog-notice", children: intl.formatMessage(messages.unrepresentable) })) : null, _jsx("div", { className: "gd-ascode-dialog-editor", children: _jsx(AsCodeEditorBody, { readOnly: isView, initialValue: initialYaml, label: intl.formatMessage(descriptor.messages.sectionHeader), onChange: handleChange, disabled: isSubmitting || isBaseUnrepresentable, editing: editing, validationContext: validationContext }) }), validationError || submitError ? (_jsxs("div", { className: "gd-ascode-dialog-error", children: [_jsx("span", { className: "gd-ascode-dialog-error-label", children: _jsx(FormattedMessage, { id: "analyticsCatalog.dialog.error.label" }) }), " ", validationError ?? submitError] })) : null] })) }) }) }));
|
|
145
147
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AsCodeValidationContext, IAsCodeEditing } from "./descriptor.js";
|
|
2
2
|
type Props = {
|
|
3
3
|
initialValue: string;
|
|
4
4
|
onChange: (value: string) => void;
|
|
5
5
|
disabled: boolean;
|
|
6
6
|
readOnly?: boolean;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
editing: IAsCodeEditing<unknown>;
|
|
8
|
+
validationContext: AsCodeValidationContext;
|
|
9
9
|
/** Accessible name for the editor; the dialog derives it from the entity's section header. */
|
|
10
10
|
label: string;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* The editor half of {@link AsCodeDialog}, split into its own module so the dialog can `lazy()`-load
|
|
14
|
-
* it: this keeps CodeMirror out of the eager catalog bundle. The completion source
|
|
15
|
-
* copy come from the entity's descriptor, so this stays entity-agnostic.
|
|
14
|
+
* it: this keeps CodeMirror out of the eager catalog bundle. The completion source,
|
|
15
|
+
* validation and syntax-error copy come from the entity's descriptor, so this stays entity-agnostic.
|
|
16
16
|
*
|
|
17
17
|
* YAML is both the only language on offer and the primary one, so the kit editor never converts
|
|
18
18
|
* anything: the text the user sees — comments, formatting and all — is exactly what `onChange`
|
|
19
19
|
* reports. The dialog reads the current value from `onChange` and never drives the value back in,
|
|
20
20
|
* which the local state here preserves.
|
|
21
21
|
*/
|
|
22
|
-
export declare function AsCodeEditorBody({ initialValue, onChange, disabled, readOnly,
|
|
22
|
+
export declare function AsCodeEditorBody({ initialValue, onChange, disabled, readOnly, editing, validationContext, label, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
export {};
|
|
24
24
|
//# sourceMappingURL=AsCodeEditorBody.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsCodeEditorBody.d.ts","sourceRoot":"","sources":["../../src/asCode/AsCodeEditorBody.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AsCodeEditorBody.d.ts","sourceRoot":"","sources":["../../src/asCode/AsCodeEditorBody.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAoB,uBAAuB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMjG,KAAK,KAAK,GAAG;IACT,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAC7B,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,KAAK,GACR,EAAE,KAAK,2CA6BP"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2026 GoodData Corporation
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
4
|
import { defineMessages, useIntl } from "react-intl";
|
|
5
5
|
import { UiConfigEditor } from "@gooddata/sdk-ui-kit";
|
|
6
6
|
const messages = defineMessages({
|
|
@@ -8,22 +8,29 @@ const messages = defineMessages({
|
|
|
8
8
|
});
|
|
9
9
|
/**
|
|
10
10
|
* The editor half of {@link AsCodeDialog}, split into its own module so the dialog can `lazy()`-load
|
|
11
|
-
* it: this keeps CodeMirror out of the eager catalog bundle. The completion source
|
|
12
|
-
* copy come from the entity's descriptor, so this stays entity-agnostic.
|
|
11
|
+
* it: this keeps CodeMirror out of the eager catalog bundle. The completion source,
|
|
12
|
+
* validation and syntax-error copy come from the entity's descriptor, so this stays entity-agnostic.
|
|
13
13
|
*
|
|
14
14
|
* YAML is both the only language on offer and the primary one, so the kit editor never converts
|
|
15
15
|
* anything: the text the user sees — comments, formatting and all — is exactly what `onChange`
|
|
16
16
|
* reports. The dialog reads the current value from `onChange` and never drives the value back in,
|
|
17
17
|
* which the local state here preserves.
|
|
18
18
|
*/
|
|
19
|
-
export function AsCodeEditorBody({ initialValue, onChange, disabled, readOnly,
|
|
19
|
+
export function AsCodeEditorBody({ initialValue, onChange, disabled, readOnly, editing, validationContext, label, }) {
|
|
20
20
|
const intl = useIntl();
|
|
21
21
|
const [value, setValue] = useState(initialValue);
|
|
22
|
+
// A read-only view has no typing to guide, and its document may predate a narrower feature gate.
|
|
23
|
+
const diagnostics = useMemo(() => (readOnly ? [] : inlineDiagnostics(editing.validate(value, validationContext))), [editing, readOnly, validationContext, value]);
|
|
22
24
|
return (_jsx(UiConfigEditor, { value: value, onChange: (next) => {
|
|
23
25
|
setValue(next);
|
|
24
26
|
onChange(next);
|
|
25
|
-
}, primaryLanguage: "yaml", languages: ["yaml"], completionSource: completionSource, label: label, disabled: disabled, readOnly: readOnly, labels: {
|
|
27
|
+
}, primaryLanguage: "yaml", languages: ["yaml"], completionSource: editing.completionSource, diagnostics: diagnostics, label: label, disabled: disabled, readOnly: readOnly, labels: {
|
|
26
28
|
autoFormat: intl.formatMessage(messages.autoFormat),
|
|
27
|
-
syntaxError: syntaxErrorMessage,
|
|
29
|
+
syntaxError: editing.syntaxErrorMessage,
|
|
28
30
|
} }));
|
|
29
31
|
}
|
|
32
|
+
function inlineDiagnostics(result) {
|
|
33
|
+
return result.isValid || result.path === undefined
|
|
34
|
+
? []
|
|
35
|
+
: [{ path: result.path, target: result.target, severity: "error", message: result.error }];
|
|
36
|
+
}
|
|
@@ -6,6 +6,11 @@ import type { ICatalogItem, ICatalogItemRef } from "../catalogItem/types.js";
|
|
|
6
6
|
import type { ObjectTypes } from "../objectType/constants.js";
|
|
7
7
|
import type { ObjectType } from "../objectType/types.js";
|
|
8
8
|
import type { useFeatureFlag } from "../permission/PermissionsContext.js";
|
|
9
|
+
/**
|
|
10
|
+
* Where a value sits in the document, as object keys and array indexes.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export type AsCodeDocumentPath = ReadonlyArray<string | number>;
|
|
9
14
|
export type AsCodeFeatureFlag = Parameters<typeof useFeatureFlag>[0];
|
|
10
15
|
export type AsCodeObjectType = typeof ObjectTypes.METRIC | typeof ObjectTypes.PARAMETER | typeof ObjectTypes.COMPUTED_ATTRIBUTE | typeof ObjectTypes.VISUALIZATION;
|
|
11
16
|
export interface IAsCodeMessages {
|
|
@@ -26,14 +31,24 @@ export interface IAsCodeMessages {
|
|
|
26
31
|
deleteSuccess: MessageDescriptor;
|
|
27
32
|
deleteError: MessageDescriptor;
|
|
28
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The field a failure marks in the editor: the value at `path`, or with `target: "key"` the key that
|
|
36
|
+
* names it, as for an unknown key. A failure without a path (empty or malformed document) has nothing
|
|
37
|
+
* to mark and shows only as a banner.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export type AsCodeFieldMark = {
|
|
41
|
+
path?: AsCodeDocumentPath;
|
|
42
|
+
target?: "key";
|
|
43
|
+
};
|
|
29
44
|
/** @internal */
|
|
30
45
|
export type AsCodeValidation<TDef> = {
|
|
31
46
|
isValid: true;
|
|
32
47
|
definition: TDef;
|
|
33
|
-
} | {
|
|
48
|
+
} | ({
|
|
34
49
|
isValid: false;
|
|
35
50
|
error: string;
|
|
36
|
-
};
|
|
51
|
+
} & AsCodeFieldMark);
|
|
37
52
|
/**
|
|
38
53
|
* Identity rule per flow: `edit` keeps `fixedIdentifier`; `duplicate` accepts and ignores any id (the
|
|
39
54
|
* copy re-derives identity downstream); `create` applies the entity's own id policy.
|
|
@@ -47,6 +62,12 @@ export type AsCodeValidationContext = {
|
|
|
47
62
|
} | {
|
|
48
63
|
intent: "duplicate";
|
|
49
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* The failure of {@link IAsCodeEditing.validate} for a failed per-type validation and its localized
|
|
67
|
+
* message.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare function toAsCodeFailure(failure: AsCodeFieldMark, error: string): AsCodeValidation<never>;
|
|
50
71
|
/** @internal */
|
|
51
72
|
export declare function fixedIdentifierOf(context: AsCodeValidationContext): string | undefined;
|
|
52
73
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../src/asCode/descriptor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAErE,MAAM,MAAM,gBAAgB,GACtB,OAAO,WAAW,CAAC,MAAM,GACzB,OAAO,WAAW,CAAC,SAAS,GAC5B,OAAO,WAAW,CAAC,kBAAkB,GACrC,OAAO,WAAW,CAAC,aAAa,CAAC;AAEvC,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,iBAAiB,CAAC;IAC/B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,iBAAiB,CAAC;IACjC,oBAAoB,EAAE,iBAAiB,CA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
|
3
|
+
* The failure of {@link IAsCodeEditing.validate} for a failed per-type validation and its localized
|
|
4
|
+
* message.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export function toAsCodeFailure(failure, error) {
|
|
8
|
+
return { isValid: false, error, path: failure.path, target: failure.target };
|
|
9
|
+
}
|
|
2
10
|
/** @internal */
|
|
3
11
|
export function fixedIdentifierOf(context) {
|
|
4
12
|
return context.intent === "edit" ? context.fixedIdentifier : undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Completion, type CompletionContext, type CompletionResult } from "@codemirror/autocomplete";
|
|
2
|
+
/**
|
|
3
|
+
* A completion source for a flat mapping: it offers the keys at column zero only, since an indented
|
|
4
|
+
* line sits inside a sequence value (e.g. under `tags:`), where those keys must not be offered.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createFlatKeyCompletions(keys: string[]): (context: CompletionContext) => CompletionResult | null;
|
|
7
|
+
/**
|
|
8
|
+
* The result's own `to` stays at the caret because the popup filters options by the text between
|
|
9
|
+
* `from` and `to`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function replacingKey(option: Completion): Completion;
|
|
12
|
+
//# sourceMappingURL=keyCompletions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyCompletions.d.ts","sourceRoot":"","sources":["../../src/asCode/keyCompletions.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAExB,MAAM,0BAA0B,CAAC;AAGlC;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,aAGV,iBAAiB,KAAG,gBAAgB,GAAG,IAAI,CAavF;AAgBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAc3D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { insertCompletionText, } from "@codemirror/autocomplete";
|
|
3
|
+
/**
|
|
4
|
+
* A completion source for a flat mapping: it offers the keys at column zero only, since an indented
|
|
5
|
+
* line sits inside a sequence value (e.g. under `tags:`), where those keys must not be offered.
|
|
6
|
+
*/
|
|
7
|
+
export function createFlatKeyCompletions(keys) {
|
|
8
|
+
const options = keys.map((label) => replacingKey({ label, type: "property", apply: `${label}: ` }));
|
|
9
|
+
return function completeFlatKey(context) {
|
|
10
|
+
const line = context.state.doc.lineAt(context.pos);
|
|
11
|
+
const before = line.text.slice(0, context.pos - line.from);
|
|
12
|
+
const match = before.match(/^(\w*)$/);
|
|
13
|
+
if (!match) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const present = presentTopLevelKeys(context.state.doc, line.number);
|
|
17
|
+
return {
|
|
18
|
+
from: context.pos - match[1].length,
|
|
19
|
+
options: options.filter((option) => !present.has(option.label)),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function presentTopLevelKeys(doc, exceptLine) {
|
|
24
|
+
const keys = new Set();
|
|
25
|
+
for (let number = 1; number <= doc.lines; number++) {
|
|
26
|
+
if (number === exceptLine) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const key = /^(\w+):/.exec(doc.line(number).text)?.[1];
|
|
30
|
+
if (key !== undefined) {
|
|
31
|
+
keys.add(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return keys;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The result's own `to` stays at the caret because the popup filters options by the text between
|
|
38
|
+
* `from` and `to`.
|
|
39
|
+
*/
|
|
40
|
+
export function replacingKey(option) {
|
|
41
|
+
return {
|
|
42
|
+
...option,
|
|
43
|
+
apply(view, completion, from, to) {
|
|
44
|
+
const end = keyReplacementEnd(view.state, to);
|
|
45
|
+
const apply = view.state.sliceDoc(end, end + 1) === ":" ? option.label : (option.apply ?? option.label);
|
|
46
|
+
if (typeof apply === "string") {
|
|
47
|
+
view.dispatch(view.state.update(insertCompletionText(view.state, apply, from, end)));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
apply(view, completion, from, end);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function keyReplacementEnd(state, pos) {
|
|
56
|
+
const line = state.doc.lineAt(pos);
|
|
57
|
+
return pos + (/^\w*/.exec(line.text.slice(pos - line.from))?.[0].length ?? 0);
|
|
58
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as z from "zod/mini";
|
|
2
|
+
/**
|
|
3
|
+
* Child keys reachable under a parent key: directly in its mapping, or inside each item of its
|
|
4
|
+
* sequence. A sequence of scalars has no keys.
|
|
5
|
+
*/
|
|
6
|
+
export type SchemaKeysEntry = {
|
|
7
|
+
kind: "mapping" | "sequence";
|
|
8
|
+
keys: string[];
|
|
9
|
+
};
|
|
10
|
+
/** Parent key → child-key entry, the root mapping keyed by `""`; powers YAML editor autocompletion. */
|
|
11
|
+
export type SchemaKeys = Record<string, SchemaKeysEntry>;
|
|
12
|
+
export declare function deriveSchemaKeys(schema: z.core.$ZodType): SchemaKeys;
|
|
13
|
+
//# sourceMappingURL=schemaKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaKeys.d.ts","sourceRoot":"","sources":["../../src/asCode/schemaKeys.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,CAAC,MAAM,UAAU,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;IAC7B,IAAI,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,uGAAuG;AACvG,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAEzD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAEpE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { union } from "lodash-es";
|
|
3
|
+
export function deriveSchemaKeys(schema) {
|
|
4
|
+
return collectSchemaKeys(schema, "", "mapping", {});
|
|
5
|
+
}
|
|
6
|
+
function collectSchemaKeys(schema, parentKey, kind, result) {
|
|
7
|
+
for (const object of objectSchemasOf(schema)) {
|
|
8
|
+
const { shape } = object._zod.def;
|
|
9
|
+
result[parentKey] = { kind, keys: union(result[parentKey]?.keys, Object.keys(shape)) };
|
|
10
|
+
for (const [key, child] of Object.entries(shape)) {
|
|
11
|
+
const inner = unwrap(child);
|
|
12
|
+
if (inner._zod.def.type === "array") {
|
|
13
|
+
// A sequence is a block even when its items are scalars and add no keys.
|
|
14
|
+
result[key] ??= { kind: "sequence", keys: [] };
|
|
15
|
+
const element = unwrap(inner._zod.def.element);
|
|
16
|
+
collectSchemaKeys(element, key, "sequence", result);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
collectSchemaKeys(inner, key, "mapping", result);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/** Object schemas reachable from `schema`, flattening a discriminated union into its arms. */
|
|
26
|
+
function objectSchemasOf(schema) {
|
|
27
|
+
const { def } = schema._zod;
|
|
28
|
+
if (def.type === "object") {
|
|
29
|
+
return [schema];
|
|
30
|
+
}
|
|
31
|
+
if (def.type === "union") {
|
|
32
|
+
return def.options.flatMap((option) => objectSchemasOf(unwrap(option)));
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
function unwrap(schema) {
|
|
37
|
+
const { type } = schema._zod.def;
|
|
38
|
+
if (type === "optional" || type === "default") {
|
|
39
|
+
return unwrap(schema._zod.def.innerType);
|
|
40
|
+
}
|
|
41
|
+
if (type === "pipe") {
|
|
42
|
+
return unwrap(schema._zod.def.in);
|
|
43
|
+
}
|
|
44
|
+
return schema;
|
|
45
|
+
}
|
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import type * as z from "zod/mini";
|
|
2
|
-
|
|
3
|
-
* Neutral result of the shared YAML validation skeleton, before a type shapes it into its own result.
|
|
4
|
-
* `data` is the parsed-and-schema-validated value; the caller converts it to a definition. A `schema`
|
|
5
|
-
* failure hands the caller the `error` and the `parsed` value to classify against its own error codes;
|
|
6
|
-
* the other kinds are already the codes every as-code type shares.
|
|
7
|
-
*/
|
|
8
|
-
export type YamlValidation<TData> = {
|
|
9
|
-
ok: true;
|
|
10
|
-
data: TData;
|
|
11
|
-
} | {
|
|
12
|
-
ok: false;
|
|
13
|
-
kind: "empty" | "syntax" | "idImmutable";
|
|
14
|
-
} | {
|
|
15
|
-
ok: false;
|
|
16
|
-
kind: "schema";
|
|
17
|
-
error: z.core.$ZodError;
|
|
18
|
-
parsed: unknown;
|
|
19
|
-
};
|
|
2
|
+
import type { AsCodeFieldMark } from "./descriptor.js";
|
|
20
3
|
type SafeParseSchema<TData> = {
|
|
21
4
|
safeParse(value: unknown): {
|
|
22
5
|
success: true;
|
|
@@ -26,18 +9,38 @@ type SafeParseSchema<TData> = {
|
|
|
26
9
|
error: z.core.$ZodError;
|
|
27
10
|
};
|
|
28
11
|
};
|
|
29
|
-
type
|
|
12
|
+
type YamlErrorCode = "empty" | "syntax" | "invalidStructure" | "idImmutable";
|
|
13
|
+
type SharedYamlFailure<TFailure> = {
|
|
14
|
+
errorCode: YamlErrorCode;
|
|
15
|
+
} & {
|
|
16
|
+
[TKey in Exclude<keyof TFailure, "errorCode">]?: undefined;
|
|
17
|
+
};
|
|
18
|
+
export type YamlValidationFailure<TFailure extends {
|
|
19
|
+
errorCode: string;
|
|
20
|
+
}> = {
|
|
21
|
+
isValid: false;
|
|
22
|
+
} & AsCodeFieldMark & (TFailure | SharedYamlFailure<TFailure>);
|
|
23
|
+
export type YamlValidation<TData, TFailure extends {
|
|
24
|
+
errorCode: string;
|
|
25
|
+
}> = {
|
|
26
|
+
isValid: true;
|
|
27
|
+
data: TData;
|
|
28
|
+
} | YamlValidationFailure<TFailure>;
|
|
29
|
+
type ValidateYamlOptions<TData, TFailure> = {
|
|
30
30
|
schema: SafeParseSchema<TData>;
|
|
31
31
|
/** When set, the parsed `id` must match it, else `idImmutable` (identity is fixed while editing). */
|
|
32
32
|
fixedIdentifier?: string;
|
|
33
|
+
classifyIssue: (dottedPath: string, parsed: unknown, issue: z.core.$ZodIssue) => TFailure | undefined;
|
|
33
34
|
};
|
|
34
|
-
/**
|
|
35
|
-
* Runs the steps every as-code YAML shares: reject empty input, parse (strict) YAML, drop a blank
|
|
36
|
-
* identity, validate against the schema, and enforce identity immutability. The schema itself and the
|
|
37
|
-
* conversion of validated data into a definition are the caller's.
|
|
38
|
-
*/
|
|
39
35
|
export declare function validateYaml<TData extends {
|
|
40
36
|
id?: string;
|
|
41
|
-
}
|
|
37
|
+
}, TFailure extends {
|
|
38
|
+
errorCode: string;
|
|
39
|
+
}>(value: string, { schema, fixedIdentifier, classifyIssue }: ValidateYamlOptions<TData, TFailure>): YamlValidation<TData, TFailure>;
|
|
40
|
+
/**
|
|
41
|
+
* A blank `maql:` / `maql: ` line parses to null - the seeded template's state - and counts as
|
|
42
|
+
* unwritten, not as a value of the wrong type.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isMaqlWritten(parsed: unknown): boolean;
|
|
42
45
|
export {};
|
|
43
46
|
//# sourceMappingURL=validateYaml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateYaml.d.ts","sourceRoot":"","sources":["../../src/asCode/validateYaml.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,CAAC,MAAM,UAAU,CAAC;AAEnC
|
|
1
|
+
{"version":3,"file":"validateYaml.d.ts","sourceRoot":"","sources":["../../src/asCode/validateYaml.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK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O,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,QAAQ,GAAG,SAAS,CAAC;CACzG,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC9F,KAAK,EAAE,MAAM,EACb,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,EAAE,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,GACjF,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CA6BjC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEtD"}
|
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
// (C) 2026 GoodData Corporation
|
|
2
2
|
import { parse as parseYaml } from "yaml";
|
|
3
|
-
|
|
4
|
-
* Runs the steps every as-code YAML shares: reject empty input, parse (strict) YAML, drop a blank
|
|
5
|
-
* identity, validate against the schema, and enforce identity immutability. The schema itself and the
|
|
6
|
-
* conversion of validated data into a definition are the caller's.
|
|
7
|
-
*/
|
|
8
|
-
export function validateYaml(value, { schema, fixedIdentifier }) {
|
|
3
|
+
export function validateYaml(value, { schema, fixedIdentifier, classifyIssue }) {
|
|
9
4
|
if (value.trim() === "") {
|
|
10
|
-
return {
|
|
5
|
+
return { isValid: false, errorCode: "empty" };
|
|
11
6
|
}
|
|
12
7
|
let parsed;
|
|
13
8
|
try {
|
|
14
9
|
parsed = parseYaml(value, { strict: true });
|
|
15
10
|
}
|
|
16
11
|
catch {
|
|
17
|
-
return {
|
|
12
|
+
return { isValid: false, errorCode: "syntax" };
|
|
18
13
|
}
|
|
19
14
|
const document = withoutBlankIdentity(parsed);
|
|
20
15
|
const result = schema.safeParse(document);
|
|
21
16
|
if (!result.success) {
|
|
22
|
-
|
|
17
|
+
for (const issue of result.error.issues) {
|
|
18
|
+
const failure = classifyIssue(issue.path.map(String).join("."), document, issue);
|
|
19
|
+
if (failure) {
|
|
20
|
+
return { isValid: false, ...failure, ...markedField(issue) };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { isValid: false, errorCode: "invalidStructure", ...markedField(result.error.issues[0]) };
|
|
23
24
|
}
|
|
24
25
|
if (fixedIdentifier !== undefined && result.data.id !== fixedIdentifier) {
|
|
25
|
-
return {
|
|
26
|
+
return { isValid: false, errorCode: "idImmutable", path: ["id"] };
|
|
26
27
|
}
|
|
27
|
-
return {
|
|
28
|
+
return { isValid: true, data: result.data };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A blank `maql:` / `maql: ` line parses to null - the seeded template's state - and counts as
|
|
32
|
+
* unwritten, not as a value of the wrong type.
|
|
33
|
+
*/
|
|
34
|
+
export function isMaqlWritten(parsed) {
|
|
35
|
+
return parsed !== null && typeof parsed === "object" && "maql" in parsed && parsed.maql != null;
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
30
38
|
* Drops an `id` the author left blank, so the template can offer the key without forcing a value.
|
|
@@ -41,3 +49,18 @@ function withoutBlankIdentity(parsed) {
|
|
|
41
49
|
const { id, ...rest } = parsed;
|
|
42
50
|
return id === null || (typeof id === "string" && id.trim() === "") ? rest : parsed;
|
|
43
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* The field to mark for an issue. Symbols cannot name a YAML node, so they are dropped, and an empty
|
|
54
|
+
* path names no field. Zod reports an unknown key on its parent object, so the first unknown key is
|
|
55
|
+
* appended and marked by its key.
|
|
56
|
+
*/
|
|
57
|
+
function markedField(issue) {
|
|
58
|
+
if (issue.code === "unrecognized_keys") {
|
|
59
|
+
return { path: [...issue.path.filter(isDocumentKey), issue.keys[0]], target: "key" };
|
|
60
|
+
}
|
|
61
|
+
const keys = issue.path.filter(isDocumentKey);
|
|
62
|
+
return { path: keys.length > 0 ? keys : undefined };
|
|
63
|
+
}
|
|
64
|
+
function isDocumentKey(key) {
|
|
65
|
+
return typeof key !== "symbol";
|
|
66
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCatalogItemUpdate.d.ts","sourceRoot":"","sources":["../../../src/catalogDetail/hooks/useCatalogItemUpdate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCatalogItemUpdate.d.ts","sourceRoot":"","sources":["../../../src/catalogDetail/hooks/useCatalogItemUpdate.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,MAAM,EAEd,MAAM,qBAAqB,CAAC;AAkB7B,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACvB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,MAAM,WAAW,qBAAqB;IAClC,WAAW,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,IAAI,CAAC;IACzD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACpC;AAID,wBAAgB,oBAAoB,CAAC,EACjC,WAAW,EACX,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,OAAO,GACV,EAAE,qBAAqB;;;;6BAyFR,MAAM;yCAIA,MAAM;2BAIb,MAAM,EAAE;mCAIJ,OAAO;iDAQA,OAAO;uCAQZ,UAAU,GAAG,SAAS;+BAY1B,MAAM,GAAG,IAAI;6DAYE,mBAAmB,CAAC,uBAAuB,CAAC;qDAYzD,MAAM,yBAAyB,8BAA8B,GAAG,SAAS;6CAqBpE,YAAY,CAAC,eAAe,CAAC;+BApInC,YAAY;2BAUhB,eAAe;EA6J5B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// (C) 2025-2026 GoodData Corporation
|
|
2
2
|
import { useCallback, useEffect, useState } from "react";
|
|
3
|
-
import { isEqual } from "lodash-es";
|
|
4
3
|
import { areObjRefsEqual, } from "@gooddata/sdk-model";
|
|
5
4
|
import { useBackendStrict, useWorkspaceStrict } from "@gooddata/sdk-ui";
|
|
5
|
+
import { _isEqual } from "@gooddata/util";
|
|
6
6
|
import { getDisplayName } from "../../catalogItem/converter.js";
|
|
7
7
|
import { isCatalogItemAttribute, isCatalogItemHidable, isCatalogItemLoaded, isCatalogItemMeasure, isCatalogItemWithPermissions, } from "../../catalogItem/guards.js";
|
|
8
8
|
import { persistLabelConditionalFormatting, persistMeasureConditionalFormatting, updateCatalogItem, updateCatalogItemCertification, } from "../../catalogItem/query.js";
|
|
@@ -170,7 +170,7 @@ function makeUpdatedItem(user, item, changes) {
|
|
|
170
170
|
function hasChanges(item, changes) {
|
|
171
171
|
return Object.keys(changes).some((key) => {
|
|
172
172
|
const typedKey = key;
|
|
173
|
-
return !
|
|
173
|
+
return !_isEqual(item[typedKey], changes[typedKey]);
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
function persistMeasureMetadata(backend, workspace, item) {
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Completion source for the computed attribute YAML schema. The schema is a flat mapping, so
|
|
4
|
-
* completion only offers the top-level property names, and only at column zero — an indented line
|
|
5
|
-
* sits inside a sequence value (e.g. under `tags:`), where those keys must not be offered.
|
|
6
|
-
*/
|
|
7
|
-
export declare function computedAttributeCompletions(context: CompletionContext): CompletionResult | null;
|
|
1
|
+
export declare const computedAttributeCompletions: (context: import("@codemirror/autocomplete").CompletionContext) => import("@codemirror/autocomplete").CompletionResult | null;
|
|
8
2
|
//# sourceMappingURL=computedAttributeCompletions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedAttributeCompletions.d.ts","sourceRoot":"","sources":["../../src/computedAttribute/computedAttributeCompletions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computedAttributeCompletions.d.ts","sourceRoot":"","sources":["../../src/computedAttribute/computedAttributeCompletions.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B,+HAExC,CAAC"}
|
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { createFlatKeyCompletions } from "../asCode/keyCompletions.js";
|
|
2
3
|
import { COMPUTED_ATTRIBUTE_SCHEMA_KEYS } from "./computedAttributeSchema.js";
|
|
3
|
-
const
|
|
4
|
-
label,
|
|
5
|
-
type: "property",
|
|
6
|
-
}));
|
|
7
|
-
/**
|
|
8
|
-
* Completion source for the computed attribute YAML schema. The schema is a flat mapping, so
|
|
9
|
-
* completion only offers the top-level property names, and only at column zero — an indented line
|
|
10
|
-
* sits inside a sequence value (e.g. under `tags:`), where those keys must not be offered.
|
|
11
|
-
*/
|
|
12
|
-
export function computedAttributeCompletions(context) {
|
|
13
|
-
const line = context.state.doc.lineAt(context.pos);
|
|
14
|
-
const before = line.text.slice(0, context.pos - line.from);
|
|
15
|
-
// Trigger only for a key typed at column zero; any leading whitespace means the cursor is nested.
|
|
16
|
-
const match = before.match(/^([\w-]*)$/);
|
|
17
|
-
if (!match) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return { from: context.pos - match[1].length, options: rootOptions, validFor: /^[\w-]*$/ };
|
|
21
|
-
}
|
|
4
|
+
export const computedAttributeCompletions = createFlatKeyCompletions(COMPUTED_ATTRIBUTE_SCHEMA_KEYS[""]?.keys ?? []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedAttributeDescriptor.d.ts","sourceRoot":"","sources":["../../src/computedAttribute/computedAttributeDescriptor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"computedAttributeDescriptor.d.ts","sourceRoot":"","sources":["../../src/computedAttribute/computedAttributeDescriptor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,qBAAqB,CAAC;AAStF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAwF7E;;GAEG;AACH,eAAO,MAAM,2BAA2B,gIAoCtC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// (C) 2026 GoodData Corporation
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { defineMessages, useIntl } from "react-intl";
|
|
4
|
-
import { defineAsCodeDescriptor, fixedIdentifierOf, } from "../asCode/descriptor.js";
|
|
4
|
+
import { defineAsCodeDescriptor, fixedIdentifierOf, toAsCodeFailure, } from "../asCode/descriptor.js";
|
|
5
5
|
import { ObjectTypes } from "../objectType/constants.js";
|
|
6
6
|
import { computedAttributeCompletions } from "./computedAttributeCompletions.js";
|
|
7
7
|
import { computedAttributeYamlToDefinition, definitionToComputedAttributeYaml, reconcileComputedAttributeDefinition, } from "./computedAttributeConverter.js";
|
|
@@ -65,7 +65,7 @@ function useComputedAttributeEditing() {
|
|
|
65
65
|
});
|
|
66
66
|
return result.isValid
|
|
67
67
|
? { isValid: true, definition: result.computedAttribute }
|
|
68
|
-
:
|
|
68
|
+
: toAsCodeFailure(result, intl.formatMessage(errorMessages[result.errorCode]));
|
|
69
69
|
},
|
|
70
70
|
reconcile: reconcileComputedAttributeDefinition,
|
|
71
71
|
}), [intl]);
|