@zthun/romulator-api 1.7.0 → 1.8.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.
@@ -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,24 @@ 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
+ * Gets the contents of the file.
76
+ *
77
+ * @param info -
78
+ * The file to read and store.
79
+ *
80
+ * @returns
81
+ * The buffer of data that the file contained.
82
+ */
83
+ read(info: IZFileSystemNode): Promise<Buffer>;
84
+ /**
85
+ * Initializes the file repository.
86
+ */
87
+ init(): Promise<void>;
88
+ /**
89
+ * Cleans up internal resources.
90
+ */
91
+ dispose(): Promise<void>;
74
92
  }
75
93
  export declare class ZRomulatorFilesService implements IZRomulatorFilesService {
76
94
  private readonly _configs;
@@ -79,6 +97,7 @@ export declare class ZRomulatorFilesService implements IZRomulatorFilesService {
79
97
  private static readonly InfoFolderName;
80
98
  private _repository;
81
99
  private _folderStream;
100
+ private _fileStream;
82
101
  private _globs;
83
102
  private _systems;
84
103
  constructor(_configs: IZRomulatorConfigsService, _fileSystem: IZFileSystemService);
@@ -86,6 +105,8 @@ export declare class ZRomulatorFilesService implements IZRomulatorFilesService {
86
105
  private mediaFolder;
87
106
  private infoFolder;
88
107
  private contents;
108
+ init(): Promise<void>;
109
+ dispose(): Promise<void>;
89
110
  seed(): Promise<IZFileRepository>;
90
111
  media(): Promise<IZFileSystemNode[]>;
91
112
  media(path: string): Promise<IZFileSystemNode | null>;
@@ -93,4 +114,7 @@ export declare class ZRomulatorFilesService implements IZRomulatorFilesService {
93
114
  systems(path: string): Promise<IZFileSystemNode | null>;
94
115
  info(): Promise<IZFileSystemNode[]>;
95
116
  info(path: string): Promise<IZFileSystemNode | null>;
117
+ games(): Promise<IZFileSystemNode[]>;
118
+ games(path: string): Promise<IZFileSystemNode | null>;
119
+ read(node: IZFileSystemNode): Promise<Buffer>;
96
120
  }
@@ -1,5 +1,5 @@
1
1
  import { IZFileSystemService } from '@zthun/crumbtrail-fs';
2
- import { IZDataRequest, IZPage } from '@zthun/helpful-query';
2
+ import { IZDataMatch, IZDataRequest, IZPage } from '@zthun/helpful-query';
3
3
  import { IZLogger } from '@zthun/lumberjacky-log';
4
4
  import { IZRomulatorGame } from '@zthun/romulator-client';
5
5
  import { IZRestfulGet } from '@zthun/webigail-rest';
@@ -8,11 +8,12 @@ export declare const ZRomulatorGamesToken: unique symbol;
8
8
  export interface IZRomulatorGamesService extends IZRestfulGet<IZRomulatorGame> {
9
9
  list(req: IZDataRequest): Promise<IZPage<IZRomulatorGame>>;
10
10
  }
11
- export declare class ZRomulatorGamesService implements IZRomulatorGamesService {
11
+ export declare class ZRomulatorGamesService implements IZRomulatorGamesService, IZDataMatch<IZRomulatorGame, string> {
12
12
  private readonly _file;
13
13
  private readonly _config;
14
14
  private readonly _logger;
15
15
  constructor(_file: IZFileSystemService, _config: IZRomulatorConfigsService, logger: IZLogger);
16
16
  list(req: IZDataRequest): Promise<IZPage<IZRomulatorGame>>;
17
17
  get(id: string): Promise<IZRomulatorGame>;
18
+ match(data: IZRomulatorGame, filter: string): boolean;
18
19
  }
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";
@@ -322,7 +322,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
322
322
  * A {@link ZRomulatorSystemBuilder} instance that has
323
323
  * built the nes.
324
324
  */ static nes() {
325
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).console().name("Nintendo Entertainment System").generation(3).build();
325
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).name("Nintendo Entertainment System").build();
326
326
  }
327
327
  /**
328
328
  * Creates a system that represents the Super
@@ -331,7 +331,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
331
331
  * @returns
332
332
  * This instance.
333
333
  */ static snes() {
334
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).console().name("Super Nintendo Entertainment System").generation(4).build();
334
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).name("Super Nintendo Entertainment System").build();
335
335
  }
336
336
  /**
337
337
  * Creates a system that represents the Nintendo
@@ -340,7 +340,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
340
340
  * @returns
341
341
  * This instance.
342
342
  */ static n64() {
343
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).console().name("Nintendo 64").generation(5).build();
343
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).name("Nintendo 64").build();
344
344
  }
