@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.js CHANGED
@@ -5,7 +5,7 @@ import { ZFileSystemModule, ZFileSystemToken } from '@zthun/crumbtrail-nest';
5
5
  import { ZLoggerToken, ZLoggerModule } from '@zthun/lumberjacky-nest';
6
6
  import { ZDataSourceStaticOptionsBuilder, ZDataSearchFields, ZDataSourceStatic, ZPageBuilder, ZDataRequestBuilder, ZSortBuilder, ZFilterBinaryBuilder, ZFilterLogicBuilder } from '@zthun/helpful-query';
7
7
  import { IsDefined, IsObject, IsNotEmptyObject } from 'class-validator';
8
- import { firstDefined, createError, detokenize, firstTruthy } from '@zthun/helpful-fn';
8
+ import { firstDefined, createError, detokenize, firstTruthy, html } from '@zthun/helpful-fn';
9
9
  import { ZLoggerContext, ZLogEntryBuilder } from '@zthun/lumberjacky-log';
10
10
  import { ZRomulatorConfigBuilder, ZRomulatorConfigId as ZRomulatorConfigId$1, ZRomulatorConfigGamesMetadata, ZRomulatorSystemBuilder, ZRomulatorSystemId, ZRomulatorConfigGamesBuilder, ZRomulatorGameBuilder, ZRomulatorMediaBuilder, isSystemId } from '@zthun/romulator-client';
11
11
  import { find, kebabCase, castArray, trimEnd, first, findIndex } from 'lodash-es';
@@ -17,11 +17,12 @@ import 'reflect-metadata';
17
17
  import { ZFileRepository, ZStreamFolder, ZStreamFile } from '@zthun/crumbtrail-fs';
18
18
  import { env } from 'node:process';
19
19
  import { ZHttpCodeSuccess, ZHttpCodeClient } from '@zthun/webigail-http';
20
- import { ZMimeTypeApplication } from '@zthun/webigail-url';
20
+ import { ZMimeTypeImage } from '@zthun/webigail-url';
21
21
  import { lookup } from 'mime-types';
22
22
  import { createReadStream } from 'node:fs';
23
+ import { Readable } from 'node:stream';
23
24
 
