@zthun/romulator-api 1.5.0 → 1.7.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/config/config-known.d.mts +0 -1
- package/dist/files/files-module.d.mts +2 -0
- package/dist/files/files-service.d.mts +96 -0
- package/dist/main.cjs +328 -167
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +333 -172
- package/dist/main.js.map +1 -1
- package/dist/media/media-service.d.mts +3 -6
- package/dist/systems/systems-service.d.mts +5 -5
- package/package.json +13 -13
package/dist/main.cjs
CHANGED
|
@@ -16,25 +16,26 @@ const node_path = require('node:path');
|
|
|
16
16
|
const node_os = require('node:os');
|
|
17
17
|
const helpfulReflection = require('@zthun/helpful-reflection');
|
|
18
18
|
require('reflect-metadata');
|
|
19
|
+
const crumbtrailFs = require('@zthun/crumbtrail-fs');
|
|
20
|
+
const node_process = require('node:process');
|
|
19
21
|
const webigailHttp = require('@zthun/webigail-http');
|
|
20
22
|
const webigailUrl = require('@zthun/webigail-url');
|
|
21
23
|
const mimeTypes = require('mime-types');
|
|
22
24
|
const node_fs = require('node:fs');
|
|
23
|
-
const node_process = require('node:process');
|
|
24
25
|
|
|
25
|
-
function _ts_decorate$
|
|
26
|
+
function _ts_decorate$g(decorators, target, key, desc) {
|
|
26
27
|
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
27
28
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
29
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
30
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
31
|
}
|
|
31
|
-
function _ts_metadata$
|
|
32
|
+
function _ts_metadata$a(k, v) {
|
|
32
33
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
34
|
}
|
|
34
35
|
class ZRomulatorConfigUpdateDto {
|
|
35
36
|
contents;
|
|
36
37
|
}
|
|
37
|
-
_ts_decorate$
|
|
38
|
+
_ts_decorate$g([
|
|
38
39
|
swagger.ApiProperty({
|
|
39
40
|
type: "object",
|
|
40
41
|
properties: {}
|
|
@@ -46,7 +47,7 @@ _ts_decorate$e([
|
|
|
46
47
|
message: "The contents of the config must be an object "
|
|
47
48
|
}),
|
|
48
49
|
classValidator.IsNotEmptyObject(),
|
|
49
|
-
_ts_metadata$
|
|
50
|
+
_ts_metadata$a("design:type", typeof T === "undefined" ? Object : T)
|
|
50
51
|
], ZRomulatorConfigUpdateDto.prototype, "contents", void 0);
|
|
51
52
|
|
|
52
53
|
class ZDir {
|
|
@@ -61,8 +62,7 @@ class ZDir {
|
|
|
61
62
|
class ZRomulatorConfigKnown {
|
|
62
63
|
static all() {
|
|
63
64
|
return [
|
|
64
|
-
ZRomulatorConfigKnown.games()
|
|
65
|
-
ZRomulatorConfigKnown.media()
|
|
65
|
+
ZRomulatorConfigKnown.games()
|
|
66
66
|
];
|
|
67
67
|
}
|
|
68
68
|
static create(id) {
|
|
@@ -72,21 +72,18 @@ class ZRomulatorConfigKnown {
|
|
|
72
72
|
static games() {
|
|
73
73
|
return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Games).name("Game Settings").description("Modify where your games are stored and related settings").avatar("gamepad").metadata(romulatorClient.ZRomulatorConfigGamesMetadata.all()).build();
|
|
74
74
|
}
|
|
75
|
-
static media() {
|
|
76
|
-
return ZRomulatorConfigKnown.create(romulatorClient.ZRomulatorConfigId.Media).name("Media Settings").description("Modify where media is stored and what media to retrieve").avatar("image").metadata(romulatorClient.ZRomulatorConfigMediaMetadata.all()).build();
|
|
77
|
-
}
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
function _ts_decorate$
|
|
77
|
+
function _ts_decorate$f(decorators, target, key, desc) {
|
|
81
78
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
82
79
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
83
80
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
84
81
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
85
82
|
}
|
|
86
|
-
function _ts_metadata$
|
|
83
|
+
function _ts_metadata$9(k, v) {
|
|
87
84
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
88
85
|
}
|
|
89
|
-
function _ts_param$
|
|
86
|
+
function _ts_param$8(paramIndex, decorator) {
|
|
90
87
|
return function(target, key) {
|
|
91
88
|
decorator(target, key, paramIndex);
|
|
92
89
|
};
|
|
@@ -168,25 +165,25 @@ class ZRomulatorConfigsService {
|
|
|
168
165
|
return config;
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
|
-
ZRomulatorConfigsService = _ts_decorate$
|
|
168
|
+
ZRomulatorConfigsService = _ts_decorate$f([
|
|
172
169
|
common.Injectable(),
|
|
173
|
-
_ts_param$
|
|
174
|
-
_ts_metadata$
|
|
175
|
-
_ts_metadata$
|
|
170
|
+
_ts_param$8(0, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
171
|
+
_ts_metadata$9("design:type", Function),
|
|
172
|
+
_ts_metadata$9("design:paramtypes", [
|
|
176
173
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
177
174
|
])
|
|
178
175
|
], ZRomulatorConfigsService);
|
|
179
176
|
|
|
180
|
-
function _ts_decorate$
|
|
177
|
+
function _ts_decorate$e(decorators, target, key, desc) {
|
|
181
178
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
182
179
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
183
180
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
184
181
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
185
182
|
}
|
|
186
|
-
function _ts_metadata$
|
|
183
|
+
function _ts_metadata$8(k, v) {
|
|
187
184
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
188
185
|
}
|
|
189
|
-
function _ts_param$
|
|
186
|
+
function _ts_param$7(paramIndex, decorator) {
|
|
190
187
|
return function(target, key) {
|
|
191
188
|
decorator(target, key, paramIndex);
|
|
192
189
|
};
|
|
@@ -207,16 +204,16 @@ class ZRomulatorConfigsController {
|
|
|
207
204
|
return await this._configs.get(identification);
|
|
208
205
|
}
|
|
209
206
|
}
|
|
210
|
-
_ts_decorate$
|
|
207
|
+
_ts_decorate$e([
|
|
211
208
|
common.Get(),
|
|
212
|
-
_ts_param$
|
|
213
|
-
_ts_metadata$
|
|
214
|
-
_ts_metadata$
|
|
209
|
+
_ts_param$7(0, common.Query()),
|
|
210
|
+
_ts_metadata$8("design:type", Function),
|
|
211
|
+
_ts_metadata$8("design:paramtypes", [
|
|
215
212
|
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
216
213
|
]),
|
|
217
|
-
_ts_metadata$
|
|
214
|
+
_ts_metadata$8("design:returntype", Promise)
|
|
218
215
|
], ZRomulatorConfigsController.prototype, "list", null);
|
|
219
|
-
_ts_decorate$
|
|
216
|
+
_ts_decorate$e([
|
|
220
217
|
swagger.ApiParam({
|
|
221
218
|
type: "string",
|
|
222
219
|
name: "identification",
|
|
@@ -233,39 +230,39 @@ _ts_decorate$c([
|
|
|
233
230
|
skipNullProperties: false,
|
|
234
231
|
skipUndefinedProperties: false
|
|
235
232
|
})),
|
|
236
|
-
_ts_param$
|
|
237
|
-
_ts_param$
|
|
238
|
-
_ts_metadata$
|
|
239
|
-
_ts_metadata$
|
|
233
|
+
_ts_param$7(0, common.Param("identification")),
|
|
234
|
+
_ts_param$7(1, common.Body()),
|
|
235
|
+
_ts_metadata$8("design:type", Function),
|
|
236
|
+
_ts_metadata$8("design:paramtypes", [
|
|
240
237
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId,
|
|
241
238
|
typeof ZRomulatorConfigUpdateDto === "undefined" ? Object : ZRomulatorConfigUpdateDto
|
|
242
239
|
]),
|
|
243
|
-
_ts_metadata$
|
|
240
|
+
_ts_metadata$8("design:returntype", Promise)
|
|
244
241
|
], ZRomulatorConfigsController.prototype, "update", null);
|
|
245
|
-
_ts_decorate$
|
|
242
|
+
_ts_decorate$e([
|
|
246
243
|
swagger.ApiParam({
|
|
247
244
|
type: "string",
|
|
248
245
|
name: "identification",
|
|
249
246
|
description: "The id of the config"
|
|
250
247
|
}),
|
|
251
248
|
common.Get(":identification"),
|
|
252
|
-
_ts_param$
|
|
253
|
-
_ts_metadata$
|
|
254
|
-
_ts_metadata$
|
|
249
|
+
_ts_param$7(0, common.Param("identification")),
|
|
250
|
+
_ts_metadata$8("design:type", Function),
|
|
251
|
+
_ts_metadata$8("design:paramtypes", [
|
|
255
252
|
typeof ZRomulatorConfigId === "undefined" ? Object : ZRomulatorConfigId
|
|
256
253
|
]),
|
|
257
|
-
_ts_metadata$
|
|
254
|
+
_ts_metadata$8("design:returntype", Promise)
|
|
258
255
|
], ZRomulatorConfigsController.prototype, "get", null);
|
|
259
|
-
ZRomulatorConfigsController = _ts_decorate$
|
|
256
|
+
ZRomulatorConfigsController = _ts_decorate$e([
|
|
260
257
|
common.Controller("configs"),
|
|
261
|
-
_ts_param$
|
|
262
|
-
_ts_metadata$
|
|
263
|
-
_ts_metadata$
|
|
258
|
+
_ts_param$7(0, common.Inject(ZRomulatorConfigsToken)),
|
|
259
|
+
_ts_metadata$8("design:type", Function),
|
|
260
|
+
_ts_metadata$8("design:paramtypes", [
|
|
264
261
|
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService
|
|
265
262
|
])
|
|
266
263
|
], ZRomulatorConfigsController);
|
|
267
264
|
|
|
268
|
-
function _ts_decorate$
|
|
265
|
+
function _ts_decorate$d(decorators, target, key, desc) {
|
|
269
266
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
270
267
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
271
268
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -273,7 +270,7 @@ function _ts_decorate$b(decorators, target, key, desc) {
|
|
|
273
270
|
}
|
|
274
271
|
class ZRomulatorConfigsModule {
|
|
275
272
|
}
|
|
276
|
-
ZRomulatorConfigsModule = _ts_decorate$
|
|
273
|
+
ZRomulatorConfigsModule = _ts_decorate$d([
|
|
277
274
|
common.Module({
|
|
278
275
|
imports: [
|
|
279
276
|
crumbtrailNest.ZFileSystemModule,
|
|
@@ -294,13 +291,13 @@ ZRomulatorConfigsModule = _ts_decorate$b([
|
|
|
294
291
|
})
|
|
295
292
|
], ZRomulatorConfigsModule);
|
|
296
293
|
|
|
297
|
-
function _ts_decorate$
|
|
294
|
+
function _ts_decorate$c(decorators, target, key, desc) {
|
|
298
295
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
299
296
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
300
297
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
301
298
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
302
299
|
}
|
|
303
|
-
function _ts_metadata$
|
|
300
|
+
function _ts_metadata$7(k, v) {
|
|
304
301
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
305
302
|
}
|
|
306
303
|
const KnownSystem = "@zthunworks/romulator/known-system";
|
|
@@ -325,7 +322,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
325
322
|
* A {@link ZRomulatorSystemBuilder} instance that has
|
|
326
323
|
* built the nes.
|
|
327
324
|
*/ static nes() {
|
|
328
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).console().name("Nintendo Entertainment System").
|
|
325
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo).console().name("Nintendo Entertainment System").generation(3).build();
|
|
329
326
|
}
|
|
330
327
|
/**
|
|
331
328
|
* Creates a system that represents the Super
|
|
@@ -334,7 +331,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
334
331
|
* @returns
|
|
335
332
|
* This instance.
|
|
336
333
|
*/ static snes() {
|
|
337
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).console().name("Super Nintendo Entertainment System").
|
|
334
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.SuperNintendo).console().name("Super Nintendo Entertainment System").generation(4).build();
|
|
338
335
|
}
|
|
339
336
|
/**
|
|
340
337
|
* Creates a system that represents the Nintendo
|
|
@@ -343,7 +340,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
343
340
|
* @returns
|
|
344
341
|
* This instance.
|
|
345
342
|
*/ static n64() {
|
|
346
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).console().name("Nintendo 64").
|
|
343
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Nintendo64).console().name("Nintendo 64").generation(5).build();
|
|
347
344
|
}
|
|
348
345
|
/**
|
|
349
346
|
* Creates a system that represents the Nintendo
|
|
@@ -352,7 +349,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
352
349
|
* @returns
|
|
353
350
|
* This instance.
|
|
354
351
|
*/ static gc() {
|
|
355
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).console().name("Nintendo GameCube").
|
|
352
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.GameCube).console().name("Nintendo GameCube").generation(6).build();
|
|
356
353
|
}
|
|
357
354
|
/**
|
|
358
355
|
* Creates a system that represents the Nintendo
|
|
@@ -361,7 +358,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
361
358
|
* @returns
|
|
362
359
|
* This instance.
|
|
363
360
|
*/ static wii() {
|
|
364
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).console().name("Nintendo Wii").
|
|
361
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Wii).console().name("Nintendo Wii").generation(7).build();
|
|
365
362
|
}
|
|
366
363
|
/**
|
|
367
364
|
* Creates a system that represents the Nintendo
|
|
@@ -370,7 +367,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
370
367
|
* @returns
|
|
371
368
|
* This instance.
|
|
372
369
|
*/ static wiiu() {
|
|
373
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).console().name("Nintendo Wii U").
|
|
370
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.WiiU).console().name("Nintendo Wii U").generation(8).build();
|
|
374
371
|
}
|
|
375
372
|
/**
|
|
376
373
|
* Creates a system that represents the Nintendo
|
|
@@ -379,7 +376,7 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
379
376
|
* @returns
|
|
380
377
|
* This instance.
|
|
381
378
|
*/ static switch() {
|
|
382
|
-
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).console().name("Nintendo Switch").
|
|
379
|
+
return new romulatorClient.ZRomulatorSystemBuilder().id(romulatorClient.ZRomulatorSystemId.Switch).console().name("Nintendo Switch").generation(9).build();
|
|
383
380
|
}
|
|
384
381
|
/**
|
|
385
382
|
* Creates a system from an id slug.
|
|
@@ -396,47 +393,47 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
396
393
|
return null;
|
|
397
394
|
}
|
|
398
395
|
}
|
|
399
|
-
_ts_decorate$
|
|
396
|
+
_ts_decorate$c([
|
|
400
397
|
helpfulReflection.ZTag(KnownSystem),
|
|
401
|
-
_ts_metadata$
|
|
402
|
-
_ts_metadata$
|
|
403
|
-
_ts_metadata$
|
|
398
|
+
_ts_metadata$7("design:type", Function),
|
|
399
|
+
_ts_metadata$7("design:paramtypes", []),
|
|
400
|
+
_ts_metadata$7("design:returntype", void 0)
|
|
404
401
|
], ZRomulatorSystemKnown, "nes", null);
|
|
405
|
-
_ts_decorate$
|
|
402
|
+
_ts_decorate$c([
|
|
406
403
|
helpfulReflection.ZTag(KnownSystem),
|
|
407
|
-
_ts_metadata$
|
|
408
|
-
_ts_metadata$
|
|
409
|
-
_ts_metadata$
|
|
404
|
+
_ts_metadata$7("design:type", Function),
|
|
405
|
+
_ts_metadata$7("design:paramtypes", []),
|
|
406
|
+
_ts_metadata$7("design:returntype", void 0)
|
|
410
407
|
], ZRomulatorSystemKnown, "snes", null);
|
|
411
|
-
_ts_decorate$
|
|
408
|
+
_ts_decorate$c([
|
|
412
409
|
helpfulReflection.ZTag(KnownSystem),
|
|
413
|
-
_ts_metadata$
|
|
414
|
-
_ts_metadata$
|
|
415
|
-
_ts_metadata$
|
|
410
|
+
_ts_metadata$7("design:type", Function),
|
|
411
|
+
_ts_metadata$7("design:paramtypes", []),
|
|
412
|
+
_ts_metadata$7("design:returntype", void 0)
|
|
416
413
|
], ZRomulatorSystemKnown, "n64", null);
|
|
417
|
-
_ts_decorate$
|
|
414
|
+
_ts_decorate$c([
|
|
418
415
|
helpfulReflection.ZTag(KnownSystem),
|
|
419
|
-
_ts_metadata$
|
|
420
|
-
_ts_metadata$
|
|
421
|
-
_ts_metadata$
|
|
416
|
+
_ts_metadata$7("design:type", Function),
|
|
417
|
+
_ts_metadata$7("design:paramtypes", []),
|
|
418
|
+
_ts_metadata$7("design:returntype", void 0)
|
|
422
419
|
], ZRomulatorSystemKnown, "gc", null);
|
|
423
|
-
_ts_decorate$
|
|
420
|
+
_ts_decorate$c([
|
|
424
421
|
helpfulReflection.ZTag(KnownSystem),
|
|
425
|
-
_ts_metadata$
|
|
426
|
-
_ts_metadata$
|
|
427
|
-
_ts_metadata$
|
|
422
|
+
_ts_metadata$7("design:type", Function),
|
|
423
|
+
_ts_metadata$7("design:paramtypes", []),
|
|
424
|
+
_ts_metadata$7("design:returntype", void 0)
|
|
428
425
|
], ZRomulatorSystemKnown, "wii", null);
|
|
429
|
-
_ts_decorate$
|
|
426
|
+
_ts_decorate$c([
|
|
430
427
|
helpfulReflection.ZTag(KnownSystem),
|
|
431
|
-
_ts_metadata$
|
|
432
|
-
_ts_metadata$
|
|
433
|
-
_ts_metadata$
|
|
428
|
+
_ts_metadata$7("design:type", Function),
|
|
429
|
+
_ts_metadata$7("design:paramtypes", []),
|
|
430
|
+
_ts_metadata$7("design:returntype", void 0)
|
|
434
431
|
], ZRomulatorSystemKnown, "wiiu", null);
|
|
435
|
-
_ts_decorate$
|
|
432
|
+
_ts_decorate$c([
|
|
436
433
|
helpfulReflection.ZTag(KnownSystem),
|
|
437
|
-
_ts_metadata$
|
|
438
|
-
_ts_metadata$
|
|
439
|
-
_ts_metadata$
|
|
434
|
+
_ts_metadata$7("design:type", Function),
|
|
435
|
+
_ts_metadata$7("design:paramtypes", []),
|
|
436
|
+
_ts_metadata$7("design:returntype", void 0)
|
|
440
437
|
], ZRomulatorSystemKnown, "switch", null);
|
|
441
438
|
|
|
442
439
|
/**
|
|
@@ -459,16 +456,16 @@ _ts_decorate$a([
|
|
|
459
456
|
}
|
|
460
457
|
}
|
|
461
458
|
|
|
462
|
-
function _ts_decorate$
|
|
459
|
+
function _ts_decorate$b(decorators, target, key, desc) {
|
|
463
460
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
464
461
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
465
462
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
466
463
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
467
464
|
}
|
|
468
|
-
function _ts_metadata$
|
|
465
|
+
function _ts_metadata$6(k, v) {
|
|
469
466
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
470
467
|
}
|
|
471
|
-
function _ts_param$
|
|
468
|
+
function _ts_param$6(paramIndex, decorator) {
|
|
472
469
|
return function(target, key) {
|
|
473
470
|
decorator(target, key, paramIndex);
|
|
474
471
|
};
|
|
@@ -524,29 +521,29 @@ class ZRomulatorGamesService {
|
|
|
524
521
|
return match;
|
|
525
522
|
}
|
|
526
523
|
}
|
|
527
|
-
ZRomulatorGamesService = _ts_decorate$
|
|
524
|
+
ZRomulatorGamesService = _ts_decorate$b([
|
|
528
525
|
common.Injectable(),
|
|
529
|
-
_ts_param$
|
|
530
|
-
_ts_param$
|
|
531
|
-
_ts_param$
|
|
532
|
-
_ts_metadata$
|
|
533
|
-
_ts_metadata$
|
|
526
|
+
_ts_param$6(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
|
|
527
|
+
_ts_param$6(1, common.Inject(ZRomulatorConfigsToken)),
|
|
528
|
+
_ts_param$6(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
529
|
+
_ts_metadata$6("design:type", Function),
|
|
530
|
+
_ts_metadata$6("design:paramtypes", [
|
|
534
531
|
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService,
|
|
535
532
|
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
536
533
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
537
534
|
])
|
|
538
535
|
], ZRomulatorGamesService);
|
|
539
536
|
|
|
540
|
-
function _ts_decorate$
|
|
537
|
+
function _ts_decorate$a(decorators, target, key, desc) {
|
|
541
538
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
542
539
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
543
540
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
544
541
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
545
542
|
}
|
|
546
|
-
function _ts_metadata$
|
|
543
|
+
function _ts_metadata$5(k, v) {
|
|
547
544
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
548
545
|
}
|
|
549
|
-
function _ts_param$
|
|
546
|
+
function _ts_param$5(paramIndex, decorator) {
|
|
550
547
|
return function(target, key) {
|
|
551
548
|
decorator(target, key, paramIndex);
|
|
552
549
|
};
|
|
@@ -563,34 +560,34 @@ class ZRomulatorGamesController {
|
|
|
563
560
|
return this._games.get(identification);
|
|
564
561
|
}
|
|
565
562
|
}
|
|
566
|
-
_ts_decorate$
|
|
563
|
+
_ts_decorate$a([
|
|
567
564
|
common.Get(),
|
|
568
|
-
_ts_param$
|
|
569
|
-
_ts_metadata$
|
|
570
|
-
_ts_metadata$
|
|
565
|
+
_ts_param$5(0, common.Query()),
|
|
566
|
+
_ts_metadata$5("design:type", Function),
|
|
567
|
+
_ts_metadata$5("design:paramtypes", [
|
|
571
568
|
typeof IZDataRequestQuery === "undefined" ? Object : IZDataRequestQuery
|
|
572
569
|
]),
|
|
573
|
-
_ts_metadata$
|
|
570
|
+
_ts_metadata$5("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
574
571
|
], ZRomulatorGamesController.prototype, "list", null);
|
|
575
|
-
_ts_decorate$
|
|
572
|
+
_ts_decorate$a([
|
|
576
573
|
common.Get(":identification"),
|
|
577
|
-
_ts_param$
|
|
578
|
-
_ts_metadata$
|
|
579
|
-
_ts_metadata$
|
|
574
|
+
_ts_param$5(0, common.Param("identification")),
|
|
575
|
+
_ts_metadata$5("design:type", Function),
|
|
576
|
+
_ts_metadata$5("design:paramtypes", [
|
|
580
577
|
String
|
|
581
578
|
]),
|
|
582
|
-
_ts_metadata$
|
|
579
|
+
_ts_metadata$5("design:returntype", void 0)
|
|
583
580
|
], ZRomulatorGamesController.prototype, "get", null);
|
|
584
|
-
ZRomulatorGamesController = _ts_decorate$
|
|
581
|
+
ZRomulatorGamesController = _ts_decorate$a([
|
|
585
582
|
common.Controller("games"),
|
|
586
|
-
_ts_param$
|
|
587
|
-
_ts_metadata$
|
|
588
|
-
_ts_metadata$
|
|
583
|
+
_ts_param$5(0, common.Inject(ZRomulatorGamesToken)),
|
|
584
|
+
_ts_metadata$5("design:type", Function),
|
|
585
|
+
_ts_metadata$5("design:paramtypes", [
|
|
589
586
|
typeof IZRomulatorGamesService === "undefined" ? Object : IZRomulatorGamesService
|
|
590
587
|
])
|
|
591
588
|
], ZRomulatorGamesController);
|
|
592
589
|
|
|
593
|
-
function _ts_decorate$
|
|
590
|
+
function _ts_decorate$9(decorators, target, key, desc) {
|
|
594
591
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
595
592
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
596
593
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -598,7 +595,7 @@ function _ts_decorate$7(decorators, target, key, desc) {
|
|
|
598
595
|
}
|
|
599
596
|
class ZRomulatorGamesModule {
|
|
600
597
|
}
|
|
601
|
-
ZRomulatorGamesModule = _ts_decorate$
|
|
598
|
+
ZRomulatorGamesModule = _ts_decorate$9([
|
|
602
599
|
common.Module({
|
|
603
600
|
imports: [
|
|
604
601
|
ZRomulatorConfigsModule,
|
|
@@ -617,6 +614,135 @@ ZRomulatorGamesModule = _ts_decorate$7([
|
|
|
617
614
|
})
|
|
618
615
|
], ZRomulatorGamesModule);
|
|
619
616
|
|
|
617
|
+
function _ts_decorate$8(decorators, target, key, desc) {
|
|
618
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
619
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
620
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
621
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
622
|
+
}
|
|
623
|
+
function _ts_metadata$4(k, v) {
|
|
624
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
625
|
+
}
|
|
626
|
+
function _ts_param$4(paramIndex, decorator) {
|
|
627
|
+
return function(target, key) {
|
|
628
|
+
decorator(target, key, paramIndex);
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
const ZRomulatorFilesToken = Symbol("files");
|
|
632
|
+
class ZRomulatorFilesService {
|
|
633
|
+
_configs;
|
|
634
|
+
_fileSystem;
|
|
635
|
+
static MediaFolderName = ".media";
|
|
636
|
+
static InfoFolderName = ".info";
|
|
637
|
+
_repository = new crumbtrailFs.ZFileRepository();
|
|
638
|
+
_folderStream = new crumbtrailFs.ZStreamFolder();
|
|
639
|
+
_globs;
|
|
640
|
+
_systems;
|
|
641
|
+
constructor(_configs, _fileSystem){
|
|
642
|
+
this._configs = _configs;
|
|
643
|
+
this._fileSystem = _fileSystem;
|
|
644
|
+
const slugs = Object.values(romulatorClient.ZRomulatorSystemId);
|
|
645
|
+
this._globs = [
|
|
646
|
+
".media/**",
|
|
647
|
+
".info/**",
|
|
648
|
+
...slugs.map((s)=>`${s}/*.*`)
|
|
649
|
+
];
|
|
650
|
+
this._systems = Object.values(romulatorClient.ZRomulatorSystemId);
|
|
651
|
+
this.seed();
|
|
652
|
+
}
|
|
653
|
+
async gamesFolder() {
|
|
654
|
+
const config = await this._configs.get(romulatorClient.ZRomulatorConfigId.Games);
|
|
655
|
+
const { gamesFolder } = new romulatorClient.ZRomulatorConfigGamesBuilder().copy(config.contents).build();
|
|
656
|
+
const { fallback } = romulatorClient.ZRomulatorConfigGamesMetadata.gamesFolder();
|
|
657
|
+
const _gamesFolder = helpfulFn.firstDefined(fallback.gamesFolder, gamesFolder);
|
|
658
|
+
return helpfulFn.detokenize(_gamesFolder, node_process.env);
|
|
659
|
+
}
|
|
660
|
+
async mediaFolder() {
|
|
661
|
+
const gamesFolder = await this.gamesFolder();
|
|
662
|
+
return node_path.resolve(gamesFolder, ZRomulatorFilesService.MediaFolderName);
|
|
663
|
+
}
|
|
664
|
+
async infoFolder() {
|
|
665
|
+
const gamesFolder = await this.gamesFolder();
|
|
666
|
+
return node_path.resolve(gamesFolder, ZRomulatorFilesService.InfoFolderName);
|
|
667
|
+
}
|
|
668
|
+
async contents(root, path) {
|
|
669
|
+
const repository = await this.seed();
|
|
670
|
+
const prefix = lodashEs.trimEnd(root, "/");
|
|
671
|
+
const folder = `${prefix}${node_path.sep}`;
|
|
672
|
+
let filter = new helpfulQuery.ZFilterBinaryBuilder().subject("path");
|
|
673
|
+
filter = path == null ? filter.startsWith().value(folder) : filter.equal().value(node_path.resolve(folder, path));
|
|
674
|
+
const sort = new helpfulQuery.ZSortBuilder().ascending("path").build();
|
|
675
|
+
const request = new helpfulQuery.ZDataRequestBuilder().filter(filter.build()).sort(sort).build();
|
|
676
|
+
const nodes = await repository.retrieve(request);
|
|
677
|
+
return path == null ? nodes : helpfulFn.firstDefined(null, lodashEs.first(nodes));
|
|
678
|
+
}
|
|
679
|
+
async seed() {
|
|
680
|
+
const path = await this.gamesFolder();
|
|
681
|
+
if (this._repository.path !== path) {
|
|
682
|
+
await this._folderStream.write(await this.mediaFolder());
|
|
683
|
+
await this._folderStream.write(await this.infoFolder());
|
|
684
|
+
await this._repository.initialize(path, this._globs);
|
|
685
|
+
}
|
|
686
|
+
return this._repository;
|
|
687
|
+
}
|
|
688
|
+
async media(path) {
|
|
689
|
+
return this.contents(await this.mediaFolder(), path);
|
|
690
|
+
}
|
|
691
|
+
async systems(path) {
|
|
692
|
+
// Systems use directories. There's a maximum limit of about 200 systems.
|
|
693
|
+
// Since we don't actually need to read any metadata or scan through thousands
|
|
694
|
+
// of unknown folders, we can use the supported system ids to just grab the
|
|
695
|
+
// systems that we need. Since the file repository does a stat anyway, we can just
|
|
696
|
+
// grab the systems from the file system and it should be fast enough. These are all
|
|
697
|
+
// folders, so we don't even need the stats for them and we can assume folders.
|
|
698
|
+
const games = await this.gamesFolder();
|
|
699
|
+
const folders = path == null ? this._systems.map((s)=>`${s}/`) : node_path.resolve(games, path);
|
|
700
|
+
const items = await this._fileSystem.search(folders, {
|
|
701
|
+
cwd: games
|
|
702
|
+
});
|
|
703
|
+
return path == null ? items : helpfulFn.firstDefined(null, lodashEs.first(items));
|
|
704
|
+
}
|
|
705
|
+
async info(path) {
|
|
706
|
+
return this.contents(await this.infoFolder(), path);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
ZRomulatorFilesService = _ts_decorate$8([
|
|
710
|
+
common.Injectable(),
|
|
711
|
+
_ts_param$4(0, common.Inject(ZRomulatorConfigsToken)),
|
|
712
|
+
_ts_param$4(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
|
|
713
|
+
_ts_metadata$4("design:type", Function),
|
|
714
|
+
_ts_metadata$4("design:paramtypes", [
|
|
715
|
+
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
716
|
+
typeof IZFileSystemService === "undefined" ? Object : IZFileSystemService
|
|
717
|
+
])
|
|
718
|
+
], ZRomulatorFilesService);
|
|
719
|
+
|
|
720
|
+
function _ts_decorate$7(decorators, target, key, desc) {
|
|
721
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
722
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
723
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
724
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
725
|
+
}
|
|
726
|
+
class ZRomulatorFilesModule {
|
|
727
|
+
}
|
|
728
|
+
ZRomulatorFilesModule = _ts_decorate$7([
|
|
729
|
+
common.Module({
|
|
730
|
+
imports: [
|
|
731
|
+
crumbtrailNest.ZFileSystemModule,
|
|
732
|
+
ZRomulatorConfigsModule
|
|
733
|
+
],
|
|
734
|
+
providers: [
|
|
735
|
+
{
|
|
736
|
+
provide: ZRomulatorFilesToken,
|
|
737
|
+
useClass: ZRomulatorFilesService
|
|
738
|
+
}
|
|
739
|
+
],
|
|
740
|
+
exports: [
|
|
741
|
+
ZRomulatorFilesToken
|
|
742
|
+
]
|
|
743
|
+
})
|
|
744
|
+
], ZRomulatorFilesModule);
|
|
745
|
+
|
|
620
746
|
function _ts_decorate$6(decorators, target, key, desc) {
|
|
621
747
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
622
748
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -633,37 +759,24 @@ function _ts_param$3(paramIndex, decorator) {
|
|
|
633
759
|
}
|
|
634
760
|
const ZRomulatorMediaToken = Symbol("romulator-media-service");
|
|
635
761
|
class ZRomulatorMediaService {
|
|
636
|
-
|
|
637
|
-
_config;
|
|
762
|
+
_files;
|
|
638
763
|
_logger;
|
|
639
|
-
constructor(
|
|
640
|
-
this.
|
|
641
|
-
this._config = _config;
|
|
764
|
+
constructor(_files, logger){
|
|
765
|
+
this._files = _files;
|
|
642
766
|
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorMediaService", logger);
|
|
643
767
|
}
|
|
644
|
-
async
|
|
645
|
-
const
|
|
646
|
-
const { contents } = await this._config.get(mediaConfig.id);
|
|
647
|
-
const { mediaFolder } = new romulatorClient.ZRomulatorConfigMediaBuilder().copy(contents).build();
|
|
648
|
-
return helpfulFn.detokenize(mediaFolder, node_process.env);
|
|
649
|
-
}
|
|
650
|
-
async findAllMedia(cwd) {
|
|
651
|
-
const systems = ZRomulatorSystemKnown.all().map((s)=>s.id).join(",");
|
|
652
|
-
const glob = `{${systems}}/**`;
|
|
653
|
-
const files = await this._file.search(glob, {
|
|
654
|
-
cwd,
|
|
655
|
-
stat: false
|
|
656
|
-
});
|
|
768
|
+
async findAllMedia() {
|
|
769
|
+
const files = await this._files.media();
|
|
657
770
|
return files.map((f)=>new romulatorClient.ZRomulatorMediaBuilder().from(f.path).build()).filter((media)=>!!media.id);
|
|
658
771
|
}
|
|
659
772
|
async list(req) {
|
|
660
|
-
|
|
661
|
-
let msg = `Reading all media from ${cwd}`;
|
|
773
|
+
let msg = `Querying media`;
|
|
662
774
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
663
775
|
const time = new Date();
|
|
664
|
-
const mediaList = await this.findAllMedia(
|
|
776
|
+
const mediaList = await this.findAllMedia();
|
|
665
777
|
const span = new Date().getTime() - time.getTime();
|
|
666
778
|
msg = `Found ${mediaList.length} media files. Search took ${span} milliseconds`;
|
|
779
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
667
780
|
const options = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields()).build();
|
|
668
781
|
const source = new helpfulQuery.ZDataSourceStatic(mediaList, options);
|
|
669
782
|
const page = await source.retrieve(req);
|
|
@@ -671,11 +784,10 @@ class ZRomulatorMediaService {
|
|
|
671
784
|
return new helpfulQuery.ZPageBuilder().data(page).count(count).build();
|
|
672
785
|
}
|
|
673
786
|
async get(id) {
|
|
674
|
-
const cwd = await this.getMediaFolder();
|
|
675
787
|
const time = new Date();
|
|
676
788
|
let log = `Searching for media with id ${id}.`;
|
|
677
789
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
678
|
-
const mediaList = await this.findAllMedia(
|
|
790
|
+
const mediaList = await this.findAllMedia();
|
|
679
791
|
const index = lodashEs.findIndex(mediaList, (m)=>m.id === id);
|
|
680
792
|
const span = new Date().getTime() - time.getTime();
|
|
681
793
|
if (index < 0) {
|
|
@@ -736,13 +848,11 @@ class ZRomulatorMediaService {
|
|
|
736
848
|
}
|
|
737
849
|
ZRomulatorMediaService = _ts_decorate$6([
|
|
738
850
|
common.Injectable(),
|
|
739
|
-
_ts_param$3(0, common.Inject(
|
|
740
|
-
_ts_param$3(1, common.Inject(
|
|
741
|
-
_ts_param$3(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
851
|
+
_ts_param$3(0, common.Inject(ZRomulatorFilesToken)),
|
|
852
|
+
_ts_param$3(1, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
742
853
|
_ts_metadata$3("design:type", Function),
|
|
743
854
|
_ts_metadata$3("design:paramtypes", [
|
|
744
|
-
typeof
|
|
745
|
-
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
855
|
+
typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService,
|
|
746
856
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
747
857
|
])
|
|
748
858
|
], ZRomulatorMediaService);
|
|
@@ -779,6 +889,42 @@ class ZRomulatorMediaController {
|
|
|
779
889
|
}
|
|
780
890
|
}
|
|
781
891
|
_ts_decorate$5([
|
|
892
|
+
swagger.ApiQuery({
|
|
893
|
+
name: "page",
|
|
894
|
+
required: false,
|
|
895
|
+
type: Number,
|
|
896
|
+
example: 1,
|
|
897
|
+
description: "Page number (1-based)"
|
|
898
|
+
}),
|
|
899
|
+
swagger.ApiQuery({
|
|
900
|
+
name: "size",
|
|
901
|
+
required: false,
|
|
902
|
+
type: Number,
|
|
903
|
+
example: 20,
|
|
904
|
+
description: "Items per page. Defaults to Infinity"
|
|
905
|
+
}),
|
|
906
|
+
swagger.ApiQuery({
|
|
907
|
+
name: "search",
|
|
908
|
+
required: false,
|
|
909
|
+
type: String,
|
|
910
|
+
description: "Search query"
|
|
911
|
+
}),
|
|
912
|
+
swagger.ApiQuery({
|
|
913
|
+
name: "sort",
|
|
914
|
+
required: false,
|
|
915
|
+
type: String,
|
|
916
|
+
description: "Sort criterion"
|
|
917
|
+
}),
|
|
918
|
+
swagger.ApiQuery({
|
|
919
|
+
name: "filter",
|
|
920
|
+
required: false,
|
|
921
|
+
type: String,
|
|
922
|
+
description: "Filter criterion"
|
|
923
|
+
}),
|
|
924
|
+
swagger.ApiResponse({
|
|
925
|
+
status: webigailHttp.ZHttpCodeSuccess.OK,
|
|
926
|
+
description: "Returns the requested page of media and the total count"
|
|
927
|
+
}),
|
|
782
928
|
common.Get(),
|
|
783
929
|
_ts_param$2(0, common.Query()),
|
|
784
930
|
_ts_metadata$2("design:type", Function),
|
|
@@ -838,6 +984,7 @@ _ts_decorate$5([
|
|
|
838
984
|
_ts_metadata$2("design:returntype", Promise)
|
|
839
985
|
], ZRomulatorMediaController.prototype, "delete", null);
|
|
840
986
|
ZRomulatorMediaController = _ts_decorate$5([
|
|
987
|
+
swagger.ApiTags("Media"),
|
|
841
988
|
common.Controller("media"),
|
|
842
989
|
_ts_param$2(0, common.Inject(ZRomulatorMediaToken)),
|
|
843
990
|
_ts_metadata$2("design:type", Function),
|
|
@@ -857,9 +1004,8 @@ class ZRomulatorMediaModule {
|
|
|
857
1004
|
ZRomulatorMediaModule = _ts_decorate$4([
|
|
858
1005
|
common.Module({
|
|
859
1006
|
imports: [
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
lumberjackyNest.ZLoggerModule
|
|
1007
|
+
lumberjackyNest.ZLoggerModule,
|
|
1008
|
+
ZRomulatorFilesModule
|
|
863
1009
|
],
|
|
864
1010
|
controllers: [
|
|
865
1011
|
ZRomulatorMediaController
|
|
@@ -889,13 +1035,16 @@ function _ts_param$1(paramIndex, decorator) {
|
|
|
889
1035
|
}
|
|
890
1036
|
const ZRomulatorSystemsToken = Symbol("romulator-systems-service");
|
|
891
1037
|
class ZRomulatorSystemsService {
|
|
892
|
-
|
|
893
|
-
_configs;
|
|
1038
|
+
_files;
|
|
894
1039
|
logger;
|
|
895
1040
|
_logger;
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1041
|
+
_fileStream = new crumbtrailFs.ZStreamFile({
|
|
1042
|
+
cache: {
|
|
1043
|
+
maxFiles: Object.keys(romulatorClient.ZRomulatorSystemId).length + 1
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
constructor(_files, logger){
|
|
1047
|
+
this._files = _files;
|
|
899
1048
|
this.logger = logger;
|
|
900
1049
|
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorSystemsService", logger);
|
|
901
1050
|
}
|
|
@@ -904,18 +1053,8 @@ class ZRomulatorSystemsService {
|
|
|
904
1053
|
const size = helpfulFn.firstDefined(Infinity, req.size);
|
|
905
1054
|
let msg = `Retrieving systems page, ${page}, with size, ${size}.`;
|
|
906
1055
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
907
|
-
const
|
|
908
|
-
const
|
|
909
|
-
const { fallback } = romulatorClient.ZRomulatorConfigGamesMetadata.gamesFolder();
|
|
910
|
-
const _folder = helpfulFn.firstDefined(fallback, gamesFolder);
|
|
911
|
-
const cwd = helpfulFn.detokenize(_folder, process.env);
|
|
912
|
-
msg = `Looking for systems in ${cwd}`;
|
|
913
|
-
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
914
|
-
const searchOptions = {
|
|
915
|
-
cwd
|
|
916
|
-
};
|
|
917
|
-
const folders = await this._file.search("*/", searchOptions);
|
|
918
|
-
const systems = folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).map((slug)=>ZRomulatorSystemKnown.from(slug)).filter((system)=>system != null);
|
|
1056
|
+
const folders = await this._files.systems();
|
|
1057
|
+
const systems = await Promise.all(folders.map((folder)=>folder.path).map((path)=>node_path.basename(path)).filter((slug)=>romulatorClient.isSystemId(slug)).map((slug)=>this._createSystemFromSlug(slug)));
|
|
919
1058
|
msg = `Found ${systems.length} systems`;
|
|
920
1059
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build());
|
|
921
1060
|
const sourceOptions = new helpfulQuery.ZDataSourceStaticOptionsBuilder().search(new helpfulQuery.ZDataSearchFields([
|
|
@@ -929,23 +1068,46 @@ class ZRomulatorSystemsService {
|
|
|
929
1068
|
return new helpfulQuery.ZPageBuilder().data(data).count(count).build();
|
|
930
1069
|
}
|
|
931
1070
|
async get(id) {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
throw new common.NotFoundException(
|
|
1071
|
+
// The system path should be the slug itself.
|
|
1072
|
+
if (!romulatorClient.isSystemId(id)) {
|
|
1073
|
+
const message = `The specified system slug, ${id}, is not supported.`;
|
|
1074
|
+
throw new common.NotFoundException(message);
|
|
1075
|
+
}
|
|
1076
|
+
const node = await this._files.systems(id);
|
|
1077
|
+
if (node == null) {
|
|
1078
|
+
const message = `System with slug, ${id}, was not found.`;
|
|
1079
|
+
throw new common.NotFoundException(message);
|
|
1080
|
+
}
|
|
1081
|
+
return this._createSystemFromSlug(id);
|
|
1082
|
+
}
|
|
1083
|
+
async _createSystemFromSlug(slug) {
|
|
1084
|
+
const system = new romulatorClient.ZRomulatorSystemBuilder().id(slug);
|
|
1085
|
+
const path = `${slug}/info.json`;
|
|
1086
|
+
const info = await this._files.info(path);
|
|
1087
|
+
if (info == null) {
|
|
1088
|
+
// Best we can do right now.
|
|
1089
|
+
return system.build();
|
|
1090
|
+
}
|
|
1091
|
+
try {
|
|
1092
|
+
const contents = await this._fileStream.read(info.path);
|
|
1093
|
+
const json = JSON.parse(contents.toString());
|
|
1094
|
+
return system.assign(json).redact().build();
|
|
1095
|
+
} catch (e) {
|
|
1096
|
+
// Best we can do
|
|
1097
|
+
const err = helpfulFn.createError(e);
|
|
1098
|
+
const msg = `Cannot read system metadata, ${err.message}`;
|
|
1099
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
1100
|
+
return system.build();
|
|
936
1101
|
}
|
|
937
|
-
return system;
|
|
938
1102
|
}
|
|
939
1103
|
}
|
|
940
1104
|
ZRomulatorSystemsService = _ts_decorate$3([
|
|
941
1105
|
common.Injectable(),
|
|
942
|
-
_ts_param$1(0, common.Inject(
|
|
943
|
-
_ts_param$1(1, common.Inject(
|
|
944
|
-
_ts_param$1(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
1106
|
+
_ts_param$1(0, common.Inject(ZRomulatorFilesToken)),
|
|
1107
|
+
_ts_param$1(1, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
945
1108
|
_ts_metadata$1("design:type", Function),
|
|
946
1109
|
_ts_metadata$1("design:paramtypes", [
|
|
947
|
-
typeof
|
|
948
|
-
typeof IZRomulatorConfigsService === "undefined" ? Object : IZRomulatorConfigsService,
|
|
1110
|
+
typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService,
|
|
949
1111
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
950
1112
|
])
|
|
951
1113
|
], ZRomulatorSystemsService);
|
|
@@ -1019,8 +1181,7 @@ class ZRomulatorSystemsModule {
|
|
|
1019
1181
|
ZRomulatorSystemsModule = _ts_decorate$1([
|
|
1020
1182
|
common.Module({
|
|
1021
1183
|
imports: [
|
|
1022
|
-
|
|
1023
|
-
crumbtrailNest.ZFileSystemModule,
|
|
1184
|
+
ZRomulatorFilesModule,
|
|
1024
1185
|
lumberjackyNest.ZLoggerModule
|
|
1025
1186
|
],
|
|
1026
1187
|
controllers: [
|