345
345
  /**
346
346
  * Creates a system that represents the Nintendo
@@ -349,7 +349,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
349
349
  * @returns
350
350
  * This instance.
351
351
  */ static gc() {
352
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).console().name("Nintendo GameCube").generation(6).build();
352
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).name("Nintendo GameCube").build();
353
353
  }
354
354
  /**
355
355
  * Creates a system that represents the Nintendo
@@ -358,7 +358,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
358
358
  * @returns
359
359
  * This instance.
360
360
  */ static wii() {
361
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).console().name("Nintendo Wii").generation(7).build();
361
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).name("Nintendo Wii").build();
362
362
  }
363
363
  /**
364
364
  * Creates a system that represents the Nintendo
@@ -367,7 +367,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
367
367
  * @returns
368
368
  * This instance.
369
369
  */ static wiiu() {
370
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).console().name("Nintendo Wii U").generation(8).build();
370
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).name("Nintendo Wii U").build();
371
371
  }
372
372
  /**
373
373
  * Creates a system that represents the Nintendo
@@ -376,7 +376,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
376
376
  * @returns
377
377
  * This instance.
378
378
  */ static switch() {
379
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).console().name("Nintendo Switch").generation(9).build();
379
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).name("Nintendo Switch").build();
380
380
  }
381
381
  /**
382
382
  * Creates a system from an id slug.
@@ -395,77 +395,57 @@ 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
- /**
440
- * A data match function which matches a string (search) filter
441
- * to a game's name, system slug, or system name.
442
- */ class ZRomulatorDataMatchGame {
443
- match(data, filter) {
444
- const needle = filter?.trim().toLowerCase();
445
- const { name = "", system = "" } = data;
446
- const target = ZRomulatorSystemKnown.from(system);
447
- const systemName = helpfulFn.firstTruthy("", target?.name);
448
- if (!needle?.length) {
449
- return true;
450
- }
451
- return [
452
- name,
453
- system,
454
- systemName
455
- ].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
456
- }
457
- }
458
-
459
439
  function _ts_decorate$b(decorators, target, key, desc) {
460
440
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
461
441
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
462
442
  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
443
  return c > 3 && r && Object.defineProperty(target, key, r), r;
464
444
  }
465
- function _ts_metadata$6(k, v) {
445
+ function _ts_metadata$7(k, v) {
466
446
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
467
447
  }
468
- function _ts_param$6(paramIndex, decorator) {
448
+ function _ts_param$7(paramIndex, decorator) {
469
449
  return function(target, key) {
470
450
  decorator(target, key, paramIndex);
471
451
  };
@@ -504,7 +484,7 @@ class ZRomulatorGamesService {
504
484
  const id = `${dir}-${lodashEs.kebabCase(file)}`;
505
485
  return new romulatorClient.ZRomulatorGameBuilder().id(id).system(dir).file(path).name(file).build();
506
486
  });
507
- const options = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new ZRomulatorDataMatchGame()).build();
487
+ const options = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(this).build();
508
488
  const source = new helpfulQuery.ZDataSourceStatic(games, options);
509
489
  const $sort = new helpfulQuery.ZSortBuilder().sorts(helpfulFn.firstDefined([], req.sort)).ascending("system").ascending("name").build();
510
490
  const $request = new helpfulQuery.ZDataRequestBuilder().copy(req).sort($sort).build();
@@ -520,14 +500,28 @@ class ZRomulatorGamesService {
520
500
  }
521
501
  return match;
522
502
  }
503
+ match(data, filter) {
504
+ const needle = filter?.trim().toLowerCase();
505
+ const { name = "", system = "" } = data;
506
+ const target = ZRomulatorSystemKnown.from(system);
507
+ const systemName = helpfulFn.firstTruthy("", target?.name);
508
+ if (!needle?.length) {
509
+ return true;
510
+ }
511
+ return [
512
+ name,
513
+ system,
514
+ systemName
515
+ ].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
516
+ }
523
517
  }