24
- function _ts_decorate$g(decorators, target, key, desc) {
25
+ function _ts_decorate$h(decorators, target, key, desc) {
25
26
  var c = arguments.length, r = c < 3 ? target : desc, d;
26
27
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
27
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;
@@ -33,7 +34,7 @@ function _ts_metadata$b(k, v) {
33
34
  class ZRomulatorConfigUpdateDto {
34
35
  contents;
35
36
  }
36
- _ts_decorate$g([
37
+ _ts_decorate$h([
37
38
  ApiProperty({
38
39
  type: "object",
39
40
  properties: {}
@@ -72,7 +73,7 @@ class ZRomulatorConfigKnown {
72
73
  }
73
74
  }
74
75
 
75
- function _ts_decorate$f(decorators, target, key, desc) {
76
+ function _ts_decorate$g(decorators, target, key, desc) {
76
77
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
77
78
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
78
79
  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;
@@ -163,7 +164,7 @@ class ZRomulatorConfigsService {
163
164
  return config;
164
165
  }
165
166
  }
166
- ZRomulatorConfigsService = _ts_decorate$f([
167
+ ZRomulatorConfigsService = _ts_decorate$g([
167
168
  Injectable(),
168
169
  _ts_param$9(0, Inject(ZLoggerToken)),
169
170
  _ts_metadata$a("design:type", Function),
@@ -172,7 +173,7 @@ ZRomulatorConfigsService = _ts_decorate$f([
172
173
  ])
173
174
  ], ZRomulatorConfigsService);
174
175
 
175
- function _ts_decorate$e(decorators, target, key, desc) {
176
+ function _ts_decorate$f(decorators, target, key, desc) {
176
177
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
177
178
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
178
179
  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;
@@ -202,7 +203,7 @@ class ZRomulatorConfigsController {
202
203
  return await this._configs.get(identification);
203
204
  }
204
205
  }
205
- _ts_decorate$e([
206
+ _ts_decorate$f([
206
207
  Get(),
207
208
  _ts_param$8(0, Query()),
208
209
  _ts_metadata$9("design:type", Function),
@@ -211,7 +212,7 @@ _ts_decorate$e([
211
212
  ]),
212
213
  _ts_metadata$9("design:returntype", Promise)
213
214
  ], ZRomulatorConfigsController.prototype, "list", null);
214
- _ts_decorate$e([
215
+ _ts_decorate$f([
215
216
  ApiParam({
216
217
  type: "string",
217
218
  name: "identification",
@@ -237,7 +238,7 @@ _ts_decorate$e([
237
238
  ]),
238
239
  _ts_metadata$9("design:returntype", Promise)
239
240
  ], ZRomulatorConfigsController.prototype, "update", null);
240
- _ts_decorate$e([
241
+ _ts_decorate$f([
241
242
  ApiParam({
242
243
  type: "string",
243
244
  name: "identification",
@@ -251,7 +252,7 @@ _ts_decorate$e([
251
252
  ]),
252
253
  _ts_metadata$9("design:returntype", Promise)
253
254
  ], ZRomulatorConfigsController.prototype, "get", null);
254
- ZRomulatorConfigsController = _ts_decorate$e([
255
+ ZRomulatorConfigsController = _ts_decorate$f([
255
256
  Controller("configs"),
256
257
  _ts_param$8(0, Inject(ZRomulatorConfigsToken)),
257
258
  _ts_metadata$9("design:type", Function),
@@ -260,7 +261,7 @@ ZRomulatorConfigsController = _ts_decorate$e([
260
261
  ])
261
262
  ], ZRomulatorConfigsController);
262
263
 
263
- function _ts_decorate$d(decorators, target, key, desc) {
264
+ function _ts_decorate$e(decorators, target, key, desc) {
264
265
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
265
266
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
266
267
  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;
@@ -268,7 +269,7 @@ function _ts_decorate$d(decorators, target, key, desc) {
268
269
  }
269
270
  class ZRomulatorConfigsModule {
270
271
  }
271
- ZRomulatorConfigsModule = _ts_decorate$d([
272
+ ZRomulatorConfigsModule = _ts_decorate$e([
272
273
  Module({
273
274
  imports: [
274
275
  ZFileSystemModule,
@@ -289,7 +290,7 @@ ZRomulatorConfigsModule = _ts_decorate$d([
289
290
  })
290
291
  ], ZRomulatorConfigsModule);
291
292
 
292
- function _ts_decorate$c(decorators, target, key, desc) {
293
+ function _ts_decorate$d(decorators, target, key, desc) {
293
294
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
294
295
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
295
296
  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;
@@ -391,50 +392,50 @@ const KnownSystem = "@zthunworks/romulator/known-system";
391
392
  return null;
392
393
  }
393
394
  }
394
- _ts_decorate$c([
395
+ _ts_decorate$d([
395
396
  ZTag(KnownSystem),
396
397
  _ts_metadata$8("design:type", Function),
397
398
  _ts_metadata$8("design:paramtypes", []),
398
399
  _ts_metadata$8("design:returntype", void 0)
399
400
  ], ZRomulatorSystemKnown, "nes", null);
400
- _ts_decorate$c([
401
+ _ts_decorate$d([
401
402
  ZTag(KnownSystem),
402
403
  _ts_metadata$8("design:type", Function),
403
404
  _ts_metadata$8("design:paramtypes", []),
404
405
  _ts_metadata$8("design:returntype", void 0)
405
406
  ], ZRomulatorSystemKnown, "snes", null);
406
- _ts_decorate$c([
407
+ _ts_decorate$d([
407
408
  ZTag(KnownSystem),
408
409
  _ts_metadata$8("design:type", Function),
409
410
  _ts_metadata$8("design:paramtypes", []),
410
411
  _ts_metadata$8("design:returntype", void 0)
411
412
  ], ZRomulatorSystemKnown, "n64", null);
412
- _ts_decorate$c([
413
+ _ts_decorate$d([
413
414
  ZTag(KnownSystem),
414
415
  _ts_metadata$8("design:type", Function),
415
416
  _ts_metadata$8("design:paramtypes", []),
416
417
  _ts_metadata$8("design:returntype", void 0)
417
418
  ], ZRomulatorSystemKnown, "gc", null);
418
- _ts_decorate$c([
419
+ _ts_decorate$d([
419
420
  ZTag(KnownSystem),
420
421
  _ts_metadata$8("design:type", Function),
421
422
  _ts_metadata$8("design:paramtypes", []),
422
423
  _ts_metadata$8("design:returntype", void 0)
423
424
  ], ZRomulatorSystemKnown, "wii", null);
424
- _ts_decorate$c([
425
+ _ts_decorate$d([
425
426
  ZTag(KnownSystem),
426
427
  _ts_metadata$8("design:type", Function),
427
428
  _ts_metadata$8("design:paramtypes", []),
428
429
  _ts_metadata$8("design:returntype", void 0)
429
430
  ], ZRomulatorSystemKnown, "wiiu", null);
430
- _ts_decorate$c([
431
+ _ts_decorate$d([
431
432
  ZTag(KnownSystem),
432
433
  _ts_metadata$8("design:type", Function),
433
434
  _ts_metadata$8("design:paramtypes", []),
434
435
  _ts_metadata$8("design:returntype", void 0)
435
436
  ], ZRomulatorSystemKnown, "switch", null);
436
437
 
437
- function _ts_decorate$b(decorators, target, key, desc) {
438
+ function _ts_decorate$c(decorators, target, key, desc) {
438
439
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
439
440
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
440
441
  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;
@@ -513,7 +514,7 @@ class ZRomulatorGamesService {
513
514
  ].filter((s)=>s.length).some((k)=>k.toLowerCase().includes(needle));
514
515
  }
515
516
  }
516
- ZRomulatorGamesService = _ts_decorate$b([
517
+ ZRomulatorGamesService = _ts_decorate$c([
517
518
  Injectable(),
518
519
  _ts_param$7(0, Inject(ZFileSystemToken)),
519
520
  _ts_param$7(1, Inject(ZRomulatorConfigsToken)),
@@ -526,7 +527,7 @@ ZRomulatorGamesService = _ts_decorate$b([
526
527
  ])
527
528
  ], ZRomulatorGamesService);
528
529
 
529
- function _ts_decorate$a(decorators, target, key, desc) {
530
+ function _ts_decorate$b(decorators, target, key, desc) {
530
531
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
531
532
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
532
533
  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;
@@ -552,7 +553,7 @@ class ZRomulatorGamesController {
552
553
  return this._games.get(identification);
553
554
  }
554
555
  }
555
- _ts_decorate$a([
556
+ _ts_decorate$b([
556
557
  Get(),
557
558
  _ts_param$6(0, Query()),
558
559
  _ts_metadata$6("design:type", Function),
@@ -561,7 +562,7 @@ _ts_decorate$a([
561
562
  ]),
562
563
  _ts_metadata$6("design:returntype", typeof Promise === "undefined" ? Object : Promise)
563
564
  ], ZRomulatorGamesController.prototype, "list", null);
564
- _ts_decorate$a([
565
+ _ts_decorate$b([
565
566
  Get(":identification"),
566
567
  _ts_param$6(0, Param("identification")),
567
568
  _ts_metadata$6("design:type", Function),
@@ -570,7 +571,7 @@ _ts_decorate$a([
570
571
  ]),
571
572
  _ts_metadata$6("design:returntype", void 0)
572
573
  ], ZRomulatorGamesController.prototype, "get", null);
573
- ZRomulatorGamesController = _ts_decorate$a([
574
+ ZRomulatorGamesController = _ts_decorate$b([
574
575
  Controller("games"),
575
576
  _ts_param$6(0, Inject(ZRomulatorGamesToken)),
576
577
  _ts_metadata$6("design:type", Function),
@@ -579,7 +580,7 @@ ZRomulatorGamesController = _ts_decorate$a([
579
580
  ])
580
581
  ], ZRomulatorGamesController);
581
582
 
582
- function _ts_decorate$9(decorators, target, key, desc) {
583
+ function _ts_decorate$a(decorators, target, key, desc) {
583
584
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
584
585
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
585
586
  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;
@@ -587,7 +588,7 @@ function _ts_decorate$9(decorators, target, key, desc) {
587
588
  }
588
589
  class ZRomulatorGamesModule {
589
590
  }
590
- ZRomulatorGamesModule = _ts_decorate$9([
591
+ ZRomulatorGamesModule = _ts_decorate$a([
591
592
  Module({
592
593
  imports: [
593
594
  ZRomulatorConfigsModule,
@@ -606,7 +607,7 @@ ZRomulatorGamesModule = _ts_decorate$9([
606
607
  })
607
608
  ], ZRomulatorGamesModule);
608
609
 
609
- function _ts_decorate$8(decorators, target, key, desc) {
610
+ function _ts_decorate$9(decorators, target, key, desc) {
610
611
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
611
612
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
612
613
  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;
@@ -715,7 +716,7 @@ class ZRomulatorFilesService {
715
716
  return this._fileStream.read(node.path);
716
717
  }
717
718
  }
718
- ZRomulatorFilesService = _ts_decorate$8([
719
+ ZRomulatorFilesService = _ts_decorate$9([
719
720
  Injectable(),
720
721
  _ts_param$5(0, Inject(ZRomulatorConfigsToken)),
721
722
  _ts_param$5(1, Inject(ZFileSystemToken)),
@@ -726,7 +727,7 @@ ZRomulatorFilesService = _ts_decorate$8([
726
727
  ])
727
728
  ], ZRomulatorFilesService);
728
729
 
729
- function _ts_decorate$7(decorators, target, key, desc) {
730
+ function _ts_decorate$8(decorators, target, key, desc) {
730
731
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
731
732
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
732
733
  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;
@@ -752,7 +753,7 @@ class ZRomulatorFilesModule {
752
753
  await this._files.dispose();
753
754
  }
754
755
  }
755
- ZRomulatorFilesModule = _ts_decorate$7([
756
+ ZRomulatorFilesModule = _ts_decorate$8([
756
757
  Module({
757
758
  imports: [
758
759
  ZFileSystemModule,
@@ -775,6 +776,52 @@ ZRomulatorFilesModule = _ts_decorate$7([
775
776
  ])
776
777
  ], ZRomulatorFilesModule);
777
778
 
779
+ function _ts_decorate$7(decorators, target, key, desc) {
780
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
781
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
782
+ 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;
783
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
784
+ }
785
+ /**
786
+ * The injection token for the media generator.
787
+ */ const ZRomulatorMediaGeneratorToken = Symbol("media-generator");
788
+ class ZRomulatorMediaGenerator {
789
+ generate(name) {
790
+ const width = 373;
791
+ const height = 187;
792
+ const fallbackName = name?.trim().length ? name.trim() : "?";
793
+ const uppercaseName = fallbackName.toUpperCase();
794
+ const escapedName = this.escapeSvgText(uppercaseName);
795
+ const svg = html`
796
+ <svg
797
+ xmlns="http://www.w3.org/2000/svg"
798
+ width="${width}"
799
+ height="${height}"
800
+ viewBox="0 0 ${width} ${height}"
801
+ >
802
+ <text
803
+ x="50%"
804
+ y="50%"
805
+ fill="#fff"
806
+ font-size="48"
807
+ text-anchor="middle"
808
+ textLength="${width}"
809
+ lengthAdjust="spacingAndGlyphs"
810
+ >
811
+ ${escapedName}
812
+ </text>
813
+ </svg>
814
+ `;
815
+ return Promise.resolve(Buffer.from(svg));
816
+ }
817
+ escapeSvgText(value) {
818
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
819
+ }
820
+ }
821
+ ZRomulatorMediaGenerator = _ts_decorate$7([
822
+ Injectable()
823
+ ], ZRomulatorMediaGenerator);
824
+
778
825
  function _ts_decorate$6(decorators, target, key, desc) {
779
826
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
780
827
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -791,9 +838,11 @@ function _ts_param$3(paramIndex, decorator) {
791
838
  }
792
839
  const ZRomulatorMediaToken = Symbol("romulator-media-service");
793
840
  class ZRomulatorMediaService {
841
+ _generator;
794
842
  _files;
795
843
  _logger;
796
- constructor(_files, logger){
844
+ constructor(_generator, _files, logger){
845
+ this._generator = _generator;
797
846
  this._files = _files;
798
847
  this._logger = new ZLoggerContext("ZRomulatorMediaService", logger);
799
848
  }
@@ -815,31 +864,34 @@ class ZRomulatorMediaService {
815
864
  const count = await source.count(req);
816
865
  return new ZPageBuilder().data(page).count(count).build();
817
866
  }
867
+ async query(id) {
868
+ const mediaList = await this.findAllMedia();
869
+ const index = findIndex(mediaList, (m)=>m.id === id);
870
+ return firstDefined(null, mediaList[index]);
871
+ }
818
872
  async get(id) {
819
873
  const time = new Date();
820
874
  let log = `Searching for media with id ${id}.`;
821
875
  this._logger.log(new ZLogEntryBuilder().info().message(log).build());
822
- const mediaList = await this.findAllMedia();
823
- const index = findIndex(mediaList, (m)=>m.id === id);
876
+ const media = await this.query(id);
824
877
  const span = new Date().getTime() - time.getTime();
825
- if (index < 0) {
878
+ if (media == null) {
826
879
  const msg = `Could not find any media with id, ${id}.`;
827
880
  log = `${msg} Search took ${span} milliseconds`;
828
881
  this._logger.log(new ZLogEntryBuilder().warning().message(log).build());
829
882
  throw new NotFoundException(msg);
830
883
  }
831
- const media = mediaList[index];
832
884
  log = `Found media, ${media.url} after ${span} milliseconds`;
833
885
  this._logger.log(new ZLogEntryBuilder().info().message(log).build());
834
886
  return media;
835
887
  }
836
888
  async download(id, accept) {
837
- let log = `Download request received for ${id}`;
889
+ const log = `Download request received for ${id}`;
838
890
  this._logger.log(new ZLogEntryBuilder().info().message(log).build());
839
- const fallback = ZMimeTypeApplication.OctetStream;
840
- const { fileName, url } = await this.get(id);
841
- const lookupResult = lookup(firstDefined("", fileName));
842
- const mime = firstTruthy(fallback, lookupResult);
891
+ const media = await this.query(id);
892
+ const url = firstDefined("", media?.url);
893
+ const fileName = firstDefined("", media?.fileName);
894
+ const mime = firstTruthy(ZMimeTypeImage.SVG, lookup(fileName));
843
895
  const accepts = accept.split(",").map((h)=>h.split(";")[0].trim());
844
896
  const acceptable = accepts.some((a)=>{
845
897
  if (a === "*/*") {
@@ -855,9 +907,20 @@ class ZRomulatorMediaService {
855
907
  this._logger.log(new ZLogEntryBuilder().error().message(msg).build());
856
908
  throw new NotAcceptableException(msg);
857
909
  }
858
- log = `Streaming ${url}`;
859
- this._logger.log(new ZLogEntryBuilder().info().message(log).build());
860
- return new StreamableFile(createReadStream(firstDefined("", url)), {
910
+ const generate = async ()=>{
911
+ // Note that this isn't perfect and is just a fallback to a wheel + marquee for now.
912
+ // When we get to retrieving other media besides wheels, we will generate
913
+ // everything, but for now, this will be fine enough.
914
+ const log = `Media, ${id}, does not exist. Generating one`;
915
+ this._logger.log(new ZLogEntryBuilder().warning().message(log).build());
916
+ const parts = id.split("-");
917
+ parts.pop();
918
+ const name = parts.join(" ");
919
+ const buffer = await this._generator.generate(name);
920
+ return Readable.from(buffer);
921
+ };
922
+ const stream = media == null ? await generate() : createReadStream(url);
923
+ return new StreamableFile(stream, {
861
924
  type: mime,
862
925
  disposition: `inline; filename=${fileName}`
863
926
  });
@@ -880,10 +943,12 @@ class ZRomulatorMediaService {
880
943
  }
881
944
  ZRomulatorMediaService = _ts_decorate$6([
882
945
  Injectable(),
883
- _ts_param$3(0, Inject(ZRomulatorFilesToken)),
884
- _ts_param$3(1, Inject(ZLoggerToken)),
946
+ _ts_param$3(0, Inject(ZRomulatorMediaGeneratorToken)),
947
+ _ts_param$3(1, Inject(ZRomulatorFilesToken)),
948
+ _ts_param$3(2, Inject(ZLoggerToken)),
885
949
  _ts_metadata$3("design:type", Function),
886
950
  _ts_metadata$3("design:paramtypes", [
951
+ typeof IZRomulatorMediaGenerator === "undefined" ? Object : IZRomulatorMediaGenerator,
887
952
  typeof IZRomulatorFilesService === "undefined" ? Object : IZRomulatorFilesService,
888
953
  typeof IZLogger === "undefined" ? Object : IZLogger
889
954
  ])
@@ -1043,6 +1108,10 @@ ZRomulatorMediaModule = _ts_decorate$4([
1043
1108
  ZRomulatorMediaController
1044
1109
  ],
1045
1110
  providers: [
1111
+ {
1112
+ provide: ZRomulatorMediaGeneratorToken,
1113
+ useClass: ZRomulatorMediaGenerator
1114
+ },
1046
1115
  {
1047
1116
  provide: ZRomulatorMediaToken,
1048
1117
  useClass: ZRomulatorMediaService