datagrok-tools 4.12.17 → 4.12.19
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/.eslintrc.json +43 -0
- package/bin/_deprecated/migrate.js +9 -9
- package/bin/_deprecated/upload.js +36 -36
- package/bin/commands/add.js +16 -29
- package/bin/commands/api.js +22 -21
- package/bin/commands/check.js +10 -12
- package/bin/commands/config.js +120 -140
- package/bin/commands/create.js +6 -11
- package/bin/commands/help.js +11 -5
- package/bin/commands/init.js +11 -13
- package/bin/commands/link.js +6 -7
- package/bin/commands/publish.js +220 -226
- package/bin/commands/test.js +178 -184
- package/bin/grok.js +3 -3
- package/bin/utils/color-utils.js +5 -10
- package/bin/utils/ent-helpers.js +2 -3
- package/bin/utils/func-generation.js +19 -20
- package/bin/utils/test-utils.js +140 -150
- package/bin/utils/utils.js +20 -41
- package/bin/validators/config-validator.js +1 -3
- package/package-template/ts.webpack.config.js +3 -3
- package/package-template/webpack.config.js +1 -1
- package/package.json +26 -21
- package/plugins/func-gen-plugin.js +12 -12
- package/script-template/node.js +1 -1
package/bin/commands/test.js
CHANGED
|
@@ -18,8 +18,10 @@ var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
|
18
18
|
var utils = _interopRequireWildcard(require("../utils/utils"));
|
|
19
19
|
var color = _interopRequireWildcard(require("../utils/color-utils"));
|
|
20
20
|
var testUtils = _interopRequireWildcard(require("../utils/test-utils"));
|
|
21
|
-
function _getRequireWildcardCache(
|
|
22
|
-
function _interopRequireWildcard(
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
23
|
+
/* eslint-disable max-len */
|
|
24
|
+
|
|
23
25
|
function test(args) {
|
|
24
26
|
var options = Object.keys(args).slice(1);
|
|
25
27
|
var commandOptions = ['host', 'csv', 'gui', 'catchUnhandled', 'report', 'skip-build', 'skip-publish', 'category', 'record', 'verbose', 'benchmark'];
|
|
@@ -65,11 +67,9 @@ function test(args) {
|
|
|
65
67
|
}
|
|
66
68
|
if (args['skip-build']) {
|
|
67
69
|
if (args['skip-publish']) test();else publish(test);
|
|
68
|
-
} else {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
70
|
+
} else build(args['skip-publish'] ? test : function () {
|
|
71
|
+
return publish(test);
|
|
72
|
+
});
|
|
73
73
|
function build(callback) {
|
|
74
74
|
(0, _child_process.exec)('npm run build', function (err, stdout, stderr) {
|
|
75
75
|
color.info("Building package...");
|
|
@@ -105,27 +105,25 @@ function test(args) {
|
|
|
105
105
|
return testUtils.runWithTimeout(timeout, /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
106
106
|
var out;
|
|
107
107
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
108
|
-
while (1) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return _context.stop();
|
|
128
|
-
}
|
|
108
|
+
while (1) switch (_context.prev = _context.next) {
|
|
109
|
+
case 0:
|
|
110
|
+
_context.prev = 0;
|
|
111
|
+
_context.next = 3;
|
|
112
|
+
return testUtils.getBrowserPage(_puppeteer["default"], params);
|
|
113
|
+
case 3:
|
|
114
|
+
out = _context.sent;
|
|
115
|
+
browser = out.browser;
|
|
116
|
+
page = out.page;
|
|
117
|
+
recorder = new _puppeteerScreenRecorder.PuppeteerScreenRecorder(page, testUtils.recorderConfig);
|
|
118
|
+
_context.next = 12;
|
|
119
|
+
break;
|
|
120
|
+
case 9:
|
|
121
|
+
_context.prev = 9;
|
|
122
|
+
_context.t0 = _context["catch"](0);
|
|
123
|
+
throw _context.t0;
|
|
124
|
+
case 12:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context.stop();
|
|
129
127
|
}
|
|
130
128
|
}, _callee, null, [[0, 9]]);
|
|
131
129
|
})));
|
|
@@ -136,121 +134,119 @@ function test(args) {
|
|
|
136
134
|
var _process$env$TARGET_P;
|
|
137
135
|
var consoleLog, targetPackage, r;
|
|
138
136
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
139
|
-
while (1) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
failReport = "Fail reason: No package tests found".concat(options.category ? " for category \"".concat(options.category, "\"") : '');
|
|
181
|
-
resolve({
|
|
182
|
-
failReport: failReport,
|
|
183
|
-
skipReport: skipReport,
|
|
184
|
-
passReport: passReport,
|
|
185
|
-
failed: failed,
|
|
186
|
-
countReport: countReport
|
|
187
|
-
});
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
var cStatus = df.columns.byName('success');
|
|
191
|
-
var cSkipped = df.columns.byName('skipped');
|
|
192
|
-
var cMessage = df.columns.byName('result');
|
|
193
|
-
var cCat = df.columns.byName('category');
|
|
194
|
-
var cName = df.columns.byName('name');
|
|
195
|
-
var cTime = df.columns.byName('ms');
|
|
196
|
-
for (var i = 0; i < df.rowCount; i++) {
|
|
197
|
-
if (cStatus.get(i)) {
|
|
198
|
-
if (cSkipped.get(i)) {
|
|
199
|
-
skipReport += "Test result : Skipped : ".concat(cTime.get(i), " : ").concat(targetPackage, ".").concat(cCat.get(i), ".").concat(cName.get(i), " : ").concat(cMessage.get(i), "\n");
|
|
200
|
-
countReport.skip += 1;
|
|
201
|
-
} else {
|
|
202
|
-
passReport += "Test result : Success : ".concat(cTime.get(i), " : ").concat(targetPackage, ".").concat(cCat.get(i), ".").concat(cName.get(i), " : ").concat(cMessage.get(i), "\n");
|
|
203
|
-
countReport.pass += 1;
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
failed = true;
|
|
207
|
-
failReport += "Test result : Failed : ".concat(cTime.get(i), " : ").concat(targetPackage, ".").concat(cCat.get(i), ".").concat(cName.get(i), " : ").concat(cMessage.get(i), "\n");
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (!options.verbose) df.rows.removeWhere(function (r) {
|
|
211
|
-
return r.get('success');
|
|
212
|
-
});
|
|
213
|
-
var csv = df.toCsv();
|
|
137
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
138
|
+
case 0:
|
|
139
|
+
consoleLog = '';
|
|
140
|
+
if (!options.record) {
|
|
141
|
+
_context2.next = 7;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
_context2.next = 4;
|
|
145
|
+
return recorder.start('./test-record.mp4');
|
|
146
|
+
case 4:
|
|
147
|
+
page.on('console', function (msg) {
|
|
148
|
+
return consoleLog += "CONSOLE LOG ENTRY: ".concat(msg.text(), "\n");
|
|
149
|
+
});
|
|
150
|
+
page.on('pageerror', function (error) {
|
|
151
|
+
consoleLog += "CONSOLE LOG ERROR: ".concat(error.message, "\n");
|
|
152
|
+
});
|
|
153
|
+
page.on('response', function (response) {
|
|
154
|
+
consoleLog += "CONSOLE LOG REQUEST: ".concat(response.status(), ", ").concat(response.url(), "\n");
|
|
155
|
+
});
|
|
156
|
+
case 7:
|
|
157
|
+
targetPackage = (_process$env$TARGET_P = process.env.TARGET_PACKAGE) !== null && _process$env$TARGET_P !== void 0 ? _process$env$TARGET_P : '#{PACKAGE_NAMESPACE}';
|
|
158
|
+
console.log("Testing ".concat(targetPackage, " package...\n"));
|
|
159
|
+
_context2.next = 11;
|
|
160
|
+
return page.evaluate(function (targetPackage, options, testContext) {
|
|
161
|
+
if (options.benchmark) window.DG.Test.isInBenchmark = true;
|
|
162
|
+
return new Promise(function (resolve, reject) {
|
|
163
|
+
window.grok.functions.call("".concat(targetPackage, ":test"), {
|
|
164
|
+
'category': options.category,
|
|
165
|
+
'testContext': testContext
|
|
166
|
+
}).then(function (df) {
|
|
167
|
+
var failed = false;
|
|
168
|
+
var skipReport = '';
|
|
169
|
+
var passReport = '';
|
|
170
|
+
var failReport = '';
|
|
171
|
+
var countReport = {
|
|
172
|
+
skip: 0,
|
|
173
|
+
pass: 0
|
|
174
|
+
};
|
|
175
|
+
if (df == null) {
|
|
176
|
+
failed = true;
|
|
177
|
+
failReport = "Fail reason: No package tests found".concat(options.category ? " for category \"".concat(options.category, "\"") : '');
|
|
214
178
|
resolve({
|
|
215
179
|
failReport: failReport,
|
|
216
180
|
skipReport: skipReport,
|
|
217
181
|
passReport: passReport,
|
|
218
182
|
failed: failed,
|
|
219
|
-
csv: csv,
|
|
220
183
|
countReport: countReport
|
|
221
184
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
var cStatus = df.columns.byName('success');
|
|
188
|
+
var cSkipped = df.columns.byName('skipped');
|
|
189
|
+
var cMessage = df.columns.byName('result');
|
|
190
|
+
var cCat = df.columns.byName('category');
|
|
191
|
+
var cName = df.columns.byName('name');
|
|
192
|
+
var cTime = df.columns.byName('ms');
|
|
193
|
+
for (var i = 0; i < df.rowCount; i++) {
|
|
194
|
+
if (cStatus.get(i)) {
|
|
195
|
+
if (cSkipped.get(i)) {
|
|
196
|
+
skipReport += "Test result : Skipped : ".concat(cTime.get(i), " : ").concat(targetPackage, ".").concat(cCat.get(i), ".").concat(cName.get(i), " : ").concat(cMessage.get(i), "\n");
|
|
197
|
+
countReport.skip += 1;
|
|
198
|
+
} else {
|
|
199
|
+
passReport += "Test result : Success : ".concat(cTime.get(i), " : ").concat(targetPackage, ".").concat(cCat.get(i), ".").concat(cName.get(i), " : ").concat(cMessage.get(i), "\n");
|
|
200
|
+
countReport.pass += 1;
|
|
233
201
|
}
|
|
234
|
-
}
|
|
202
|
+
} else {
|
|
203
|
+
failed = true;
|
|
204
|
+
failReport += "Test result : Failed : ".concat(cTime.get(i), " : ").concat(targetPackage, ".").concat(cCat.get(i), ".").concat(cName.get(i), " : ").concat(cMessage.get(i), "\n");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (!options.verbose) df.rows.removeWhere(function (r) {
|
|
208
|
+
return r.get('success');
|
|
209
|
+
});
|
|
210
|
+
var csv = df.toCsv();
|
|
211
|
+
resolve({
|
|
212
|
+
failReport: failReport,
|
|
213
|
+
skipReport: skipReport,
|
|
214
|
+
passReport: passReport,
|
|
215
|
+
failed: failed,
|
|
216
|
+
csv: csv,
|
|
217
|
+
countReport: countReport
|
|
218
|
+
});
|
|
219
|
+
})["catch"](function (e) {
|
|
220
|
+
var stack = window.DG.Logger.translateStackTrace(e.stack);
|
|
221
|
+
resolve({
|
|
222
|
+
failReport: "".concat(e.message, "\n").concat(stack),
|
|
223
|
+
skipReport: '',
|
|
224
|
+
passReport: '',
|
|
225
|
+
failed: true,
|
|
226
|
+
csv: '',
|
|
227
|
+
countReport: {
|
|
228
|
+
skip: 0,
|
|
229
|
+
pass: 0
|
|
230
|
+
}
|
|
235
231
|
});
|
|
236
232
|
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
233
|
+
});
|
|
234
|
+
}, targetPackage, options, new testUtils.TestContext(options.catchUnhandled, options.report));
|
|
235
|
+
case 11:
|
|
236
|
+
r = _context2.sent;
|
|
237
|
+
if (!options.record) {
|
|
238
|
+
_context2.next = 16;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
_context2.next = 15;
|
|
242
|
+
return recorder.stop();
|
|
243
|
+
case 15:
|
|
244
|
+
_fs["default"].writeFileSync('./test-console-output.log', consoleLog);
|
|
245
|
+
case 16:
|
|
246
|
+
return _context2.abrupt("return", r);
|
|
247
|
+
case 17:
|
|
248
|
+
case "end":
|
|
249
|
+
return _context2.stop();
|
|
254
250
|
}
|
|
255
251
|
}, _callee2);
|
|
256
252
|
})));
|
|
@@ -258,59 +254,57 @@ function test(args) {
|
|
|
258
254
|
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
259
255
|
var r;
|
|
260
256
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
261
|
-
while (1) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
257
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
258
|
+
case 0:
|
|
259
|
+
_context3.prev = 0;
|
|
260
|
+
_context3.next = 3;
|
|
261
|
+
return init(P_START_TIMEOUT);
|
|
262
|
+
case 3:
|
|
263
|
+
color.success('Initialization completed.');
|
|
264
|
+
_context3.next = 10;
|
|
265
|
+
break;
|
|
266
|
+
case 6:
|
|
267
|
+
_context3.prev = 6;
|
|
268
|
+
_context3.t0 = _context3["catch"](0);
|
|
269
|
+
color.error('Initialization failed.');
|
|
270
|
+
throw _context3.t0;
|
|
271
|
+
case 10:
|
|
272
|
+
_context3.next = 12;
|
|
273
|
+
return runTest(7200000, {
|
|
274
|
+
category: args.category,
|
|
275
|
+
verbose: args.verbose,
|
|
276
|
+
catchUnhandled: args.catchUnhandled,
|
|
277
|
+
report: args.report,
|
|
278
|
+
record: args.record,
|
|
279
|
+
benchmark: args.benchmark
|
|
280
|
+
});
|
|
281
|
+
case 12:
|
|
282
|
+
r = _context3.sent;
|
|
283
|
+
if (r.csv && args.csv) {
|
|
284
|
+
_fs["default"].writeFileSync(_path["default"].join(curDir, 'test-report.csv'), r.csv, 'utf8');
|
|
285
|
+
color.info('Saved `test-report.csv`\n');
|
|
286
|
+
}
|
|
287
|
+
if (r.passReport && args.verbose) console.log(r.passReport);else console.log('Passed tests: ' + r.countReport.pass);
|
|
288
|
+
if (r.skipReport && args.verbose) console.log(r.skipReport);else console.log('Skipped tests: ' + r.countReport.skip);
|
|
289
|
+
if (r.failed) {
|
|
290
|
+
console.log(r.failReport);
|
|
291
|
+
color.fail('Tests failed.');
|
|
292
|
+
testUtils.exitWithCode(1);
|
|
293
|
+
} else {
|
|
294
|
+
color.success('Tests passed.');
|
|
295
|
+
testUtils.exitWithCode(0);
|
|
296
|
+
}
|
|
302
297
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
_context3.next = 20;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
298
|
+
//@ts-ignore
|
|
299
|
+
if (!(browser != null)) {
|
|
308
300
|
_context3.next = 20;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
_context3.next = 20;
|
|
304
|
+
return browser.close();
|
|
305
|
+
case 20:
|
|
306
|
+
case "end":
|
|
307
|
+
return _context3.stop();
|
|
314
308
|
}
|
|
315
309
|
}, _callee3, null, [[0, 6]]);
|
|
316
310
|
}))();
|
package/bin/grok.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const argv = require('minimist')(process.argv.slice(2), {
|
|
3
|
-
alias: {
|
|
3
|
+
alias: {k: 'key', h: 'help', r: 'recursive'},
|
|
4
4
|
});
|
|
5
5
|
const help = require('./commands/help').help;
|
|
6
6
|
|
|
@@ -28,9 +28,9 @@ if (command in commands) {
|
|
|
28
28
|
console.log(help[command]);
|
|
29
29
|
exitWithCode(1);
|
|
30
30
|
}
|
|
31
|
-
} else
|
|
31
|
+
} else
|
|
32
32
|
console.log(help.help);
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
|
|
35
35
|
function exitWithCode(code) {
|
|
36
36
|
console.log(`Exiting with code ${code}`);
|
package/bin/utils/color-utils.js
CHANGED
|
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.warn = exports.success = exports.info = exports.fail = exports.error = void 0;
|
|
7
|
-
var error = function error(s) {
|
|
7
|
+
var error = exports.error = function error(s) {
|
|
8
8
|
return console.log('\x1b[31m%s\x1b[0m', s);
|
|
9
9
|
};
|
|
10
|
-
exports.
|
|
11
|
-
var info = function info(s) {
|
|
10
|
+
var info = exports.info = function info(s) {
|
|
12
11
|
return console.log('\x1b[32m%s\x1b[0m', s);
|
|
13
12
|
};
|
|
14
|
-
exports.
|
|
15
|
-
var warn = function warn(s) {
|
|
13
|
+
var warn = exports.warn = function warn(s) {
|
|
16
14
|
return console.log('\x1b[33m%s\x1b[0m', s);
|
|
17
15
|
};
|
|
18
|
-
exports.
|
|
19
|
-
var
|
|
20
|
-
exports.success = success;
|
|
21
|
-
var fail = error;
|
|
22
|
-
exports.fail = fail;
|
|
16
|
+
var success = exports.success = info;
|
|
17
|
+
var fail = exports.fail = error;
|
package/bin/utils/ent-helpers.js
CHANGED
|
@@ -35,7 +35,7 @@ var _package = function _package(ts) {
|
|
|
35
35
|
var test = function test(dir) {
|
|
36
36
|
return "Tests have been added successfully to ".concat(dir, "\nRun 'npm install' to get newly added packages\nRead more about package testing at https://datagrok.ai/help/develop/how-to/test-packages");
|
|
37
37
|
};
|
|
38
|
-
var help = {
|
|
38
|
+
var help = exports.help = {
|
|
39
39
|
app: app,
|
|
40
40
|
connection: connection,
|
|
41
41
|
detector: detector,
|
|
@@ -46,5 +46,4 @@ var help = {
|
|
|
46
46
|
viewer: viewer,
|
|
47
47
|
"package": _package,
|
|
48
48
|
test: test
|
|
49
|
-
};
|
|
50
|
-
exports.help = help;
|
|
49
|
+
};
|
|
@@ -12,20 +12,18 @@ exports.getFuncAnnotation = getFuncAnnotation;
|
|
|
12
12
|
exports.reservedDecorators = exports.pseudoParams = exports.headerParams = void 0;
|
|
13
13
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
14
14
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.
|
|
20
|
-
|
|
15
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
|
+
/* eslint-disable no-unused-vars */
|
|
17
|
+
/* eslint-disable valid-jsdoc */
|
|
18
|
+
|
|
19
|
+
var headerParams = exports.headerParams = ['name', 'description', 'tags', 'inputs', 'outputs'];
|
|
20
|
+
var pseudoParams = exports.pseudoParams = /*#__PURE__*/function (pseudoParams) {
|
|
21
21
|
pseudoParams["EXTENSION"] = "extension";
|
|
22
22
|
pseudoParams["EXTENSIONS"] = "extensions";
|
|
23
23
|
pseudoParams["INPUT_TYPE"] = "inputType";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.FUNC_TYPES = FUNC_TYPES;
|
|
28
|
-
(function (FUNC_TYPES) {
|
|
24
|
+
return pseudoParams;
|
|
25
|
+
}({});
|
|
26
|
+
var FUNC_TYPES = exports.FUNC_TYPES = /*#__PURE__*/function (FUNC_TYPES) {
|
|
29
27
|
FUNC_TYPES["CELL_RENDERER"] = "cellRenderer";
|
|
30
28
|
FUNC_TYPES["FILE_EXPORTER"] = "fileExporter";
|
|
31
29
|
FUNC_TYPES["FILE_IMPORTER"] = "file-handler";
|
|
@@ -33,7 +31,9 @@ exports.FUNC_TYPES = FUNC_TYPES;
|
|
|
33
31
|
FUNC_TYPES["SETTINGS_EDITOR"] = "packageSettingsEditor";
|
|
34
32
|
FUNC_TYPES["VIEWER"] = "viewer";
|
|
35
33
|
FUNC_TYPES["FILTER"] = "filter";
|
|
36
|
-
|
|
34
|
+
return FUNC_TYPES;
|
|
35
|
+
}({});
|
|
36
|
+
/** Generates an annotation header for a function based on provided metadata. */
|
|
37
37
|
function getFuncAnnotation(data) {
|
|
38
38
|
var _data$tags$includes, _data$tags, _data$tags$includes2, _data$tags2;
|
|
39
39
|
var comment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '//';
|
|
@@ -43,9 +43,11 @@ function getFuncAnnotation(data) {
|
|
|
43
43
|
var s = '';
|
|
44
44
|
if (data.name) s += "".concat(comment, "name: ").concat(data.name).concat(sep);
|
|
45
45
|
if (pseudoParams.EXTENSION in data && data.tags != null && data.tags.includes(FUNC_TYPES.FILE_EXPORTER)) s += "".concat(comment, "description: Save as ").concat(data[pseudoParams.EXTENSION]).concat(sep);else if (data.description) s += "".concat(comment, "description: ").concat(data.description).concat(sep);
|
|
46
|
-
if (data.tags)
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if (data.tags) {
|
|
47
|
+
s += "".concat(comment, "tags: ").concat(isFileViewer && data[pseudoParams.EXTENSIONS] ? data.tags.concat(data[pseudoParams.EXTENSIONS].map(function (ext) {
|
|
48
|
+
return 'fileViewer-' + ext;
|
|
49
|
+
})).join() : data.tags.join()).concat(sep);
|
|
50
|
+
}
|
|
49
51
|
if (data.inputs) {
|
|
50
52
|
var _iterator = _createForOfIteratorHelper(data.inputs),
|
|
51
53
|
_step;
|
|
@@ -78,13 +80,11 @@ function getFuncAnnotation(data) {
|
|
|
78
80
|
if (parameter === pseudoParams.EXTENSION || parameter === pseudoParams.INPUT_TYPE) continue;else if (parameter === pseudoParams.EXTENSIONS) {
|
|
79
81
|
if (isFileViewer) continue;
|
|
80
82
|
s += "".concat(comment, "meta.ext: ").concat(data[parameter]).concat(sep);
|
|
81
|
-
} else if (!headerParams.includes(parameter))
|
|
82
|
-
s += "".concat(comment, "meta.").concat(parameter, ": ").concat(data[parameter]).concat(sep);
|
|
83
|
-
}
|
|
83
|
+
} else if (!headerParams.includes(parameter)) s += "".concat(comment, "meta.").concat(parameter, ": ").concat(data[parameter]).concat(sep);
|
|
84
84
|
}
|
|
85
85
|
return s;
|
|
86
86
|
}
|
|
87
|
-
var reservedDecorators = {
|
|
87
|
+
var reservedDecorators = exports.reservedDecorators = {
|
|
88
88
|
viewer: {
|
|
89
89
|
metadata: {
|
|
90
90
|
tags: [FUNC_TYPES.VIEWER],
|
|
@@ -168,7 +168,6 @@ var reservedDecorators = {
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
/** Generates a DG function that instantiates a class. */
|
|
171
|
-
exports.reservedDecorators = reservedDecorators;
|
|
172
171
|
function generateClassFunc(annotation, className) {
|
|
173
172
|
var sep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '\n';
|
|
174
173
|
return annotation + "export function _".concat(className, "() {").concat(sep, " return new ").concat(className, "();").concat(sep, "}").concat(sep.repeat(2));
|