creo-flow-extensions-base 1.1.0-dev.2 → 1.1.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,13 +123,7 @@ const getFullNode = async (event, extension) => {
123
123
  nodeName: event.nodeTitle
124
124
  });
125
125
  }
126
- const fullFields = await Promise.all(method.fields.map(async (field) => {
127
- const isSelect = field.type === enum_2.FieldTypes.SELECT;
128
- if (!isSelect)
129
- return field;
130
- const options = field?.getOptions ? await field.getOptions(methodProps) : [];
131
- return { ...field, options };
132
- }));
126
+ const fullFields = await resolveFields(method.fields, methodProps);
133
127
  return {
134
128
  statusCode: 200,
135
129
  body: JSON.stringify({ ...method, fields: fullFields }),
@@ -151,3 +145,20 @@ const getFullNode = async (event, extension) => {
151
145
  };
152
146
  }
153
147
  };
148
+ async function resolveFields(fields, methodProps) {
149
+ return await Promise.all(fields.map(async (field) => {
150
+ const isSelect = field.type === enum_2.FieldTypes.SELECT;
151
+ const hasNestedFields = Array.isArray(field.fields);
152
+ const options = isSelect && field.getOptions
153
+ ? await field.getOptions(methodProps)
154
+ : undefined;
155
+ const resolvedNestedFields = hasNestedFields
156
+ ? await resolveFields(field.fields, methodProps)
157
+ : undefined;
158
+ return {
159
+ ...field,
160
+ ...(options !== undefined ? { options } : {}),
161
+ ...(resolvedNestedFields ? { fields: resolvedNestedFields } : {}),
162
+ };
163
+ }));
164
+ }
@@ -4,6 +4,7 @@ export interface ICheckboxField {
4
4
  label: string;
5
5
  isRequired: boolean;
6
6
  isChecked?: boolean;
7
+ description?: string;
7
8
  type: FieldTypes.CHECKBOX;
8
9
  dependsOn?: string[];
9
10
  }
@@ -5,6 +5,7 @@ export interface ICodeField {
5
5
  language: 'javascript' | 'python';
6
6
  isRequired: boolean;
7
7
  type: FieldTypes.CODE;
8
+ description?: string;
8
9
  dependsOn?: string[];
9
10
  }
10
11
  interface IProps {
@@ -0,0 +1,19 @@
1
+ import { FieldTypes } from "../enum";
2
+ import { Field } from "../../nodes";
3
+ export interface ICollapsibleFieldsList {
4
+ name: string;
5
+ label: string;
6
+ placeholder?: string;
7
+ description?: string;
8
+ type: FieldTypes.COLLAPSIBLE_FIELDS_LIST;
9
+ fields: Field[];
10
+ }
11
+ interface IProps {
12
+ label?: string;
13
+ name: string;
14
+ placeholder?: '';
15
+ description?: '';
16
+ fields: Field[];
17
+ }
18
+ export declare const createCollapsibleFieldsList: (codeField: IProps) => ICollapsibleFieldsList;
19
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCollapsibleFieldsList = void 0;
4
+ const enum_1 = require("../enum");
5
+ const createCollapsibleFieldsList = (codeField) => {
6
+ const { name, label = '', fields = [], description = '', placeholder = '', } = codeField;
7
+ return {
8
+ name,
9
+ label,
10
+ type: enum_1.FieldTypes.COLLAPSIBLE_FIELDS_LIST,
11
+ fields,
12
+ description,
13
+ placeholder,
14
+ };
15
+ };
16
+ exports.createCollapsibleFieldsList = createCollapsibleFieldsList;
@@ -0,0 +1,19 @@
1
+ import { FieldTypes } from "../enum";
2
+ import { Field } from "../../nodes";
3
+ export interface IDynamicFieldsList {
4
+ name: string;
5
+ label: string;
6
+ placeholder?: string;
7
+ description?: string;
8
+ type: FieldTypes.DYNAMIC_FIELDS_LIST;
9
+ fields: Field[];
10
+ }
11
+ interface IProps {
12
+ label?: string;
13
+ name: string;
14
+ placeholder?: '';
15
+ description?: '';
16
+ fields: Field[];
17
+ }
18
+ export declare const createDynamicFieldsList: (codeField: IProps) => IDynamicFieldsList;
19
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDynamicFieldsList = void 0;
4
+ const enum_1 = require("../enum");
5
+ const createDynamicFieldsList = (codeField) => {
6
+ const { name, label = '', fields = [], description = '', placeholder = '', } = codeField;
7
+ return {
8
+ name,
9
+ label,
10
+ type: enum_1.FieldTypes.DYNAMIC_FIELDS_LIST,
11
+ fields,
12
+ description,
13
+ placeholder,
14
+ };
15
+ };
16
+ exports.createDynamicFieldsList = createDynamicFieldsList;
@@ -2,5 +2,8 @@ export declare enum FieldTypes {
2
2
  CHECKBOX = "checkbox",
3
3
  CODE = "code",
4
4
  INPUT = "input",
5
- SELECT = "select"
5
+ SELECT = "select",
6
+ DYNAMIC_FIELDS_LIST = "dynamicFieldsList",
7
+ FIELDS_GROUP = "fieldsListGroup",
8
+ COLLAPSIBLE_FIELDS_LIST = "collapsibleFieldsList"
6
9
  }
@@ -7,5 +7,8 @@ var FieldTypes;
7
7
  FieldTypes["CODE"] = "code";
8
8
  FieldTypes["INPUT"] = "input";
9
9
  FieldTypes["SELECT"] = "select";
10
+ FieldTypes["DYNAMIC_FIELDS_LIST"] = "dynamicFieldsList";
11
+ FieldTypes["FIELDS_GROUP"] = "fieldsListGroup";
12
+ FieldTypes["COLLAPSIBLE_FIELDS_LIST"] = "collapsibleFieldsList";
10
13
  })(FieldTypes || (exports.FieldTypes = FieldTypes = {}));
