1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | exports.validateModels = exports.updateLegacySessionModel = exports.validateModel = void 0;
|
6 | const validate_1 = require("../kernel/validate");
|
7 | const validate_2 = require("../validate");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function validateModel(data) {
|
13 | (0, validate_2.validateProperty)(data, 'id', 'string');
|
14 | (0, validate_2.validateProperty)(data, 'type', 'string');
|
15 | (0, validate_2.validateProperty)(data, 'name', 'string');
|
16 | (0, validate_2.validateProperty)(data, 'path', 'string');
|
17 | (0, validate_2.validateProperty)(data, 'kernel', 'object');
|
18 | (0, validate_1.validateModel)(data.kernel);
|
19 | }
|
20 | exports.validateModel = validateModel;
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | function updateLegacySessionModel(data) {
|
26 | if (data.path === undefined && data.notebook !== undefined) {
|
27 | data.path = data.notebook.path;
|
28 | data.type = 'notebook';
|
29 | data.name = '';
|
30 | }
|
31 | }
|
32 | exports.updateLegacySessionModel = updateLegacySessionModel;
|
33 |
|
34 |
|
35 |
|
36 | function validateModels(models) {
|
37 | if (!Array.isArray(models)) {
|
38 | throw new Error('Invalid session list');
|
39 | }
|
40 | models.forEach(d => validateModel(d));
|
41 | }
|
42 | exports.validateModels = validateModels;
|
43 |
|
\ | No newline at end of file |