datagrok-tools 4.14.21 → 4.14.23

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.
@@ -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']
@@ -109,7 +109,7 @@ const replacers = exports.replacers = {
109
109
  FUNC_NAME_LOWERCASE: (s, name) => s.replace(/#{FUNC_NAME_LOWERCASE}/g, friendlyNameToName(name, false)),
110
110
  PARAMS_OBJECT: (s, params) => s.replace(/#{PARAMS_OBJECT}/g, params.length ? `{ ${params.map(p => p.name).join(', ')} }` : `{}`),
111
111
  OUTPUT_TYPE: (s, type) => s.replace(/#{OUTPUT_TYPE}/g, type),
112
- TYPED_PARAMS: (s, params) => s.replace(/#{TYPED_PARAMS}/g, params.map(p => `${p.name}${p.isOptional ? '?' : ''}: ${p.type}`).join(', '))
112
+ TYPED_PARAMS: (s, params) => s.replace(/#{TYPED_PARAMS}/g, params.map(p => `${p.name}${p.isOptional ? '?' : ''}: ${p.type} ${p.nullable ? '| null' : ''}`).join(', '))
113
113
  };
114
114
  class TemplateBuilder {
115
115
  static sep = '\n';
@@ -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]];
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]]}`].join(', ');
213
+ }
214
+ }
215
+ return wasSecond ? `{${resType}}` : resType;
201
216
  }
202
217
  ;
203
218
  function getScriptInputs(script, comment = '#') {
@@ -205,12 +220,14 @@ function getScriptInputs(script, comment = '#') {
205
220
  const inputs = [];
206
221
  for (const match of script.matchAll(regex)) {
207
222
  const isOptional = /isOptional\s*:\s*true/.test(match[0]) || /optional\s*:\s*true/.test(match[0]);
223
+ const nullable = /nullable\s*:\s*true/.test(match[0]);
208
224
  const type = dgToTsTypeMap[match[1]] || 'any';
209
225
  const name = match[2];
210
226
  inputs.push({
211
227
  type,
212
228
  name,
213
- isOptional
229
+ isOptional,
230
+ nullable
214
231
  });
215
232
  }
216
233
  return inputs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datagrok-tools",
3
- "version": "4.14.21",
3
+ "version": "4.14.23",
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": {