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