datagrok-tools 4.14.20 → 4.14.22
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/bin/utils/utils.js
CHANGED
|
@@ -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';
|
|
@@ -204,13 +204,15 @@ function getScriptInputs(script, comment = '#') {
|
|
|
204
204
|
const regex = new RegExp(`${comment}\\s*input:\\s?([a-z_]+)(?:<[^>]*>)?\\s+(\\w+)(?:[^{\\n]*{[^}\\n]*})?`, 'g');
|
|
205
205
|
const inputs = [];
|
|
206
206
|
for (const match of script.matchAll(regex)) {
|
|
207
|
-
const isOptional = /isOptional\s*:\s*true/.test(match[0]);
|
|
207
|
+
const isOptional = /isOptional\s*:\s*true/.test(match[0]) || /optional\s*:\s*true/.test(match[0]);
|
|
208
|
+
const nullable = /nullable\s*:\s*true/.test(match[0]);
|
|
208
209
|
const type = dgToTsTypeMap[match[1]] || 'any';
|
|
209
210
|
const name = match[2];
|
|
210
211
|
inputs.push({
|
|
211
212
|
type,
|
|
212
213
|
name,
|
|
213
|
-
isOptional
|
|
214
|
+
isOptional,
|
|
215
|
+
nullable
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
218
|
return inputs;
|
package/package.json
CHANGED