datagrok-tools 4.14.22 → 4.14.24

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.
@@ -103,13 +103,7 @@ function generateFunctionWrappers() {
103
103
  const annotationInputs = utils.getScriptInputs(annotation[0], utils.commentMap[utils.jsExtention]);
104
104
  const annotationOutputDir = utils.getScriptOutputType(annotation[0], utils.commentMap[utils.jsExtention]);
105
105
  let outputType = '';
106
- for (let outputAnnotation of annotationOutputDir) {
107
- if (outputType != '') {
108
- outputType = 'any';
109
- break;
110
- }
111
- outputType = utils.dgToTsTypeMap[outputAnnotation[1]] ?? 'any';
112
- }
106
+ outputType = annotationOutputDir ?? 'any';
113
107
  checkNameColision(name);
114
108
  const tb = new utils.TemplateBuilder(utils.scriptWrapperTemplate).replace('FUNC_NAME', name).replace('FUNC_NAME_LOWERCASE', name).replace('PACKAGE_NAMESPACE', _package?.friendlyName ?? '').replace('PARAMS_OBJECT', annotationInputs).replace('FUNC_DESCRIPTION', description).replace('TYPED_PARAMS', annotationInputs).replace('OUTPUT_TYPE', outputType);
115
109
  wrappers.push(tb.build(1));
@@ -35,6 +35,7 @@ function check(args) {
35
35
  }
36
36
  }
37
37
  function runChecks(packagePath, soft = false) {
38
+ if (packagePath.includes(`${_path.default.sep}node_modules${_path.default.sep}`)) return true;
38
39
  const files = _ignoreWalk.default.sync({
39
40
  path: packagePath,
40
41
  ignoreFiles: ['.npmignore', '.gitignore']
@@ -194,10 +194,25 @@ const nameAnnRegex = exports.nameAnnRegex = /\s*(name[^:]*): ([^\n\r\[\{]+)/;
194
194
  const nameRegex = exports.nameRegex = /(?:|(?:static)(?:export )(?:async ))\s+function\s+([a-zA-Z_][a-zA-Z0-9_$]*)\s*\((.*?).*/;
195
195
  const absUrlRegex = exports.absUrlRegex = new RegExp('^(?:[a-z+]+:)?//', 'i');
196
196
  function getScriptOutputType(script, comment = '#') {
197
- const regex = new RegExp(`${comment}\\s*output:\\s?([a-z_]+)\\s*`);
198
- const match = script.match(regex);
199
- if (!match) return 'void';
200
- return dgToTsTypeMap[match[1]] || 'any';
197
+ const regex = /\s*output:\s?([a-z_]+)\s*([^\s]*)/g;
198
+ const matches = script.matchAll(regex);
199
+ if (!matches) return 'void';
200
+ let resType = 'void';
201
+ let firstItemName = '';
202
+ let wasSecond = false;
203
+ for (let match of matches) {
204
+ if (resType === 'void') {
205
+ resType = dgToTsTypeMap[match[1]] ?? 'any';
206
+ firstItemName = match[2];
207
+ } else {
208
+ if (!wasSecond) {
209
+ resType = `${firstItemName}: ${resType}`;
210
+ wasSecond = true;
211
+ }
212
+ resType = [resType, `${match[2]}: ${dgToTsTypeMap[match[1]] ?? 'any'}`].join(', ');
213
+ }
214
+ }
215
+ return wasSecond ? `{${resType}}` : resType;
201
216
  }
202
217
  ;
203
218
  function getScriptInputs(script, comment = '#') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datagrok-tools",
3
- "version": "4.14.22",
3
+ "version": "4.14.24",
4
4
  "description": "Utility to upload and publish packages to Datagrok",
5
5
  "homepage": "https://github.com/datagrok-ai/public/tree/master/tools#readme",
6
6
  "dependencies": {