@zthun/romulator-api 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.cjs +115 -46
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +117 -48
- package/dist/main.js.map +1 -1
- package/dist/media/media-generator.d.mts +32 -0
- package/dist/media/media-service.d.mts +4 -1
- package/package.json +6 -6
package/dist/main.cjs
CHANGED
|
@@ -22,8 +22,9 @@ const webigailHttp = require('@zthun/webigail-http');
|
|
|
22
22
|
const webigailUrl = require('@zthun/webigail-url');
|
|
23
23
|
const mimeTypes = require('mime-types');
|
|
24
24
|
const node_fs = require('node:fs');
|
|
25
|
+
const node_stream = require('node:stream');
|
|
25
26
|
|
|
26
|
-
function _ts_decorate$
|
|
27
|
+
function _ts_decorate$h(decorators, target, key, desc) {
|
|
27
28
|
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
28
29
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
30
|
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;
|
|
@@ -35,7 +36,7 @@ function _ts_metadata$b(k, v) {
|
|
|
35
36
|
class ZRomulatorConfigUpdateDto {
|
|
36
37
|
contents;
|
|
37
38
|
}
|
|
38
|
-
_ts_decorate$
|
|
39
|
+
_ts_decorate$h([
|
|
39
40
|
swagger.ApiProperty({
|
|
40
41
|
type: "object",
|
|
41
42
|
properties: {}
|
|
@@ -74,7 +75,7 @@ class ZRomulatorConfigKnown {
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
function _ts_decorate$
|
|
78
|
+
function _ts_decorate$g(decorators, target, key, desc) {
|
|
78
79
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
79
80
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
80
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;
|
|
@@ -165,7 +166,7 @@ class ZRomulatorConfigsService {
|
|
|
165
166
|
return config;
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
|
-
ZRomulatorConfigsService = _ts_decorate$
|
|
169
|
+
ZRomulatorConfigsService = _ts_decorate$g([
|
|
169
170
|
common.Injectable(),
|
|
170
171
|
_ts_param$9(0, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
171
172
|
_ts_metadata$a("design:type", Function),
|
|
@@ -174,7 +175,7 @@ ZRomulatorConfigsService = _ts_decorate$f([
|
|
|
174
175
|
])
|
|
175
176
|
], ZRomulatorConfigsService);
|
|
176
177
|
|
|
177
|
-
function _ts_decorate$
|
|
178
|
+
function _ts_decorate$f(decorators, target, key, desc) {
|
|
178
179
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
179
180
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
180
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;
|
|
@@ -204,7 +205,7 @@ class ZRomulatorConfigsController {
|
|
|
204
205
|
return await this._configs.get(identification);
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
|
-
_ts_decorate$
|
|
208
|
+
_ts_decorate$f([
|
|
208
209
|
common.Get(),
|
|
209
210
|
_ts_param$8(0, common.Query()),
|
|
210
211
|
_ts_metadata$9("design:type", Function),
|
|
@@ -213,7 +214,7 @@ _ts_decorate$e([
|
|
|
213
214
|
]),
|
|
214
215
|
_ts_metadata$9("design:returntype", Promise)
|
|
215
216
|
], ZRomulatorConfigsController.prototype, "list", null);
|
|
216
|
-
_ts_decorate$
|
|
217
|
+
_ts_decorate$f([
|
|
217
218
|
swagger.ApiParam({
|
|
218
219
|
type: "string",
|
|
219
220
|
name: "identification",
|
|
@@ -239,7 +240,7 @@ _ts_decorate$e([
|
|
|
239
240
|
]),
|
|
240
241
|
_ts_metadata$9("design:returntype", Promise)
|
|
241
242
|
], ZRomulatorConfigsController.prototype, "update", null);
|
|
242
|
-
_ts_decorate$
|
|
243
|
+
_ts_decorate$f([
|
|
243
244
|
swagger.ApiParam({
|
|
244
245
|
type: "string",
|
|
245
246
|
name: "identification",
|
|
@@ -253,7 +254,7 @@ _ts_decorate$e([
|
|
|
253
254
|
]),
|
|
254
255
|
_ts_metadata$9("design:returntype", Promise)
|
|
255
256
|
], ZRomulatorConfigsController.prototype, "get", null);
|
|
256
|
-
ZRomulatorConfigsController = _ts_decorate$
|
|
257
|
+
ZRomulatorConfigsController = _ts_decorate$f([
|
|
257
258
|
common.Controller("configs"),
|
|
258
259
|
_ts_param$8(0, common.Inject(ZRomulatorConfigsToken)),
|
|
259
260
|
_ts_metadata$9("design:type", Function),
|
|
@@ -262,7 +263,7 @@ ZRomulatorConfigsController = _ts_decorate$e([
|
|
|
262
263
|
])
|
|
263
264
|
], ZRomulatorConfigsController);
|
|
264
265
|
|
|
265
|
-
function _ts_decorate$
|
|
266
|
+
function _ts_decorate$e(decorators, target, key, desc) {
|
|
266
267
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
267
268
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
268
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;
|
|
@@ -270,7 +271,7 @@ function _ts_decorate$d(decorators, target, key, desc) {
|
|
|
270
271
|
}
|
|
271
272
|
class ZRomulatorConfigsModule {
|
|
272
273
|
}
|
|
273
|
-
ZRomulatorConfigsModule = _ts_decorate$
|
|
274
|
+
ZRomulatorConfigsModule = _ts_decorate$e([
|
|
274
275
|
common.Module({
|
|
275
276
|
imports: [
|
|
276
277
|
crumbtrailNest.ZFileSystemModule,
|
|
@@ -291,7 +292,7 @@ ZRomulatorConfigsModule = _ts_decorate$d([
|
|
|
291
292
|
})
|
|
292
293
|
], ZRomulatorConfigsModule);
|
|
293
294
|
|
|
294
|
-
function _ts_decorate$
|
|
295
|
+
function _ts_decorate$d(decorators, target, key, desc) {
|
|
295
296
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
296
297
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
297
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;
|
|
@@ -393,50 +394,50 @@ const KnownSystem = "@zthunworks/romulator/known-system";
|
|
|
393
394
|
return null;
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
|
-
_ts_decorate$
|
|
397
|
+
_ts_decorate$d([
|
|
397
398
|
helpfulReflection.ZTag(KnownSystem),
|
|
398
399
|
_ts_metadata$8("design:type", Function),
|
|
399
400
|
_ts_metadata$8("design:paramtypes", []),
|
|
400
401
|
_ts_metadata$8("design:returntype", void 0)
|
|
401
402
|
], ZRomulatorSystemKnown, "nes", null);
|
|
402
|
-
_ts_decorate$
|
|
403
|
+
_ts_decorate$d([
|
|
403
404
|
helpfulReflection.ZTag(KnownSystem),
|
|
404
405
|
_ts_metadata$8("design:type", Function),
|
|
405
406
|
_ts_metadata$8("design:paramtypes", []),
|
|
406
407
|
_ts_metadata$8("design:returntype", void 0)
|
|
407
408
|
], ZRomulatorSystemKnown, "snes", null);
|
|
408
|
-
_ts_decorate$
|
|
409
|
+
_ts_decorate$d([
|
|
409
410
|
helpfulReflection.ZTag(KnownSystem),
|
|
410
411
|
_ts_metadata$8("design:type", Function),
|
|
411
412
|
_ts_metadata$8("design:paramtypes", []),
|
|
412
413
|
_ts_metadata$8("design:returntype", void 0)
|
|
413
414
|
], ZRomulatorSystemKnown, "n64", null);
|
|
414
|
-
_ts_decorate$
|
|
415
|
+
_ts_decorate$d([
|
|
415
416
|
helpfulReflection.ZTag(KnownSystem),
|
|
416
417
|
_ts_metadata$8("design:type", Function),
|
|
417
418
|
_ts_metadata$8("design:paramtypes", []),
|
|
418
419
|
_ts_metadata$8("design:returntype", void 0)
|
|
419
420
|
], ZRomulatorSystemKnown, "gc", null);
|
|
420
|
-
_ts_decorate$
|
|
421
|
+
_ts_decorate$d([
|
|
421
422
|
helpfulReflection.ZTag(KnownSystem),
|
|
422
423
|
_ts_metadata$8("design:type", Function),
|
|
423
424
|
_ts_metadata$8("design:paramtypes", []),
|
|
424
425
|
_ts_metadata$8("design:returntype", void 0)
|
|
425
426
|
], ZRomulatorSystemKnown, "wii", null);
|
|
426
|
-
_ts_decorate$
|
|
427
|
+
_ts_decorate$d([
|
|
427
428
|
helpfulReflection.ZTag(KnownSystem),
|
|
428
429
|
_ts_metadata$8("design:type", Function),
|
|
429
430
|
_ts_metadata$8("design:paramtypes", []),
|
|
430
431
|
_ts_metadata$8("design:returntype", void 0)
|
|
431
432
|
], ZRomulatorSystemKnown, "wiiu", null);
|
|
432
|
-
_ts_decorate$
|
|
433
|
+
_ts_decorate$d([
|
|
433
434
|
helpfulReflection.ZTag(KnownSystem),
|
|
434
435
|
_ts_metadata$8("design:type", Function),
|
|
435
436
|
_ts_metadata$8("design:paramtypes", []),
|
|
436
437
|
_ts_metadata$8("design:returntype", void 0)
|
|
437
438
|
], ZRomulatorSystemKnown, "switch", null);
|
|
438
439
|
|
|
439
|
-
function _ts_decorate$
|
|
440
|
+
function _ts_decorate$c(decorators, target, key, desc) {
|
|
440
441
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
441
442
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
442
443
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -515,7 +516,7 @@ class ZRomulatorGamesService {
|
|
|
515
516
|
].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
|
|
516
517
|
}
|
|
517
518
|
}
|
|
518
|
-
ZRomulatorGamesService = _ts_decorate$
|
|
519
|
+
ZRomulatorGamesService = _ts_decorate$c([
|
|
519
520
|
common.Injectable(),
|
|
520
521
|
_ts_param$7(0, common.Inject(crumbtrailNest.ZFileSystemToken)),
|
|
521
522
|
_ts_param$7(1, common.Inject(ZRomulatorConfigsToken)),
|
|
@@ -528,7 +529,7 @@ ZRomulatorGamesService = _ts_decorate$b([
|
|
|
528
529
|
])
|
|
529
530
|
], ZRomulatorGamesService);
|
|
530
531
|
|
|
531
|
-
function _ts_decorate$
|
|
532
|
+
function _ts_decorate$b(decorators, target, key, desc) {
|
|
532
533
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
533
534
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
534
535
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -554,7 +555,7 @@ class ZRomulatorGamesController {
|
|
|
554
555
|
return this._games.get(identification);
|
|
555
556
|
}
|
|
556
557
|
}
|
|
557
|
-
_ts_decorate$
|
|
558
|
+
_ts_decorate$b([
|
|
558
559
|
common.Get(),
|
|
559
560
|
_ts_param$6(0, common.Query()),
|
|
560
561
|
_ts_metadata$6("design:type", Function),
|
|
@@ -563,7 +564,7 @@ _ts_decorate$a([
|
|
|
563
564
|
]),
|
|
564
565
|
_ts_metadata$6("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
565
566
|
], ZRomulatorGamesController.prototype, "list", null);
|
|
566
|
-
_ts_decorate$
|
|
567
|
+
_ts_decorate$b([
|
|
567
568
|
common.Get(":identification"),
|
|
568
569
|
_ts_param$6(0, common.Param("identification")),
|
|
569
570
|
_ts_metadata$6("design:type", Function),
|
|
@@ -572,7 +573,7 @@ _ts_decorate$a([
|
|
|
572
573
|
]),
|
|
573
574
|
_ts_metadata$6("design:returntype", void 0)
|
|
574
575
|
], ZRomulatorGamesController.prototype, "get", null);
|
|
575
|
-
ZRomulatorGamesController = _ts_decorate$
|
|
576
|
+
ZRomulatorGamesController = _ts_decorate$b([
|
|
576
577
|
common.Controller("games"),
|
|
577
578
|
_ts_param$6(0, common.Inject(ZRomulatorGamesToken)),
|
|
578
579
|
_ts_metadata$6("design:type", Function),
|
|
@@ -581,7 +582,7 @@ ZRomulatorGamesController = _ts_decorate$a([
|
|
|
581
582
|
])
|
|
582
583
|
], ZRomulatorGamesController);
|
|
583
584
|
|
|
584
|
-
function _ts_decorate$
|
|
585
|
+
function _ts_decorate$a(decorators, target, key, desc) {
|
|
585
586
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
586
587
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
587
588
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
@@ -589,7 +590,7 @@ function _ts_decorate$9(decorators, target, key, desc) {
|
|
|
589
590
|
}
|
|
590
591
|
class ZRomulatorGamesModule {
|
|
591
592
|
}
|
|
592
|
-
ZRomulatorGamesModule = _ts_decorate$
|
|
593
|
+
ZRomulatorGamesModule = _ts_decorate$a([
|
|
593
594
|
common.Module({
|
|
594
595
|
imports: [
|
|
595
596
|
ZRomulatorConfigsModule,
|
|
@@ -608,7 +609,7 @@ ZRomulatorGamesModule = _ts_decorate$9([
|
|
|
608
609
|
})
|
|
609
610
|
], ZRomulatorGamesModule);
|
|
610
611
|
|
|
611
|
-
function _ts_decorate$
|
|
612
|
+
function _ts_decorate$9(decorators, target, key, desc) {
|
|
612
613
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
613
614
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
614
615
|
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;
|
|
@@ -717,7 +718,7 @@ class ZRomulatorFilesService {
|
|
|
717
718
|
return this._fileStream.read(node.path);
|
|
718
719
|
}
|
|
719
720
|
}
|
|
720
|
-
ZRomulatorFilesService = _ts_decorate$
|
|
721
|
+
ZRomulatorFilesService = _ts_decorate$9([
|
|
721
722
|
common.Injectable(),
|
|
722
723
|
_ts_param$5(0, common.Inject(ZRomulatorConfigsToken)),
|
|
723
724
|
_ts_param$5(1, common.Inject(crumbtrailNest.ZFileSystemToken)),
|
|
@@ -728,7 +729,7 @@ ZRomulatorFilesService = _ts_decorate$8([
|
|
|
728
729
|
])
|
|
729
730
|
], ZRomulatorFilesService);
|
|
730
731
|
|
|
731
|
-
function _ts_decorate$
|
|
732
|
+
function _ts_decorate$8(decorators, target, key, desc) {
|
|
732
733
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
733
734
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
734
735
|
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;
|
|
@@ -754,7 +755,7 @@ class ZRomulatorFilesModule {
|
|
|
754
755
|
await this._files.dispose();
|
|
755
756
|
}
|
|
756
757
|
}
|
|
757
|
-
ZRomulatorFilesModule = _ts_decorate$
|
|
758
|
+
ZRomulatorFilesModule = _ts_decorate$8([
|
|
758
759
|
common.Module({
|
|
759
760
|
imports: [
|
|
760
761
|
crumbtrailNest.ZFileSystemModule,
|
|
@@ -777,6 +778,52 @@ ZRomulatorFilesModule = _ts_decorate$7([
|
|
|
777
778
|
])
|
|
778
779
|
], ZRomulatorFilesModule);
|
|
779
780
|
|
|
781
|
+
function _ts_decorate$7(decorators, target, key, desc) {
|
|
782
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
783
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
784
|
+
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;
|
|
785
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* The injection token for the media generator.
|
|
789
|
+
*/ const ZRomulatorMediaGeneratorToken = Symbol("media-generator");
|
|
790
|
+
class ZRomulatorMediaGenerator {
|
|
791
|
+
generate(name) {
|
|
792
|
+
const width = 373;
|
|
793
|
+
const height = 187;
|
|
794
|
+
const fallbackName = name?.trim().length ? name.trim() : "?";
|
|
795
|
+
const uppercaseName = fallbackName.toUpperCase();
|
|
796
|
+
const escapedName = this.escapeSvgText(uppercaseName);
|
|
797
|
+
const svg = helpfulFn.html`
|
|
798
|
+
<svg
|
|
799
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
800
|
+
width="${width}"
|
|
801
|
+
height="${height}"
|
|
802
|
+
viewBox="0 0 ${width} ${height}"
|
|
803
|
+
>
|
|
804
|
+
<text
|
|
805
|
+
x="50%"
|
|
806
|
+
y="50%"
|
|
807
|
+
fill="#fff"
|
|
808
|
+
font-size="48"
|
|
809
|
+
text-anchor="middle"
|
|
810
|
+
textLength="${width}"
|
|
811
|
+
lengthAdjust="spacingAndGlyphs"
|
|
812
|
+
>
|
|
813
|
+
${escapedName}
|
|
814
|
+
</text>
|
|
815
|
+
</svg>
|
|
816
|
+
`;
|
|
817
|
+
return Promise.resolve(Buffer.from(svg));
|
|
818
|
+
}
|
|
819
|
+
escapeSvgText(value) {
|
|
820
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
ZRomulatorMediaGenerator = _ts_decorate$7([
|
|
824
|
+
common.Injectable()
|
|
825
|
+
], ZRomulatorMediaGenerator);
|
|
826
|
+
|
|
780
827
|
function _ts_decorate$6(decorators, target, key, desc) {
|
|
781
828
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
782
829
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -793,9 +840,11 @@ function _ts_param$3(paramIndex, decorator) {
|
|
|
793
840
|
}
|
|
794
841
|
const ZRomulatorMediaToken = Symbol("romulator-media-service");
|
|
795
842
|
class ZRomulatorMediaService {
|
|
843
|
+
_generator;
|
|
796
844
|
_files;
|
|
797
845
|
_logger;
|
|
798
|
-
constructor(_files, logger){
|
|
846
|
+
constructor(_generator, _files, logger){
|
|
847
|
+
this._generator = _generator;
|
|
799
848
|
this._files = _files;
|
|
800
849
|
this._logger = new lumberjackyLog.ZLoggerContext("ZRomulatorMediaService", logger);
|
|
801
850
|
}
|
|
@@ -817,31 +866,34 @@ class ZRomulatorMediaService {
|
|
|
817
866
|
const count = await source.count(req);
|
|
818
867
|
return new helpfulQuery.ZPageBuilder().data(page).count(count).build();
|
|
819
868
|
}
|
|
869
|
+
async query(id) {
|
|
870
|
+
const mediaList = await this.findAllMedia();
|
|
871
|
+
const index = lodashEs.findIndex(mediaList, (m)=>m.id === id);
|
|
872
|
+
return helpfulFn.firstDefined(null, mediaList[index]);
|
|
873
|
+
}
|
|
820
874
|
async get(id) {
|
|
821
875
|
const time = new Date();
|
|
822
876
|
let log = `Searching for media with id ${id}.`;
|
|
823
877
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
824
|
-
const
|
|
825
|
-
const index = lodashEs.findIndex(mediaList, (m)=>m.id === id);
|
|
878
|
+
const media = await this.query(id);
|
|
826
879
|
const span = new Date().getTime() - time.getTime();
|
|
827
|
-
if (
|
|
880
|
+
if (media == null) {
|
|
828
881
|
const msg = `Could not find any media with id, ${id}.`;
|
|
829
882
|
log = `${msg} Search took ${span} milliseconds`;
|
|
830
883
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().warning().message(log).build());
|
|
831
884
|
throw new common.NotFoundException(msg);
|
|
832
885
|
}
|
|
833
|
-
const media = mediaList[index];
|
|
834
886
|
log = `Found media, ${media.url} after ${span} milliseconds`;
|
|
835
887
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
836
888
|
return media;
|
|
837
889
|
}
|
|
838
890
|
async download(id, accept) {
|
|
839
|
-
|
|
891
|
+
const log = `Download request received for ${id}`;
|
|
840
892
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(log).build());
|
|
841
|
-
const
|
|
842
|
-
const
|
|
843
|
-
const
|
|
844
|
-
const mime = helpfulFn.firstTruthy(
|
|
893
|
+
const media = await this.query(id);
|
|
894
|
+
const url = helpfulFn.firstDefined("", media?.url);
|
|
895
|
+
const fileName = helpfulFn.firstDefined("", media?.fileName);
|
|
896
|
+
const mime = helpfulFn.firstTruthy(webigailUrl.ZMimeTypeImage.SVG, mimeTypes.lookup(fileName));
|
|
845
897
|
const accepts = accept.split(",").map((h)=>h.split(";")[0].trim());
|
|
846
898
|
const acceptable = accepts.some((a)=>{
|
|
847
899
|
if (a === "*/*") {
|
|
@@ -857,9 +909,20 @@ class ZRomulatorMediaService {
|
|
|
857
909
|
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().error().message(msg).build());
|
|
858
910
|
throw new common.NotAcceptableException(msg);
|
|
859
911
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
912
|
+
const generate = async ()=>{
|
|
913
|
+
// Note that this isn't perfect and is just a fallback to a wheel + marquee for now.
|
|
914
|
+
// When we get to retrieving other media besides wheels, we will generate
|
|
915
|
+
// everything, but for now, this will be fine enough.
|
|
916
|
+
const log = `Media, ${id}, does not exist. Generating one`;
|
|
917
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().warning().message(log).build());
|
|
918
|
+
const parts = id.split("-");
|
|
919
|
+
parts.pop();
|
|
920
|
+
const name = parts.join(" ");
|
|
921
|
+
const buffer = await this._generator.generate(name);
|
|
922
|
+
return node_stream.Readable.from(buffer);
|
|
923
|
+
};
|
|
924
|
+
const stream = media == null ? await generate() : node_fs.createReadStream(url);
|
|
925
|
+
return new common.StreamableFile(stream, {
|
|
863
926
|
type: mime,
|
|
864
927
|
disposition: `inline; filename=${fileName}`
|
|
865
928
|
});
|
|
@@ -882,10 +945,12 @@ class ZRomulatorMediaService {
|
|
|
882
945
|
}
|
|
883
946
|
ZRomulatorMediaService = _ts_decorate$6([
|
|
884
947
|
common.Injectable(),
|
|
885
|
-
_ts_param$3(0, common.Inject(
|
|
886
|
-
_ts_param$3(1, common.Inject(
|
|
948
|
+
_ts_param$3(0, common.Inject(ZRomulatorMediaGeneratorToken)),
|
|
949
|
+
_ts_param$3(1, common.Inject(ZRomulatorFilesToken)),
|
|
950
|
+
_ts_param$3(2, common.Inject(lumberjackyNest.ZLoggerToken)),
|
|
887
951
|
_ts_metadata$3("design:type", Function),
|
|
888
952
|
_ts_metadata$3("design:paramtypes", [
|
|
953
|
+
typeof IZRomulatorMediaGenerator === "undefined" ? Object : IZRomulatorMediaGenerator,
|
|
889
954
|
typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService,
|
|
890
955
|
typeof IZLogger === "undefined" ? Object : IZLogger
|
|
891
956
|
])
|
|
@@ -1045,6 +1110,10 @@ ZRomulatorMediaModule = _ts_decorate$4([
|
|
|
1045
1110
|
ZRomulatorMediaController
|
|
1046
1111
|
],
|
|
1047
1112
|
providers: [
|
|
1113
|
+
{
|
|
1114
|
+
provide: ZRomulatorMediaGeneratorToken,
|
|
1115
|
+
useClass: ZRomulatorMediaGenerator
|
|
1116
|
+
},
|
|
1048
1117
|
{
|
|
1049
1118
|
provide: ZRomulatorMediaToken,
|
|
1050
1119
|
useClass: ZRomulatorMediaService
|