datagrok-tools 4.14.48 → 4.14.50
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.
|
@@ -21,7 +21,7 @@ let pseudoParams = exports.pseudoParams = /*#__PURE__*/function (pseudoParams) {
|
|
|
21
21
|
return pseudoParams;
|
|
22
22
|
}({});
|
|
23
23
|
const nonMetaData = ['sidebar', 'editor', 'friendlyName', 'helpUrl', 'help-url', 'condition', 'connection', 'top-menu', 'cache', 'cache.invalidateOn', 'test'];
|
|
24
|
-
const decoratorOptionToAnnotation = exports.decoratorOptionToAnnotation = new Map([['
|
|
24
|
+
const decoratorOptionToAnnotation = exports.decoratorOptionToAnnotation = new Map([['helpUrl', 'help-url'], ['topMenu', 'top-menu'], ['metaUrl', 'meta.url'], ['optionsType', 'type'], ['cacheInvalidateOn', 'cache.invalidateOn'], ['scriptHandlerLanguage', 'scriptHandler.language'], ['scriptHandlerExtensions', 'scriptHandler.extensions'], ['scriptHandlerCommentStart', 'scriptHandler.commentStart'], ['scriptHandlerTemplateScript', 'scriptHandler.templateScript'], ['scriptHandlerCodeEditorMode', 'scriptHandler.codeEditorMode'], ['scriptHandlerVectorizationFunction', 'scriptHandler.vectorizationFunction']]);
|
|
25
25
|
const dgAnnotationTypes = exports.dgAnnotationTypes = {
|
|
26
26
|
INT: 'int',
|
|
27
27
|
BIG_INT: 'bigint',
|
|
@@ -129,7 +129,7 @@ function getFuncAnnotation(data, comment = '//', sep = '\n') {
|
|
|
129
129
|
const isFileViewer = data.tags?.includes(FUNC_TYPES.FILE_VIEWER) ?? false;
|
|
130
130
|
const isFileImporter = data.tags?.includes(FUNC_TYPES.FILE_HANDLER) ?? false;
|
|
131
131
|
let s = '';
|
|
132
|
-
if (data.name
|
|
132
|
+
if (data.name) s += `${comment}name: ${data.name}${sep}`;
|
|
133
133
|
if (pseudoParams.EXTENSION in data && data.tags != null && data.tags.includes(FUNC_TYPES.FILE_EXPORTER)) s += `${comment}description: Save as ${data[pseudoParams.EXTENSION]}${sep}`;else if (data.description) s += `${comment}description: ${data.description}${sep}`;
|
|
134
134
|
if (data.tags && data.tags?.length > 0) {
|
|
135
135
|
s += `${comment}tags: ${isFileViewer && data[pseudoParams.EXTENSIONS] ? data.tags.concat(data[pseudoParams.EXTENSIONS].map(ext => 'fileViewer-' + ext)).join(', ') : data.tags.join(', ')}${sep}`;
|
|
@@ -186,14 +186,19 @@ function getFuncAnnotation(data, comment = '//', sep = '\n') {
|
|
|
186
186
|
const inputOptionsNames = exports.inputOptionsNames = ['semType', 'category', 'optional', 'editor', 'nullable', 'separators', 'choices', 'format', 'min', 'max', 'caption', 'description', 'initialValue', 'viewer', 'units', 'type', 'optionsType', 'step', 'meta.url', 'metaUrl'];
|
|
187
187
|
function buildStringOfOptions(input) {
|
|
188
188
|
const optionsInString = [];
|
|
189
|
-
|
|
189
|
+
const opt = input.options ?? {};
|
|
190
|
+
let defaultValue = '';
|
|
191
|
+
if (opt['initialValue']) defaultValue = ` = ${opt['initialValue']}`;
|
|
192
|
+
for (const [key, value] of Object.entries(opt)) {
|
|
193
|
+
if (key === 'initialValue') continue;
|
|
190
194
|
let val = value;
|
|
191
195
|
let option = key;
|
|
192
196
|
option = decoratorOptionToAnnotation.get(option) ?? option;
|
|
193
197
|
if (Array.isArray(value)) val = JSON.stringify(value);
|
|
194
198
|
optionsInString.push(`${option}: ${val}`);
|
|
195
199
|
}
|
|
196
|
-
|
|
200
|
+
const optString = optionsInString.length > 0 ? `{ ${optionsInString.join('; ')} }` : '';
|
|
201
|
+
return `${defaultValue} ${optString}`;
|
|
197
202
|
}
|
|
198
203
|
const reservedDecorators = exports.reservedDecorators = {
|
|
199
204
|
viewer: {
|
package/package.json
CHANGED
|
@@ -173,11 +173,13 @@ class FuncGeneratorPlugin {
|
|
|
173
173
|
node?.type === 'MethodDefinition' ? className : identifierName,
|
|
174
174
|
modifyImportPath(path.dirname(this.options.outputPath), file),
|
|
175
175
|
);
|
|
176
|
+
|
|
176
177
|
imports.add(importString);
|
|
177
178
|
const funcName = `${
|
|
178
179
|
node?.type === 'MethodDefinition' ? '' : '_'
|
|
179
180
|
}${identifierName}`;
|
|
180
181
|
const funcAnnotaionOptions = {
|
|
182
|
+
...{name: funcName},
|
|
181
183
|
...reservedDecorators[name]['metadata'],
|
|
182
184
|
...(annotationByReturnObj ?
|
|
183
185
|
{outputs: annotationByReturnObj ?? []} :
|
|
@@ -196,10 +198,20 @@ class FuncGeneratorPlugin {
|
|
|
196
198
|
actualType = 'void';
|
|
197
199
|
|
|
198
200
|
// if (!funcAnnotaionOptions.name) funcAnnotaionOptions.name = identifierName;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
function containsAnything(funcAnnotaionOptions) {
|
|
202
|
+
let hasValues = false;
|
|
203
|
+
const arrays = ['tags', 'inputs', 'outputs'];
|
|
204
|
+
for (const option of Object.keys(funcAnnotaionOptions)) {
|
|
205
|
+
if (arrays.includes(option)) {
|
|
206
|
+
if (funcAnnotaionOptions[option].length > 0)
|
|
207
|
+
hasValues = true;
|
|
208
|
+
} else if (option != 'isAsync' && option != 'name')
|
|
209
|
+
hasValues = true;
|
|
210
|
+
}
|
|
211
|
+
return hasValues;
|
|
212
|
+
}
|
|
213
|
+
if (funcAnnotaionOptions.name === funcName && containsAnything(funcAnnotaionOptions))
|
|
214
|
+
delete funcAnnotaionOptions.name;
|
|
203
215
|
functions.push(
|
|
204
216
|
reservedDecorators[name]['genFunc'](
|
|
205
217
|
getFuncAnnotation(funcAnnotaionOptions),
|