@zthun/romulator-api 1.5.0 → 1.6.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
@@ -16,25 +16,26 @@ const node_path = require('node:path');
16
16
  const node_os = require('node:os');
17
17
  const helpfulReflection = require('@zthun/helpful-reflection');
18
18
  require('reflect-metadata');
19
+ const crumbtrailFs = require('@zthun/crumbtrail-fs');
20
+ const node_process = require('node:process');
19
21
  const webigailHttp = require('@zthun/webigail-http');
20
22
  const webigailUrl = require('@zthun/webigail-url');
21
23
  const mimeTypes = require('mime-types');
22
24
  const node_fs = require('node:fs');
23
- const node_process = require('node:process');
24
25
 
25
- function _ts_decorate$e(decorators, target, key, desc) {
26
+ function _ts_decorate$g(decorators, target, key, desc) {
26
27
  var c = arguments.length, r = c < 3 ? target : desc, d;
27
28
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
28
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;
29
30
  return c > 3 && r && Object.defineProperty(target, key, r), r;
30
31
  }
31
- function _ts_metadata$9(k, v) {
32
+ function _ts_metadata$a(k, v) {
32
33
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
34
  }
34
35
  class ZRomulatorConfigUpdateDto {
35
36
  contents;
36
37
  }
37
- _ts_decorate$e([
38
+ _ts_decorate$g([
38
39
  swagger.ApiProperty({
39
40
  type: "object",
40
41
  properties: {}
@@ -46,7 +47,7 @@ _ts_decorate$e([
46
47
  message: "The contents of the config must be an object "
47
48
  }),
48
49
  classValidator.IsNotEmptyObject(),
49
- _ts_metadata$9("design:type", typeof T === "undefined" ? Object : T)
50
+ _ts_metadata$a("design:type", typeof T === "undefined" ? Object : T)
50
51
  ], ZRomulatorConfigUpdateDto.prototype, "contents", void 0);
51
52
 
52
53
  class ZDir {
@@ -61,8 +62,7 @@ class ZDir {
61
62
  class ZRomulatorConfigKnown {
62
63
  static all() {
63
64
  return [
64
- ZRomulatorConfigKnown.games(),
65
- ZRomulatorConfigKnown.media()
65
+ ZRomulatorConfigKnown.games()
66
66
  ];
67
67
  }
68
68
  static create(id) {
@@ -72,21 +72,18 @@ class ZRomulatorConfigKnown {
72
72
  static games() {
73
73
  return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Games).name("Game Settings").description("Modify where your games are stored and related settings").avatar("gamepad").metadata(romulatorClient.ZRomulatorConfigGamesMetadata.all()).build();
74
74
  }
75
- static media() {
76
- return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Media).name("Media Settings").description("Modify where media is stored and what media to retrieve").avatar("image").metadata(romulatorClient.ZRomulatorConfigMediaMetadata.all()).build();
77
- }
78
75
  }
79
76
 
80
- function _ts_decorate$d(decorators, target, key, desc) {
77
+ function _ts_decorate$f(decorators, target, key, desc) {
81
78
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
82
79
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
83
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;
84
81
  return c > 3 && r && Object.defineProperty(target, key, r), r;
85
82
  }
86
- function _ts_metadata$8(k, v) {
83
+ function _ts_metadata$9(k, v) {
87
84
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
88
85
  }
89
- function _ts_param$7(paramIndex, decorator) {
86
+ function _ts_param$8(paramIndex, decorator) {
90
87
  return function(target, key) {
91
88
  decorator(target, key, paramIndex);
92
89
  };
@@ -168,25 +165,25 @@ class ZRomulatorConfigsService {
168
165
  return config;
169
166
  }
170
167
  }
171
- ZRomulatorConfigsService = _ts_decorate$d([
168
+ ZRomulatorConfigsService = _ts_decorate$f([
172
169
  common.Injectable(),
173
- _ts_param$7(0, common.Inject(lumberjackyNest.ZLoggerToken)),
174
- _ts_metadata$8("design:type", Function),
175
- _ts_metadata$8("design:paramtypes", [
170
+ _ts_param$8(0, common.Inject(lumberjackyNest.ZLoggerToken)),
171
+ _ts_metadata$9("design:type", Function),
172
+ _ts_metadata$9("design:paramtypes", [
176
173
  typeof IZLogger === "undefined" ? Object : IZLogger
177
174
  ])
178
175
  ], ZRomulatorConfigsService);
179
176
 
180
- function _ts_decorate$c(decorators, target, key, desc) {
177
+ function _ts_decorate$e(decorators, target, key, desc) {
181
178
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
182
179
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
183
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;
184
181
  return c > 3 && r && Object.defineProperty(target, key, r), r;
185
182
  }
186
- function _ts_metadata$7(k, v) {
183
+ function _ts_metadata$8(k, v) {
187
184
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
188
185
  }
189
- function _ts_param$6(paramIndex, decorator) {
186
+ function _ts_param$7(paramIndex, decorator) {
190
187
  return function(target, key) {
191
188
  decorator(target, key, paramIndex);
192
189
  };
@@ -207,16 +204,16 @@ class ZRomulatorConfigsController {
207
204
  return await this._configs.get(identification);
208
205
  }
209
206
  }
210
- _ts_decorate$c([
207
+ _ts_decorate$e([
211
208
  common.Get(),
212
- _ts_param$6(0, common.Query()),
213
- _ts_metadata$7("design:type", Function),
214
- _ts_metadata$7("design:paramtypes", [
209
+ _ts_param$7(0, common.Query()),
210
+ _ts_metadata$8("design:type", Function),
211
+ _ts_metadata$8("design:paramtypes", [
215
212
  typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
216
213
  ]),
217
- _ts_metadata$7("design:returntype", Promise)
214
+ _ts_metadata$8("design:returntype", Promise)
218
215
  ], ZRomulatorConfigsController.prototype, "list", null);
219
- _ts_decorate$c([
216
+ _ts_decorate$e([
220
217
  swagger.ApiParam({
221
218
  type: "string",
222
219
  name: "identification",
@@ -233,39 +230,39 @@ _ts_decorate$c([
233
230
  skipNullProperties: false,
234
231
  skipUndefinedProperties: false
235
232
  })),
236
- _ts_param$6(0, common.Param("identification")),
237
- _ts_param$6(1, common.Body()),
238
- _ts_metadata$7("design:type", Function),
239
- _ts_metadata$7("design:paramtypes", [
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", [
240
237
  typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
241
238
  typeof ZRomulatorConfigUpdateDto === "undefined" ? Object : ZRomulatorConfigUpdateDto
242
239
  ]),
243
- _ts_metadata$7("design:returntype", Promise)
240
+ _ts_metadata$8("design:returntype", Promise)
244
241
  ], ZRomulatorConfigsController.prototype, "update", null);
245
- _ts_decorate$c([
242
+ _ts_decorate$e([
246
243
  swagger.ApiParam({
247
244
  type: "string",
248
245
  name: "identification",
249
246
  description: "The id of the config"
250
247
  }),
251
248
  common.Get(":identification"),
252
- _ts_param$6(0, common.Param("identification")),
253
- _ts_metadata$7("design:type", Function),
254
- _ts_metadata$7("design:paramtypes", [
249
+ _ts_param$7(0, common.Param("identification")),
250
+ _ts_metadata$8("design:type", Function),
251
+ _ts_metadata$8("design:paramtypes", [
255
252
  typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
256
253
  ]),
257
- _ts_metadata$7("design:returntype", Promise)
254
+ _ts_metadata$8("design:returntype", Promise)
258
255
  ], ZRomulatorConfigsController.prototype, "get", null);
259
- ZRomulatorConfigsController = _ts_decorate$c([
256
+ ZRomulatorConfigsController = _ts_decorate$e([
260
257
  common.Controller("configs"),
261
- _ts_param$6(0, common.Inject(ZRomulatorConfigsToken)),
262
- _ts_metadata$7("design:type", Function),
263
- _ts_metadata$7("design:paramtypes", [
258
+ _ts_param$7(0, common.Inject(ZRomulatorConfigsToken)),
259
+ _ts_metadata$8("design:type", Function),
260
+ _ts_metadata$8("design:paramtypes", [
264
261
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
265
262
  ])
266
263
  ], ZRomulatorConfigsController);
267
264
 
268
- function _ts_decorate$b(decorators, target, key, desc) {
265
+ function _ts_decorate$d(decorators, target, key, desc) {
269
266
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
270
267
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
271
268
  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;
@@ -273,7 +270,7 @@ function _ts_decorate$b(decorators, target, key, desc) {
273
270
  }
274
271
  class ZRomulatorConfigsModule {
275
272
  }
276
- ZRomulatorConfigsModule = _ts_decorate$b([
273
+ ZRomulatorConfigsModule = _ts_decorate$d([
277
274
  common.Module({
278
275
  imports: [
279
276
  crumbtrailNest.ZFileSystemModule,
@@ -294,13 +291,13 @@ ZRomulatorConfigsModule = _ts_decorate$b([
294
291
  })
295
292
  ], ZRomulatorConfigsModule);
296
293
 
297
- function _ts_decorate$a(decorators, target, key, desc) {
294
+ function _ts_decorate$c(decorators, target, key, desc) {
298
295
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
299
296
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
300
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;
301
298
  return c > 3 && r && Object.defineProperty(target, key, r), r;
302
299
  }
303
- function _ts_metadata$6(k, v) {
300
+ function _ts_metadata$7(k, v) {
304
301
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
305
302
  }
306
303
  const KnownSystem = "@zthunworks/romulator/known-system";
@@ -325,7 +322,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
325
322
  * A {@link ZRomulatorSystemBuilder} instance that has
326
323
  * built the nes.
327
324
  */ static nes() {
328
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).console().name("Nintendo Entertainment System").alias("Famicom").alias("NES").alias("Hyundai Comboy").alias("Samurai Electronic TV Game System").alias("Dendy").generation(3).manufacturer("Nintendo").build();
325
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).console().name("Nintendo Entertainment System").generation(3).build();
329
326
  }
330
327
  /**
331
328
  * Creates a system that represents the Super
@@ -334,7 +331,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
334
331
  * @returns
335
332
  * This instance.
336
333
  */ static snes() {
337
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).console().name("Super Nintendo Entertainment System").alias("Super Nintendo").alias("Super Famicom").alias("SNES").alias("Super NES").alias("Super Comboy").generation(4).manufacturer("Nintendo").build();
334
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).console().name("Super Nintendo Entertainment System").generation(4).build();
338
335
  }
339
336
  /**
340
337
  * Creates a system that represents the Nintendo
@@ -343,7 +340,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
343
340
  * @returns
344
341
  * This instance.
345
342
  */ static n64() {
346
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).console().name("Nintendo 64").alias("N64").alias("Ultra 64").alias("Hyundai Comboy 64").generation(5).manufacturer("Nintendo").build();
343
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).console().name("Nintendo 64").generation(5).build();
347
344
  }
348
345
  /**
349
346
  * Creates a system that represents the Nintendo
@@ -352,7 +349,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
352
349
  * @returns
353
350
  * This instance.
354
351
  */ static gc() {
355
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).console().name("Nintendo GameCube").alias("GameCube").alias("Dolphin").generation(6).manufacturer("Nintendo").manufacturer("Foxconn").build();
352
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).console().name("Nintendo GameCube").generation(6).build();
356
353
  }
357
354
  /**
358
355
  * Creates a system that represents the Nintendo
@@ -361,7 +358,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
361
358
  * @returns
362
359
  * This instance.
363
360
  */ static wii() {
364
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).console().name("Nintendo Wii").alias("Wii").alias("Revolution").generation(7).manufacturer("Foxconn").build();
361
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).console().name("Nintendo Wii").generation(7).build();
365
362
  }
366
363
  /**
367
364
  * Creates a system that represents the Nintendo
@@ -370,7 +367,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
370
367
  * @returns
371
368
  * This instance.
372
369
  */ static wiiu() {
373
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).console().name("Nintendo Wii U").alias("WiiU").alias("Project Cafe").generation(8).manufacturer("Nintendo").manufacturer("Foxconn").manufacturer("Mitsumi").build();
370
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).console().name("Nintendo Wii U").generation(8).build();
374
371
  }
375
372
  /**
376
373
  * Creates a system that represents the Nintendo
@@ -379,7 +376,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
379
376
  * @returns
380
377
  * This instance.
381
378
  */ static switch() {
382
- return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).console().name("Nintendo Switch").alias("Switch").alias("NX").alias("HAC").alias("Odin").generation(9).manufacturer("Foxconn").manufacturer("Hosiden").build();
379
+ return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).console().name("Nintendo Switch").generation(9).build();
383
380
  }
384
381
  /**
385
382
  * Creates a system from an id slug.
@@ -396,47 +393,47 @@ const KnownSystem = "@zthunworks/romulator/known-system";
396
393
  return null;
397
394
  }
398
395
  }
399
- _ts_decorate$a([
396
+ _ts_decorate$c([
400
397
  helpfulReflection.ZTag(KnownSystem),
401
- _ts_metadata$6("design:type", Function),
402
- _ts_metadata$6("design:paramtypes", []),
403
- _ts_metadata$6("design:returntype", void 0)
398
+ _ts_metadata$7("design:type", Function),
399
+ _ts_metadata$7("design:paramtypes", []),
400
+ _ts_metadata$7("design:returntype", void 0)
404
401
  ], ZRomulatorSystemKnown, "nes", null);
405
- _ts_decorate$a([
402
+ _ts_decorate$c([
406
403
  helpfulReflection.ZTag(KnownSystem),
407
- _ts_metadata$6("design:type", Function),
408
- _ts_metadata$6("design:paramtypes", []),
409
- _ts_metadata$6("design:returntype", void 0)
404
+ _ts_metadata$7("design:type", Function),
405
+ _ts_metadata$7("design:paramtypes", []),
406
+ _ts_metadata$7("design:returntype", void 0)
410
407
  ], ZRomulatorSystemKnown, "snes", null);
411
- _ts_decorate$a([
408
+ _ts_decorate$c([
412
409
  helpfulReflection.ZTag(KnownSystem),
413
- _ts_metadata$6("design:type", Function),
414
- _ts_metadata$6("design:paramtypes", []),
415
- _ts_metadata$6("design:returntype", void 0)
410
+ _ts_metadata$7("design:type", Function),
411
+ _ts_metadata$7("design:paramtypes", []),
412
+ _ts_metadata$7("design:returntype", void 0)
416
413
  ], ZRomulatorSystemKnown, "n64", null);
417
- _ts_decorate$a([
414
+ _ts_decorate$c([
418
415
  helpfulReflection.ZTag(KnownSystem),
419
- _ts_metadata$6("design:type", Function),
420
- _ts_metadata$6("design:paramtypes", []),
421
- _ts_metadata$6("design:returntype", void 0)
416
+ _ts_metadata$7("design:type", Function),
417
+ _ts_metadata$7("design:paramtypes", []),
418
+ _ts_metadata$7("design:returntype", void 0)
422
419
  ], ZRomulatorSystemKnown, "gc", null);
423
- _ts_decorate$a([
420
+ _ts_decorate$c([
424
421
  helpfulReflection.ZTag(KnownSystem),
425
- _ts_metadata$6("design:type", Function),
426
- _ts_metadata$6("design:paramtypes", []),
427
- _ts_metadata$6("design:returntype", void 0)
422
+ _ts_metadata$7("design:type", Function),
423
+ _ts_metadata$7("design:paramtypes", []),
424
+ _ts_metadata$7("design:returntype", void 0)
428
425
  ], ZRomulatorSystemKnown, "wii", null);
429
- _ts_decorate$a([
426
+ _ts_decorate$c([
430
427
  helpfulReflection.ZTag(KnownSystem),
431
- _ts_metadata$6("design:type", Function),
432
- _ts_metadata$6("design:paramtypes", []),
433
- _ts_metadata$6("design:returntype", void 0)
428
+ _ts_metadata$7("design:type", Function),
429
+ _ts_metadata$7("design:paramtypes", []),
430
+ _ts_metadata$7("design:returntype", void 0)
434
431
  ], ZRomulatorSystemKnown, "wiiu", null);
435
- _ts_decorate$a([
432
+ _ts_decorate$c([
436
433
  helpfulReflection.ZTag(KnownSystem),
437
- _ts_metadata$6("design:type", Function),
438
- _ts_metadata$6("design:paramtypes", []),
439
- _ts_metadata$6("design:returntype", void 0)
434
+ _ts_metadata$7("design:type", Function),
435
+ _ts_metadata$7("design:paramtypes", []),
436
+ _ts_metadata$7("design:returntype", void 0)
440
437
  ], ZRomulatorSystemKnown, "switch", null);
441
438
 
442
439
  /**
@@ -459,16 +456,16 @@ _ts_decorate$a([
459
456
  }
460
457
  }
461
458
 
462
- function _ts_decorate$9(decorators, target, key, desc) {
459
+ function _ts_decorate$b(decorators, target, key, desc) {
463
460
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
464
461
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
465
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;
466
463
  return c > 3 && r && Object.defineProperty(target, key, r), r;
467
464
  }
468
- function _ts_metadata$5(k, v) {
465
+ function _ts_metadata$6(k, v) {
469
466
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
470
467
  }
471
- function _ts_param$5(paramIndex, decorator) {
468
+ function _ts_param$6(paramIndex, decorator) {
472
469
  return function(target, key) {
473
470
  decorator(target, key, paramIndex);
474
471
  };
@@ -524,29 +521,29 @@ class ZRomulatorGamesService {
524
521
  return match;
525
522
  }
526
523
  }
527
- ZRomulatorGamesService = _ts_decorate$9([
524
+ ZRomulatorGamesService = _ts_decorate$b([
528
525
  common.Injectable(),
529
- _ts_param$5(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
530
- _ts_param$5(1, common.Inject(ZRomulatorConfigsToken)),
531
- _ts_param$5(2, common.Inject(lumberjackyNest.ZLoggerToken)),
532
- _ts_metadata$5("design:type", Function),
533
- _ts_metadata$5("design:paramtypes", [
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", [
534
531
  typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
535
532
  typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
536
533
  typeof IZLogger === "undefined" ? Object : IZLogger
537
534
  ])
538
535
  ], ZRomulatorGamesService);
539
536
 
540
- function _ts_decorate$8(decorators, target, key, desc) {
537
+ function _ts_decorate$a(decorators, target, key, desc) {
541
538
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
542
539
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
543
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;
544
541
  return c > 3 && r && Object.defineProperty(target, key, r), r;
545
542
  }
546
- function _ts_metadata$4(k, v) {
543
+ function _ts_metadata$5(k, v) {
547
544
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
548
545
  }
549
- function _ts_param$4(paramIndex, decorator) {
546
+ function _ts_param$5(paramIndex, decorator) {
550
547
  return function(target, key) {
551
548
  decorator(target, key, paramIndex);
552
549
  };
@@ -563,34 +560,34 @@ class ZRomulatorGamesController {
563
560
  return this._games.get(identification);
564
561
  }
565
562
  }
566
- _ts_decorate$8([
563
+ _ts_decorate$a([
567
564
  common.Get(),
568
- _ts_param$4(0, common.Query()),
569
- _ts_metadata$4("design:type", Function),
570
- _ts_metadata$4("design:paramtypes", [
565
+ _ts_param$5(0, common.Query()),
566
+ _ts_metadata$5("design:type", Function),
567
+ _ts_metadata$5("design:paramtypes", [
571
568
  typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
572
569
  ]),
573
- _ts_metadata$4("design:returntype", typeof Promise === "undefined" ? Object : Promise)
570
+ _ts_metadata$5("design:returntype", typeof Promise === "undefined" ? Object : Promise)
574
571
  ], ZRomulatorGamesController.prototype, "list", null);
575
- _ts_decorate$8([
572
+ _ts_decorate$a([
576
573
  common.Get(":identification"),
577
- _ts_param$4(0, common.Param("identification")),
578
- _ts_metadata$4("design:type", Function),
579
- _ts_metadata$4("design:paramtypes", [
574
+ _ts_param$5(0, common.Param("identification")),
575
+ _ts_metadata$5("design:type", Function),
576
+ _ts_metadata$5("design:paramtypes", [
580
577
  String
581
578
  ]),
582
- _ts_metadata$4("design:returntype", void 0)
579
+ _ts_metadata$5("design:returntype", void 0)
583
580
  ], ZRomulatorGamesController.prototype, "get", null);
584
- ZRomulatorGamesController = _ts_decorate$8([
581
+ ZRomulatorGamesController = _ts_decorate$a([
585
582
  common.Controller("games"),
586
- _ts_param$4(0, common.Inject(ZRomulatorGamesToken)),
587
- _ts_metadata$4("design:type", Function),
588
- _ts_metadata$4("design:paramtypes", [
583
+ _ts_param$5(0, common.Inject(ZRomulatorGamesToken)),
584
+ _ts_metadata$5("design:type", Function),
585
+ _ts_metadata$5("design:paramtypes", [
589
586
  typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
590
587
  ])
591
588
  ], ZRomulatorGamesController);
592
589
 
593
- function _ts_decorate$7(decorators, target, key, desc) {
590
+ function _ts_decorate$9(decorators, target, key, desc) {
594
591
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
595
592
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
596
593
  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;
@@ -598,7 +595,7 @@ function _ts_decorate$7(decorators, target, key, desc) {
598
595
  }
599
596
  class ZRomulatorGamesModule {
600
597
  }
601
- ZRomulatorGamesModule = _ts_decorate$7([
598
+ ZRomulatorGamesModule = _ts_decorate$9([
602
599
  common.Module({
603
600
  imports: [
604
601
  ZRomulatorConfigsModule,
@@ -617,6 +614,105 @@ ZRomulatorGamesModule = _ts_decorate$7([
617
614
  })
618
615
  ], ZRomulatorGamesModule);
619
616
 
617
+ function _ts_decorate$8(decorators, target, key, desc) {
618
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
619
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
622
+ }
623
+ function _ts_metadata$4(k, v) {
624
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
625
+ }
626
+ function _ts_param$4(paramIndex, decorator) {
627
+ return function(target, key) {
628
+ decorator(target, key, paramIndex);
629
+ };
630
+ }
631
+ const ZRomulatorFilesToken = Symbol("files");
632
+ class ZRomulatorFilesService {
633
+ _configs;
634
+ static MediaFolderName = ".media";
635
+ static InfoFolderName = ".info";
636
+ _repository = new crumbtrailFs.ZFileRepository();
637
+ _folderWriter = new crumbtrailFs.ZStreamFolder();
638
+ _globs;
639
+ constructor(_configs){
640
+ this._configs = _configs;
641
+ const slugs = Object.values(romulatorClient.ZRomulatorSystemId);
642
+ this._globs = [
643
+ ".media/**",
644
+ ".info/**",
645
+ ...slugs.map((s)=>`${s}/*.*`)
646
+ ];
647
+ }
648
+ async gamesFolder() {
649
+ const config = await this._configs.get(romulatorClient.ZRomulatorConfigId.Games);
650
+ const { gamesFolder } = new romulatorClient.ZRomulatorConfigGamesBuilder().copy(config.contents).build();
651
+ const { fallback } = romulatorClient.ZRomulatorConfigGamesMetadata.gamesFolder();
652
+ const _gamesFolder = helpfulFn.firstDefined(fallback.gamesFolder, gamesFolder);
653
+ return helpfulFn.detokenize(_gamesFolder, node_process.env);
654
+ }
655
+ async mediaFolder() {
656
+ const gamesFolder = await this.gamesFolder();
657
+ return node_path.resolve(gamesFolder, ZRomulatorFilesService.MediaFolderName);
658
+ }
659
+ async infoFolder() {
660
+ const gamesFolder = await this.gamesFolder();
661
+ return node_path.resolve(gamesFolder, ZRomulatorFilesService.InfoFolderName);
662
+ }
663
+ async repository() {
664
+ const path = await this.gamesFolder();
665
+ if (this._repository.path !== path) {
666
+ await this._folderWriter.write(await this.mediaFolder());
667
+ await this._folderWriter.write(await this.infoFolder());
668
+ await this._repository.initialize(path, this._globs);
669
+ }
670
+ return this._repository;
671
+ }
672
+ async media() {
673
+ const repository = await this.repository();
674
+ const prefix = lodashEs.trimEnd(await this.mediaFolder(), "/");
675
+ const folder = `${prefix}${node_path.sep}`;
676
+ const filter = new helpfulQuery.ZFilterBinaryBuilder().subject("path").startsWith().value(folder).build();
677
+ const sort = new helpfulQuery.ZSortBuilder().ascending("path").build();
678
+ const request = new helpfulQuery.ZDataRequestBuilder().filter(filter).sort(sort).build();
679
+ return repository.retrieve(request);
680
+ }
681
+ }
682
+ ZRomulatorFilesService = _ts_decorate$8([
683
+ common.Injectable(),
684
+ _ts_param$4(0, common.Inject(ZRomulatorConfigsToken)),
685
+ _ts_metadata$4("design:type", Function),
686
+ _ts_metadata$4("design:paramtypes", [
687
+ typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
688
+ ])
689
+ ], ZRomulatorFilesService);
690
+
691
+ function _ts_decorate$7(decorators, target, key, desc) {
692
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
693
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
694
+ 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;
695
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
696
+ }
697
+ class ZRomulatorFilesModule {
698
+ }
699
+ ZRomulatorFilesModule = _ts_decorate$7([
700
+ common.Module({
701
+ imports: [
702
+ ZRomulatorConfigsModule
703
+ ],
704
+ providers: [
705
+ {
706
+ provide: ZRomulatorFilesToken,
707
+ useClass: ZRomulatorFilesService
708
+ }
709
+ ],
710
+ exports: [
711
+ ZRomulatorFilesToken
712
+ ]
713
+ })
714
+ ], ZRomulatorFilesModule);
715
+
620
716
  function _ts_decorate$6(decorators, target, key, desc) {
621
717
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
622
718
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -633,37 +729,24 @@ function _ts_param$3(paramIndex, decorator) {
633
729
  }
634
730
  const ZRomulatorMediaToken = Symbol("romulator-media-service");
635
731
  class ZRomulatorMediaService {
636
- _file;
637
- _config;
732
+ _files;
638
733
  _logger;
639
- constructor(_file, _config, logger){
640
- this._file = _file;
641
- this._config = _config;
734
+ constructor(_files, logger){
735
+ this._files = _files;
642
736
  this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorMediaService", logger);
643
737
  }
644
- async getMediaFolder() {
645
- const mediaConfig = ZRomulatorConfigKnown.media();
646
- const { contents } = await this._config.get(mediaConfig.id);
647
- const { mediaFolder } = new romulatorClient.ZRomulatorConfigMediaBuilder().copy(contents).build();
648
- return helpfulFn.detokenize(mediaFolder, node_process.env);
649
- }
650
- async findAllMedia(cwd) {
651
- const systems = ZRomulatorSystemKnown.all().map((s)=>s.id).join(",");
652
- const glob = `{${systems}}/**`;
653
- const files = await this._file.search(glob, {
654
- cwd,
655
- stat: false
656
- });
738
+ async findAllMedia() {
739
+ const files = await this._files.media();
657
740
  return files.map((f)=>new romulatorClient.ZRomulatorMediaBuilder().from(f.path).build()).filter((media)=>!!media.id);
658
741
  }
659
742
  async list(req) {
660
- const cwd = await this.getMediaFolder();
661
- let msg = `Reading all media from ${cwd}`;
743
+ let msg = `Querying media`;
662
744
  this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
663
745
  const time = new Date();
664
- const mediaList = await this.findAllMedia(cwd);
746
+ const mediaList = await this.findAllMedia();
665
747
  const span = new Date().getTime() - time.getTime();
666
748
  msg = `Found ${mediaList.length} media files. Search took ${span} milliseconds`;
749
+ this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
667
750
  const options = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields()).build();
668
751
  const source = new helpfulQuery.ZDataSourceStatic(mediaList, options);
669
752
  const page = await source.retrieve(req);
@@ -671,11 +754,10 @@ class ZRomulatorMediaService {
671
754
  return new helpfulQuery.ZPageBuilder().data(page).count(count).build();
672
755
  }
673
756
  async get(id) {
674
- const cwd = await this.getMediaFolder();
675
757
  const time = new Date();
676
758
  let log = `Searching for media with id ${id}.`;
677
759
  this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
678
- const mediaList = await this.findAllMedia(cwd);
760
+ const mediaList = await this.findAllMedia();
679
761
  const index = lodashEs.findIndex(mediaList, (m)=>m.id === id);
680
762
  const span = new Date().getTime() - time.getTime();
681
763
  if (index < 0) {
@@ -736,13 +818,11 @@ class ZRomulatorMediaService {
736
818
  }
737
819
  ZRomulatorMediaService = _ts_decorate$6([
738
820
  common.Injectable(),
739
- _ts_param$3(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
740
- _ts_param$3(1, common.Inject(ZRomulatorConfigsToken)),
741
- _ts_param$3(2, common.Inject(lumberjackyNest.ZLoggerToken)),
821
+ _ts_param$3(0, common.Inject(ZRomulatorFilesToken)),
822
+ _ts_param$3(1, common.Inject(lumberjackyNest.ZLoggerToken)),
742
823
  _ts_metadata$3("design:type", Function),
743
824
  _ts_metadata$3("design:paramtypes", [
744
- typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
745
- typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
825
+ typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService,
746
826
  typeof IZLogger === "undefined" ? Object : IZLogger
747
827
  ])
748
828
  ], ZRomulatorMediaService);
@@ -779,6 +859,42 @@ class ZRomulatorMediaController {
779
859
  }
780
860
  }
781
861
  _ts_decorate$5([
862
+ swagger.ApiQuery({
863
+ name: "page",
864
+ required: false,
865
+ type: Number,
866
+ example: 1,
867
+ description: "Page number (1-based)"
868
+ }),
869
+ swagger.ApiQuery({
870
+ name: "size",
871
+ required: false,
872
+ type: Number,
873
+ example: 20,
874
+ description: "Items per page. Defaults to Infinity"
875
+ }),
876
+ swagger.ApiQuery({
877
+ name: "search",
878
+ required: false,
879
+ type: String,
880
+ description: "Search query"
881
+ }),
882
+ swagger.ApiQuery({
883
+ name: "sort",
884
+ required: false,
885
+ type: String,
886
+ description: "Sort criterion"
887
+ }),
888
+ swagger.ApiQuery({
889
+ name: "filter",
890
+ required: false,
891
+ type: String,
892
+ description: "Filter criterion"
893
+ }),
894
+ swagger.ApiResponse({
895
+ status: webigailHttp.ZHttpCodeSuccess.OK,
896
+ description: "Returns the requested page of media and the total count"
897
+ }),
782
898
  common.Get(),
783
899
  _ts_param$2(0, common.Query()),
784
900
  _ts_metadata$2("design:type", Function),
@@ -838,6 +954,7 @@ _ts_decorate$5([
838
954
  _ts_metadata$2("design:returntype", Promise)
839
955
  ], ZRomulatorMediaController.prototype, "delete", null);
840
956
  ZRomulatorMediaController = _ts_decorate$5([
957
+ swagger.ApiTags("Media"),
841
958
  common.Controller("media"),
842
959
  _ts_param$2(0, common.Inject(ZRomulatorMediaToken)),
843
960
  _ts_metadata$2("design:type", Function),
@@ -857,9 +974,8 @@ class ZRomulatorMediaModule {
857
974
  ZRomulatorMediaModule = _ts_decorate$4([
858
975
  common.Module({
859
976
  imports: [
860
- crumbtrailNest.ZFileSystemModule,
861
- ZRomulatorConfigsModule,
862
- lumberjackyNest.ZLoggerModule
977
+ lumberjackyNest.ZLoggerModule,
978
+ ZRomulatorFilesModule
863
979
  ],
864
980
  controllers: [
865
981
  ZRomulatorMediaController
@@ -915,7 +1031,7 @@ class ZRomulatorSystemsService {
915
1031
  cwd
916
1032
  };
917
1033
  const folders = await this._file.search("*/", searchOptions);
918
- const systems = folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).map((slug)=>ZRomulatorSystemKnown.from(slug)).filter((system)=>system != null);
1034
+ const systems = folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).map((slug)=>this._createSystemFromSlug(slug)).filter((system)=>system != null);
919
1035
  msg = `Found ${systems.length} systems`;
920
1036
  this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
921
1037
  const sourceOptions = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields([
@@ -936,6 +1052,10 @@ class ZRomulatorSystemsService {
936
1052
  }
937
1053
  return system;
938
1054
  }
1055
+ _createSystemFromSlug(slug) {
1056
+ // A romulator system's slug should read the metadata.json file from the root
1057
+ return ZRomulatorSystemKnown.from(slug);
1058
+ }
939
1059
  }
940
1060
  ZRomulatorSystemsService = _ts_decorate$3([
941
1061
  common.Injectable(),