@datagrok/compute 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/compute",
|
|
3
3
|
"friendlyName": "Compute",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"cash-dom": "latest",
|
|
8
8
|
"codemirror": "^5.64.0",
|
|
9
|
-
"datagrok-api": ">=0.
|
|
9
|
+
"datagrok-api": ">=0.98.0",
|
|
10
10
|
"dayjs": "latest",
|
|
11
11
|
"exceljs": "^4.3.0",
|
|
12
12
|
"file-saver": "^2.0.5",
|
|
@@ -100,7 +100,8 @@ enum COMMON_TAG_NAME {
|
|
|
100
100
|
VALIDATORS = 'validators',
|
|
101
101
|
CAPTION = 'caption',
|
|
102
102
|
POSTFIX = 'postfix',
|
|
103
|
-
UNITS = 'units'
|
|
103
|
+
UNITS = 'units',
|
|
104
|
+
EDITOR = 'editor',
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
enum OPTIONAL_TAG_NAME {
|
|
@@ -112,21 +113,31 @@ enum OPTIONAL_TAG_NAME {
|
|
|
112
113
|
ACTION = 'action',
|
|
113
114
|
CHOICES = 'choices',
|
|
114
115
|
SUGGESTIONS = 'suggestions',
|
|
115
|
-
SEM_TYPE = 'semType'
|
|
116
|
+
SEM_TYPE = 'semType',
|
|
117
|
+
MIN = 'min',
|
|
118
|
+
MAX = 'max',
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
type DF_TAG_NAME = COMMON_TAG_NAME | OPTIONAL_TAG_NAME.COLUMNS | OPTIONAL_TAG_NAME.CATEGORICAL;
|
|
119
122
|
type COLUMN_TAG_NAME = COMMON_TAG_NAME |
|
|
120
|
-
OPTIONAL_TAG_NAME.
|
|
123
|
+
OPTIONAL_TAG_NAME.COLUMNS | OPTIONAL_TAG_NAME.FORMAT |
|
|
121
124
|
OPTIONAL_TAG_NAME.ALLOW_NULLS | OPTIONAL_TAG_NAME.ACTION | OPTIONAL_TAG_NAME.SEM_TYPE
|
|
122
125
|
|
|
123
126
|
type STRING_TAG_NAME = COMMON_TAG_NAME |
|
|
124
127
|
OPTIONAL_TAG_NAME.CHOICES | OPTIONAL_TAG_NAME.SUGGESTIONS
|
|
125
128
|
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
type INT_TAG_NAME = COMMON_TAG_NAME | OPTIONAL_TAG_NAME.MIN | OPTIONAL_TAG_NAME.MAX
|
|
130
|
+
|
|
131
|
+
const COMMON_TAG_NAMES = [...Object.values(COMMON_TAG_NAME)];
|
|
132
|
+
const DF_TAG_NAMES = [
|
|
133
|
+
...Object.values(COMMON_TAG_NAME),
|
|
134
|
+
OPTIONAL_TAG_NAME.COLUMNS,
|
|
135
|
+
OPTIONAL_TAG_NAME.CATEGORICAL,
|
|
136
|
+
OPTIONAL_TAG_NAME.ACTION];
|
|
137
|
+
const COLUMN_TAG_NAMES = [...Object.values(COMMON_TAG_NAME), OPTIONAL_TAG_NAME.COLUMNS, OPTIONAL_TAG_NAME.FORMAT,
|
|
128
138
|
OPTIONAL_TAG_NAME.ALLOW_NULLS, OPTIONAL_TAG_NAME.ACTION, OPTIONAL_TAG_NAME.SEM_TYPE];
|
|
129
139
|
const STRING_TAG_NAMES = [...Object.values(COMMON_TAG_NAME), OPTIONAL_TAG_NAME.CHOICES, OPTIONAL_TAG_NAME.SUGGESTIONS];
|
|
140
|
+
const INT_TAG_NAMES = [...Object.values(COMMON_TAG_NAME), OPTIONAL_TAG_NAME.MIN, OPTIONAL_TAG_NAME.MAX];
|
|
130
141
|
|
|
131
142
|
type FuncParamBase = {
|
|
132
143
|
direction: DIRECTION,
|
|
@@ -136,9 +147,12 @@ type FuncParamBase = {
|
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
type FuncParam =
|
|
139
|
-
|
|
150
|
+
FuncParamBase & {
|
|
140
151
|
type: DG.TYPE.BOOL | DG.TYPE.DATE_TIME | DG.TYPE.FLOAT | DG.TYPE.GRAPHICS | DG.TYPE.INT
|
|
141
152
|
options?: {tag: COMMON_TAG_NAME, value: string}[]
|
|
153
|
+
} | FuncParamBase & {
|
|
154
|
+
type: DG.TYPE.INT
|
|
155
|
+
options?: {tag: COMMON_TAG_NAME, value: string}[]
|
|
142
156
|
} | FuncParamBase & {
|
|
143
157
|
type: DG.TYPE.DATA_FRAME,
|
|
144
158
|
options?: {tag: DF_TAG_NAME, value: string}[]
|
|
@@ -151,17 +165,30 @@ type FuncParam =
|
|
|
151
165
|
}
|
|
152
166
|
|
|
153
167
|
const generateParamLine = (param: DG.Property, direction: string) => {
|
|
154
|
-
const optionTags =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
168
|
+
const optionTags = (() => {
|
|
169
|
+
switch (param.propertyType) {
|
|
170
|
+
case DG.TYPE.INT:
|
|
171
|
+
return INT_TAG_NAMES;
|
|
172
|
+
case DG.TYPE.DATA_FRAME:
|
|
173
|
+
return DF_TAG_NAMES;
|
|
174
|
+
case DG.TYPE.COLUMN_LIST:
|
|
175
|
+
case DG.TYPE.COLUMN:
|
|
176
|
+
return COLUMN_TAG_NAMES;
|
|
177
|
+
case DG.TYPE.STRING:
|
|
178
|
+
return STRING_TAG_NAMES;
|
|
179
|
+
default:
|
|
180
|
+
return COMMON_TAG_NAMES;
|
|
181
|
+
}
|
|
182
|
+
})();
|
|
183
|
+
const optionTagsPreview = optionTags
|
|
184
|
+
.map((tag) => {
|
|
185
|
+
// console.log(param.name, tag, JSON.stringify(param.options), param.options[tag]);
|
|
186
|
+
return {tag: tag, val: param.options[tag]};
|
|
187
|
+
})
|
|
188
|
+
.filter((value) => !!value.val)
|
|
189
|
+
.map(({tag, val}) => `${tag}:${val}`)
|
|
190
|
+
.join('; ');
|
|
191
|
+
const result =`#${direction}: ${param.propertyType} ${param.name? `${param.name} ` : ''}${param.defaultValue ? `= ${param.defaultValue} ` : ''}${!!optionTagsPreview.length ? `{${optionTagsPreview}} ` : ''}${param.description ? `[${param.description}]` : ''}\n`;
|
|
165
192
|
return result;
|
|
166
193
|
};
|
|
167
194
|
|
|
@@ -218,7 +245,9 @@ export function _functionEditor(functionCode: string) {
|
|
|
218
245
|
addButton.replaceWith(newAddButton);
|
|
219
246
|
addButton = newAddButton;
|
|
220
247
|
};
|
|
221
|
-
const menu = DG.Menu.popup().items(getNewProps()
|
|
248
|
+
const menu = DG.Menu.popup().items(getNewProps().map(
|
|
249
|
+
(propName) => functionPropsLabels(propName as FUNC_PROPS_FIELDS),
|
|
250
|
+
), onItemClick);
|
|
222
251
|
|
|
223
252
|
const shevron = ui.iconFA('chevron-down');
|
|
224
253
|
const button = ui.button([ui.icons.add(()=>{}), shevron], () => {
|