11
14
  ;
@@ -0,0 +1,22 @@
1
+ import { FieldTypes } from "../enum";
2
+ import { Field } from "../../nodes";
3
+ type ISizedField = Field & {
4
+ size: number | string;
5
+ };
6
+ export interface IFieldsGroup {
7
+ name: string;
8
+ label: string;
9
+ placeholder?: string;
10
+ description?: string;
11
+ type: FieldTypes.FIELDS_GROUP;
12
+ fields: ISizedField[];
13
+ }
14
+ interface IProps {
15
+ label?: string;
16
+ name: string;
17
+ placeholder?: '';
18
+ description?: '';
19
+ fields: ISizedField[];
20
+ }
21
+ export declare const createFieldsGroup: (codeField: IProps) => IFieldsGroup;
22
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFieldsGroup = void 0;
4
+ const enum_1 = require("../enum");
5
+ const createFieldsGroup = (codeField) => {
6
+ const { name, label = '', fields = [], description = '', placeholder = '', } = codeField;
7
+ return {
8
+ name,
9
+ label,
10
+ type: enum_1.FieldTypes.FIELDS_GROUP,
11
+ fields,
12
+ description,
13
+ placeholder,
14
+ };
15
+ };
16
+ exports.createFieldsGroup = createFieldsGroup;
@@ -4,6 +4,7 @@ export interface IInputField {
4
4
  name: string;
5
5
  label: string;
6
6
  placeholder?: string;
7
+ description?: string;
7
8
  inputType?: 'text' | 'number' | 'password';
8
9
  isRequired: boolean;
9
10
  behavior?: IBehavior[];
@@ -8,6 +8,7 @@ export interface ISelectField {
8
8
  name: string;
9
9
  label?: string;
10
10
  placeholder?: string;
11
+ description?: string;
11
12
  options?: {
12
13
  label: string;
13
14
  value: string;
@@ -3,7 +3,10 @@ import { IInputField } from '../fields/input';
3
3
  import { ISelectField } from '../fields/select';
4
4
  import { ICodeField } from '../fields/code';
5
5
  import { NodeContext } from "../executionContext";
6
- type Field = IInputField | ISelectField | ICheckboxField | ICodeField;
6
+ import { ICollapsibleFieldsList } from "../fields/collapsibleFieldsList";
7
+ import { IDynamicFieldsList } from "../fields/dynamicFieldsList";
8
+ import { IFieldsGroup } from "../fields/fieldsGroup";
9
+ export type Field = IInputField | ISelectField | ICheckboxField | ICodeField | ICollapsibleFieldsList | IDynamicFieldsList | IFieldsGroup;
7
10
  export interface IFuncProps {
8
11
  args: any;
9
12
  context: object;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creo-flow-extensions-base",
3
- "version": "1.1.0-dev.2",
3
+ "version": "1.1.0-dev.4",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:CloudDataHub/cdh-flow-extension-base.git",
6
6
  "author": "Ilia Kobaliia",