@zthun/romulator-api 1.10.0 → 1.12.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/files/files-games-repository.d.mts +27 -0
- package/dist/files/files-repository.d.mts +53 -16
- package/dist/files/files-systems-repository.d.mts +27 -0
- package/dist/games/games-service.d.mts +8 -8
- package/dist/main.cjs +571 -468
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +578 -475
- package/dist/main.js.map +1 -1
- package/dist/systems/systems-service.d.mts +2 -4
- package/package.json +11 -11
- package/dist/files/files-system-json-repository.d.mts +0 -28
- package/dist/systems/system-known.d.mts +0 -80
package/dist/main.cjs
CHANGED
|
@@ -14,9 +14,8 @@ const lodashEs = require('lodash-es');
|
|
|
14
14
|
const promises = require('node:fs/promises');
|
|
15
15
|
const node_path = require('node:path');
|
|
16
16
|
const node_os = require('node:os');
|
|
17
|
-
const helpfulReflection = require('@zthun/helpful-reflection');
|
|
18
|
-
require('reflect-metadata');
|
|
19
17
|
const crumbtrailFs = require('@zthun/crumbtrail-fs');
|
|
18
|
+
const path = require('path');
|
|
20
19
|
const node_process = require('node:process');
|
|
21
20
|
const webigailHttp = require('@zthun/webigail-http');
|
|
22
21
|
const webigailUrl = require('@zthun/webigail-url');
|
|
@@ -24,6 +23,19 @@ const mimeTypes = require('mime-types');
|
|
|
24
23
|
const node_fs = require('node:fs');
|
|
25
24
|
const node_stream = require('node:stream');
|
|
26
25
|
|
|
26
|
+
function _define_property$c(obj, key, value) {
|
|
27
|
+
if (key in obj) {
|
|
28
|
+
Object.defineProperty(obj, key, {
|
|
29
|
+
value: value,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
obj[key] = value;
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
27
39
|
function _ts_decorate$i(decorators, target, key, desc) {
|
|
28
40
|
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
29
41
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -34,7 +46,9 @@ function _ts_metadata$c(k, v) {
|
|
|
34
46
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35
47
|
}
|
|
36
48
|
class ZRomulatorConfigUpdateDto {
|
|
37
|
-
|
|
49
|
+
constructor(){
|
|
50
|
+
_define_property$c(this, "contents", void 0);
|
|
51
|
+
}
|
|
38
52
|
}
|
|
39
53
|
_ts_decorate$i([
|
|
40
54
|
swagger.ApiProperty({
|
|
@@ -75,6 +89,19 @@ class ZRomulatorConfigKnown {
|
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
|
|
92
|
+
function _define_property$b(obj, key, value) {
|
|
93
|
+
if (key in obj) {
|
|
94
|
+
Object.defineProperty(obj, key, {
|
|
95
|
+
value: value,
|
|
96
|
+
enumerable: true,
|
|
97
|
+
configurable: true,
|
|
98
|
+
writable: true
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
obj[key] = value;
|
|
102
|
+
}
|
|
103
|
+
return obj;
|
|
104
|
+
}
|
|
78
105
|
function _ts_decorate$h(decorators, target, key, desc) {
|
|
79
106
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
80
107
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -84,17 +111,13 @@ function _ts_decorate$h(decorators, target, key, desc) {
|
|
|
84
111
|
function _ts_metadata$b(k, v) {
|
|
85
112
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
86
113
|
}
|
|
87
|
-
function _ts_param$
|
|
114
|
+
function _ts_param$b(paramIndex, decorator) {
|
|
88
115
|
return function(target, key) {
|
|
89
116
|
decorator(target, key, paramIndex);
|
|
90
117
|
};
|
|
91
118
|
}
|
|
92
119
|
const ZRomulatorConfigsToken = Symbol("configs");
|
|
93
120
|
class ZRomulatorConfigsService {
|
|
94
|
-
_logger;
|
|
95
|
-
constructor(_logger){
|
|
96
|
-
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorConfigsService", _logger);
|
|
97
|
-
}
|
|
98
121
|
async list(req) {
|
|
99
122
|
const page = helpfulFn.firstDefined(1, req.page);
|
|
100
123
|
const size = helpfulFn.firstDefined(Infinity, req.size);
|
|
@@ -165,16 +188,33 @@ class ZRomulatorConfigsService {
|
|
|
165
188
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
166
189
|
return config;
|
|
167
190
|
}
|
|
191
|
+
constructor(_logger){
|
|
192
|
+
_define_property$b(this, "_logger", void 0);
|
|
193
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorConfigsService", _logger);
|
|
194
|
+
}
|
|
168
195
|
}
|
|
169
196
|
ZRomulatorConfigsService = _ts_decorate$h([
|
|
170
197
|
common.Injectable(),
|
|
171
|
-
_ts_param$
|
|
198
|
+
_ts_param$b(0, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
172
199
|
_ts_metadata$b("design:type", Function),
|
|
173
200
|
_ts_metadata$b("design:paramtypes", [
|
|
174
201
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
175
202
|
])
|
|
176
203
|
], ZRomulatorConfigsService);
|
|
177
204
|
|
|
205
|
+
function _define_property$a(obj, key, value) {
|
|
206
|
+
if (key in obj) {
|
|
207
|
+
Object.defineProperty(obj, key, {
|
|
208
|
+
value: value,
|
|
209
|
+
enumerable: true,
|
|
210
|
+
configurable: true,
|
|
211
|
+
writable: true
|
|
212
|
+
});
|
|
213
|
+
} else {
|
|
214
|
+
obj[key] = value;
|
|
215
|
+
}
|
|
216
|
+
return obj;
|
|
217
|
+
}
|
|
178
218
|
function _ts_decorate$g(decorators, target, key, desc) {
|
|
179
219
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
180
220
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -184,16 +224,12 @@ function _ts_decorate$g(decorators, target, key, desc) {
|
|
|
184
224
|
function _ts_metadata$a(k, v) {
|
|
185
225
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
186
226
|
}
|
|
187
|
-
function _ts_param$
|
|
227
|
+
function _ts_param$a(paramIndex, decorator) {
|
|
188
228
|
return function(target, key) {
|
|
189
229
|
decorator(target, key, paramIndex);
|
|
190
230
|
};
|
|
191
231
|
}
|
|
192
232
|
class ZRomulatorConfigsController {
|
|
193
|
-
_configs;
|
|
194
|
-
constructor(_configs){
|
|
195
|
-
this._configs = _configs;
|
|
196
|
-
}
|
|
197
233
|
async list(query) {
|
|
198
234
|
const request = new helpfulQuery.ZDataRequestBuilder().query(query).build();
|
|
199
235
|
return this._configs.list(request);
|
|
@@ -204,10 +240,14 @@ class ZRomulatorConfigsController {
|
|
|
204
240
|
async get(identification) {
|
|
205
241
|
return await this._configs.get(identification);
|
|
206
242
|
}
|
|
243
|
+
constructor(_configs){
|
|
244
|
+
_define_property$a(this, "_configs", void 0);
|
|
245
|
+
this._configs = _configs;
|
|
246
|
+
}
|
|
207
247
|
}
|
|
208
248
|
_ts_decorate$g([
|
|
209
249
|
common.Get(),
|
|
210
|
-
_ts_param$
|
|
250
|
+
_ts_param$a(0, common.Query()),
|
|
211
251
|
_ts_metadata$a("design:type", Function),
|
|
212
252
|
_ts_metadata$a("design:paramtypes", [
|
|
213
253
|
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
@@ -231,8 +271,8 @@ _ts_decorate$g([
|
|
|
231
271
|
skipNullProperties: false,
|
|
232
272
|
skipUndefinedProperties: false
|
|
233
273
|
})),
|
|
234
|
-
_ts_param$
|
|
235
|
-
_ts_param$
|
|
274
|
+
_ts_param$a(0, common.Param("identification")),
|
|
275
|
+
_ts_param$a(1, common.Body()),
|
|
236
276
|
_ts_metadata$a("design:type", Function),
|
|
237
277
|
_ts_metadata$a("design:paramtypes", [
|
|
238
278
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
|
|
@@ -247,7 +287,7 @@ _ts_decorate$g([
|
|
|
247
287
|
description: "The id of the config"
|
|
248
288
|
}),
|
|
249
289
|
common.Get(":identification"),
|
|
250
|
-
_ts_param$
|
|
290
|
+
_ts_param$a(0, common.Param("identification")),
|
|
251
291
|
_ts_metadata$a("design:type", Function),
|
|
252
292
|
_ts_metadata$a("design:paramtypes", [
|
|
253
293
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
|
|
@@ -256,7 +296,7 @@ _ts_decorate$g([
|
|
|
256
296
|
], ZRomulatorConfigsController.prototype, "get", null);
|
|
257
297
|
ZRomulatorConfigsController = _ts_decorate$g([
|
|
258
298
|
common.Controller("configs"),
|
|
259
|
-
_ts_param$
|
|
299
|
+
_ts_param$a(0, common.Inject(ZRomulatorConfigsToken)),
|
|
260
300
|
_ts_metadata$a("design:type", Function),
|
|
261
301
|
_ts_metadata$a("design:paramtypes", [
|
|
262
302
|
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
|
|
@@ -292,358 +332,35 @@ ZRomulatorConfigsModule = _ts_decorate$f([
|
|
|
292
332
|
})
|
|
293
333
|
], ZRomulatorConfigsModule);
|
|
294
334
|
|
|
295
|
-
function
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
303
|
-
}
|
|
304
|
-
const KnownSystem = "@zthunworks/romulator/known-system";
|
|
305
|
-
/**
|
|
306
|
-
* A helper factory class for creating supported systems.
|
|
307
|
-
*/ class ZRomulatorSystemKnown {
|
|
308
|
-
/**
|
|
309
|
-
* Returns all known systems.
|
|
310
|
-
*
|
|
311
|
-
* @returns
|
|
312
|
-
* All supported systems.
|
|
313
|
-
*/ static all() {
|
|
314
|
-
const properties = Object.getOwnPropertyNames(ZRomulatorSystemKnown);
|
|
315
|
-
const methods = properties.filter((p)=>helpfulReflection.isTagged(KnownSystem, ZRomulatorSystemKnown, p)).map((p)=>ZRomulatorSystemKnown[p]).map((f)=>f);
|
|
316
|
-
return methods.map((m)=>m.call(null));
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Creates a system that represents the Nintendo
|
|
320
|
-
* Entertainment System (NES).
|
|
321
|
-
*
|
|
322
|
-
* @returns
|
|
323
|
-
* A {@link ZRomulatorSystemBuilder} instance that has
|
|
324
|
-
* built the nes.
|
|
325
|
-
*/ static nes() {
|
|
326
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).name("Nintendo Entertainment System").build();
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Creates a system that represents the Super
|
|
330
|
-
* Nintendo Entertainment System (SNES).
|
|
331
|
-
*
|
|
332
|
-
* @returns
|
|
333
|
-
* This instance.
|
|
334
|
-
*/ static snes() {
|
|
335
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).name("Super Nintendo Entertainment System").build();
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Creates a system that represents the Nintendo
|
|
339
|
-
* 64 (N64).
|
|
340
|
-
*
|
|
341
|
-
* @returns
|
|
342
|
-
* This instance.
|
|
343
|
-
*/ static n64() {
|
|
344
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).name("Nintendo 64").build();
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Creates a system that represents the Nintendo
|
|
348
|
-
* GameCube (GC).
|
|
349
|
-
*
|
|
350
|
-
* @returns
|
|
351
|
-
* This instance.
|
|
352
|
-
*/ static gc() {
|
|
353
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).name("Nintendo GameCube").build();
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Creates a system that represents the Nintendo
|
|
357
|
-
* Wii (Wii).
|
|
358
|
-
*
|
|
359
|
-
* @returns
|
|
360
|
-
* This instance.
|
|
361
|
-
*/ static wii() {
|
|
362
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).name("Nintendo Wii").build();
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Creates a system that represents the Nintendo
|
|
366
|
-
* Wii U (WiiU).
|
|
367
|
-
*
|
|
368
|
-
* @returns
|
|
369
|
-
* This instance.
|
|
370
|
-
*/ static wiiu() {
|
|
371
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).name("Nintendo Wii U").build();
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Creates a system that represents the Nintendo
|
|
375
|
-
* Switch (Switch).
|
|
376
|
-
*
|
|
377
|
-
* @returns
|
|
378
|
-
* This instance.
|
|
379
|
-
*/ static switch() {
|
|
380
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).name("Nintendo Switch").build();
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Creates a system from an id slug.
|
|
384
|
-
*
|
|
385
|
-
* @param id -
|
|
386
|
-
* The id slug of the system to create.
|
|
387
|
-
*
|
|
388
|
-
* @return
|
|
389
|
-
* The system, or null if the id is not known.
|
|
390
|
-
*/ static from(id) {
|
|
391
|
-
if (helpfulReflection.isTagged(KnownSystem, ZRomulatorSystemKnown, id)) {
|
|
392
|
-
return ZRomulatorSystemKnown[id]();
|
|
393
|
-
}
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
_ts_decorate$e([
|
|
398
|
-
helpfulReflection.ZTag(KnownSystem),
|
|
399
|
-
_ts_metadata$9("design:type", Function),
|
|
400
|
-
_ts_metadata$9("design:paramtypes", []),
|
|
401
|
-
_ts_metadata$9("design:returntype", void 0)
|
|
402
|
-
], ZRomulatorSystemKnown, "nes", null);
|
|
403
|
-
_ts_decorate$e([
|
|
404
|
-
helpfulReflection.ZTag(KnownSystem),
|
|
405
|
-
_ts_metadata$9("design:type", Function),
|
|
406
|
-
_ts_metadata$9("design:paramtypes", []),
|
|
407
|
-
_ts_metadata$9("design:returntype", void 0)
|
|
408
|
-
], ZRomulatorSystemKnown, "snes", null);
|
|
409
|
-
_ts_decorate$e([
|
|
410
|
-
helpfulReflection.ZTag(KnownSystem),
|
|
411
|
-
_ts_metadata$9("design:type", Function),
|
|
412
|
-
_ts_metadata$9("design:paramtypes", []),
|
|
413
|
-
_ts_metadata$9("design:returntype", void 0)
|
|
414
|
-
], ZRomulatorSystemKnown, "n64", null);
|
|
415
|
-
_ts_decorate$e([
|
|
416
|
-
helpfulReflection.ZTag(KnownSystem),
|
|
417
|
-
_ts_metadata$9("design:type", Function),
|
|
418
|
-
_ts_metadata$9("design:paramtypes", []),
|
|
419
|
-
_ts_metadata$9("design:returntype", void 0)
|
|
420
|
-
], ZRomulatorSystemKnown, "gc", null);
|
|
421
|
-
_ts_decorate$e([
|
|
422
|
-
helpfulReflection.ZTag(KnownSystem),
|
|
423
|
-
_ts_metadata$9("design:type", Function),
|
|
424
|
-
_ts_metadata$9("design:paramtypes", []),
|
|
425
|
-
_ts_metadata$9("design:returntype", void 0)
|
|
426
|
-
], ZRomulatorSystemKnown, "wii", null);
|
|
427
|
-
_ts_decorate$e([
|
|
428
|
-
helpfulReflection.ZTag(KnownSystem),
|
|
429
|
-
_ts_metadata$9("design:type", Function),
|
|
430
|
-
_ts_metadata$9("design:paramtypes", []),
|
|
431
|
-
_ts_metadata$9("design:returntype", void 0)
|
|
432
|
-
], ZRomulatorSystemKnown, "wiiu", null);
|
|
433
|
-
_ts_decorate$e([
|
|
434
|
-
helpfulReflection.ZTag(KnownSystem),
|
|
435
|
-
_ts_metadata$9("design:type", Function),
|
|
436
|
-
_ts_metadata$9("design:paramtypes", []),
|
|
437
|
-
_ts_metadata$9("design:returntype", void 0)
|
|
438
|
-
], ZRomulatorSystemKnown, "switch", null);
|
|
439
|
-
|
|
440
|
-
function _ts_decorate$d(decorators, target, key, desc) {
|
|
441
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
442
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
445
|
-
}
|
|
446
|
-
function _ts_metadata$8(k, v) {
|
|
447
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
448
|
-
}
|
|
449
|
-
function _ts_param$8(paramIndex, decorator) {
|
|
450
|
-
return function(target, key) {
|
|
451
|
-
decorator(target, key, paramIndex);
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
const ZRomulatorGamesToken = Symbol("romulator-games-service");
|
|
455
|
-
class ZRomulatorGamesService {
|
|
456
|
-
_file;
|
|
457
|
-
_config;
|
|
458
|
-
_logger;
|
|
459
|
-
constructor(_file, _config, logger){
|
|
460
|
-
this._file = _file;
|
|
461
|
-
this._config = _config;
|
|
462
|
-
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorGamesService", logger);
|
|
463
|
-
}
|
|
464
|
-
async list(req) {
|
|
465
|
-
const config = ZRomulatorConfigKnown.games();
|
|
466
|
-
const { contents } = await this._config.get(config.id);
|
|
467
|
-
const { gamesFolder } = new romulatorClient.ZRomulatorConfigGamesBuilder().copy(contents).build();
|
|
468
|
-
const { fallback } = romulatorClient.ZRomulatorConfigGamesMetadata.gamesFolder();
|
|
469
|
-
const cwd = helpfulFn.detokenize(helpfulFn.firstDefined(fallback, gamesFolder), process.env);
|
|
470
|
-
const time = new Date();
|
|
471
|
-
let msg = `Searching for games in ${cwd}`;
|
|
472
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
473
|
-
const systems = ZRomulatorSystemKnown.all().map((system)=>system.id);
|
|
474
|
-
const glob = `{${systems.join(",")}}/**/*.zip`;
|
|
475
|
-
const nodes = await this._file.search(glob, {
|
|
476
|
-
cwd,
|
|
477
|
-
stat: false
|
|
478
|
-
});
|
|
479
|
-
const span = new Date().getTime() - time.getTime();
|
|
480
|
-
msg = `Found ${nodes.length} games. Search took ${span} milliseconds.`;
|
|
481
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
482
|
-
const games = nodes.map(({ path })=>{
|
|
483
|
-
const dir = node_path.basename(node_path.dirname(path));
|
|
484
|
-
const { name: file } = node_path.parse(path);
|
|
485
|
-
const id = `${dir}-${lodashEs.kebabCase(file)}`;
|
|
486
|
-
return new romulatorClient.ZRomulatorGameBuilder().id(id).system(dir).file(path).name(file).build();
|
|
335
|
+
function _define_property$9(obj, key, value) {
|
|
336
|
+
if (key in obj) {
|
|
337
|
+
Object.defineProperty(obj, key, {
|
|
338
|
+
value: value,
|
|
339
|
+
enumerable: true,
|
|
340
|
+
configurable: true,
|
|
341
|
+
writable: true
|
|
487
342
|
});
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const $sort = new helpfulQuery.ZSortBuilder().sorts(helpfulFn.firstDefined([], req.sort)).ascending("system").ascending("name").build();
|
|
491
|
-
const $request = new helpfulQuery.ZDataRequestBuilder().copy(req).sort($sort).build();
|
|
492
|
-
const data = await source.retrieve($request);
|
|
493
|
-
const count = await source.count($request);
|
|
494
|
-
return new helpfulQuery.ZPageBuilder().count(count).data(data).build();
|
|
495
|
-
}
|
|
496
|
-
async get(id) {
|
|
497
|
-
const { data: games } = await this.list(new helpfulQuery.ZDataRequestBuilder().build());
|
|
498
|
-
const match = games.find((game)=>game.id === id);
|
|
499
|
-
if (!match) {
|
|
500
|
-
throw new common.NotFoundException(`Unable to find game with id, ${id}.`);
|
|
501
|
-
}
|
|
502
|
-
return match;
|
|
503
|
-
}
|
|
504
|
-
match(data, filter) {
|
|
505
|
-
const needle = filter?.trim().toLowerCase();
|
|
506
|
-
const { name = "", system = "" } = data;
|
|
507
|
-
const target = ZRomulatorSystemKnown.from(system);
|
|
508
|
-
const systemName = helpfulFn.firstTruthy("", target?.name);
|
|
509
|
-
if (!needle?.length) {
|
|
510
|
-
return true;
|
|
511
|
-
}
|
|
512
|
-
return [
|
|
513
|
-
name,
|
|
514
|
-
system,
|
|
515
|
-
systemName
|
|
516
|
-
].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
|
|
343
|
+
} else {
|
|
344
|
+
obj[key] = value;
|
|
517
345
|
}
|
|
346
|
+
return obj;
|
|
518
347
|
}
|
|
519
|
-
|
|
520
|
-
common.Injectable(),
|
|
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
|
-
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
|
|
527
|
-
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
528
|
-
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
529
|
-
])
|
|
530
|
-
], ZRomulatorGamesService);
|
|
531
|
-
|
|
532
|
-
function _ts_decorate$c(decorators, target, key, desc) {
|
|
533
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
534
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
537
|
-
}
|
|
538
|
-
function _ts_metadata$7(k, v) {
|
|
539
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
540
|
-
}
|
|
541
|
-
function _ts_param$7(paramIndex, decorator) {
|
|
542
|
-
return function(target, key) {
|
|
543
|
-
decorator(target, key, paramIndex);
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
class ZRomulatorGamesController {
|
|
547
|
-
_games;
|
|
548
|
-
constructor(_games){
|
|
549
|
-
this._games = _games;
|
|
550
|
-
}
|
|
551
|
-
list(query) {
|
|
552
|
-
return this._games.list(new helpfulQuery.ZDataRequestBuilder().query(query).build());
|
|
553
|
-
}
|
|
554
|
-
get(identification) {
|
|
555
|
-
return this._games.get(identification);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
_ts_decorate$c([
|
|
559
|
-
common.Get(),
|
|
560
|
-
_ts_param$7(0, common.Query()),
|
|
561
|
-
_ts_metadata$7("design:type", Function),
|
|
562
|
-
_ts_metadata$7("design:paramtypes", [
|
|
563
|
-
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
564
|
-
]),
|
|
565
|
-
_ts_metadata$7("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
566
|
-
], ZRomulatorGamesController.prototype, "list", null);
|
|
567
|
-
_ts_decorate$c([
|
|
568
|
-
common.Get(":identification"),
|
|
569
|
-
_ts_param$7(0, common.Param("identification")),
|
|
570
|
-
_ts_metadata$7("design:type", Function),
|
|
571
|
-
_ts_metadata$7("design:paramtypes", [
|
|
572
|
-
String
|
|
573
|
-
]),
|
|
574
|
-
_ts_metadata$7("design:returntype", void 0)
|
|
575
|
-
], ZRomulatorGamesController.prototype, "get", null);
|
|
576
|
-
ZRomulatorGamesController = _ts_decorate$c([
|
|
577
|
-
common.Controller("games"),
|
|
578
|
-
_ts_param$7(0, common.Inject(ZRomulatorGamesToken)),
|
|
579
|
-
_ts_metadata$7("design:type", Function),
|
|
580
|
-
_ts_metadata$7("design:paramtypes", [
|
|
581
|
-
typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
|
|
582
|
-
])
|
|
583
|
-
], ZRomulatorGamesController);
|
|
584
|
-
|
|
585
|
-
function _ts_decorate$b(decorators, target, key, desc) {
|
|
586
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
587
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
589
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
590
|
-
}
|
|
591
|
-
class ZRomulatorGamesModule {
|
|
592
|
-
}
|
|
593
|
-
ZRomulatorGamesModule = _ts_decorate$b([
|
|
594
|
-
common.Module({
|
|
595
|
-
imports: [
|
|
596
|
-
ZRomulatorConfigsModule,
|
|
597
|
-
crumbtrailNest.ZFileSystemModule,
|
|
598
|
-
lumberjackyNest.ZLoggerModule
|
|
599
|
-
],
|
|
600
|
-
controllers: [
|
|
601
|
-
ZRomulatorGamesController
|
|
602
|
-
],
|
|
603
|
-
providers: [
|
|
604
|
-
{
|
|
605
|
-
provide: ZRomulatorGamesToken,
|
|
606
|
-
useClass: ZRomulatorGamesService
|
|
607
|
-
}
|
|
608
|
-
]
|
|
609
|
-
})
|
|
610
|
-
], ZRomulatorGamesModule);
|
|
611
|
-
|
|
612
|
-
function _ts_decorate$a(decorators, target, key, desc) {
|
|
348
|
+
function _ts_decorate$e(decorators, target, key, desc) {
|
|
613
349
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
614
350
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
615
351
|
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
352
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
617
353
|
}
|
|
618
|
-
function _ts_metadata$
|
|
354
|
+
function _ts_metadata$9(k, v) {
|
|
619
355
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
620
356
|
}
|
|
621
|
-
function _ts_param$
|
|
357
|
+
function _ts_param$9(paramIndex, decorator) {
|
|
622
358
|
return function(target, key) {
|
|
623
359
|
decorator(target, key, paramIndex);
|
|
624
360
|
};
|
|
625
361
|
}
|
|
626
|
-
const
|
|
362
|
+
const ZRomulatorFilesRepositoryToken = Symbol("files-repository");
|
|
627
363
|
class ZRomulatorFilesRepository {
|
|
628
|
-
_configs;
|
|
629
|
-
_fileSystem;
|
|
630
|
-
static MediaFolderName = ".media";
|
|
631
|
-
static InfoFolderName = ".info";
|
|
632
|
-
_repository = new crumbtrailFs.ZFileRepository();
|
|
633
|
-
_folderStream = new crumbtrailFs.ZStreamFolder();
|
|
634
|
-
_globs;
|
|
635
|
-
_systems;
|
|
636
|
-
constructor(_configs, _fileSystem){
|
|
637
|
-
this._configs = _configs;
|
|
638
|
-
this._fileSystem = _fileSystem;
|
|
639
|
-
const slugs = Object.values(romulatorClient.ZRomulatorSystemId);
|
|
640
|
-
this._globs = [
|
|
641
|
-
".media/**",
|
|
642
|
-
".info/**",
|
|
643
|
-
...slugs.map((s)=>`${s}/*.*`)
|
|
644
|
-
];
|
|
645
|
-
this._systems = Object.values(romulatorClient.ZRomulatorSystemId);
|
|
646
|
-
}
|
|
647
364
|
async gamesFolder() {
|
|
648
365
|
const config = await this._configs.get(romulatorClient.ZRomulatorConfigId.Games);
|
|
649
366
|
const { gamesFolder } = new romulatorClient.ZRomulatorConfigGamesBuilder().copy(config.contents).build();
|
|
@@ -684,7 +401,21 @@ class ZRomulatorFilesRepository {
|
|
|
684
401
|
const path = node_path.resolve(folder, `${id}.json`);
|
|
685
402
|
return this._repository.get(path);
|
|
686
403
|
}
|
|
687
|
-
async
|
|
404
|
+
async json(node) {
|
|
405
|
+
if (node == null) {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
const contents = await this._fileStream.read(node.path);
|
|
410
|
+
return JSON.parse(contents.toString());
|
|
411
|
+
} catch (e) {
|
|
412
|
+
const err = helpfulFn.createError(e);
|
|
413
|
+
const msg = `Unable to read ${node.path}: ${err.message}`;
|
|
414
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
async systems() {
|
|
688
419
|
// Systems use directories. There's a maximum limit of about 200 systems.
|
|
689
420
|
// Since we don't actually need to read any metadata or scan through thousands
|
|
690
421
|
// of unknown folders, we can use the supported system ids to just grab the
|
|
@@ -692,73 +423,106 @@ class ZRomulatorFilesRepository {
|
|
|
692
423
|
// grab the systems from the file system and it should be fast enough. These are all
|
|
693
424
|
// folders, so we don't even need the stats for them and we can assume folders.
|
|
694
425
|
const games = await this.gamesFolder();
|
|
695
|
-
const folders =
|
|
696
|
-
|
|
426
|
+
const folders = this._systems.map((s)=>`${s}/`);
|
|
427
|
+
return await this._fileSystem.search(folders, {
|
|
697
428
|
cwd: games,
|
|
698
429
|
stat: false
|
|
699
430
|
});
|
|
700
|
-
|
|
431
|
+
}
|
|
432
|
+
async games(systems) {
|
|
433
|
+
const repository = await this.init();
|
|
434
|
+
const folder = await this.gamesFolder();
|
|
435
|
+
const queries = systems.map((s)=>{
|
|
436
|
+
const dir = `${folder}/${s.id}`;
|
|
437
|
+
const byExtension = new helpfulQuery.ZFilterCollectionBuilder().subject("extension").in().values(s.extensions.map((e)=>`.${lodashEs.trimStart(e, ".")}`)).build();
|
|
438
|
+
const inPath = new helpfulQuery.ZFilterBinaryBuilder().subject("parent").equal().value(dir).build();
|
|
439
|
+
const filter = new helpfulQuery.ZFilterLogicBuilder().and().clause(inPath).clause(byExtension).build();
|
|
440
|
+
const request = new helpfulQuery.ZDataRequestBuilder().filter(filter).build();
|
|
441
|
+
return repository.retrieve(request);
|
|
442
|
+
});
|
|
443
|
+
const results = await Promise.all(queries);
|
|
444
|
+
return lodashEs.flatten(results);
|
|
445
|
+
}
|
|
446
|
+
constructor(_configs, _fileSystem, logger){
|
|
447
|
+
_define_property$9(this, "_configs", void 0);
|
|
448
|
+
_define_property$9(this, "_fileSystem", void 0);
|
|
449
|
+
_define_property$9(this, "logger", void 0);
|
|
450
|
+
_define_property$9(this, "_logger", void 0);
|
|
451
|
+
_define_property$9(this, "_repository", void 0);
|
|
452
|
+
_define_property$9(this, "_folderStream", void 0);
|
|
453
|
+
_define_property$9(this, "_fileStream", void 0);
|
|
454
|
+
_define_property$9(this, "_globs", void 0);
|
|
455
|
+
_define_property$9(this, "_systems", void 0);
|
|
456
|
+
this._configs = _configs;
|
|
457
|
+
this._fileSystem = _fileSystem;
|
|
458
|
+
this.logger = logger;
|
|
459
|
+
this._repository = new crumbtrailFs.ZFileRepository();
|
|
460
|
+
this._folderStream = new crumbtrailFs.ZStreamFolder();
|
|
461
|
+
this._fileStream = new crumbtrailFs.ZStreamFile({
|
|
462
|
+
cache: {
|
|
463
|
+
fileSize: BigInt(helpfulFn.mib(1)),
|
|
464
|
+
maxFiles: 250
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
const slugs = Object.values(romulatorClient.ZRomulatorSystemId);
|
|
468
|
+
this._globs = [
|
|
469
|
+
".media/**",
|
|
470
|
+
".info/**",
|
|
471
|
+
...slugs.map((s)=>`${s}/*.*`)
|
|
472
|
+
];
|
|
473
|
+
this._systems = Object.values(romulatorClient.ZRomulatorSystemId);
|
|
474
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorFilesRepository", logger);
|
|
701
475
|
}
|
|
702
476
|
}
|
|
703
|
-
ZRomulatorFilesRepository
|
|
477
|
+
_define_property$9(ZRomulatorFilesRepository, "MediaFolderName", ".media");
|
|
478
|
+
_define_property$9(ZRomulatorFilesRepository, "InfoFolderName", ".info");
|
|
479
|
+
ZRomulatorFilesRepository = _ts_decorate$e([
|
|
704
480
|
common.Injectable(),
|
|
705
|
-
_ts_param$
|
|
706
|
-
_ts_param$
|
|
707
|
-
|
|
708
|
-
_ts_metadata$
|
|
481
|
+
_ts_param$9(0, common.Inject(ZRomulatorConfigsToken)),
|
|
482
|
+
_ts_param$9(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
|
|
483
|
+
_ts_param$9(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
484
|
+
_ts_metadata$9("design:type", Function),
|
|
485
|
+
_ts_metadata$9("design:paramtypes", [
|
|
709
486
|
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
710
|
-
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService
|
|
487
|
+
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
|
|
488
|
+
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
711
489
|
])
|
|
712
490
|
], ZRomulatorFilesRepository);
|
|
713
491
|
|
|
714
|
-
function
|
|
492
|
+
function _define_property$8(obj, key, value) {
|
|
493
|
+
if (key in obj) {
|
|
494
|
+
Object.defineProperty(obj, key, {
|
|
495
|
+
value: value,
|
|
496
|
+
enumerable: true,
|
|
497
|
+
configurable: true,
|
|
498
|
+
writable: true
|
|
499
|
+
});
|
|
500
|
+
} else {
|
|
501
|
+
obj[key] = value;
|
|
502
|
+
}
|
|
503
|
+
return obj;
|
|
504
|
+
}
|
|
505
|
+
function _ts_decorate$d(decorators, target, key, desc) {
|
|
715
506
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
716
507
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
717
508
|
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
509
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
719
510
|
}
|
|
720
|
-
function _ts_metadata$
|
|
511
|
+
function _ts_metadata$8(k, v) {
|
|
721
512
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
722
513
|
}
|
|
723
|
-
function _ts_param$
|
|
514
|
+
function _ts_param$8(paramIndex, decorator) {
|
|
724
515
|
return function(target, key) {
|
|
725
516
|
decorator(target, key, paramIndex);
|
|
726
517
|
};
|
|
727
518
|
}
|
|
728
|
-
const
|
|
729
|
-
class
|
|
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);
|
|
743
|
-
}
|
|
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
|
-
}
|
|
759
|
-
}
|
|
519
|
+
const ZRomulatorFilesSystemsRepositoryToken = Symbol("files-systems-repository");
|
|
520
|
+
class ZRomulatorFilesSystemsRepository {
|
|
760
521
|
async systems() {
|
|
761
|
-
const
|
|
522
|
+
const info = await this._filesRepository.info("systems");
|
|
523
|
+
const json = await this._filesRepository.json(info);
|
|
524
|
+
const candidates = lodashEs.castArray(helpfulFn.firstDefined([], json));
|
|
525
|
+
const folders = await this._filesRepository.systems();
|
|
762
526
|
function hasId(candidate) {
|
|
763
527
|
return Object.prototype.hasOwnProperty.call(candidate, "id");
|
|
764
528
|
}
|
|
@@ -766,47 +530,149 @@ class ZRomulatorFilesSystemsJsonRepository {
|
|
|
766
530
|
c.id,
|
|
767
531
|
c
|
|
768
532
|
]);
|
|
769
|
-
|
|
533
|
+
const lookup = new Map(entries);
|
|
534
|
+
const systems = folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).filter((slug)=>romulatorClient.isSystemId(slug)).map((slug)=>new romulatorClient.ZRomulatorSystemBuilder().parse(lookup.get(slug)).id(slug).build());
|
|
535
|
+
return new Map(systems.map((s)=>[
|
|
536
|
+
s.id,
|
|
537
|
+
s
|
|
538
|
+
]));
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Initializes a new instance of this object.
|
|
542
|
+
*/ constructor(_filesRepository){
|
|
543
|
+
_define_property$8(this, "_filesRepository", void 0);
|
|
544
|
+
this._filesRepository = _filesRepository;
|
|
770
545
|
}
|
|
771
546
|
}
|
|
772
|
-
|
|
547
|
+
ZRomulatorFilesSystemsRepository = _ts_decorate$d([
|
|
773
548
|
common.Injectable(),
|
|
774
|
-
_ts_param$
|
|
775
|
-
|
|
776
|
-
_ts_metadata$
|
|
777
|
-
|
|
778
|
-
typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository,
|
|
779
|
-
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
549
|
+
_ts_param$8(0, common.Inject(ZRomulatorFilesRepositoryToken)),
|
|
550
|
+
_ts_metadata$8("design:type", Function),
|
|
551
|
+
_ts_metadata$8("design:paramtypes", [
|
|
552
|
+
typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository
|
|
780
553
|
])
|
|
781
|
-
],
|
|
554
|
+
], ZRomulatorFilesSystemsRepository);
|
|
782
555
|
|
|
783
|
-
function
|
|
556
|
+
function _define_property$7(obj, key, value) {
|
|
557
|
+
if (key in obj) {
|
|
558
|
+
Object.defineProperty(obj, key, {
|
|
559
|
+
value: value,
|
|
560
|
+
enumerable: true,
|
|
561
|
+
configurable: true,
|
|
562
|
+
writable: true
|
|
563
|
+
});
|
|
564
|
+
} else {
|
|
565
|
+
obj[key] = value;
|
|
566
|
+
}
|
|
567
|
+
return obj;
|
|
568
|
+
}
|
|
569
|
+
function _ts_decorate$c(decorators, target, key, desc) {
|
|
784
570
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
785
571
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
786
572
|
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;
|
|
787
573
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
788
574
|
}
|
|
789
|
-
function _ts_metadata$
|
|
575
|
+
function _ts_metadata$7(k, v) {
|
|
790
576
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
791
577
|
}
|
|
792
|
-
function _ts_param$
|
|
578
|
+
function _ts_param$7(paramIndex, decorator) {
|
|
793
579
|
return function(target, key) {
|
|
794
580
|
decorator(target, key, paramIndex);
|
|
795
581
|
};
|
|
796
582
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
583
|
+
const ZRomulatorFilesGamesRepositoryToken = Symbol("files-games-repository");
|
|
584
|
+
class ZRomulatorFilesGamesRepository {
|
|
585
|
+
async games() {
|
|
586
|
+
function hasPath(entry) {
|
|
587
|
+
return typeof lodashEs.get(entry, "path") === "string";
|
|
588
|
+
}
|
|
589
|
+
const gamesFolder = await this._filesRepository.gamesFolder();
|
|
590
|
+
const games = [];
|
|
591
|
+
const systemLookup = await this._systemsRepository.systems();
|
|
592
|
+
const systems = Array.from(systemLookup.values());
|
|
593
|
+
const gameFiles = await this._filesRepository.games(systems);
|
|
594
|
+
const systemsInUse = lodashEs.uniq(gameFiles.map((g)=>g.parent)).map((dir)=>new crumbtrailFs.ZFileSystemNodeBuilder().path(dir).folder().build()).map((node)=>node.title).filter((title)=>romulatorClient.isSystemId(title));
|
|
595
|
+
const gameInfo = new Map();
|
|
596
|
+
for await (const system of systemsInUse){
|
|
597
|
+
const info = await this._filesRepository.info(system);
|
|
598
|
+
const json = await this._filesRepository.json(info);
|
|
599
|
+
const gameList = lodashEs.castArray(json).filter((e)=>hasPath(e));
|
|
600
|
+
gameList.forEach((entry)=>{
|
|
601
|
+
gameInfo.set(path.resolve(gamesFolder, system, entry.path), entry);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
// Variable, gameInfo, now has all of the information data that we need.
|
|
605
|
+
for (const file of gameFiles){
|
|
606
|
+
const { title, path } = file;
|
|
607
|
+
const { title: systemId } = new crumbtrailFs.ZFileSystemNodeBuilder().path(file.parent).folder().build();
|
|
608
|
+
const id = `${lodashEs.kebabCase(systemId)}-${lodashEs.kebabCase(title)}`;
|
|
609
|
+
const info = gameInfo.get(path);
|
|
610
|
+
const game = new romulatorClient.ZRomulatorGameBuilder().id(id).system(systemId).file(path).parse(info).build();
|
|
611
|
+
games.push(game);
|
|
612
|
+
}
|
|
613
|
+
return new Map(games.map((g)=>[
|
|
614
|
+
g.id,
|
|
615
|
+
g
|
|
616
|
+
]));
|
|
617
|
+
}
|
|
618
|
+
constructor(_systemsRepository, _filesRepository){
|
|
619
|
+
_define_property$7(this, "_systemsRepository", void 0);
|
|
620
|
+
_define_property$7(this, "_filesRepository", void 0);
|
|
621
|
+
this._systemsRepository = _systemsRepository;
|
|
622
|
+
this._filesRepository = _filesRepository;
|
|
801
623
|
}
|
|
624
|
+
}
|
|
625
|
+
ZRomulatorFilesGamesRepository = _ts_decorate$c([
|
|
626
|
+
common.Injectable(),
|
|
627
|
+
_ts_param$7(0, common.Inject(ZRomulatorFilesSystemsRepositoryToken)),
|
|
628
|
+
_ts_param$7(1, common.Inject(ZRomulatorFilesRepositoryToken)),
|
|
629
|
+
_ts_metadata$7("design:type", Function),
|
|
630
|
+
_ts_metadata$7("design:paramtypes", [
|
|
631
|
+
typeof IZRomulatorFilesSystemsRepository === "undefined" ? Object : IZRomulatorFilesSystemsRepository,
|
|
632
|
+
typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository
|
|
633
|
+
])
|
|
634
|
+
], ZRomulatorFilesGamesRepository);
|
|
635
|
+
|
|
636
|
+
function _define_property$6(obj, key, value) {
|
|
637
|
+
if (key in obj) {
|
|
638
|
+
Object.defineProperty(obj, key, {
|
|
639
|
+
value: value,
|
|
640
|
+
enumerable: true,
|
|
641
|
+
configurable: true,
|
|
642
|
+
writable: true
|
|
643
|
+
});
|
|
644
|
+
} else {
|
|
645
|
+
obj[key] = value;
|
|
646
|
+
}
|
|
647
|
+
return obj;
|
|
648
|
+
}
|
|
649
|
+
function _ts_decorate$b(decorators, target, key, desc) {
|
|
650
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
651
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
652
|
+
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;
|
|
653
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
654
|
+
}
|
|
655
|
+
function _ts_metadata$6(k, v) {
|
|
656
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
657
|
+
}
|
|
658
|
+
function _ts_param$6(paramIndex, decorator) {
|
|
659
|
+
return function(target, key) {
|
|
660
|
+
decorator(target, key, paramIndex);
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
class ZRomulatorFilesModule {
|
|
802
664
|
async onModuleInit() {
|
|
803
665
|
await this._files.init();
|
|
804
666
|
}
|
|
805
667
|
async onModuleDestroy() {
|
|
806
668
|
await this._files.dispose();
|
|
807
669
|
}
|
|
670
|
+
constructor(_files){
|
|
671
|
+
_define_property$6(this, "_files", void 0);
|
|
672
|
+
this._files = _files;
|
|
673
|
+
}
|
|
808
674
|
}
|
|
809
|
-
ZRomulatorFilesModule = _ts_decorate$
|
|
675
|
+
ZRomulatorFilesModule = _ts_decorate$b([
|
|
810
676
|
common.Module({
|
|
811
677
|
imports: [
|
|
812
678
|
crumbtrailNest.ZFileSystemModule,
|
|
@@ -815,26 +681,216 @@ ZRomulatorFilesModule = _ts_decorate$8([
|
|
|
815
681
|
],
|
|
816
682
|
providers: [
|
|
817
683
|
{
|
|
818
|
-
provide:
|
|
684
|
+
provide: ZRomulatorFilesRepositoryToken,
|
|
819
685
|
useClass: ZRomulatorFilesRepository
|
|
820
686
|
},
|
|
821
687
|
{
|
|
822
|
-
provide:
|
|
823
|
-
useClass:
|
|
688
|
+
provide: ZRomulatorFilesSystemsRepositoryToken,
|
|
689
|
+
useClass: ZRomulatorFilesSystemsRepository
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
provide: ZRomulatorFilesGamesRepositoryToken,
|
|
693
|
+
useClass: ZRomulatorFilesGamesRepository
|
|
824
694
|
}
|
|
825
695
|
],
|
|
826
696
|
exports: [
|
|
827
|
-
|
|
828
|
-
|
|
697
|
+
ZRomulatorFilesRepositoryToken,
|
|
698
|
+
ZRomulatorFilesSystemsRepositoryToken,
|
|
699
|
+
ZRomulatorFilesGamesRepositoryToken
|
|
829
700
|
]
|
|
830
701
|
}),
|
|
831
|
-
_ts_param$
|
|
832
|
-
_ts_metadata$
|
|
833
|
-
_ts_metadata$
|
|
702
|
+
_ts_param$6(0, common.Inject(ZRomulatorFilesRepositoryToken)),
|
|
703
|
+
_ts_metadata$6("design:type", Function),
|
|
704
|
+
_ts_metadata$6("design:paramtypes", [
|
|
834
705
|
typeof IZRomulatorFilesRepository === "undefined" ? Object : IZRomulatorFilesRepository
|
|
835
706
|
])
|
|
836
707
|
], ZRomulatorFilesModule);
|
|
837
708
|
|
|
709
|
+
function _define_property$5(obj, key, value) {
|
|
710
|
+
if (key in obj) {
|
|
711
|
+
Object.defineProperty(obj, key, {
|
|
712
|
+
value: value,
|
|
713
|
+
enumerable: true,
|
|
714
|
+
configurable: true,
|
|
715
|
+
writable: true
|
|
716
|
+
});
|
|
717
|
+
} else {
|
|
718
|
+
obj[key] = value;
|
|
719
|
+
}
|
|
720
|
+
return obj;
|
|
721
|
+
}
|
|
722
|
+
function _ts_decorate$a(decorators, target, key, desc) {
|
|
723
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
724
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
725
|
+
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;
|
|
726
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
727
|
+
}
|
|
728
|
+
function _ts_metadata$5(k, v) {
|
|
729
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
730
|
+
}
|
|
731
|
+
function _ts_param$5(paramIndex, decorator) {
|
|
732
|
+
return function(target, key) {
|
|
733
|
+
decorator(target, key, paramIndex);
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
const ZRomulatorGamesToken = Symbol("romulator-games-service");
|
|
737
|
+
class ZRomulatorGamesService {
|
|
738
|
+
async list(req) {
|
|
739
|
+
const msg = `Searching for games`;
|
|
740
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
741
|
+
const systems = await this._systemsRepository.systems();
|
|
742
|
+
const games = await this._filesRepository.games();
|
|
743
|
+
const match = (data, filter)=>{
|
|
744
|
+
const needle = filter?.trim().toLowerCase();
|
|
745
|
+
const { name = "", system = "" } = data;
|
|
746
|
+
const systemId = system;
|
|
747
|
+
const systemName = helpfulFn.firstTruthy("", systems.get(systemId)?.name);
|
|
748
|
+
if (!needle?.length) {
|
|
749
|
+
return true;
|
|
750
|
+
}
|
|
751
|
+
return [
|
|
752
|
+
name,
|
|
753
|
+
system,
|
|
754
|
+
systemName
|
|
755
|
+
].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
|
|
756
|
+
};
|
|
757
|
+
const options = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search({
|
|
758
|
+
match
|
|
759
|
+
}).build();
|
|
760
|
+
const source = new helpfulQuery.ZDataSourceStatic(Array.from(games.values()), options);
|
|
761
|
+
const $sort = new helpfulQuery.ZSortBuilder().sorts(helpfulFn.firstDefined([], req.sort)).ascending("system").ascending("name").build();
|
|
762
|
+
const $request = new helpfulQuery.ZDataRequestBuilder().copy(req).sort($sort).build();
|
|
763
|
+
const data = await source.retrieve($request);
|
|
764
|
+
const count = await source.count($request);
|
|
765
|
+
return new helpfulQuery.ZPageBuilder().count(count).data(data).build();
|
|
766
|
+
}
|
|
767
|
+
async get(id) {
|
|
768
|
+
const filter = new helpfulQuery.ZFilterBinaryBuilder().subject("id").equal().value(id).build();
|
|
769
|
+
const request = new helpfulQuery.ZDataRequestBuilder().filter(filter).size(1).build();
|
|
770
|
+
const { data: games } = await this.list(request);
|
|
771
|
+
const [game] = games;
|
|
772
|
+
if (game == null) {
|
|
773
|
+
const message = `Game, ${id}, was not found.`;
|
|
774
|
+
throw new common.NotFoundException(message);
|
|
775
|
+
}
|
|
776
|
+
return game;
|
|
777
|
+
}
|
|
778
|
+
constructor(_systemsRepository, _filesRepository, logger){
|
|
779
|
+
_define_property$5(this, "_systemsRepository", void 0);
|
|
780
|
+
_define_property$5(this, "_filesRepository", void 0);
|
|
781
|
+
_define_property$5(this, "logger", void 0);
|
|
782
|
+
_define_property$5(this, "_logger", void 0);
|
|
783
|
+
this._systemsRepository = _systemsRepository;
|
|
784
|
+
this._filesRepository = _filesRepository;
|
|
785
|
+
this.logger = logger;
|
|
786
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorGamesService", logger);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
ZRomulatorGamesService = _ts_decorate$a([
|
|
790
|
+
common.Injectable(),
|
|
791
|
+
_ts_param$5(0, common.Inject(ZRomulatorFilesSystemsRepositoryToken)),
|
|
792
|
+
_ts_param$5(1, common.Inject(ZRomulatorFilesGamesRepositoryToken)),
|
|
793
|
+
_ts_param$5(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
794
|
+
_ts_metadata$5("design:type", Function),
|
|
795
|
+
_ts_metadata$5("design:paramtypes", [
|
|
796
|
+
typeof IZRomulatorFilesSystemsRepository === "undefined" ? Object : IZRomulatorFilesSystemsRepository,
|
|
797
|
+
typeof IZRomulatorFilesGamesRepository === "undefined" ? Object : IZRomulatorFilesGamesRepository,
|
|
798
|
+
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
799
|
+
])
|
|
800
|
+
], ZRomulatorGamesService);
|
|
801
|
+
|
|
802
|
+
function _define_property$4(obj, key, value) {
|
|
803
|
+
if (key in obj) {
|
|
804
|
+
Object.defineProperty(obj, key, {
|
|
805
|
+
value: value,
|
|
806
|
+
enumerable: true,
|
|
807
|
+
configurable: true,
|
|
808
|
+
writable: true
|
|
809
|
+
});
|
|
810
|
+
} else {
|
|
811
|
+
obj[key] = value;
|
|
812
|
+
}
|
|
813
|
+
return obj;
|
|
814
|
+
}
|
|
815
|
+
function _ts_decorate$9(decorators, target, key, desc) {
|
|
816
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
817
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
818
|
+
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;
|
|
819
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
820
|
+
}
|
|
821
|
+
function _ts_metadata$4(k, v) {
|
|
822
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
823
|
+
}
|
|
824
|
+
function _ts_param$4(paramIndex, decorator) {
|
|
825
|
+
return function(target, key) {
|
|
826
|
+
decorator(target, key, paramIndex);
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
class ZRomulatorGamesController {
|
|
830
|
+
list(query) {
|
|
831
|
+
return this._games.list(new helpfulQuery.ZDataRequestBuilder().query(query).build());
|
|
832
|
+
}
|
|
833
|
+
get(identification) {
|
|
834
|
+
return this._games.get(identification);
|
|
835
|
+
}
|
|
836
|
+
constructor(_games){
|
|
837
|
+
_define_property$4(this, "_games", void 0);
|
|
838
|
+
this._games = _games;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
_ts_decorate$9([
|
|
842
|
+
common.Get(),
|
|
843
|
+
_ts_param$4(0, common.Query()),
|
|
844
|
+
_ts_metadata$4("design:type", Function),
|
|
845
|
+
_ts_metadata$4("design:paramtypes", [
|
|
846
|
+
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
847
|
+
]),
|
|
848
|
+
_ts_metadata$4("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
849
|
+
], ZRomulatorGamesController.prototype, "list", null);
|
|
850
|
+
_ts_decorate$9([
|
|
851
|
+
common.Get(":identification"),
|
|
852
|
+
_ts_param$4(0, common.Param("identification")),
|
|
853
|
+
_ts_metadata$4("design:type", Function),
|
|
854
|
+
_ts_metadata$4("design:paramtypes", [
|
|
855
|
+
String
|
|
856
|
+
]),
|
|
857
|
+
_ts_metadata$4("design:returntype", void 0)
|
|
858
|
+
], ZRomulatorGamesController.prototype, "get", null);
|
|
859
|
+
ZRomulatorGamesController = _ts_decorate$9([
|
|
860
|
+
common.Controller("games"),
|
|
861
|
+
_ts_param$4(0, common.Inject(ZRomulatorGamesToken)),
|
|
862
|
+
_ts_metadata$4("design:type", Function),
|
|
863
|
+
_ts_metadata$4("design:paramtypes", [
|
|
864
|
+
typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
|
|
865
|
+
])
|
|
866
|
+
], ZRomulatorGamesController);
|
|
867
|
+
|
|
868
|
+
function _ts_decorate$8(decorators, target, key, desc) {
|
|
869
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
870
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
871
|
+
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;
|
|
872
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
873
|
+
}
|
|
874
|
+
class ZRomulatorGamesModule {
|
|
875
|
+
}
|
|
876
|
+
ZRomulatorGamesModule = _ts_decorate$8([
|
|
877
|
+
common.Module({
|
|
878
|
+
imports: [
|
|
879
|
+
ZRomulatorFilesModule,
|
|
880
|
+
lumberjackyNest.ZLoggerModule
|
|
881
|
+
],
|
|
882
|
+
controllers: [
|
|
883
|
+
ZRomulatorGamesController
|
|
884
|
+
],
|
|
885
|
+
providers: [
|
|
886
|
+
{
|
|
887
|
+
provide: ZRomulatorGamesToken,
|
|
888
|
+
useClass: ZRomulatorGamesService
|
|
889
|
+
}
|
|
890
|
+
]
|
|
891
|
+
})
|
|
892
|
+
], ZRomulatorGamesModule);
|
|
893
|
+
|
|
838
894
|
function _ts_decorate$7(decorators, target, key, desc) {
|
|
839
895
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
840
896
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -881,6 +937,19 @@ ZRomulatorMediaGenerator = _ts_decorate$7([
|
|
|
881
937
|
common.Injectable()
|
|
882
938
|
], ZRomulatorMediaGenerator);
|
|
883
939
|
|
|
940
|
+
function _define_property$3(obj, key, value) {
|
|
941
|
+
if (key in obj) {
|
|
942
|
+
Object.defineProperty(obj, key, {
|
|
943
|
+
value: value,
|
|
944
|
+
enumerable: true,
|
|
945
|
+
configurable: true,
|
|
946
|
+
writable: true
|
|
947
|
+
});
|
|
948
|
+
} else {
|
|
949
|
+
obj[key] = value;
|
|
950
|
+
}
|
|
951
|
+
return obj;
|
|
952
|
+
}
|
|
884
953
|
function _ts_decorate$6(decorators, target, key, desc) {
|
|
885
954
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
886
955
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -897,14 +966,6 @@ function _ts_param$3(paramIndex, decorator) {
|
|
|
897
966
|
}
|
|
898
967
|
const ZRomulatorMediaToken = Symbol("romulator-media-service");
|
|
899
968
|
class ZRomulatorMediaService {
|
|
900
|
-
_generator;
|
|
901
|
-
_files;
|
|
902
|
-
_logger;
|
|
903
|
-
constructor(_generator, _files, logger){
|
|
904
|
-
this._generator = _generator;
|
|
905
|
-
this._files = _files;
|
|
906
|
-
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorMediaService", logger);
|
|
907
|
-
}
|
|
908
969
|
async findAllMedia() {
|
|
909
970
|
const files = await this._files.media();
|
|
910
971
|
return files.map((f)=>new romulatorClient.ZRomulatorMediaBuilder().from(f.path).build()).filter((media)=>!!media.id);
|
|
@@ -999,11 +1060,19 @@ class ZRomulatorMediaService {
|
|
|
999
1060
|
log = `Deleted ${url}`;
|
|
1000
1061
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
1001
1062
|
}
|
|
1063
|
+
constructor(_generator, _files, logger){
|
|
1064
|
+
_define_property$3(this, "_generator", void 0);
|
|
1065
|
+
_define_property$3(this, "_files", void 0);
|
|
1066
|
+
_define_property$3(this, "_logger", void 0);
|
|
1067
|
+
this._generator = _generator;
|
|
1068
|
+
this._files = _files;
|
|
1069
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorMediaService", logger);
|
|
1070
|
+
}
|
|
1002
1071
|
}
|
|
1003
1072
|
ZRomulatorMediaService = _ts_decorate$6([
|
|
1004
1073
|
common.Injectable(),
|
|
1005
1074
|
_ts_param$3(0, common.Inject(ZRomulatorMediaGeneratorToken)),
|
|
1006
|
-
_ts_param$3(1, common.Inject(
|
|
1075
|
+
_ts_param$3(1, common.Inject(ZRomulatorFilesRepositoryToken)),
|
|
1007
1076
|
_ts_param$3(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
1008
1077
|
_ts_metadata$3("design:type", Function),
|
|
1009
1078
|
_ts_metadata$3("design:paramtypes", [
|
|
@@ -1013,6 +1082,19 @@ ZRomulatorMediaService = _ts_decorate$6([
|
|
|
1013
1082
|
])
|
|
1014
1083
|
], ZRomulatorMediaService);
|
|
1015
1084
|
|
|
1085
|
+
function _define_property$2(obj, key, value) {
|
|
1086
|
+
if (key in obj) {
|
|
1087
|
+
Object.defineProperty(obj, key, {
|
|
1088
|
+
value: value,
|
|
1089
|
+
enumerable: true,
|
|
1090
|
+
configurable: true,
|
|
1091
|
+
writable: true
|
|
1092
|
+
});
|
|
1093
|
+
} else {
|
|
1094
|
+
obj[key] = value;
|
|
1095
|
+
}
|
|
1096
|
+
return obj;
|
|
1097
|
+
}
|
|
1016
1098
|
function _ts_decorate$5(decorators, target, key, desc) {
|
|
1017
1099
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1018
1100
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1028,10 +1110,6 @@ function _ts_param$2(paramIndex, decorator) {
|
|
|
1028
1110
|
};
|
|
1029
1111
|
}
|
|
1030
1112
|
class ZRomulatorMediaController {
|
|
1031
|
-
_media;
|
|
1032
|
-
constructor(_media){
|
|
1033
|
-
this._media = _media;
|
|
1034
|
-
}
|
|
1035
1113
|
list(params) {
|
|
1036
1114
|
const request = new helpfulQuery.ZDataRequestBuilder().query(params).build();
|
|
1037
1115
|
return this._media.list(request);
|
|
@@ -1043,6 +1121,10 @@ class ZRomulatorMediaController {
|
|
|
1043
1121
|
async delete(identification) {
|
|
1044
1122
|
await this._media.delete(identification);
|
|
1045
1123
|
}
|
|
1124
|
+
constructor(_media){
|
|
1125
|
+
_define_property$2(this, "_media", void 0);
|
|
1126
|
+
this._media = _media;
|
|
1127
|
+
}
|
|
1046
1128
|
}
|
|
1047
1129
|
_ts_decorate$5([
|
|
1048
1130
|
swagger.ApiQuery({
|
|
@@ -1179,6 +1261,19 @@ ZRomulatorMediaModule = _ts_decorate$4([
|
|
|
1179
1261
|
})
|
|
1180
1262
|
], ZRomulatorMediaModule);
|
|
1181
1263
|
|
|
1264
|
+
function _define_property$1(obj, key, value) {
|
|
1265
|
+
if (key in obj) {
|
|
1266
|
+
Object.defineProperty(obj, key, {
|
|
1267
|
+
value: value,
|
|
1268
|
+
enumerable: true,
|
|
1269
|
+
configurable: true,
|
|
1270
|
+
writable: true
|
|
1271
|
+
});
|
|
1272
|
+
} else {
|
|
1273
|
+
obj[key] = value;
|
|
1274
|
+
}
|
|
1275
|
+
return obj;
|
|
1276
|
+
}
|
|
1182
1277
|
function _ts_decorate$3(decorators, target, key, desc) {
|
|
1183
1278
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1184
1279
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1195,30 +1290,18 @@ function _ts_param$1(paramIndex, decorator) {
|
|
|
1195
1290
|
}
|
|
1196
1291
|
const ZRomulatorSystemsToken = Symbol("romulator-systems-service");
|
|
1197
1292
|
class ZRomulatorSystemsService {
|
|
1198
|
-
_filesRepository;
|
|
1199
|
-
_systemsRepository;
|
|
1200
|
-
logger;
|
|
1201
|
-
_logger;
|
|
1202
|
-
constructor(_filesRepository, _systemsRepository, logger){
|
|
1203
|
-
this._filesRepository = _filesRepository;
|
|
1204
|
-
this._systemsRepository = _systemsRepository;
|
|
1205
|
-
this.logger = logger;
|
|
1206
|
-
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorSystemsService", logger);
|
|
1207
|
-
}
|
|
1208
1293
|
async list(req) {
|
|
1209
1294
|
const page = helpfulFn.firstDefined(1, req.page);
|
|
1210
1295
|
const size = helpfulFn.firstDefined(Infinity, req.size);
|
|
1211
1296
|
let msg = `Retrieving systems page, ${page}, with size, ${size}.`;
|
|
1212
1297
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
1213
|
-
const
|
|
1214
|
-
const
|
|
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()));
|
|
1298
|
+
const systemMap = await this._systemsRepository.systems();
|
|
1299
|
+
const systems = Array.from(systemMap.values());
|
|
1216
1300
|
msg = `Found ${systems.length} systems`;
|
|
1217
1301
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
1218
1302
|
const sourceOptions = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields([
|
|
1219
1303
|
"id",
|
|
1220
|
-
"name"
|
|
1221
|
-
"short"
|
|
1304
|
+
"name"
|
|
1222
1305
|
])).build();
|
|
1223
1306
|
const source = new helpfulQuery.ZDataSourceStatic(systems, sourceOptions);
|
|
1224
1307
|
const data = await source.retrieve(req);
|
|
@@ -1231,29 +1314,49 @@ class ZRomulatorSystemsService {
|
|
|
1231
1314
|
const message = `The specified system slug, ${id}, is not supported.`;
|
|
1232
1315
|
throw new common.NotFoundException(message);
|
|
1233
1316
|
}
|
|
1234
|
-
const
|
|
1317
|
+
const filter = new helpfulQuery.ZFilterBinaryBuilder().subject("id").equal().value(id).build();
|
|
1318
|
+
const request = new helpfulQuery.ZDataRequestBuilder().filter(filter).size(1).build();
|
|
1319
|
+
const { data: systems } = await this.list(request);
|
|
1320
|
+
const [system] = systems;
|
|
1235
1321
|
if (system == null) {
|
|
1236
1322
|
const message = `System with slug, ${id}, was not found.`;
|
|
1237
1323
|
throw new common.NotFoundException(message);
|
|
1238
1324
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1325
|
+
return system;
|
|
1326
|
+
}
|
|
1327
|
+
constructor(_systemsRepository, logger){
|
|
1328
|
+
_define_property$1(this, "_systemsRepository", void 0);
|
|
1329
|
+
_define_property$1(this, "logger", void 0);
|
|
1330
|
+
_define_property$1(this, "_logger", void 0);
|
|
1331
|
+
this._systemsRepository = _systemsRepository;
|
|
1332
|
+
this.logger = logger;
|
|
1333
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorSystemsService", logger);
|
|
1242
1334
|
}
|
|
1243
1335
|
}
|
|
1244
1336
|
ZRomulatorSystemsService = _ts_decorate$3([
|
|
1245
1337
|
common.Injectable(),
|
|
1246
|
-
_ts_param$1(0, common.Inject(
|
|
1247
|
-
_ts_param$1(1, common.Inject(
|
|
1248
|
-
_ts_param$1(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
1338
|
+
_ts_param$1(0, common.Inject(ZRomulatorFilesSystemsRepositoryToken)),
|
|
1339
|
+
_ts_param$1(1, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
1249
1340
|
_ts_metadata$1("design:type", Function),
|
|
1250
1341
|
_ts_metadata$1("design:paramtypes", [
|
|
1251
|
-
typeof
|
|
1252
|
-
typeof IZRomulatorFilesSystemsJsonRepository === "undefined" ? Object : IZRomulatorFilesSystemsJsonRepository,
|
|
1342
|
+
typeof IZRomulatorFilesSystemsRepository === "undefined" ? Object : IZRomulatorFilesSystemsRepository,
|
|
1253
1343
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
1254
1344
|
])
|
|
1255
1345
|
], ZRomulatorSystemsService);
|
|
1256
1346
|
|
|
1347
|
+
function _define_property(obj, key, value) {
|
|
1348
|
+
if (key in obj) {
|
|
1349
|
+
Object.defineProperty(obj, key, {
|
|
1350
|
+
value: value,
|
|
1351
|
+
enumerable: true,
|
|
1352
|
+
configurable: true,
|
|
1353
|
+
writable: true
|
|
1354
|
+
});
|
|
1355
|
+
} else {
|
|
1356
|
+
obj[key] = value;
|
|
1357
|
+
}
|
|
1358
|
+
return obj;
|
|
1359
|
+
}
|
|
1257
1360
|
function _ts_decorate$2(decorators, target, key, desc) {
|
|
1258
1361
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1259
1362
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1269,16 +1372,16 @@ function _ts_param(paramIndex, decorator) {
|
|
|
1269
1372
|
};
|
|
1270
1373
|
}
|
|
1271
1374
|
class ZRomulatorSystemsController {
|
|
1272
|
-
_systems;
|
|
1273
|
-
constructor(_systems){
|
|
1274
|
-
this._systems = _systems;
|
|
1275
|
-
}
|
|
1276
1375
|
list(query) {
|
|
1277
1376
|
return this._systems.list(new helpfulQuery.ZDataRequestBuilder().query(query).build());
|
|
1278
1377
|
}
|
|
1279
1378
|
get(identification) {
|
|
1280
1379
|
return this._systems.get(identification);
|
|
1281
1380
|
}
|
|
1381
|
+
constructor(_systems){
|
|
1382
|
+
_define_property(this, "_systems", void 0);
|
|
1383
|
+
this._systems = _systems;
|
|
1384
|
+
}
|
|
1282
1385
|
}
|
|
1283
1386
|
_ts_decorate$2([
|
|
1284
1387
|
common.Get(),
|