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