@zthun/romulator-api 1.2.0 → 1.3.0
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/dist/config/config-known.d.mts +2 -3
- package/dist/main.cjs +554 -1329
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +561 -1336
- package/dist/main.js.map +1 -1
- package/dist/media/media-controller.d.mts +10 -0
- package/dist/media/media-module.d.mts +2 -0
- package/dist/media/media-service.d.mts +24 -0
- package/dist/systems/system-known.d.mts +78 -9
- package/package.json +17 -11
package/dist/main.cjs
CHANGED
|
@@ -14,40 +14,27 @@ const lodashEs = require('lodash-es');
|
|
|
14
14
|
const promises = require('node:fs/promises');
|
|
15
15
|
const node_path = require('node:path');
|
|
16
16
|
const node_os = require('node:os');
|
|
17
|
+
const webigailHttp = require('@zthun/webigail-http');
|
|
18
|
+
const webigailUrl = require('@zthun/webigail-url');
|
|
19
|
+
const mimeTypes = require('mime-types');
|
|
20
|
+
const node_fs = require('node:fs');
|
|
21
|
+
const node_process = require('node:process');
|
|
22
|
+
const helpfulReflection = require('@zthun/helpful-reflection');
|
|
17
23
|
require('reflect-metadata');
|
|
18
24
|
|
|
19
|
-
function
|
|
20
|
-
if (!(instance instanceof Constructor)) {
|
|
21
|
-
throw new TypeError("Cannot call a class as a function");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function _define_property$4(obj, key, value) {
|
|
25
|
-
if (key in obj) {
|
|
26
|
-
Object.defineProperty(obj, key, {
|
|
27
|
-
value: value,
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true
|
|
31
|
-
});
|
|
32
|
-
} else {
|
|
33
|
-
obj[key] = value;
|
|
34
|
-
}
|
|
35
|
-
return obj;
|
|
36
|
-
}
|
|
37
|
-
function _ts_decorate$8(decorators, target, key, desc) {
|
|
25
|
+
function _ts_decorate$b(decorators, target, key, desc) {
|
|
38
26
|
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
39
27
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
40
28
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
41
29
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
42
30
|
}
|
|
43
|
-
function _ts_metadata$
|
|
31
|
+
function _ts_metadata$7(k, v) {
|
|
44
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
45
33
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_ts_decorate$8([
|
|
34
|
+
class ZRomulatorConfigUpdateDto {
|
|
35
|
+
contents;
|
|
36
|
+
}
|
|
37
|
+
_ts_decorate$b([
|
|
51
38
|
swagger.ApiProperty({
|
|
52
39
|
type: "object",
|
|
53
40
|
properties: {}
|
|
@@ -59,727 +46,177 @@ _ts_decorate$8([
|
|
|
59
46
|
message: "The contents of the config must be an object "
|
|
60
47
|
}),
|
|
61
48
|
classValidator.IsNotEmptyObject(),
|
|
62
|
-
_ts_metadata$
|
|
49
|
+
_ts_metadata$7("design:type", typeof T === "undefined" ? Object : T)
|
|
63
50
|
], ZRomulatorConfigUpdateDto.prototype, "contents", void 0);
|
|
64
51
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function _defineProperties$6(target, props) {
|
|
71
|
-
for(var i = 0; i < props.length; i++){
|
|
72
|
-
var descriptor = props[i];
|
|
73
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
74
|
-
descriptor.configurable = true;
|
|
75
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
76
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function _create_class$6(Constructor, protoProps, staticProps) {
|
|
80
|
-
if (staticProps) _defineProperties$6(Constructor, staticProps);
|
|
81
|
-
return Constructor;
|
|
82
|
-
}
|
|
83
|
-
var ZDir = /*#__PURE__*/ function() {
|
|
84
|
-
function ZDir() {
|
|
85
|
-
_class_call_check$9(this, ZDir);
|
|
86
|
-
}
|
|
87
|
-
_create_class$6(ZDir, null, [
|
|
88
|
-
{
|
|
89
|
-
key: "application",
|
|
90
|
-
value: function application() {
|
|
91
|
-
return node_path.resolve(node_os.homedir(), ".zthunworks", "romulator");
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
key: "configs",
|
|
96
|
-
value: function configs() {
|
|
97
|
-
return node_path.resolve(ZDir.application(), "configs");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
]);
|
|
101
|
-
return ZDir;
|
|
102
|
-
}();
|
|
103
|
-
|
|
104
|
-
function _class_call_check$8(instance, Constructor) {
|
|
105
|
-
if (!(instance instanceof Constructor)) {
|
|
106
|
-
throw new TypeError("Cannot call a class as a function");
|
|
52
|
+
class ZDir {
|
|
53
|
+
static application() {
|
|
54
|
+
return node_path.resolve(node_os.homedir(), ".zthunworks", "romulator");
|
|
107
55
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
for(var i = 0; i < props.length; i++){
|
|
111
|
-
var descriptor = props[i];
|
|
112
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
113
|
-
descriptor.configurable = true;
|
|
114
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
115
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
56
|
+
static configs() {
|
|
57
|
+
return node_path.resolve(ZDir.application(), "configs");
|
|
116
58
|
}
|
|
117
59
|
}
|
|
118
|
-
function _create_class$5(Constructor, protoProps, staticProps) {
|
|
119
|
-
if (staticProps) _defineProperties$5(Constructor, staticProps);
|
|
120
|
-
return Constructor;
|
|
121
|
-
}
|
|
122
|
-
var ZRomulatorConfigKnown = /*#__PURE__*/ function() {
|
|
123
|
-
function ZRomulatorConfigKnown() {
|
|
124
|
-
_class_call_check$8(this, ZRomulatorConfigKnown);
|
|
125
|
-
}
|
|
126
|
-
_create_class$5(ZRomulatorConfigKnown, null, [
|
|
127
|
-
{
|
|
128
|
-
key: "all",
|
|
129
|
-
value: function all() {
|
|
130
|
-
return [
|
|
131
|
-
ZRomulatorConfigKnown.games().build(),
|
|
132
|
-
ZRomulatorConfigKnown.media().build()
|
|
133
|
-
];
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
key: "create",
|
|
138
|
-
value: function create(id) {
|
|
139
|
-
var file = node_path.resolve(ZDir.configs(), "".concat(id, ".json"));
|
|
140
|
-
return new romulatorClient.ZRomulatorConfigBuilder().id(id).file(file);
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
key: "games",
|
|
145
|
-
value: function games() {
|
|
146
|
-
return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Games).name("Game Settings").description("Modify where your games are stored and related settings").avatar("gamepad").metadata(romulatorClient.ZRomulatorConfigGamesMetadata.all());
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
key: "media",
|
|
151
|
-
value: function media() {
|
|
152
|
-
return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Media).name("Media Settings").description("Modify where media is stored and what media to retrieve").avatar("image").metadata(romulatorClient.ZRomulatorConfigMediaMetadata.all());
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
]);
|
|
156
|
-
return ZRomulatorConfigKnown;
|
|
157
|
-
}();
|
|
158
60
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (info.done) {
|
|
168
|
-
resolve(value);
|
|
169
|
-
} else {
|
|
170
|
-
Promise.resolve(value).then(_next, _throw);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function _async_to_generator$3(fn) {
|
|
174
|
-
return function() {
|
|
175
|
-
var self = this, args = arguments;
|
|
176
|
-
return new Promise(function(resolve, reject) {
|
|
177
|
-
var gen = fn.apply(self, args);
|
|
178
|
-
function _next(value) {
|
|
179
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
180
|
-
}
|
|
181
|
-
function _throw(err) {
|
|
182
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
183
|
-
}
|
|
184
|
-
_next(undefined);
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function _class_call_check$7(instance, Constructor) {
|
|
189
|
-
if (!(instance instanceof Constructor)) {
|
|
190
|
-
throw new TypeError("Cannot call a class as a function");
|
|
61
|
+
class ZRomulatorConfigKnown {
|
|
62
|
+
static all() {
|
|
63
|
+
return [
|
|
64
|
+
ZRomulatorConfigKnown.games(),
|
|
65
|
+
ZRomulatorConfigKnown.media()
|
|
66
|
+
];
|
|
191
67
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
var descriptor = props[i];
|
|
196
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
197
|
-
descriptor.configurable = true;
|
|
198
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
199
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
68
|
+
static create(id) {
|
|
69
|
+
const file = node_path.resolve(ZDir.configs(), `${id}.json`);
|
|
70
|
+
return new romulatorClient.ZRomulatorConfigBuilder().id(id).file(file);
|
|
200
71
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
|
204
|
-
return Constructor;
|
|
205
|
-
}
|
|
206
|
-
function _define_property$3(obj, key, value) {
|
|
207
|
-
if (key in obj) {
|
|
208
|
-
Object.defineProperty(obj, key, {
|
|
209
|
-
value: value,
|
|
210
|
-
enumerable: true,
|
|
211
|
-
configurable: true,
|
|
212
|
-
writable: true
|
|
213
|
-
});
|
|
214
|
-
} else {
|
|
215
|
-
obj[key] = value;
|
|
72
|
+
static games() {
|
|
73
|
+
return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Games).name("Game Settings").description("Modify where your games are stored and related settings").avatar("gamepad").metadata(romulatorClient.ZRomulatorConfigGamesMetadata.all()).build();
|
|
216
74
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
function _object_spread(target) {
|
|
220
|
-
for(var i = 1; i < arguments.length; i++){
|
|
221
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
222
|
-
var ownKeys = Object.keys(source);
|
|
223
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
224
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
225
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
226
|
-
}));
|
|
227
|
-
}
|
|
228
|
-
ownKeys.forEach(function(key) {
|
|
229
|
-
_define_property$3(target, key, source[key]);
|
|
230
|
-
});
|
|
75
|
+
static media() {
|
|
76
|
+
return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Media).name("Media Settings").description("Modify where media is stored and what media to retrieve").avatar("image").metadata(romulatorClient.ZRomulatorConfigMediaMetadata.all()).build();
|
|
231
77
|
}
|
|
232
|
-
return target;
|
|
233
78
|
}
|
|
234
|
-
|
|
79
|
+
|
|
80
|
+
function _ts_decorate$a(decorators, target, key, desc) {
|
|
235
81
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
236
82
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
237
83
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
238
84
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
239
85
|
}
|
|
240
|
-
function
|
|
241
|
-
var f, y, t, _ = {
|
|
242
|
-
label: 0,
|
|
243
|
-
sent: function() {
|
|
244
|
-
if (t[0] & 1) throw t[1];
|
|
245
|
-
return t[1];
|
|
246
|
-
},
|
|
247
|
-
trys: [],
|
|
248
|
-
ops: []
|
|
249
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
250
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
251
|
-
return this;
|
|
252
|
-
}), g;
|
|
253
|
-
function verb(n) {
|
|
254
|
-
return function(v) {
|
|
255
|
-
return step([
|
|
256
|
-
n,
|
|
257
|
-
v
|
|
258
|
-
]);
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
function step(op) {
|
|
262
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
263
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
264
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
265
|
-
if (y = 0, t) op = [
|
|
266
|
-
op[0] & 2,
|
|
267
|
-
t.value
|
|
268
|
-
];
|
|
269
|
-
switch(op[0]){
|
|
270
|
-
case 0:
|
|
271
|
-
case 1:
|
|
272
|
-
t = op;
|
|
273
|
-
break;
|
|
274
|
-
case 4:
|
|
275
|
-
_.label++;
|
|
276
|
-
return {
|
|
277
|
-
value: op[1],
|
|
278
|
-
done: false
|
|
279
|
-
};
|
|
280
|
-
case 5:
|
|
281
|
-
_.label++;
|
|
282
|
-
y = op[1];
|
|
283
|
-
op = [
|
|
284
|
-
0
|
|
285
|
-
];
|
|
286
|
-
continue;
|
|
287
|
-
case 7:
|
|
288
|
-
op = _.ops.pop();
|
|
289
|
-
_.trys.pop();
|
|
290
|
-
continue;
|
|
291
|
-
default:
|
|
292
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
293
|
-
_ = 0;
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
297
|
-
_.label = op[1];
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
301
|
-
_.label = t[1];
|
|
302
|
-
t = op;
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
if (t && _.label < t[2]) {
|
|
306
|
-
_.label = t[2];
|
|
307
|
-
_.ops.push(op);
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
if (t[2]) _.ops.pop();
|
|
311
|
-
_.trys.pop();
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
op = body.call(thisArg, _);
|
|
315
|
-
} catch (e) {
|
|
316
|
-
op = [
|
|
317
|
-
6,
|
|
318
|
-
e
|
|
319
|
-
];
|
|
320
|
-
y = 0;
|
|
321
|
-
} finally{
|
|
322
|
-
f = t = 0;
|
|
323
|
-
}
|
|
324
|
-
if (op[0] & 5) throw op[1];
|
|
325
|
-
return {
|
|
326
|
-
value: op[0] ? op[1] : void 0,
|
|
327
|
-
done: true
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function _ts_metadata$4(k, v) {
|
|
86
|
+
function _ts_metadata$6(k, v) {
|
|
332
87
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
333
88
|
}
|
|
334
|
-
function _ts_param$
|
|
89
|
+
function _ts_param$5(paramIndex, decorator) {
|
|
335
90
|
return function(target, key) {
|
|
336
91
|
decorator(target, key, paramIndex);
|
|
337
92
|
};
|
|
338
93
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
_define_property$3(this, "_logger", void 0);
|
|
94
|
+
const ZRomulatorConfigsToken = Symbol("configs");
|
|
95
|
+
class ZRomulatorConfigsService {
|
|
96
|
+
_logger;
|
|
97
|
+
constructor(_logger){
|
|
344
98
|
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorConfigsService", _logger);
|
|
345
99
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
4,
|
|
412
|
-
promises.readFile(config.file)
|
|
413
|
-
];
|
|
414
|
-
case 3:
|
|
415
|
-
buffer = _state.sent();
|
|
416
|
-
json = buffer.toString("utf-8");
|
|
417
|
-
contents = JSON.parse(json);
|
|
418
|
-
msg = "Finished reading config contents (".concat(buffer.byteLength, " bytes)");
|
|
419
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
420
|
-
return [
|
|
421
|
-
3,
|
|
422
|
-
5
|
|
423
|
-
];
|
|
424
|
-
case 4:
|
|
425
|
-
e = _state.sent();
|
|
426
|
-
msg = helpfulFn.createError(e).message;
|
|
427
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().warning().message(msg).build());
|
|
428
|
-
return [
|
|
429
|
-
3,
|
|
430
|
-
5
|
|
431
|
-
];
|
|
432
|
-
case 5:
|
|
433
|
-
result = new romulatorClient.ZRomulatorConfigBuilder().copy(config).contents(contents).build();
|
|
434
|
-
return [
|
|
435
|
-
2,
|
|
436
|
-
Promise.resolve(result)
|
|
437
|
-
];
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}).call(this);
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
key: "update",
|
|
445
|
-
value: function update(id, record) {
|
|
446
|
-
return _async_to_generator$3(function() {
|
|
447
|
-
var config, msg, next, json, e, error;
|
|
448
|
-
return _ts_generator$3(this, function(_state) {
|
|
449
|
-
switch(_state.label){
|
|
450
|
-
case 0:
|
|
451
|
-
return [
|
|
452
|
-
4,
|
|
453
|
-
this.get(id)
|
|
454
|
-
];
|
|
455
|
-
case 1:
|
|
456
|
-
config = _state.sent();
|
|
457
|
-
msg = "Updating config file, ".concat(id);
|
|
458
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
459
|
-
next = _object_spread({}, config.contents, record.contents);
|
|
460
|
-
json = JSON.stringify(next);
|
|
461
|
-
_state.label = 2;
|
|
462
|
-
case 2:
|
|
463
|
-
_state.trys.push([
|
|
464
|
-
2,
|
|
465
|
-
5,
|
|
466
|
-
,
|
|
467
|
-
6
|
|
468
|
-
]);
|
|
469
|
-
return [
|
|
470
|
-
4,
|
|
471
|
-
promises.mkdir(node_path.dirname(config.file), {
|
|
472
|
-
recursive: true
|
|
473
|
-
})
|
|
474
|
-
];
|
|
475
|
-
case 3:
|
|
476
|
-
_state.sent();
|
|
477
|
-
return [
|
|
478
|
-
4,
|
|
479
|
-
promises.writeFile(config.file, json)
|
|
480
|
-
];
|
|
481
|
-
case 4:
|
|
482
|
-
_state.sent();
|
|
483
|
-
return [
|
|
484
|
-
2,
|
|
485
|
-
new romulatorClient.ZRomulatorConfigBuilder().copy(config).contents(next).build()
|
|
486
|
-
];
|
|
487
|
-
case 5:
|
|
488
|
-
e = _state.sent();
|
|
489
|
-
error = helpfulFn.createError(e);
|
|
490
|
-
msg = "Unable to write to, ".concat(config.file);
|
|
491
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
492
|
-
msg = error.message;
|
|
493
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
494
|
-
return [
|
|
495
|
-
2,
|
|
496
|
-
Promise.reject(new common.InternalServerErrorException(error))
|
|
497
|
-
];
|
|
498
|
-
case 6:
|
|
499
|
-
return [
|
|
500
|
-
2
|
|
501
|
-
];
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
}).call(this);
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
key: "_find",
|
|
509
|
-
value: function _find(id) {
|
|
510
|
-
return _async_to_generator$3(function() {
|
|
511
|
-
var msg, configs, config;
|
|
512
|
-
return _ts_generator$3(this, function(_state) {
|
|
513
|
-
msg = "Attempting to retrieve config, ".concat(id);
|
|
514
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
515
|
-
configs = ZRomulatorConfigKnown.all();
|
|
516
|
-
config = lodashEs.find(configs, function(c) {
|
|
517
|
-
return c.id === id;
|
|
518
|
-
});
|
|
519
|
-
if (config == null) {
|
|
520
|
-
msg = "Could not find config, ".concat(id);
|
|
521
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
522
|
-
return [
|
|
523
|
-
2,
|
|
524
|
-
Promise.reject(new common.NotFoundException(msg))
|
|
525
|
-
];
|
|
526
|
-
}
|
|
527
|
-
msg = "Config, ".concat(id, ", found");
|
|
528
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
529
|
-
return [
|
|
530
|
-
2,
|
|
531
|
-
config
|
|
532
|
-
];
|
|
533
|
-
});
|
|
534
|
-
}).call(this);
|
|
535
|
-
}
|
|
100
|
+
async list(req) {
|
|
101
|
+
const page = helpfulFn.firstDefined(1, req.page);
|
|
102
|
+
const size = helpfulFn.firstDefined(Infinity, req.size);
|
|
103
|
+
let msg = `Retrieving configs page, ${page}, with size, ${size}`;
|
|
104
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
105
|
+
const configs = ZRomulatorConfigKnown.all();
|
|
106
|
+
const options = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields()).build();
|
|
107
|
+
const source = new helpfulQuery.ZDataSourceStatic(configs, options);
|
|
108
|
+
const data = await source.retrieve(req);
|
|
109
|
+
const count = await source.count(req);
|
|
110
|
+
msg = `Responding with ${data.length} configs out of ${count} total`;
|
|
111
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
112
|
+
return new helpfulQuery.ZPageBuilder().data(data).count(count).build();
|
|
113
|
+
}
|
|
114
|
+
async get(id) {
|
|
115
|
+
const config = await this._find(id);
|
|
116
|
+
let msg = `Attempting to read the file contents for config, ${id}.`;
|
|
117
|
+
let contents = {};
|
|
118
|
+
try {
|
|
119
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
120
|
+
const buffer = await promises.readFile(config.file);
|
|
121
|
+
const json = buffer.toString("utf-8");
|
|
122
|
+
contents = JSON.parse(json);
|
|
123
|
+
msg = `Finished reading config contents (${buffer.byteLength} bytes)`;
|
|
124
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
125
|
+
} catch (e) {
|
|
126
|
+
msg = helpfulFn.createError(e).message;
|
|
127
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().warning().message(msg).build());
|
|
128
|
+
}
|
|
129
|
+
const result = new romulatorClient.ZRomulatorConfigBuilder().copy(config).contents(contents).build();
|
|
130
|
+
return Promise.resolve(result);
|
|
131
|
+
}
|
|
132
|
+
async update(id, record) {
|
|
133
|
+
const config = await this.get(id);
|
|
134
|
+
let msg = `Updating config file, ${id}`;
|
|
135
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
136
|
+
const next = {
|
|
137
|
+
...config.contents,
|
|
138
|
+
...record.contents
|
|
139
|
+
};
|
|
140
|
+
const json = JSON.stringify(next);
|
|
141
|
+
try {
|
|
142
|
+
await promises.mkdir(node_path.dirname(config.file), {
|
|
143
|
+
recursive: true
|
|
144
|
+
});
|
|
145
|
+
await promises.writeFile(config.file, json);
|
|
146
|
+
return new romulatorClient.ZRomulatorConfigBuilder().copy(config).contents(next).build();
|
|
147
|
+
} catch (e) {
|
|
148
|
+
const error = helpfulFn.createError(e);
|
|
149
|
+
msg = `Unable to write to, ${config.file}`;
|
|
150
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
151
|
+
msg = error.message;
|
|
152
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
153
|
+
return Promise.reject(new common.InternalServerErrorException(error));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async _find(id) {
|
|
157
|
+
let msg = `Attempting to retrieve config, ${id}`;
|
|
158
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
159
|
+
const configs = ZRomulatorConfigKnown.all();
|
|
160
|
+
const config = lodashEs.find(configs, (c)=>c.id === id);
|
|
161
|
+
if (config == null) {
|
|
162
|
+
msg = `Could not find config, ${id}`;
|
|
163
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
164
|
+
return Promise.reject(new common.NotFoundException(msg));
|
|
536
165
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
166
|
+
msg = `Config, ${id}, found`;
|
|
167
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
168
|
+
return config;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
ZRomulatorConfigsService = _ts_decorate$a([
|
|
541
172
|
common.Injectable(),
|
|
542
|
-
_ts_param$
|
|
543
|
-
_ts_metadata$
|
|
544
|
-
_ts_metadata$
|
|
173
|
+
_ts_param$5(0, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
174
|
+
_ts_metadata$6("design:type", Function),
|
|
175
|
+
_ts_metadata$6("design:paramtypes", [
|
|
545
176
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
546
177
|
])
|
|
547
178
|
], ZRomulatorConfigsService);
|
|
548
179
|
|
|
549
|
-
function
|
|
550
|
-
try {
|
|
551
|
-
var info = gen[key](arg);
|
|
552
|
-
var value = info.value;
|
|
553
|
-
} catch (error) {
|
|
554
|
-
reject(error);
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
if (info.done) {
|
|
558
|
-
resolve(value);
|
|
559
|
-
} else {
|
|
560
|
-
Promise.resolve(value).then(_next, _throw);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
function _async_to_generator$2(fn) {
|
|
564
|
-
return function() {
|
|
565
|
-
var self = this, args = arguments;
|
|
566
|
-
return new Promise(function(resolve, reject) {
|
|
567
|
-
var gen = fn.apply(self, args);
|
|
568
|
-
function _next(value) {
|
|
569
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
570
|
-
}
|
|
571
|
-
function _throw(err) {
|
|
572
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
573
|
-
}
|
|
574
|
-
_next(undefined);
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
function _class_call_check$6(instance, Constructor) {
|
|
579
|
-
if (!(instance instanceof Constructor)) {
|
|
580
|
-
throw new TypeError("Cannot call a class as a function");
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
function _defineProperties$3(target, props) {
|
|
584
|
-
for(var i = 0; i < props.length; i++){
|
|
585
|
-
var descriptor = props[i];
|
|
586
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
587
|
-
descriptor.configurable = true;
|
|
588
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
589
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function _create_class$3(Constructor, protoProps, staticProps) {
|
|
593
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
594
|
-
return Constructor;
|
|
595
|
-
}
|
|
596
|
-
function _define_property$2(obj, key, value) {
|
|
597
|
-
if (key in obj) {
|
|
598
|
-
Object.defineProperty(obj, key, {
|
|
599
|
-
value: value,
|
|
600
|
-
enumerable: true,
|
|
601
|
-
configurable: true,
|
|
602
|
-
writable: true
|
|
603
|
-
});
|
|
604
|
-
} else {
|
|
605
|
-
obj[key] = value;
|
|
606
|
-
}
|
|
607
|
-
return obj;
|
|
608
|
-
}
|
|
609
|
-
function _ts_decorate$6(decorators, target, key, desc) {
|
|
180
|
+
function _ts_decorate$9(decorators, target, key, desc) {
|
|
610
181
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
611
182
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
612
183
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
613
184
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
614
185
|
}
|
|
615
|
-
function
|
|
616
|
-
var f, y, t, _ = {
|
|
617
|
-
label: 0,
|
|
618
|
-
sent: function() {
|
|
619
|
-
if (t[0] & 1) throw t[1];
|
|
620
|
-
return t[1];
|
|
621
|
-
},
|
|
622
|
-
trys: [],
|
|
623
|
-
ops: []
|
|
624
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
625
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
626
|
-
return this;
|
|
627
|
-
}), g;
|
|
628
|
-
function verb(n) {
|
|
629
|
-
return function(v) {
|
|
630
|
-
return step([
|
|
631
|
-
n,
|
|
632
|
-
v
|
|
633
|
-
]);
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
function step(op) {
|
|
637
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
638
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
639
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
640
|
-
if (y = 0, t) op = [
|
|
641
|
-
op[0] & 2,
|
|
642
|
-
t.value
|
|
643
|
-
];
|
|
644
|
-
switch(op[0]){
|
|
645
|
-
case 0:
|
|
646
|
-
case 1:
|
|
647
|
-
t = op;
|
|
648
|
-
break;
|
|
649
|
-
case 4:
|
|
650
|
-
_.label++;
|
|
651
|
-
return {
|
|
652
|
-
value: op[1],
|
|
653
|
-
done: false
|
|
654
|
-
};
|
|
655
|
-
case 5:
|
|
656
|
-
_.label++;
|
|
657
|
-
y = op[1];
|
|
658
|
-
op = [
|
|
659
|
-
0
|
|
660
|
-
];
|
|
661
|
-
continue;
|
|
662
|
-
case 7:
|
|
663
|
-
op = _.ops.pop();
|
|
664
|
-
_.trys.pop();
|
|
665
|
-
continue;
|
|
666
|
-
default:
|
|
667
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
668
|
-
_ = 0;
|
|
669
|
-
continue;
|
|
670
|
-
}
|
|
671
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
672
|
-
_.label = op[1];
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
676
|
-
_.label = t[1];
|
|
677
|
-
t = op;
|
|
678
|
-
break;
|
|
679
|
-
}
|
|
680
|
-
if (t && _.label < t[2]) {
|
|
681
|
-
_.label = t[2];
|
|
682
|
-
_.ops.push(op);
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
685
|
-
if (t[2]) _.ops.pop();
|
|
686
|
-
_.trys.pop();
|
|
687
|
-
continue;
|
|
688
|
-
}
|
|
689
|
-
op = body.call(thisArg, _);
|
|
690
|
-
} catch (e) {
|
|
691
|
-
op = [
|
|
692
|
-
6,
|
|
693
|
-
e
|
|
694
|
-
];
|
|
695
|
-
y = 0;
|
|
696
|
-
} finally{
|
|
697
|
-
f = t = 0;
|
|
698
|
-
}
|
|
699
|
-
if (op[0] & 5) throw op[1];
|
|
700
|
-
return {
|
|
701
|
-
value: op[0] ? op[1] : void 0,
|
|
702
|
-
done: true
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
function _ts_metadata$3(k, v) {
|
|
186
|
+
function _ts_metadata$5(k, v) {
|
|
707
187
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
708
188
|
}
|
|
709
|
-
function _ts_param$
|
|
189
|
+
function _ts_param$4(paramIndex, decorator) {
|
|
710
190
|
return function(target, key) {
|
|
711
191
|
decorator(target, key, paramIndex);
|
|
712
192
|
};
|
|
713
193
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
_define_property$2(this, "_configs", void 0);
|
|
194
|
+
class ZRomulatorConfigsController {
|
|
195
|
+
_configs;
|
|
196
|
+
constructor(_configs){
|
|
718
197
|
this._configs = _configs;
|
|
719
198
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
});
|
|
733
|
-
}).call(this);
|
|
734
|
-
}
|
|
735
|
-
},
|
|
736
|
-
{
|
|
737
|
-
key: "update",
|
|
738
|
-
value: function update(identification, payload) {
|
|
739
|
-
return _async_to_generator$2(function() {
|
|
740
|
-
return _ts_generator$2(this, function(_state) {
|
|
741
|
-
return [
|
|
742
|
-
2,
|
|
743
|
-
this._configs.update(identification, payload)
|
|
744
|
-
];
|
|
745
|
-
});
|
|
746
|
-
}).call(this);
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
|
-
{
|
|
750
|
-
key: "get",
|
|
751
|
-
value: function get(identification) {
|
|
752
|
-
return _async_to_generator$2(function() {
|
|
753
|
-
return _ts_generator$2(this, function(_state) {
|
|
754
|
-
switch(_state.label){
|
|
755
|
-
case 0:
|
|
756
|
-
return [
|
|
757
|
-
4,
|
|
758
|
-
this._configs.get(identification)
|
|
759
|
-
];
|
|
760
|
-
case 1:
|
|
761
|
-
return [
|
|
762
|
-
2,
|
|
763
|
-
_state.sent()
|
|
764
|
-
];
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
}).call(this);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
]);
|
|
771
|
-
return ZRomulatorConfigsController;
|
|
772
|
-
}();
|
|
773
|
-
_ts_decorate$6([
|
|
199
|
+
async list(query) {
|
|
200
|
+
const request = new helpfulQuery.ZDataRequestBuilder().query(query).build();
|
|
201
|
+
return this._configs.list(request);
|
|
202
|
+
}
|
|
203
|
+
async update(identification, payload) {
|
|
204
|
+
return this._configs.update(identification, payload);
|
|
205
|
+
}
|
|
206
|
+
async get(identification) {
|
|
207
|
+
return await this._configs.get(identification);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
_ts_decorate$9([
|
|
774
211
|
common.Get(),
|
|
775
|
-
_ts_param$
|
|
776
|
-
_ts_metadata$
|
|
777
|
-
_ts_metadata$
|
|
212
|
+
_ts_param$4(0, common.Query()),
|
|
213
|
+
_ts_metadata$5("design:type", Function),
|
|
214
|
+
_ts_metadata$5("design:paramtypes", [
|
|
778
215
|
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
779
216
|
]),
|
|
780
|
-
_ts_metadata$
|
|
217
|
+
_ts_metadata$5("design:returntype", Promise)
|
|
781
218
|
], ZRomulatorConfigsController.prototype, "list", null);
|
|
782
|
-
_ts_decorate$
|
|
219
|
+
_ts_decorate$9([
|
|
783
220
|
swagger.ApiParam({
|
|
784
221
|
type: "string",
|
|
785
222
|
name: "identification",
|
|
@@ -796,53 +233,47 @@ _ts_decorate$6([
|
|
|
796
233
|
skipNullProperties: false,
|
|
797
234
|
skipUndefinedProperties: false
|
|
798
235
|
})),
|
|
799
|
-
_ts_param$
|
|
800
|
-
_ts_param$
|
|
801
|
-
_ts_metadata$
|
|
802
|
-
_ts_metadata$
|
|
236
|
+
_ts_param$4(0, common.Param("identification")),
|
|
237
|
+
_ts_param$4(1, common.Body()),
|
|
238
|
+
_ts_metadata$5("design:type", Function),
|
|
239
|
+
_ts_metadata$5("design:paramtypes", [
|
|
803
240
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
|
|
804
241
|
typeof ZRomulatorConfigUpdateDto === "undefined" ? Object : ZRomulatorConfigUpdateDto
|
|
805
242
|
]),
|
|
806
|
-
_ts_metadata$
|
|
243
|
+
_ts_metadata$5("design:returntype", Promise)
|
|
807
244
|
], ZRomulatorConfigsController.prototype, "update", null);
|
|
808
|
-
_ts_decorate$
|
|
245
|
+
_ts_decorate$9([
|
|
809
246
|
swagger.ApiParam({
|
|
810
247
|
type: "string",
|
|
811
248
|
name: "identification",
|
|
812
249
|
description: "The id of the config"
|
|
813
250
|
}),
|
|
814
251
|
common.Get(":identification"),
|
|
815
|
-
_ts_param$
|
|
816
|
-
_ts_metadata$
|
|
817
|
-
_ts_metadata$
|
|
252
|
+
_ts_param$4(0, common.Param("identification")),
|
|
253
|
+
_ts_metadata$5("design:type", Function),
|
|
254
|
+
_ts_metadata$5("design:paramtypes", [
|
|
818
255
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
|
|
819
256
|
]),
|
|
820
|
-
_ts_metadata$
|
|
257
|
+
_ts_metadata$5("design:returntype", Promise)
|
|
821
258
|
], ZRomulatorConfigsController.prototype, "get", null);
|
|
822
|
-
ZRomulatorConfigsController = _ts_decorate$
|
|
259
|
+
ZRomulatorConfigsController = _ts_decorate$9([
|
|
823
260
|
common.Controller("configs"),
|
|
824
|
-
_ts_param$
|
|
825
|
-
_ts_metadata$
|
|
826
|
-
_ts_metadata$
|
|
261
|
+
_ts_param$4(0, common.Inject(ZRomulatorConfigsToken)),
|
|
262
|
+
_ts_metadata$5("design:type", Function),
|
|
263
|
+
_ts_metadata$5("design:paramtypes", [
|
|
827
264
|
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
|
|
828
265
|
])
|
|
829
266
|
], ZRomulatorConfigsController);
|
|
830
267
|
|
|
831
|
-
function
|
|
832
|
-
if (!(instance instanceof Constructor)) {
|
|
833
|
-
throw new TypeError("Cannot call a class as a function");
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
function _ts_decorate$5(decorators, target, key, desc) {
|
|
268
|
+
function _ts_decorate$8(decorators, target, key, desc) {
|
|
837
269
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
838
270
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
839
271
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
840
272
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
841
273
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
ZRomulatorConfigsModule = _ts_decorate$5([
|
|
274
|
+
class ZRomulatorConfigsModule {
|
|
275
|
+
}
|
|
276
|
+
ZRomulatorConfigsModule = _ts_decorate$8([
|
|
846
277
|
common.Module({
|
|
847
278
|
imports: [
|
|
848
279
|
crumbtrailNest.ZFileSystemModule,
|
|
@@ -863,137 +294,94 @@ ZRomulatorConfigsModule = _ts_decorate$5([
|
|
|
863
294
|
})
|
|
864
295
|
], ZRomulatorConfigsModule);
|
|
865
296
|
|
|
866
|
-
function
|
|
867
|
-
if (!(instance instanceof Constructor)) {
|
|
868
|
-
throw new TypeError("Cannot call a class as a function");
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
function _defineProperties$2(target, props) {
|
|
872
|
-
for(var i = 0; i < props.length; i++){
|
|
873
|
-
var descriptor = props[i];
|
|
874
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
875
|
-
descriptor.configurable = true;
|
|
876
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
877
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
function _create_class$2(Constructor, protoProps, staticProps) {
|
|
881
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
882
|
-
return Constructor;
|
|
883
|
-
}
|
|
884
|
-
function _ts_decorate$4(decorators, target, key, desc) {
|
|
297
|
+
function _ts_decorate$7(decorators, target, key, desc) {
|
|
885
298
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
886
299
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
887
300
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
888
301
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
889
302
|
}
|
|
890
|
-
function _ts_metadata$
|
|
303
|
+
function _ts_metadata$4(k, v) {
|
|
891
304
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
892
305
|
}
|
|
893
|
-
|
|
894
|
-
function KnownSystem() {
|
|
895
|
-
return function(_, __, descriptor) {
|
|
896
|
-
Reflect.defineMetadata(IS_SYSTEM, true, descriptor.value);
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
function isKnownSystem(target) {
|
|
900
|
-
return target != null && Reflect.getMetadata(IS_SYSTEM, target) === true;
|
|
901
|
-
}
|
|
306
|
+
const KnownSystem = "@zthunworks/romulator/known-system";
|
|
902
307
|
/**
|
|
903
308
|
* A helper factory class for creating supported systems.
|
|
904
|
-
*/
|
|
905
|
-
|
|
906
|
-
|
|
309
|
+
*/ class ZRomulatorSystemKnown {
|
|
310
|
+
/**
|
|
311
|
+
* Returns all known systems.
|
|
312
|
+
*
|
|
313
|
+
* @returns
|
|
314
|
+
* All supported systems.
|
|
315
|
+
*/ static all() {
|
|
316
|
+
const properties = Object.getOwnPropertyNames(ZRomulatorSystemKnown);
|
|
317
|
+
const methods = properties.filter((p)=>helpfulReflection.isTagged(KnownSystem, ZRomulatorSystemKnown, p)).map((p)=>ZRomulatorSystemKnown[p]).map((f)=>f);
|
|
318
|
+
return methods.map((m)=>m.call(null));
|
|
907
319
|
}
|
|
908
|
-
|
|
909
|
-
{
|
|
910
|
-
key: "nes",
|
|
911
|
-
value: /**
|
|
320
|
+
/**
|
|
912
321
|
* Creates a system that represents the Nintendo
|
|
913
322
|
* Entertainment System (NES).
|
|
914
323
|
*
|
|
915
324
|
* @returns
|
|
916
325
|
* A {@link ZRomulatorSystemBuilder} instance that has
|
|
917
326
|
* built the nes.
|
|
918
|
-
*/
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
{
|
|
923
|
-
key: "snes",
|
|
924
|
-
value: /**
|
|
327
|
+
*/ static nes() {
|
|
328
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).console().name("Nintendo Entertainment System").alias("Famicom").alias("NES").alias("Hyundai Comboy").alias("Samurai Electronic TV Game System").alias("Dendy").generation(3).manufacturer("Nintendo").build();
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
925
331
|
* Creates a system that represents the Super
|
|
926
332
|
* Nintendo Entertainment System (SNES).
|
|
927
333
|
*
|
|
928
334
|
* @returns
|
|
929
335
|
* This instance.
|
|
930
|
-
*/
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
{
|
|
935
|
-
key: "n64",
|
|
936
|
-
value: /**
|
|
336
|
+
*/ static snes() {
|
|
337
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).console().name("Super Nintendo Entertainment System").alias("Super Nintendo").alias("Super Famicom").alias("SNES").alias("Super NES").alias("Super Comboy").generation(4).manufacturer("Nintendo").build();
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
937
340
|
* Creates a system that represents the Nintendo
|
|
938
341
|
* 64 (N64).
|
|
939
342
|
*
|
|
940
343
|
* @returns
|
|
941
344
|
* This instance.
|
|
942
|
-
*/
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
{
|
|
947
|
-
key: "gc",
|
|
948
|
-
value: /**
|
|
345
|
+
*/ static n64() {
|
|
346
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).console().name("Nintendo 64").alias("N64").alias("Ultra 64").alias("Hyundai Comboy 64").generation(5).manufacturer("Nintendo").build();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
949
349
|
* Creates a system that represents the Nintendo
|
|
950
350
|
* GameCube (GC).
|
|
951
351
|
*
|
|
952
352
|
* @returns
|
|
953
353
|
* This instance.
|
|
954
|
-
*/
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
{
|
|
959
|
-
key: "wii",
|
|
960
|
-
value: /**
|
|
354
|
+
*/ static gc() {
|
|
355
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).console().name("Nintendo GameCube").alias("GameCube").alias("Dolphin").generation(6).manufacturer("Nintendo").manufacturer("Foxconn").build();
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
961
358
|
* Creates a system that represents the Nintendo
|
|
962
359
|
* Wii (Wii).
|
|
963
360
|
*
|
|
964
361
|
* @returns
|
|
965
362
|
* This instance.
|
|
966
|
-
*/
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
{
|
|
971
|
-
key: "wiiu",
|
|
972
|
-
value: /**
|
|
363
|
+
*/ static wii() {
|
|
364
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).console().name("Nintendo Wii").alias("Wii").alias("Revolution").generation(7).manufacturer("Foxconn").build();
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
973
367
|
* Creates a system that represents the Nintendo
|
|
974
368
|
* Wii U (WiiU).
|
|
975
369
|
*
|
|
976
370
|
* @returns
|
|
977
371
|
* This instance.
|
|
978
|
-
*/
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
{
|
|
983
|
-
key: "switch",
|
|
984
|
-
value: /**
|
|
372
|
+
*/ static wiiu() {
|
|
373
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).console().name("Nintendo Wii U").alias("WiiU").alias("Project Cafe").generation(8).manufacturer("Nintendo").manufacturer("Foxconn").manufacturer("Mitsumi").build();
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
985
376
|
* Creates a system that represents the Nintendo
|
|
986
377
|
* Switch (Switch).
|
|
987
378
|
*
|
|
988
379
|
* @returns
|
|
989
380
|
* This instance.
|
|
990
|
-
*/
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
{
|
|
995
|
-
key: "from",
|
|
996
|
-
value: /**
|
|
381
|
+
*/ static switch() {
|
|
382
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).console().name("Nintendo Switch").alias("Switch").alias("NX").alias("HAC").alias("Odin").generation(9).manufacturer("Foxconn").manufacturer("Hosiden").build();
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
997
385
|
* Creates a system from an id slug.
|
|
998
386
|
*
|
|
999
387
|
* @param id -
|
|
@@ -1001,216 +389,317 @@ function isKnownSystem(target) {
|
|
|
1001
389
|
*
|
|
1002
390
|
* @return
|
|
1003
391
|
* The system, or null if the id is not known.
|
|
1004
|
-
*/
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
return system();
|
|
1008
|
-
}
|
|
1009
|
-
return null;
|
|
1010
|
-
}
|
|
392
|
+
*/ static from(id) {
|
|
393
|
+
if (helpfulReflection.isTagged(KnownSystem, ZRomulatorSystemKnown, id)) {
|
|
394
|
+
return ZRomulatorSystemKnown[id]();
|
|
1011
395
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
_ts_decorate$
|
|
1016
|
-
KnownSystem
|
|
1017
|
-
_ts_metadata$
|
|
1018
|
-
_ts_metadata$
|
|
1019
|
-
_ts_metadata$
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
_ts_decorate$7([
|
|
400
|
+
helpfulReflection.ZTag(KnownSystem),
|
|
401
|
+
_ts_metadata$4("design:type", Function),
|
|
402
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
403
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1020
404
|
], ZRomulatorSystemKnown, "nes", null);
|
|
1021
|
-
_ts_decorate$
|
|
1022
|
-
KnownSystem
|
|
1023
|
-
_ts_metadata$
|
|
1024
|
-
_ts_metadata$
|
|
1025
|
-
_ts_metadata$
|
|
405
|
+
_ts_decorate$7([
|
|
406
|
+
helpfulReflection.ZTag(KnownSystem),
|
|
407
|
+
_ts_metadata$4("design:type", Function),
|
|
408
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
409
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1026
410
|
], ZRomulatorSystemKnown, "snes", null);
|
|
1027
|
-
_ts_decorate$
|
|
1028
|
-
KnownSystem
|
|
1029
|
-
_ts_metadata$
|
|
1030
|
-
_ts_metadata$
|
|
1031
|
-
_ts_metadata$
|
|
411
|
+
_ts_decorate$7([
|
|
412
|
+
helpfulReflection.ZTag(KnownSystem),
|
|
413
|
+
_ts_metadata$4("design:type", Function),
|
|
414
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
415
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1032
416
|
], ZRomulatorSystemKnown, "n64", null);
|
|
1033
|
-
_ts_decorate$
|
|
1034
|
-
KnownSystem
|
|
1035
|
-
_ts_metadata$
|
|
1036
|
-
_ts_metadata$
|
|
1037
|
-
_ts_metadata$
|
|
417
|
+
_ts_decorate$7([
|
|
418
|
+
helpfulReflection.ZTag(KnownSystem),
|
|
419
|
+
_ts_metadata$4("design:type", Function),
|
|
420
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
421
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1038
422
|
], ZRomulatorSystemKnown, "gc", null);
|
|
1039
|
-
_ts_decorate$
|
|
1040
|
-
KnownSystem
|
|
1041
|
-
_ts_metadata$
|
|
1042
|
-
_ts_metadata$
|
|
1043
|
-
_ts_metadata$
|
|
423
|
+
_ts_decorate$7([
|
|
424
|
+
helpfulReflection.ZTag(KnownSystem),
|
|
425
|
+
_ts_metadata$4("design:type", Function),
|
|
426
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
427
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1044
428
|
], ZRomulatorSystemKnown, "wii", null);
|
|
1045
|
-
_ts_decorate$
|
|
1046
|
-
KnownSystem
|
|
1047
|
-
_ts_metadata$
|
|
1048
|
-
_ts_metadata$
|
|
1049
|
-
_ts_metadata$
|
|
429
|
+
_ts_decorate$7([
|
|
430
|
+
helpfulReflection.ZTag(KnownSystem),
|
|
431
|
+
_ts_metadata$4("design:type", Function),
|
|
432
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
433
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1050
434
|
], ZRomulatorSystemKnown, "wiiu", null);
|
|
1051
|
-
_ts_decorate$
|
|
1052
|
-
KnownSystem
|
|
1053
|
-
_ts_metadata$
|
|
1054
|
-
_ts_metadata$
|
|
1055
|
-
_ts_metadata$
|
|
435
|
+
_ts_decorate$7([
|
|
436
|
+
helpfulReflection.ZTag(KnownSystem),
|
|
437
|
+
_ts_metadata$4("design:type", Function),
|
|
438
|
+
_ts_metadata$4("design:paramtypes", []),
|
|
439
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
1056
440
|
], ZRomulatorSystemKnown, "switch", null);
|
|
1057
441
|
|
|
1058
|
-
function
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
reject(error);
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
if (info.done) {
|
|
1067
|
-
resolve(value);
|
|
1068
|
-
} else {
|
|
1069
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1070
|
-
}
|
|
442
|
+
function _ts_decorate$6(decorators, target, key, desc) {
|
|
443
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
444
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
445
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
446
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1071
447
|
}
|
|
1072
|
-
function
|
|
1073
|
-
return
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1079
|
-
}
|
|
1080
|
-
function _throw(err) {
|
|
1081
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1082
|
-
}
|
|
1083
|
-
_next(undefined);
|
|
1084
|
-
});
|
|
448
|
+
function _ts_metadata$3(k, v) {
|
|
449
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
450
|
+
}
|
|
451
|
+
function _ts_param$3(paramIndex, decorator) {
|
|
452
|
+
return function(target, key) {
|
|
453
|
+
decorator(target, key, paramIndex);
|
|
1085
454
|
};
|
|
1086
455
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
456
|
+
const ZRomulatorMediaToken = Symbol("romulator-media-service");
|
|
457
|
+
class ZRomulatorMediaService {
|
|
458
|
+
_file;
|
|
459
|
+
_config;
|
|
460
|
+
_logger;
|
|
461
|
+
constructor(_file, _config, logger){
|
|
462
|
+
this._file = _file;
|
|
463
|
+
this._config = _config;
|
|
464
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorMediaService", logger);
|
|
465
|
+
}
|
|
466
|
+
async getMediaFolder() {
|
|
467
|
+
const mediaConfig = ZRomulatorConfigKnown.media();
|
|
468
|
+
const { contents } = await this._config.get(mediaConfig.id);
|
|
469
|
+
const { mediaFolder } = new romulatorClient.ZRomulatorConfigMediaBuilder().copy(contents).build();
|
|
470
|
+
return helpfulFn.detokenize(mediaFolder, node_process.env);
|
|
471
|
+
}
|
|
472
|
+
async findAllMedia(cwd) {
|
|
473
|
+
const systems = ZRomulatorSystemKnown.all().map((s)=>s.id).join(",");
|
|
474
|
+
const glob = `{${systems}}/**`;
|
|
475
|
+
const files = await this._file.search(glob, {
|
|
476
|
+
cwd,
|
|
477
|
+
stat: false
|
|
478
|
+
});
|
|
479
|
+
return files.map((f)=>new romulatorClient.ZRomulatorMediaBuilder().from(f.path).build()).filter((media)=>!!media.id);
|
|
480
|
+
}
|
|
481
|
+
async list(req) {
|
|
482
|
+
const cwd = await this.getMediaFolder();
|
|
483
|
+
let msg = `Reading all media from ${cwd}`;
|
|
484
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
485
|
+
const time = new Date();
|
|
486
|
+
const mediaList = await this.findAllMedia(cwd);
|
|
487
|
+
const span = new Date().getTime() - time.getTime();
|
|
488
|
+
msg = `Found ${mediaList.length} media files. Search took ${span} milliseconds`;
|
|
489
|
+
const options = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields()).build();
|
|
490
|
+
const source = new helpfulQuery.ZDataSourceStatic(mediaList, options);
|
|
491
|
+
const page = await source.retrieve(req);
|
|
492
|
+
const count = await source.count(req);
|
|
493
|
+
return new helpfulQuery.ZPageBuilder().data(page).count(count).build();
|
|
494
|
+
}
|
|
495
|
+
async get(id) {
|
|
496
|
+
const cwd = await this.getMediaFolder();
|
|
497
|
+
const time = new Date();
|
|
498
|
+
let log = `Searching for media with id ${id}.`;
|
|
499
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
500
|
+
const mediaList = await this.findAllMedia(cwd);
|
|
501
|
+
const index = lodashEs.findIndex(mediaList, (m)=>m.id === id);
|
|
502
|
+
const span = new Date().getTime() - time.getTime();
|
|
503
|
+
if (index < 0) {
|
|
504
|
+
const msg = `Could not find any media with id, ${id}.`;
|
|
505
|
+
log = `${msg} Search took ${span} milliseconds`;
|
|
506
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().warning().message(log).build());
|
|
507
|
+
throw new common.NotFoundException(msg);
|
|
508
|
+
}
|
|
509
|
+
const media = mediaList[index];
|
|
510
|
+
log = `Found media, ${media.url} after ${span} milliseconds`;
|
|
511
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
512
|
+
return media;
|
|
513
|
+
}
|
|
514
|
+
async download(id, accept) {
|
|
515
|
+
let log = `Download request received for ${id}`;
|
|
516
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
517
|
+
const fallback = webigailUrl.ZMimeTypeApplication.OctetStream;
|
|
518
|
+
const { fileName, url } = await this.get(id);
|
|
519
|
+
const lookupResult = mimeTypes.lookup(helpfulFn.firstDefined("", fileName));
|
|
520
|
+
const mime = helpfulFn.firstTruthy(fallback, lookupResult);
|
|
521
|
+
const accepts = accept.split(",").map((h)=>h.split(";")[0].trim());
|
|
522
|
+
const acceptable = accepts.some((a)=>{
|
|
523
|
+
if (a === "*/*") {
|
|
524
|
+
return true;
|
|
525
|
+
}
|
|
526
|
+
if (a.endsWith("/*")) {
|
|
527
|
+
return mime.startsWith(a.slice(0, -1));
|
|
528
|
+
}
|
|
529
|
+
return a === mime;
|
|
530
|
+
});
|
|
531
|
+
if (!acceptable) {
|
|
532
|
+
const msg = `The media requested is of type ${mime}. ` + `The request only accepts ${accept}.`;
|
|
533
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
534
|
+
throw new common.NotAcceptableException(msg);
|
|
535
|
+
}
|
|
536
|
+
log = `Streaming ${url}`;
|
|
537
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
538
|
+
return new common.StreamableFile(node_fs.createReadStream(helpfulFn.firstDefined("", url)), {
|
|
539
|
+
type: mime,
|
|
540
|
+
disposition: `inline; filename=${fileName}`
|
|
541
|
+
});
|
|
1090
542
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
543
|
+
async delete(id) {
|
|
544
|
+
const { url } = await this.get(id);
|
|
545
|
+
const _url = helpfulFn.firstDefined("", url);
|
|
546
|
+
let log = `Attempting to delete file ${_url}`;
|
|
547
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
548
|
+
try {
|
|
549
|
+
await promises.unlink(_url);
|
|
550
|
+
} catch (err) {
|
|
551
|
+
const { message } = helpfulFn.createError(err);
|
|
552
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(message).build());
|
|
553
|
+
throw new common.ForbiddenException(message);
|
|
554
|
+
}
|
|
555
|
+
log = `Deleted ${url}`;
|
|
556
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
1099
557
|
}
|
|
1100
558
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
559
|
+
ZRomulatorMediaService = _ts_decorate$6([
|
|
560
|
+
common.Injectable(),
|
|
561
|
+
_ts_param$3(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
|
|
562
|
+
_ts_param$3(1, common.Inject(ZRomulatorConfigsToken)),
|
|
563
|
+
_ts_param$3(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
564
|
+
_ts_metadata$3("design:type", Function),
|
|
565
|
+
_ts_metadata$3("design:paramtypes", [
|
|
566
|
+
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
|
|
567
|
+
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
568
|
+
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
569
|
+
])
|
|
570
|
+
], ZRomulatorMediaService);
|
|
571
|
+
|
|
572
|
+
function _ts_decorate$5(decorators, target, key, desc) {
|
|
573
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
574
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
575
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
576
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
577
|
+
}
|
|
578
|
+
function _ts_metadata$2(k, v) {
|
|
579
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
580
|
+
}
|
|
581
|
+
function _ts_param$2(paramIndex, decorator) {
|
|
582
|
+
return function(target, key) {
|
|
583
|
+
decorator(target, key, paramIndex);
|
|
584
|
+
};
|
|
1104
585
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
}
|
|
1114
|
-
|
|
586
|
+
class ZRomulatorMediaController {
|
|
587
|
+
_media;
|
|
588
|
+
constructor(_media){
|
|
589
|
+
this._media = _media;
|
|
590
|
+
}
|
|
591
|
+
list(params) {
|
|
592
|
+
const request = new helpfulQuery.ZDataRequestBuilder().query(params).build();
|
|
593
|
+
return this._media.list(request);
|
|
594
|
+
}
|
|
595
|
+
async get(identification, req) {
|
|
596
|
+
const { accept = "*/*" } = req.headers;
|
|
597
|
+
return accept.includes("application/json") ? this._media.get(identification) : this._media.download(identification, accept);
|
|
598
|
+
}
|
|
599
|
+
async delete(identification) {
|
|
600
|
+
await this._media.delete(identification);
|
|
1115
601
|
}
|
|
1116
|
-
return obj;
|
|
1117
602
|
}
|
|
1118
|
-
|
|
603
|
+
_ts_decorate$5([
|
|
604
|
+
common.Get(),
|
|
605
|
+
_ts_param$2(0, common.Query()),
|
|
606
|
+
_ts_metadata$2("design:type", Function),
|
|
607
|
+
_ts_metadata$2("design:paramtypes", [
|
|
608
|
+
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
609
|
+
]),
|
|
610
|
+
_ts_metadata$2("design:returntype", void 0)
|
|
611
|
+
], ZRomulatorMediaController.prototype, "list", null);
|
|
612
|
+
_ts_decorate$5([
|
|
613
|
+
swagger.ApiParam({
|
|
614
|
+
type: "string",
|
|
615
|
+
name: "identification",
|
|
616
|
+
description: "The id of the media"
|
|
617
|
+
}),
|
|
618
|
+
swagger.ApiResponse({
|
|
619
|
+
status: webigailHttp.ZHttpCodeSuccess.OK,
|
|
620
|
+
description: "Returns the media",
|
|
621
|
+
content: {
|
|
622
|
+
"*/*": {},
|
|
623
|
+
"image/*": {},
|
|
624
|
+
"image/png": {},
|
|
625
|
+
"image/jpeg": {},
|
|
626
|
+
"application/mp4": {},
|
|
627
|
+
"application/json": {}
|
|
628
|
+
}
|
|
629
|
+
}),
|
|
630
|
+
swagger.ApiResponse({
|
|
631
|
+
status: webigailHttp.ZHttpCodeClient.NotFound,
|
|
632
|
+
description: "Media not found"
|
|
633
|
+
}),
|
|
634
|
+
swagger.ApiResponse({
|
|
635
|
+
status: webigailHttp.ZHttpCodeClient.NotAcceptable,
|
|
636
|
+
description: "Unsupported Accept header"
|
|
637
|
+
}),
|
|
638
|
+
common.Get(":identification"),
|
|
639
|
+
_ts_param$2(0, common.Param("identification")),
|
|
640
|
+
_ts_param$2(1, common.Req()),
|
|
641
|
+
_ts_metadata$2("design:type", Function),
|
|
642
|
+
_ts_metadata$2("design:paramtypes", [
|
|
643
|
+
String,
|
|
644
|
+
typeof Request === "undefined" ? Object : Request
|
|
645
|
+
]),
|
|
646
|
+
_ts_metadata$2("design:returntype", Promise)
|
|
647
|
+
], ZRomulatorMediaController.prototype, "get", null);
|
|
648
|
+
_ts_decorate$5([
|
|
649
|
+
swagger.ApiParam({
|
|
650
|
+
type: "string",
|
|
651
|
+
name: "identification",
|
|
652
|
+
description: "The id of the media"
|
|
653
|
+
}),
|
|
654
|
+
common.Delete(":identification"),
|
|
655
|
+
_ts_param$2(0, common.Param("identification")),
|
|
656
|
+
_ts_metadata$2("design:type", Function),
|
|
657
|
+
_ts_metadata$2("design:paramtypes", [
|
|
658
|
+
String
|
|
659
|
+
]),
|
|
660
|
+
_ts_metadata$2("design:returntype", Promise)
|
|
661
|
+
], ZRomulatorMediaController.prototype, "delete", null);
|
|
662
|
+
ZRomulatorMediaController = _ts_decorate$5([
|
|
663
|
+
common.Controller("media"),
|
|
664
|
+
_ts_param$2(0, common.Inject(ZRomulatorMediaToken)),
|
|
665
|
+
_ts_metadata$2("design:type", Function),
|
|
666
|
+
_ts_metadata$2("design:paramtypes", [
|
|
667
|
+
typeof IZRomulatorMediaService === "undefined" ? Object : IZRomulatorMediaService
|
|
668
|
+
])
|
|
669
|
+
], ZRomulatorMediaController);
|
|
670
|
+
|
|
671
|
+
function _ts_decorate$4(decorators, target, key, desc) {
|
|
1119
672
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1120
673
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1121
674
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1122
675
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1123
676
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
n,
|
|
1141
|
-
v
|
|
1142
|
-
]);
|
|
1143
|
-
};
|
|
1144
|
-
}
|
|
1145
|
-
function step(op) {
|
|
1146
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1147
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1148
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1149
|
-
if (y = 0, t) op = [
|
|
1150
|
-
op[0] & 2,
|
|
1151
|
-
t.value
|
|
1152
|
-
];
|
|
1153
|
-
switch(op[0]){
|
|
1154
|
-
case 0:
|
|
1155
|
-
case 1:
|
|
1156
|
-
t = op;
|
|
1157
|
-
break;
|
|
1158
|
-
case 4:
|
|
1159
|
-
_.label++;
|
|
1160
|
-
return {
|
|
1161
|
-
value: op[1],
|
|
1162
|
-
done: false
|
|
1163
|
-
};
|
|
1164
|
-
case 5:
|
|
1165
|
-
_.label++;
|
|
1166
|
-
y = op[1];
|
|
1167
|
-
op = [
|
|
1168
|
-
0
|
|
1169
|
-
];
|
|
1170
|
-
continue;
|
|
1171
|
-
case 7:
|
|
1172
|
-
op = _.ops.pop();
|
|
1173
|
-
_.trys.pop();
|
|
1174
|
-
continue;
|
|
1175
|
-
default:
|
|
1176
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1177
|
-
_ = 0;
|
|
1178
|
-
continue;
|
|
1179
|
-
}
|
|
1180
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1181
|
-
_.label = op[1];
|
|
1182
|
-
break;
|
|
1183
|
-
}
|
|
1184
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1185
|
-
_.label = t[1];
|
|
1186
|
-
t = op;
|
|
1187
|
-
break;
|
|
1188
|
-
}
|
|
1189
|
-
if (t && _.label < t[2]) {
|
|
1190
|
-
_.label = t[2];
|
|
1191
|
-
_.ops.push(op);
|
|
1192
|
-
break;
|
|
1193
|
-
}
|
|
1194
|
-
if (t[2]) _.ops.pop();
|
|
1195
|
-
_.trys.pop();
|
|
1196
|
-
continue;
|
|
677
|
+
class ZRomulatorMediaModule {
|
|
678
|
+
}
|
|
679
|
+
ZRomulatorMediaModule = _ts_decorate$4([
|
|
680
|
+
common.Module({
|
|
681
|
+
imports: [
|
|
682
|
+
crumbtrailNest.ZFileSystemModule,
|
|
683
|
+
ZRomulatorConfigsModule,
|
|
684
|
+
lumberjackyNest.ZLoggerModule
|
|
685
|
+
],
|
|
686
|
+
controllers: [
|
|
687
|
+
ZRomulatorMediaController
|
|
688
|
+
],
|
|
689
|
+
providers: [
|
|
690
|
+
{
|
|
691
|
+
provide: ZRomulatorMediaToken,
|
|
692
|
+
useClass: ZRomulatorMediaService
|
|
1197
693
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
}
|
|
1208
|
-
if (op[0] & 5) throw op[1];
|
|
1209
|
-
return {
|
|
1210
|
-
value: op[0] ? op[1] : void 0,
|
|
1211
|
-
done: true
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
694
|
+
]
|
|
695
|
+
})
|
|
696
|
+
], ZRomulatorMediaModule);
|
|
697
|
+
|
|
698
|
+
function _ts_decorate$3(decorators, target, key, desc) {
|
|
699
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
700
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
701
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
702
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1214
703
|
}
|
|
1215
704
|
function _ts_metadata$1(k, v) {
|
|
1216
705
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
@@ -1220,125 +709,56 @@ function _ts_param$1(paramIndex, decorator) {
|
|
|
1220
709
|
decorator(target, key, paramIndex);
|
|
1221
710
|
};
|
|
1222
711
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
_define_property$1(this, "_logger", void 0);
|
|
712
|
+
const ZRomulatorSystemsToken = Symbol("romulator-systems-service");
|
|
713
|
+
class ZRomulatorSystemsService {
|
|
714
|
+
_file;
|
|
715
|
+
_configs;
|
|
716
|
+
logger;
|
|
717
|
+
_logger;
|
|
718
|
+
constructor(_file, _configs, logger){
|
|
1231
719
|
this._file = _file;
|
|
1232
720
|
this._configs = _configs;
|
|
1233
721
|
this.logger = logger;
|
|
1234
722
|
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorSystemsService", logger);
|
|
1235
723
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
systems = folders.map(function(folder) {
|
|
1271
|
-
return folder.path;
|
|
1272
|
-
}).map(function(path) {
|
|
1273
|
-
return node_path.basename(path);
|
|
1274
|
-
}).map(function(slug) {
|
|
1275
|
-
return ZRomulatorSystemKnown.from(slug);
|
|
1276
|
-
}).filter(function(system) {
|
|
1277
|
-
return system != null;
|
|
1278
|
-
}).map(function(system) {
|
|
1279
|
-
return system.build();
|
|
1280
|
-
});
|
|
1281
|
-
msg = "Found ".concat(systems.length, " systems");
|
|
1282
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
1283
|
-
sourceOptions = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields([
|
|
1284
|
-
"id",
|
|
1285
|
-
"name",
|
|
1286
|
-
"short"
|
|
1287
|
-
])).build();
|
|
1288
|
-
source = new helpfulQuery.ZDataSourceStatic(systems, sourceOptions);
|
|
1289
|
-
return [
|
|
1290
|
-
4,
|
|
1291
|
-
source.retrieve(req)
|
|
1292
|
-
];
|
|
1293
|
-
case 3:
|
|
1294
|
-
data = _state.sent();
|
|
1295
|
-
return [
|
|
1296
|
-
4,
|
|
1297
|
-
source.count(req)
|
|
1298
|
-
];
|
|
1299
|
-
case 4:
|
|
1300
|
-
count = _state.sent();
|
|
1301
|
-
return [
|
|
1302
|
-
2,
|
|
1303
|
-
new helpfulQuery.ZPageBuilder().data(data).count(count).build()
|
|
1304
|
-
];
|
|
1305
|
-
}
|
|
1306
|
-
});
|
|
1307
|
-
}).call(this);
|
|
1308
|
-
}
|
|
1309
|
-
},
|
|
1310
|
-
{
|
|
1311
|
-
key: "get",
|
|
1312
|
-
value: function get(id) {
|
|
1313
|
-
return _async_to_generator$1(function() {
|
|
1314
|
-
var all, system;
|
|
1315
|
-
return _ts_generator$1(this, function(_state) {
|
|
1316
|
-
switch(_state.label){
|
|
1317
|
-
case 0:
|
|
1318
|
-
return [
|
|
1319
|
-
4,
|
|
1320
|
-
this.list(new helpfulQuery.ZDataRequestBuilder().build())
|
|
1321
|
-
];
|
|
1322
|
-
case 1:
|
|
1323
|
-
all = _state.sent();
|
|
1324
|
-
system = lodashEs.find(all.data, function(system) {
|
|
1325
|
-
return system.id === id;
|
|
1326
|
-
});
|
|
1327
|
-
if (!system) {
|
|
1328
|
-
throw new common.NotFoundException("Unable to find system with id, ".concat(id, "."));
|
|
1329
|
-
}
|
|
1330
|
-
return [
|
|
1331
|
-
2,
|
|
1332
|
-
system
|
|
1333
|
-
];
|
|
1334
|
-
}
|
|
1335
|
-
});
|
|
1336
|
-
}).call(this);
|
|
1337
|
-
}
|
|
724
|
+
async list(req) {
|
|
725
|
+
const page = helpfulFn.firstDefined(1, req.page);
|
|
726
|
+
const size = helpfulFn.firstDefined(Infinity, req.size);
|
|
727
|
+
let msg = `Retrieving systems page, ${page}, with size, ${size}.`;
|
|
728
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
729
|
+
const { contents } = await this._configs.get(romulatorClient.ZRomulatorConfigId.Games);
|
|
730
|
+
const { gamesFolder } = contents;
|
|
731
|
+
const { fallback } = romulatorClient.ZRomulatorConfigGamesMetadata.gamesFolder();
|
|
732
|
+
const _folder = helpfulFn.firstDefined(fallback, gamesFolder);
|
|
733
|
+
const cwd = helpfulFn.detokenize(_folder, process.env);
|
|
734
|
+
msg = `Looking for systems in ${cwd}`;
|
|
735
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
736
|
+
const searchOptions = {
|
|
737
|
+
cwd
|
|
738
|
+
};
|
|
739
|
+
const folders = await this._file.search("*/", searchOptions);
|
|
740
|
+
const systems = folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).map((slug)=>ZRomulatorSystemKnown.from(slug)).filter((system)=>system != null);
|
|
741
|
+
msg = `Found ${systems.length} systems`;
|
|
742
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
743
|
+
const sourceOptions = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields([
|
|
744
|
+
"id",
|
|
745
|
+
"name",
|
|
746
|
+
"short"
|
|
747
|
+
])).build();
|
|
748
|
+
const source = new helpfulQuery.ZDataSourceStatic(systems, sourceOptions);
|
|
749
|
+
const data = await source.retrieve(req);
|
|
750
|
+
const count = await source.count(req);
|
|
751
|
+
return new helpfulQuery.ZPageBuilder().data(data).count(count).build();
|
|
752
|
+
}
|
|
753
|
+
async get(id) {
|
|
754
|
+
const all = await this.list(new helpfulQuery.ZDataRequestBuilder().build());
|
|
755
|
+
const system = lodashEs.find(all.data, (system)=>system.id === id);
|
|
756
|
+
if (!system) {
|
|
757
|
+
throw new common.NotFoundException(`Unable to find system with id, ${id}.`);
|
|
1338
758
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
}
|
|
759
|
+
return system;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
1342
762
|
ZRomulatorSystemsService = _ts_decorate$3([
|
|
1343
763
|
common.Injectable(),
|
|
1344
764
|
_ts_param$1(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
|
|
@@ -1352,37 +772,6 @@ ZRomulatorSystemsService = _ts_decorate$3([
|
|
|
1352
772
|
])
|
|
1353
773
|
], ZRomulatorSystemsService);
|
|
1354
774
|
|
|
1355
|
-
function _class_call_check$2(instance, Constructor) {
|
|
1356
|
-
if (!(instance instanceof Constructor)) {
|
|
1357
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
function _defineProperties(target, props) {
|
|
1361
|
-
for(var i = 0; i < props.length; i++){
|
|
1362
|
-
var descriptor = props[i];
|
|
1363
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1364
|
-
descriptor.configurable = true;
|
|
1365
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1366
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
1370
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
1371
|
-
return Constructor;
|
|
1372
|
-
}
|
|
1373
|
-
function _define_property(obj, key, value) {
|
|
1374
|
-
if (key in obj) {
|
|
1375
|
-
Object.defineProperty(obj, key, {
|
|
1376
|
-
value: value,
|
|
1377
|
-
enumerable: true,
|
|
1378
|
-
configurable: true,
|
|
1379
|
-
writable: true
|
|
1380
|
-
});
|
|
1381
|
-
} else {
|
|
1382
|
-
obj[key] = value;
|
|
1383
|
-
}
|
|
1384
|
-
return obj;
|
|
1385
|
-
}
|
|
1386
775
|
function _ts_decorate$2(decorators, target, key, desc) {
|
|
1387
776
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1388
777
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1397,28 +786,18 @@ function _ts_param(paramIndex, decorator) {
|
|
|
1397
786
|
decorator(target, key, paramIndex);
|
|
1398
787
|
};
|
|
1399
788
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
_define_property(this, "_systems", void 0);
|
|
789
|
+
class ZRomulatorSystemsController {
|
|
790
|
+
_systems;
|
|
791
|
+
constructor(_systems){
|
|
1404
792
|
this._systems = _systems;
|
|
1405
793
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
{
|
|
1414
|
-
key: "get",
|
|
1415
|
-
value: function get(identification) {
|
|
1416
|
-
return this._systems.get(identification);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
]);
|
|
1420
|
-
return ZRomulatorSystemsController;
|
|
1421
|
-
}();
|
|
794
|
+
list(query) {
|
|
795
|
+
return this._systems.list(new helpfulQuery.ZDataRequestBuilder().query(query).build());
|
|
796
|
+
}
|
|
797
|
+
get(identification) {
|
|
798
|
+
return this._systems.get(identification);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
1422
801
|
_ts_decorate$2([
|
|
1423
802
|
common.Get(),
|
|
1424
803
|
_ts_param(0, common.Query()),
|
|
@@ -1430,7 +809,7 @@ _ts_decorate$2([
|
|
|
1430
809
|
], ZRomulatorSystemsController.prototype, "list", null);
|
|
1431
810
|
_ts_decorate$2([
|
|
1432
811
|
swagger.ApiParam({
|
|
1433
|
-
type: "string
|
|
812
|
+
type: "string",
|
|
1434
813
|
name: "identification",
|
|
1435
814
|
description: "The id of the system"
|
|
1436
815
|
}),
|
|
@@ -1451,20 +830,14 @@ ZRomulatorSystemsController = _ts_decorate$2([
|
|
|
1451
830
|
])
|
|
1452
831
|
], ZRomulatorSystemsController);
|
|
1453
832
|
|
|
1454
|
-
function _class_call_check$1(instance, Constructor) {
|
|
1455
|
-
if (!(instance instanceof Constructor)) {
|
|
1456
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
833
|
function _ts_decorate$1(decorators, target, key, desc) {
|
|
1460
834
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1461
835
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1462
836
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1463
837
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1464
838
|
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
};
|
|
839
|
+
class ZRomulatorSystemsModule {
|
|
840
|
+
}
|
|
1468
841
|
ZRomulatorSystemsModule = _ts_decorate$1([
|
|
1469
842
|
common.Module({
|
|
1470
843
|
imports: [
|
|
@@ -1484,180 +857,32 @@ ZRomulatorSystemsModule = _ts_decorate$1([
|
|
|
1484
857
|
})
|
|
1485
858
|
], ZRomulatorSystemsModule);
|
|
1486
859
|
|
|
1487
|
-
/* istanbul ignore file -- @preserve */ function
|
|
1488
|
-
if (!(instance instanceof Constructor)) {
|
|
1489
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
860
|
+
/* istanbul ignore file -- @preserve */ function _ts_decorate(decorators, target, key, desc) {
|
|
1493
861
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1494
862
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1495
863
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1496
864
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1497
865
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
};
|
|
866
|
+
class ZRomulatorModule {
|
|
867
|
+
}
|
|
1501
868
|
ZRomulatorModule = _ts_decorate([
|
|
1502
869
|
common.Module({
|
|
1503
870
|
imports: [
|
|
1504
871
|
ZRomulatorSystemsModule,
|
|
1505
|
-
ZRomulatorConfigsModule
|
|
872
|
+
ZRomulatorConfigsModule,
|
|
873
|
+
ZRomulatorMediaModule
|
|
1506
874
|
]
|
|
1507
875
|
})
|
|
1508
876
|
], ZRomulatorModule);
|
|
1509
877
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
resolve(value);
|
|
1520
|
-
} else {
|
|
1521
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
function _async_to_generator(fn) {
|
|
1525
|
-
return function() {
|
|
1526
|
-
var self = this, args = arguments;
|
|
1527
|
-
return new Promise(function(resolve, reject) {
|
|
1528
|
-
var gen = fn.apply(self, args);
|
|
1529
|
-
function _next(value) {
|
|
1530
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1531
|
-
}
|
|
1532
|
-
function _throw(err) {
|
|
1533
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1534
|
-
}
|
|
1535
|
-
_next(undefined);
|
|
1536
|
-
});
|
|
1537
|
-
};
|
|
1538
|
-
}
|
|
1539
|
-
function _ts_generator(thisArg, body) {
|
|
1540
|
-
var f, y, t, _ = {
|
|
1541
|
-
label: 0,
|
|
1542
|
-
sent: function() {
|
|
1543
|
-
if (t[0] & 1) throw t[1];
|
|
1544
|
-
return t[1];
|
|
1545
|
-
},
|
|
1546
|
-
trys: [],
|
|
1547
|
-
ops: []
|
|
1548
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
1549
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1550
|
-
return this;
|
|
1551
|
-
}), g;
|
|
1552
|
-
function verb(n) {
|
|
1553
|
-
return function(v) {
|
|
1554
|
-
return step([
|
|
1555
|
-
n,
|
|
1556
|
-
v
|
|
1557
|
-
]);
|
|
1558
|
-
};
|
|
1559
|
-
}
|
|
1560
|
-
function step(op) {
|
|
1561
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1562
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1563
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1564
|
-
if (y = 0, t) op = [
|
|
1565
|
-
op[0] & 2,
|
|
1566
|
-
t.value
|
|
1567
|
-
];
|
|
1568
|
-
switch(op[0]){
|
|
1569
|
-
case 0:
|
|
1570
|
-
case 1:
|
|
1571
|
-
t = op;
|
|
1572
|
-
break;
|
|
1573
|
-
case 4:
|
|
1574
|
-
_.label++;
|
|
1575
|
-
return {
|
|
1576
|
-
value: op[1],
|
|
1577
|
-
done: false
|
|
1578
|
-
};
|
|
1579
|
-
case 5:
|
|
1580
|
-
_.label++;
|
|
1581
|
-
y = op[1];
|
|
1582
|
-
op = [
|
|
1583
|
-
0
|
|
1584
|
-
];
|
|
1585
|
-
continue;
|
|
1586
|
-
case 7:
|
|
1587
|
-
op = _.ops.pop();
|
|
1588
|
-
_.trys.pop();
|
|
1589
|
-
continue;
|
|
1590
|
-
default:
|
|
1591
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1592
|
-
_ = 0;
|
|
1593
|
-
continue;
|
|
1594
|
-
}
|
|
1595
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1596
|
-
_.label = op[1];
|
|
1597
|
-
break;
|
|
1598
|
-
}
|
|
1599
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1600
|
-
_.label = t[1];
|
|
1601
|
-
t = op;
|
|
1602
|
-
break;
|
|
1603
|
-
}
|
|
1604
|
-
if (t && _.label < t[2]) {
|
|
1605
|
-
_.label = t[2];
|
|
1606
|
-
_.ops.push(op);
|
|
1607
|
-
break;
|
|
1608
|
-
}
|
|
1609
|
-
if (t[2]) _.ops.pop();
|
|
1610
|
-
_.trys.pop();
|
|
1611
|
-
continue;
|
|
1612
|
-
}
|
|
1613
|
-
op = body.call(thisArg, _);
|
|
1614
|
-
} catch (e) {
|
|
1615
|
-
op = [
|
|
1616
|
-
6,
|
|
1617
|
-
e
|
|
1618
|
-
];
|
|
1619
|
-
y = 0;
|
|
1620
|
-
} finally{
|
|
1621
|
-
f = t = 0;
|
|
1622
|
-
}
|
|
1623
|
-
if (op[0] & 5) throw op[1];
|
|
1624
|
-
return {
|
|
1625
|
-
value: op[0] ? op[1] : void 0,
|
|
1626
|
-
done: true
|
|
1627
|
-
};
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
var PORT = 3000;
|
|
1631
|
-
(function() {
|
|
1632
|
-
return _async_to_generator(function() {
|
|
1633
|
-
var app, config, document;
|
|
1634
|
-
return _ts_generator(this, function(_state) {
|
|
1635
|
-
switch(_state.label){
|
|
1636
|
-
case 0:
|
|
1637
|
-
return [
|
|
1638
|
-
4,
|
|
1639
|
-
core.NestFactory.create(ZRomulatorModule)
|
|
1640
|
-
];
|
|
1641
|
-
case 1:
|
|
1642
|
-
app = _state.sent();
|
|
1643
|
-
app.setGlobalPrefix("api");
|
|
1644
|
-
app.enableCors();
|
|
1645
|
-
config = new swagger.DocumentBuilder().setTitle("Romulator API").setDescription("The Romulator API").setVersion("1").build();
|
|
1646
|
-
document = function() {
|
|
1647
|
-
return swagger.SwaggerModule.createDocument(app, config);
|
|
1648
|
-
};
|
|
1649
|
-
swagger.SwaggerModule.setup("api/docs", app, document);
|
|
1650
|
-
return [
|
|
1651
|
-
4,
|
|
1652
|
-
app.listen(PORT)
|
|
1653
|
-
];
|
|
1654
|
-
case 2:
|
|
1655
|
-
_state.sent();
|
|
1656
|
-
return [
|
|
1657
|
-
2
|
|
1658
|
-
];
|
|
1659
|
-
}
|
|
1660
|
-
});
|
|
1661
|
-
})();
|
|
878
|
+
const PORT = 3000;
|
|
879
|
+
(async function() {
|
|
880
|
+
const app = await core.NestFactory.create(ZRomulatorModule);
|
|
881
|
+
app.setGlobalPrefix("api");
|
|
882
|
+
app.enableCors();
|
|
883
|
+
const config = new swagger.DocumentBuilder().setTitle("Romulator API").setDescription("The Romulator API").setVersion("1").build();
|
|
884
|
+
const document = ()=>swagger.SwaggerModule.createDocument(app, config);
|
|
885
|
+
swagger.SwaggerModule.setup("api/docs", app, document);
|
|
886
|
+
await app.listen(PORT);
|
|
1662
887
|
})();
|
|
1663
888
|
//# sourceMappingURL=main.cjs.map
|