@zthun/romulator-api 1.9.0 → 1.10.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.cjs CHANGED
@@ -24,19 +24,19 @@ const mimeTypes = require('mime-types');
24
24
  const node_fs = require('node:fs');
25
25
  const node_stream = require('node:stream');
26
26
 
27
- function _ts_decorate$h(decorators, target, key, desc) {
27
+ function _ts_decorate$i(decorators, target, key, desc) {
28
28
  var c = arguments.length, r = c < 3 ? target : desc, d;
29
29
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
30
  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;
31
31
  return c > 3 && r && Object.defineProperty(target, key, r), r;
32
32
  }
33
- function _ts_metadata$b(k, v) {
33
+ function _ts_metadata$c(k, v) {
34
34
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
35
35
  }
36
36
  class ZRomulatorConfigUpdateDto {
37
37
  contents;
38
38
  }
39
- _ts_decorate$h([
39
+ _ts_decorate$i([
40
40
  swagger.ApiProperty({
41
41
  type: "object",
42
42
  properties: {}
@@ -48,7 +48,7 @@ _ts_decorate$h([
48
48
  message: "The contents of the config must be an object "
49
49
  }),
50
50
  classValidator.IsNotEmptyObject(),
51
- _ts_metadata$b("design:type", typeof T === "undefined" ? Object : T)
51
+ _ts_metadata$c("design:type", typeof T === "undefined" ? Object : T)
52
52
  ], ZRomulatorConfigUpdateDto.prototype, "contents", void 0);
53
53
 
54
54
  class ZDir {
@@ -75,16 +75,16 @@ class ZRomulatorConfigKnown {
75
75
  }
76
76
  }
77
77
 
78
- function _ts_decorate$g(decorators, target, key, desc) {
78
+ function _ts_decorate$h(decorators, target, key, desc) {
79
79
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
80
80
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
81
81
  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;
82
82
  return c > 3 && r && Object.defineProperty(target, key, r), r;
83
83
  }
84
- function _ts_metadata$a(k, v) {
84
+ function _ts_metadata$b(k, v) {
85
85
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
86
86
  }
87
- function _ts_param$9(paramIndex, decorator) {
87
+ function _ts_param$a(paramIndex, decorator) {
88
88
  return function(target, key) {
89
89
  decorator(target, key, paramIndex);
90
90
  };
@@ -166,25 +166,25 @@ class ZRomulatorConfigsService {
166
166
  return config;
167
167
  }
168
168
  }
169
- ZRomulatorConfigsService = _ts_decorate$g([
169
+ ZRomulatorConfigsService = _ts_decorate$h([
170
170
  common.Injectable(),
171
- _ts_param$9(0, common.Inject(lumberjackyNest.ZLoggerToken)),
172
- _ts_metadata$a("design:type", Function),
173
- _ts_metadata$a("design:paramtypes", [
171
+ _ts_param$a(0, common.Inject(lumberjackyNest.ZLoggerToken)),
172
+ _ts_metadata$b("design:type", Function),
173
+ _ts_metadata$b("design:paramtypes", [
174
174
  typeof IZLogger === "undefined" ? Object : IZLogger
175
175
  ])
176
176
  ], ZRomulatorConfigsService);
177
177
 
178
- function _ts_decorate$f(decorators, target, key, desc) {
178
+ function _ts_decorate$g(decorators, target, key, desc) {
179
179
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
180
180
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
181
181
  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;
182
182
  return c > 3 && r && Object.defineProperty(target, key, r), r;
183
183
  }
184
- function _ts_metadata$9(k, v) {
184
+ function _ts_metadata$a(k, v) {
185
185
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
186
186
  }
187
- function _ts_param$8(paramIndex, decorator) {
187
+ function _ts_param$9(paramIndex, decorator) {
188
188
  return function(target, key) {
189
189
  decorator(target, key, paramIndex);
190
190
  };
@@ -205,16 +205,16 @@ class ZRomulatorConfigsController {
205
205
  return await this._configs.get(identification);
206
206
  }
207
207
  }
208
- _ts_decorate$f([
208
+ _ts_decorate$g([
209
209
  common.Get(),
210
- _ts_param$8(0, common.Query()),
211
- _ts_metadata$9("design:type", Function),
212
- _ts_metadata$9("design:paramtypes", [
210
+ _ts_param$9(0, common.Query()),
211
+ _ts_metadata$a("design:type", Function),
212
+ _ts_metadata$a("design:paramtypes", [
213
213
  typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
214
214
  ]),
215
- _ts_metadata$9("design:returntype", Promise)
215
+ _ts_metadata$a("design:returntype", Promise)
216
216
  ], ZRomulatorConfigsController.prototype, "list", null);
217
- _ts_decorate$f([
217
+ _ts_decorate$g([
218
218
  swagger.ApiParam({
219
219
  type: "string",
220
220
  name: "identification",
@@ -231,39 +231,39 @@ _ts_decorate$f([
231
231
  skipNullProperties: false,
232
232
  skipUndefinedProperties: false
233
233
  })),
234
- _ts_param$8(0, common.Param("identification")),
235
- _ts_param$8(1, common.Body()),
236
- _ts_metadata$9("design:type", Function),
237
- _ts_metadata$9("design:paramtypes", [
234
+ _ts_param$9(0, common.Param("identification")),
235
+ _ts_param$9(1, common.Body()),
236
+ _ts_metadata$a("design:type", Function),
237
+ _ts_metadata$a("design:paramtypes", [
238
238
  typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
239
239
  typeof ZRomulatorConfigUpdateDto === "undefined" ? Object : ZRomulatorConfigUpdateDto
240
240
  ]),
241
- _ts_metadata$9("design:returntype", Promise)
241
+ _ts_metadata$a("design:returntype", Promise)
242
242
  ], ZRomulatorConfigsController.prototype, "update", null);
243
- _ts_decorate$f([
243
+ _ts_decorate$g([
244
244
  swagger.ApiParam({
245
245
  type: "string",
246
246
  name: "identification",
247
247
  description: "The id of the config"
248
248
  }),
249
249
  common.Get(":identification"),
250
- _ts_param$8(0, common.Param("identification")),
251
- _ts_metadata$9("design:type", Function),
252
- _ts_metadata$9("design:paramtypes", [
250
+ _ts_param$9(0, common.Param("identification")),
251
+ _ts_metadata$a("design:type", Function),
252
+ _ts_metadata$a("design:paramtypes", [
253
253
  typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
254
254
  ]),
255
- _ts_metadata$9("design:returntype", Promise)
255
+ _ts_metadata$a("design:returntype", Promise)
256
256
  ], ZRomulatorConfigsController.prototype, "get", null);
257
- ZRomulatorConfigsController = _ts_decorate$f([
257
+ ZRomulatorConfigsController = _ts_decorate$g([
258
258
  common.Controller("configs"),
259
- _ts_param$8(0, common.Inject(ZRomulatorConfigsToken)),
260
- _ts_metadata$9("design:type", Function),
261
- _ts_metadata$9("design:paramtypes", [
259
+ _ts_param$9(0, common.Inject(ZRomulatorConfigsToken)),
260
+ _ts_metadata$a("design:type", Function),
261
+ _ts_metadata$a("design:paramtypes", [
262
262
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
263
263
  ])
264
264
  ], ZRomulatorConfigsController);
265
265
 
266
- function _ts_decorate$e(decorators, target, key, desc) {
266
+ function _ts_decorate$f(decorators, target, key, desc) {
267
267
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
268
268
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
269
269
  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;
@@ -271,7 +271,7 @@ function _ts_decorate$e(decorators, target, key, desc) {
271
271
  }
272
272
  class ZRomulatorConfigsModule {
273
273
  }
274
- ZRomulatorConfigsModule = _ts_decorate$e([
274
+ ZRomulatorConfigsModule = _ts_decorate$f([
275
275
  common.Module({
276
276
  imports: [
277
277
  crumbtrailNest.ZFileSystemModule,
@@ -292,13 +292,13 @@ ZRomulatorConfigsModule = _ts_decorate$e([
292
292
  })
293
293
  ], ZRomulatorConfigsModule);
294
294
 
295
- function _ts_decorate$d(decorators, target, key, desc) {
295
+ function _ts_decorate$e(decorators, target, key, desc) {
296
296
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
297
297
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
298
298
  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;
299
299
  return c > 3 && r && Object.defineProperty(target, key, r), r;
300
300
  }
301
- function _ts_metadata$8(k, v) {
301
+ function _ts_metadata$9(k, v) {
302
302
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
303
303
  }
304
304
  const KnownSystem = "@zthunworks/romulator/known-system";
@@ -394,59 +394,59 @@ const KnownSystem = "@zthunworks/romulator/known-system";
394
394
  return null;
395
395
  }
396
396
  }
397
- _ts_decorate$d([
397
+ _ts_decorate$e([
398
398
  helpfulReflection.ZTag(KnownSystem),
399
- _ts_metadata$8("design:type", Function),
400
- _ts_metadata$8("design:paramtypes", []),
401
- _ts_metadata$8("design:returntype", void 0)
399
+ _ts_metadata$9("design:type", Function),
400
+ _ts_metadata$9("design:paramtypes", []),
401
+ _ts_metadata$9("design:returntype", void 0)
402
402
  ], ZRomulatorSystemKnown, "nes", null);
403
- _ts_decorate$d([
403
+ _ts_decorate$e([
404
404
  helpfulReflection.ZTag(KnownSystem),
405
- _ts_metadata$8("design:type", Function),
406
- _ts_metadata$8("design:paramtypes", []),
407
- _ts_metadata$8("design:returntype", void 0)
405
+ _ts_metadata$9("design:type", Function),
406
+ _ts_metadata$9("design:paramtypes", []),
407
+ _ts_metadata$9("design:returntype", void 0)
408
408
  ], ZRomulatorSystemKnown, "snes", null);
409
- _ts_decorate$d([
409
+ _ts_decorate$e([
410
410
  helpfulReflection.ZTag(KnownSystem),
411
- _ts_metadata$8("design:type", Function),
412
- _ts_metadata$8("design:paramtypes", []),
413
- _ts_metadata$8("design:returntype", void 0)
411
+ _ts_metadata$9("design:type", Function),
412
+ _ts_metadata$9("design:paramtypes", []),
413
+ _ts_metadata$9("design:returntype", void 0)
414
414
  ], ZRomulatorSystemKnown, "n64", null);
415
- _ts_decorate$d([
415
+ _ts_decorate$e([
416
416
  helpfulReflection.ZTag(KnownSystem),
417
- _ts_metadata$8("design:type", Function),
418
- _ts_metadata$8("design:paramtypes", []),
419
- _ts_metadata$8("design:returntype", void 0)
417
+ _ts_metadata$9("design:type", Function),
418
+ _ts_metadata$9("design:paramtypes", []),
419
+ _ts_metadata$9("design:returntype", void 0)
420
420
  ], ZRomulatorSystemKnown, "gc", null);
421
- _ts_decorate$d([
421
+ _ts_decorate$e([
422
422
  helpfulReflection.ZTag(KnownSystem),
423
- _ts_metadata$8("design:type", Function),
424
- _ts_metadata$8("design:paramtypes", []),
425
- _ts_metadata$8("design:returntype", void 0)
423
+ _ts_metadata$9("design:type", Function),
424
+ _ts_metadata$9("design:paramtypes", []),
425
+ _ts_metadata$9("design:returntype", void 0)
426
426
  ], ZRomulatorSystemKnown, "wii", null);
427
- _ts_decorate$d([
427
+ _ts_decorate$e([
428
428
  helpfulReflection.ZTag(KnownSystem),
429
- _ts_metadata$8("design:type", Function),
430
- _ts_metadata$8("design:paramtypes", []),
431
- _ts_metadata$8("design:returntype", void 0)
429
+ _ts_metadata$9("design:type", Function),
430
+ _ts_metadata$9("design:paramtypes", []),
431
+ _ts_metadata$9("design:returntype", void 0)
432
432
  ], ZRomulatorSystemKnown, "wiiu", null);
433
- _ts_decorate$d([
433
+ _ts_decorate$e([
434
434
  helpfulReflection.ZTag(KnownSystem),
435
- _ts_metadata$8("design:type", Function),
436
- _ts_metadata$8("design:paramtypes", []),
437
- _ts_metadata$8("design:returntype", void 0)
435
+ _ts_metadata$9("design:type", Function),
436
+ _ts_metadata$9("design:paramtypes", []),
437
+ _ts_metadata$9("design:returntype", void 0)
438
438
  ], ZRomulatorSystemKnown, "switch", null);
439
439
 
440
- function _ts_decorate$c(decorators, target, key, desc) {
440
+ function _ts_decorate$d(decorators, target, key, desc) {
441
441
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
442
442
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
443
443
  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;
444
444
  return c > 3 && r && Object.defineProperty(target, key, r), r;
445
445
  }
446
- function _ts_metadata$7(k, v) {
446
+ function _ts_metadata$8(k, v) {
447
447
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
448
448
  }
449
- function _ts_param$7(paramIndex, decorator) {
449
+ function _ts_param$8(paramIndex, decorator) {
450
450
  return function(target, key) {
451
451
  decorator(target, key, paramIndex);
452
452
  };
@@ -516,29 +516,29 @@ class ZRomulatorGamesService {
516
516
  ].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
517
517
  }
518
518
  }
519
- ZRomulatorGamesService = _ts_decorate$c([
519
+ ZRomulatorGamesService = _ts_decorate$d([
520
520
  common.Injectable(),
521
- _ts_param$7(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
522
- _ts_param$7(1, common.Inject(ZRomulatorConfigsToken)),
523
- _ts_param$7(2, common.Inject(lumberjackyNest.ZLoggerToken)),
524
- _ts_metadata$7("design:type", Function),
525
- _ts_metadata$7("design:paramtypes", [
521
+ _ts_param$8(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
522
+ _ts_param$8(1, common.Inject(ZRomulatorConfigsToken)),
523
+ _ts_param$8(2, common.Inject(lumberjackyNest.ZLoggerToken)),
524
+ _ts_metadata$8("design:type", Function),
525
+ _ts_metadata$8("design:paramtypes", [
526
526
  typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
527
527
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
528
528
  typeof IZLogger === "undefined" ? Object : IZLogger
529
529
  ])
530
530
  ], ZRomulatorGamesService);
531
531
 
532
- function _ts_decorate$b(decorators, target, key, desc) {
532
+ function _ts_decorate$c(decorators, target, key, desc) {
533
533
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
534
534
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
535
535
  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;
536
536
  return c > 3 && r && Object.defineProperty(target, key, r), r;
537
537
  }
538
- function _ts_metadata$6(k, v) {
538
+ function _ts_metadata$7(k, v) {
539
539
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
540
540
  }
541
- function _ts_param$6(paramIndex, decorator) {
541
+ function _ts_param$7(paramIndex, decorator) {
542
542
  return function(target, key) {
543
543
  decorator(target, key, paramIndex);
544
544
  };
@@ -555,34 +555,34 @@ class ZRomulatorGamesController {
555
555
  return this._games.get(identification);
556
556
  }
557
557
  }
558
- _ts_decorate$b([
558
+ _ts_decorate$c([
559
559
  common.Get(),
560
- _ts_param$6(0, common.Query()),
561
- _ts_metadata$6("design:type", Function),
562
- _ts_metadata$6("design:paramtypes", [
560
+ _ts_param$7(0, common.Query()),
561
+ _ts_metadata$7("design:type", Function),
562
+ _ts_metadata$7("design:paramtypes", [
563
563
  typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
564
564
  ]),
565
- _ts_metadata$6("design:returntype", typeof Promise === "undefined" ? Object : Promise)
565
+ _ts_metadata$7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
566
566
  ], ZRomulatorGamesController.prototype, "list", null);
567
- _ts_decorate$b([
567
+ _ts_decorate$c([
568
568
  common.Get(":identification"),
569
- _ts_param$6(0, common.Param("identification")),
570
- _ts_metadata$6("design:type", Function),
571
- _ts_metadata$6("design:paramtypes", [
569
+ _ts_param$7(0, common.Param("identification")),
570
+ _ts_metadata$7("design:type", Function),
571
+ _ts_metadata$7("design:paramtypes", [
572
572
  String
573
573
  ]),
574
- _ts_metadata$6("design:returntype", void 0)
574
+ _ts_metadata$7("design:returntype", void 0)
575
575
  ], ZRomulatorGamesController.prototype, "get", null);
576
- ZRomulatorGamesController = _ts_decorate$b([
576
+ ZRomulatorGamesController = _ts_decorate$c([
577
577
  common.Controller("games"),
578
- _ts_param$6(0, common.Inject(ZRomulatorGamesToken)),
579
- _ts_metadata$6("design:type", Function),
580
- _ts_metadata$6("design:paramtypes", [
578
+ _ts_param$7(0, common.Inject(ZRomulatorGamesToken)),
579
+ _ts_metadata$7("design:type", Function),
580
+ _ts_metadata$7("design:paramtypes", [
581
581
  typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
582
582
  ])
583
583
  ], ZRomulatorGamesController);
584
584
 
585
- function _ts_decorate$a(decorators, target, key, desc) {
585
+ function _ts_decorate$b(decorators, target, key, desc) {
586
586
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
587
587
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
588
588
  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;
@@ -590,7 +590,7 @@ function _ts_decorate$a(decorators, target, key, desc) {
590
590
  }
591
591
  class ZRomulatorGamesModule {
592
592
  }
593
- ZRomulatorGamesModule = _ts_decorate$a([
593
+ ZRomulatorGamesModule = _ts_decorate$b([
594
594
  common.Module({
595
595
  imports: [
596
596
  ZRomulatorConfigsModule,
@@ -609,29 +609,28 @@ ZRomulatorGamesModule = _ts_decorate$a([
609
609
  })
610
610
  ], ZRomulatorGamesModule);
611
611
 
612
- function _ts_decorate$9(decorators, target, key, desc) {
612
+ function _ts_decorate$a(decorators, target, key, desc) {
613
613
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
614
614
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
615
615
  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;
616
616
  return c > 3 && r && Object.defineProperty(target, key, r), r;
617
617
  }
618
- function _ts_metadata$5(k, v) {
618
+ function _ts_metadata$6(k, v) {
619
619
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
620
620
  }
621
- function _ts_param$5(paramIndex, decorator) {
621
+ function _ts_param$6(paramIndex, decorator) {
622
622
  return function(target, key) {
623
623
  decorator(target, key, paramIndex);
624
624
  };
625
625
  }
626
626
  const ZRomulatorFilesToken = Symbol("files");
627
- class ZRomulatorFilesService {
627
+ class ZRomulatorFilesRepository {
628
628
  _configs;
629
629
  _fileSystem;
630
630
  static MediaFolderName = ".media";
631
631
  static InfoFolderName = ".info";
632
632
  _repository = new crumbtrailFs.ZFileRepository();
633
633
  _folderStream = new crumbtrailFs.ZStreamFolder();
634
- _fileStream = new crumbtrailFs.ZStreamFile();
635
634
  _globs;
636
635
  _systems;
637
636
  constructor(_configs, _fileSystem){
@@ -654,33 +653,16 @@ class ZRomulatorFilesService {
654
653
  }
655
654
  async mediaFolder() {
656
655
  const gamesFolder = await this.gamesFolder();
657
- return node_path.resolve(gamesFolder, ZRomulatorFilesService.MediaFolderName);
656
+ return node_path.resolve(gamesFolder, ZRomulatorFilesRepository.MediaFolderName);
658
657
  }
659
658
  async infoFolder() {
660
659
  const gamesFolder = await this.gamesFolder();
661
- return node_path.resolve(gamesFolder, ZRomulatorFilesService.InfoFolderName);
662
- }
663
- async contents(roots, path) {
664
- const repository = await this.seed();
665
- const folders = lodashEs.castArray(roots).map((root)=>`${lodashEs.trimEnd(root, "/")}/`);
666
- const byPaths = folders.map((folder)=>{
667
- const byPath = new helpfulQuery.ZFilterBinaryBuilder().subject("path");
668
- const pathFilter = path == null ? byPath.startsWith().value(folder) : byPath.equal().value(node_path.resolve(folder, path));
669
- return pathFilter.build();
670
- });
671
- const filter = byPaths.length > 1 ? new helpfulQuery.ZFilterLogicBuilder().or().clauses(byPaths).build() : lodashEs.first(byPaths);
672
- const sort = new helpfulQuery.ZSortBuilder().ascending("path").build();
673
- const request = new helpfulQuery.ZDataRequestBuilder().filter(filter).sort(sort).build();
674
- const nodes = await repository.retrieve(request);
675
- return path == null ? nodes : helpfulFn.firstDefined(null, lodashEs.first(nodes));
676
- }
677
- async init() {
678
- await this.seed();
660
+ return node_path.resolve(gamesFolder, ZRomulatorFilesRepository.InfoFolderName);
679
661
  }
680
662
  async dispose() {
681
663
  await this._repository.reset();
682
664
  }
683
- async seed() {
665
+ async init() {
684
666
  const path = await this.gamesFolder();
685
667
  if (this._repository.path !== path) {
686
668
  await this._folderStream.write(await this.mediaFolder());
@@ -689,10 +671,20 @@ class ZRomulatorFilesService {
689
671
  }
690
672
  return this._repository;
691
673
  }
692
- async media(path) {
693
- return this.contents(await this.mediaFolder(), path);
674
+ async media() {
675
+ const repository = await this.init();
676
+ const folder = `${await this.mediaFolder()}/`;
677
+ const request = new helpfulQuery.ZDataRequestBuilder().filter(new helpfulQuery.ZFilterBinaryBuilder().subject("path").startsWith().value(folder).build()).sort(new helpfulQuery.ZSortBuilder().ascending("path").build()).build();
678
+ return repository.retrieve(request);
694
679
  }
695
- async systems(path) {
680
+ async info(id) {
681
+ // The info json files are json files that contain arrays of games grouped by systems,
682
+ // or systems.json which describes system information.
683
+ const folder = await this.infoFolder();
684
+ const path = node_path.resolve(folder, `${id}.json`);
685
+ return this._repository.get(path);
686
+ }
687
+ async systems(id) {
696
688
  // Systems use directories. There's a maximum limit of about 200 systems.
697
689
  // Since we don't actually need to read any metadata or scan through thousands
698
690
  // of unknown folders, we can use the supported system ids to just grab the
@@ -700,34 +692,93 @@ class ZRomulatorFilesService {
700
692
  // grab the systems from the file system and it should be fast enough. These are all
701
693
  // folders, so we don't even need the stats for them and we can assume folders.
702
694
  const games = await this.gamesFolder();
703
- const folders = path == null ? this._systems.map((s)=>`${s}/`) : node_path.resolve(games, path);
695
+ const folders = id == null ? this._systems.map((s)=>`${s}/`) : node_path.resolve(games, id);
704
696
  const items = await this._fileSystem.search(folders, {
705
697
  cwd: games,
706
698
  stat: false
707
699
  });
708
- return path == null ? items : helpfulFn.firstDefined(null, lodashEs.first(items));
700
+ return id == null ? items : helpfulFn.firstDefined(null, lodashEs.first(items));
709
701
  }
710
- async info(path) {
711
- return this.contents(await this.infoFolder(), path);
702
+ }
703
+ ZRomulatorFilesRepository = _ts_decorate$a([
704
+ common.Injectable(),
705
+ _ts_param$6(0, common.Inject(ZRomulatorConfigsToken)),
706
+ _ts_param$6(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
707
+ _ts_metadata$6("design:type", Function),
708
+ _ts_metadata$6("design:paramtypes", [
709
+ typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
710
+ typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService
711
+ ])
712
+ ], ZRomulatorFilesRepository);
713
+
714
+ function _ts_decorate$9(decorators, target, key, desc) {
715
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
716
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
717
+ 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;
718
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
719
+ }
720
+ function _ts_metadata$5(k, v) {
721
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
722
+ }
723
+ function _ts_param$5(paramIndex, decorator) {
724
+ return function(target, key) {
725
+ decorator(target, key, paramIndex);
726
+ };
727
+ }
728
+ const ZRomulatorFilesSystemsJsonRepositoryToken = Symbol("files-systems-json-repository");
729
+ class ZRomulatorFilesSystemsJsonRepository {
730
+ _files;
731
+ _logger;
732
+ _stream = new crumbtrailFs.ZStreamFile({
733
+ cache: {
734
+ maxFiles: 1,
735
+ fileSize: BigInt(helpfulFn.mib(5))
736
+ }
737
+ });
738
+ /**
739
+ * Initializes a new instance of this object.
740
+ */ constructor(_files, logger){
741
+ this._files = _files;
742
+ this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorSystemsRepository", logger);
712
743
  }
713
- async games(path) {
714
- const root = await this.gamesFolder();
715
- return this.contents(this._systems.map((s)=>node_path.resolve(root, s)), path);
744
+ async _read() {
745
+ const info = await this._files.info("systems");
746
+ if (info == null) {
747
+ return [];
748
+ }
749
+ try {
750
+ const contents = await this._stream.read(info.path);
751
+ const json = JSON.parse(contents.toString());
752
+ return lodashEs.castArray(json);
753
+ } catch (e) {
754
+ const err = helpfulFn.createError(e);
755
+ const msg = `Unable to read ${info.path}: ${err.message}`;
756
+ this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
757
+ return [];
758
+ }
716
759
  }
717
- read(node) {
718
- return this._fileStream.read(node.path);
760
+ async systems() {
761
+ const candidates = await this._read();
762
+ function hasId(candidate) {
763
+ return Object.prototype.hasOwnProperty.call(candidate, "id");
764
+ }
765
+ const entries = candidates.filter((c)=>hasId(c)).filter((c)=>romulatorClient.isSystemId(c.id)).map((c)=>[
766
+ c.id,
767
+ c
768
+ ]);
769
+ return Promise.resolve(new Map(entries));
719
770
  }
720
771
  }
721
- ZRomulatorFilesService = _ts_decorate$9([
772
+ ZRomulatorFilesSystemsJsonRepository = _ts_decorate$9([
722
773
  common.Injectable(),
723
- _ts_param$5(0, common.Inject(ZRomulatorConfigsToken)),
724
- _ts_param$5(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
774
+ _ts_param$5(0, common.Inject(ZRomulatorFilesToken)),
775
+ _ts_param$5(1, common.Inject(lumberjackyNest.ZLoggerToken)),
725
776
  _ts_metadata$5("design:type", Function),
726
777
  _ts_metadata$5("design:paramtypes", [
727
- typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
728
- typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService
778
+ typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository,
779
+ typeof IZLogger === "undefined" ? Object : IZLogger
729
780
  ])
730
- ], ZRomulatorFilesService);
781
+ ], ZRomulatorFilesSystemsJsonRepository);
731
782
 
732
783
  function _ts_decorate$8(decorators, target, key, desc) {
733
784
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -759,22 +810,28 @@ ZRomulatorFilesModule = _ts_decorate$8([
759
810
  common.Module({
760
811
  imports: [
761
812
  crumbtrailNest.ZFileSystemModule,
762
- ZRomulatorConfigsModule
813
+ ZRomulatorConfigsModule,
814
+ lumberjackyNest.ZLoggerModule
763
815
  ],
764
816
  providers: [
765
817
  {
766
818
  provide: ZRomulatorFilesToken,
767
- useClass: ZRomulatorFilesService
819
+ useClass: ZRomulatorFilesRepository
820
+ },
821
+ {
822
+ provide: ZRomulatorFilesSystemsJsonRepositoryToken,
823
+ useClass: ZRomulatorFilesSystemsJsonRepository
768
824
  }
769
825
  ],
770
826
  exports: [
771
- ZRomulatorFilesToken
827
+ ZRomulatorFilesToken,
828
+ ZRomulatorFilesSystemsJsonRepositoryToken
772
829
  ]
773
830
  }),
774
831
  _ts_param$4(0, common.Inject(ZRomulatorFilesToken)),
775
832
  _ts_metadata$4("design:type", Function),
776
833
  _ts_metadata$4("design:paramtypes", [
777
- typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService
834
+ typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository
778
835
  ])
779
836
  ], ZRomulatorFilesModule);
780
837
 
@@ -951,7 +1008,7 @@ ZRomulatorMediaService = _ts_decorate$6([
951
1008
  _ts_metadata$3("design:type", Function),
952
1009
  _ts_metadata$3("design:paramtypes", [
953
1010
  typeof IZRomulatorMediaGenerator === "undefined" ? Object : IZRomulatorMediaGenerator,
954
- typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService,
1011
+ typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository,
955
1012
  typeof IZLogger === "undefined" ? Object : IZLogger
956
1013
  ])
957
1014
  ], ZRomulatorMediaService);
@@ -1138,11 +1195,13 @@ function _ts_param$1(paramIndex, decorator) {
1138
1195
  }
1139
1196
  const ZRomulatorSystemsToken = Symbol("romulator-systems-service");
1140
1197
  class ZRomulatorSystemsService {
1141
- _files;
1198
+ _filesRepository;
1199
+ _systemsRepository;
1142
1200
  logger;
1143
1201
  _logger;
1144
- constructor(_files, logger){
1145
- this._files = _files;
1202
+ constructor(_filesRepository, _systemsRepository, logger){
1203
+ this._filesRepository = _filesRepository;
1204
+ this._systemsRepository = _systemsRepository;
1146
1205
  this.logger = logger;
1147
1206
  this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorSystemsService", logger);
1148
1207
  }
@@ -1151,8 +1210,9 @@ class ZRomulatorSystemsService {
1151
1210
  const size = helpfulFn.firstDefined(Infinity, req.size);
1152
1211
  let msg = `Retrieving systems page, ${page}, with size, ${size}.`;
1153
1212
  this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
1154
- const folders = await this._files.systems();
1155
- const systems = await Promise.all(folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).filter((slug)=>romulatorClient.isSystemId(slug)).map((slug)=>this._createSystemFromSlug(slug)));
1213
+ const folders = await this._filesRepository.systems();
1214
+ const lookup = await this._systemsRepository.systems();
1215
+ const systems = await Promise.all(folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).filter((slug)=>romulatorClient.isSystemId(slug)).map((slug)=>new romulatorClient.ZRomulatorSystemBuilder().id(slug).parse(lookup.get(slug)).build()));
1156
1216
  msg = `Found ${systems.length} systems`;
1157
1217
  this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
1158
1218
  const sourceOptions = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields([
@@ -1171,41 +1231,25 @@ class ZRomulatorSystemsService {
1171
1231
  const message = `The specified system slug, ${id}, is not supported.`;
1172
1232
  throw new common.NotFoundException(message);
1173
1233
  }
1174
- const node = await this._files.systems(id);
1175
- if (node == null) {
1234
+ const system = await this._filesRepository.systems(id);
1235
+ if (system == null) {
1176
1236
  const message = `System with slug, ${id}, was not found.`;
1177
1237
  throw new common.NotFoundException(message);
1178
1238
  }
1179
- return this._createSystemFromSlug(id);
1180
- }
1181
- async _createSystemFromSlug(slug) {
1182
- const system = new romulatorClient.ZRomulatorSystemBuilder().id(slug);
1183
- const path = `${slug}/info.json`;
1184
- const info = await this._files.info(path);
1185
- if (info == null) {
1186
- // Best we can do right now.
1187
- return system.build();
1188
- }
1189
- try {
1190
- const contents = await this._files.read(info);
1191
- const json = JSON.parse(contents.toString());
1192
- return system.assign(json).redact().build();
1193
- } catch (e) {
1194
- // Best we can do
1195
- const err = helpfulFn.createError(e);
1196
- const msg = `Cannot read system metadata, ${err.message}`;
1197
- this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
1198
- return system.build();
1199
- }
1239
+ const lookup = await this._systemsRepository.systems();
1240
+ const info = lookup.get(id);
1241
+ return new romulatorClient.ZRomulatorSystemBuilder().id(id).parse(info).build();
1200
1242
  }
1201
1243
  }
1202
1244
  ZRomulatorSystemsService = _ts_decorate$3([
1203
1245
  common.Injectable(),
1204
1246
  _ts_param$1(0, common.Inject(ZRomulatorFilesToken)),
1205
- _ts_param$1(1, common.Inject(lumberjackyNest.ZLoggerToken)),
1247
+ _ts_param$1(1, common.Inject(ZRomulatorFilesSystemsJsonRepositoryToken)),
1248
+ _ts_param$1(2, common.Inject(lumberjackyNest.ZLoggerToken)),
1206
1249
  _ts_metadata$1("design:type", Function),
1207
1250
  _ts_metadata$1("design:paramtypes", [
1208
- typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService,
1251
+ typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository,
1252
+ typeof IZRomulatorFilesSystemsJsonRepository === "undefined" ? Object : IZRomulatorFilesSystemsJsonRepository,
1209
1253
  typeof IZLogger === "undefined" ? Object : IZLogger
1210
1254
  ])
1211
1255
  ], ZRomulatorSystemsService);
@@ -1290,6 +1334,9 @@ ZRomulatorSystemsModule = _ts_decorate$1([
1290
1334
  provide: ZRomulatorSystemsToken,
1291
1335
  useClass: ZRomulatorSystemsService
1292
1336
  }
1337
+ ],
1338
+ exports: [
1339
+ ZRomulatorSystemsToken
1293
1340
  ]
1294
1341
  })
1295
1342
  ], ZRomulatorSystemsModule);