From 6eee5aaf1e12007cebe834de5b0a38b8c97833d8 Mon Sep 17 00:00:00 2001 From: Samuel Meyer Date: Fri, 20 Dec 2024 13:12:09 -0800 Subject: [PATCH] #1320 Add module TypeScript definitions Signed-off-by: Samuel Meyer --- .../command-actions/locales/index.d.ts | 18 + .../locales/common-canvas/locales/index.d.ts | 18 + .../common-properties/locales/index.d.ts | 18 + .../notification-panel/locales/index.d.ts | 18 + .../locales/palette/locales/index.d.ts | 18 + .../locales/toolbar/locales/index.d.ts | 18 + canvas_modules/common-canvas/package.json | 1 + .../common-canvas/types/app-data-def.ts | 22 + .../common-properties-controller.model.ts | 466 +++ .../types/conditions-v3.model.ts | 323 ++ .../types/datarecord-metadata-v3.ts | 197 ++ .../types/expression-info-v3.model.ts | 172 + .../types/function-list-v3.model.ts | 97 + canvas_modules/common-canvas/types/index.d.ts | 2809 +++++++++++++++++ .../common-canvas/types/operator-v3.model.ts | 192 ++ .../common-canvas/types/palette-v3.ts | 80 + .../types/parameter-defs-v3.model.ts | 73 + .../common-canvas/types/parameters-v3.ts | 71 + .../common-canvas/types/parametersets-v3.ts | 88 + .../types/pipeline-connection-v3.ts | 118 + .../types/pipeline-flow-ui-v3.ts | 471 +++ .../common-canvas/types/pipeline-flow-v3.ts | 512 +++ .../common-canvas/types/uihints-v3.model.ts | 709 +++++ 23 files changed, 6509 insertions(+) create mode 100644 canvas_modules/common-canvas/locales/command-actions/locales/index.d.ts create mode 100644 canvas_modules/common-canvas/locales/common-canvas/locales/index.d.ts create mode 100644 canvas_modules/common-canvas/locales/common-properties/locales/index.d.ts create mode 100644 canvas_modules/common-canvas/locales/notification-panel/locales/index.d.ts create mode 100644 canvas_modules/common-canvas/locales/palette/locales/index.d.ts create mode 100644 canvas_modules/common-canvas/locales/toolbar/locales/index.d.ts create mode 100644 canvas_modules/common-canvas/types/app-data-def.ts create mode 100644 canvas_modules/common-canvas/types/common-properties-controller.model.ts create mode 100644 canvas_modules/common-canvas/types/conditions-v3.model.ts create mode 100644 canvas_modules/common-canvas/types/datarecord-metadata-v3.ts create mode 100644 canvas_modules/common-canvas/types/expression-info-v3.model.ts create mode 100644 canvas_modules/common-canvas/types/function-list-v3.model.ts create mode 100644 canvas_modules/common-canvas/types/index.d.ts create mode 100644 canvas_modules/common-canvas/types/operator-v3.model.ts create mode 100644 canvas_modules/common-canvas/types/palette-v3.ts create mode 100644 canvas_modules/common-canvas/types/parameter-defs-v3.model.ts create mode 100644 canvas_modules/common-canvas/types/parameters-v3.ts create mode 100644 canvas_modules/common-canvas/types/parametersets-v3.ts create mode 100644 canvas_modules/common-canvas/types/pipeline-connection-v3.ts create mode 100644 canvas_modules/common-canvas/types/pipeline-flow-ui-v3.ts create mode 100644 canvas_modules/common-canvas/types/pipeline-flow-v3.ts create mode 100644 canvas_modules/common-canvas/types/uihints-v3.model.ts diff --git a/canvas_modules/common-canvas/locales/command-actions/locales/index.d.ts b/canvas_modules/common-canvas/locales/command-actions/locales/index.d.ts new file mode 100644 index 0000000000..dffc1bc4a6 --- /dev/null +++ b/canvas_modules/common-canvas/locales/command-actions/locales/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare const messages: Record; +export default messages; diff --git a/canvas_modules/common-canvas/locales/common-canvas/locales/index.d.ts b/canvas_modules/common-canvas/locales/common-canvas/locales/index.d.ts new file mode 100644 index 0000000000..dffc1bc4a6 --- /dev/null +++ b/canvas_modules/common-canvas/locales/common-canvas/locales/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare const messages: Record; +export default messages; diff --git a/canvas_modules/common-canvas/locales/common-properties/locales/index.d.ts b/canvas_modules/common-canvas/locales/common-properties/locales/index.d.ts new file mode 100644 index 0000000000..dffc1bc4a6 --- /dev/null +++ b/canvas_modules/common-canvas/locales/common-properties/locales/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare const messages: Record; +export default messages; diff --git a/canvas_modules/common-canvas/locales/notification-panel/locales/index.d.ts b/canvas_modules/common-canvas/locales/notification-panel/locales/index.d.ts new file mode 100644 index 0000000000..dffc1bc4a6 --- /dev/null +++ b/canvas_modules/common-canvas/locales/notification-panel/locales/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare const messages: Record; +export default messages; diff --git a/canvas_modules/common-canvas/locales/palette/locales/index.d.ts b/canvas_modules/common-canvas/locales/palette/locales/index.d.ts new file mode 100644 index 0000000000..dffc1bc4a6 --- /dev/null +++ b/canvas_modules/common-canvas/locales/palette/locales/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare const messages: Record; +export default messages; diff --git a/canvas_modules/common-canvas/locales/toolbar/locales/index.d.ts b/canvas_modules/common-canvas/locales/toolbar/locales/index.d.ts new file mode 100644 index 0000000000..dffc1bc4a6 --- /dev/null +++ b/canvas_modules/common-canvas/locales/toolbar/locales/index.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare const messages: Record; +export default messages; diff --git a/canvas_modules/common-canvas/package.json b/canvas_modules/common-canvas/package.json index f8255d57a5..ecd73b37c4 100644 --- a/canvas_modules/common-canvas/package.json +++ b/canvas_modules/common-canvas/package.json @@ -14,6 +14,7 @@ }, "license": "Apache-2.0", "sideEffects": false, + "types": "./types/index.d.ts", "scripts": { "build": "npx stylelint '**/*.scss' && grunt && rollup -c", "test": "NODE_ENV=test jest", diff --git a/canvas_modules/common-canvas/types/app-data-def.ts b/canvas_modules/common-canvas/types/app-data-def.ts new file mode 100644 index 0000000000..b63b181f68 --- /dev/null +++ b/canvas_modules/common-canvas/types/app-data-def.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Object containing application-specific data + */ +export interface AppDataDef { + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/common-properties-controller.model.ts b/canvas_modules/common-canvas/types/common-properties-controller.model.ts new file mode 100644 index 0000000000..7ef238990c --- /dev/null +++ b/canvas_modules/common-canvas/types/common-properties-controller.model.ts @@ -0,0 +1,466 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { RecordSchema } from './datarecord-metadata-v3'; +import { PropertyDefinitionsSchema } from './parameter-defs-v3.model'; + +interface BaseProperty { + /** parameter name defined in operator definition */ + name: string; + /** propertyId of the nested structure */ + propertyId?: string; +} + +interface ArrayProperty extends BaseProperty { + row: number; +} + +interface TableProperty extends ArrayProperty { + col: number; +} + +/** https://elyra-ai.github.io/canvas/04.07-properties-controller/#common-properties-controller-api */ +export type PropertyId = BaseProperty | ArrayProperty | TableProperty; + +/** This is sometimes similar to MessageDef from pipeline-flow-ui-v3.ts */ +export interface PropertyMessageDef { + propertyId?: PropertyId; + required?: boolean; + text: string; + type: 'error' | 'warning' | 'info'; + validation_id?: string; + [key: string]: unknown; +} + +type ControlState = 'enabled' | 'disabled' | 'visible' | 'hidden'; + +/** + * https://elyra-ai.github.io/canvas/04.07-properties-controller/ + */ +export interface CommonPropertiesController { + // Property methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#property-methods + + /** + * options - optional object of config options where: + * setDefaultValues (boolean): when set to true, set default values from parameter definition + */ + setPropertyValues( + values: unknown, + options: { + setDefaultValues: boolean; + }, + ): void; + updatePropertyValue(propertyId: PropertyId, value: unknown): void; + + /** + * options - optional object of config options where: + * filterHiddenDisabled (boolean): when set to true, filter out data values with a state of disabled or hidden + * filterHiddenControls (boolean): when set to true, filter out data values having control type hidden + * applyProperties (boolean): when set to true, will return data values in the format expected by the `applyPropertyChanges` callback. If unset or false, will return the internal format used by Common Properties. + */ + getPropertyValue( + propertyId: PropertyId, + options: { + filterHiddenDisabled: boolean; + filterHiddenControls: boolean; + applyProperties: boolean; + }, + ): unknown; + + /** + * options - optional object of config options where: + * filterHiddenDisabled (boolean): when set to true, filter out data values with a state of disabled or hidden + * filterHiddenControls (boolean): when set to true, filter out data values having control type hidden + * applyProperties (boolean): when set to true, will return data values in the format expected by the `applyPropertyChanges` callback. If unset or false, will return the internal format used by Common Properties. + */ + getPropertyValues(options: { + filterHiddenDisabled: boolean; + filterHiddenControls: boolean; + applyProperties: boolean; + }): unknown; + + // Message methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#message-methods + + getAllErrorMessages(): Record; + /** + * Returns current list of error messages + * @filteredPipeline (boolean) optional + * @filterHiddenDisable (boolean) optional. If true, will not return error messages from controls that are hidden or disabled + * @filterDisplayError (boolean) optional. If true, will not return error messages that are not displayed in the editor + * when filteredPipeline=true returns enabled/visible control messages and only 1 per control. + */ + getErrorMessages( + filteredPipeline?: boolean, + filterHiddenDisable?: boolean, + filterSuccess?: boolean, + filterDisplayError?: boolean, + ): Record; + getErrorMessage( + propertyId: PropertyId, + filterHiddenDisable?: boolean, + filterSuccess?: boolean, + filterDisplayError?: boolean, + ): PropertyMessageDef | null; + getRequiredErrorMessages(): Record; + setErrorMessages(messages: Record): void; + updateErrorMessage(propertyId: PropertyId, message: PropertyMessageDef): void; + + // State methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#state-methods-disableenabled-hiddenvisible + + getControlState(propertyId: PropertyId): ControlState; + getControlStates(): Record; + setControlStates(states: Record): void; + + /** + * @propertyId - see above + * @state - valid values are "enabled", "disabled", "visible", "hidden" + */ + updateControlState(propertyId: PropertyId, state: ControlState): void; + + // DatasetMetadata methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#datasetmetadata-methods + + /** + * @datasetMetadata - see [schema](https://github.com/elyra-ai/pipeline-schemas/blob/master/common-pipeline/datarecord-metadata/datarecord-metadata-v1-schema.json) + */ + setDatasetMetadata(datasetMetadata: RecordSchema): void; + + // Row selection methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#row-selection-methods + + /** + * Returns table row selection indices as an array of integers. + * @propertyId - see above + */ + getSelectedRows(propertyId: PropertyId): number[]; + + /** + * Updates table row selections for the given table control. + * @propertyId - see above + * @selection - A zero-based array of integer selection indices + */ + updateSelectedRows(propertyId: PropertyId, selection: number[]): void; + + /** + * Clears selected table rows for the given table. + * @propertyId - see above + * If the propertyId is omitted all table row selections are cleared + */ + clearSelectedRows(propertyId: PropertyId): void; + + /** + * Adds a row selection listener for a table or list. + * @propertyId - see above + * @listener - callback function for when a selection is made in the table or list + */ + addRowSelectionListener( + propertyId: PropertyId, + listener: (...args: any[]) => void, + ): void; + + /** + * Removes the row selection listener from a table or list. + * @propertyId - see above + */ + removeRowSelectionListener(propertyId: PropertyId): void; + + // Validation methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#validation-methods + /** + * Runs validation conditions on all controls + */ + validatePropertiesValues(): void; + + /** + * Validates a specific propertyId + */ + validateInput(propertyId: PropertyId): void; + + // Control methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#control-methods + + /** + * Update the enum values for a given control. Used when enum values aren't static + * @propertyId - see above + * @valuesObj (array) [{ value: , label: "" }] + */ + updateControlEnumValues( + propertyId: PropertyId, + valuesObj: { value: string | number | boolean; label: string }[], + ): void; + + // General methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#general-methods + + /** + * Returns the current size of the RHS flyout. + */ + getEditorSize(): string; + + /** + * Sets default property values from parameter definition in the propertiesController. + * Note - These values won't be displayed on the UI. Host applications can call getPropertyValues() to retrieve the values. + * @paramDef - Follows the format of https://github.com/elyra-ai/pipeline-schemas/blob/master/common-canvas/parameter-defs/parameter-defs-v3-schema.json + */ + setParamDef(paramDef: PropertyDefinitionsSchema): void; + + /** + * Returns the id of top-level active tab or accordion + */ + getTopLevelActiveGroupId(): string; + + /** + * Makes the passed in groupId active. Only works for top-level groups + */ + setTopLevelActiveGroupId(groupId: string): void; + + // Disable move row buttons methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#disable-move-row-buttons-methods + + /** + * Disable table row move buttons for all propertyIds in given array + * @param propertyIds Array of propertyIds + * + */ + setDisableRowMoveButtons(propertyIds: PropertyId[]): void; + + /** + * Returns array of propertyIds for which row move buttons will be disabled + * @return Array of propertyIds + */ + getDisableRowMoveButtons(): PropertyId[]; + + /** + * Check if row move buttons should be disabled for given propertyId + * @param propertyId The unique property identifier + * @return boolean + */ + isDisableRowMoveButtons(propertyId: PropertyId): boolean; + + // Custom panel and control methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#custom-panel-and-control-methods + + /** + * Only used in custom panel to allow for custom property summary values to be displayed + * Displays the value set in propertiesReducer for that parameter + * @propertyId - see above + * @label (string) + * @inSummary (boolean) + */ + setControlInSummary( + propertyId: PropertyId, + label: string, + inSummary: boolean, + ): void; + + /** + * Sets the content to be displayed in the summaryPanel for a customPanel property. + * The summary panel will directly display the content. + * @propertyId - see above + * @content = { value: , label: "" } + */ + updateCustPropSumPanelValue( + propertyId: PropertyId, + content: { value: Record; label: string }, + ): void; + + /** + * Returns a standard control that can then be used in a customPanel. + * @propertyId - See above + * @paramDef - Follows the format of https://github.com/elyra-ai/pipeline-schemas/blob/master/common-canvas/parameter-defs/parameter-defs-v1-schema.json). titleDefinition, current_parameters, conditions, dataset_metadata are ignored and are optional. + * @parameter - This is the parameter from the paramDef to create the control for. + */ + createControl( + propertyId: PropertyId, + paramDef: unknown, + parameter: string, + ): void; + + /** + * Returns the translated text for a control given a resource key. + * Users should be able to use the values from resources that has been uploaded as part of paramDef. + * @key - Resource key + * @value - Default value returned when no resource or key has been found. + */ + getResource(key: string, value: unknown): void; + + // maxLength for single-line and multi-line control methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#maxlength-for-single-line-and-multi-line-control-methods + + /** + * Returns the maximum characters allowed for multi-line string controls + * Default value is 1024 + */ + getMaxLengthForMultiLineControls(): number; + + /** + * Returns the maximum characters allowed for single-line string controls + * Default value is 128 + */ + getMaxLengthForSingleLineControls(): number; + + // Enabling/disabling addRemoveRows methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#enablingdisabling-addremoverows-methods + + /** + * Set the addRemoveRows attribute to 'enabled' for the given propertyId + * @param propertyId The unique property identifier + * @param enabled boolean value to enable or disable addRemoveRows + */ + setAddRemoveRows(propertyId: PropertyId, enabled: boolean): void; + + /** + * Returns the true if addRemoveRows is enabled for the given propertyID + * @param propertyId The unique property identifier + * @return boolean + */ + getAddRemoveRows(propertyId: PropertyId): boolean; + + // Enabling/disabling properties editor “save” button methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#enablingdisabling-properties-editor-save-button-methods + + /** + * Set the main "save" button to disabled(true) or enabled(false) + * @param saveDisable (boolean) + */ + setSaveButtonDisable(saveDisable: boolean): void; + + /** + * Returns the true if the main "save" button is disabled, false otherwise + * @return boolean + */ + getSaveButtonDisable(): boolean; + + // Add static rows for table controls which will disable the re-ordering of the rows that are set as static for the given propertyId + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#add-static-rows-for-table-controls-which-will-disable-the-re-ordering-of-the-rows-that-are-set-as-static-for-the-given-propertyid + + /** + * Set static rows for the given propertyId + * @param propertyId The unique property identifier + * @param staticRowsArr Array of first n row indexes or last n row indexes + */ + updateStaticRows(propertyId: PropertyId, staticRowsArr: number[]): void; + + /** + * Returns the static rows set for the given propertyId + * @param propertyId The unique property identifier + */ + getStaticRows(propertyId: PropertyId): unknown[]; + + /** + * Removes the static rows set for the given propertyId + * @param propertyId The unique property identifier + */ + clearStaticRows(propertyId: PropertyId): void; + + // Enabling/disabling custom table buttons + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#enablingdisabling-custom-table-buttons + + /** + * Set the table button to 'enabled' for the given propertyId + * @param propertyId The unique property identifier + * @param buttonId The unique button identifier + * @param enabled boolean value to enable or disable the button + */ + setTableButtonEnabled( + propertyId: PropertyId, + buttonId: string, + enabled: boolean, + ): void; + + /** + * Returns the table button states for the given propertyID + * @param propertyId The unique property identifier + * @return object An object of buttonIds mapped to their enabled state + */ + getTableButtons(propertyId: PropertyId): Record; + + /** + * Returns the true if the table button is enabled for the given propertyID and buttonId + * @param propertyId The unique property identifier + * @param buttonId The unique button identifier + * @return boolean + */ + getTableButtonEnabled(propertyId: PropertyId, buttonId: string): boolean; + + // Column visibility methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#column-visibility-methods + + /** + * Check if given column is visible in the table + * @param propertyId The unique property identifier + * @param columnIndex Column index in the table + */ + getColumnVisibility(propertyId: PropertyId, columnIndex: number): boolean; + + /** + * Set column visibility + * @param propertyId The unique property identifier + * @param columnIndex Column index in the table + * @param value Boolean value to set column visible/invisible + */ + toggleColumnVisibility( + propertyId: PropertyId, + columnIndex: number, + value: boolean, + ): void; + + // Enabling/disabling wide flyout “OK” button methods + // https://elyra-ai.github.io/canvas/04.07-properties-controller/#enablingdisabling-wide-flyout-ok-button-methods + + /** + * Set the "OK" button in Wide Flyout to disabled(true) or enabled(false) for given summary panel + * @param panelId {name: panel.id} + * @param wideFlyoutPrimaryButtonDisable boolean + */ + setWideFlyoutPrimaryButtonDisabled( + panelId: { name: string }, + wideFlyoutPrimaryButtonDisable: boolean, + ): void; + + /** + * @param panelId {name: panel.id} + */ + getWideFlyoutPrimaryButtonDisabled(panelId: { name: string }): boolean; + + // Undocumented but used in examples + + getControl(propertyId: PropertyId): unknown; + /** + * @param inPropertyId the property to get the value of + * @param options - optional object of config options where + * @param options.filterHiddenDisabled true - filter out values from controls having state "hidden" or "disabled" + * @param options.applyProperties true - this function is called from PropertiesMain.applyPropertiesEditing() + * @param options.filterHidden true - filter out values from controls having state "hidden" + * @param options.filterDisabled true - filter out values from controls having state "disabled" + * @param options.filterHiddenControls true - filter out values from controls having type "hidden" + * @returns the property value for the given 'inPropertyId' + */ + getPropertyValue( + inPropertyId: PropertyId, + options?: { + filterHiddenDisabled: boolean; + applyProperties: boolean; + filterHidden: boolean; + filterDisabled: boolean; + filterHiddenControls: boolean; + }, + defaultValue?: unknown, + ): unknown; +} diff --git a/canvas_modules/common-canvas/types/conditions-v3.model.ts b/canvas_modules/common-canvas/types/conditions-v3.model.ts new file mode 100644 index 0000000000..d3504de2d2 --- /dev/null +++ b/canvas_modules/common-canvas/types/conditions-v3.model.ts @@ -0,0 +1,323 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/operators/conditions-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +export type ConditionsDefinition = + | ValidationDefinition + | EnabledDefinition + | VisibleDefinition + | FilterDefinition + | EnumFilterDefinition + | AllowChangeDefinition + | DefaultValueDefinition; +/** + * User message + */ +export type MessageDefinition = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Evaluates to a boolean result + */ +export type EvaluateDefinition = + | AndDefinition + | OrDefinition + | ConditionDefinition + | FilterConditionDefinition; +/** + * A single operator for comparing data record schema field attributes and sharing source fields + */ +export type FilterOpDefinition = + | 'dmMeasurement' + | 'dmType' + | 'dmModelingRole' + | 'dmSharedFields'; +/** + * Evaluates to return values included in an enumeration control + */ +export type EvaluateDefinition1 = + | AndDefinition + | OrDefinition + | ConditionDefinition + | FilterConditionDefinition; +/** + * Evaluates to a boolean result + */ +export type EvaluateDefinition2 = + | AndDefinition + | OrDefinition + | ConditionDefinition + | FilterConditionDefinition; +/** + * Evaluates to a boolean result + */ +export type EvaluateDefinition3 = + | AndDefinition + | OrDefinition + | ConditionDefinition + | FilterConditionDefinition; + +/** + * User Interface Condition schema for the Watson Data Platform + */ +export interface WatsonDataPlatformValidationSchema { + /** + * Refers to the JSON schema used to validate documents of this type + */ + json_schema?: 'https://api.dataplatform.ibm.com/schemas/common-pipeline/operators/conditions-v3-schema.json'; + conditions: ConditionsDefinition[]; + [k: string]: unknown; +} +export interface ValidationDefinition { + /** + * A single validation. The fail_message is displayed upon validation failure. + */ + validation: { + /** + * Unique identifier. Required when multiple fail_message sections have the same focus_parameter_ref value. + */ + id?: string; + fail_message: FailMessageDefinition; + evaluate: EvaluateDefinition; + [k: string]: unknown; + }; + [k: string]: unknown; +} +/** + * Error/warning + */ +export interface FailMessageDefinition { + /** + * The parameter control to get the error/warning message. + */ + focus_parameter_ref: string; + message: MessageDefinition; + type?: 'error' | 'warning' | 'info'; + [k: string]: unknown; +} +/** + * Container for 'and' operations + */ +export interface AndDefinition { + /** + * The 'and' condition. All sub-conditions evaluate to true. Can nest any number of additional conditional types. + */ + and: ( + | AndDefinition + | OrDefinition + | ConditionDefinition + | FilterConditionDefinition + )[]; + [k: string]: unknown; +} +/** + * Container for 'or' operations + */ +export interface OrDefinition { + /** + * The 'or' condition. Any sub-condition evaluates to true. Can nest any number of additional conditional types. + */ + or: ( + | AndDefinition + | OrDefinition + | ConditionDefinition + | FilterConditionDefinition + )[]; + [k: string]: unknown; +} +/** + * A parameter condition. Evaluates to true or false. + */ +export interface ConditionDefinition { + /** + * The condition that is evaluated + */ + condition: { + /** + * A single operator for the properties of the condition. + */ + op: + | ( + | 'isEmpty' + | 'isNotEmpty' + | 'greaterThan' + | 'lessThan' + | 'equals' + | 'notEquals' + | 'contains' + | 'notContains' + | 'colNotExists' + | 'cellNotEmpty' + | 'colDoesExist' + | 'isDateTime' + | 'dmTypeEquals' + | 'dmTypeNotEquals' + | 'dmMeasurementEquals' + | 'dmMeasurementNotEquals' + | 'dmRoleEquals' + | 'dmRoleNotEquals' + | 'matches' + | 'notMatches' + ) + | string; + /** + * The primary parameter - must be present + */ + parameter_ref: string; + /** + * Optional second parameter for multi-parameter validation + */ + parameter_2_ref?: string; + /** + * Optional value against which to compare the primary parameter value + */ + value?: string | number | boolean | unknown[] | null; + [k: string]: unknown; + }; + [k: string]: unknown; +} +/** + * Allows for filtering available fields in the data record schema(s) + */ +export interface FilterConditionDefinition { + /** + * The condition that is evaluated + */ + condition: + | { + op: FilterOpDefinition; + /** + * Value to compare against data record schema field attribute + */ + value?: string; + [k: string]: unknown; + } + | { + op: FilterOpDefinition; + /** + * Array of values which are compared to a data record schema field attribute + * + * @minItems 1 + */ + values: [string, ...string[]]; + [k: string]: unknown; + }; + [k: string]: unknown; +} +export interface EnabledDefinition { + /** + * Enablement test. Disables controls if evaluate is false. + */ + enabled: { + [k: string]: unknown; + }; + [k: string]: unknown; +} +export interface VisibleDefinition { + /** + * Visibility test. Hides controls if evaluate is false. + */ + visible: { + [k: string]: unknown; + }; + [k: string]: unknown; +} +export interface FilterDefinition { + /** + * Filter test. Includes support for filtering the values to be displayed in a control + */ + filter: { + [k: string]: unknown; + }; + [k: string]: unknown; +} +export interface EnumFilterDefinition { + /** + * Allows filtering of available enumeration options + */ + enum_filter: { + /** + * The target parameter information + */ + target: { + /** + * The enumeration parameter affected by this operation + */ + parameter_ref: string; + /** + * Array of available enumeration options when the condition evaluates to 'true' + * + * @minItems 1 + */ + values: [unknown, ...unknown[]]; + [k: string]: unknown; + }; + evaluate: EvaluateDefinition1; + [k: string]: unknown; + }; + [k: string]: unknown; +} +export interface AllowChangeDefinition { + /** + * Allow change test. Allows a field value to be changed if evaluates to true. + */ + allow_change: { + /** + * Array of parameter names who values changes are allowed by this operation + * + * @minItems 1 + */ + parameter_refs: [string, ...string[]]; + evaluate: EvaluateDefinition2; + [k: string]: unknown; + }; + [k: string]: unknown; +} +export interface DefaultValueDefinition { + /** + * Set default value of the parameter_ref if condition evaluates to true. + */ + default_value: { + /** + * Parameter whose default value is to be set. + */ + parameter_ref: string; + /** + * This will be the default value of parameter_ref if condition evaluates to true. + */ + value: + | number + | string + | boolean + | { + [k: string]: unknown; + } + | unknown[]; + evaluate: EvaluateDefinition3; + [k: string]: unknown; + }; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/datarecord-metadata-v3.ts b/canvas_modules/common-canvas/types/datarecord-metadata-v3.ts new file mode 100644 index 0000000000..71f63ff74b --- /dev/null +++ b/canvas_modules/common-canvas/types/datarecord-metadata-v3.ts @@ -0,0 +1,197 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AppDataDef } from "./app-data-def"; + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript --unreachableDefinitions + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/datarecord-metadata/datarecord-metadata-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +/** + * Metadata schema for datarecords in the Watson Data Platform + */ +export interface WatsonDataPlatformDatarecordMetadataSchema { + [k: string]: unknown; +} +/** + * Description of a datarecord including column types and metadata + * + * This interface was referenced by `WatsonDataPlatformDatarecordMetadataSchema`'s JSON-Schema + * via the `definition` "record_schema". + */ +export interface RecordSchema { + /** + * Unique identifier + */ + id: string; + /** + * Name of datarecord + */ + name?: string; + /** + * Refers to the JSON schema used to validate documents of this type + */ + json_schema?: 'https://api.dataplatform.ibm.com/schemas/common-pipeline/datarecord-metadata/datarecord-metadata-v3-schema.json'; + /** + * Always 'struct' for datarecord schema + */ + type?: string; + /** + * Array of field definitions + * + * @minItems 0 + */ + fields: Field[]; + /** + * The list of custom struct types to be used as field types + */ + struct_types?: { + /** + * This interface was referenced by `undefined`'s JSON-Schema definition + * via the `patternProperty` ".". + */ + [k: string]: { + /** + * Array of field definitions + * + * @minItems 0 + */ + fields?: Field[]; + [k: string]: unknown; + }; + }; + [k: string]: unknown; +} +/** + * Definition of a datarecord field + * + * This interface was referenced by `WatsonDataPlatformDatarecordMetadataSchema`'s JSON-Schema + * via the `definition` "field". + */ +export interface Field { + /** + * Field name. Must be unique within the datarecord + */ + name: string; + /** + * Field type. Can be a primitive type (string, integer, double, date, time, timestamp, binary, boolean, array[type], map[type, type]. The type can also be a reference to a struct_type declaration.) + */ + type: string; + /** + * Whether or not one can place null values into the field + */ + nullable?: boolean; + metadata?: Metadata; + app_data?: AppDataDef; + [k: string]: unknown; +} +/** + * Additional field metadata + * + * This interface was referenced by `WatsonDataPlatformDatarecordMetadataSchema`'s JSON-Schema + * via the `definition` "metadata". + */ +export interface Metadata { + /** + * Field description + */ + description?: string; + /** + * Field measurement level + */ + measure?: + | 'range' + | 'discrete' + | 'flag' + | 'set' + | 'ordered-set' + | 'typeless' + | 'collection' + | 'geospatial' + | 'default'; + /** + * Field role for modeling + */ + modeling_role?: + | 'input' + | 'target' + | 'both' + | 'none' + | 'partition' + | 'split' + | 'frequency' + | 'record-id'; + /** + * Maximum length for fields. Length is unlimited when not present + */ + max_length?: number; + /** + * Minimum length for fields + */ + min_length?: number; + /** + * Precision for decimal, time, and timestamp types + */ + decimal_precision?: number; + /** + * Scale for decimal, time, and timestamp types + */ + decimal_scale?: number; + /** + * Array of unique categorical values for the column + * + * @minItems 0 + */ + values?: (string | number | boolean)[]; + /** + * Minimum and maximum discovered values for scalar data + */ + range?: { + /** + * Lowest value discovered in the data + */ + min: string | number; + /** + * Highest value discovered in the data + */ + max: string | number; + [k: string]: unknown; + }; + /** + * Type of runtime + */ + runtime_type?: string; + /** + * A field is key + */ + is_key?: boolean; + /** + * Signed or Unsigned for number + */ + is_signed?: boolean; + /** + * Item record level + */ + item_index?: number; + /** + * Source field for a target field + */ + source_field_id?: string; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/expression-info-v3.model.ts b/canvas_modules/common-canvas/types/expression-info-v3.model.ts new file mode 100644 index 0000000000..77161a8048 --- /dev/null +++ b/canvas_modules/common-canvas/types/expression-info-v3.model.ts @@ -0,0 +1,172 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-canvas/expression/expression-info-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +import { ExpressionBuilderFunctionListSchema } from "./function-list-v3.model"; +import { ResourceDefinition } from "./uihints-v3.model"; + +/** + * Array of categories for the field dropdown menu + * + * @minItems 0 + */ +export type FieldCategoriesDef = FieldCategoriesItemDef[]; +/** + * Array of table contents for each field category + * + * @minItems 0 + */ +export type FieldTableInfoDef = FieldTableInfoItemDef[]; + +/** + * Watson Data Platform Expression Builder Expression Info Schema for the Common Properties editor + */ +export interface ExpressionBuilderExpressionInfoSchema { + functions?: ExpressionBuilderFunctionListSchema; + /** + * Metadata and content for field and value tables + */ + fields?: { + field_categories?: FieldCategoriesDef; + field_table_info?: FieldTableInfoDef; + [k: string]: unknown; + }; + /** + * Map of string resources. + */ + resources?: { + [k: string]: unknown; + }; + /** + * Controls if the validate schema link is shown + */ + validateLink?: boolean; + [k: string]: unknown; +} +/** + * Metadata of a field dropdown menu item + */ +export interface FieldCategoriesItemDef { + /** + * Unique string to reference this category + */ + id: string; + /** + * User-readable name of field category + */ + label?: ResourceDefinition; + /** + * Title of the field column + */ + field_columns: { + field_column_info: ColumnHeaderLabel; + value_column_info: ColumnHeaderLabel; + additional_column_info?: AdditionalInfoHeaderLabel; + [k: string]: unknown; + }; + [k: string]: unknown; +} +/** + * Info about columns headers + */ +export interface ColumnHeaderLabel { + label?: ResourceDefinition; + description?: ResourceDefinition; + [k: string]: unknown; +} +/** + * Info about info columns headers + */ +export interface AdditionalInfoHeaderLabel { + /** + * Unique string to reference this info column + */ + id: { + [k: string]: unknown; + }; + label?: ResourceDefinition; + [k: string]: unknown; +} +/** + * Wrapper for all the field/value groups of a single category + */ +export interface FieldTableInfoItemDef { + /** + * Unique string to reference this category + */ + field_category_ref: string; + /** + * Array of all the field/value groups of a single category + * + * @minItems 0 + */ + field_value_groups?: FieldValueGroupsItemDef[]; + [k: string]: unknown; +} +/** + * A field entry, and all associated values and informational columns + */ +export interface FieldValueGroupsItemDef { + /** + * Unique identifier for this field entry + */ + id: string; + /** + * A list of all values that are associated with this field + * + * @minItems 0 + */ + values?: ValueDef[]; + /** + * Value type that will be used in the value array. Can be a primitive type (string, integer, double, date, time, timestamp, binary, boolean, or other) + */ + value_type?: string; + /** + * A list of all informational column entries that are associated with this field + * + * @minItems 0 + */ + additional_column_entries?: AdditionalInfoItem[]; + /** + * Object/primitive type used in the info array (string, integer, double, date, time, timestamp, binary, boolean, or custom types) + */ + additional_column_type?: string; + [k: string]: unknown; +} +/** + * A wrapper a value of any basic type + */ +export interface ValueDef { + value: + | string + | number + | boolean + | { + [k: string]: unknown; + } + | unknown[] + | null; + [k: string]: unknown; +} +/** + * A wrapper a value of any basic type and a column id + */ +export interface AdditionalInfoItem { + /** + * A string that uniquely identifies this column, + */ + id: string; + value: + | string + | number + | boolean + | { + [k: string]: unknown; + } + | unknown[] + | null; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/function-list-v3.model.ts b/canvas_modules/common-canvas/types/function-list-v3.model.ts new file mode 100644 index 0000000000..caed720851 --- /dev/null +++ b/canvas_modules/common-canvas/types/function-list-v3.model.ts @@ -0,0 +1,97 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-canvas/expression/function-list-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +import { ResourceDefinition } from './uihints-v3.model'; + +/** + * Watson Data Platform Expression Builder Function List Schema for the Common Properties editor + */ +export interface ExpressionBuilderFunctionListSchema { + /** + * Array of categories of functions + * + * @minItems 0 + */ + function_categories: FunctionCategoriesDef[]; + /** + * Array of refs to functions that will be displayed as operators. + * + * @minItems 1 + */ + operator_refs?: [string, ...string[]]; + /** + * Array of function information + * + * @minItems 1 + */ + function_info: [FunctionDef, ...FunctionDef[]]; + [k: string]: unknown; +} +/** + * Definition of a information about a function + */ +export interface FunctionCategoriesDef { + /** + * Unique string to reference this category + */ + id?: string; + /** + * External name of category + */ + label: ResourceDefinition; + /** + * Array of function ids that are part of this fuction category + * + * @minItems 1 + */ + function_refs: [string, ...string[]]; +} +/** + * Definition of a information about a function + */ +export interface FunctionDef { + /** + * Unique string to reference this function + */ + id: string; + /** + * User-readable name of function + */ + label: ResourceDefinition; + /** + * Array of parameter information + * + * @minItems 0 + */ + parameters?: FunctionParameterDef[]; + /** + * Translatable data type name of what is returned from the function. If this is not provided, default to return_type + */ + return_type_label?: ResourceDefinition; + /** + * The data type name of what is returned from the function. + */ + return_type: string; + /** + * The help text for the function. + */ + description?: ResourceDefinition; +} +/** + * Definition of a information about a functions parameters. + */ +export interface FunctionParameterDef { + /** + * User-readable name of parameter + */ + label: ResourceDefinition; + /** + * The type of the parameter. + */ + type?: string; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/index.d.ts b/canvas_modules/common-canvas/types/index.d.ts new file mode 100644 index 0000000000..d7db180806 --- /dev/null +++ b/canvas_modules/common-canvas/types/index.d.ts @@ -0,0 +1,2809 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React, { ComponentClass, FunctionComponent, ReactNode } from "react"; +import { PropertyDefinitionsSchema } from "./parameter-defs-v3.model"; +import { + CommonPropertiesController, + PropertyId, + PropertyMessageDef, +} from "./common-properties-controller.model"; +import { DecorationDef, MessageDef, NodeInfoDef } from "./pipeline-flow-ui-v3"; +import { + HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowV3SchemaJson, + NodeTypeDef, +} from "./pipeline-flow-v3"; +import { ExpressionBuilderExpressionInfoSchema } from "./expression-info-v3.model.ts"; +import { HttpsApiDataplatformIbmComSchemasCommonCanvasPalettePaletteV3SchemaJson } from "./palette-v3"; + +export * from "./common-properties-controller.model.ts"; +export * from "./conditions-v3.model.ts"; +export * from "./datarecord-metadata-v3.ts"; +export * from "./expression-info-v3.model.ts"; +export * from "./function-list-v3.model.ts"; +export { + ParameterDefinition as OperatorParameterDefinition, + WatsonDataPlatformOperatorSchema, + PortDefinition, + ParameterRefDefinition, + ComplexTypeDefinition as OperatorComplexTypeDefinition, +} from "./operator-v3.model.ts"; +export * from "./palette-v3.ts"; +export * from "./parameter-defs-v3.model.ts"; +export * from "./parameters-v3.ts"; +export * from "./parametersets-v3.ts"; +export * from "./pipeline-connection-v3.ts"; +export { + PipelineDef as UiPipelineDef, + HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson, + PipelineOverviewDef, + CommentDef, + CommentLinkDef, + PortInfoDef, + NodeInfoDef, + AssociationDef, + DecorationDef, + MessageDef, + NodeLinkInfoDef, + RuntimeInfoDef, +} from "./pipeline-flow-ui-v3.ts"; +export * from "./pipeline-flow-v3.ts"; +export * from "./uihints-v3.model.ts"; + +export interface CanvasLink { + app_data: Record; + class_name: string; + id: string; + srcNodeId: string; + srcNodePortId: string; + trgNodeId: string; + trgNodePortId: string; + type: string; +} + +export type NodePosition = + | "topLeft" + | "middleLeft" + | "bottomLeft" + | "topCenter" + | "middleCenter" + | "bottomCenter" + | "topRight" + | "middleRight" + | "bottomRight"; + +export type LinkPosition = "source" | "middle" | "target"; + +interface ImageDecoration { + id: string; + image: string; + position: NodePosition | LinkPosition; + distance: number; + x_pos: number; + y_pos: number; + width: number; + height: number; + hotspot: boolean; + class_name: string; + outline: boolean; + tooltip: string; + temporary: boolean; +} + +export type NodeImageDecoration = ImageDecoration & + DecorationDef & { + position: NodePosition; + }; +export interface LinkImageDecoration extends ImageDecoration { + position: LinkPosition; +} + +interface LabelDecoration { + id: string; + label?: string; + label_editable?: boolean; + label_align?: "center" | "left"; + label_single_line?: boolean; + label_max_characters?: number; + label_allow_return_key?: boolean; + position?: NodePosition | LinkPosition; + distance?: number; + x_pos?: number; + y_pos?: number; + width?: number; + height?: number; + hotspot?: boolean; + class_name?: string; + tooltip?: string; + temporary?: boolean; +} + +export type NodeLabelDecoration = LabelDecoration & + DecorationDef & { + position: NodePosition; + }; +export interface LinkLabelDecoration extends LabelDecoration { + position: LinkPosition; +} + +interface ShapeDecoration { + id: string; + path?: string; + position?: NodePosition | LinkPosition; + distance?: number; + x_pos?: number; + y_pos?: number; + width?: number; + height?: number; + hotspot?: boolean; + class_name?: boolean; + tooltip?: string; + temporary?: boolean; +} + +export type NodeShapeDecoration = ShapeDecoration & + DecorationDef & { + position: NodePosition; + }; +export interface LinkShapeDecoration extends ShapeDecoration { + position: LinkPosition; +} + +interface JsxDecoration { + id: string; + jsx: ReactNode; + position: NodePosition | LinkPosition; + distance: number; + x_pos: number; + y_pos: number; + width: number; + height: number; + hotspot: boolean; + class_name: string; + tooltip: string; +} + +export type NodeJsxDecoration = JsxDecoration & + DecorationDef & { + position: NodePosition; + }; +export interface LinkJsxDecoration extends JsxDecoration { + position: LinkPosition; +} + +/** https://elyra-ai.github.io/canvas/03.04.01-decorations/ */ +export type Decoration = + | ImageDecoration + | LabelDecoration + | ShapeDecoration + | JsxDecoration; + +/** https://elyra-ai.github.io/canvas/03.04.01-decorations/ */ +export type LinkDecoration = + | LinkImageDecoration + | LinkLabelDecoration + | LinkShapeDecoration + | LinkJsxDecoration; + +/** https://elyra-ai.github.io/canvas/03.04.01-decorations/ */ +export type NodeDecoration = + | NodeImageDecoration + | NodeLabelDecoration + | NodeShapeDecoration + | NodeJsxDecoration; + +/** + * A node as represented inside Elyra Canvas. The generic type is of app_data. + * https://elyra-ai.github.io/canvas/03.04.02-api-object-structure/#api-differences-with-schema + */ +export type CanvasNode> = NodeTypeDef & + NodeInfoDef & + Required> & { + app_data: T; + height: number; + width: number; + }; + +export interface CanvasComment { + class_name: string; + content: string; + height: number; + id: string; + width: number; + x_pos: number; + y_pos: number; +} + +export type ContextMenuHandler = ( + source: CtxMenuHandlerSource, + defaultMenu: CtxMenuHandlerMenuAction[] +) => CtxMenuHandlerMenuAction[]; + +export interface StyleSpec { + body?: { + default?: string; + hover?: string; + }; + image?: { + default: string; + }; + label?: { + default: string; + }; + selection_outline?: { + default: string; + }; +} + +export interface PipelineObjectStyle { + style: StyleSpec; + pipelineId: string; + objId: string; +} + +export type NotificationMsgType = + | "info" + | "success" + | "warning" + | "error" + | "" + | undefined + | null; +/** https://elyra-ai.github.io/canvas/03.04.05-notification-messages/ */ +export interface NotificationMsg { + id: string; + type: NotificationMsgType; + title?: string | ReactNode; + content?: string | ReactNode; + timestamp?: string; + callback?: (id: string) => void; + closeMessage?: string | ReactNode; +} + +/** + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/ + */ +export declare class CanvasController { + /** + * Loads the pipelineFlow document provided into common-canvas and displays it. + * The document must conform to the pipelineFlow schema as documented in the + * elyra-ai pipeline-schemas repo. Documents conforming to older versions may be + * provided, but they will be upgraded to the most recent version. + */ + setPipelineFlow( + pipelineFlow: HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowV3SchemaJson + ): void; + /** + * Clears the pipeline flow and displays an empty canvas. + */ + clearPipelineFlow(): void; + /** + * @return the current pipelineFlow document in the latest version of the + * pipelineFlow schema as documented in the elyra-ai pipeline-schemas repo. + */ + getPipelineFlow(): HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowV3SchemaJson; + /** + * Returns the current pipelineFlow document ID. + */ + getPipelineFlowId(): string; + /** + * Returns the ID of the primary pipeline from the pipelineFlow. + */ + getPrimaryPipelineId(): string; + /** + * Returns the external pipeline flow for the url passed in. The external + * flow must have been loaded through some common canvas action for this + * method to be able to return anything. + * @param url + */ + getExternalPipelineFlow(url: string): Record; + /** + * Returns the internal format of all canvas data stored in memory by + * common-canvas. Nodes, comments and links are returned in the internal + * format. + */ + getCanvasInfo(): Record; + /** + * @param pipelineId + * @return the IDs of the ancestor pipeline of the pipeline ID passed in. + */ + getAncestorPipelineIds(pipelineId: string): Record[]; + /** + * Removes all styles from nodes, comments and links. See the setObjectsStyle + * and setLinkStyle methods for details on setting styles. + * temporary - is a boolean that indicates whether temporary or permanent + * styles should be removed. + * @param temporary - boolean + */ + removeAllStyles(temporary: boolean): void; + /** + * Specifies the new styles for objects that are not highlighted during + * branch highlighting. + * @param newStyle - is a style specification object + */ + setSubdueStyle(newStyle: StyleSpec): void; + + /** + * ## Pipeline methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#pipeline-methods + */ + + /** + * @return the pipeline object for the pipeline Id passed in. + */ + getPipeline(pipelineId: string): Record; + /** + * Returns the ID of the pipeline object which is currently on display + * in the canvas. Typically, this is the primary pipeline but will be + * different if the user has navigated into one or more supernodes; in + * which case it will be the ID of the pipeline at the level in the + * supernode hierarchy that is currently on display. + */ + getCurrentPipelineId(): string; + /** + * Returns truthy if the pipeline is external (that is it is part of an + * external pipeline flow). Otherwise, return falsy to indicate the pipeline + * is local. + */ + isPipelineExternal(pipelineId: string): boolean; + /** + * Returns the flow validation messages for the pipeline ID passed in. + */ + getFlowMessages(pipelineId: string): Record; + /** + * @return a boolean to indicate whether there are any messages of + * includeMsgsType in the pipeline identified by the pipeline ID passed in. + * @param includeMsgType - can be either "error" or "warning" + */ + isFlowValid(includeMsgType: "error" | "warning"): boolean; + /** + * Rearranges the nodes in the canvas in the direction specified for the + * pipeline ID passed in. + * @param layoutDirection - can be "horizontal" or "vertical" + */ + autoLayout(layoutDirection: "horizontal" | "vertical"): void; + + /** + * ## Palette methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#palette-methods + */ + + /** + * Loads the palette data as described in the palette schema in + * elyra-ai pipeline-schemas repo. Any version can be loaded and it will be + * upgraded to the latest version. + */ + setPipelineFlowPalette( + palette: HttpsApiDataplatformIbmComSchemasCommonCanvasPalettePaletteV3SchemaJson + ): void; + /** + * Clears the palette data from common-canvas. + */ + clearPaletteData(): void; + /** + * Sets the loading text of the category. If set to a non-empty string the + * category will show an InlineLoading control in the palette category div + * with this text as the label. If set to falsey the palette category + * will display as normal. + * @param categoryId + * @param loadingText + */ + setCategoryLoadingText(categoryId: string, loadingText: string): void; + /** + * Sets the empty text of the category. If set to a non-empty string and the + * category does not have any nodes, the palette will show a warning icon with + * this text as a message under the category title when the category is opened. + * This message will not be displayed if the field is set to falsey or if + * nodetypes are added to the category. + * @param categoryId + * @param emptyText + */ + setCategoryEmptyText(categoryId: string, emptyText: string): void; + /** + * Adds a new node into the palette: + * @param nodeTypeObj - must conform to the style of node used by the palette as + * described in the palette schema. See objects in nodeTypes array in the + * palette schema: + * https://github.com/elyra-ai/pipeline-schemas/blob/main/common-canvas/palette/palette-v3-schema.json + * @param categoryId - is the name of the palette category where the node will be + * added. If the category doesn't exist it will be created. + * @param categoryLabel - Is an optional param. If a new category is created it will + * be displayed with this label. + * @param categoryDescription - Is an optional param. If a new category is created + * it will be displayed with this description. + * @param categoryImage - Is an optional param. The image displayed for the category provided as a + * reference to an image or the image itself. + */ + addNodeTypeToPalette( + nodeTypeObj: HttpsApiDataplatformIbmComSchemasCommonCanvasPalettePaletteV3SchemaJson, + categoryId: string, + categoryLabel?: string, + categoryDescription?: string, + categoryImage?: string + ): void; + /** + * Adds an array of new node into the palette: + * nodeTypeObjs - an array of nodetypes that must conform to the style of + * nodes used by the palette as described in the palette schema. See objects + * in nodeTypes array in the palette schema: + * https://github.com/elyra-ai/pipeline-schemas/blob/main/common-canvas/palette/palette-v3-schema.json + * category - is the name of the palette category where the node will be + * added. If the category doesn't exist it will be created. + * categoryLabel - is an optional param. If a new category is created it will + * be displayed with this label. + * categoryImage - the image displayed for the category provided as a + * reference to an image or the image itself. + * categoryDescription - Is an optional param. If a new category is created + * it will be displayed with this description. + * categoryImage - Is an optional param. The image displayed for the category provided as a + * reference to an image or the image itself. + */ + addNodeTypesToPalette( + nodeTypeObj: HttpsApiDataplatformIbmComSchemasCommonCanvasPalettePaletteV3SchemaJson[], + categoryId: string, + categoryLabel?: string, + categoryDescription?: string, + categoryImage?: string + ); + /** + * Removes nodetypes from a palette category + * @param selObjectIds - an array of object IDs to identify the nodetypes to be + * @param categoryId - the ID of teh category from which the nodes will be removed + */ + removeNodesFromPalette(selObjectIds: string[], categoryId: string): void; + /** + * @return the palette data document which will conform to the latest version + * of the palette schema. + */ + getPaletteData(): HttpsApiDataplatformIbmComSchemasCommonCanvasPalettePaletteV3SchemaJson; + /** + * @return the palette node identified by the operator ID passed in. + */ + getPaletteNode(operatorId: string): NodeTypeDef; + /** + * @return the palette node identified by the node ID passed in. + */ + getPaletteNodeById(nodeId: string): NodeTypeDef; + /** + * @return the category of the palette node identified by the operator passed in + */ + getCategoryForNode(nodeOpIdRef: string): string; + /** + * Converts a node template from the format use in the palette (that conforms + * to the schema) to the internal node format. + */ + convertNodeTemplate(nodeTemplate: NodeTypeDef): unknown; + /** Opens the palette category identified by the category ID passed in. */ + openPaletteCategory(categoryId: string): void; + /** Closes the palette category idetified by the category ID passed in. */ + closePaletteCategory(categoryId: string): void; + /** Opens all the palette categories. */ + openAllPaletteCategories(): void; + /** Closes all the palette categories. */ + closeAllPaletteCategories(): void; + /** Returns true or false to indicate whether a palette category is open or not. */ + isPaletteCategoryOpen(categoryId: string): boolean; + + /** + * ## Selection methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#selections-methods + */ + + /** + * Sets the currently selected objects replacing any current selections. + * Selected objects can only be in one pipeline. If this parameter is omitted + * it is assumed the selections will be for objects in the 'top-level' pipeline + * being displayed. + * @param newSelection - An array of object IDs for nodes and/or comments + * @param pipelineId - Optional. The ID of the pipeline where the objects exist. + */ + setSelections( + newSelection: string[] | Record[], + pipelineId?: string + ): void; + /** + * Clears all the current selections from the canvas. + */ + clearSelections(): void; + /** + * Selects all the objects on the canvas. + */ + selectAll(): void; + /** + * @return an array of the IDs of the currently selected objects. + */ + getSelectedObjectIds(): string[]; + /** + * @return the currently selected nodes. + */ + getSelectedNodes(): CanvasNode[]; + /** + * @return the currently selected comments. + */ + getSelectedComments(): CanvasComment[]; + /** + * @return the ID of the pipeline in which the currently selected objects + * exist. Only one pipeline may contain selected objects. + */ + getSelectedPipelineId(): string; + /** + * Deletes all currently selected objects. + */ + deleteSelectedObjects(): void; + /** + * This is used when deciding to creating a supernode. + * @return true if the currently selected objects are all linked together. + */ + areSelectedNodesContiguous(): boolean; + + /** + * ## Notification messages methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#notification-messages-methods + */ + + /** + * Overwrites the array of notification messages shown in the notification panel. + * @param newMessages - An array of messages (see `getNotificationMessages`) + */ + setNotificationMessages(newMessages: NotificationMsg[]): void; + /** + * Deletes all notification messages shown in the notification panel. + */ + clearNotificationMessages(): void; + /** + * Removes the notification messages from array of IDs. + * @param ids - array of IDs + */ + deleteNotificationMessages(ids: string[]): void; + /** + * Returns the array of current notification messages. If the messageType is + * provided only messages of that type will be returned. If messageType is + * not provided, all messages will be returned. The format of a notification + * message is an object with these fields: + * { + * "id": string (Required), + * "type" : enum, oneOf ["info", "success", "warning", "error"] (Required), + * "callback": function, the callback function when a message is clicked (Required), + * "title": string (Optional), + * "content": string, html, JSX Object (Optional), + * "timestamp": string (Optional), + * "closeMessage": string (Optional) + * } + */ + getNotificationMessages(messageType?: NotificationMsgType): NotificationMsg; + /** + * + * Returns the maximum notification message type present in the current set + * of notification messages. For this: ("error" > "warning" > "success" > "info") + * @return `"info" | "success" | "warning" | "error";` + */ + getNotificationMessagesMaxType(): NotificationMsgType; + + /** + * ## Node and Comment methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#node-and-comment-methods + */ + + /** + * Moves the objects identified in the data object which must be in the + * pipeline identified by the pipeline ID. + */ + moveObjects( + data: { + nodes: (string | CanvasNode | CanvasComment)[]; + offsetX: number; + offsetY: number; + }, + pipelineId: string + ): void; + /** + * Deletes the objects specified in objectIds array. + * @param objectIds - An array of node and comment IDs + * @param pipelineId + */ + deleteObjects( + objectIds: (string | CanvasNode | CanvasComment)[], + pipelineId: string + ): void; + /** + * Removes the links to and from the objects specified in the objectIds array. + * @param objectIds - An array of node and comment IDs + * @param pipelineId + */ + disconnectObjects( + objectIds: (string | CanvasNode | CanvasComment)[], + pipelineId: string + ): void; + /** + * Deletes the object specified by the id in the pipeline specified by + * pipeline ID. + * @deprecated Use deleteNode or deleteComment as appropriate instead. + */ + deleteObject(id: string, pipelineId: string): void; + /** + * Sets the style of the objects specified by pipelineObjectIds to be + * the newStyle which will be either temporary or permanent. + * pipelineObjectIds: This identified the objects to be styles. It is a + * javascript object like this: + * + * ```javascript + * { + * : [ + * , + * + * ], + * : [ + * , + * + * ] + * } + * ``` + * + * @param pipelineObjectIds + * @param newStyle - This is a style specification. See the wiki for details. + * @param temporary - A boolean to indicate if the style is serialized when + * getPipelineFlow() method is called or not. + */ + setObjectsStyle( + pipelineObjectIds: Record, + newStyle: StyleSpec, + temporary: boolean + ): void; + /** + * Sets the styles of multiple objects at once. + * @param pipelineObjStyles - Specified the objects and the styles each should be + * set to. It is a javascript array like this: + * + * ```javascript + * [ + * { pipelineId: , objId: , style: }, + * { pipelineId: , objId: , style: }, + * { pipelineId: , objId: , style: } + * ] + * ``` + * @param temporary - A boolean to indicate if the styles are serialized when + * getPipelineFlow() method is called or not. + */ + setObjectsMultiStyle( + pipelineObjStyles: PipelineObjectStyle[], + temporary: boolean + ): void; + + /** + * ## Node methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#node-methods + */ + + /** + * Returns an array of nodes for the pipeline specified by the pipelineId. + * @param pipelineId + */ + getNodes(pipelineId?: string): CanvasNode[]; + /** + * Returns a new node created from the data parameter in the pipeline + * identified by the pipelineId. + * @param data - An object containing + * + * `nodeTemplate` - a node template from the palette. The nodeTemplate + * can be retrieved from the palette using with Canvas + * Controller methods: getPaletteNode or getPaletteNodeById. + * + * `offsetX` - the x coordinate of the new node + * + * `offsetY` - the y coordinate of the new node + * + * @param pipelineId + */ + createNode(newNode: { + nodeTemplate: + | NodeTypeDef + | { + type: string; + op: string; + }; + offsetX: number; + offsetY: number; + }): CanvasNode; + /** + * Adds a new node into the pipeline specified by the pipelineId. + * @param node + * @param pipelineId + */ + addNode(node: CanvasNode, pipelineId?: string): void; + /** + * Creates a node using the data parameter provided in the pipeline specified + * by pipelineId and adds the command to the command stack (so the user can + * undo/redo the command). This will also cause the beforeEditActionHandler + * and editActionHandler callbacks to be called. + * If pipelineId is omitted the node will be created in the current + * "top-level" pipeline. + * @param data - An object containing + * + * `nodeTemplate` - a node template from the palette. The nodeTemplate + * can be retrieved from the palette using with Canvas + * Controller methods: getPaletteNode or getPaletteNodeById. + * + * `offsetX` - the x coordinate of the new node + * + * `offsetY` - the y coordinate of the new node + * + * @param pipelineId + */ + createNodeCommand( + data: { + nodeTemplate: + | NodeTypeDef + | { + type: string; + op: string; + }; + offsetX: number; + offsetY: number; + }, + pipelineId?: string + ): void; + + openPalette(): void; + setLinkDecorations( + id: string, + decorations: LinkDecoration[], + pipelineId: string + ); + /** + * Deletes the node specified. + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + deleteNode(nodeId: string, pipelineId?: string): void; + /** + * Sets the node properties + * @param nodeId - The ID of the node + * @param properties - An object containing properties to be overriden in the node + * @param pipelineId - The ID of the pipeline + */ + setNodeProperties( + nodeId: string, + properties: { + nodeTemplate: + | NodeTypeDef + | { + type: string; + op: string; + }; + offsetX: number; + offsetY: number; + }, + pipelineId: string + ): void; + /** + * Sets the node parameters + * @param nodeId - The ID of the node + * @param parameters - An array of parameters + * @param pipelineId - The ID of the pipeline + */ + setNodeParameters( + nodeId: string, + parameters: Record[], + pipelineId: string + ): void; + /** + * Sets the node UI parameters + * @param nodeId - The ID of the node + * @param uiParameters - An array of UI parameters + * @param pipelineId - The ID of the pipeline + */ + setNodeUiParameters( + nodeId: string, + uiParameters: Record[], + pipelineId: string + ): void; + /** + * Sets the node messages + * @param nodeId - The ID of the node + * @param messages - An array of messages + * @param pipelineId - The ID of the pipeline + */ + setNodeMessages( + nodeId: string, + messages: Record[], + pipelineId: string + ): void; + /** + * Sets a single message on a node + * @param nodeId - The ID of the node + * @param message - A message + * @param pipelineId - The ID of the pipeline + */ + setNodeMessage(nodeId: string, message: string, pipelineId: string): void; + /** + * Sets the lable for a node + * @param nodeId - The ID of the node + * @param newLabel - The label + * @param pipelineId - The ID of the pipeline + */ + setNodeLabel(nodeId: string, newLabel: string, pipelineId: string): void; + /** + * Sets the class name to newClassName of the nodes identified by nodeIds + * array in the pipeline specified by pipeline ID. The class name will be + * applied to the node body path. + */ + setNodesClassName( + nodeIds: string[], + newClassName: string, + pipelineId: string + ): void; + /** + * Sets the decorations on a node. The decorations array passed in + * will replace any decorations currently applied to the node. + * @param nodeId - The ID of the node + * @param newDecorations - An array of decorations. See Wiki for details. + * @param pipelineId - The ID of the pipeline + */ + setNodeDecorations( + nodeId: string, + newDecorations: Decoration[], + pipelineId: string + ): void; + /** + * Sets the input ports on a node. The inputs array of ports provided will + * replace any input ports for a node. + * @param nodeId - The ID of the node + * @param inputs - An array of input port objects. + * @param pipelineId - The ID of the pipeline + */ + setNodeInputPorts( + nodeId: string, + inputs: Record[], + pipelineId: string + ): void; + /** + * Sets the output ports on a node. The outputs array of ports provided will + * replace any output ports for a node. + * @param nodeId - The ID of the node + * @param outputs - An array of output port objects. + * @param pipelineId - The ID of the pipeline + */ + setNodeOutputPorts( + nodeId: string, + outputs: Record[], + pipelineId: string + ): void; + /** + * Sets the decorations of multiple nodes at once. The decorations array + * passed in will replace any decorations currently applied to the nodes. + * pipelineNodeDecorations - Specifies the nodes and their decorations. + * It is a JavaScript array like this: + * + * ```javascript + * [ + * { pipelineId: , nodeId: , decorations: }, + * { pipelineId: , nodeId: , decorations: }, + * { pipelineId: , nodeId: , decorations: } + * ] + * ``` + */ + setNodesMultiDecorations( + pipelineNodeDecorations: { + pipelineId: string; + nodeId: string; + decorations: Decoration[]; + }[] + ): void; + /** + * Sets the input port label on a node + * @param nodeId - The ID of the node + * @param portId - The ID of the input port + * @param newLabel - The label + * @param pipelineId - The ID of the pipeline + */ + setInputPortLabel( + nodeId: string, + portId: string, + newLabel: string, + pipelineId: string + ): void; + /** + * Sets the output port label on a node + * @param nodeId - The ID of the node + * @param portId - The ID of the output port + * @param newLabel - The label + * @param pipelineId - The ID of the pipeline + */ + setOutputPortLabel( + nodeId: string, + portId: string, + newLabel: string, + pipelineId: string + ): void; + /** + * Gets a node + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + getNode(nodeId: string, pipelineId?: string): CanvasNode; + /** + * Gets the UI parameters for a node + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + getNodeUiParameters( + nodeId: string, + pipelineId: string + ): Record[]; + /** + * Gets the supernodes for a pipeline. + * @param pipelineId - The ID of the pipeline + */ + getSupernodes(pipelineId: string): Record[]; + /** + * @return supernode ID that has a subflow_ref to the given pipelineId. + */ + getSupernodeObjReferencing(pipelineId: string): string; + /** + * Gets the messages for a node + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + getNodeMessages( + nodeId: string, + pipelineId: string + ): Record[]; + /** + * Gets the array of input ports for the node or null if the node ID is + * not recognized. + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + getNodeInputPorts( + nodeId: string, + pipelineId: string + ): Record[]; + /** + * Gets the array of output ports for the node or null if the node ID is + * not recognized. + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + getNodeOutputPorts( + nodeId: string, + pipelineId: string + ): Record[]; + /** + * Gets a message for a specific control for a node + * @param nodeId - The ID of the node + * @param controlName - The control name + * @param pipelineId - The ID of the pipeline + */ + getNodeMessage( + nodeId: string, + controlName: string, + pipelineId: string + ): string; + /** + * Gets an array of decorations for a node + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + getNodeDecorations(nodeId: string, pipelineId: string): Decoration[]; + /** + * Gets the class name associated with the node specified by nodeId in the + * pipeline specified by pipelineId. + */ + getNodeClassName(nodeId: string, pipelineId: string): string; + /** + * Gets the style specification (see Wiki) for a node + * @param nodeId - The ID of the node + * @param temporary - A boolean to indicate if the style is serialized when + * getPipelineFlow() method is called or not. + * @param pipelineId - The ID of the pipeline + */ + getNodeStyle( + nodeId: string, + temporary: boolean, + pipelineId: string + ): StyleSpec; + /** + * Returns an array of nodes that are for the branch(es) that the nodes, + * identified by the node IDs passed in, are within. + * @param nodeIds - An array of node Ids + * @param pipelineId - The ID of the pipeline where the nodes exist + */ + getBranchNodes(nodeIds: string[], pipelineId: string): CanvasNode[]; + /** + * Returns an array of nodes that are upstream from the nodes + * identified by the node IDs passed in. + * @param nodeIds - An array of node Ids + * @param pipelineId - The ID of the pipeline where the nodes exist + */ + getUpstreamNodes(nodeIds: string[], pipelineId: string): CanvasNode[]; + /** + * Returns an array of nodes that are downstream from the nodes + * identified by the node IDs passed in. + * @param nodeIds - An array of node Ids + * @param pipelineId - The ID of the pipeline where the nodes exist + */ + getDownstreamNodes(nodeIds: string[], pipelineId: string): CanvasNode[]; + /** + * Returns a boolean to indicate whether the supernode is expanded in place. + * @param nodeId - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + isSuperNodeExpandedInPlace(nodeId: string, pipelineId: string): boolean; + /** + * Sets the label, for the node identified, to edit mode, provided the node + * label is editable. This allows the user to edite the label text. + */ + setNodeLabelEditingMode(nodeId: string, pipelineId: string): void; + /** + * Sets the decoration label, for the decoration in the node identified, to edit + * mode, provided the node label is editable. This allows the user to edit the + * label text. + */ + setNodeDecorationLabelEditingMode( + decId: string, + nodeId: string, + pipelineId: string + ): void; + + /** + * ## Comment methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#comment-methods + */ + + /** + * Returns the comments from the pipeline. + * @param pipelineId - The ID of the pipeline + */ + getComments(pipelineId: string): CanvasComment[]; + /** + * Returns a comment from the pipeline. + * @param comId - The ID of the comment + * @param pipelineId - The ID of the pipeline + */ + getComment(comId: string, pipelineId: string): CanvasComment; + /** + * Returns a position object which indicates the position of where a new + * comment should be placed in a situation where the mouse position cannot be + * used (e.g. the toolbar button was clicked). + * pipelineId - The ID of the pipeline + */ + getNewCommentPosition(pipelineId): { x: number; y: number }; + /** + * Creates a comment for the pipeline. + * @param source - Input data + * @param pipelineId - The ID of the pipeline + */ + createComment(source: CanvasComment, pipelineId: string): void; + /** + * Adds a comment to the pipeline. + * @param data - the data describing the comment + * @param pipelineId - The ID of the pipeline + */ + addComment(data: CanvasComment, pipelineId: string): void; + /** + * Edits a comment with the data. + * @param data - the comment + * @param pipelineId - The ID of the pipeline + */ + editComment(data: CanvasComment, pipelineId: string): void; + /** + * Sets the properties in the comment identified by the commentId. The + * commentProperties is an object containing one or more properties that will + * replace the corresponding properties in the comment. For example: if + * commentProperties is { x_pos: 50, y_pos: 70 } the comment + * will be set to that position. + */ + setCommentProperties( + commentId: string, + commentProperties: Partial, + pipelineId: string + ): void; + /** + * Sets the class name to newClassName of the comments identified by commentIds + * array in the pipeline specified by pipeline ID. The class name will be + * applied to the comment body path. + */ + setCommentsClassName( + commentIds: string[], + newClassName: string, + pipelineId: string + ): void; + /** + * Deletes a comment + * @param comId - The ID of the comment + * @param pipelineId - The ID of the pipeline + */ + deleteComment(comId: string, pipelineId: string): void; + /** + * Gets the class name associated with the comment specified by commentId in the + * pipeline specified by pipelineId. + */ + getCommentClassName(commentId: string, pipelineId: string): void; + /** + * Gets the style spcification (see Wiki) for a comment + * @param commentId - The ID of the node + * @param temporary - A boolean to indicate if the style is serialized when + * getPipelineFlow() method is called or not. + * @param pipelineId - The ID of the pipeline + */ + getCommentStyle( + commentId: string, + temporary: boolean, + pipelineId: string + ): StyleSpec; + /** Hides all comments on the canvas. */ + hideComments(): void; + /** + * Shows all comments on the canvas - if they were previously hiding. + */ + showComments(): void; + /** + * Returns true if comments are currently hiding. + */ + isHidingComments(): boolean; + /** + * Sets the comment identified, to edit mode so the user can + * edit the comment. + */ + setCommentEditingMode(commentId: string, pipelineId: string): void; + + /** + * Link methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#link-methods + */ + + /** + * Gets a link + * @param linkId - The ID of the link + * @param pipelineId - The ID of the pipeline + */ + getLink(linkId: string, pipelineId: string): CanvasLink; + /** + * @return an array of link objects for the pipelineId passed in. + * @param pipelineId - The ID of the pipeline + */ + getLinks(pipelineId: string): CanvasLink[]; + /** + * Sets the properties in the link identified by the linkId. The + * linkProperties is an object containing one or more properties that will + * replace the corresponding properties in the link. For exam`ple: if + * linkProperties is { trgNodeId: "123", trgNodePortId: "789" } the target + * node ID will be set to "123" and the target port ID set to "789". + */ + setLinkProperties( + linkId: string, + linkProperties: Partial, + pipelineId: string + ): void; + /** + * Sets the source properties in the data link identified by the linkId. The + * srcNodeId and srcNodePortId will be set to the values provided. If + * srcNodePortId is set to null the current srcNodePortId will be removed + * from the link. Also, if the link has a srcPos property (because its + * source end is detached) that will be removed. + */ + setNodeDataLinkSrcInfo( + linkId: string, + srcNodeId: string, + srcNodePortId: string, + pipelineId: string + ): void; + /** + * Sets the target properties in the data link identified by the linkId. The + * trgNodeId and trgNodePortId will be set to the values provided. If + * trgNodePortId is set to null the current trgNodePortId will be removed + * from the link. Also, if the link has a trgPos property (because its + * target end is detached) that will be removed. + */ + setNodeDataLinkTrgInfo( + linkId: string, + trgNodeId: string, + trgNodePortId: string, + pipelineId: string + ): void; + /** + * Gets a node to node data link + * @param srcNodeId - The ID of the source node + * @param srcNodePortId - The ID of the source node port + * @param trgNodeId - The ID of the target node + * @param trgNodePortId - The ID of the target node port + * @param pipelineId - The ID of the pipeline + */ + getNodeDataLinkFromInfo( + srcNodeId: string, + srcNodePortId: string, + trgNodeId: string, + trgNodePortId: string, + pipelineId: string + ): CanvasNode; + /** + * Gets a comment to node link + * @param id1 - The ID of the comment + * @param id2 - The ID of the node + * @param pipelineId - The ID of the pipeline + */ + getCommentLinkFromInfo( + id1: string, + id2: string, + pipelineId: string + ): Record; + /** + * Gets a node to node association link + * @param id1 - The ID of one of the node + * @param id2 - The ID of one of the node + * @param pipelineId - The ID of the pipeline + */ + getNodeAssocLinkFromInfo(id1: string, id2: string, pipelineId: string): void; + /** + * Adds links to a pipeline + * @param linkList - An array of links + * @param pipelineId - The ID of the pipeline + */ + addLinks(linkList: CanvasLink[], pipelineId?: string): void; + /** + * Deletes a link + * @param source - An array of links + * @param pipelineId - The ID of the pipeline + */ + deleteLink( + link: string | CanvasLink | Record, + pipelineId?: string + ): void; + /** + * Creates node to node links + * @param data - Data describing the links + * @param pipelineId - The ID of the pipeline + */ + createNodeLinks( + data: { + id?: string; + type: string; + nodes: { + id?: string; + portId?: string; + srcPos?: { x_pos: number; y_pos: number }; + }[]; + targetNodes: { + id?: string; + portId?: string; + trgPos?: { x_pos: number; y_pos: number }; + }[]; + }, + pipelineId?: string + ): CanvasLink[]; + /** + * Creates comment links + * @param data - Data describing the links + * @param pipelineId - The ID of the pipeline + */ + createCommentLinks(data: Record, pipelineId: string): void; + /** + * Sets the class name to newClassName of the links identified by linkIds + * array in the pipeline specified by pipeline ID. The class name will be + * applied to the link line path. + */ + setLinksClassName( + linkIds: string[], + newClassName: string, + pipelineId: string + ): void; + /** + * Sets the style of the links specified by pipelineLinkIds to be + * the newStyle which will be either temporary or permanent. + * @param pipelineLinkIds - This identifies the objects to be styles. It is a + * javascript object like this: + * { + * : [ + * , + * + * ], + * : [ + * , + * + * ] + * } + * @param newStyle - This is a style specification. See the wiki for details. + * @param temporary - A boolean to indicate if the style is serialized when + * getPipelineFlow() method is called or not. + */ + setLinksStyle( + pipelineLinkIds: Record, + newStyle: StyleSpec, + temporary: boolean + ): void; + /** + * Sets the styles of multiple links at once. + * @param pipelineObjStyles - Specified the links and the styles each should be + * set to. It is a javascript array like this: + * [ + * { pipelineId: , objId: , style: }, + * { pipelineId: , objId: , style: }, + * { pipelineId: , objId: , style: } + * ] + * @param temporary - A boolean to indicate if the styles are serialized when + * getPipelineFlow() method is called or not. + */ + setLinksMultiStyle( + pipelineObjStyles: PipelineObjectStyle[], + temporary: boolean + ): void; + /** + * Gets the class name associated with the link specified by linkId in the + * pipeline specified by pipelineId. + */ + getLinkClassName(linkId: string, pipelineId: string): void; + /** + * Returns the style specification for a link. + * @param linkIds - An array of links + * @param temporary - A boolean to indicate if the style is serialized when + * getPipelineFlow() method is called or not. + * @param pipelineId - The ID of the pipeline + * @return the style specification for a link. + */ + getLinkStyle( + linkId: string, + temporary: boolean, + pipelineId: string + ): StyleSpec; + /** + * Sets the decorations on a link. The decorations array passed in + * will replace any decorations currently applied to the link. + * @param linkId - The ID of the link + * @param newDecorations - An array of decorations. See Wiki for details. + * @param pipelineId - The ID of the pipeline + */ + setLinkDecorations( + linkId: string, + newDecorations: Decoration[], + pipelineId: string + ): void; + /** + * Sets the decorations of multiple links at once. The decorations array + * passed in will replace any decorations currently applied to the links. + * @param pipelineLinkDecorations - Specifies the links and their decorations. + * + * ```javascript + * It is a javascript array like this: + * [ + * { pipelineId: , linkId: , decorations: }, + * { pipelineId: , linkId: , decorations: }, + * { pipelineId: , linkId: , decorations: } + * ] + * ``` + */ + setLinksMultiDecorations( + pipelineLinkDecorations: { + pipelineId: string; + linkId: string; + decorations: Decoration[]; + }[] + ): void; + /** + * Gets an array of decorations for a link + * @param linkId - The ID of the link + * @param pipelineId - The ID of the pipeline + */ + getLinkDecorations(linkId: string, pipelineId: string): Decoration[]; + /** + * Sets the decoration label, for the decoration in the link identified, to edit + * mode provided the link label is editable. This allows the user to edit the + * label text. + */ + setLinkDecorationLabelEditingMode( + decId: string, + linkId: string, + pipelineId: string + ): void; + + /** + * Breadcrumbs methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#breadcrumbs-methods + */ + + /** + * Returns the current array of breadcrumbs. There will one breadcrumb object + * for each level of supernode that the user has navigated into. This array + * can be used to display breadcrumbs to the user to show where they are + * within the navigation hierarchy within common canvas. + */ + getBreadcrumbs(): { pipelineId?: string; pipelineFlowId?: string }[]; + /** + * @return the last breadcrumb which represents the level with supernode + * hierarchy that the user has currently navigated to. + */ + getCurrentBreadcrumb(): { pipelineId?: string; pipelineFlowId?: string }; + + /** + * ## Branch highlight methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#branch-highlight-methods + */ + + /** + * Highlights the branch(s) (both upstream and downstream) from the node + * IDs passed in and returns the highlighted object Ids. + * @param nodeIds - An array of node Ids + * @param pipelineId - The ID of the pipeline + */ + highlightBranch(nodeIds: string[], pipelineId: string): string[]; + /** + * Highlights the upstream nodes from the node IDs passed in + * and returns the highlighted object Ids. + */ + highlightUpstream(nodeIds: string[], pipelineId: string): string[]; + /** + * Highlights the downstream nodes from the node IDs passed in + * and returns highlighted object Ids. + * @param nodeIds - An array of node Ids + * @param pipelineId - The ID of the pipeline + */ + highlightDownstream(nodeIds: string[], pipelineId: string): string[]; + + /** + * ## Logging methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#logging-methods + */ + + /** + * @return a Boolean to indicate whether canvas logging is switched on or off. + */ + getLoggingState(): boolean; + /** + * Sets canvas logging based on the Boolean passed in. + * @param state + */ + setLoggingState(state: boolean): void; + + /** + * Palette methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#palette-methods_1 + */ + + openPalette(): void; + closePalette(): void; + isPaletteOpen(): boolean; + + /** + * ## Context menu methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#context-menu-methods + */ + + /** + * Opens the context menu + * @param menuDef + */ + openContextMenu(menuDef: Record): void; + /** + * Closes the context menu + */ + closeContextMenu(): void; + + /** + * ## Notification panel methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#notification-panel-methods + */ + + /** + * Opens the notification panel + */ + openNotificationPanel(): void; + /** + * Closes the notification panel + */ + closeNotificationPanel(): void; + /** + * Either opens or closes the notifictaion panel based on its current status + */ + toggleNotificationPanel(): void; + + /** + * Right flyout methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#right-flyout-methods + */ + + /** + * @return a boolean to indicate if the right flyout is open or not + */ + isRightFlyoutOpen(): boolean; + + /** + * Top panel methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#top-panel-methods + */ + + /** + * @return a boolean to indicate if the top panel is open or not + */ + isTopPanelOpen(): boolean; + + /** + * ## Bottom panel methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#bottom-panel-methods + */ + + isBottomPanelOpen(): boolean; + /** + * Sets the height of the bottom panel in pixels. This can be called + * immediately after the CanvasController has been created, if the bottom + * panel should be displayed at a specific height when it first opens. + * @param height - height in pixels + */ + setBottomPanelHeight(height: number): void; + + /** + * ## Canvas/pipeline navigation methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#canvaspipeline-navigation-methods + */ + + /** + * Displays a pipeline (identified by the pipelineId passed in). This must be + * one of the pipelines referenced by the current set of breadcrumbs. It + * cannot be used to open a new pipeline outside the current set of breadcruumbs. + * @param pipelineId + */ + displaySubPipeline(pipelineId: string): void; + /** + * Displays a pipeline for the supernode (identified by the supernodeId + * parameter) in the pipeline (identified by the pipelineId parameter). For + * correct breadcrumb generation this pipeline should be the one in the last + * of the current set of breadcrumbs. That is, the pipeline currently shown + * "full page" in the canvas. + */ + displaySubPipelineForSupernode(supernodeId: string, pipelineId: string): void; + /** + * Displays full-page the previous pipeline from the one currently being displayed + */ + displayPreviousPipeline(): void; + + /** + * Command Stack interaction methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#command-stack-interaction-methods + */ + + /** + * Adds the command object to the command stack which will cause the + * do() method of the command to be called. + */ + do(command: unknown): void; + /** + * Calls the undo() method of the next available command on the command + * stack that can be undone, if one is available. + */ + undo(): void; + /** + * Undoes a number of commands on the command stack as indicated by the + * 'count' parameter. If 'count' is bigger than the number of undoable commands + * on the stack, all undoable commands currently on the command stack + * will be undone. Uses the editActionHandler method which will cause + * the app's editActionHandler to be called. + */ + undoMulti(count: number): void; + /** + * Calls the redo() method of the next available command on the command + * stack that can be redone, if one is available. + */ + redo(): void; + /** + * Redoes a number of commands on the command stack as indicated by the + * 'count' parameter. If 'count' is bigger than the number of redoable commands + * on the stack, all redoable commands currently on the command stack + * will be redone. Uses the editActionHandler method which will cause + * the app's editActionHandler to be called. + */ + redoMulti(count: number): void; + /** + * Returns true if there is a command on the command stack + * available to be undone. + */ + canUndo(): void; + /** + * Returns true if there is a command on the command stack + * available to be redone. + */ + canRedo(): void; + /** + * Returns a string which is the label that descibes the next undoable + * command. + */ + getUndoLabel(): void; + /** + * Returns a string which is the label that descibes the next redoable + * command. + */ + getRedoLabel(): void; + /** Returns an array of all undoable commands currently on the command stack. */ + getAllUndoCommands(): void; + /** Returns an array of all redoable commands currently on the command stack. */ + getAllRedoCommands(): void; + /** Clears the command stack of all currently stored commands. */ + clearCommandStack(): void; + + /** + * ## Zoom methods + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/#zoom-methods + */ + + /** + * Centers the canvas contents and zooms in + */ + zoomIn(): void; + /** + * Centers the canvas contents and zooms out + */ + zoomOut(): void; + /** + * Zooms the canvas contents to fit within the viewport + */ + zoomToFit(): void; + /** + * Changes the zoom amounts for the canvas. This method does not alter the + * pipelineFlow document. zoomObject is an object with three fields: + * @param zoomObject - accepts a config object where + * + * `x`: Is the horizontal translate amount which is a number indicating the + * pixel amount to move. Negative left and positive right + * + * `y`: Is the vertical translate amount which is a number indicating the + * pixel amount to move. Negative up and positive down. + * + * `k`: is the scale amount which is a number greater than 0 where 1 is the + * default scale size. + */ + zoomTo(zoomObject: { x: number; y: number; k: number }): void; + /** + * Increments the translation of the canvas by the x and y increment + * amounts. The optional animateTime parameter can be provided to animate the + * movement of the canvas. It is a time for the animation in milliseconds. + * If omitted the movement happens immediately. + */ + translateBy(x: number, y: number, animateTime: number): void; + /** + * @return the current zoom object for the currently displayed canvas or null + * if the canvas is not yet rendered for the first time. + */ + getZoom(): Record | null; + /** + * Returns a zoom object required to pan the objects (nodes and/or comments) + * identified by the objectIds array to 'reveal' the objects in the viewport. + * The zoom object returned can be provided to the CanvasController.zoomTo() + * method to perform the zoom/pan action. + * If the xPos and yPos variables are provided it will return a zoom object + * to pan the objects to a location specified by a percentage offset of the + * viewport width and height respectively. + * If the xPos and yPos parameters are undefined (omitted) and all the + * objects are fully within the canvas viewport, it will return null. + * This can be used to detect whether the objects are fully visible or not. + * Otherwise it will return a zoom object which can be used to pan the + * objects into the viewport so they appear at the nearest side of the + * viewport to where they are currently positioned. + * The zoom object has three fields: + * + * `x`: Is the horizontal translate amount which is a number indicating the + * pixel amount to move. Negative left and positive right + * + * `y`: Is the vertical translate amount which is a number indicating the + * pixel amount to move. Negative up and positive down. + * + * `k`: is the scale amount which is a number greater than 0 where 1 is the + * default scale size. + * + * Parameters: + * @param objectIds - An array of nodes and/or comment IDs. + * @param xPos - Optional. Can be set to percentage offset of the viewport width. + * @param yPos - Optional. Can be set to percentage offset of the viewport height. + */ + getZoomToReveal( + objectIds: string[], + xPos?: number, + yPos?: number + ): { x: number; y: number; k: number }; + /** + * Clears any saved zoom values stored in local storage. This means + * newly opened flows will appear with the default zoom. This method + * is only applicable when the `enableSaveZoom` config parameter is + * set to "LocalStorage". + */ + clearSavedZoomValues(): void; +} + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#actionhandler + */ +export type ActionHandler = ( + id: string, + appData?: Record | undefined, + data?: Record +) => void; + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#applypropertychangespropertyset-appdata-additionalinfo-undoinfo-uiproperties + */ +export type ApplyPropertyChangesCallback = ( + propertySet: Record, + appData: Record | undefined, + additionalInfo: { + messages?: MessageDef[]; + title: string; + }, + undoInfo: { + properties: Record; + messages?: Record< + string, + { + type: "info" | "error" | "warning"; + text: string; + propertyId?: PropertyId; + required?: boolean; + validation_id?: string; + } + >; + }, + uiProperties?: Record +) => void; + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#propertylistener + */ +export type PropertyListenerCallback = ( + data: + | { + action: "SET_PROPERTIES" | "PROPERTIES_LOADED"; + } + | { + action: "UPDATE_PROPERTY"; + previousValue: unknown; + value: unknown; + property: PropertyId; + type?: "initial_load"; + } + | { action: string; [key: string]: unknown } +) => void; + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#buttonhandler + */ +export type ButtonHandler = ( + data: { + type: "customButtonIcon"; + propertyId: PropertyId; + buttonId: string; + carbonIcon: string; + }, + callbackIcon: (icon: ReactNode) => {} +) => void; + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#buttoniconhandler + */ +export type ButtonIconHandler = ( + data: { + type: "customButtonIcon"; + propertyId: PropertyId; + buttonId: string; + carbonIcon: string; + }, + callbackIcon: (icon: ReactNode) => {} +) => void; + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#propertyiconhandler + */ +export type PropertyIconHandler = ( + data: { + propertyId: PropertyId; + enumValue: string; + }, + callbackIcon: (icon: ReactNode) => {} +) => {}; + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#helpclickhandler + */ +export type HelpClickHandler = ( + nodeTypeId: string, + helpData: unknown, + appData: Record +) => {}; + +/** + * https://elyra-ai.github.io/canvas/04.02-callbacks/#titlechangehandler + */ +export type TitleChangeHandler = ( + title: string, + callbackFunction: (data: { type: "warning" | "error"; message: string }) => {} +) => void; + +/** + * https://elyra-ai.github.io/canvas/04.08-properties-config/ + */ +export interface CommonPropertiesConfig { + /** + * type of container to display the properties. + * default is 'Custom' + */ + containerType?: "Modal" | "Tearsheet" | "Custom"; + /** + * If set to true, groups will be displayed as an accordion. If false, + * groups are displayed as tabs. default: false + */ + rightFlyout?: boolean; + /** + * calls applyPropertyChanges when focus leave Common Properties. + * default: false + */ + applyOnBlur?: boolean; + /** + * Disable the properties editor “save” button if there are required errors + */ + disableSaveOnRequiredErrors?: boolean; + /** + * adds a button that allows the right-side fly-out editor to + * expand/collapse between small and medium sizes. default: true + */ + enableResize?: boolean; + /** + * used to determine how hidden or disabled control values are returned in + * applyPropertyChanges callback. Current options are “value” or “null”. + * default: "value" + */ + conditionReturnValueHandling?: "value" | "null"; + buttonLabels?: { + /** Label to use for the primary button of the properties dialog */ + primary: string; + /** Label to use for the secondary button of the properties dialog */ + secondary: string; + }; + /** + * show heading and heading icon in right-side fly-out panels. + * default: false + */ + heading?: boolean; + /** + * If set to true, schema validation will be enabled when a parameter + * definition has been set in CommonProperties. Any errors found will be + * reported on the browser dev console. It is recommended you run with + * schema validation switched on while in development mode. + */ + schemaValidation?: boolean; + /** + * When true, will always call applyPropertyChanges even if no changes were + * made. default: false + */ + applyPropertiesWithoutEdit?: boolean; + /** + * maximum characters allowed for multi-line string controls like textarea. + * default: 1024 + */ + maxLengthForMultiLineControls?: number; + /** + * maximum characters allowed for single-line string controls like textfield. + * default: 128 + */ + maxLengthForSingleLineControls?: number; + /** + * Default false. If set to true, currentParameter values whose data type + * does not match what is defined in the parameter definitions will be + * converted to the specified data type. + */ + convertValueDataTypes?: boolean; + /** + * Default true. If set to false, condition ops(isEmpty, isNotEmpty) and + * required fields are allowed to only contain spaces without triggering + * condition errors. + */ + trimSpaces?: boolean; + /** + * Default true to show (required) indicator. If set to false, show + * (optional) indicator next to properties label. + */ + showRequiredIndicator: boolean; + /** + * Default true to show “Alerts” tab whenever there are error or warning + * messages. If set to false, Alerts tab won’t be displayed. + */ + showAlertsTab: boolean; + /** + * Default []. When set this will filter out any values in the array in + * the parameters returned when applyPropertyChanges is call. Only + * primitive data types are currently supported. + */ + returnValueFiltering: unknown[] | string; + /** + * View categories in right-flyout. Can be "accordions" or "tabs". + * default: "accordions". + */ + categoryView: "accordions" | "tabs"; +} + +/** + * https://elyra-ai.github.io/canvas/04.06-custom-components/ + */ +export interface CustomControl { + renderControl(): ReactNode; +} + +/** + * This is a class that constructs a {@link CustomControl} + * https://elyra-ai.github.io/canvas/04.06-custom-components/ + */ +export interface CustomControlClass { + new ( + propertyId: PropertyId, + controller: CommonPropertiesController, + /** Returns values stored in data attribute */ + data: Record, + tableInfo: { + table: boolean; + editStyle: "summary" | "inline"; + } + ): CustomControl; + id(): string; +} + +export interface CommonPropertiesProps { + propertiesInfo: { + parameterDef: PropertyDefinitionsSchema; + appData?: Record; + additionalComponents?: Record; + messages?: PropertyMessageDef[]; + expressionInfo?: ExpressionBuilderExpressionInfoSchema; + initialEditorSize?: "small" | "medium" | "large" | null; + schemaValidation?: boolean; + id?: string; + }; + callbacks: { + /** + * Executes when the user clicks OK in the property dialog. This callback allows users to save the current property values. + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#applypropertychangespropertyset-appdata-additionalinfo-undoinfo-uiproperties + */ + applyPropertyChanges?: ApplyPropertyChangesCallback; + /** + * Executes when user clicks Save or Cancel in the property editor + * dialog. This callback is used to control the visibility of the + * property editor dialog. closeSource identifies where this call was + * initiated from. It will equal “apply” if the user clicked on “Save” + * when no changes were made, or “cancel” if the user clicked on “Cancel” + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#closepropertiesdialogclosesource + */ + closePropertiesDialog?: (closeSource: "apply" | "cancel") => {}; + /** + * Executes when a user property values are updated. + * https://elyra-ai.github.io/canvas/04.02-callbacks/#propertylistener + */ + propertyListener?: PropertyListenerCallback; + /** + * Executes when the property controller is created. Returns the property + * controller. + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#controllerhandler + */ + controllerHandler?: ( + propertyController: CommonPropertiesController + ) => void; + /** + * Called whenever an action is ran. id and data come from uihints and + * appData is passed in with propertiesInfo. + * https://elyra-ai.github.io/canvas/04.02-callbacks/#actionhandler + */ + actionHandler?: ActionHandler; + /** + * Called when the edit button is clicked on in a readonlyTable control, + * or if a custom table button is clicked + * https://elyra-ai.github.io/canvas/04.02-callbacks/#buttonhandler + */ + buttonHandler?: ButtonHandler; + /** + * Called when there is a buttons uihints set in the complex_type_info + * section of the parameter definition. This buttonIconHandler expects a + * Carbon Icon jsx object as the return value from the callback. This is + * used to display the Carbon icon in the custom table button. + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#buttoniconhandler + */ + buttonIconHandler?: ButtonIconHandler; + /** + * Called when a user wants to pass in a specific object to a dropdown + * menu. The propertyIconHandler expects a jsx object as the return value + * from the callback. This is used to display the jsx object in the + * dropdown menu. + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#propertyiconhandler + */ + propertyIconHandler?: PropertyIconHandler; + /** + * Executes when user clicks the help icon in the property editor dialog + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#helpclickhandler + */ + helpClickHandler?: HelpClickHandler; + /** + * Called on properties title change. This callback can be used to + * validate the new title and return warning or error message if the new + * title is invalid. This callback is optional. + * + * In case of error or warning, titleChangeHandler should call + * callbackFunction with an object having type and message. If the new + * title is valid, no need to call the callbackFunction. + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#titlechangehandler + */ + titleChangeHandler?: TitleChangeHandler; + /** + * This is an optional handler you don’t need to implement anything for + * it unless you want to. This callback allows your code to override the + * default tooltip text for the Undo and Redo buttons. + * The propertiesActionLabelHandler callback, when provided, is called + * for the save properties action that is performed in Common Properties. + * This callback should return a string or null. If a string is returned + * it will be shown in the tooltip for the Undo button in the toolbar + * preceded by “Undo:” and the string will also appear in the tooltip for + * the Redo button (when appropriate) preceded by “Redo:”. If null is + * returned, Common Properties will display the default text Save + * {node_name} node properties for the Undo and Redo buttons. + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#propertiesactionlabelhandler + */ + propertiesActionLabelHandler?: () => string; + /** + * Optional callback used for adding a link in properties tooltips. link + * object must be defined under description in uiHints parameter info. + * Common Properties internally pass the link object to + * tooltipLinkHandler callback. This callback must return an object + * having url and label. + * + * https://elyra-ai.github.io/canvas/04.02-callbacks/#tooltiplinkhandler + */ + tooltipLinkHandler?: (link: Record) => { + url: string; + label: string; + }; + }; + propertiesConfig?: CommonPropertiesConfig; + customPanels?: unknown[]; + customControls?: CustomControlClass[]; + customConditionOps?: unknown[]; + light?: boolean; +} + +/** + * https://elyra-ai.github.io/canvas/04-common-properties/ + */ +export declare class CommonProperties extends React.Component { + applyPropertiesEditing: (closeEditor: boolean) => {}; +} + +export type PortObject = + | { + type: "circle" | "circleWithArrow"; + } + | { type: "image"; src: string; width: number; height: number } + | { + type: "jsx"; + src: ReactNode; + width: number; + height: number; + }; + +/** + * https://elyra-ai.github.io/canvas/03.06.01-node-customization/#default-values-for-node-layout-properties + */ +export interface NodeLayout { + /** + * Default node sizes. The height might be overridden for nodes with more ports + * than will fit in the default size. + */ + defaultNodeWidth: number; + defaultNodeHeight: number; + /** + * A space separated list of classes that will be added to the group + * DOM element for the node. + */ + className: string; + /** + * Displays the node outline shape underneath the image and label. + */ + nodeShapeDisplay: boolean; + /** + * Displays the external object specified, as the body of the node + */ + nodeExternalObject: FunctionComponent | ComponentClass; + /** + * Default node shape. Can be "rectangle" or "port-arcs" + */ + nodeShape: "port-arcs" | "rectangle"; + /** + * SVG path strings to define the shape of your node and its + * selection highlighting. If set to null the paths will be set by default + * based on the nodeShape setting. + */ + bodyPath: null | string; + selectionPath: null | string; + /** Display image */ + imageDisplay: boolean; + imageWidth: number; + imageHeight: number; + /** Image position */ + imagePosition: "topLeft"; + imagePosX: number; + imagePosY: number; + /** Display label */ + labelDisplay: boolean; + /** Label dimensions */ + labelWidth: number; + labelHeight: number; + /** Label position */ + labelPosition: "topLeft"; + labelPosX: number; + labelPosY: number; + /** Label appearance */ + labelEditable: false; + /** can be "left" or "center" */ + labelAlign: "left" | "center"; + /** false allow multi-line labels */ + labelSingleLine: boolean; + labelOutline: boolean; + /** null allows unlimited characters */ + labelMaxCharacters: boolean; + /** true allows line feed to be inserted into label */ + labelAllowReturnKey: boolean; + /** + * An array of decorations to be applied to the node. For details see: + * https://elyra-ai.github.io/canvas/03.04.01-decorations/ + * These are added to the node at run time and will not be saved into + * the pipeline flow. + */ + decorations: NodeDecoration[]; + /** + * Positions and dimensions for 9 enumerated default decorator positions. + * decoratorWidth and decoratorHeight are the dimensions of the outline + * rectangle and decoratorPadding is the padding for the image within the + * outline rectangle. + */ + decoratorTopY: number; + decoratorMiddleY: number; + decoratorBottomY: number; + decoratorLeftX: number; + decoratorCenterX: number; + decoratorRightX: number; + /** Width, height and padding for image decorators */ + decoratorWidth: number; + decoratorHeight: number; + decoratorPadding: number; + /** Width and height for label decorators */ + decoratorLabelWidth: 80; + decoratorLabelHeight: 15; + /** Display drop shadow under and round the nodes */ + dropShadow: boolean; + /** The gap between a node and its selection highlight rectangle */ + nodeHighlightGap: number; + /** + * The size of the node sizing area that extends around the node, over + * which the mouse pointer will change to the sizing arrows. + */ + nodeSizingArea: number; + /** Error indicator dimensions */ + errorPosition: "topLeft"; + errorXPos: number; + errorYPos: number; + errorWidth: number; + errorHeight: number; + /** + * When sizing a supernode this decides the size of the corner area for + * diagonal sizing. + */ + nodeCornerResizeArea: number; + /** + * What point to draw the data links from and to when enableLinkType is set + * to "Straight". Possible values are "image_center" or "node_center". + */ + drawNodeLinkLineFromTo: "node_center" | "image_center"; + /** + * What point to draw the comment to node link line to. Possible values + * are "image_center" or "node_center". + */ + drawCommentLinkLineTo: "node_center" | "image_center"; + /** + * This is the size of the horizontal line protruding from the + * port on the source node when drawing an elbow or straight connection line. + */ + minInitialLine: number; + /** + * For the elbow connection type with nodes with multiple output ports, + * this is used to increment the minInitialLine so that connection lines + * do not overlap each other when they turn up or down after the elbow. + */ + minInitialLineIncrement: number; + /** + * This is the minimum size of the horizontal line entering the + * target port on the target node when drawing an Elbow connection line. + */ + minFinalLine: number; + /** + * Display input ports. + */ + inputPortDisplay: boolean; + /** + * Object for input port can be "circle" or "image". + * @deprecated use inputPortDisplayObjects instead + */ + inputPortObject: "circle" | "image"; + /** + * If input port object is "image" use this image. + * @deprecated use inputPortDisplayObjects instead + */ + inputPortImage: string; + /** + * If input port dimensions for `inputPortObject: "image"`. + * @deprecated use inputPortDisplayObjects instead + */ + inputPortWidth: number; + /** + * @deprecated use inputPortDisplayObjects instead + */ + inputPortHeight: number; + inputPortDisplayObjects: PortObject[]; + /** + * Indicates whether multiple input ports should be automatically + * positioned (true) or positioned based on the contents of + * inputPortPositions array (false). + */ + inputPortAutoPosition: boolean; + /** + * An array of input port positions. Each element is structured like + * this: { x_pos: 5, y_pos: 10, pos: "topLeft" }. x_pos and y_pos are + * offsets from the pos point on the node. + * The order of the elements corresponds to the order of ports in the + * inputs array for the node. If there are more input ports than elements + * in the array, the last element will be used for all remaining ports. + */ + inputPortPositions: { x_pos: number; y_pos: number; pos: NodePosition }[]; + /** + * An array of elements to control display of input port guide objects. + * That is the object drawn at the end of a new link as it is being dragged. + * Each element can have a number of different structures like this: + * Either + * { type: "circle" } // Can also be "circleWithArrow" + * Or + * { type: "image", src: "path/picture.svg", width: 10, height: 10 } + * Or + * { type: "jsx", src: (), width: 16, height: 16 } + * + * The order of the elements corresponds to the order of ports in the + * inputs array for the node. If there are more input ports than elements + * in the array, the last element will be used for all remaining ports. + */ + inputPortGuideObjects: PortObject[]; + /** + * Position of left single input port. Multiple input ports will be + * automatically positioned with the Y coordinate being overriden. These + * values are an offset from the top left corner of the node outline. + * Used when linkDirection is "LeftRight". + */ + inputPortLeftPosX: number; + inputPortLeftPosY: number; + /** + * Position of top single input port. Multiple input ports will be + * automatically positioned with the X coordinate being overriden. These + * values are an offset from the top left corner of the node outline. + * Used when linkDirection is "TopBottom". + */ + inputPortTopPosX: number; + inputPortTopPosY: number; + /** + * Position of bottom single input port. Multiple input ports will be + * automatically positioned with the X coordinate being overriden. These + * values are an offset from the bottom left corner of the node outline. + * Used when linkDirection is "BottomTop". + */ + inputPortBottomPosX: number; + inputPortBottomPosY: number; + /** + * The 'guide' is the object drawn at the mouse position as a new line + * is being dragged outwards. + * Object for input port guide can be "circle" or "image". + * @deprecated use inputPortGuideObjects instead + */ + inputPortGuideObject: "circle" | "image"; + /** + * If input port guide object is "image" use this image. + * @deprecated use inputPortGuideObjects instead + */ + inputPortGuideImage: string; + /** Display output ports. */ + outputPortDisplay: boolean; + /** + * Object for output port can be "circle" or "image". + * @deprecated use outputPortDisplayObjects instead + */ + outputPortObject: "circle" | "image"; + /** + * If output port object is "image" use this image. + * @deprecated use outputPortDisplayObjects instead + */ + outputPortImage: string; + /** + * Output port dimensions for `outputPortImage: "image"`. + * @deprecated use outputPortDisplayObjects instead + */ + outputPortWidth: number; + /** + * @deprecated use outputPortDisplayObjects instead + */ + outputPortHeight: number; + /** + * An array of elements to control display of output ports. Each element + * can have a number of different structures like this: + * Either + * { type: "circle" } // Can also be "circleWithArrow" + * Or + * { type: "image", src: "path/picture.svg", width: 10, height: 10 } + * Or + * { type: "jsx", src: (), width: 16, height: 16 } + * + * The order of the elements corresponds to the order of ports in the + * outputs array for the node. If there are more output ports than elements + * in the array, the last element will be used for all remaining ports. + */ + outputPortDisplayObjects: PortObject[]; + /** + * Indicates whether multiple output ports should be automatically + * positioned (true) or positioned based on the contents of + * outputPortPositions array (false). + */ + outputPortAutoPosition: boolean; + /** + * An array of output port positions. Each element is structured like + * this: { x_pos: 5, y_pos: 10, pos: "topRight" }. x_pos and y_pos are + * offsets from the pos point on the node. + * The order of the elements corresponds to the order of ports in the + * outputs array for the node. If there are more output ports than elements + * in the array, the last element will be used for all remaining ports. + */ + outputPortPositions: { x_pos: number; y_pos: number; pos: NodePosition }[]; + /** + * An array of elements to control display of output port guide objects. + * That is the object drawn at the end of a new link as it is being dragged. + * Each element can have a number of different structures like this: + * Either + * { type: "circle" } // Can also be "circleWithArrow" + * Or + * { type: "image", src: "path/picture.svg", width: 10, height: 10 } + * Or + * { type: "jsx", src: (), width: 16, height: 16 } + * + * The order of the elements corresponds to the order of ports in the + * outputs array for the node. If there are more output ports than elements + * in the array, the last element will be used for all remaining ports. + */ + outputPortGuideObjects: PortObject[]; + /** + * Position of right single input port. Multiple input ports will be + * automatically positioned with the Y coordinate being overriden. These + * values are an offset from the top right corner of the node outline. + * Used when linkDirection is "LeftRight". + */ + outputPortRightPosX: number; + outputPortRightPosY: number; + /** + * Position of top single input port. Multiple input ports will be + * automatically positioned with the X coordinate being overriden. These + * values are an offset from the top left corner of the node outline. + * Used when linkDirection is "BottomTop". + */ + outputPortTopPosX: number; + outputPortTopPosY: number; + /** + * Position of bottom single input port. Multiple input ports will be + * automatically positioned with the X coordinate being overriden. These + * values are an offset from the bottom left corner of the node outline. + * Used when linkDirection is "TopBottom". + */ + outputPortBottomPosX: number; + outputPortBottomPosY: number; + /** + * The 'guide' is the object drawn at the mouse position as a new line + * is being dragged outwards. + * Object for output port guide can be "circle" or "image". + * @deprecated use outputPortGuideObjects instead + */ + outputPortGuideObject: "circle" | "image"; + /** + * If output port guide object is "image" use this image. + * @deprecated use outputPortGuideObjects instead + */ + outputPortGuideImage: string; + /** + * Automatically increases the node size to accommodate its ports so both + * input and output ports can be shown within the dimensions of + * the node. + */ + autoSizeNode: boolean; + /** Radius of either the input or output ports when they are set to "circle" */ + portRadius: number; + /** + * Size of an offset above and below the set of port arcs. + */ + portArcOffset: number; + /** + * Radius of an imaginary circle around the port. This controls the + * spacing of ports and the size of port arcs when nodeShape is set to + * port-arcs. + */ + portArcRadius: number; + /** Spacing between the port arcs around the ports. */ + portArcSpacing: number; + /** + * Position of the context toolbar relative to the node. Some adjustment + * will be made to account for the width of the toolbar. + */ + contextToolbarPosition: NodePosition; + /** Display of vertical ellipsis to show context menu */ + ellipsisDisplay: boolean; + ellipsisPosition: "topLeft"; + ellipsisWidth: number; + ellipsisHeight: number; + ellipsisPosX: number; + ellipsisPosY: number; + ellipsisHoverAreaPadding: number; +} + +/** + * https://elyra-ai.github.io/canvas/03.02.01-canvas-config/ + */ +export interface CanvasConfig { + enableInteractionType?: "Mouse" | "Carbon" | "Trackpad"; + enableNodeFormatType?: "Horizontal" | "Vertical"; + enableLinkType?: "Curve" | "Elbow" | "Straight" | "Parallax"; + enableLinkDirection?: "LeftRight" | "TopBottom" | "BottomTop"; + enableLinkSelection?: "None" | "LinkOnly" | "Handles" | "Detachable"; + enableLinkReplaceOnNewConnection?: boolean; + enableInternalObjectModel?: boolean; + enablePaletteLayout?: "Model" | "Flyout" | "None"; + enableToolbarLayout?: "Top" | "None"; + enableResizableNodes?: boolean; + enableInsertNodeDroppedOnLink?: boolean; + enableRightFlyoutUnderToolbar?: boolean; + enablePositionNodeOnRightFlyoutOpen?: boolean; + enableHighlightUnavailableNodes?: boolean; + enableHighlightNodeOnNewLinkDrag?: boolean; + enableAutoLinkOnlyFromSelNodes?: boolean; + enableExternalPipelineFlows?: boolean; + enableMoveNodesOnSupernodeResize?: boolean; + enableDisplayFullLabelOnHover?: boolean; + enableSingleOutputPortDisplay?: boolean; + enableDragWithoutSelect?: boolean; + enableDragToMoveSizeNodesComments?: boolean; + enableEditingActions?: boolean; + enableStateTag?: "None" | "ReadOnly" | "Locked"; + enableDropZoneOnExternalDrag?: boolean; + enableNodeLayout?: Partial; + enableSaveZoom?: "LocalStorage" | "None" | "PipelineFlow"; + enablePanIntoViewOnOpen?: boolean; + enableZoomIntoSubFlows?: boolean; + enableSnapToGridType?: "During" | "None" | "After"; + enableSnapToGridX?: string; + enableSnapToGridY?: string; + enableAutoLayoutVerticalSpacing?: string; + enableAutoLayoutHorizontalSpacing?: string; + enableAssocLinkCreation?: boolean; + enableAssocLinkType?: "Straight" | "RightSideCurve"; + enableBrowserEditMenu?: boolean; + enableNarrowPalette?: boolean; + enableContextToolbar?: boolean; + enableRightFlyoutDragToResize?: boolean; + enableFocusOnMount?: boolean; + emptyCanvasContent?: ReactNode; + dropZoneCanvasContent?: ReactNode; + schemaValidation?: boolean; + tipConfig?: { + palette?: boolean; + nodes?: boolean; + ports?: boolean; + links?: boolean; + decorations?: boolean; + stateTag?: boolean; + }; + enableSelfRefLinks?: boolean; + enableRaiseNodesToTopOnHover?: boolean; + enableLinkMethod?: "Ports" | "Freeform"; + /** + * @deprecated + */ + enableStraightLinksAsFreeform?: boolean; + enableLinksOverNodes?: boolean; + enableMarkdownInComments?: boolean; + enablePaletteHeader?: ReactNode; + /** + * @deprecated + */ + paletteInitialState?: boolean; + enableKeyboardNavigation?: boolean; + enableParentClass?: string; + enableImageDisplay?: "SVGInline" | "LoadSVGToDefs" | "SVGAsImage"; + enableLeftFlyoutUnderToolbar?: boolean; +} + +export interface ToolbarActionItem { + action?: string; + label?: string; + enable?: boolean; + iconEnabled?: string; + iconDisabled?: string; + incLabelWithIcon?: string; + kind?: string; + tooltip?: string; + isSelected?: boolean; + jsx?: ReactNode; + divider?: boolean; +} +export interface ToolbarConfig { + leftBar: ToolbarActionItem[]; + rightBar?: ToolbarActionItem[]; + overrideAutoEnableDisable: boolean; +} + +export interface NotificationConfig { + action: string; + label: string; + enable: boolean; + notificationHeader: string; + notificationSubtitle: string; + emptyMessage: string; + clearAllMessage: string; + keepOpen: boolean; + clearAllCallback: () => void; +} + +export interface CtxMenuConfig { + enableCreateSupernodeNonContiguous: boolean; + defaultMenuEntries: { + saveToPalette: boolean; + createSupernode: boolean; + displaySupernodeFullPage: boolean; + colorBackground: boolean; + }; +} + +export interface KeyboardConfig { + actions: { + delete: boolean; + undo: boolean; + redo: boolean; + selectAll: boolean; + cutToClipboard: boolean; + copyToClipboard: boolean; + pasteFromClipboard: boolean; + }; +} + +export type CtxMenuHandlerSource = + | { + type: "node"; + targetObject: CanvasNode; + selectedObjectIds: string[]; + mousePos: { x: string; y: string }; + } + | { + type: "input_port" | "output_port" | "link" | "comment"; + targetObject: Record; + selectedObjectIds: string[]; + mousePos: { x: string; y: string }; + } + | { + type: "canvas"; + selectedObjectIds: string[]; + mousePos: { x: string; y: string }; + }; + +/** Existing internal common canvas actions */ +type InternalAction = + | "selectAll" + | "cut" + | "copy" + | "paste" + | "undo" + | "redo" + | "createSupernode" + | "expandSupernode" + | "collapseSupernode" + | "deleteSelectedObjects" + | "createComment" + | "deleteLink" + | "disconnectNode" + | "highlightBranch" + | "highlightDownstream" + | "highlightUpstream" + | "unhighlight"; +export interface CtxMenuHandlerMenuAction { + action?: InternalAction | string; + label?: string; + divider?: boolean; + submenu?: boolean; + enable?: boolean; + toolbarItem?: boolean; + icon?: string | ReactNode; +} + +export interface EditActionData { + editType: + | "createComment" + | "createNode" + | "moveObjects" + | "linkNodes" + | "linkComment" + | "resizeObjects" + | "editComment" + | "expandSuperNodeInPlace" + | "displaySubPipeline" + | "displayPreviousPipeline" + | string; + editSource: "contextmenu" | "toolbar" | "keyboard" | "canvas"; + selectedObjects: Record[]; + /** @deprecated */ + selectedObjectIds: string[]; + [key: string]: unknown; +} + +export type EditActionCommand = unknown; + +export type ClickActionSource = + | { + clickType: "DOUBLE_CLICK" | "SINGLE_CLICK" | "SINGLE_CLICK_CONTEXTMENU"; + objectType: "node" | "comment" | "canvas" | "region"; + id?: string; + selectedObjectIds: string[]; + } + | { + clickType: "DOUBLE_CLICK" | "SINGLE_CLICK" | "SINGLE_CLICK_CONTEXTMENU"; + objectType: "port"; + id: string; + selectedObjectIds: string[]; + nodeId: string; + }; + +export type GeneratorAction = + | "create_node" + | "create_comment" + | "create_node_link" + | "create_comment_link" + | "clone_node" + | "clone_comment" + | "clone_node_link" + | "clone_comment_link"; +export interface GeneratorActionCreateNode { + label: string; + description: string; + operator_id_ref: string; + type: "model_node"; + image: string; + input_ports: { + id: "inPort" | "outPort"; + label: "Input Port"; + cardinality: { + min: number; + max: number; + }; + }[]; + output_ports: []; +} +export type GeneratorData = GeneratorActionCreateNode | null; + +export interface SelectionChangeHandlerData { + selection: string[]; + selectedLinks: CanvasLink[]; + selectedNodes: NodeTypeDef[]; + selectedComments: CanvasLink[]; + addedLinks: CanvasLink[]; + addedNodes: NodeTypeDef[]; + addedComments: unknown[]; + deselectedLinks: CanvasLink[]; + deselectedNodes: NodeTypeDef[]; + deselectedComments: unknown[]; + selectedPipelineId: string; +} + +export interface CommonCanvasProps { + /** + * https://elyra-ai.github.io/canvas/03.04-canvas-controller/ + * Your application code can programmatically perform many of the actions that the user can do in the common canvas using the Canvas Controller API. Note: See this section for differences between the structure of objects in the API and the schema. + * In most cases within the API, the pipelineId parameter is optional. If pipelineId is omitted, the method will default to the pipeline that is currently displayed in the main canvas viewport. + * + * Warning 1: Do not alter the IDs of objects that currently exist on the canvas. Changing object IDs can cause internal problems, in particular with the command stack. + * + * Warning 2: When using external pipeline flows, Pipeline IDs must be globally unique identifiers. + */ + canvasController: CanvasController; + /** + * https://elyra-ai.github.io/canvas/03.02.01-canvas-config/ + */ + config?: CanvasConfig; + /** + * https://elyra-ai.github.io/canvas/03.02.02-toolbar-config/ + */ + toolbarConfig?: ToolbarConfig; + /** + * https://elyra-ai.github.io/canvas/03.02.03-notification-config/ + */ + notificationConfig?: NotificationConfig; + /** + * https://elyra-ai.github.io/canvas/03.02.04-context-menu-config/ + */ + contextMenuConfig?: CtxMenuConfig; + /** + * https://elyra-ai.github.io/canvas/03.02.05-keyboard-config/ + */ + keyboardConfig?: KeyboardConfig; + /** + * https://elyra-ai.github.io/canvas/03.03.01-context-menu-handler/ + */ + contextMenuHandler?: ContextMenuHandler; + /** + * https://elyra-ai.github.io/canvas/03.03.02-before-edit-action-handler/ + */ + beforeEditActionHandler?: ( + data: EditActionData, + command: EditActionCommand + ) => EditActionCommand | void; + /** + * https://elyra-ai.github.io/canvas/03.03.03-edit-action-handler/ + */ + editActionHandler?: ( + data: EditActionData, + command: EditActionCommand + ) => void; + /** + * https://elyra-ai.github.io/canvas/03.03.09-click-action-handler/ + */ + clickActionHandler?: (source: ClickActionSource) => void; + /** + * https://elyra-ai.github.io/canvas/03.03.05-decoration-action-handler/ + */ + decorationActionHandler?: ( + object: Record, + id: string, + pipelineId: string + ) => void; + /** + * https://elyra-ai.github.io/canvas/03.03.04-layout-handler/ + */ + layoutHandler?: (data: CanvasNode) => Record; + /* + * https://elyra-ai.github.io/canvas/03.03.06-tip-handler/ + */ + tipHandler?: ( + tipType: string, + data: Record + ) => string | ReactNode | null; + /** + * https://elyra-ai.github.io/canvas/03.03.07-id-generator-handler/ + */ + idGeneratorHandler?: (action: GeneratorAction, data?: GeneratorData) => void; + /** + * https://elyra-ai.github.io/canvas/03.03.08-selection-change-handler/ + */ + selectionChangeHandler?: (data: SelectionChangeHandlerData) => void; + /** + * https://elyra-ai.github.io/canvas/03.03.10-action-label-handler/ + */ + actionLabelHandler?: (action: GeneratorAction) => string | null | void; + showRightFlyout?: boolean; + rightFlyoutContent?: ReactNode; + showBottomPanel?: boolean; + bottomPanelContent?: ReactNode; +} + +export class CommonCanvas extends React.Component {} diff --git a/canvas_modules/common-canvas/types/operator-v3.model.ts b/canvas_modules/common-canvas/types/operator-v3.model.ts new file mode 100644 index 0000000000..a314ad006b --- /dev/null +++ b/canvas_modules/common-canvas/types/operator-v3.model.ts @@ -0,0 +1,192 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AppDataDef } from "./app-data-def"; + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/operators/operator-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +type basicParameterTypes = + | 'integer' + | 'double' + | 'string' + | 'date' + | 'time' + | 'timestamp' + | 'custom' + | 'boolean' + | 'password'; + +/** https://elyra-ai.github.io/canvas/04.01-parameter-definition/#parameter-definitions */ +type allParameterTypes = + | `array[${string}]` + | `map[string, ${string}]` + | basicParameterTypes + | string; + +/** + * Operator parameters definition + */ +export type ParameterDefinition = ParameterDefinition1 & { + /** + * A unique name for the parameter. + */ + id?: string; + /** + * Indication whether parameter is required or optional + */ + required?: boolean; + /** + * Role of parameter + */ + role?: 'column' | 'new_column' | 'expression'; + /** + * Field type. Can be a primitive type (string, integer, double, date, time, timestamp, or custom), an array, or map containing those types(note arrays and maps can contain complex_types) + */ + type?: allParameterTypes; + /** + * List of valid values. Can be used instead of specifying type. + */ + enum?: unknown[]; + /** + * default value based on type of parameter + */ + default?: + | ParameterRefDefinition + | ( + | string + | number + | boolean + | unknown[] + | { + [k: string]: unknown; + } + | null + ); + [k: string]: unknown; +}; +export type ParameterDefinition1 = { + [k: string]: unknown; +}; + +/** + * Operator schema for the Watson Data Platform + */ +export interface WatsonDataPlatformOperatorSchema { + /** + * Operator identifier + */ + id: string; + /** + * Refers to the JSON schema used to validate documents of this type + */ + json_schema?: 'https://api.dataplatform.ibm.com/schemas/common-pipeline/operators/operator-v3-schema.json'; + /** + * operator type + */ + operator_type: + | 'model' + | 'transformer' + | 'estimator' + | 'dataReader' + | 'dataWriter'; + /** + * List of input ports. If no ports are defined this is a source operator that accepts no data inputs. If the input_ports array is missing a single input port with id 'input_port' is assumed which accepts only a single connection. + * + * @minItems 0 + */ + input_ports?: PortDefinition[]; + /** + * List of output ports. If no ports are defined this is a terminal operator that provides no data outputs. If the output_ports array is missing a single output port named 'output_port' is assumed which accepts multiple connections. + * + * @minItems 0 + */ + output_ports?: PortDefinition[]; + /** + * List of complex types + */ + complex_types?: ComplexTypeDefinition[]; + /** + * List of parameters + */ + parameters: ParameterDefinition[]; + app_data?: AppDataDef; + [k: string]: unknown; +} +/** + * Operator ports support multiple differentiated connections for either inputs or outputs. + */ +export interface PortDefinition { + /** + * Unique identifier within the node + */ + id?: string; + /** + * Property to capture how many connections are allowed for this port, e.g., min: 1, max:1 implies you must supply 1 and only 1; min:0, max:1 implies it is optional and a max of one, min:0, max:-1 means it is optional and you can may have any number of connections. The default value is 1:1 for inputs and 1:-1 for outputs. + */ + cardinality?: { + /** + * Minimum data sets that are required for this port + */ + min?: number; + /** + * Maximum data sets that are allowed on this port. A negative value indicates unlimited. The default value is 1 for inputs and -1 for outputs. + */ + max?: number; + }; + /** + * List of parameters + */ + parameters?: ParameterDefinition[]; + /** + * List of complex types + */ + complex_types?: ComplexTypeDefinition[]; + [k: string]: unknown; +} +/** + * Structure for parameter refs + */ +export interface ParameterRefDefinition { + /** + * Reference to another parameter. + */ + parameter_ref: string; + [k: string]: unknown; +} +/** + * Structure for complex parameters + */ +export interface ComplexTypeDefinition { + /** + * Identifier of complex type, can be referenced in other places. + */ + id: string; + /** + * Used to determine how parameters in the complex_type stored. Valid values are array and object. + */ + type?: string; + key_definition?: ParameterDefinition; + /** + * List of parameters + */ + parameters: (ParameterDefinition | ComplexTypeDefinition)[]; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/palette-v3.ts b/canvas_modules/common-canvas/types/palette-v3.ts new file mode 100644 index 0000000000..23b571fbef --- /dev/null +++ b/canvas_modules/common-canvas/types/palette-v3.ts @@ -0,0 +1,80 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { NodeTypeDef } from './pipeline-flow-v3'; + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-canvas/palette/palette-v3-schema.json + * after removing broken $ref URL's. + * It has been modified by hand, so run a diff if you need to update it. + */ + +/** + * Common Canvas palette schema + */ +export interface HttpsApiDataplatformIbmComSchemasCommonCanvasPalettePaletteV3SchemaJson { + /** + * Palette schema version + */ + version?: '3.0'; + /** + * Array of palette categories + * + * @minItems 0 + */ + categories?: CategoryDef[]; +} +/** + * Palette Category + */ +export interface CategoryDef { + /** + * ID of the category + */ + id: string; + /** + * Category label + */ + label: string; + /** + * Category description + */ + description?: string; + /** + * Boolean to indicate if the category is open (true) or not (false). + */ + is_open?: boolean; + /** + * When set to a non-empty string and node_types is empty, is used to indicate that no nodes exist + */ + empty_text?: string; + /** + * When set to a non-empty string, causes a loading indicator to appear with this text as a label + */ + loading_text?: string; + /** + * Encoded image or image reference for the category + */ + image?: string; + /** + * Array of pipeline node types + * + * @minItems 0 + */ + node_types?: NodeTypeDef[]; +} diff --git a/canvas_modules/common-canvas/types/parameter-defs-v3.model.ts b/canvas_modules/common-canvas/types/parameter-defs-v3.model.ts new file mode 100644 index 0000000000..e5d0f85c9f --- /dev/null +++ b/canvas_modules/common-canvas/types/parameter-defs-v3.model.ts @@ -0,0 +1,73 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-canvas/parameter-defs/parameter-defs-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +import { ConditionsDefinition } from './conditions-v3.model'; +import { + ComplexTypeDefinition, + ParameterDefinition, +} from './operator-v3.model'; +import { WDPUIHintsSchema } from './uihints-v3.model'; + +/** + * Watson Data Platform Property Definition Schema for the Common Properties editor + */ +export interface PropertyDefinitionsSchema { + titleDefinition?: { + title?: string; + /** + * True if the title can be edited. False if the title should be readonly. + */ + editable?: boolean; + [k: string]: unknown; + }; + /** + * Current parameter set upon input. Keys are parameter names, values are their values. + */ + current_parameters?: { + [k: string]: unknown; + }; + /** + * Current UI only parameter set upon input. Keys are parameter names, values are their values. + */ + current_ui_parameters?: { + [k: string]: unknown; + }; + parameters?: ParameterDefinition[]; + complex_types?: ComplexTypeDefinition[]; + uihints?: WDPUIHintsSchema; + conditions?: ConditionsDefinition[]; + dataset_metadata?: + | { + [k: string]: unknown; + } + | { + [k: string]: unknown; + }[]; + /** + * Map of string resources. + */ + resources?: { + [k: string]: unknown; + }; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/parameters-v3.ts b/canvas_modules/common-canvas/types/parameters-v3.ts new file mode 100644 index 0000000000..0c35d887ff --- /dev/null +++ b/canvas_modules/common-canvas/types/parameters-v3.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/parameters/parameters-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +/** + * Parameters schema for pipelines in the Watson Data Platform + */ +export interface WatsonDataPlatformPipelineParametersSchema { + /** + * Refers to the JSON schema used to validate documents of this type + */ + json_schema?: 'https://api.dataplatform.ibm.com/schemas/common-pipeline/parameters/parameters-v3-schema.json'; + /** + * @minItems 0 + */ + parameters: ParamPropertyDef[]; + [k: string]: unknown; +} +/** + * The parameter definition. + */ +export interface ParamPropertyDef { + /** + * The name of the parameter. + */ + name: string; + /** + * The description of the parameter. + */ + description?: string; + /** + * The parameter type. Each product manages its own list of parameter type. The parameter type should be an enum list ideally. As schema is common to all products, use string instead. + */ + type: string; + /** + * The parameter subtype. + */ + subtype?: string; + /** + * The literal default value to replace at runtime. + */ + value?: { + [k: string]: unknown; + }; + /** + * Valid values. + */ + valid_values?: { + [k: string]: unknown; + }; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/parametersets-v3.ts b/canvas_modules/common-canvas/types/parametersets-v3.ts new file mode 100644 index 0000000000..c8a168849c --- /dev/null +++ b/canvas_modules/common-canvas/types/parametersets-v3.ts @@ -0,0 +1,88 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript --unreachableDefinitions + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/parameters/parametersets-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +import { ParamPropertyDef } from './parameters-v3'; + +/** + * Parametersets schema for pipelines in the Watson Data Platform + */ +export interface WatsonDataPlatformPipelineParametersetsSchema { + /** + * Refers to the JSON schema used to validate documents of this type + */ + json_schema?: 'https://api.dataplatform.ibm.com/schemas/common-pipeline/parameters/parametersets-v3-schema.json'; + paramset: { + [k: string]: unknown; + }; + [k: string]: unknown; +} +/** + * The parameter set definition referenced within a pipleine. + * + * This interface was referenced by `WatsonDataPlatformPipelineParametersetsSchema`'s JSON-Schema + * via the `definition` "paramset_def". + */ +export interface ParamsetDef { + /** + * The disambiguating name of the parameter set. + */ + name: string; + /** + * The description of the parameter set. + */ + description?: string; + /** + * @minItems 0 + */ + parameters?: ParamPropertyDef[]; + [k: string]: unknown; +} +/** + * Refers to the external parameter set. + * + * This interface was referenced by `WatsonDataPlatformPipelineParametersetsSchema`'s JSON-Schema + * via the `definition` "paramset_ref". + */ +export interface ParamsetRef { + /** + * The disambiguating name of the parameter set. + */ + name?: string; + /** + * A reference to a parameter set by ID. + */ + ref: string; + /** + * If ref is set, this refers to the ID of the catalog which contains the parameter set. If neither this attribute nor project_ref and space_ref are specified, the parameter set will be assumed to exist in the project, catalog or space which contains the pipeline. + */ + catalog_ref?: string; + /** + * If ref is set, this refers to the ID of the project which contains the parameter set. If neither this attribute nor catalog_ref and space_ref are specified, the parameter set will be assumed to exist in the project, catalog or space which contains the pipeline. + */ + project_ref?: string; + /** + * If ref is set, this refers to the ID of the space which contains the parameter set. If neither this attribute nor catalog_ref and project_ref are specified, the parameter set will be assumed to exist in the project, catalog or space which contains the pipeline. + */ + space_ref?: string; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/pipeline-connection-v3.ts b/canvas_modules/common-canvas/types/pipeline-connection-v3.ts new file mode 100644 index 0000000000..fd2d28eb73 --- /dev/null +++ b/canvas_modules/common-canvas/types/pipeline-connection-v3.ts @@ -0,0 +1,118 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AppDataDef } from "./app-data-def"; + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript --unreachableDefinitions + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/pipeline-connection/pipeline-connection-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +/** + * Connection schema for pipelines in the Watson Data Platform + */ +export interface WatsonDataPlatformPipelineConnectionSchema { + [k: string]: unknown; +} +/** + * Details of the connection to use for a pipeline binding node. + * + * This interface was referenced by `WatsonDataPlatformPipelineConnectionSchema`'s JSON-Schema + * via the `definition` "common_pipeline_connection_def". + */ +export interface CommonPipelineConnectionDef { + /** + * A name tag for disambiguating connections + */ + name?: string; + app_data?: AppDataDef; + /** + * A reference to a connection by ID. + */ + ref: string; + /** + * If ref is set, this refers to the ID of the catalog which contains the connection. If neither this attribute nor project_ref are specified, the connection will be assumed to exist in the project, space, or catalog which contains the pipeline. + */ + catalog_ref?: string; + /** + * If ref is set, this refers to the ID of the project which contains the connection. If neither this attribute nor catalog_ref are specified, the connection will be assumed to exist in the project, space, or catalog which contains the pipeline. + */ + project_ref?: string; + /** + * If ref is set, this refers to the ID of the space which contains the connection. If neither this attribute nor space_ref are specified, the connection will be assumed to exist in the project, space, or catalog which contains the pipeline. + */ + space_ref?: string; + /** + * The properties for the connection. The specific properties allowed depend on the type of connection referenced. + */ + properties?: { + [k: string]: unknown; + }; + [k: string]: unknown; +} +/** + * Details of the data asset contained in a catalog or project to use for a pipeline binding node. + * + * This interface was referenced by `WatsonDataPlatformPipelineConnectionSchema`'s JSON-Schema + * via the `definition` "common_pipeline_data_asset_def". + */ +export interface CommonPipelineDataAssetDef { + app_data?: AppDataDef; + /** + * A reference to a data asset by ID. + */ + ref?: string; + /** + * If ref is set, this refers to the ID of the catalog which contains the data asset. If neither this attribute nor project_ref are specified, the data asset will be assumed to exist in the project, space, or catalog which contains the pipeline. + */ + catalog_ref?: string; + /** + * If ref is set, this refers to the ID of the project which contains the data asset. If neither this attribute nor catalog_ref are specified, the data asset will be assumed to exist in the project, space, or catalog which contains the pipeline. + */ + project_ref?: string; + /** + * If ref is set, this refers to the ID of the space which contains the data asset. If neither this attribute nor space_ref are specified, the data asset will be assumed to exist in the project, space, or catalog which contains the pipeline. + */ + space_ref?: string; + /** + * Properties controlling how the data asset is used. + */ + properties?: { + /** + * The ID of the data asset attachment to use. If not specified and used as a source, the first suitable attachment found will be used. If not specified and used as a target, a new attachment will be created. + */ + attachment_ref?: string; + /** + * Specifies the name of the data asset to read, create or update if ref is unset. + */ + name?: boolean & string; + /** + * When used as a target, whether to update the data asset with the schema when a run completes or not (will be automatically updated if not supplied by caller). + */ + no_write_schema?: boolean; + /** + * When used as a target, whether to update the data asset with the status when a run completes or not (will be automatically updated if not supplied by caller). + */ + no_write_status?: boolean; + } & { + [k: string]: { + [k: string]: unknown; + }; + }; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/pipeline-flow-ui-v3.ts b/canvas_modules/common-canvas/types/pipeline-flow-ui-v3.ts new file mode 100644 index 0000000000..3fee7d7b4c --- /dev/null +++ b/canvas_modules/common-canvas/types/pipeline-flow-ui-v3.ts @@ -0,0 +1,471 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript --unreachableDefinitions + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/pipeline-flow/pipeline-flow-ui-v3-schema.json + * after removing broken $ref URL's. + * It has been modified by hand, so run a diff if you need to update it. + */ + +import { PipelineDef as NonUiPipelineDef } from './pipeline-flow-v3'; + +/** + * WDP Pipeline Flow UI Schema. Defines UI-only constructs for pipeline flow documents. + */ +export interface HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson { + [k: string]: unknown; +} +/** + * Top level UI information + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "pipeline_overview_def". + */ +export interface PipelineOverviewDef { + /** + * User-defined name + */ + name?: string; + /** + * User-defined description + */ + description?: string; + /** + * CSS class name + */ + class_name?: string; + [k: string]: unknown; +} +/** + * Pipeline level UI information + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "pipeline_def". + */ +export interface PipelineDef { + /** + * User-defined description + */ + description?: string; + zoom?: + | number + | { + /** + * Horizontal translation amount. Positive value moves right, negative to the left. + */ + x: number; + /** + * Vertical translation amount. Positive value moves down, negative moves up. + */ + y: number; + /** + * Scale amount. 1.0 is the standard scale amount. Smaller values zoom out. Larger values zoom in. + */ + k: number; + }; + /** + * Array of Comments, optionally associated with nodes + * + * @minItems 0 + */ + comments?: CommentDef[]; + [k: string]: unknown; +} +/** + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "comment_def". + */ +export interface CommentDef { + /** + * Comment identifier. Must be unique. + */ + id: string; + /** + * Horizontal comment position + */ + x_pos: number; + /** + * Vertical comment position + */ + y_pos: number; + /** + * Comment width + */ + width: number; + /** + * Comment height + */ + height: number; + /** + * CSS class(es) to apply to the comment + */ + class_name?: string; + /** + * A 'style spec' object containing CSS strings to be applied to the SVG objects of the comment. + */ + style?: + | string + | { + [k: string]: unknown; + }; + /** + * Optional attributes to be added to this element. For example: "attributes": "attr1='value1'; attr2='value2'" + */ + attributes?: string; + /** + * Comment content + */ + content?: string; + /** + * Optional array of associated node id references + * + * @minItems 0 + */ + associated_id_refs?: CommentLinkDef[]; + [k: string]: unknown; +} +/** + * Comment link definition + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "comment_link_def". + */ +export interface CommentLinkDef { + /** + * Node reference + */ + node_ref: string; + /** + * CSS class name for link styling + */ + class_name?: string; + /** + * A 'style spec' object containing CSS strings to be applied to the SVG objects of the comment link. + */ + style?: + | string + | { + [k: string]: unknown; + }; + [k: string]: unknown; +} +/** + * Additional UI info for ports + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "port_info_def". + */ +export interface PortInfoDef { + /** + * Property to capture how many data assets are allowed for this port, e.g., min: 1, max:1 implies you must supply 1 and only 1; min:0, max:1 implies it is optional and a max of one, min:0, max:-1 means it is optional and you can may have any number of data assets. The default value is 1:1 for inputs and 1:-1 for outputs. + */ + cardinality?: { + /** + * Minimum data sets that are required for this port + */ + min?: number; + /** + * Maximum data sets that are allowed on this port. A negative value indicates unlimited. The default value is 1 for inputs and -1 for outputs. + */ + max?: number; + }; + /** + * CSS class name + */ + class_name?: string; + /** + * A 'style spec' object containing CSS strings to be applied to the SVG objects of the port. + */ + style?: + | string + | { + [k: string]: unknown; + }; + /** + * Port name + */ + label?: string; + [k: string]: unknown; +} +/** + * object with app-specific UI-information + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "node_info_def". + */ +export interface NodeInfoDef { + /** + * User-defined label + */ + label?: string; + /** + * User-defined description + */ + description?: string; + /** + * CSS class name + */ + class_name?: string; + /** + * A 'style spec' object containing CSS strings to be applied to the SVG objects of the node. + */ + style?: + | string + | { + [k: string]: unknown; + }; + /** + * URL to image source. Although a data URL can be used to embed an image inline, it is not recommended. The 'image' property can also be a JSX object that displays an image using an element however, JSX images must be set programmatically and cannot be stringified into JSON. + */ + image?: + | string + | { + [k: string]: unknown; + }; + /** + * x-position + */ + x_pos?: number; + /** + * y-position + */ + y_pos?: number; + /** + * Indicates whether a supernode is shown in expanded state or as a regular node. + */ + is_expanded?: boolean; + /** + * Height of expanded supernode. If not provided an appropriate height is calculated. + */ + expanded_height?: number; + /** + * Width of expanded supernode. If not provided an appropriate width is calculated. + */ + expanded_width?: number; + /** + * Indicates whether a node has been resized or not. If true, resize_width and resize_height are used for node display. If false, the default width and height are used. + */ + is_resized?: boolean; + /** + * Height of resized node. The node will be displayed with this height, when is_resized is true, in preference to its default height. + */ + resize_height?: number; + /** + * Width of resized node. The node will be displayed with this width, when is_resized is true, in preference to its default width. + */ + resize_width?: number; + /** + * An array of pipelines referenced when this node is a supernode. This field is only used when the supernode is in a palette or on the clipboard. It will be an empty array when the supernode references an external pipeline. + * + * @minItems 0 + */ + sub_pipelines?: NonUiPipelineDef[]; + /** + * additional attributes + */ + attributes?: string; + /** + * Array of non-data node linkage + * + * @minItems 0 + */ + associations?: AssociationDef[]; + /** + * An array of messages for the node + * + * @minItems 0 + */ + messages?: MessageDef[]; + /** + * UI only parameter values for the node + */ + ui_parameters?: { + [k: string]: unknown; + }; + /** + * Image name for the node displayed in palette. If omitted the image from 'image' field will be used. + */ + palette_image?: string; + /** + * CSS class name applied to the
shown in palette for the node + */ + palette_class_name?: string; + /** + * Indicates whether the node in the palette is disabled. If true, prevents the node being dragged or double-clicked from palette. + */ + palette_disabled?: boolean; + /** + * Array of decorations used to decorate nodes + * + * @minItems 0 + */ + decorations?: DecorationDef[]; + [k: string]: unknown; +} +/** + * Non-data link + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "association_def". + */ +export interface AssociationDef { + /** + * Association identifier + */ + id: string; + /** + * Target node id + */ + node_ref: string; + /** + * CSS class name for link styling + */ + class_name?: string; + /** + * A 'style spec' object containing CSS strings to be applied to the SVG objects of the association link. + */ + style?: + | string + | { + [k: string]: unknown; + }; + /** + * Array of decorations used to decorate association links + * + * @minItems 0 + */ + decorations?: DecorationDef[]; +} +/** + * Decoration used to decorate a node + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "decoration_def". + */ +export interface DecorationDef { + /** + * An identifier used to identify the decoration + */ + id?: string; + /** + * Indicates whether the decorator is a hotspot or not. ie does it send an event to consuming app. when clicked + */ + hotspot?: boolean; + /** + * CSS class name for decoration styling + */ + class_name?: string; + /** + * Indicates an anchor point on the node or link from which the decoration will be displayed. If x_pos and y_pos are not provided the decoration is displayed with a default offset from this position. + */ + position?: + | 'topLeft' + | 'topCenter' + | 'topRight' + | 'middleLeft' + | 'middleCenter' + | 'middleRight' + | 'bottomLeft' + | 'bottomCenter' + | 'bottomRight' + | 'source' + | 'middle' + | 'target'; + /** + * X position of the decorator relative to the node's position field. If position is not provided it is relative to the 'topLeft' position + */ + x_pos?: number; + /** + * Y position of the decorator relative to the node's position field. If position is not provided it is relative to the 'topLeft' position + */ + y_pos?: number; + /** + * Image displayed at the decoration position. Provide either this or a label. + */ + image?: string; + /** + * Label displayed at the decoration position. Provide either this or an image. + */ + label?: string; + [k: string]: unknown; +} +/** + * Node message definition + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "message_def". + */ +export interface MessageDef { + /** + * Name of the parameter that has the message + */ + id_ref: string; + /** + * Validation identifier from the fail_message validation section. + */ + validation_id?: string; + /** + * Type of message + */ + type: 'info' | 'error' | 'warning'; + /** + * Message string + */ + text: string; + [k: string]: unknown; +} +/** + * object with app-specific UI-information + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "node_link_info_def". + */ +export interface NodeLinkInfoDef { + /** + * User-defined description + */ + description?: string; + /** + * CSS class name + */ + class_name?: string; + /** + * A 'style spec' object containing CSS strings to be applied to the SVG objects of the node to node link. + */ + style?: + | string + | { + [k: string]: unknown; + }; + /** + * Array of decorations used to decorate node links + * + * @minItems 0 + */ + decorations?: DecorationDef[]; + [k: string]: unknown; +} +/** + * Runtime information + * + * This interface was referenced by `HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowUiV3SchemaJson`'s JSON-Schema + * via the `definition` "runtime_info_def". + */ +export interface RuntimeInfoDef { + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/pipeline-flow-v3.ts b/canvas_modules/common-canvas/types/pipeline-flow-v3.ts new file mode 100644 index 0000000000..d9978e5e65 --- /dev/null +++ b/canvas_modules/common-canvas/types/pipeline-flow-v3.ts @@ -0,0 +1,512 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json + * after removing broken $ref URL's. + * It has been modified by hand, so run a diff if you need to update it. + */ + +import { RecordSchema } from './datarecord-metadata-v3'; +import { ParamsetRef } from './parametersets-v3'; +import { + CommonPipelineConnectionDef, + CommonPipelineDataAssetDef, +} from './pipeline-connection-v3'; +import { + NodeInfoDef, + NodeLinkInfoDef, + PipelineOverviewDef, + PortInfoDef, + RuntimeInfoDef, +} from './pipeline-flow-ui-v3'; +import { PipelineDef as UiPipelineDef } from './pipeline-flow-ui-v3'; + +export type NodeTypeDef = + | ExecutionNodeDef + | SupernodeDef + | BindingEntryNodeDef + | BindingExitNodeDef + | ModelNodeDef; +/** + * @minItems 0 + */ +export type PortsDef = PortDef[]; +/** + * @minItems 0 + */ +export type BoundPortsDef = BoundPortDef[]; +/** + * An optional set of output ports, typically used for directing error information out of the binding node. + * + * @minItems 0 + */ +export type PortsDef1 = PortDef[]; + +/** + * WDP Pipeline Flow Schema + */ +export interface HttpsApiDataplatformIbmComSchemasCommonPipelinePipelineFlowPipelineFlowV3SchemaJson { + /** + * Document type + */ + doc_type: string; + /** + * Pipeline-flow schema version + */ + version: '3.0'; + /** + * Refers to the JSON schema used to validate documents of this type + */ + json_schema?: + | 'http://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json' + | 'https://api.dataplatform.ibm.com/schemas/common-pipeline/pipeline-flow/pipeline-flow-v3-schema.json'; + /** + * Preferred authoring application + */ + open_with_tool?: string; + /** + * Document identifier, GUID recommended + */ + id?: string; + /** + * Parameters for the flow document + */ + parameters?: { + [k: string]: unknown; + }; + /** + * Reference to the primary (main) pipeline flow within the document + */ + primary_pipeline: string; + /** + * Array of pipelines + * + * @minItems 1 + */ + pipelines: [PipelineDef, ...PipelineDef[]]; + /** + * Array of data record schemas used in the document + * + * @minItems 0 + */ + schemas?: RecordSchema[]; + /** + * Array of runtime objects referred to in the document + * + * @minItems 0 + */ + runtimes?: RuntimeDef[]; + /** + * Array of parameter set references + * + * @minItems 0 + */ + external_paramsets?: ParamsetRef[]; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: PipelineOverviewDef; + [k: string]: unknown; + }; +} +/** + * Definition of a single pipeline flow + */ +export interface PipelineDef { + /** + * Unique identifier + */ + id: string; + /** + * @deprecated + * Deprecated - use description in pipeline-flow-ui-v3-schema.json#/definitions/pipeline_def instead. + */ + description?: string; + /** + * User-readable name + */ + name?: string; + /** + * Reference to the id of the runtime associated with the operations in the current pipeline + */ + runtime_ref: string; + /** + * Array of pipeline nodes + * + * @minItems 0 + */ + nodes: NodeTypeDef[]; + /** + * Parameters for the pipeline + */ + parameters?: { + [k: string]: unknown; + }; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: UiPipelineDef; + [k: string]: unknown; + }; +} +/** + * Definition of a single execution pipeline node + */ +export interface ExecutionNodeDef { + /** + * Unique identifier for node within the current pipeline + */ + id: string; + /** + * @deprecated + * Deprecated - use description in pipeline-flow-ui-v3-schema.json#/definitions/node_info_def instead. + */ + description?: string; + /** + * Node type - always 'execution_node' for non-model pipeline elements + */ + type: 'execution_node'; + /** + * Operator type identifier + */ + op: string; + inputs?: PortsDef; + outputs?: PortsDef; + /** + * Input parameters for the operator + */ + parameters?: { + [k: string]: unknown; + }; + /** + * Optional reference to the id of the runtime associated with the current node + */ + runtime_ref?: string; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: NodeInfoDef; + [k: string]: unknown; + }; +} +/** + * Port definition (input/output) on a node + */ +export interface PortDef { + /** + * Unique identifier + */ + id: string; + /** + * Optional data record schema reference associated with the port + */ + schema_ref?: string; + /** + * Array of links going into the node. Applies to input ports and exit bindings only. + * + * @minItems 0 + */ + links?: LinkDef[]; + /** + * Parameters for the port + */ + parameters?: { + [k: string]: unknown; + }; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: PortInfoDef; + [k: string]: unknown; + }; +} +/** + * Node link definition + */ +export interface LinkDef { + /** + * Unique id of this link within the pipelineFlow. If omitted a new link id will be generated. + */ + id?: string; + /** + * id of a node this link connects to + */ + node_id_ref: string; + /** + * optional port id of a node this link connects to + */ + port_id_ref?: string; + /** + * optional link name (used in parameter sets when there are multiple input sources) + */ + link_name?: string; + /** + * Link type attribute + */ + type_attr?: string; + /** + * Deprecated - use description in pipeline-flow-ui-v3-schema.json#/definitions/node_link_info_def instead. + */ + description?: string; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: NodeLinkInfoDef; + [k: string]: unknown; + }; +} +/** + * Definition of a supernode which serves as the entry point for a sub-pipeline + */ +export interface SupernodeDef { + /** + * Unique identifier for the supernode within the current pipeline + */ + id: string; + /** + * @deprecated + * Deprecated - use description in pipeline-flow-ui-v3-schema.json#/definitions/node_info_def instead. + */ + description?: string; + /** + * Node type - always 'super_node' for supernode elements + */ + type: 'super_node'; + /** + * Name of the tool which can be used to view or edit the sub-flow for this supernode. The default is 'canvas' + */ + open_with_tool?: string; + /** + * Refers to the sub-flow associated with this supernode + */ + subflow_ref: { + /** + * Reference to an external sub-flow. When not present the sub-flow is assumed to be in the current document. A value of 'app_defined' indicates a sub-flow identifier is present, but the controlling application will serve up the sub-pipeline in the form of a new pipeline-flow document (no sub-flow is present in the document). + */ + url?: string; + /** + * Sub-flow identifier reference + */ + pipeline_id_ref: string; + [k: string]: unknown; + }; + inputs?: BoundPortsDef; + outputs?: BoundPortsDef; + /** + * Input parameters for the supernode + */ + parameters?: { + [k: string]: unknown; + }; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: NodeInfoDef; + [k: string]: unknown; + }; +} +/** + * Port definition (input/output) on a node with optional pipeline port binding for supernodes + */ +export interface BoundPortDef { + /** + * Unique identifier + */ + id: string; + /** + * Optional data record schema associated with the port + */ + schema_ref?: string; + /** + * Array of links going into the node. Applies to input ports and exit bindings only. + * + * @minItems 1 + */ + links?: [LinkDef, ...LinkDef[]]; + /** + * Optional node id binding within the current document. + */ + subflow_node_ref?: string; + /** + * Parameters for the binding port + */ + parameters?: { + [k: string]: unknown; + }; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: PortInfoDef; + [k: string]: unknown; + }; +} +/** + * Defines an entry point (source) for a pipeline. Bindings can be concrete: the concrete_binding element is present on the port; or bindings can be abstract: bindings are performed externally via configuration or a wrapper document. + */ +export interface BindingEntryNodeDef { + /** + * Unique identifier for the binding within the current pipeline + */ + id: string; + /** + * @deprecated + * Deprecated - use description in pipeline-flow-ui-v3-schema.json#/definitions/node_info_def instead. + */ + description?: string; + /** + * Node type - always 'binding' for binding elements + */ + type: 'binding'; + outputs: PortsDef; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: NodeInfoDef; + [k: string]: unknown; + }; + connection?: CommonPipelineConnectionDef; + data_asset?: CommonPipelineDataAssetDef; + /** + * Binding node type identifier + */ + op?: string; + /** + * Parameters for the binding entry node + */ + parameters?: { + [k: string]: unknown; + }; +} +/** + * Defines an exit point (sink) for a pipeline. Bindings can be concrete: the concrete_binding element is present on the port; or bindings can be abstract: bindings are performed externally via configuration or a wrapper document. + */ +export interface BindingExitNodeDef { + /** + * Unique identifier for the binding within the current pipeline + */ + id: string; + /** + * @deprecated + * Deprecated - use description in pipeline-flow-ui-v3-schema.json#/definitions/node_info_def instead. + */ + description?: string; + /** + * Node type - always 'binding' for binding elements + */ + type: 'binding'; + inputs: PortsDef; + outputs?: PortsDef1; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: NodeInfoDef; + [k: string]: unknown; + }; + connection?: CommonPipelineConnectionDef; + data_asset?: CommonPipelineDataAssetDef; + /** + * Binding node type identifier + */ + op?: string; + /** + * Parameters for the binding exit node + */ + parameters?: { + [k: string]: unknown; + }; +} +/** + * Definition of a single predictive model node + */ +export interface ModelNodeDef { + /** + * Unique identifier for the model within the current pipeline + */ + id: string; + /** + * @deprecated + * Deprecated - use description in pipeline-flow-ui-v3-schema.json#/definitions/node_info_def instead. + */ + description?: string; + /** + * Node type - always 'model_node' for model pipeline elements + */ + type: 'model_node'; + /** + * Reference to the binary model + */ + model_ref?: string; + inputs: PortsDef; + outputs?: PortsDef; + /** + * Node type identifier of modeling node that created this model. + */ + op?: string; + /** + * Input parameters for the operator + */ + parameters?: { + [k: string]: unknown; + }; + /** + * Reference to the runtime associated with the current node + */ + runtime_ref?: string; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: NodeInfoDef; + [k: string]: unknown; + }; +} +/** + * Runtime associated with the operations in the current pipeline + */ +export interface RuntimeDef { + /** + * Unique internal runtime identifier + */ + id: string; + /** + * The runtime name + */ + name: string; + /** + * The runtime version. When not present the latest version is assumed + */ + version?: string; + /** + * Object containing app-specific data + */ + app_data?: { + ui_data?: RuntimeInfoDef; + [k: string]: unknown; + }; + [k: string]: unknown; +} diff --git a/canvas_modules/common-canvas/types/uihints-v3.model.ts b/canvas_modules/common-canvas/types/uihints-v3.model.ts new file mode 100644 index 0000000000..dae954cdf4 --- /dev/null +++ b/canvas_modules/common-canvas/types/uihints-v3.model.ts @@ -0,0 +1,709 @@ +/* + * Copyright 2017-2024 Elyra Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript + * from https://github.com/elyra-ai/pipeline-schemas/blob/main/common-pipeline/operators/uihints-v3-schema.json + * It has been modified by hand, so run a diff if you need to update it. + */ + +import { ParameterDefinition as OperatorParameterDefinition } from './operator-v3.model'; + +/** + * External name of operator + */ +export type ResourceDefinition = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Description of operator + */ +export type ResourceDefinition1 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Group label + */ +export type ResourceDefinition2 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Group description. Used in a textPanel and tearsheetPanel + */ +export type ResourceDefinition3 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * External name for parameter + */ +export type ResourceDefinition4 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition5 = ResourceDefinition6 & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +export type ResourceDefinition6 = { + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition7 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition8 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Static text to be displayed before the control + */ +export type TextDefinition = ResourceDefinition5 & { + /** + * Type of text message to display + */ + type?: 'info'; + [k: string]: unknown; +}; +/** + * Static text to be displayed after the control + */ +export type TextDefinition1 = ResourceDefinition5 & { + /** + * Type of text message to display + */ + type?: 'info'; + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition9 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition10 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Button to be displayed after the table's search bar + */ +export type ButtonDefinition = ButtonDefinition1 & { + /** + * Button identifier used to idenify the button in the callback function + */ + id?: string; + label?: ResourceDefinition11; + description?: ResourceDefinition12; + /** + * URL to .svg image to display + */ + icon?: string; + /** + * Host provided name of Carbon icon to display. A callback function is required for the host application to return the jsx icon object imported from @carbon/icons-react library + */ + carbon_icon?: string; + /** + * Button will be enabled if true, disabled if false + */ + enabled?: boolean; + /** + * Display a divider before or after this button + */ + divider?: 'before' | 'after'; + [k: string]: unknown; +}; +export type ButtonDefinition1 = { + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition11 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition12 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition13 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; +/** + * Localizable string resource + */ +export type ResourceDefinition14 = { + [k: string]: unknown; +} & { + default?: string; + resource_key?: string; + [k: string]: unknown; +}; + +/** + * WDP UI Hints schema + */ +export interface WDPUIHintsSchema { + /** + * Operator identifier + */ + id: string; + /** + * Refers to the JSON schema used to validate documents of this type + */ + json_schema?: 'https://api.dataplatform.ibm.com/schemas/common-pipeline/operators/uihints-v3-schema.json'; + label?: ResourceDefinition; + description?: ResourceDefinition1; + /** + * URL to operation icon + */ + icon?: string; + title_info?: { + /** + * List of actions to be displayed in the title section + */ + action_refs?: string[]; + [k: string]: unknown; + }; + group_info?: GroupDefinition[]; + /** + * Editor size for node edits + */ + editor_size?: 'small' | 'medium' | 'large'; + /** + * Gives more control of editor panel width. The panel is shown at min size if editor_size is small and max size if editor_size is medium. If min and max are the same no sizing button is displayed. + */ + pixel_width?: { + /** + * Minimum size in pixels for the right side editor flyout + */ + min?: number; + /** + * Maximum size in pixels for the right side editor flyout + */ + max?: number; + [k: string]: unknown; + }; + parameter_info?: ParameterDefinition[]; + complex_type_info?: ComplexTypeDefinition[]; + /** + * List of UI only parameters + */ + ui_parameters?: OperatorParameterDefinition[]; + action_info?: ActionDefinition[]; + /** + * Help information + */ + help?: { + /** + * Data passed in the helpClickHandler. + */ + data?: { + [k: string]: unknown; + }; + [k: string]: unknown; + }; + [k: string]: unknown; +} +/** + * Grouping for parameters and groups + */ +export interface GroupDefinition { + /** + * Identifier for this group + */ + id: string; + /** + * The group type to be displayed + */ + type?: + | 'controls' + | 'tabs' + | 'subTabs' + | 'panels' + | 'columnSelection' + | 'columnSelectionRecursive' + | 'panelSelector' + | 'customPanel' + | 'summaryPanel' + | 'actionPanel' + | 'textPanel' + | 'twistyPanel' + | 'tearsheetPanel' + | 'columnPanel'; + /** + * Parameter name this group depends upon. Valid for panelSelector groups only. + */ + depends_on_ref?: string; + /** + * Indicates whether panels, contained with a panelSelector, should be inserted between the radio buttons of a radio button set indicated by the depends_on_ref parameter. + */ + insert_panels?: boolean; + /** + * Indicate whether panel should be nested. Nested panels are indented by 16px from the left and display left border. Default is false. + */ + nested_panel?: boolean; + /** + * Used to determine if a panel is open or closed when UI is displayed. Currenty only supported with twistyPanel. Default is false. + */ + open?: boolean; + label?: ResourceDefinition2; + description?: ResourceDefinition3; + /** + * List of parameters to be displayed + */ + parameter_refs?: string[]; + /** + * List of actions to be displayed. Used with an actionPanel + */ + action_refs?: string[]; + /** + * Data passed to custom panel when group type is 'customPanel' + */ + data?: + | { + [k: string]: unknown; + } + | unknown[]; + group_info?: GroupDefinition[]; + /** + * Optional class name to set for this group + */ + class_name?: string; + [k: string]: unknown; +} +/** + * Operator parameters hints + */ +export interface ParameterDefinition { + /** + * Parameter reference to base operator parameter definition + */ + parameter_ref: string; + label?: ResourceDefinition4; + /** + * Whether to display the label or not. If not displayed, the label can still be used by screen readers + */ + label_visible?: boolean; + /** + * Description of parameter with optional placement context and optional link + */ + description?: ResourceDefinition5 & { + /** + * Optional placement context for the text + */ + placement?: 'as_tooltip' | 'on_panel'; + /** + * Optional link in the description. tooltipLinkHandler callback must be defined whenever link object is added in uiHints. + */ + link?: { + /** + * link id + */ + id: string; + /** + * Data passed to the tooltipLinkHandler callback + */ + data?: { + [k: string]: unknown; + }; + [k: string]: unknown; + }; + [k: string]: unknown; + }; + /** + * Which control to use. In most cases the control gets to be determined and should not be set + */ + control?: + | 'readonly' + | 'readonlyTable' + | 'textfield' + | 'passwordfield' + | 'textarea' + | 'expression' + | 'numberfield' + | 'spinner' + | 'checkbox' + | 'radioset' + | 'checkboxset' + | 'toggletext' + | 'toggle' + | 'oneofselect' + | 'multiselect' + | 'someofselect' + | 'selectcolumn' + | 'selectcolumns' + | 'selectschema' + | 'structuretable' + | 'structurelisteditor' + | 'structureeditor' + | 'custom' + | 'datefield' + | 'datepicker' + | 'datepickerRange' + | 'timefield' + | 'timestampfield' + | 'slider' + | 'code' + | 'list' + | 'hidden'; + /** + * Determines the step value to increment/decrement for spinner and slider controls + */ + increment?: number; + /** + * Determines the minimum value for the slider control only + */ + min_value?: number; + /** + * Determines the max value for the slider control only + */ + max_value?: number; + /** + * Determines how the control is displayed + */ + orientation?: 'vertical' | 'horizontal'; + /** + * Percentage of group width the control should use + */ + width?: number; + /** + * Limits the number of characters a user can enter into the control for string parameters only + */ + char_limit?: number; + /** + * This has been deprecated and is subject to removal. Limits the number of characters displayed for a text field in a column in a table. The text will have an ellipsis appended at this limit. + */ + display_chars?: number; + /** + * Determines where to put a separator relative to the current control + */ + separator?: 'before' | 'after'; + /** + * Determines whether to display parameter in control. Used in complex structures + */ + visible?: boolean; + place_holder_text?: ResourceDefinition7; + helper_text?: ResourceDefinition8; + /** + * Determines whether the control should be readonly or can be edited + */ + read_only?: boolean; + text_before?: TextDefinition; + text_after?: TextDefinition1; + /** + * Used as a key for enum value labels + */ + resource_key?: string; + /** + * Editing style of elements in a table + */ + edit_style?: 'subpanel' | 'inline' | 'on_panel'; + /** + * For enumerated types, this defines the set of icons for the valid values. The ordering must be consistent with the order in the parameter enum attribute. + */ + value_icons?: string[]; + /** + * Determines if this column values can be sorted into ascending/descending order in a table. Applies to structure parameters only. + */ + sortable?: boolean; + /** + * Determines if this column values can be filtered so that only rows that match the filter in column values are shown in the table. Applies to structure parameters and multiselect control only. + */ + filterable?: boolean; + /** + * Determines if this column can be resized in a table. When a column is resized, width of all the columns to the right of resized column is adjusted. Applies to structure parameters only. + */ + resizable?: boolean; + /** + * The language for the expression editor syntax highlight and autocomplete workds. Applies to expression control type. + */ + language?: + | 'CLEM' + | 'javascript' + | 'text/x-hive' + | 'text/x-rsrc' + | 'text/x-python' + | 'text/x-sql'; + /** + * Determines if this column values will be shown in the summaryPanel + */ + summary?: boolean; + /** + * Generates values for a column in a 'readonly' parameter. + */ + generated_values?: { + /** + * Currently only 'index' is supported which will auto-increment the integer column value starting at 1. The start value can be configured by setting a start_value. + */ + operation: 'index'; + /** + * Optional start value to increment from when the 'type' is 'index'. If the start_value is not set, it will default to 1. + */ + start_value?: number; + [k: string]: unknown; + }; + /** + * Adds a number generation button beside the numeric control + */ + number_generator?: { + label: ResourceDefinition9; + /** + * Number generator range + */ + range?: { + /** + * Maximum value for generated numbers + */ + min: number; + [k: string]: unknown; + }; + [k: string]: unknown; + }; + /** + * Used within complex structures containing 'column' key_definition fields. This associates the subControl parameter with a field attribute in the current record schema. + */ + dm_default?: 'type' | 'description' | 'measure' | 'modeling_role'; + /** + * This can be set to display an icon of the corresponding dm type in the `role`:`column' field of a table. + */ + dm_icon?: 'measure' | 'none'; + /** + * Used to determine which custom control to use when control=custom. + */ + custom_control_id?: string; + /** + * Data passed to custom control when control=custom + */ + data?: { + [k: string]: unknown; + }; + /** + * A format string such as YYYY-MM-DD which describes the display and entry format for a date field. + */ + date_format?: string; + /** + * A format string such as HH:mm:ss which describes the display and entry format for a time field. + */ + time_format?: string; + /** + * Determines if rows can be moved up or down in a table or array of strings + */ + moveable_rows?: boolean; + /** + * Number of rows to display in tables + */ + rows?: number; + /** + * Determines an action should be added to the control + */ + action_ref?: string; + /** + * Determines if a dropdown, outside of a table, can allow a custom value to be entered + */ + custom_value_allowed?: boolean; + /** + * Optional class name to set for this control + */ + class_name?: string; + /** + * Determines if maximize/minimze buttons are shown for code control + */ + enable_maximize?: boolean; + [k: string]: unknown; +} +/** + * Complex parameters + */ +export interface ComplexTypeDefinition { + /** + * Name of complex type, can be referenced in other places. + */ + complex_type_ref: string; + label?: ResourceDefinition10; + key_definition?: ParameterDefinition; + /** + * Array of rows containing structure element names + */ + layout?: string[][]; + /** + * List of parameters + */ + parameters: (ParameterDefinition | ComplexTypeDefinition)[]; + /** + * Determines if the table can have rows added and removed + */ + add_remove_rows?: boolean; + /** + * Determines how many rows can be selected at a time. 'multiple-edit': select multiple rows and allow the editing of column values for all selected rows. + */ + row_selection?: 'single' | 'multiple' | 'multiple-edit'; + /** + * Determines if the table header should be displayed + */ + header?: boolean; + /** + * Use when `add_remove_rows` is false. Ensures the control contains a record for each field in the data model. + */ + include_all_fields?: boolean; + /** + * Display custom buttons in place of any buttons from the table. Will override 'add_remove_rows' and readonlyTable edit buttons. + */ + buttons?: ButtonDefinition[]; + [k: string]: unknown; +} +/** + * Actions that callback to application + */ +export interface ActionDefinition { + /** + * Identifier for this action + */ + id: string; + description?: ResourceDefinition13; + /** + * The action type to be displayed + */ + control?: 'button' | 'image'; + /** + * Optional class name to set for this action + */ + class_name?: string; + label?: ResourceDefinition14; + /** + * Properties for button kind and size. Use when control=button. + */ + button?: { + /** + * button kind + */ + kind?: + | 'primary' + | 'secondary' + | 'tertiary' + | 'ghost' + | 'danger' + | 'danger--tertiary' + | 'danger--ghost'; + /** + * button size + */ + size?: 'sm' | 'md' | 'lg' | 'xl'; + [k: string]: unknown; + }; + /** + * Properties for how the image will look. Use when control=image. + */ + image?: { + /** + * image url to be used for action + */ + url?: string; + /** + * placement of the action image + */ + placement?: 'right' | 'left'; + /** + * pixel size of the image. + */ + size?: { + /** + * image height in pixels + */ + height?: number; + /** + * image width in pixels + */ + width?: number; + [k: string]: unknown; + }; + /** + * Action image tooltip direction. + */ + tooltip_direction?: 'right' | 'left' | 'top' | 'bottom'; + [k: string]: unknown; + }; + /** + * Data returned when action called + */ + data?: { + [k: string]: unknown; + }; + [k: string]: unknown; +}