@squiz/edge-dev-render-runtime-lib 2.5.1 → 2.5.3

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/lib/index.js CHANGED
@@ -66,7 +66,7 @@ var import_http = __toESM(require("http"));
66
66
  var import_supertest = __toESM(require("supertest"));
67
67
  var import_child_process = require("child_process");
68
68
  var import_path4 = __toESM(require("path"));
69
- var import_os2 = __toESM(require("os"));
69
+ var import_os = __toESM(require("os"));
70
70
  var import_dx_logger_lib = require("@squiz/dx-logger-lib");
71
71
 
72
72
  // src/webserver/app.ts
@@ -190,8 +190,8 @@ var import_component_lib = require("@squiz/component-lib");
190
190
  var import_dx_common_lib2 = require("@squiz/dx-common-lib");
191
191
 
192
192
  // src/utils/setHeadersOnExpressResponse.ts
193
- function setHeadersOnExpressResponse(headers, response) {
194
- for (const [headerName, headerValue] of Object.entries(headers)) {
193
+ function setHeadersOnExpressResponse(headers3, response) {
194
+ for (const [headerName, headerValue] of Object.entries(headers3)) {
195
195
  if (headerValue) {
196
196
  response.setHeader(headerName, headerValue);
197
197
  } else {
@@ -200,6 +200,1289 @@ function setHeadersOnExpressResponse(headers, response) {
200
200
  }
201
201
  }
202
202
 
203
+ // src/webserver/controllers/utils/ReplaceWithMock.ts
204
+ var import_dx_json_schema_lib2 = require("@squiz/dx-json-schema-lib");
205
+
206
+ // src/webserver/controllers/mocks/mockResources.ts
207
+ var resources = [
208
+ {
209
+ id: "1",
210
+ type: {
211
+ code: "image",
212
+ name: "Image"
213
+ },
214
+ status: {
215
+ code: "live",
216
+ name: "Live"
217
+ },
218
+ source: {
219
+ id: "1",
220
+ type: "matrix"
221
+ },
222
+ name: "Example image",
223
+ childCount: 0,
224
+ url: "https://picsum.photos/200/300",
225
+ urls: [],
226
+ squizImage: {
227
+ name: "My Image",
228
+ alt: "My Image that did not load",
229
+ caption: "This above is a loaded image",
230
+ imageVariations: {
231
+ original: {
232
+ url: "http://example.com/image.jpg",
233
+ width: 100,
234
+ height: 100,
235
+ byteSize: 1e3,
236
+ mimeType: "image/jpeg",
237
+ aspectRatio: "1:1",
238
+ sha1Hash: "1234567890abcdef1234567890abcdef12345678"
239
+ }
240
+ },
241
+ exif: {
242
+ thumbnail: {
243
+ Compression: void 0,
244
+ Orientation: void 0,
245
+ ResolutionUnit: void 0,
246
+ ThumbnailLength: void 0,
247
+ ThumbnailOffset: void 0,
248
+ XResolution: void 0,
249
+ YCbCrPositioning: void 0,
250
+ YResolution: void 0
251
+ },
252
+ exif: {
253
+ ApertureValue: void 0,
254
+ BrightnessValue: void 0,
255
+ ColorSpace: void 0,
256
+ ComponentsConfiguration: void 0,
257
+ CompressedBitsPerPixel: void 0,
258
+ CreateDate: void 0,
259
+ DateTimeOriginal: void 0,
260
+ ExifImageHeight: void 0,
261
+ ExifImageWidth: void 0,
262
+ ExifVersion: void 0,
263
+ ExposureCompensation: void 0,
264
+ ExposureMode: void 0,
265
+ ExposureProgram: void 0,
266
+ ExposureTime: void 0,
267
+ FileSource: void 0,
268
+ Flash: void 0,
269
+ FlashpixVersion: void 0,
270
+ FNumber: void 0,
271
+ FocalLength: void 0,
272
+ FocalLengthIn35mmFormat: void 0,
273
+ FocalPlaneResolutionUnit: void 0,
274
+ FocalPlaneXResolution: void 0,
275
+ FocalPlaneYResolution: void 0,
276
+ ImageUniqueID: void 0,
277
+ InteropOffset: void 0,
278
+ ISO: void 0,
279
+ LensMake: void 0,
280
+ LensModel: void 0,
281
+ MakerNote: void 0,
282
+ MaxApertureValue: void 0,
283
+ MeteringMode: void 0,
284
+ SceneCaptureType: void 0,
285
+ SceneType: void 0,
286
+ SensingMethod: void 0,
287
+ ShutterSpeedValue: void 0,
288
+ UserComment: void 0,
289
+ WhiteBalance: void 0
290
+ },
291
+ gps: {
292
+ GPSAltitude: void 0,
293
+ GPSAltitudeRef: void 0,
294
+ GPSAreaInformation: void 0,
295
+ GPSDateStamp: void 0,
296
+ GPSDestBearing: void 0,
297
+ GPSDestBearingRef: void 0,
298
+ GPSDestDistance: void 0,
299
+ GPSDestDistanceRef: void 0,
300
+ GPSDestLatitude: void 0,
301
+ GPSDestLatitudeRef: void 0,
302
+ GPSDestLongitude: void 0,
303
+ GPSDestLongitudeRef: void 0,
304
+ GPSDifferential: void 0,
305
+ GPSDOP: void 0,
306
+ GPSHPositioningError: void 0,
307
+ GPSImgDirection: void 0,
308
+ GPSImgDirectionRef: void 0,
309
+ GPSLatitude: void 0,
310
+ GPSLatitudeRef: void 0,
311
+ GPSLongitude: void 0,
312
+ GPSLongitudeRef: void 0,
313
+ GPSMapDatum: void 0,
314
+ GPSMeasureMode: void 0,
315
+ GPSProcessingMethod: void 0,
316
+ GPSTimeStamp: void 0,
317
+ GPSSatellites: void 0,
318
+ GPSSpeed: void 0,
319
+ GPSSpeedRef: void 0,
320
+ GPSStatus: void 0,
321
+ GPSTrack: void 0,
322
+ GPSTrackRef: void 0,
323
+ GPSVersionId: void 0
324
+ },
325
+ interoperability: {
326
+ InteropIndex: void 0,
327
+ InteropVersion: void 0
328
+ },
329
+ makernote: {
330
+ AutoBracketing: void 0,
331
+ BlurWarning: void 0,
332
+ ExposureWarning: void 0,
333
+ error: void 0,
334
+ FlashExposureComp: void 0,
335
+ FocusMode: void 0,
336
+ FocusWarning: void 0,
337
+ FujiFlashMode: void 0,
338
+ Macro: void 0,
339
+ Quality: void 0,
340
+ Sharpness: void 0,
341
+ SlowSync: void 0,
342
+ Version: void 0,
343
+ WhiteBalance: void 0
344
+ },
345
+ image: {
346
+ Artist: void 0,
347
+ Copyright: void 0,
348
+ ExifOffset: void 0,
349
+ ImageHeight: void 0,
350
+ ImageWidth: void 0,
351
+ Make: void 0,
352
+ Model: void 0,
353
+ ModifyDate: void 0,
354
+ Orientation: void 0,
355
+ ResolutionUnit: void 0,
356
+ Software: void 0,
357
+ XResolution: void 0,
358
+ YCbCrPositioning: void 0,
359
+ YResolution: void 0
360
+ }
361
+ }
362
+ }
363
+ },
364
+ {
365
+ id: "2",
366
+ type: {
367
+ code: "image",
368
+ name: "Image"
369
+ },
370
+ status: {
371
+ code: "live",
372
+ name: "Live"
373
+ },
374
+ source: {
375
+ id: "1",
376
+ type: "matrix"
377
+ },
378
+ name: "Example image two",
379
+ childCount: 0,
380
+ url: "https://picsum.photos/200/300",
381
+ urls: [],
382
+ squizImage: {
383
+ name: "My Image",
384
+ alt: "My Image that did not load",
385
+ caption: "This above is a loaded image",
386
+ imageVariations: {
387
+ original: {
388
+ url: "http://example.com/image.jpg",
389
+ width: 100,
390
+ height: 100,
391
+ byteSize: 1e3,
392
+ mimeType: "image/jpeg",
393
+ aspectRatio: "1:1",
394
+ sha1Hash: "1234567890abcdef1234567890abcdef12345678"
395
+ }
396
+ },
397
+ exif: {
398
+ thumbnail: {
399
+ Compression: void 0,
400
+ Orientation: void 0,
401
+ ResolutionUnit: void 0,
402
+ ThumbnailLength: void 0,
403
+ ThumbnailOffset: void 0,
404
+ XResolution: void 0,
405
+ YCbCrPositioning: void 0,
406
+ YResolution: void 0
407
+ },
408
+ exif: {
409
+ ApertureValue: void 0,
410
+ BrightnessValue: void 0,
411
+ ColorSpace: void 0,
412
+ ComponentsConfiguration: void 0,
413
+ CompressedBitsPerPixel: void 0,
414
+ CreateDate: void 0,
415
+ DateTimeOriginal: void 0,
416
+ ExifImageHeight: void 0,
417
+ ExifImageWidth: void 0,
418
+ ExifVersion: void 0,
419
+ ExposureCompensation: void 0,
420
+ ExposureMode: void 0,
421
+ ExposureProgram: void 0,
422
+ ExposureTime: void 0,
423
+ FileSource: void 0,
424
+ Flash: void 0,
425
+ FlashpixVersion: void 0,
426
+ FNumber: void 0,
427
+ FocalLength: void 0,
428
+ FocalLengthIn35mmFormat: void 0,
429
+ FocalPlaneResolutionUnit: void 0,
430
+ FocalPlaneXResolution: void 0,
431
+ FocalPlaneYResolution: void 0,
432
+ ImageUniqueID: void 0,
433
+ InteropOffset: void 0,
434
+ ISO: void 0,
435
+ LensMake: void 0,
436
+ LensModel: void 0,
437
+ MakerNote: void 0,
438
+ MaxApertureValue: void 0,
439
+ MeteringMode: void 0,
440
+ SceneCaptureType: void 0,
441
+ SceneType: void 0,
442
+ SensingMethod: void 0,
443
+ ShutterSpeedValue: void 0,
444
+ UserComment: void 0,
445
+ WhiteBalance: void 0
446
+ },
447
+ gps: {
448
+ GPSAltitude: void 0,
449
+ GPSAltitudeRef: void 0,
450
+ GPSAreaInformation: void 0,
451
+ GPSDateStamp: void 0,
452
+ GPSDestBearing: void 0,
453
+ GPSDestBearingRef: void 0,
454
+ GPSDestDistance: void 0,
455
+ GPSDestDistanceRef: void 0,
456
+ GPSDestLatitude: void 0,
457
+ GPSDestLatitudeRef: void 0,
458
+ GPSDestLongitude: void 0,
459
+ GPSDestLongitudeRef: void 0,
460
+ GPSDifferential: void 0,
461
+ GPSDOP: void 0,
462
+ GPSHPositioningError: void 0,
463
+ GPSImgDirection: void 0,
464
+ GPSImgDirectionRef: void 0,
465
+ GPSLatitude: void 0,
466
+ GPSLatitudeRef: void 0,
467
+ GPSLongitude: void 0,
468
+ GPSLongitudeRef: void 0,
469
+ GPSMapDatum: void 0,
470
+ GPSMeasureMode: void 0,
471
+ GPSProcessingMethod: void 0,
472
+ GPSTimeStamp: void 0,
473
+ GPSSatellites: void 0,
474
+ GPSSpeed: void 0,
475
+ GPSSpeedRef: void 0,
476
+ GPSStatus: void 0,
477
+ GPSTrack: void 0,
478
+ GPSTrackRef: void 0,
479
+ GPSVersionId: void 0
480
+ },
481
+ interoperability: {
482
+ InteropIndex: void 0,
483
+ InteropVersion: void 0
484
+ },
485
+ makernote: {
486
+ AutoBracketing: void 0,
487
+ BlurWarning: void 0,
488
+ ExposureWarning: void 0,
489
+ error: void 0,
490
+ FlashExposureComp: void 0,
491
+ FocusMode: void 0,
492
+ FocusWarning: void 0,
493
+ FujiFlashMode: void 0,
494
+ Macro: void 0,
495
+ Quality: void 0,
496
+ Sharpness: void 0,
497
+ SlowSync: void 0,
498
+ Version: void 0,
499
+ WhiteBalance: void 0
500
+ },
501
+ image: {
502
+ Artist: void 0,
503
+ Copyright: void 0,
504
+ ExifOffset: void 0,
505
+ ImageHeight: void 0,
506
+ ImageWidth: void 0,
507
+ Make: void 0,
508
+ Model: void 0,
509
+ ModifyDate: void 0,
510
+ Orientation: void 0,
511
+ ResolutionUnit: void 0,
512
+ Software: void 0,
513
+ XResolution: void 0,
514
+ YCbCrPositioning: void 0,
515
+ YResolution: void 0
516
+ }
517
+ }
518
+ }
519
+ },
520
+ {
521
+ id: "3",
522
+ type: {
523
+ code: "page_standard",
524
+ name: "Standard Page"
525
+ },
526
+ status: {
527
+ code: "live",
528
+ name: "Live"
529
+ },
530
+ source: {
531
+ id: "1",
532
+ type: "matrix"
533
+ },
534
+ name: "Example page",
535
+ childCount: 0,
536
+ url: "https://picsum.photos/200/300",
537
+ urls: []
538
+ },
539
+ {
540
+ id: "4",
541
+ type: {
542
+ code: "unknown",
543
+ name: "Unknown Type"
544
+ },
545
+ status: {
546
+ code: "live",
547
+ name: "Live"
548
+ },
549
+ source: {
550
+ id: "1",
551
+ type: "matrix"
552
+ },
553
+ name: "Unknown",
554
+ childCount: 0,
555
+ url: "https://picsum.photos/200/300",
556
+ urls: []
557
+ },
558
+ {
559
+ id: "5",
560
+ type: {
561
+ code: "audio_file",
562
+ name: "Audio File"
563
+ },
564
+ status: {
565
+ code: "live",
566
+ name: "Live"
567
+ },
568
+ source: {
569
+ id: "1",
570
+ type: "matrix"
571
+ },
572
+ name: "Audio File",
573
+ childCount: 0,
574
+ url: "https://picsum.photos/200/300",
575
+ urls: []
576
+ },
577
+ {
578
+ id: "6",
579
+ type: {
580
+ code: "excel_doc",
581
+ name: "MS Excel Document"
582
+ },
583
+ status: {
584
+ code: "live",
585
+ name: "Live"
586
+ },
587
+ source: {
588
+ id: "1",
589
+ type: "matrix"
590
+ },
591
+ name: "Excel Document",
592
+ childCount: 0,
593
+ url: "https://picsum.photos/200/300",
594
+ urls: []
595
+ },
596
+ {
597
+ id: "7",
598
+ type: {
599
+ code: "folder",
600
+ name: "Folder"
601
+ },
602
+ status: {
603
+ code: "live",
604
+ name: "Live"
605
+ },
606
+ source: {
607
+ id: "1",
608
+ type: "matrix"
609
+ },
610
+ name: "Folder",
611
+ childCount: 0,
612
+ url: "https://picsum.photos/200/300",
613
+ urls: []
614
+ },
615
+ {
616
+ id: "8",
617
+ type: {
618
+ code: "page_standard",
619
+ name: "Standard Page"
620
+ },
621
+ status: {
622
+ code: "live",
623
+ name: "Live"
624
+ },
625
+ source: {
626
+ id: "1",
627
+ type: "matrix"
628
+ },
629
+ name: "Standard Page",
630
+ childCount: 0,
631
+ url: "https://picsum.photos/200/300",
632
+ urls: []
633
+ },
634
+ {
635
+ id: "9",
636
+ type: {
637
+ code: "pdf_file",
638
+ name: "PDF File"
639
+ },
640
+ status: {
641
+ code: "live",
642
+ name: "Live"
643
+ },
644
+ source: {
645
+ id: "1",
646
+ type: "matrix"
647
+ },
648
+ name: "PDF File",
649
+ childCount: 0,
650
+ url: "https://picsum.photos/200/300",
651
+ urls: []
652
+ },
653
+ {
654
+ id: "10",
655
+ type: {
656
+ code: "powerpoint_doc",
657
+ name: "MS PowerPoint Document"
658
+ },
659
+ status: {
660
+ code: "live",
661
+ name: "Live"
662
+ },
663
+ source: {
664
+ id: "1",
665
+ type: "matrix"
666
+ },
667
+ name: "Powerpoint presentation",
668
+ childCount: 0,
669
+ url: "https://picsum.photos/200/300",
670
+ urls: []
671
+ },
672
+ {
673
+ id: "11",
674
+ type: {
675
+ code: "site",
676
+ name: "Site"
677
+ },
678
+ status: {
679
+ code: "live",
680
+ name: "Live"
681
+ },
682
+ source: {
683
+ id: "1",
684
+ type: "matrix"
685
+ },
686
+ name: "Site",
687
+ childCount: 0,
688
+ url: "https://picsum.photos/200/300",
689
+ urls: []
690
+ },
691
+ {
692
+ id: "12",
693
+ type: {
694
+ code: "video_file",
695
+ name: "Video File"
696
+ },
697
+ status: {
698
+ code: "live",
699
+ name: "Live"
700
+ },
701
+ source: {
702
+ id: "1",
703
+ type: "matrix"
704
+ },
705
+ name: "Video file",
706
+ childCount: 0,
707
+ url: "https://picsum.photos/200/300",
708
+ urls: []
709
+ },
710
+ {
711
+ id: "13",
712
+ type: {
713
+ code: "word_doc",
714
+ name: "MS Word Document"
715
+ },
716
+ status: {
717
+ code: "live",
718
+ name: "Live"
719
+ },
720
+ source: {
721
+ id: "1",
722
+ type: "matrix"
723
+ },
724
+ name: "Word document",
725
+ childCount: 0,
726
+ url: "https://picsum.photos/200/300",
727
+ urls: []
728
+ },
729
+ {
730
+ id: "14",
731
+ type: {
732
+ code: "physical_file",
733
+ name: "Physical File"
734
+ },
735
+ status: {
736
+ code: "live",
737
+ name: "Live"
738
+ },
739
+ source: {
740
+ id: "1",
741
+ type: "matrix"
742
+ },
743
+ name: "Physical file",
744
+ childCount: 0,
745
+ url: "https://picsum.photos/200/300",
746
+ urls: []
747
+ },
748
+ {
749
+ id: "15",
750
+ type: {
751
+ code: "folder",
752
+ name: "Folder"
753
+ },
754
+ status: {
755
+ code: "live",
756
+ name: "Live"
757
+ },
758
+ source: {
759
+ id: "1",
760
+ type: "matrix"
761
+ },
762
+ name: "Example folder",
763
+ childCount: 10,
764
+ url: "",
765
+ urls: [],
766
+ _children: [
767
+ {
768
+ id: "5",
769
+ type: {
770
+ code: "image",
771
+ name: "Image"
772
+ },
773
+ status: {
774
+ code: "live",
775
+ name: "Live"
776
+ },
777
+ source: {
778
+ id: "1",
779
+ type: "matrix"
780
+ },
781
+ name: "Example image one #2",
782
+ childCount: 0,
783
+ url: "https://picsum.photos/200/300",
784
+ urls: [],
785
+ squizImage: {
786
+ name: "My Image",
787
+ alt: "My Image that did not load",
788
+ caption: "This above is a loaded image",
789
+ imageVariations: {
790
+ original: {
791
+ url: "http://example.com/image.jpg",
792
+ width: 100,
793
+ height: 100,
794
+ byteSize: 1e3,
795
+ mimeType: "image/jpeg",
796
+ aspectRatio: "1:1",
797
+ sha1Hash: "1234567890abcdef1234567890abcdef12345678"
798
+ }
799
+ },
800
+ exif: {
801
+ thumbnail: {
802
+ Compression: void 0,
803
+ Orientation: void 0,
804
+ ResolutionUnit: void 0,
805
+ ThumbnailLength: void 0,
806
+ ThumbnailOffset: void 0,
807
+ XResolution: void 0,
808
+ YCbCrPositioning: void 0,
809
+ YResolution: void 0
810
+ },
811
+ exif: {
812
+ ApertureValue: void 0,
813
+ BrightnessValue: void 0,
814
+ ColorSpace: void 0,
815
+ ComponentsConfiguration: void 0,
816
+ CompressedBitsPerPixel: void 0,
817
+ CreateDate: void 0,
818
+ DateTimeOriginal: void 0,
819
+ ExifImageHeight: void 0,
820
+ ExifImageWidth: void 0,
821
+ ExifVersion: void 0,
822
+ ExposureCompensation: void 0,
823
+ ExposureMode: void 0,
824
+ ExposureProgram: void 0,
825
+ ExposureTime: void 0,
826
+ FileSource: void 0,
827
+ Flash: void 0,
828
+ FlashpixVersion: void 0,
829
+ FNumber: void 0,
830
+ FocalLength: void 0,
831
+ FocalLengthIn35mmFormat: void 0,
832
+ FocalPlaneResolutionUnit: void 0,
833
+ FocalPlaneXResolution: void 0,
834
+ FocalPlaneYResolution: void 0,
835
+ ImageUniqueID: void 0,
836
+ InteropOffset: void 0,
837
+ ISO: void 0,
838
+ LensMake: void 0,
839
+ LensModel: void 0,
840
+ MakerNote: void 0,
841
+ MaxApertureValue: void 0,
842
+ MeteringMode: void 0,
843
+ SceneCaptureType: void 0,
844
+ SceneType: void 0,
845
+ SensingMethod: void 0,
846
+ ShutterSpeedValue: void 0,
847
+ UserComment: void 0,
848
+ WhiteBalance: void 0
849
+ },
850
+ gps: {
851
+ GPSAltitude: void 0,
852
+ GPSAltitudeRef: void 0,
853
+ GPSAreaInformation: void 0,
854
+ GPSDateStamp: void 0,
855
+ GPSDestBearing: void 0,
856
+ GPSDestBearingRef: void 0,
857
+ GPSDestDistance: void 0,
858
+ GPSDestDistanceRef: void 0,
859
+ GPSDestLatitude: void 0,
860
+ GPSDestLatitudeRef: void 0,
861
+ GPSDestLongitude: void 0,
862
+ GPSDestLongitudeRef: void 0,
863
+ GPSDifferential: void 0,
864
+ GPSDOP: void 0,
865
+ GPSHPositioningError: void 0,
866
+ GPSImgDirection: void 0,
867
+ GPSImgDirectionRef: void 0,
868
+ GPSLatitude: void 0,
869
+ GPSLatitudeRef: void 0,
870
+ GPSLongitude: void 0,
871
+ GPSLongitudeRef: void 0,
872
+ GPSMapDatum: void 0,
873
+ GPSMeasureMode: void 0,
874
+ GPSProcessingMethod: void 0,
875
+ GPSTimeStamp: void 0,
876
+ GPSSatellites: void 0,
877
+ GPSSpeed: void 0,
878
+ GPSSpeedRef: void 0,
879
+ GPSStatus: void 0,
880
+ GPSTrack: void 0,
881
+ GPSTrackRef: void 0,
882
+ GPSVersionId: void 0
883
+ },
884
+ interoperability: {
885
+ InteropIndex: void 0,
886
+ InteropVersion: void 0
887
+ },
888
+ makernote: {
889
+ AutoBracketing: void 0,
890
+ BlurWarning: void 0,
891
+ ExposureWarning: void 0,
892
+ error: void 0,
893
+ FlashExposureComp: void 0,
894
+ FocusMode: void 0,
895
+ FocusWarning: void 0,
896
+ FujiFlashMode: void 0,
897
+ Macro: void 0,
898
+ Quality: void 0,
899
+ Sharpness: void 0,
900
+ SlowSync: void 0,
901
+ Version: void 0,
902
+ WhiteBalance: void 0
903
+ },
904
+ image: {
905
+ Artist: void 0,
906
+ Copyright: void 0,
907
+ ExifOffset: void 0,
908
+ ImageHeight: void 0,
909
+ ImageWidth: void 0,
910
+ Make: void 0,
911
+ Model: void 0,
912
+ ModifyDate: void 0,
913
+ Orientation: void 0,
914
+ ResolutionUnit: void 0,
915
+ Software: void 0,
916
+ XResolution: void 0,
917
+ YCbCrPositioning: void 0,
918
+ YResolution: void 0
919
+ }
920
+ }
921
+ }
922
+ },
923
+ {
924
+ id: "6",
925
+ type: {
926
+ code: "image",
927
+ name: "Image"
928
+ },
929
+ status: {
930
+ code: "live",
931
+ name: "Live"
932
+ },
933
+ source: {
934
+ id: "1",
935
+ type: "matrix"
936
+ },
937
+ name: "Example image two #2",
938
+ childCount: 0,
939
+ url: "https://picsum.photos/200/300",
940
+ urls: [],
941
+ squizImage: {
942
+ name: "My Image",
943
+ alt: "My Image that did not load",
944
+ caption: "This above is a loaded image",
945
+ imageVariations: {
946
+ original: {
947
+ url: "http://example.com/image.jpg",
948
+ width: 100,
949
+ height: 100,
950
+ byteSize: 1e3,
951
+ mimeType: "image/jpeg",
952
+ aspectRatio: "1:1",
953
+ sha1Hash: "1234567890abcdef1234567890abcdef12345678"
954
+ }
955
+ },
956
+ exif: {
957
+ thumbnail: {
958
+ Compression: void 0,
959
+ Orientation: void 0,
960
+ ResolutionUnit: void 0,
961
+ ThumbnailLength: void 0,
962
+ ThumbnailOffset: void 0,
963
+ XResolution: void 0,
964
+ YCbCrPositioning: void 0,
965
+ YResolution: void 0
966
+ },
967
+ exif: {
968
+ ApertureValue: void 0,
969
+ BrightnessValue: void 0,
970
+ ColorSpace: void 0,
971
+ ComponentsConfiguration: void 0,
972
+ CompressedBitsPerPixel: void 0,
973
+ CreateDate: void 0,
974
+ DateTimeOriginal: void 0,
975
+ ExifImageHeight: void 0,
976
+ ExifImageWidth: void 0,
977
+ ExifVersion: void 0,
978
+ ExposureCompensation: void 0,
979
+ ExposureMode: void 0,
980
+ ExposureProgram: void 0,
981
+ ExposureTime: void 0,
982
+ FileSource: void 0,
983
+ Flash: void 0,
984
+ FlashpixVersion: void 0,
985
+ FNumber: void 0,
986
+ FocalLength: void 0,
987
+ FocalLengthIn35mmFormat: void 0,
988
+ FocalPlaneResolutionUnit: void 0,
989
+ FocalPlaneXResolution: void 0,
990
+ FocalPlaneYResolution: void 0,
991
+ ImageUniqueID: void 0,
992
+ InteropOffset: void 0,
993
+ ISO: void 0,
994
+ LensMake: void 0,
995
+ LensModel: void 0,
996
+ MakerNote: void 0,
997
+ MaxApertureValue: void 0,
998
+ MeteringMode: void 0,
999
+ SceneCaptureType: void 0,
1000
+ SceneType: void 0,
1001
+ SensingMethod: void 0,
1002
+ ShutterSpeedValue: void 0,
1003
+ UserComment: void 0,
1004
+ WhiteBalance: void 0
1005
+ },
1006
+ gps: {
1007
+ GPSAltitude: void 0,
1008
+ GPSAltitudeRef: void 0,
1009
+ GPSAreaInformation: void 0,
1010
+ GPSDateStamp: void 0,
1011
+ GPSDestBearing: void 0,
1012
+ GPSDestBearingRef: void 0,
1013
+ GPSDestDistance: void 0,
1014
+ GPSDestDistanceRef: void 0,
1015
+ GPSDestLatitude: void 0,
1016
+ GPSDestLatitudeRef: void 0,
1017
+ GPSDestLongitude: void 0,
1018
+ GPSDestLongitudeRef: void 0,
1019
+ GPSDifferential: void 0,
1020
+ GPSDOP: void 0,
1021
+ GPSHPositioningError: void 0,
1022
+ GPSImgDirection: void 0,
1023
+ GPSImgDirectionRef: void 0,
1024
+ GPSLatitude: void 0,
1025
+ GPSLatitudeRef: void 0,
1026
+ GPSLongitude: void 0,
1027
+ GPSLongitudeRef: void 0,
1028
+ GPSMapDatum: void 0,
1029
+ GPSMeasureMode: void 0,
1030
+ GPSProcessingMethod: void 0,
1031
+ GPSTimeStamp: void 0,
1032
+ GPSSatellites: void 0,
1033
+ GPSSpeed: void 0,
1034
+ GPSSpeedRef: void 0,
1035
+ GPSStatus: void 0,
1036
+ GPSTrack: void 0,
1037
+ GPSTrackRef: void 0,
1038
+ GPSVersionId: void 0
1039
+ },
1040
+ interoperability: {
1041
+ InteropIndex: void 0,
1042
+ InteropVersion: void 0
1043
+ },
1044
+ makernote: {
1045
+ AutoBracketing: void 0,
1046
+ BlurWarning: void 0,
1047
+ ExposureWarning: void 0,
1048
+ error: void 0,
1049
+ FlashExposureComp: void 0,
1050
+ FocusMode: void 0,
1051
+ FocusWarning: void 0,
1052
+ FujiFlashMode: void 0,
1053
+ Macro: void 0,
1054
+ Quality: void 0,
1055
+ Sharpness: void 0,
1056
+ SlowSync: void 0,
1057
+ Version: void 0,
1058
+ WhiteBalance: void 0
1059
+ },
1060
+ image: {
1061
+ Artist: void 0,
1062
+ Copyright: void 0,
1063
+ ExifOffset: void 0,
1064
+ ImageHeight: void 0,
1065
+ ImageWidth: void 0,
1066
+ Make: void 0,
1067
+ Model: void 0,
1068
+ ModifyDate: void 0,
1069
+ Orientation: void 0,
1070
+ ResolutionUnit: void 0,
1071
+ Software: void 0,
1072
+ XResolution: void 0,
1073
+ YCbCrPositioning: void 0,
1074
+ YResolution: void 0
1075
+ }
1076
+ }
1077
+ }
1078
+ },
1079
+ {
1080
+ id: "7",
1081
+ type: {
1082
+ code: "page_standard",
1083
+ name: "Standard Page"
1084
+ },
1085
+ status: {
1086
+ code: "live",
1087
+ name: "Live"
1088
+ },
1089
+ source: {
1090
+ id: "1",
1091
+ type: "matrix"
1092
+ },
1093
+ name: "Example page #2",
1094
+ childCount: 0,
1095
+ url: "https://picsum.photos/200/300",
1096
+ urls: []
1097
+ },
1098
+ {
1099
+ id: "8",
1100
+ type: {
1101
+ code: "folder",
1102
+ name: "Folder"
1103
+ },
1104
+ status: {
1105
+ code: "live",
1106
+ name: "Live"
1107
+ },
1108
+ source: {
1109
+ id: "1",
1110
+ type: "matrix"
1111
+ },
1112
+ name: "Example folder #2",
1113
+ childCount: 10,
1114
+ url: "",
1115
+ urls: [],
1116
+ _children: [
1117
+ {
1118
+ id: "9",
1119
+ type: {
1120
+ code: "image",
1121
+ name: "Image"
1122
+ },
1123
+ status: {
1124
+ code: "live",
1125
+ name: "Live"
1126
+ },
1127
+ source: {
1128
+ id: "1",
1129
+ type: "matrix"
1130
+ },
1131
+ name: "Example image one #3",
1132
+ childCount: 0,
1133
+ url: "https://picsum.photos/200/300",
1134
+ urls: [],
1135
+ squizImage: {
1136
+ name: "My Image",
1137
+ alt: "My Image that did not load",
1138
+ caption: "This above is a loaded image",
1139
+ imageVariations: {
1140
+ original: {
1141
+ url: "http://example.com/image.jpg",
1142
+ width: 100,
1143
+ height: 100,
1144
+ byteSize: 1e3,
1145
+ mimeType: "image/jpeg",
1146
+ aspectRatio: "1:1",
1147
+ sha1Hash: "1234567890abcdef1234567890abcdef12345678"
1148
+ }
1149
+ },
1150
+ exif: {
1151
+ thumbnail: {
1152
+ Compression: void 0,
1153
+ Orientation: void 0,
1154
+ ResolutionUnit: void 0,
1155
+ ThumbnailLength: void 0,
1156
+ ThumbnailOffset: void 0,
1157
+ XResolution: void 0,
1158
+ YCbCrPositioning: void 0,
1159
+ YResolution: void 0
1160
+ },
1161
+ exif: {
1162
+ ApertureValue: void 0,
1163
+ BrightnessValue: void 0,
1164
+ ColorSpace: void 0,
1165
+ ComponentsConfiguration: void 0,
1166
+ CompressedBitsPerPixel: void 0,
1167
+ CreateDate: void 0,
1168
+ DateTimeOriginal: void 0,
1169
+ ExifImageHeight: void 0,
1170
+ ExifImageWidth: void 0,
1171
+ ExifVersion: void 0,
1172
+ ExposureCompensation: void 0,
1173
+ ExposureMode: void 0,
1174
+ ExposureProgram: void 0,
1175
+ ExposureTime: void 0,
1176
+ FileSource: void 0,
1177
+ Flash: void 0,
1178
+ FlashpixVersion: void 0,
1179
+ FNumber: void 0,
1180
+ FocalLength: void 0,
1181
+ FocalLengthIn35mmFormat: void 0,
1182
+ FocalPlaneResolutionUnit: void 0,
1183
+ FocalPlaneXResolution: void 0,
1184
+ FocalPlaneYResolution: void 0,
1185
+ ImageUniqueID: void 0,
1186
+ InteropOffset: void 0,
1187
+ ISO: void 0,
1188
+ LensMake: void 0,
1189
+ LensModel: void 0,
1190
+ MakerNote: void 0,
1191
+ MaxApertureValue: void 0,
1192
+ MeteringMode: void 0,
1193
+ SceneCaptureType: void 0,
1194
+ SceneType: void 0,
1195
+ SensingMethod: void 0,
1196
+ ShutterSpeedValue: void 0,
1197
+ UserComment: void 0,
1198
+ WhiteBalance: void 0
1199
+ },
1200
+ gps: {
1201
+ GPSAltitude: void 0,
1202
+ GPSAltitudeRef: void 0,
1203
+ GPSAreaInformation: void 0,
1204
+ GPSDateStamp: void 0,
1205
+ GPSDestBearing: void 0,
1206
+ GPSDestBearingRef: void 0,
1207
+ GPSDestDistance: void 0,
1208
+ GPSDestDistanceRef: void 0,
1209
+ GPSDestLatitude: void 0,
1210
+ GPSDestLatitudeRef: void 0,
1211
+ GPSDestLongitude: void 0,
1212
+ GPSDestLongitudeRef: void 0,
1213
+ GPSDifferential: void 0,
1214
+ GPSDOP: void 0,
1215
+ GPSHPositioningError: void 0,
1216
+ GPSImgDirection: void 0,
1217
+ GPSImgDirectionRef: void 0,
1218
+ GPSLatitude: void 0,
1219
+ GPSLatitudeRef: void 0,
1220
+ GPSLongitude: void 0,
1221
+ GPSLongitudeRef: void 0,
1222
+ GPSMapDatum: void 0,
1223
+ GPSMeasureMode: void 0,
1224
+ GPSProcessingMethod: void 0,
1225
+ GPSTimeStamp: void 0,
1226
+ GPSSatellites: void 0,
1227
+ GPSSpeed: void 0,
1228
+ GPSSpeedRef: void 0,
1229
+ GPSStatus: void 0,
1230
+ GPSTrack: void 0,
1231
+ GPSTrackRef: void 0,
1232
+ GPSVersionId: void 0
1233
+ },
1234
+ interoperability: {
1235
+ InteropIndex: void 0,
1236
+ InteropVersion: void 0
1237
+ },
1238
+ makernote: {
1239
+ AutoBracketing: void 0,
1240
+ BlurWarning: void 0,
1241
+ ExposureWarning: void 0,
1242
+ error: void 0,
1243
+ FlashExposureComp: void 0,
1244
+ FocusMode: void 0,
1245
+ FocusWarning: void 0,
1246
+ FujiFlashMode: void 0,
1247
+ Macro: void 0,
1248
+ Quality: void 0,
1249
+ Sharpness: void 0,
1250
+ SlowSync: void 0,
1251
+ Version: void 0,
1252
+ WhiteBalance: void 0
1253
+ },
1254
+ image: {
1255
+ Artist: void 0,
1256
+ Copyright: void 0,
1257
+ ExifOffset: void 0,
1258
+ ImageHeight: void 0,
1259
+ ImageWidth: void 0,
1260
+ Make: void 0,
1261
+ Model: void 0,
1262
+ ModifyDate: void 0,
1263
+ Orientation: void 0,
1264
+ ResolutionUnit: void 0,
1265
+ Software: void 0,
1266
+ XResolution: void 0,
1267
+ YCbCrPositioning: void 0,
1268
+ YResolution: void 0
1269
+ }
1270
+ }
1271
+ }
1272
+ },
1273
+ {
1274
+ id: "10",
1275
+ type: {
1276
+ code: "image",
1277
+ name: "Image"
1278
+ },
1279
+ status: {
1280
+ code: "live",
1281
+ name: "Live"
1282
+ },
1283
+ source: {
1284
+ id: "1",
1285
+ type: "matrix"
1286
+ },
1287
+ name: "Example image two #3",
1288
+ childCount: 0,
1289
+ url: "https://picsum.photos/200/300",
1290
+ urls: [],
1291
+ squizImage: {
1292
+ name: "My Image",
1293
+ alt: "My Image that did not load",
1294
+ caption: "This above is a loaded image",
1295
+ imageVariations: {
1296
+ original: {
1297
+ url: "http://example.com/image.jpg",
1298
+ width: 100,
1299
+ height: 100,
1300
+ byteSize: 1e3,
1301
+ mimeType: "image/jpeg",
1302
+ aspectRatio: "1:1",
1303
+ sha1Hash: "1234567890abcdef1234567890abcdef12345678"
1304
+ }
1305
+ },
1306
+ exif: {
1307
+ thumbnail: {
1308
+ Compression: void 0,
1309
+ Orientation: void 0,
1310
+ ResolutionUnit: void 0,
1311
+ ThumbnailLength: void 0,
1312
+ ThumbnailOffset: void 0,
1313
+ XResolution: void 0,
1314
+ YCbCrPositioning: void 0,
1315
+ YResolution: void 0
1316
+ },
1317
+ exif: {
1318
+ ApertureValue: void 0,
1319
+ BrightnessValue: void 0,
1320
+ ColorSpace: void 0,
1321
+ ComponentsConfiguration: void 0,
1322
+ CompressedBitsPerPixel: void 0,
1323
+ CreateDate: void 0,
1324
+ DateTimeOriginal: void 0,
1325
+ ExifImageHeight: void 0,
1326
+ ExifImageWidth: void 0,
1327
+ ExifVersion: void 0,
1328
+ ExposureCompensation: void 0,
1329
+ ExposureMode: void 0,
1330
+ ExposureProgram: void 0,
1331
+ ExposureTime: void 0,
1332
+ FileSource: void 0,
1333
+ Flash: void 0,
1334
+ FlashpixVersion: void 0,
1335
+ FNumber: void 0,
1336
+ FocalLength: void 0,
1337
+ FocalLengthIn35mmFormat: void 0,
1338
+ FocalPlaneResolutionUnit: void 0,
1339
+ FocalPlaneXResolution: void 0,
1340
+ FocalPlaneYResolution: void 0,
1341
+ ImageUniqueID: void 0,
1342
+ InteropOffset: void 0,
1343
+ ISO: void 0,
1344
+ LensMake: void 0,
1345
+ LensModel: void 0,
1346
+ MakerNote: void 0,
1347
+ MaxApertureValue: void 0,
1348
+ MeteringMode: void 0,
1349
+ SceneCaptureType: void 0,
1350
+ SceneType: void 0,
1351
+ SensingMethod: void 0,
1352
+ ShutterSpeedValue: void 0,
1353
+ UserComment: void 0,
1354
+ WhiteBalance: void 0
1355
+ },
1356
+ gps: {
1357
+ GPSAltitude: void 0,
1358
+ GPSAltitudeRef: void 0,
1359
+ GPSAreaInformation: void 0,
1360
+ GPSDateStamp: void 0,
1361
+ GPSDestBearing: void 0,
1362
+ GPSDestBearingRef: void 0,
1363
+ GPSDestDistance: void 0,
1364
+ GPSDestDistanceRef: void 0,
1365
+ GPSDestLatitude: void 0,
1366
+ GPSDestLatitudeRef: void 0,
1367
+ GPSDestLongitude: void 0,
1368
+ GPSDestLongitudeRef: void 0,
1369
+ GPSDifferential: void 0,
1370
+ GPSDOP: void 0,
1371
+ GPSHPositioningError: void 0,
1372
+ GPSImgDirection: void 0,
1373
+ GPSImgDirectionRef: void 0,
1374
+ GPSLatitude: void 0,
1375
+ GPSLatitudeRef: void 0,
1376
+ GPSLongitude: void 0,
1377
+ GPSLongitudeRef: void 0,
1378
+ GPSMapDatum: void 0,
1379
+ GPSMeasureMode: void 0,
1380
+ GPSProcessingMethod: void 0,
1381
+ GPSTimeStamp: void 0,
1382
+ GPSSatellites: void 0,
1383
+ GPSSpeed: void 0,
1384
+ GPSSpeedRef: void 0,
1385
+ GPSStatus: void 0,
1386
+ GPSTrack: void 0,
1387
+ GPSTrackRef: void 0,
1388
+ GPSVersionId: void 0
1389
+ },
1390
+ interoperability: {
1391
+ InteropIndex: void 0,
1392
+ InteropVersion: void 0
1393
+ },
1394
+ makernote: {
1395
+ AutoBracketing: void 0,
1396
+ BlurWarning: void 0,
1397
+ ExposureWarning: void 0,
1398
+ error: void 0,
1399
+ FlashExposureComp: void 0,
1400
+ FocusMode: void 0,
1401
+ FocusWarning: void 0,
1402
+ FujiFlashMode: void 0,
1403
+ Macro: void 0,
1404
+ Quality: void 0,
1405
+ Sharpness: void 0,
1406
+ SlowSync: void 0,
1407
+ Version: void 0,
1408
+ WhiteBalance: void 0
1409
+ },
1410
+ image: {
1411
+ Artist: void 0,
1412
+ Copyright: void 0,
1413
+ ExifOffset: void 0,
1414
+ ImageHeight: void 0,
1415
+ ImageWidth: void 0,
1416
+ Make: void 0,
1417
+ Model: void 0,
1418
+ ModifyDate: void 0,
1419
+ Orientation: void 0,
1420
+ ResolutionUnit: void 0,
1421
+ Software: void 0,
1422
+ XResolution: void 0,
1423
+ YCbCrPositioning: void 0,
1424
+ YResolution: void 0
1425
+ }
1426
+ }
1427
+ }
1428
+ },
1429
+ {
1430
+ id: "11",
1431
+ type: {
1432
+ code: "page_standard",
1433
+ name: "Standard Page"
1434
+ },
1435
+ status: {
1436
+ code: "live",
1437
+ name: "Live"
1438
+ },
1439
+ source: {
1440
+ id: "1",
1441
+ type: "matrix"
1442
+ },
1443
+ name: "Example page #3",
1444
+ childCount: 0,
1445
+ url: "https://picsum.photos/200/300",
1446
+ urls: []
1447
+ }
1448
+ ]
1449
+ }
1450
+ ]
1451
+ }
1452
+ ];
1453
+
1454
+ // src/webserver/controllers/utils/ReplaceWithMock.ts
1455
+ var typeResolver = import_dx_json_schema_lib2.TypeResolverBuilder.new().addPrimitive(import_dx_json_schema_lib2.SquizImageType).addPrimitive(import_dx_json_schema_lib2.SquizLinkType).addPrimitive(import_dx_json_schema_lib2.FormattedTextType).addResolver(import_dx_json_schema_lib2.SquizImageType, import_dx_json_schema_lib2.MatrixAssetType, ({ matrixAssetId }) => {
1456
+ const resource = resources.find((resource2) => resource2.id == matrixAssetId);
1457
+ return {
1458
+ ...resource["squizImage"]
1459
+ };
1460
+ }).build();
1461
+ function hasSquizType(componentSchema) {
1462
+ if (!componentSchema || typeof componentSchema !== "object") {
1463
+ return false;
1464
+ }
1465
+ const inputSchema = componentSchema.input;
1466
+ if (!inputSchema || typeof inputSchema !== "object" || !inputSchema.properties) {
1467
+ return false;
1468
+ }
1469
+ return Object.values(inputSchema.properties).some(
1470
+ (prop) => prop.type === "SquizImage" || prop.type === "SquizLink"
1471
+ );
1472
+ }
1473
+ async function resolveMock(componentSchema, data) {
1474
+ if (!componentSchema || typeof componentSchema !== "object") {
1475
+ return componentSchema;
1476
+ }
1477
+ const inputSchema = componentSchema.input;
1478
+ if (!inputSchema || typeof inputSchema !== "object" || !inputSchema.properties) {
1479
+ return componentSchema;
1480
+ }
1481
+ const jsonSchemaService = new import_dx_json_schema_lib2.JSONSchemaService(typeResolver, import_dx_json_schema_lib2.ComponentInputMetaSchema);
1482
+ const resolvedInput = await jsonSchemaService.resolveInput(data, inputSchema);
1483
+ return resolvedInput;
1484
+ }
1485
+
203
1486
  // src/webserver/controllers/DevelopmentController.ts
204
1487
  var UPPERCASE_REGEX = /[A-Z]/;
205
1488
  var DevelopmentController = class extends import_tsoa3.Controller {
@@ -236,7 +1519,7 @@ var DevelopmentController = class extends import_tsoa3.Controller {
236
1519
  });
237
1520
  return schemaResult;
238
1521
  }
239
- async TemporaryPreview(req, componentId, functionName, headers, envVars, data, contextMatrixAssetId, contextMatrixUrl) {
1522
+ async TemporaryPreview(req, componentId, functionName, headers3, envVars, data, contextMatrixAssetId, contextMatrixUrl) {
240
1523
  this.checkDevMode();
241
1524
  const { namespace, componentName, version } = getComponentInfoFromComponentId(componentId);
242
1525
  const res = req.res;
@@ -248,6 +1531,9 @@ var DevelopmentController = class extends import_tsoa3.Controller {
248
1531
  const rootUrl = `http://${req.headers.host}`.replace(/\/+$/, "");
249
1532
  const componentManifest = await this.manifestService.loadManifest(namespace, componentName, version);
250
1533
  const componentFunction = componentManifest.getComponentFunctionByName(functionName);
1534
+ if (hasSquizType(componentFunction)) {
1535
+ data = await resolveMock(componentFunction, data);
1536
+ }
251
1537
  const defaultPreviewKey = Object.keys(componentManifest.getModel()?.previews ?? {}).at(0) ?? void 0;
252
1538
  const componentTask = {
253
1539
  requestId: Date.now().toString(),
@@ -268,7 +1554,7 @@ var DevelopmentController = class extends import_tsoa3.Controller {
268
1554
  matrixUrl: contextMatrixUrl
269
1555
  };
270
1556
  let result = componentManifest.type === "edge" ? await this.componentRunnerService.executeEdgeComponentFunction(componentTask, ctx) : await this.componentRunnerService.executeServerComponentFunction(componentTask);
271
- const responseHeaders = headers ?? {};
1557
+ const responseHeaders = headers3 ?? {};
272
1558
  switch (componentFunction.output.responseType) {
273
1559
  case "html":
274
1560
  responseHeaders["content-type"] = "text/html";
@@ -372,16 +1658,16 @@ var DevelopmentController = class extends import_tsoa3.Controller {
372
1658
  return result;
373
1659
  }
374
1660
  setHeadersOnResponse(renderInput, response) {
375
- const headers = renderInput.headers || {};
1661
+ const headers3 = renderInput.headers || {};
376
1662
  switch (renderInput.componentFunction.output.responseType) {
377
1663
  case "html":
378
- headers["content-type"] = "text/html";
1664
+ headers3["content-type"] = "text/html";
379
1665
  break;
380
1666
  case "json":
381
- headers["content-type"] = "application/json";
1667
+ headers3["content-type"] = "application/json";
382
1668
  break;
383
1669
  }
384
- setHeadersOnExpressResponse(headers, response);
1670
+ setHeadersOnExpressResponse(headers3, response);
385
1671
  let cacheControl = response.getHeader("cache-control");
386
1672
  if (typeof cacheControl !== "string") {
387
1673
  cacheControl = void 0;
@@ -476,8 +1762,8 @@ var StaticController = class extends import_tsoa4.Controller {
476
1762
  const componentStaticFileRoot = manifestModel.staticFiles.locationRoot;
477
1763
  const manifestPath = await this.manifestService.getManifestPath(namespace, componentName, version);
478
1764
  const staticFilePathRoot = import_path.default.join(import_path.default.dirname(manifestPath), componentStaticFileRoot);
479
- const headers = await this.getHeadersForInputType(_componentSet, _previewKey, manifest);
480
- this.setResponseHeaders(headers, response);
1765
+ const headers3 = await this.getHeadersForInputType(_componentSet, _previewKey, manifest);
1766
+ this.setResponseHeaders(headers3, response);
481
1767
  response.sendFile(
482
1768
  staticFile,
483
1769
  {
@@ -516,8 +1802,8 @@ var StaticController = class extends import_tsoa4.Controller {
516
1802
  throw new import_dx_common_lib3.ResourceNotFoundError(`${componentName} ${version} doesn't expose any static resources`);
517
1803
  }
518
1804
  }
519
- setResponseHeaders(headers, response) {
520
- setHeadersOnExpressResponse(headers, response);
1805
+ setResponseHeaders(headers3, response) {
1806
+ setHeadersOnExpressResponse(headers3, response);
521
1807
  let cacheControl = response.getHeader("cache-control");
522
1808
  if (typeof cacheControl != "string") {
523
1809
  cacheControl = import_dx_common_lib3.DEFAULT_CACHE_CONTROL_HEADER;
@@ -536,8 +1822,8 @@ var StaticController = class extends import_tsoa4.Controller {
536
1822
  if (_previewKey) {
537
1823
  const previewDefinition = await this.getValidatedPreviewDefinition(_previewKey, manifest.getModel());
538
1824
  const functionPreview = previewDefinition.functionData[manifest.getModel().mainFunction];
539
- const headers = functionPreview?.headers ? functionPreview.headers : {};
540
- return headers;
1825
+ const headers3 = functionPreview?.headers ? functionPreview.headers : {};
1826
+ return headers3;
541
1827
  }
542
1828
  throw new import_dx_common_lib3.BadRequestError(`neither componentSet or previewKey set`);
543
1829
  }
@@ -1019,7 +2305,7 @@ var models = {
1019
2305
  "functions": { "dataType": "array", "array": { "dataType": "refObject", "ref": "ComponentFunction" }, "required": true, "validators": { "minItems": { "value": 0 } } },
1020
2306
  "previews": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "ref": "PreviewDefinition" } },
1021
2307
  "mockedUris": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "path": { "dataType": "string", "required": true }, "type": { "dataType": "enum", "enums": ["file"], "required": true } }, "additionalProperties": { "dataType": "any" } }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "value": { "ref": "MatrixAssetSchema", "required": true }, "type": { "dataType": "enum", "enums": ["inline"], "required": true } }, "additionalProperties": { "dataType": "any" } }] } },
1022
- "ui:metadata": { "dataType": "nestedObjectLiteral", "nestedProperties": { "autoReload": { "dataType": "intersection", "subSchemas": [{ "dataType": "boolean" }, { "dataType": "string" }], "required": true } }, "additionalProperties": { "dataType": "any" } }
2308
+ "ui:metadata": { "dataType": "nestedObjectLiteral", "nestedProperties": { "autoReload": { "dataType": "boolean", "required": true } }, "additionalProperties": { "dataType": "any" } }
1023
2309
  },
1024
2310
  "additionalProperties": false
1025
2311
  },
@@ -1272,20 +2558,20 @@ function RegisterRoutes(app) {
1272
2558
  function promiseHandler(controllerObj, promise, response, successStatus, next) {
1273
2559
  return Promise.resolve(promise).then((data) => {
1274
2560
  let statusCode = successStatus;
1275
- let headers;
2561
+ let headers3;
1276
2562
  if (isController(controllerObj)) {
1277
- headers = controllerObj.getHeaders();
2563
+ headers3 = controllerObj.getHeaders();
1278
2564
  statusCode = controllerObj.getStatus() || statusCode;
1279
2565
  }
1280
- returnHandler(response, statusCode, data, headers);
2566
+ returnHandler(response, statusCode, data, headers3);
1281
2567
  }).catch((error) => next(error));
1282
2568
  }
1283
- function returnHandler(response, statusCode, data, headers = {}) {
2569
+ function returnHandler(response, statusCode, data, headers3 = {}) {
1284
2570
  if (response.headersSent) {
1285
2571
  return;
1286
2572
  }
1287
- Object.keys(headers).forEach((name) => {
1288
- response.set(name, headers[name]);
2573
+ Object.keys(headers3).forEach((name) => {
2574
+ response.set(name, headers3[name]);
1289
2575
  });
1290
2576
  if (data && typeof data.pipe === "function" && data.readable && typeof data._read === "function") {
1291
2577
  response.status(statusCode || 200);
@@ -1297,8 +2583,8 @@ function RegisterRoutes(app) {
1297
2583
  }
1298
2584
  }
1299
2585
  function responder(response) {
1300
- return function(status, data, headers) {
1301
- returnHandler(response, status, data, headers);
2586
+ return function(status, data, headers3) {
2587
+ returnHandler(response, status, data, headers3);
1302
2588
  };
1303
2589
  }
1304
2590
  ;
@@ -1432,10 +2718,8 @@ var ContentRuntimeService = class {
1432
2718
  var import_events = require("events");
1433
2719
  var import_fs = __toESM(require("fs"));
1434
2720
  var esbuild = __toESM(require("esbuild"));
1435
- var import_crypto2 = __toESM(require("crypto"));
1436
2721
  var import_node_path = __toESM(require("node:path"));
1437
2722
  var import_node_vm = __toESM(require("node:vm"));
1438
- var import_os = require("os");
1439
2723
  var import_module = require("module");
1440
2724
  var DevelopmentComponentRunnerService = class {
1441
2725
  async executeEdgeComponentFunction(task, contextAwareness) {
@@ -1619,11 +2903,6 @@ var DevelopmentComponentRunnerService = class {
1619
2903
  };
1620
2904
  return componentContext;
1621
2905
  }
1622
- getOutputLocation(sourceJsFile) {
1623
- const fileInfo = import_fs.default.statSync(sourceJsFile);
1624
- const filenameHash = import_crypto2.default.createHash("md5").update(sourceJsFile).digest("hex");
1625
- return import_node_path.default.join((0, import_os.tmpdir)(), "components", `${filenameHash}_${fileInfo.mtime.getMilliseconds()}.mjs`);
1626
- }
1627
2906
  };
1628
2907
 
1629
2908
  // src/PreviewComponentService.ts
@@ -1760,7 +3039,7 @@ var RenderInputService = class {
1760
3039
  request.expressRequest.query["_previewEnvVars"]
1761
3040
  );
1762
3041
  const publicFacingUrl = this.rootUrlResolver(request.expressRequest, true);
1763
- let headers = {};
3042
+ let headers3 = {};
1764
3043
  let webManifest;
1765
3044
  let input = {};
1766
3045
  if (request.previewKey && request.componentSet) {
@@ -1775,14 +3054,14 @@ var RenderInputService = class {
1775
3054
  );
1776
3055
  const previewFunctionConfig = manifest.getFunctionPreviewConfiguration(request.previewKey, componentFunction);
1777
3056
  if (previewFunctionConfig && previewFunctionConfig.headers) {
1778
- headers = previewFunctionConfig.headers;
3057
+ headers3 = previewFunctionConfig.headers;
1779
3058
  }
1780
3059
  } else {
1781
3060
  if (!request.componentSet) {
1782
3061
  throw new import_dx_common_lib6.BadRequestError("You must provide either previewKey or a componentSet as input");
1783
3062
  }
1784
3063
  const set = await this.componentSetService.getComponentSet(request.componentSet);
1785
- headers = this.componentSetService.getComponentRuntimeHeaders(set, componentFunction);
3064
+ headers3 = this.componentSetService.getComponentRuntimeHeaders(set, componentFunction);
1786
3065
  webManifest = this.componentFunctionService.prepareManifestForWebResponse(
1787
3066
  manifest,
1788
3067
  runtimeSet.webPath,
@@ -1801,7 +3080,7 @@ var RenderInputService = class {
1801
3080
  manifest,
1802
3081
  manifestForWeb: webManifest,
1803
3082
  componentFullName: manifest.getName(),
1804
- headers,
3083
+ headers: headers3,
1805
3084
  runtimeSet,
1806
3085
  manifestPath: await manifest.getManifestPath(),
1807
3086
  queryParameters: this.getQueryParametersFromRequest(request, componentFunction)
@@ -1888,7 +3167,7 @@ var import_component_logger_lib = require("@squiz/component-logger-lib");
1888
3167
  var testLogger = (0, import_dx_logger_lib.getLogger)({
1889
3168
  name: "render-runtime-lib-test",
1890
3169
  meta: {
1891
- hostname: import_os2.default.hostname(),
3170
+ hostname: import_os.default.hostname(),
1892
3171
  pid: process.pid
1893
3172
  },
1894
3173
  silent: true
@@ -1977,7 +3256,7 @@ var TestServer = class {
1977
3256
  var import_promises2 = __toESM(require("fs/promises"));
1978
3257
  var import_path5 = __toESM(require("path"));
1979
3258
  var import_strict2 = __toESM(require("assert/strict"));
1980
- var import_crypto3 = require("crypto");
3259
+ var import_crypto2 = require("crypto");
1981
3260
  var FIXTURE_NAMESPACE = "some-namespace";
1982
3261
  var ComponentFixture = class {
1983
3262
  static {
@@ -2110,30 +3389,29 @@ function getTestSet() {
2110
3389
  };
2111
3390
  }
2112
3391
  function generateRandomName() {
2113
- return "test-" + (0, import_crypto3.randomUUID)();
3392
+ return "test-" + (0, import_crypto2.randomUUID)();
2114
3393
  }
2115
3394
 
2116
3395
  // src/webserver/controllers/test/render-route-tests.ts
3396
+ var CLOUDFLARE_X_API_KEY_HEADER = "x-cloudflare-key";
3397
+ var CLOUDFLARE_X_API_KEY = "x-cloudflare-key";
3398
+ var headers = {
3399
+ [CLOUDFLARE_X_API_KEY_HEADER]: CLOUDFLARE_X_API_KEY
3400
+ };
2117
3401
  function renderRouteTests(request, _rootUrl) {
2118
3402
  describe("GET /dev/render/unit-test-components__test-component__1.0.10/?_componentSet=set", () => {
2119
3403
  it("should render the test component with html endpoint", async () => {
2120
- const response = await request().get(
2121
- "/dev/render/unit-test-components__test-component__1.0.10?_componentSet=set&something=unused"
2122
- );
3404
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.10?_componentSet=set&something=unused").set(headers);
2123
3405
  expect(response.text).toEqual("<div>hello - {}</div>");
2124
3406
  expect(response.statusCode).toEqual(200);
2125
3407
  }, 2e4);
2126
3408
  it("should render the test component promise endpoint with html endpoint", async () => {
2127
- const response = await request().get(
2128
- "/dev/render/unit-test-components__test-component__1.0.10/promise?_componentSet=set&something=unused"
2129
- );
3409
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.10/promise?_componentSet=set&something=unused").set(headers);
2130
3410
  expect(response.statusCode).toEqual(200);
2131
3411
  expect(response.text).toEqual("<h1>hello</h1>");
2132
3412
  }, 2e4);
2133
3413
  it("should fail validation if input contract is not met and helpful message returned", async () => {
2134
- const response = await request().get(
2135
- "/dev/render/unit-test-components__test-component__1.0.0?_componentSet=set&something=unused"
2136
- );
3414
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.0?_componentSet=set&something=unused").set(headers);
2137
3415
  expect(response.statusCode).toEqual(400);
2138
3416
  expect(response.body).toMatchInlineSnapshot(`
2139
3417
  {
@@ -2144,7 +3422,7 @@ function renderRouteTests(request, _rootUrl) {
2144
3422
  it("should 404 if requesting a non-existent function on an otherwise valid component", async () => {
2145
3423
  const response = await request().get(
2146
3424
  "/dev/render/unit-test-components__test-component__1.0.0/non-existent-entry-file?_componentSet=set&something=not-used"
2147
- );
3425
+ ).set(headers);
2148
3426
  expect(response.statusCode).toEqual(404);
2149
3427
  expect(response.body).toMatchInlineSnapshot(`
2150
3428
  {
@@ -2155,9 +3433,7 @@ function renderRouteTests(request, _rootUrl) {
2155
3433
  });
2156
3434
  describe("GET /dev/render/unit-test-components__test-component__1.0.3/main?_componentSet=set", () => {
2157
3435
  it("should fail validation when requesting a function with a missing entry file", async () => {
2158
- const response = await request().get(
2159
- "/dev/render/unit-test-components__test-component__1.0.3/main?_componentSet=set&something=not-used"
2160
- );
3436
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.3/main?_componentSet=set&something=not-used").set(headers);
2161
3437
  expect(response.body).toEqual({
2162
3438
  message: `"main's" entry file "missing-entry-file.js" is inaccessible`
2163
3439
  });
@@ -2166,7 +3442,7 @@ function renderRouteTests(request, _rootUrl) {
2166
3442
  });
2167
3443
  describe("GET /dev/render/unit-test-components__test-component__1.0.4?_componentSet=set", () => {
2168
3444
  it("should render a simple json endpoint", async () => {
2169
- const response = await request().get("/dev/render/unit-test-components__test-component__1.0.4?_componentSet=set");
3445
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.4?_componentSet=set").set(headers);
2170
3446
  expect(response.headers["content-type"]).toContain("application/json");
2171
3447
  expect(response.body).toEqual({
2172
3448
  "my-prop": "test value for my-prop",
@@ -2179,9 +3455,7 @@ function renderRouteTests(request, _rootUrl) {
2179
3455
  });
2180
3456
  }, 2e4);
2181
3457
  it("should report error if response does not match with the schema", async () => {
2182
- const response = await request().get(
2183
- "/dev/render/unit-test-components__test-component__1.0.4/render_json_invalid?_componentSet=set"
2184
- );
3458
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.4/render_json_invalid?_componentSet=set").set(headers);
2185
3459
  expect(response.statusCode).toEqual(500);
2186
3460
  expect(response.headers["content-type"]).toEqual("application/json; charset=utf-8");
2187
3461
  expect(response.body).toEqual({
@@ -2191,7 +3465,7 @@ function renderRouteTests(request, _rootUrl) {
2191
3465
  it("should validate a complex json against a schema", async () => {
2192
3466
  const response = await request().get(
2193
3467
  "/dev/render/unit-test-components__test-component__1.0.4/render_json_nested_object_valid?_componentSet=set"
2194
- );
3468
+ ).set(headers);
2195
3469
  const myObject = {
2196
3470
  "my-object": {
2197
3471
  "a-string": "this is a string",
@@ -2207,7 +3481,7 @@ function renderRouteTests(request, _rootUrl) {
2207
3481
  it("should report errors if nested object json schema fails", async () => {
2208
3482
  const response = await request().get(
2209
3483
  "/dev/render/unit-test-components__test-component__1.0.4/render_json_nested_object_invalid?_componentSet=set"
2210
- );
3484
+ ).set(headers);
2211
3485
  expect(response.statusCode).toEqual(500);
2212
3486
  expect(response.headers["content-type"]).toEqual("application/json; charset=utf-8");
2213
3487
  expect(response.body).toEqual({
@@ -2220,7 +3494,7 @@ Expected given value \`N\` in #/my-object/a-nested-object/an-enum\` to be one of
2220
3494
  it('should return input and info object with "query parameters"', async () => {
2221
3495
  const response = await request().get(
2222
3496
  "/dev/render/unit-test-components__test-component__1.0.7?_componentSet=set&something=hello-test&foo=foo-val&foo2=foo2-val"
2223
- );
3497
+ ).set(headers);
2224
3498
  expect(response.headers["content-type"]).toContain("application/json");
2225
3499
  const result = response.body;
2226
3500
  expect(result).toEqual([
@@ -2298,18 +3572,14 @@ Expected given value \`N\` in #/my-object/a-nested-object/an-enum\` to be one of
2298
3572
  });
2299
3573
  });
2300
3574
  it("should throw error if required query parameter is missing", async () => {
2301
- const response = await request().get(
2302
- "/dev/render/unit-test-components__test-component__1.0.7?_componentSet=set&foo2=foo2-val"
2303
- );
3575
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.7?_componentSet=set&foo2=foo2-val").set(headers);
2304
3576
  expect(response.body).toEqual({
2305
3577
  message: "Required query parameter 'foo' is missing"
2306
3578
  });
2307
3579
  expect(response.statusCode).toEqual(400);
2308
3580
  });
2309
3581
  it("should throw error if query parameter is not a string", async () => {
2310
- const response = await request().get(
2311
- "/dev/render/unit-test-components__test-component__1.0.7?_componentSet=set&foo=123&foo2[]=array-val"
2312
- );
3582
+ const response = await request().get("/dev/render/unit-test-components__test-component__1.0.7?_componentSet=set&foo=123&foo2[]=array-val").set(headers);
2313
3583
  expect(response.body).toEqual({
2314
3584
  message: "Value for query parameter 'foo2' must be a string"
2315
3585
  });
@@ -2317,60 +3587,48 @@ Expected given value \`N\` in #/my-object/a-nested-object/an-enum\` to be one of
2317
3587
  });
2318
3588
  describe("GET /dev/render/unit-test-components__test-headers__1.0.3?_componentSet=set", () => {
2319
3589
  it("should make sure max-age header is clamped between max value", async () => {
2320
- const response = await request().get("/dev/render/unit-test-components__test-headers__1.0.3/max_value?_componentSet=set").send().expect(200, "rendered");
3590
+ const response = await request().get("/dev/render/unit-test-components__test-headers__1.0.3/max_value?_componentSet=set").set({ "x-cloudflare-key": CLOUDFLARE_X_API_KEY }).send().expect(200, "rendered");
2321
3591
  expect(response.headers["cache-control"]).toEqual("max-age=1800, immutable");
2322
3592
  });
2323
3593
  it("should make sure max-age header is clamped between min value", async () => {
2324
- const response = await request().get("/dev/render/unit-test-components__test-headers__1.0.3/min_value?_componentSet=set").send().expect(200, "rendered");
3594
+ const response = await request().get("/dev/render/unit-test-components__test-headers__1.0.3/min_value?_componentSet=set").set({ "x-cloudflare-key": CLOUDFLARE_X_API_KEY }).send().expect(200, "rendered");
2325
3595
  expect(response.headers["cache-control"]).toEqual("max-age=30, public");
2326
3596
  });
2327
3597
  });
2328
3598
  describe("should be able to load external dependencies", () => {
2329
3599
  it("should be able to make web requests out", async () => {
2330
- const response = await request().get(
2331
- "/dev/render/unit-test-components__test-npm-modules__3.0.0?_componentSet=set"
2332
- );
3600
+ const response = await request().get("/dev/render/unit-test-components__test-npm-modules__3.0.0?_componentSet=set").set(headers);
2333
3601
  expect(response.statusCode).toEqual(200);
2334
3602
  expect(response.text).toContain(`<h1>Example Domain</h1>`);
2335
3603
  });
2336
3604
  });
2337
3605
  describe("GET /dev/render/unit-test-components__test-formatted-text__1.0.0", () => {
2338
3606
  it("should render a component formattedText in preview inline", async () => {
2339
- const response = await request().get(
2340
- "/dev/render/unit-test-components__test-formatted-text__1.0.0?_previewKey=valid-inline-preview"
2341
- );
3607
+ const response = await request().get("/dev/render/unit-test-components__test-formatted-text__1.0.0?_previewKey=valid-inline-preview").set(headers);
2342
3608
  expect(response.statusCode).toEqual(200);
2343
3609
  expect(response.text).toMatchInlineSnapshot(`"This is a test"`);
2344
3610
  });
2345
3611
  });
2346
3612
  describe("GET /dev/render/unit-test-components__test-npm-modules__3.1.0", () => {
2347
3613
  it("should render a component with uuid", async () => {
2348
- const response = await request().get(
2349
- "/dev/render/unit-test-components__test-npm-modules__3.1.0/uuid?_componentSet=set"
2350
- );
3614
+ const response = await request().get("/dev/render/unit-test-components__test-npm-modules__3.1.0/uuid?_componentSet=set").set(headers);
2351
3615
  expect(response.statusCode).toEqual(200);
2352
3616
  });
2353
3617
  it("should render a component with Buffer", async () => {
2354
- const response = await request().get(
2355
- "/dev/render/unit-test-components__test-npm-modules__3.1.0/buffer?_componentSet=set"
2356
- );
3618
+ const response = await request().get("/dev/render/unit-test-components__test-npm-modules__3.1.0/buffer?_componentSet=set").set(headers);
2357
3619
  expect(response.statusCode).toEqual(200);
2358
3620
  });
2359
3621
  });
2360
3622
  describe("GET /dev/render/unit-test-components__test-squiz-image__1.0.0", () => {
2361
3623
  it("should render the preview", async () => {
2362
- const response = await request().get(
2363
- "/dev/render/unit-test-components__test-squiz-image__1.0.0?_previewKey=valid-inline-preview"
2364
- );
3624
+ const response = await request().get("/dev/render/unit-test-components__test-squiz-image__1.0.0?_previewKey=valid-inline-preview").set(headers);
2365
3625
  expect(response.statusCode).toEqual(200);
2366
3626
  expect(response.text).toMatchInlineSnapshot(`"My Image Component"`);
2367
3627
  });
2368
3628
  });
2369
3629
  describe("GET /dev/render/unit-test-components__test-squiz-link__1.0.0", () => {
2370
3630
  it("should render the preview", async () => {
2371
- const response = await request().get(
2372
- "/dev/render/unit-test-components__test-squiz-link__1.0.0?_previewKey=valid-inline-preview"
2373
- );
3631
+ const response = await request().get("/dev/render/unit-test-components__test-squiz-link__1.0.0?_previewKey=valid-inline-preview").set(headers);
2374
3632
  expect(response.statusCode).toEqual(200);
2375
3633
  expect(response.text).toMatchInlineSnapshot(`"{"link":{"text":"My Link","url":"https://some.link/foo"}}"`);
2376
3634
  });
@@ -2378,16 +3636,21 @@ Expected given value \`N\` in #/my-object/a-nested-object/an-enum\` to be one of
2378
3636
  }
2379
3637
 
2380
3638
  // src/webserver/controllers/test/preview-route-tests.ts
3639
+ var CLOUDFLARE_X_API_KEY_HEADER2 = "x-cloudflare-key";
3640
+ var CLOUDFLARE_X_API_KEY2 = "x-cloudflare-key";
3641
+ var headers2 = {
3642
+ [CLOUDFLARE_X_API_KEY_HEADER2]: CLOUDFLARE_X_API_KEY2
3643
+ };
2381
3644
  function previewRouteTests(request, _rootUrl = "${rootUrl}") {
2382
3645
  describe("preview routes", () => {
2383
3646
  it("should render a preview of a component with no wrapper file", async () => {
2384
- await request().get("/dev/render/unit-test-components__test-preview-component__1.2.4?_previewKey=test-preview").expect(200).expect("content-type", "text/html; charset=utf-8").expect("800 | this is nested content");
3647
+ await request().get("/dev/render/unit-test-components__test-preview-component__1.2.4?_previewKey=test-preview").set(headers2).expect(200).expect("content-type", "text/html; charset=utf-8").expect("800 | this is nested content");
2385
3648
  });
2386
3649
  it("should render a preview of a component with a different preset", async () => {
2387
- await request().get("/dev/render/unit-test-components__test-preview-component__1.2.4?_previewKey=another-preview").expect(200).expect("content-type", "text/html; charset=utf-8").expect("12300 | this is also nested content");
3650
+ await request().get("/dev/render/unit-test-components__test-preview-component__1.2.4?_previewKey=another-preview").set(headers2).expect(200).expect("content-type", "text/html; charset=utf-8").expect("12300 | this is also nested content");
2388
3651
  });
2389
3652
  it("should render a preview of a component non-main function with a wrapper html file", async () => {
2390
- await request().get("/dev/render/unit-test-components__test-preview-component__1.2.4/other?_previewKey=another-preview").expect(200).expect("content-type", "text/html; charset=utf-8").expect((a) => {
3653
+ await request().get("/dev/render/unit-test-components__test-preview-component__1.2.4/other?_previewKey=another-preview").set(headers2).expect(200).expect("content-type", "text/html; charset=utf-8").expect((a) => {
2391
3654
  expect(a.text).toMatchInlineSnapshot(`
2392
3655
  "<!DOCTYPE html>
2393
3656
  <html lang="en">
@@ -2406,30 +3669,24 @@ function previewRouteTests(request, _rootUrl = "${rootUrl}") {
2406
3669
  });
2407
3670
  });
2408
3671
  it("should load the defined preview for a given preview key", async () => {
2409
- const response = await request().get(
2410
- "/dev/render/unit-test-components__test-preview-component__1.0.3?_previewKey=second-preview"
2411
- );
3672
+ const response = await request().get("/dev/render/unit-test-components__test-preview-component__1.0.3?_previewKey=second-preview").set(headers2);
2412
3673
  expect(response.text).toContain(`<p>Second Preview</p>`);
2413
3674
  expect(response.statusCode).toEqual(200);
2414
3675
  });
2415
3676
  it("should give meaningful error when preview key is invalid", async () => {
2416
- const response = await request().get(
2417
- "/dev/render/unit-test-components__test-preview-component__1.0.3?_previewKey=invalid"
2418
- );
3677
+ const response = await request().get("/dev/render/unit-test-components__test-preview-component__1.0.3?_previewKey=invalid").set(headers2);
2419
3678
  expect(response.text).toEqual(
2420
3679
  `{"message":"Component has not defined preview with key \\"invalid\\", the defined preview keys for this component are \\"first-preview, second-preview, test-preview\\""}`
2421
3680
  );
2422
3681
  expect(response.statusCode).toEqual(404);
2423
3682
  });
2424
3683
  it("should render inline preview data through to component", async () => {
2425
- const response = await request().get(
2426
- "/dev/render/unit-test-components__test-preview-component__1.0.4?_previewKey=test-preview"
2427
- );
3684
+ const response = await request().get("/dev/render/unit-test-components__test-preview-component__1.0.4?_previewKey=test-preview").set(headers2);
2428
3685
  expect(response.text).toContain(`this is a result | 123`);
2429
3686
  expect(response.statusCode).toEqual(200);
2430
3687
  }, 1e4);
2431
3688
  it("should resolve URIs to mocked URI object in preview route", async () => {
2432
- await request().get("/dev/render/unit-test-components__test-preview-component__1.1.1?_previewKey=test-preview").expect(200).expect((a) => {
3689
+ await request().get("/dev/render/unit-test-components__test-preview-component__1.1.1?_previewKey=test-preview").set(headers2).expect(200).expect((a) => {
2433
3690
  expect(a.text).toMatchInlineSnapshot(`
2434
3691
  "
2435
3692
  inline:{"id":"id-inline","type":"root_folder","type_name":"Root Folder","version":"0.0.1","name":"Root Folder","short_name":"/","status":{"id":2,"code":"under_construction"},"created":{"date":"2020-02-27T09:47:27+11:00","user_id":null},"updated":{"date":"2020-02-27T09:47:27+11:00","user_id":""},"published":{"date":"2020-02-27T09:47:27+11:00","user_id":"null"},"status_changed":{"date":"2020-02-27T09:47:27+11:00","user_id":"null"},"url":"xxx","urls":[],"attributes":{"test":"test"},"additional":{}}