@zthun/romulator-api 1.3.4 → 1.4.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/games/data-match-game.d.mts +9 -0
- package/dist/games/games-controller.d.mts +9 -0
- package/dist/games/games-module.d.mts +2 -0
- package/dist/games/games-service.d.mts +18 -0
- package/dist/main.cjs +246 -68
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +251 -73
- package/dist/main.js.map +1 -1
- package/package.json +17 -17
package/dist/main.js
CHANGED
|
@@ -3,36 +3,36 @@ import { ApiProperty, ApiParam, ApiBody, ApiResponse, DocumentBuilder, SwaggerMo
|
|
|
3
3
|
import { InternalServerErrorException, NotFoundException, Injectable, Inject, Get, Query, Patch, UsePipes, ValidationPipe, Param, Body, Controller, Module, NotAcceptableException, StreamableFile, ForbiddenException, Req, Delete } from '@nestjs/common';
|
|
4
4
|
import { ZFileSystemModule, ZFileSystemToken } from '@zthun/crumbtrail-nest';
|
|
5
5
|
import { ZLoggerToken, ZLoggerModule } from '@zthun/lumberjacky-nest';
|
|
6
|
-
import { ZDataSourceStaticOptionsBuilder, ZDataSearchFields, ZDataSourceStatic, ZPageBuilder, ZDataRequestBuilder } from '@zthun/helpful-query';
|
|
6
|
+
import { ZDataSourceStaticOptionsBuilder, ZDataSearchFields, ZDataSourceStatic, ZPageBuilder, ZDataRequestBuilder, ZSortBuilder } from '@zthun/helpful-query';
|
|
7
7
|
import { IsDefined, IsObject, IsNotEmptyObject } from 'class-validator';
|
|
8
|
-
import { firstDefined, createError,
|
|
8
|
+
import { firstDefined, createError, firstTruthy, detokenize } from '@zthun/helpful-fn';
|
|
9
9
|
import { ZLoggerContext, ZLogEntryBuilder } from '@zthun/lumberjacky-log';
|
|
10
|
-
import { ZRomulatorConfigBuilder, ZRomulatorConfigId as ZRomulatorConfigId$1, ZRomulatorConfigGamesMetadata, ZRomulatorConfigMediaMetadata, ZRomulatorSystemBuilder, ZRomulatorSystemId, ZRomulatorConfigMediaBuilder, ZRomulatorMediaBuilder } from '@zthun/romulator-client';
|
|
11
|
-
import { find, findIndex } from 'lodash-es';
|
|
10
|
+
import { ZRomulatorConfigBuilder, ZRomulatorConfigId as ZRomulatorConfigId$1, ZRomulatorConfigGamesMetadata, ZRomulatorConfigMediaMetadata, ZRomulatorSystemBuilder, ZRomulatorSystemId, ZRomulatorConfigGamesBuilder, ZRomulatorGameBuilder, ZRomulatorConfigMediaBuilder, ZRomulatorMediaBuilder } from '@zthun/romulator-client';
|
|
11
|
+
import { find, kebabCase, findIndex } from 'lodash-es';
|
|
12
12
|
import { readFile, mkdir, writeFile, unlink } from 'node:fs/promises';
|
|
13
|
-
import { resolve, dirname, basename } from 'node:path';
|
|
13
|
+
import { resolve, dirname, basename, parse } from 'node:path';
|
|
14
14
|
import { homedir } from 'node:os';
|
|
15
|
+
import { isTagged, ZTag } from '@zthun/helpful-reflection';
|
|
16
|
+
import 'reflect-metadata';
|
|
15
17
|
import { ZHttpCodeSuccess, ZHttpCodeClient } from '@zthun/webigail-http';
|
|
16
18
|
import { ZMimeTypeApplication } from '@zthun/webigail-url';
|
|
17
19
|
import { lookup } from 'mime-types';
|
|
18
20
|
import { createReadStream } from 'node:fs';
|
|
19
21
|
import { env } from 'node:process';
|
|
20
|
-
import { isTagged, ZTag } from '@zthun/helpful-reflection';
|
|
21
|
-
import 'reflect-metadata';
|
|
22
22
|
|
|
23
|
-
function _ts_decorate$
|
|
23
|
+
function _ts_decorate$e(decorators, target, key, desc) {
|
|
24
24
|
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
25
25
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
26
26
|
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;
|
|
27
27
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
28
|
}
|
|
29
|
-
function _ts_metadata$
|
|
29
|
+
function _ts_metadata$9(k, v) {
|
|
30
30
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
31
31
|
}
|
|
32
32
|
class ZRomulatorConfigUpdateDto {
|
|
33
33
|
contents;
|
|
34
34
|
}
|
|
35
|
-
_ts_decorate$
|
|
35
|
+
_ts_decorate$e([
|
|
36
36
|
ApiProperty({
|
|
37
37
|
type: "object",
|
|
38
38
|
properties: {}
|
|
@@ -44,7 +44,7 @@ _ts_decorate$b([
|
|
|
44
44
|
message: "The contents of the config must be an object "
|
|
45
45
|
}),
|
|
46
46
|
IsNotEmptyObject(),
|
|
47
|
-
_ts_metadata$
|
|
47
|
+
_ts_metadata$9("design:type", typeof T === "undefined" ? Object : T)
|
|
48
48
|
], ZRomulatorConfigUpdateDto.prototype, "contents", void 0);
|
|
49
49
|
|
|
50
50
|
class ZDir {
|
|
@@ -75,16 +75,16 @@ class ZRomulatorConfigKnown {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function _ts_decorate$
|
|
78
|
+
function _ts_decorate$d(decorators, target, key, desc) {
|
|
79
79
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
80
80
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
81
81
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
82
82
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
83
83
|
}
|
|
84
|
-
function _ts_metadata$
|
|
84
|
+
function _ts_metadata$8(k, v) {
|
|
85
85
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
86
86
|
}
|
|
87
|
-
function _ts_param$
|
|
87
|
+
function _ts_param$7(paramIndex, decorator) {
|
|
88
88
|
return function(target, key) {
|
|
89
89
|
decorator(target, key, paramIndex);
|
|
90
90
|
};
|
|
@@ -166,25 +166,25 @@ class ZRomulatorConfigsService {
|
|
|
166
166
|
return config;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
ZRomulatorConfigsService = _ts_decorate$
|
|
169
|
+
ZRomulatorConfigsService = _ts_decorate$d([
|
|
170
170
|
Injectable(),
|
|
171
|
-
_ts_param$
|
|
172
|
-
_ts_metadata$
|
|
173
|
-
_ts_metadata$
|
|
171
|
+
_ts_param$7(0, Inject(ZLoggerToken)),
|
|
172
|
+
_ts_metadata$8("design:type", Function),
|
|
173
|
+
_ts_metadata$8("design:paramtypes", [
|
|
174
174
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
175
175
|
])
|
|
176
176
|
], ZRomulatorConfigsService);
|
|
177
177
|
|
|
178
|
-
function _ts_decorate$
|
|
178
|
+
function _ts_decorate$c(decorators, target, key, desc) {
|
|
179
179
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
180
180
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
181
181
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
182
182
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
183
183
|
}
|
|
184
|
-
function _ts_metadata$
|
|
184
|
+
function _ts_metadata$7(k, v) {
|
|
185
185
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
186
186
|
}
|
|
187
|
-
function _ts_param$
|
|
187
|
+
function _ts_param$6(paramIndex, decorator) {
|
|
188
188
|
return function(target, key) {
|
|
189
189
|
decorator(target, key, paramIndex);
|
|
190
190
|
};
|
|
@@ -205,16 +205,16 @@ class ZRomulatorConfigsController {
|
|
|
205
205
|
return await this._configs.get(identification);
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
_ts_decorate$
|
|
208
|
+
_ts_decorate$c([
|
|
209
209
|
Get(),
|
|
210
|
-
_ts_param$
|
|
211
|
-
_ts_metadata$
|
|
212
|
-
_ts_metadata$
|
|
210
|
+
_ts_param$6(0, Query()),
|
|
211
|
+
_ts_metadata$7("design:type", Function),
|
|
212
|
+
_ts_metadata$7("design:paramtypes", [
|
|
213
213
|
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
214
214
|
]),
|
|
215
|
-
_ts_metadata$
|
|
215
|
+
_ts_metadata$7("design:returntype", Promise)
|
|
216
216
|
], ZRomulatorConfigsController.prototype, "list", null);
|
|
217
|
-
_ts_decorate$
|
|
217
|
+
_ts_decorate$c([
|
|
218
218
|
ApiParam({
|
|
219
219
|
type: "string",
|
|
220
220
|
name: "identification",
|
|
@@ -231,39 +231,39 @@ _ts_decorate$9([
|
|
|
231
231
|
skipNullProperties: false,
|
|
232
232
|
skipUndefinedProperties: false
|
|
233
233
|
})),
|
|
234
|
-
_ts_param$
|
|
235
|
-
_ts_param$
|
|
236
|
-
_ts_metadata$
|
|
237
|
-
_ts_metadata$
|
|
234
|
+
_ts_param$6(0, Param("identification")),
|
|
235
|
+
_ts_param$6(1, Body()),
|
|
236
|
+
_ts_metadata$7("design:type", Function),
|
|
237
|
+
_ts_metadata$7("design:paramtypes", [
|
|
238
238
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
|
|
239
239
|
typeof ZRomulatorConfigUpdateDto === "undefined" ? Object : ZRomulatorConfigUpdateDto
|
|
240
240
|
]),
|
|
241
|
-
_ts_metadata$
|
|
241
|
+
_ts_metadata$7("design:returntype", Promise)
|
|
242
242
|
], ZRomulatorConfigsController.prototype, "update", null);
|
|
243
|
-
_ts_decorate$
|
|
243
|
+
_ts_decorate$c([
|
|
244
244
|
ApiParam({
|
|
245
245
|
type: "string",
|
|
246
246
|
name: "identification",
|
|
247
247
|
description: "The id of the config"
|
|
248
248
|
}),
|
|
249
249
|
Get(":identification"),
|
|
250
|
-
_ts_param$
|
|
251
|
-
_ts_metadata$
|
|
252
|
-
_ts_metadata$
|
|
250
|
+
_ts_param$6(0, Param("identification")),
|
|
251
|
+
_ts_metadata$7("design:type", Function),
|
|
252
|
+
_ts_metadata$7("design:paramtypes", [
|
|
253
253
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
|
|
254
254
|
]),
|
|
255
|
-
_ts_metadata$
|
|
255
|
+
_ts_metadata$7("design:returntype", Promise)
|
|
256
256
|
], ZRomulatorConfigsController.prototype, "get", null);
|
|
257
|
-
ZRomulatorConfigsController = _ts_decorate$
|
|
257
|
+
ZRomulatorConfigsController = _ts_decorate$c([
|
|
258
258
|
Controller("configs"),
|
|
259
|
-
_ts_param$
|
|
260
|
-
_ts_metadata$
|
|
261
|
-
_ts_metadata$
|
|
259
|
+
_ts_param$6(0, Inject(ZRomulatorConfigsToken)),
|
|
260
|
+
_ts_metadata$7("design:type", Function),
|
|
261
|
+
_ts_metadata$7("design:paramtypes", [
|
|
262
262
|
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
|
|
263
263
|
])
|
|
264
264
|
], ZRomulatorConfigsController);
|
|
265
265
|
|
|
266
|
-
function _ts_decorate$
|
|
266
|
+
function _ts_decorate$b(decorators, target, key, desc) {
|
|
267
267
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
268
268
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
269
269
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -271,7 +271,7 @@ function _ts_decorate$8(decorators, target, key, desc) {
|
|
|
271
271
|
}
|
|
272
272
|
class ZRomulatorConfigsModule {
|
|
273
273
|
}
|
|
274
|
-
ZRomulatorConfigsModule = _ts_decorate$
|
|
274
|
+
ZRomulatorConfigsModule = _ts_decorate$b([
|
|
275
275
|
Module({
|
|
276
276
|
imports: [
|
|
277
277
|
ZFileSystemModule,
|
|
@@ -292,13 +292,13 @@ ZRomulatorConfigsModule = _ts_decorate$8([
|
|
|
292
292
|
})
|
|
293
293
|
], ZRomulatorConfigsModule);
|
|
294
294
|
|
|
295
|
-
function _ts_decorate$
|
|
295
|
+
function _ts_decorate$a(decorators, target, key, desc) {
|
|
296
296
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
297
297
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
298
298
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
299
299
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
300
300
|
}
|
|
301
|
-
function _ts_metadata$
|
|
301
|
+
function _ts_metadata$6(k, v) {
|
|
302
302
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
303
303
|
}
|
|
304
304
|
const KnownSystem = "@zthunworks/romulator/known-system";
|
|
@@ -394,48 +394,225 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
394
394
|
return null;
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
_ts_decorate$
|
|
397
|
+
_ts_decorate$a([
|
|
398
398
|
ZTag(KnownSystem),
|
|
399
|
-
_ts_metadata$
|
|
400
|
-
_ts_metadata$
|
|
401
|
-
_ts_metadata$
|
|
399
|
+
_ts_metadata$6("design:type", Function),
|
|
400
|
+
_ts_metadata$6("design:paramtypes", []),
|
|
401
|
+
_ts_metadata$6("design:returntype", void 0)
|
|
402
402
|
], ZRomulatorSystemKnown, "nes", null);
|
|
403
|
-
_ts_decorate$
|
|
403
|
+
_ts_decorate$a([
|
|
404
404
|
ZTag(KnownSystem),
|
|
405
|
-
_ts_metadata$
|
|
406
|
-
_ts_metadata$
|
|
407
|
-
_ts_metadata$
|
|
405
|
+
_ts_metadata$6("design:type", Function),
|
|
406
|
+
_ts_metadata$6("design:paramtypes", []),
|
|
407
|
+
_ts_metadata$6("design:returntype", void 0)
|
|
408
408
|
], ZRomulatorSystemKnown, "snes", null);
|
|
409
|
-
_ts_decorate$
|
|
409
|
+
_ts_decorate$a([
|
|
410
410
|
ZTag(KnownSystem),
|
|
411
|
-
_ts_metadata$
|
|
412
|
-
_ts_metadata$
|
|
413
|
-
_ts_metadata$
|
|
411
|
+
_ts_metadata$6("design:type", Function),
|
|
412
|
+
_ts_metadata$6("design:paramtypes", []),
|
|
413
|
+
_ts_metadata$6("design:returntype", void 0)
|
|
414
414
|
], ZRomulatorSystemKnown, "n64", null);
|
|
415
|
-
_ts_decorate$
|
|
415
|
+
_ts_decorate$a([
|
|
416
416
|
ZTag(KnownSystem),
|
|
417
|
-
_ts_metadata$
|
|
418
|
-
_ts_metadata$
|
|
419
|
-
_ts_metadata$
|
|
417
|
+
_ts_metadata$6("design:type", Function),
|
|
418
|
+
_ts_metadata$6("design:paramtypes", []),
|
|
419
|
+
_ts_metadata$6("design:returntype", void 0)
|
|
420
420
|
], ZRomulatorSystemKnown, "gc", null);
|
|
421
|
-
_ts_decorate$
|
|
421
|
+
_ts_decorate$a([
|
|
422
422
|
ZTag(KnownSystem),
|
|
423
|
-
_ts_metadata$
|
|
424
|
-
_ts_metadata$
|
|
425
|
-
_ts_metadata$
|
|
423
|
+
_ts_metadata$6("design:type", Function),
|
|
424
|
+
_ts_metadata$6("design:paramtypes", []),
|
|
425
|
+
_ts_metadata$6("design:returntype", void 0)
|
|
426
426
|
], ZRomulatorSystemKnown, "wii", null);
|
|
427
|
-
_ts_decorate$
|
|
427
|
+
_ts_decorate$a([
|
|
428
428
|
ZTag(KnownSystem),
|
|
429
|
-
_ts_metadata$
|
|
430
|
-
_ts_metadata$
|
|
431
|
-
_ts_metadata$
|
|
429
|
+
_ts_metadata$6("design:type", Function),
|
|
430
|
+
_ts_metadata$6("design:paramtypes", []),
|
|
431
|
+
_ts_metadata$6("design:returntype", void 0)
|
|
432
432
|
], ZRomulatorSystemKnown, "wiiu", null);
|
|
433
|
-
_ts_decorate$
|
|
433
|
+
_ts_decorate$a([
|
|
434
434
|
ZTag(KnownSystem),
|
|
435
|
+
_ts_metadata$6("design:type", Function),
|
|
436
|
+
_ts_metadata$6("design:paramtypes", []),
|
|
437
|
+
_ts_metadata$6("design:returntype", void 0)
|
|
438
|
+
], ZRomulatorSystemKnown, "switch", null);
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* A data match function which matches a string (search) filter
|
|
442
|
+
* to a game's name, system slug, or system name.
|
|
443
|
+
*/ class ZRomulatorDataMatchGame {
|
|
444
|
+
match(data, filter) {
|
|
445
|
+
const needle = filter?.trim().toLowerCase();
|
|
446
|
+
const { name = "", system = "" } = data;
|
|
447
|
+
const target = ZRomulatorSystemKnown.from(system);
|
|
448
|
+
const systemName = firstTruthy("", target?.name);
|
|
449
|
+
if (!needle?.length) {
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
return [
|
|
453
|
+
name,
|
|
454
|
+
system,
|
|
455
|
+
systemName
|
|
456
|
+
].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function _ts_decorate$9(decorators, target, key, desc) {
|
|
461
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
462
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
463
|
+
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;
|
|
464
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
465
|
+
}
|
|
466
|
+
function _ts_metadata$5(k, v) {
|
|
467
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
468
|
+
}
|
|
469
|
+
function _ts_param$5(paramIndex, decorator) {
|
|
470
|
+
return function(target, key) {
|
|
471
|
+
decorator(target, key, paramIndex);
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const ZRomulatorGamesToken = Symbol("romulator-games-service");
|
|
475
|
+
class ZRomulatorGamesService {
|
|
476
|
+
_file;
|
|
477
|
+
_config;
|
|
478
|
+
_logger;
|
|
479
|
+
constructor(_file, _config, logger){
|
|
480
|
+
this._file = _file;
|
|
481
|
+
this._config = _config;
|
|
482
|
+
this._logger = new ZLoggerContext("ZRomulatorGamesService", logger);
|
|
483
|
+
}
|
|
484
|
+
async list(req) {
|
|
485
|
+
const config = ZRomulatorConfigKnown.games();
|
|
486
|
+
const { contents } = await this._config.get(config.id);
|
|
487
|
+
const { gamesFolder } = new ZRomulatorConfigGamesBuilder().copy(contents).build();
|
|
488
|
+
const { fallback } = ZRomulatorConfigGamesMetadata.gamesFolder();
|
|
489
|
+
const cwd = detokenize(firstDefined(fallback, gamesFolder), process.env);
|
|
490
|
+
const time = new Date();
|
|
491
|
+
let msg = `Searching for games in ${cwd}`;
|
|
492
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
493
|
+
const systems = ZRomulatorSystemKnown.all().map((system)=>system.id);
|
|
494
|
+
const glob = `{${systems.join(",")}}/**/*.zip`;
|
|
495
|
+
const nodes = await this._file.search(glob, {
|
|
496
|
+
cwd,
|
|
497
|
+
stat: false
|
|
498
|
+
});
|
|
499
|
+
const span = new Date().getTime() - time.getTime();
|
|
500
|
+
msg = `Found ${nodes.length} games. Search took ${span} milliseconds.`;
|
|
501
|
+
this._logger.log(new ZLogEntryBuilder().info().message(msg).build());
|
|
502
|
+
const games = nodes.map(({ path })=>{
|
|
503
|
+
const dir = basename(dirname(path));
|
|
504
|
+
const { name: file } = parse(path);
|
|
505
|
+
const id = `${dir}-${kebabCase(file)}`;
|
|
506
|
+
return new ZRomulatorGameBuilder().id(id).system(dir).file(path).name(file).build();
|
|
507
|
+
});
|
|
508
|
+
const options = new ZDataSourceStaticOptionsBuilder().search(new ZRomulatorDataMatchGame()).build();
|
|
509
|
+
const source = new ZDataSourceStatic(games, options);
|
|
510
|
+
const $sort = new ZSortBuilder().sorts(firstDefined([], req.sort)).ascending("system").ascending("name").build();
|
|
511
|
+
const $request = new ZDataRequestBuilder().copy(req).sort($sort).build();
|
|
512
|
+
const data = await source.retrieve($request);
|
|
513
|
+
return data;
|
|
514
|
+
}
|
|
515
|
+
async get(id) {
|
|
516
|
+
const games = await this.list(new ZDataRequestBuilder().build());
|
|
517
|
+
const match = games.find((game)=>game.id === id);
|
|
518
|
+
if (!match) {
|
|
519
|
+
throw new NotFoundException(`Unable to find game with id, ${id}.`);
|
|
520
|
+
}
|
|
521
|
+
return match;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
ZRomulatorGamesService = _ts_decorate$9([
|
|
525
|
+
Injectable(),
|
|
526
|
+
_ts_param$5(0, Inject(ZFileSystemToken)),
|
|
527
|
+
_ts_param$5(1, Inject(ZRomulatorConfigsToken)),
|
|
528
|
+
_ts_param$5(2, Inject(ZLoggerToken)),
|
|
529
|
+
_ts_metadata$5("design:type", Function),
|
|
530
|
+
_ts_metadata$5("design:paramtypes", [
|
|
531
|
+
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
|
|
532
|
+
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
533
|
+
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
534
|
+
])
|
|
535
|
+
], ZRomulatorGamesService);
|
|
536
|
+
|
|
537
|
+
function _ts_decorate$8(decorators, target, key, desc) {
|
|
538
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
539
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
540
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
541
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
542
|
+
}
|
|
543
|
+
function _ts_metadata$4(k, v) {
|
|
544
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
545
|
+
}
|
|
546
|
+
function _ts_param$4(paramIndex, decorator) {
|
|
547
|
+
return function(target, key) {
|
|
548
|
+
decorator(target, key, paramIndex);
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
class ZRomulatorGamesController {
|
|
552
|
+
_games;
|
|
553
|
+
constructor(_games){
|
|
554
|
+
this._games = _games;
|
|
555
|
+
}
|
|
556
|
+
list(query) {
|
|
557
|
+
return this._games.list(new ZDataRequestBuilder().query(query).build());
|
|
558
|
+
}
|
|
559
|
+
get(identification) {
|
|
560
|
+
return this._games.get(identification);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
_ts_decorate$8([
|
|
564
|
+
Get(),
|
|
565
|
+
_ts_param$4(0, Query()),
|
|
435
566
|
_ts_metadata$4("design:type", Function),
|
|
436
|
-
_ts_metadata$4("design:paramtypes", [
|
|
567
|
+
_ts_metadata$4("design:paramtypes", [
|
|
568
|
+
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
569
|
+
]),
|
|
570
|
+
_ts_metadata$4("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
571
|
+
], ZRomulatorGamesController.prototype, "list", null);
|
|
572
|
+
_ts_decorate$8([
|
|
573
|
+
Get(":identification"),
|
|
574
|
+
_ts_param$4(0, Param("identification")),
|
|
575
|
+
_ts_metadata$4("design:type", Function),
|
|
576
|
+
_ts_metadata$4("design:paramtypes", [
|
|
577
|
+
String
|
|
578
|
+
]),
|
|
437
579
|
_ts_metadata$4("design:returntype", void 0)
|
|
438
|
-
],
|
|
580
|
+
], ZRomulatorGamesController.prototype, "get", null);
|
|
581
|
+
ZRomulatorGamesController = _ts_decorate$8([
|
|
582
|
+
Controller("games"),
|
|
583
|
+
_ts_param$4(0, Inject(ZRomulatorGamesToken)),
|
|
584
|
+
_ts_metadata$4("design:type", Function),
|
|
585
|
+
_ts_metadata$4("design:paramtypes", [
|
|
586
|
+
typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
|
|
587
|
+
])
|
|
588
|
+
], ZRomulatorGamesController);
|
|
589
|
+
|
|
590
|
+
function _ts_decorate$7(decorators, target, key, desc) {
|
|
591
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
592
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
594
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
595
|
+
}
|
|
596
|
+
class ZRomulatorGamesModule {
|
|
597
|
+
}
|
|
598
|
+
ZRomulatorGamesModule = _ts_decorate$7([
|
|
599
|
+
Module({
|
|
600
|
+
imports: [
|
|
601
|
+
ZRomulatorConfigsModule,
|
|
602
|
+
ZFileSystemModule,
|
|
603
|
+
ZLoggerModule
|
|
604
|
+
],
|
|
605
|
+
controllers: [
|
|
606
|
+
ZRomulatorGamesController
|
|
607
|
+
],
|
|
608
|
+
providers: [
|
|
609
|
+
{
|
|
610
|
+
provide: ZRomulatorGamesToken,
|
|
611
|
+
useClass: ZRomulatorGamesService
|
|
612
|
+
}
|
|
613
|
+
]
|
|
614
|
+
})
|
|
615
|
+
], ZRomulatorGamesModule);
|
|
439
616
|
|
|
440
617
|
function _ts_decorate$6(decorators, target, key, desc) {
|
|
441
618
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -868,7 +1045,8 @@ ZRomulatorModule = _ts_decorate([
|
|
|
868
1045
|
imports: [
|
|
869
1046
|
ZRomulatorSystemsModule,
|
|
870
1047
|
ZRomulatorConfigsModule,
|
|
871
|
-
ZRomulatorMediaModule
|
|
1048
|
+
ZRomulatorMediaModule,
|
|
1049
|
+
ZRomulatorGamesModule
|
|
872
1050
|
]
|
|
873
1051
|
})
|
|
874
1052
|
], ZRomulatorModule);
|