@zthun/romulator-api 1.7.0 → 1.7.1

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.
@@ -1,2 +1,7 @@
1
+ import { IZRomulatorFilesService } from './files-service.mjs';
1
2
  export declare class ZRomulatorFilesModule {
3
+ private readonly _files;
4
+ constructor(_files: IZRomulatorFilesService);
5
+ onModuleInit(): Promise<void>;
6
+ onModuleDestroy(): Promise<void>;
2
7
  }
@@ -71,6 +71,14 @@ export interface IZRomulatorFilesService {
71
71
  * The node with the given path or null if no such file exists.
72
72
  */
73
73
  info(path: string): Promise<IZFileSystemNode | null>;
74
+ /**
75
+ * Initializes the file repository.
76
+ */
77
+ init(): Promise<void>;
78
+ /**
79
+ * Cleans up internal resources.
80
+ */
81
+ dispose(): Promise<void>;
74
82
  }
75
83
  export declare class ZRomulatorFilesService implements IZRomulatorFilesService {
76
84
  private readonly _configs;
@@ -86,6 +94,8 @@ export declare class ZRomulatorFilesService implements IZRomulatorFilesService {
86
94
  private mediaFolder;
87
95
  private infoFolder;
88
96
  private contents;
97
+ init(): Promise<void>;
98
+ dispose(): Promise<void>;
89
99
  seed(): Promise<IZFileRepository>;
90
100
  media(): Promise<IZFileSystemNode[]>;
91
101
  media(path: string): Promise<IZFileSystemNode | null>;
package/dist/main.cjs CHANGED
@@ -29,7 +29,7 @@ function _ts_decorate$g(decorators, target, key, desc) {
29
29
  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;
30
30
  return c > 3 && r && Object.defineProperty(target, key, r), r;
31
31
  }
32
- function _ts_metadata$a(k, v) {
32
+ function _ts_metadata$b(k, v) {
33
33
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
34
34
  }
35
35
  class ZRomulatorConfigUpdateDto {
@@ -47,7 +47,7 @@ _ts_decorate$g([
47
47
  message: "The contents of the config must be an object "
48
48
  }),
49
49
  classValidator.IsNotEmptyObject(),
50
- _ts_metadata$a("design:type", typeof T === "undefined" ? Object : T)
50
+ _ts_metadata$b("design:type", typeof T === "undefined" ? Object : T)
51
51
  ], ZRomulatorConfigUpdateDto.prototype, "contents", void 0);
52
52
 
53
53
  class ZDir {
@@ -80,10 +80,10 @@ function _ts_decorate$f(decorators, target, key, desc) {
80
80
  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;
81
81
  return c > 3 && r && Object.defineProperty(target, key, r), r;
82
82
  }
83
- function _ts_metadata$9(k, v) {
83
+ function _ts_metadata$a(k, v) {
84
84
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
85
85
  }
86
- function _ts_param$8(paramIndex, decorator) {
86
+ function _ts_param$9(paramIndex, decorator) {
87
87
  return function(target, key) {
88
88
  decorator(target, key, paramIndex);
89
89
  };
@@ -167,9 +167,9 @@ class ZRomulatorConfigsService {
167
167
  }
168
168
  ZRomulatorConfigsService = _ts_decorate$f([
169
169
  common.Injectable(),
170
- _ts_param$8(0, common.Inject(lumberjackyNest.ZLoggerToken)),
171
- _ts_metadata$9("design:type", Function),
172
- _ts_metadata$9("design:paramtypes", [
170
+ _ts_param$9(0, common.Inject(lumberjackyNest.ZLoggerToken)),
171
+ _ts_metadata$a("design:type", Function),
172
+ _ts_metadata$a("design:paramtypes", [
173
173
  typeof IZLogger === "undefined" ? Object : IZLogger
174
174
  ])
175
175
  ], ZRomulatorConfigsService);
@@ -180,10 +180,10 @@ function _ts_decorate$e(decorators, target, key, desc) {
180
180
  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;
181
181
  return c > 3 && r && Object.defineProperty(target, key, r), r;
182
182
  }
183
- function _ts_metadata$8(k, v) {
183
+ function _ts_metadata$9(k, v) {
184
184
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
185
185
  }
186
- function _ts_param$7(paramIndex, decorator) {
186
+ function _ts_param$8(paramIndex, decorator) {
187
187
  return function(target, key) {
188
188
  decorator(target, key, paramIndex);
189
189
  };
@@ -206,12 +206,12 @@ class ZRomulatorConfigsController {
206
206
  }
207
207
  _ts_decorate$e([
208
208
  common.Get(),
209
- _ts_param$7(0, common.Query()),
210
- _ts_metadata$8("design:type", Function),
211
- _ts_metadata$8("design:paramtypes", [
209
+ _ts_param$8(0, common.Query()),
210
+ _ts_metadata$9("design:type", Function),
211
+ _ts_metadata$9("design:paramtypes", [
212
212
  typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
213
213
  ]),
214
- _ts_metadata$8("design:returntype", Promise)
214
+ _ts_metadata$9("design:returntype", Promise)
215
215
  ], ZRomulatorConfigsController.prototype, "list", null);
216
216
  _ts_decorate$e([
217
217
  swagger.ApiParam({
@@ -230,14 +230,14 @@ _ts_decorate$e([
230
230
  skipNullProperties: false,
231
231
  skipUndefinedProperties: false
232
232
  })),
233
- _ts_param$7(0, common.Param("identification")),
234
- _ts_param$7(1, common.Body()),
235
- _ts_metadata$8("design:type", Function),
236
- _ts_metadata$8("design:paramtypes", [
233
+ _ts_param$8(0, common.Param("identification")),
234
+ _ts_param$8(1, common.Body()),
235
+ _ts_metadata$9("design:type", Function),
236
+ _ts_metadata$9("design:paramtypes", [
237
237
  typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
238
238
  typeof ZRomulatorConfigUpdateDto === "undefined" ? Object : ZRomulatorConfigUpdateDto
239
239
  ]),
240
- _ts_metadata$8("design:returntype", Promise)
240
+ _ts_metadata$9("design:returntype", Promise)
241
241
  ], ZRomulatorConfigsController.prototype, "update", null);
242
242
  _ts_decorate$e([
243
243
  swagger.ApiParam({
@@ -246,18 +246,18 @@ _ts_decorate$e([
246
246
  description: "The id of the config"
247
247
  }),
248
248
  common.Get(":identification"),
249
- _ts_param$7(0, common.Param("identification")),
250
- _ts_metadata$8("design:type", Function),
251
- _ts_metadata$8("design:paramtypes", [
249
+ _ts_param$8(0, common.Param("identification")),
250
+ _ts_metadata$9("design:type", Function),
251
+ _ts_metadata$9("design:paramtypes", [
252
252
  typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
253
253
  ]),
254
- _ts_metadata$8("design:returntype", Promise)
254
+ _ts_metadata$9("design:returntype", Promise)
255
255
  ], ZRomulatorConfigsController.prototype, "get", null);
256
256
  ZRomulatorConfigsController = _ts_decorate$e([
257
257
  common.Controller("configs"),
258
- _ts_param$7(0, common.Inject(ZRomulatorConfigsToken)),
259
- _ts_metadata$8("design:type", Function),
260
- _ts_metadata$8("design:paramtypes", [
258
+ _ts_param$8(0, common.Inject(ZRomulatorConfigsToken)),
259
+ _ts_metadata$9("design:type", Function),
260
+ _ts_metadata$9("design:paramtypes", [
261
261
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
262
262
  ])
263
263
  ], ZRomulatorConfigsController);
@@ -297,7 +297,7 @@ function _ts_decorate$c(decorators, target, key, desc) {
297
297
  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;
298
298
  return c > 3 && r && Object.defineProperty(target, key, r), r;
299
299
  }
300
- function _ts_metadata$7(k, v) {
300
+ function _ts_metadata$8(k, v) {
301
301
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
302
302
  }
303
303
  const KnownSystem = "@zthunworks/romulator/known-system";
@@ -395,45 +395,45 @@ const KnownSystem = "@zthunworks/romulator/known-system";
395
395
  }
396
396
  _ts_decorate$c([
397
397
  helpfulReflection.ZTag(KnownSystem),
398
- _ts_metadata$7("design:type", Function),
399
- _ts_metadata$7("design:paramtypes", []),
400
- _ts_metadata$7("design:returntype", void 0)
398
+ _ts_metadata$8("design:type", Function),
399
+ _ts_metadata$8("design:paramtypes", []),
400
+ _ts_metadata$8("design:returntype", void 0)
401
401
  ], ZRomulatorSystemKnown, "nes", null);
402
402
  _ts_decorate$c([
403
403
  helpfulReflection.ZTag(KnownSystem),
404
- _ts_metadata$7("design:type", Function),
405
- _ts_metadata$7("design:paramtypes", []),
406
- _ts_metadata$7("design:returntype", void 0)
404
+ _ts_metadata$8("design:type", Function),
405
+ _ts_metadata$8("design:paramtypes", []),
406
+ _ts_metadata$8("design:returntype", void 0)
407
407
  ], ZRomulatorSystemKnown, "snes", null);
408
408
  _ts_decorate$c([
409
409
  helpfulReflection.ZTag(KnownSystem),
410
- _ts_metadata$7("design:type", Function),
411
- _ts_metadata$7("design:paramtypes", []),
412
- _ts_metadata$7("design:returntype", void 0)
410
+ _ts_metadata$8("design:type", Function),
411
+ _ts_metadata$8("design:paramtypes", []),
412
+ _ts_metadata$8("design:returntype", void 0)
413
413
  ], ZRomulatorSystemKnown, "n64", null);
414
414
  _ts_decorate$c([
415
415
  helpfulReflection.ZTag(KnownSystem),
416
- _ts_metadata$7("design:type", Function),
417
- _ts_metadata$7("design:paramtypes", []),
418
- _ts_metadata$7("design:returntype", void 0)
416
+ _ts_metadata$8("design:type", Function),
417
+ _ts_metadata$8("design:paramtypes", []),
418
+ _ts_metadata$8("design:returntype", void 0)
419
419
  ], ZRomulatorSystemKnown, "gc", null);
420
420
  _ts_decorate$c([
421
421
  helpfulReflection.ZTag(KnownSystem),
422
- _ts_metadata$7("design:type", Function),
423
- _ts_metadata$7("design:paramtypes", []),
424
- _ts_metadata$7("design:returntype", void 0)
422
+ _ts_metadata$8("design:type", Function),
423
+ _ts_metadata$8("design:paramtypes", []),
424
+ _ts_metadata$8("design:returntype", void 0)
425
425
  ], ZRomulatorSystemKnown, "wii", null);
426
426
  _ts_decorate$c([
427
427
  helpfulReflection.ZTag(KnownSystem),
428
- _ts_metadata$7("design:type", Function),
429
- _ts_metadata$7("design:paramtypes", []),
430
- _ts_metadata$7("design:returntype", void 0)
428
+ _ts_metadata$8("design:type", Function),
429
+ _ts_metadata$8("design:paramtypes", []),
430
+ _ts_metadata$8("design:returntype", void 0)
431
431
  ], ZRomulatorSystemKnown, "wiiu", null);
432
432
  _ts_decorate$c([
433
433
  helpfulReflection.ZTag(KnownSystem),
434
- _ts_metadata$7("design:type", Function),
435
- _ts_metadata$7("design:paramtypes", []),
436
- _ts_metadata$7("design:returntype", void 0)
434
+ _ts_metadata$8("design:type", Function),
435
+ _ts_metadata$8("design:paramtypes", []),
436
+ _ts_metadata$8("design:returntype", void 0)
437
437
  ], ZRomulatorSystemKnown, "switch", null);
438
438
 
439
439
  /**
@@ -462,10 +462,10 @@ function _ts_decorate$b(decorators, target, key, desc) {
462
462
  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;
463
463
  return c > 3 && r && Object.defineProperty(target, key, r), r;
464
464
  }
465
- function _ts_metadata$6(k, v) {
465
+ function _ts_metadata$7(k, v) {
466
466
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
467
467
  }
468
- function _ts_param$6(paramIndex, decorator) {
468
+ function _ts_param$7(paramIndex, decorator) {
469
469
  return function(target, key) {
470
470
  decorator(target, key, paramIndex);
471
471
  };
@@ -523,11 +523,11 @@ class ZRomulatorGamesService {
523
523
  }
524
524
  ZRomulatorGamesService = _ts_decorate$b([
525
525
  common.Injectable(),
526
- _ts_param$6(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
527
- _ts_param$6(1, common.Inject(ZRomulatorConfigsToken)),
528
- _ts_param$6(2, common.Inject(lumberjackyNest.ZLoggerToken)),
529
- _ts_metadata$6("design:type", Function),
530
- _ts_metadata$6("design:paramtypes", [
526
+ _ts_param$7(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
527
+ _ts_param$7(1, common.Inject(ZRomulatorConfigsToken)),
528
+ _ts_param$7(2, common.Inject(lumberjackyNest.ZLoggerToken)),
529
+ _ts_metadata$7("design:type", Function),
530
+ _ts_metadata$7("design:paramtypes", [
531
531
  typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
532
532
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
533
533
  typeof IZLogger === "undefined" ? Object : IZLogger
@@ -540,10 +540,10 @@ function _ts_decorate$a(decorators, target, key, desc) {
540
540
  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;
541
541
  return c > 3 && r && Object.defineProperty(target, key, r), r;
542
542
  }
543
- function _ts_metadata$5(k, v) {
543
+ function _ts_metadata$6(k, v) {
544
544
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
545
545
  }
546
- function _ts_param$5(paramIndex, decorator) {
546
+ function _ts_param$6(paramIndex, decorator) {
547
547
  return function(target, key) {
548
548
  decorator(target, key, paramIndex);
549
549
  };
@@ -562,27 +562,27 @@ class ZRomulatorGamesController {
562
562
  }
563
563
  _ts_decorate$a([
564
564
  common.Get(),
565
- _ts_param$5(0, common.Query()),
566
- _ts_metadata$5("design:type", Function),
567
- _ts_metadata$5("design:paramtypes", [
565
+ _ts_param$6(0, common.Query()),
566
+ _ts_metadata$6("design:type", Function),
567
+ _ts_metadata$6("design:paramtypes", [
568
568
  typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
569
569
  ]),
570
- _ts_metadata$5("design:returntype", typeof Promise === "undefined" ? Object : Promise)
570
+ _ts_metadata$6("design:returntype", typeof Promise === "undefined" ? Object : Promise)
571
571
  ], ZRomulatorGamesController.prototype, "list", null);
572
572
  _ts_decorate$a([
573
573
  common.Get(":identification"),
574
- _ts_param$5(0, common.Param("identification")),
575
- _ts_metadata$5("design:type", Function),
576
- _ts_metadata$5("design:paramtypes", [
574
+ _ts_param$6(0, common.Param("identification")),
575
+ _ts_metadata$6("design:type", Function),
576
+ _ts_metadata$6("design:paramtypes", [
577
577
  String
578
578
  ]),
579
- _ts_metadata$5("design:returntype", void 0)
579
+ _ts_metadata$6("design:returntype", void 0)
580
580
  ], ZRomulatorGamesController.prototype, "get", null);
581
581
  ZRomulatorGamesController = _ts_decorate$a([
582
582
  common.Controller("games"),
583
- _ts_param$5(0, common.Inject(ZRomulatorGamesToken)),
584
- _ts_metadata$5("design:type", Function),
585
- _ts_metadata$5("design:paramtypes", [
583
+ _ts_param$6(0, common.Inject(ZRomulatorGamesToken)),
584
+ _ts_metadata$6("design:type", Function),
585
+ _ts_metadata$6("design:paramtypes", [
586
586
  typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
587
587
  ])
588
588
  ], ZRomulatorGamesController);
@@ -620,10 +620,10 @@ function _ts_decorate$8(decorators, target, key, desc) {
620
620
  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;
621
621
  return c > 3 && r && Object.defineProperty(target, key, r), r;
622
622
  }
623
- function _ts_metadata$4(k, v) {
623
+ function _ts_metadata$5(k, v) {
624
624
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
625
625
  }
626
- function _ts_param$4(paramIndex, decorator) {
626
+ function _ts_param$5(paramIndex, decorator) {
627
627
  return function(target, key) {
628
628
  decorator(target, key, paramIndex);
629
629
  };
@@ -648,7 +648,6 @@ class ZRomulatorFilesService {
648
648
  ...slugs.map((s)=>`${s}/*.*`)
649
649
  ];
650
650
  this._systems = Object.values(romulatorClient.ZRomulatorSystemId);
651
- this.seed();
652
651
  }
653
652
  async gamesFolder() {
654
653
  const config = await this._configs.get(romulatorClient.ZRomulatorConfigId.Games);
@@ -676,6 +675,12 @@ class ZRomulatorFilesService {
676
675
  const nodes = await repository.retrieve(request);
677
676
  return path == null ? nodes : helpfulFn.firstDefined(null, lodashEs.first(nodes));
678
677
  }
678
+ async init() {
679
+ await this.seed();
680
+ }
681
+ async dispose() {
682
+ await this._repository.reset();
683
+ }
679
684
  async seed() {
680
685
  const path = await this.gamesFolder();
681
686
  if (this._repository.path !== path) {
@@ -708,10 +713,10 @@ class ZRomulatorFilesService {
708
713
  }
709
714
  ZRomulatorFilesService = _ts_decorate$8([
710
715
  common.Injectable(),
711
- _ts_param$4(0, common.Inject(ZRomulatorConfigsToken)),
712
- _ts_param$4(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
713
- _ts_metadata$4("design:type", Function),
714
- _ts_metadata$4("design:paramtypes", [
716
+ _ts_param$5(0, common.Inject(ZRomulatorConfigsToken)),
717
+ _ts_param$5(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
718
+ _ts_metadata$5("design:type", Function),
719
+ _ts_metadata$5("design:paramtypes", [
715
720
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
716
721
  typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService
717
722
  ])
@@ -723,7 +728,25 @@ function _ts_decorate$7(decorators, target, key, desc) {
723
728
  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;
724
729
  return c > 3 && r && Object.defineProperty(target, key, r), r;
725
730
  }
731
+ function _ts_metadata$4(k, v) {
732
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
733
+ }
734
+ function _ts_param$4(paramIndex, decorator) {
735
+ return function(target, key) {
736
+ decorator(target, key, paramIndex);
737
+ };
738
+ }
726
739
  class ZRomulatorFilesModule {
740
+ _files;
741
+ constructor(_files){
742
+ this._files = _files;
743
+ }
744
+ async onModuleInit() {
745
+ await this._files.init();
746
+ }
747
+ async onModuleDestroy() {
748
+ await this._files.dispose();
749
+ }
727
750
  }
728
751
  ZRomulatorFilesModule = _ts_decorate$7([
729
752
  common.Module({
@@ -740,7 +763,12 @@ ZRomulatorFilesModule = _ts_decorate$7([
740
763
  exports: [
741
764
  ZRomulatorFilesToken
742
765
  ]
743
- })
766
+ }),
767
+ _ts_param$4(0, common.Inject(ZRomulatorFilesToken)),
768
+ _ts_metadata$4("design:type", Function),
769
+ _ts_metadata$4("design:paramtypes", [
770
+ typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService
771
+ ])
744
772
  ], ZRomulatorFilesModule);
745
773
 
746
774
  function _ts_decorate$6(decorators, target, key, desc) {