524
518
  ZRomulatorGamesService = _ts_decorate$b([
525
519
  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", [
520
+ _ts_param$7(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
521
+ _ts_param$7(1, common.Inject(ZRomulatorConfigsToken)),
522
+ _ts_param$7(2, common.Inject(lumberjackyNest.ZLoggerToken)),
523
+ _ts_metadata$7("design:type", Function),
524
+ _ts_metadata$7("design:paramtypes", [
531
525
  typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
532
526
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
533
527
  typeof IZLogger === "undefined" ? Object : IZLogger
@@ -540,10 +534,10 @@ function _ts_decorate$a(decorators, target, key, desc) {
540
534
  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
535
  return c > 3 && r && Object.defineProperty(target, key, r), r;
542
536
  }
543
- function _ts_metadata$5(k, v) {
537
+ function _ts_metadata$6(k, v) {
544
538
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
545
539
  }
546
- function _ts_param$5(paramIndex, decorator) {
540
+ function _ts_param$6(paramIndex, decorator) {
547
541
  return function(target, key) {
548
542
  decorator(target, key, paramIndex);
549
543
  };
@@ -562,27 +556,27 @@ class ZRomulatorGamesController {
562
556
  }
563
557
  _ts_decorate$a([
564
558
  common.Get(),
565
- _ts_param$5(0, common.Query()),
566
- _ts_metadata$5("design:type", Function),
567
- _ts_metadata$5("design:paramtypes", [
559
+ _ts_param$6(0, common.Query()),
560
+ _ts_metadata$6("design:type", Function),
561
+ _ts_metadata$6("design:paramtypes", [
568
562
  typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
569
563
  ]),
570
- _ts_metadata$5("design:returntype", typeof Promise === "undefined" ? Object : Promise)
564
+ _ts_metadata$6("design:returntype", typeof Promise === "undefined" ? Object : Promise)
571
565
  ], ZRomulatorGamesController.prototype, "list", null);
572
566
  _ts_decorate$a([
573
567
  common.Get(":identification"),
574
- _ts_param$5(0, common.Param("identification")),
575
- _ts_metadata$5("design:type", Function),
576
- _ts_metadata$5("design:paramtypes", [
568
+ _ts_param$6(0, common.Param("identification")),
569
+ _ts_metadata$6("design:type", Function),
570
+ _ts_metadata$6("design:paramtypes", [
577
571
  String
578
572
  ]),
579
- _ts_metadata$5("design:returntype", void 0)
573
+ _ts_metadata$6("design:returntype", void 0)
580
574
  ], ZRomulatorGamesController.prototype, "get", null);
581
575
  ZRomulatorGamesController = _ts_decorate$a([
582
576
  common.Controller("games"),
583
- _ts_param$5(0, common.Inject(ZRomulatorGamesToken)),
584
- _ts_metadata$5("design:type", Function),
585
- _ts_metadata$5("design:paramtypes", [
577
+ _ts_param$6(0, common.Inject(ZRomulatorGamesToken)),
578
+ _ts_metadata$6("design:type", Function),
579
+ _ts_metadata$6("design:paramtypes", [
586
580
  typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
587
581
  ])
588
582
  ], ZRomulatorGamesController);
@@ -620,10 +614,10 @@ function _ts_decorate$8(decorators, target, key, desc) {
620
614
  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
615
  return c > 3 && r && Object.defineProperty(target, key, r), r;
622
616
  }
623
- function _ts_metadata$4(k, v) {
617
+ function _ts_metadata$5(k, v) {
624
618
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
625
619
  }
626
- function _ts_param$4(paramIndex, decorator) {
620
+ function _ts_param$5(paramIndex, decorator) {
627
621
  return function(target, key) {
628
622
  decorator(target, key, paramIndex);
629
623
  };
@@ -636,6 +630,7 @@ class ZRomulatorFilesService {
636
630
  static InfoFolderName = ".info";
637
631
  _repository = new crumbtrailFs.ZFileRepository();
638
632
  _folderStream = new crumbtrailFs.ZStreamFolder();
633
+ _fileStream = new crumbtrailFs.ZStreamFile();
639
634
  _globs;
640
635
  _systems;
641
636
  constructor(_configs, _fileSystem){
@@ -648,7 +643,6 @@ class ZRomulatorFilesService {
648
643
  ...slugs.map((s)=>`${s}/*.*`)
649
644
  ];
650
645
  this._systems = Object.values(romulatorClient.ZRomulatorSystemId);
651
- this.seed();
652
646
  }
653
647
  async gamesFolder() {
654
648
  const config = await this._configs.get(romulatorClient.ZRomulatorConfigId.Games);
@@ -665,17 +659,26 @@ class ZRomulatorFilesService {
665
659
  const gamesFolder = await this.gamesFolder();
666
660
  return node_path.resolve(gamesFolder, ZRomulatorFilesService.InfoFolderName);
667
661
  }
668
- async contents(root, path) {
662
+ async contents(roots, path) {
669
663
  const repository = await this.seed();
670
- const prefix = lodashEs.trimEnd(root, "/");
671
- const folder = `${prefix}${node_path.sep}`;
672
- let filter = new helpfulQuery.ZFilterBinaryBuilder().subject("path");
673
- filter = path == null ? filter.startsWith().value(folder) : filter.equal().value(node_path.resolve(folder, path));
664
+ const folders = lodashEs.castArray(roots).map((root)=>`${lodashEs.trimEnd(root, "/")}/`);
665
+ const byPaths = folders.map((folder)=>{
666
+ const byPath = new helpfulQuery.ZFilterBinaryBuilder().subject("path");
667
+ const pathFilter = path == null ? byPath.startsWith().value(folder) : byPath.equal().value(node_path.resolve(folder, path));
668
+ return pathFilter.build();
669
+ });
670
+ const filter = byPaths.length > 1 ? new helpfulQuery.ZFilterLogicBuilder().or().clauses(byPaths).build() : lodashEs.first(byPaths);
674
671
  const sort = new helpfulQuery.ZSortBuilder().ascending("path").build();
675
- const request = new helpfulQuery.ZDataRequestBuilder().filter(filter.build()).sort(sort).build();
672
+ const request = new helpfulQuery.ZDataRequestBuilder().filter(filter).sort(sort).build();
676
673
  const nodes = await repository.retrieve(request);
677
674
  return path == null ? nodes : helpfulFn.firstDefined(null, lodashEs.first(nodes));
678
675
  }
676
+ async init() {
677
+ await this.seed();
678
+ }
679
+ async dispose() {
680
+ await this._repository.reset();
681
+ }
679
682
  async seed() {
680
683
  const path = await this.gamesFolder();
681
684
  if (this._repository.path !== path) {
@@ -698,20 +701,28 @@ class ZRomulatorFilesService {
698
701
  const games = await this.gamesFolder();
699
702
  const folders = path == null ? this._systems.map((s)=>`${s}/`) : node_path.resolve(games, path);
700
703
  const items = await this._fileSystem.search(folders, {
701
- cwd: games
704
+ cwd: games,
705
+ stat: false
702
706
  });
703
707
  return path == null ? items : helpfulFn.firstDefined(null, lodashEs.first(items));
704
708
  }
705
709
  async info(path) {
706
710
  return this.contents(await this.infoFolder(), path);
707
711
  }
712
+ async games(path) {
713
+ const root = await this.gamesFolder();
714
+ return this.contents(this._systems.map((s)=>node_path.resolve(root, s)), path);
715
+ }
716
+ read(node) {
717
+ return this._fileStream.read(node.path);
718
+ }
708
719
  }
709
720
  ZRomulatorFilesService = _ts_decorate$8([
710
721
  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", [
722
+ _ts_param$5(0, common.Inject(ZRomulatorConfigsToken)),
723
+ _ts_param$5(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
724
+ _ts_metadata$5("design:type", Function),
725
+ _ts_metadata$5("design:paramtypes", [
715
726
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
716
727
  typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService
717
728
  ])
@@ -723,7 +734,25 @@ function _ts_decorate$7(decorators, target, key, desc) {
723
734
  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
735
  return c > 3 && r && Object.defineProperty(target, key, r), r;
725
736
  }
737
+ function _ts_metadata$4(k, v) {
738
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
739
+ }
740
+ function _ts_param$4(paramIndex, decorator) {
741
+ return function(target, key) {
742
+ decorator(target, key, paramIndex);
743
+ };
744
+ }
726
745
  class ZRomulatorFilesModule {
746
+ _files;
747
+ constructor(_files){
748
+ this._files = _files;
749
+ }
750
+ async onModuleInit() {
751
+ await this._files.init();
752
+ }
753
+ async onModuleDestroy() {
754
+ await this._files.dispose();
755
+ }
727
756
  }
728
757
  ZRomulatorFilesModule = _ts_decorate$7([
729
758
  common.Module({
@@ -740,7 +769,12 @@ ZRomulatorFilesModule = _ts_decorate$7([
740
769
  exports: [
741
770
  ZRomulatorFilesToken
742
771
  ]
743
- })
772
+ }),
773
+ _ts_param$4(0, common.Inject(ZRomulatorFilesToken)),
774
+ _ts_metadata$4("design:type", Function),
775
+ _ts_metadata$4("design:paramtypes", [
776
+ typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService
777
+ ])
744
778
  ], ZRomulatorFilesModule);
745
779
 
746
780
  function _ts_decorate$6(decorators, target, key, desc) {
@@ -1038,11 +1072,6 @@ class ZRomulatorSystemsService {
1038
1072
  _files;
1039
1073
  logger;
1040
1074
  _logger;
1041
- _fileStream = new crumbtrailFs.ZStreamFile({
1042
- cache: {
1043
- maxFiles: Object.keys(romulatorClient.ZRomulatorSystemId).length + 1
1044
- }
1045
- });
1046
1075
  constructor(_files, logger){
1047
1076
  this._files = _files;
1048
1077
  this.logger = logger;
@@ -1089,7 +1118,7 @@ class ZRomulatorSystemsService {
1089
1118
  return system.build();
1090
1119
  }
1091
1120
  try {
1092
- const contents = await this._fileStream.read(info.path);
1121
+ const contents = await this._files.read(info);
1093
1122
  const json = JSON.parse(contents.toString());
1094
1123
  return system.assign(json).redact().build();
1095
1124
  } catch (e) {